diff --git a/dist/markdown-it-imsize.js b/dist/markdown-it-imsize.js index e191f12ed2b147a54bbfbe2108e075773ee84aad..155b032969913187ac5af6f3705ba2e910311380 100644 --- a/dist/markdown-it-imsize.js +++ b/dist/markdown-it-imsize.js @@ -11,41 +11,41 @@ return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; -/******/ + /******/ // The require function /******/ function __webpack_require__(moduleId) { -/******/ + /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) /******/ return installedModules[moduleId].exports; -/******/ + /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ exports: {}, /******/ id: moduleId, /******/ loaded: false /******/ }; -/******/ + /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ + /******/ // Flag the module as loaded /******/ module.loaded = true; -/******/ + /******/ // Return the exports of the module /******/ return module.exports; /******/ } -/******/ -/******/ + + /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; -/******/ + /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; -/******/ + /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; -/******/ + /******/ // Load entry module and return exports /******/ return __webpack_require__(0); /******/ }) @@ -298,7 +298,7 @@ return /******/ (function(modules) { // webpackBootstrap code = str.charCodeAt(pos); - while (pos < max && (code >= 0x30 /* 0 */ && code <= 0x39 /* 9 */)) { + while (pos < max && (code >= 0x30 /* 0 */ && code <= 0x39 /* 9 */) || code === 0x25 /* % */) { code = str.charCodeAt(++pos); } @@ -468,8 +468,8 @@ return /******/ (function(modules) { // webpackBootstrap return lookup(buffer, filepath); } }; - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(16).Buffer)) + + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8).Buffer)) /***/ }, /* 4 */ @@ -503,22 +503,22 @@ return /******/ (function(modules) { // webpackBootstrap /***/ function(module, exports, __webpack_require__) { var map = { - "./bmp": 8, - "./bmp.js": 8, - "./gif": 9, - "./gif.js": 9, - "./jpg": 10, - "./jpg.js": 10, - "./png": 11, - "./png.js": 11, - "./psd": 12, - "./psd.js": 12, - "./svg": 13, - "./svg.js": 13, - "./tiff": 14, - "./tiff.js": 14, - "./webp": 15, - "./webp.js": 15 + "./bmp": 9, + "./bmp.js": 9, + "./gif": 10, + "./gif.js": 10, + "./jpg": 11, + "./jpg.js": 11, + "./png": 12, + "./png.js": 12, + "./psd": 13, + "./psd.js": 13, + "./svg": 14, + "./svg.js": 14, + "./tiff": 15, + "./tiff.js": 15, + "./webp": 16, + "./webp.js": 16 }; function webpackContext(req) { return __webpack_require__(webpackContextResolve(req)); @@ -777,1531 +777,1810 @@ return /******/ (function(modules) { // webpackBootstrap return str.substr(start, len); } ; - + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(19))) /***/ }, /* 8 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; - - function isBMP (buffer) { - return ('BM' === buffer.toString('ascii', 0, 2)); - } + /* WEBPACK VAR INJECTION */(function(Buffer) {/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org> + * @license MIT + */ - function calculate (buffer) { - return { - 'width': buffer.readUInt32LE(18), - 'height': buffer.readUInt32LE(22) - }; - } + var base64 = __webpack_require__(22) + var ieee754 = __webpack_require__(20) + var isArray = __webpack_require__(21) - module.exports = { - 'detect': isBMP, - 'calculate': calculate - }; + exports.Buffer = Buffer + exports.SlowBuffer = SlowBuffer + exports.INSPECT_MAX_BYTES = 50 + Buffer.poolSize = 8192 // not used by this implementation + var kMaxLength = 0x3fffffff + var rootParent = {} -/***/ }, -/* 9 */ -/***/ function(module, exports, __webpack_require__) { + /** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Use Object implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * Note: + * + * - Implementation must support adding new properties to `Uint8Array` instances. + * Firefox 4-29 lacked support, fixed in Firefox 30+. + * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. + * + * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. + * + * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of + * incorrect length in some situations. + * + * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they will + * get the Object implementation, which is slower but will work correctly. + */ + Buffer.TYPED_ARRAY_SUPPORT = (function () { + try { + var buf = new ArrayBuffer(0) + var arr = new Uint8Array(buf) + arr.foo = function () { return 42 } + return arr.foo() === 42 && // typed array instances can be augmented + typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` + new Uint8Array(1).subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` + } catch (e) { + return false + } + })() - 'use strict'; + /** + * Class: Buffer + * ============= + * + * The Buffer constructor returns instances of `Uint8Array` that are augmented + * with function properties for all the node `Buffer` API functions. We use + * `Uint8Array` so that square bracket notation works as expected -- it returns + * a single octet. + * + * By augmenting the instances, we can avoid modifying the `Uint8Array` + * prototype. + */ + function Buffer (subject, encoding) { + var self = this + if (!(self instanceof Buffer)) return new Buffer(subject, encoding) - var gifRegexp = /^GIF8[7,9]a/; - function isGIF (buffer) { - var signature = buffer.toString('ascii', 0, 6); - return (gifRegexp.test(signature)); - } + var type = typeof subject + var length - function calculate(buffer) { - return { - 'width': buffer.readUInt16LE(6), - 'height': buffer.readUInt16LE(8) - }; - } + if (type === 'number') { + length = +subject + } else if (type === 'string') { + length = Buffer.byteLength(subject, encoding) + } else if (type === 'object' && subject !== null) { + // assume object is array-like + if (subject.type === 'Buffer' && isArray(subject.data)) subject = subject.data + length = +subject.length + } else { + throw new TypeError('must start with number, buffer, array or string') + } - module.exports = { - 'detect': isGIF, - 'calculate': calculate - }; + if (length > kMaxLength) { + throw new RangeError('Attempt to allocate Buffer larger than maximum size: 0x' + + kMaxLength.toString(16) + ' bytes') + } -/***/ }, -/* 10 */ -/***/ function(module, exports, __webpack_require__) { + if (length < 0) length = 0 + else length >>>= 0 // coerce to uint32 - 'use strict'; + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Preferred: Return an augmented `Uint8Array` instance for best performance + self = Buffer._augment(new Uint8Array(length)) // eslint-disable-line consistent-this + } else { + // Fallback: Return THIS instance of Buffer (created by `new`) + self.length = length + self._isBuffer = true + } - // NOTE: we only support baseline and progressive JPGs here - // due to the structure of the loader class, we only get a buffer - // with a maximum size of 4096 bytes. so if the SOF marker is outside - // if this range we can't detect the file size correctly. + var i + if (Buffer.TYPED_ARRAY_SUPPORT && typeof subject.byteLength === 'number') { + // Speed optimization -- use set if we're copying from a typed array + self._set(subject) + } else if (isArrayish(subject)) { + // Treat array-ish objects as a byte array + if (Buffer.isBuffer(subject)) { + for (i = 0; i < length; i++) { + self[i] = subject.readUInt8(i) + } + } else { + for (i = 0; i < length; i++) { + self[i] = ((subject[i] % 256) + 256) % 256 + } + } + } else if (type === 'string') { + self.write(subject, 0, encoding) + } else if (type === 'number' && !Buffer.TYPED_ARRAY_SUPPORT) { + for (i = 0; i < length; i++) { + self[i] = 0 + } + } - // TO-DO: handle all JFIFs - var validJFIFMarkers = { - 'ffdb': '0001010101', // Samsung D807 JPEG - 'ffe0': '4a46494600', // Standard JPEG - 'ffe1': '4578696600', // Camera JPEG, with EXIF data - 'ffe2': '4943435f50', // Canon EOS-1D JPEG - 'ffe3': '', // Samsung D500 JPEG - 'ffe8': '5350494646', // SPIFF JPEG - 'ffec': '4475636b79', // Photoshop JPEG - 'ffed': '50686f746f', // Adobe JPEG, Photoshop CMYK buffer - 'ffee': '41646f6265' // Adobe JPEG, Unrecognised (Lightroom??) - }; + if (length > 0 && length <= Buffer.poolSize) self.parent = rootParent - var red = ['\x1B[31m', '\x1B[39m']; - function isJPG (buffer) { //, filepath - var SOIMarker = buffer.toString('hex', 0, 2); - var JFIFMarker = buffer.toString('hex', 2, 4); + return self + } - // not a valid jpeg - if ('ffd8' !== SOIMarker) { - return false; - } + function SlowBuffer (subject, encoding) { + if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding) - // TO-DO: validate the end-bytes of a jpeg file - // use filepath, get the last bytes, check for ffd9 - var got = buffer.toString('hex', 6, 11); - var expected = JFIFMarker && validJFIFMarkers[JFIFMarker]; - if (expected === '') { - console.warn( - red[0] + - 'this looks like a unrecognised jpeg\n' + - 'please report the issue here\n' + - red[1], - '\thttps://github.com/netroy/image-size/issues/new\n' - ); - return false; - } - return (got === expected) || (JFIFMarker === 'ffdb'); + var buf = new Buffer(subject, encoding) + delete buf.parent + return buf } - function extractSize (buffer, i) { - return { - 'height' : buffer.readUInt16BE(i), - 'width' : buffer.readUInt16BE(i + 2) - }; + Buffer.isBuffer = function isBuffer (b) { + return !!(b != null && b._isBuffer) } - function validateBuffer (buffer, i) { - // index should be within buffer limits - if (i > buffer.length) { - throw new TypeError('Corrupt JPG, exceeded buffer limits'); + Buffer.compare = function compare (a, b) { + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError('Arguments must be Buffers') } - // Every JPEG block must begin with a 0xFF - if (buffer[i] !== 0xFF) { - throw new TypeError('Invalid JPG, marker table corrupted'); + + if (a === b) return 0 + + var x = a.length + var y = b.length + for (var i = 0, len = Math.min(x, y); i < len && a[i] === b[i]; i++) {} + if (i !== len) { + x = a[i] + y = b[i] } + if (x < y) return -1 + if (y < x) return 1 + return 0 } - function calculate (buffer) { - - // Skip 5 chars, they are for signature - buffer = buffer.slice(4); + Buffer.isEncoding = function isEncoding (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'binary': + case 'base64': + case 'raw': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false + } + } - var i, next; - while (buffer.length) { - // read length of the next block - i = buffer.readUInt16BE(0); + Buffer.concat = function concat (list, totalLength) { + if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.') - // ensure correct format - validateBuffer(buffer, i); + if (list.length === 0) { + return new Buffer(0) + } else if (list.length === 1) { + return list[0] + } - // 0xFFC0 is baseline(SOF) - // 0xFFC2 is progressive(SOF2) - next = buffer[i + 1]; - if (next === 0xC0 || next === 0xC2) { - return extractSize(buffer, i + 5); + var i + if (totalLength === undefined) { + totalLength = 0 + for (i = 0; i < list.length; i++) { + totalLength += list[i].length } - - // move to the next block - buffer = buffer.slice(i + 2); } - throw new TypeError('Invalid JPG, no size found'); - } - - module.exports = { - 'detect': isJPG, - 'calculate': calculate - }; - - -/***/ }, -/* 11 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var pngSignature = 'PNG\r\n\x1a\n'; - function isPNG (buffer) { - if (pngSignature === buffer.toString('ascii', 1, 8)) { - if ('IHDR' !== buffer.toString('ascii', 12, 16)) { - throw new TypeError('invalid png'); - } - return true; + var buf = new Buffer(totalLength) + var pos = 0 + for (i = 0; i < list.length; i++) { + var item = list[i] + item.copy(buf, pos) + pos += item.length } + return buf } - function calculate (buffer) { - return { - 'width': buffer.readUInt32BE(16), - 'height': buffer.readUInt32BE(20) - }; + Buffer.byteLength = function byteLength (str, encoding) { + var ret + str = str + '' + switch (encoding || 'utf8') { + case 'ascii': + case 'binary': + case 'raw': + ret = str.length + break + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + ret = str.length * 2 + break + case 'hex': + ret = str.length >>> 1 + break + case 'utf8': + case 'utf-8': + ret = utf8ToBytes(str).length + break + case 'base64': + ret = base64ToBytes(str).length + break + default: + ret = str.length + } + return ret } - module.exports = { - 'detect': isPNG, - 'calculate': calculate - }; - - -/***/ }, -/* 12 */ -/***/ function(module, exports, __webpack_require__) { + // pre-set for values that may exist in the future + Buffer.prototype.length = undefined + Buffer.prototype.parent = undefined - 'use strict'; + // toString(encoding, start=0, end=buffer.length) + Buffer.prototype.toString = function toString (encoding, start, end) { + var loweredCase = false - function isPSD (buffer) { - return ('8BPS' === buffer.toString('ascii', 0, 4)); - } + start = start >>> 0 + end = end === undefined || end === Infinity ? this.length : end >>> 0 - function calculate (buffer) { - return { - 'width': buffer.readUInt32BE(18), - 'height': buffer.readUInt32BE(14) - }; - } + if (!encoding) encoding = 'utf8' + if (start < 0) start = 0 + if (end > this.length) end = this.length + if (end <= start) return '' - module.exports = { - 'detect': isPSD, - 'calculate': calculate - }; + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) -/***/ }, -/* 13 */ -/***/ function(module, exports, __webpack_require__) { + case 'ascii': + return asciiSlice(this, start, end) - 'use strict'; + case 'binary': + return binarySlice(this, start, end) - var svgReg = /<svg[^>]+[^>]*>/; - function isSVG (buffer) { - return svgReg.test(buffer); - } + case 'base64': + return base64Slice(this, start, end) - var extractorRegExps = { - 'root': /<svg [^>]+>/, - 'width': /(^|\s)width\s*=\s*"(.+?)"/i, - 'height': /(^|\s)height\s*=\s*"(.+?)"/i, - 'viewbox': /(^|\s)viewbox\s*=\s*"(.+?)"/i - }; + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) - function getRatio (viewbox) { - var ratio = 1; - if (viewbox && viewbox[2]) { - var dim = viewbox[2].split(/\s/g); - if (dim.length === 4) { - dim = dim.map(function (i) { - return parseInt(i, 10); - }); - ratio = (dim[2] - dim[0]) / (dim[3] - dim[1]); + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase() + loweredCase = true } } - return ratio; } - function parse (buffer) { - var body = buffer.toString().replace(/[\r\n\s]+/g, ' '); - var section = body.match(extractorRegExps.root); - var root = section && section[0]; - if (root) { - var width = root.match(extractorRegExps.width); - var height = root.match(extractorRegExps.height); - var viewbox = root.match(extractorRegExps.viewbox); - var ratio = getRatio(viewbox); - return { - 'width': parseInt(width && width[2], 10) || 0, - 'height': parseInt(height && height[2], 10) || 0, - 'ratio': ratio - }; - } + Buffer.prototype.equals = function equals (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 } - function calculate (buffer) { - - var parsed = parse(buffer); - var width = parsed.width; - var height = parsed.height; - var ratio = parsed.ratio; - - if (width && height) { - return { 'width': width, 'height': height }; - } else { - if (width) { - return { 'width': width, 'height': Math.floor(width / ratio) }; - } else if (height) { - return { 'width': Math.floor(height * ratio), 'height': height }; - } else { - throw new TypeError('invalid svg'); - } + Buffer.prototype.inspect = function inspect () { + var str = '' + var max = exports.INSPECT_MAX_BYTES + if (this.length > 0) { + str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') + if (this.length > max) str += ' ... ' } + return '<Buffer ' + str + '>' } - module.exports = { - 'detect': isSVG, - 'calculate': calculate - }; + Buffer.prototype.compare = function compare (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return 0 + return Buffer.compare(this, b) + } + Buffer.prototype.indexOf = function indexOf (val, byteOffset) { + if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff + else if (byteOffset < -0x80000000) byteOffset = -0x80000000 + byteOffset >>= 0 -/***/ }, -/* 14 */ -/***/ function(module, exports, __webpack_require__) { + if (this.length === 0) return -1 + if (byteOffset >= this.length) return -1 - /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict'; + // Negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0) - // based on http://www.compix.com/fileformattif.htm - // TO-DO: support big-endian as well + if (typeof val === 'string') { + if (val.length === 0) return -1 // special case: looking for empty string always fails + return String.prototype.indexOf.call(this, val, byteOffset) + } + if (Buffer.isBuffer(val)) { + return arrayIndexOf(this, val, byteOffset) + } + if (typeof val === 'number') { + if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') { + return Uint8Array.prototype.indexOf.call(this, val, byteOffset) + } + return arrayIndexOf(this, [ val ], byteOffset) + } - var fs = __webpack_require__(17); - var readUInt = __webpack_require__(18); + function arrayIndexOf (arr, val, byteOffset) { + var foundIndex = -1 + for (var i = 0; byteOffset + i < arr.length; i++) { + if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex + } else { + foundIndex = -1 + } + } + return -1 + } - function isTIFF (buffer) { - var hex4 = buffer.toString('hex', 0, 4); - return ('49492a00' === hex4 || '4d4d002a' === hex4); + throw new TypeError('val must be string, number or Buffer') } - // Read IFD (image-file-directory) into a buffer - function readIFD (buffer, filepath, isBigEndian) { + // `get` will be removed in Node 0.13+ + Buffer.prototype.get = function get (offset) { + console.log('.get() is deprecated. Access using array indexes instead.') + return this.readUInt8(offset) + } - var ifdOffset = readUInt(buffer, 32, 4, isBigEndian); + // `set` will be removed in Node 0.13+ + Buffer.prototype.set = function set (v, offset) { + console.log('.set() is deprecated. Access using array indexes instead.') + return this.writeUInt8(v, offset) + } - // read only till the end of the file - var bufferSize = 1024; - var fileSize = fs.statSync(filepath).size; - if (ifdOffset + bufferSize > fileSize) { - bufferSize = fileSize - ifdOffset - 10; + function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0 + var remaining = buf.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining + } } - // populate the buffer - var endBuffer = new Buffer(bufferSize); - var descriptor = fs.openSync(filepath, 'r'); - fs.readSync(descriptor, endBuffer, 0, bufferSize, ifdOffset); + // must be an even number of digits + var strLen = string.length + if (strLen % 2 !== 0) throw new Error('Invalid hex string') - // var ifdLength = readUInt(endBuffer, 16, 0, isBigEndian); - var ifdBuffer = endBuffer.slice(2); //, 2 + 12 * ifdLength); - return ifdBuffer; + if (length > strLen / 2) { + length = strLen / 2 + } + for (var i = 0; i < length; i++) { + var parsed = parseInt(string.substr(i * 2, 2), 16) + if (isNaN(parsed)) throw new Error('Invalid hex string') + buf[offset + i] = parsed + } + return i } - // TIFF values seem to be messed up on Big-Endian, this helps - function readValue (buffer, isBigEndian) { - var low = readUInt(buffer, 16, 8, isBigEndian); - var high = readUInt(buffer, 16, 10, isBigEndian); - return (high << 16) + low; + function utf8Write (buf, string, offset, length) { + var charsWritten = blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) + return charsWritten } - // move to the next tag - function nextTag (buffer) { - if (buffer.length > 24) { - return buffer.slice(12); - } + function asciiWrite (buf, string, offset, length) { + var charsWritten = blitBuffer(asciiToBytes(string), buf, offset, length) + return charsWritten } - // Extract IFD tags from TIFF metadata - function extractTags (buffer, isBigEndian) { - var tags = {}; - var code, type, length; + function binaryWrite (buf, string, offset, length) { + return asciiWrite(buf, string, offset, length) + } - while (buffer && buffer.length) { - code = readUInt(buffer, 16, 0, isBigEndian); - type = readUInt(buffer, 16, 2, isBigEndian); - length = readUInt(buffer, 32, 4, isBigEndian); + function base64Write (buf, string, offset, length) { + var charsWritten = blitBuffer(base64ToBytes(string), buf, offset, length) + return charsWritten + } - // 0 means end of IFD - if (code === 0) { - break; - } else { - // 256 is width, 257 is height - // if (code === 256 || code === 257) { - if (length === 1 && type === 3) { - tags[code] = readValue(buffer, isBigEndian); - } + function utf16leWrite (buf, string, offset, length) { + var charsWritten = blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) + return charsWritten + } - // move to the next tag - buffer = nextTag(buffer); + Buffer.prototype.write = function write (string, offset, length, encoding) { + // Support both (string, offset, length, encoding) + // and the legacy (string, encoding, offset, length) + if (isFinite(offset)) { + if (!isFinite(length)) { + encoding = length + length = undefined } + } else { // legacy + var swap = encoding + encoding = offset + offset = length + length = swap } - return tags; - } - // Test if the TIFF is Big Endian or Little Endian - function determineEndianness (buffer) { - var signature = buffer.toString('ascii', 0, 2); - if ('II' === signature) { - return 'LE'; - } else if ('MM' === signature) { - return 'BE'; + offset = Number(offset) || 0 + + if (length < 0 || offset < 0 || offset > this.length) { + throw new RangeError('attempt to write outside buffer bounds') + } + + var remaining = this.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining + } + } + encoding = String(encoding || 'utf8').toLowerCase() + + var ret + switch (encoding) { + case 'hex': + ret = hexWrite(this, string, offset, length) + break + case 'utf8': + case 'utf-8': + ret = utf8Write(this, string, offset, length) + break + case 'ascii': + ret = asciiWrite(this, string, offset, length) + break + case 'binary': + ret = binaryWrite(this, string, offset, length) + break + case 'base64': + ret = base64Write(this, string, offset, length) + break + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + ret = utf16leWrite(this, string, offset, length) + break + default: + throw new TypeError('Unknown encoding: ' + encoding) } + return ret } - function calculate (buffer, filepath) { + Buffer.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } + } - if (!filepath) { - throw new TypeError('Tiff doesn\'t support buffer'); + function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return base64.fromByteArray(buf) + } else { + return base64.fromByteArray(buf.slice(start, end)) } + } - // Determine BE/LE - var isBigEndian = determineEndianness(buffer) === 'BE'; + function utf8Slice (buf, start, end) { + var res = '' + var tmp = '' + end = Math.min(buf.length, end) - // read the IFD - var ifdBuffer = readIFD(buffer, filepath, isBigEndian); + for (var i = start; i < end; i++) { + if (buf[i] <= 0x7F) { + res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i]) + tmp = '' + } else { + tmp += '%' + buf[i].toString(16) + } + } - // extract the tags from the IFD - var tags = extractTags(ifdBuffer, isBigEndian); + return res + decodeUtf8Char(tmp) + } - var width = tags[256]; - var height = tags[257]; + function asciiSlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) - if (!width || !height) { - throw new TypeError('Invalid Tiff, missing tags'); + for (var i = start; i < end; i++) { + ret += String.fromCharCode(buf[i] & 0x7F) } - - return { - 'width': width, - 'height': height - }; + return ret } - module.exports = { - 'detect': isTIFF, - 'calculate': calculate - }; - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(16).Buffer)) + function binarySlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) -/***/ }, -/* 15 */ -/***/ function(module, exports, __webpack_require__) { + for (var i = start; i < end; i++) { + ret += String.fromCharCode(buf[i]) + } + return ret + } - 'use strict'; + function hexSlice (buf, start, end) { + var len = buf.length - // based on https://developers.google.com/speed/webp/docs/riff_container + if (!start || start < 0) start = 0 + if (!end || end < 0 || end > len) end = len - function isWebP (buffer) { - var riffHeader = 'RIFF' === buffer.toString('ascii', 0, 4); - var webpHeader = 'WEBP' === buffer.toString('ascii', 8, 12); - var vp8Header = 'VP8' === buffer.toString('ascii', 12, 15); - return (riffHeader && webpHeader && vp8Header); + var out = '' + for (var i = start; i < end; i++) { + out += toHex(buf[i]) + } + return out } - function calculate (buffer) { + function utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end) + var res = '' + for (var i = 0; i < bytes.length; i += 2) { + res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) + } + return res + } - var chunkHeader = buffer.toString('ascii', 12, 16); - buffer = buffer.slice(20, 30); + Buffer.prototype.slice = function slice (start, end) { + var len = this.length + start = ~~start + end = end === undefined ? len : ~~end - // Lossless webp stream signature - if (chunkHeader === 'VP8 ' && buffer[0] !== 0x2f) { - return calculateLossy(buffer); + if (start < 0) { + start += len + if (start < 0) start = 0 + } else if (start > len) { + start = len } - // Lossy webp stream signature - var signature = buffer.toString('hex', 3, 6); - if (chunkHeader === 'VP8L' && signature !== '9d012a') { - return calculateLossless(buffer); + if (end < 0) { + end += len + if (end < 0) end = 0 + } else if (end > len) { + end = len } - return false; - } + if (end < start) end = start - function calculateLossless (buffer) { - return { - 'width': 1 + (((buffer[2] & 0x3F) << 8) | buffer[1]), - 'height': 1 + (((buffer[4] & 0xF) << 10) | (buffer[3] << 2) | - ((buffer[2] & 0xC0) >> 6)) - }; + var newBuf + if (Buffer.TYPED_ARRAY_SUPPORT) { + newBuf = Buffer._augment(this.subarray(start, end)) + } else { + var sliceLen = end - start + newBuf = new Buffer(sliceLen, undefined) + for (var i = 0; i < sliceLen; i++) { + newBuf[i] = this[i + start] + } + } + + if (newBuf.length) newBuf.parent = this.parent || this + + return newBuf } - function calculateLossy (buffer) { - // `& 0x3fff` returns the last 14 bits - // TO-DO: include webp scaling in the calculations - return { - 'width': buffer.readInt16LE(6) & 0x3fff, - 'height': buffer.readInt16LE(8) & 0x3fff - }; + /* + * Need to make sure that buffer isn't trying to write out of bounds. + */ + function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') } - module.exports = { - 'detect': isWebP, - 'calculate': calculate - }; + Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } -/***/ }, -/* 16 */ -/***/ function(module, exports, __webpack_require__) { + return val + } - /* WEBPACK VAR INJECTION */(function(Buffer) {/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org> - * @license MIT - */ + Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + checkOffset(offset, byteLength, this.length) + } - var base64 = __webpack_require__(22) - var ieee754 = __webpack_require__(20) - var isArray = __webpack_require__(21) + var val = this[offset + --byteLength] + var mul = 1 + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul + } - exports.Buffer = Buffer - exports.SlowBuffer = Buffer - exports.INSPECT_MAX_BYTES = 50 - Buffer.poolSize = 8192 // not used by this implementation + return val + } - var kMaxLength = 0x3fffffff + Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length) + return this[offset] + } - /** - * If `Buffer.TYPED_ARRAY_SUPPORT`: - * === true Use Uint8Array implementation (fastest) - * === false Use Object implementation (most compatible, even IE6) - * - * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, - * Opera 11.6+, iOS 4.2+. - * - * Note: - * - * - Implementation must support adding new properties to `Uint8Array` instances. - * Firefox 4-29 lacked support, fixed in Firefox 30+. - * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. - * - * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. - * - * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of - * incorrect length in some situations. - * - * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they will - * get the Object implementation, which is slower but will work correctly. - */ - Buffer.TYPED_ARRAY_SUPPORT = (function () { - try { - var buf = new ArrayBuffer(0) - var arr = new Uint8Array(buf) - arr.foo = function () { return 42 } - return 42 === arr.foo() && // typed array instances can be augmented - typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` - new Uint8Array(1).subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` - } catch (e) { - return false - } - })() + Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + return this[offset] | (this[offset + 1] << 8) + } - /** - * Class: Buffer - * ============= - * - * The Buffer constructor returns instances of `Uint8Array` that are augmented - * with function properties for all the node `Buffer` API functions. We use - * `Uint8Array` so that square bracket notation works as expected -- it returns - * a single octet. - * - * By augmenting the instances, we can avoid modifying the `Uint8Array` - * prototype. - */ - function Buffer (subject, encoding, noZero) { - if (!(this instanceof Buffer)) - return new Buffer(subject, encoding, noZero) + Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + return (this[offset] << 8) | this[offset + 1] + } - var type = typeof subject + Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) - // Find the length - var length - if (type === 'number') - length = subject > 0 ? subject >>> 0 : 0 - else if (type === 'string') { - if (encoding === 'base64') - subject = base64clean(subject) - length = Buffer.byteLength(subject, encoding) - } else if (type === 'object' && subject !== null) { // assume object is array-like - if (subject.type === 'Buffer' && isArray(subject.data)) - subject = subject.data - length = +subject.length > 0 ? Math.floor(+subject.length) : 0 - } else - throw new TypeError('must start with number, buffer, array or string') + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) + } - if (this.length > kMaxLength) - throw new RangeError('Attempt to allocate Buffer larger than maximum ' + - 'size: 0x' + kMaxLength.toString(16) + ' bytes') + Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) - var buf - if (Buffer.TYPED_ARRAY_SUPPORT) { - // Preferred: Return an augmented `Uint8Array` instance for best performance - buf = Buffer._augment(new Uint8Array(length)) - } else { - // Fallback: Return THIS instance of Buffer (created by `new`) - buf = this - buf.length = length - buf._isBuffer = true - } + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) + } - var i - if (Buffer.TYPED_ARRAY_SUPPORT && typeof subject.byteLength === 'number') { - // Speed optimization -- use set if we're copying from a typed array - buf._set(subject) - } else if (isArrayish(subject)) { - // Treat array-ish objects as a byte array - if (Buffer.isBuffer(subject)) { - for (i = 0; i < length; i++) - buf[i] = subject.readUInt8(i) - } else { - for (i = 0; i < length; i++) - buf[i] = ((subject[i] % 256) + 256) % 256 - } - } else if (type === 'string') { - buf.write(subject, 0, encoding) - } else if (type === 'number' && !Buffer.TYPED_ARRAY_SUPPORT && !noZero) { - for (i = 0; i < length; i++) { - buf[i] = 0 - } + Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul } + mul *= 0x80 - return buf - } + if (val >= mul) val -= Math.pow(2, 8 * byteLength) - Buffer.isBuffer = function (b) { - return !!(b != null && b._isBuffer) + return val } - Buffer.compare = function (a, b) { - if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) - throw new TypeError('Arguments must be Buffers') - - var x = a.length - var y = b.length - for (var i = 0, len = Math.min(x, y); i < len && a[i] === b[i]; i++) {} - if (i !== len) { - x = a[i] - y = b[i] - } - if (x < y) return -1 - if (y < x) return 1 - return 0 - } + Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) - Buffer.isEncoding = function (encoding) { - switch (String(encoding).toLowerCase()) { - case 'hex': - case 'utf8': - case 'utf-8': - case 'ascii': - case 'binary': - case 'base64': - case 'raw': - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return true - default: - return false + var i = byteLength + var mul = 1 + var val = this[offset + --i] + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul } - } + mul *= 0x80 - Buffer.concat = function (list, totalLength) { - if (!isArray(list)) throw new TypeError('Usage: Buffer.concat(list[, length])') + if (val >= mul) val -= Math.pow(2, 8 * byteLength) - if (list.length === 0) { - return new Buffer(0) - } else if (list.length === 1) { - return list[0] - } + return val + } - var i - if (totalLength === undefined) { - totalLength = 0 - for (i = 0; i < list.length; i++) { - totalLength += list[i].length - } - } + Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length) + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) + } - var buf = new Buffer(totalLength) - var pos = 0 - for (i = 0; i < list.length; i++) { - var item = list[i] - item.copy(buf, pos) - pos += item.length - } - return buf + Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset] | (this[offset + 1] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val } - Buffer.byteLength = function (str, encoding) { - var ret - str = str + '' - switch (encoding || 'utf8') { - case 'ascii': - case 'binary': - case 'raw': - ret = str.length - break - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - ret = str.length * 2 - break - case 'hex': - ret = str.length >>> 1 - break - case 'utf8': - case 'utf-8': - ret = utf8ToBytes(str).length - break - case 'base64': - ret = base64ToBytes(str).length - break - default: - ret = str.length - } - return ret + Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset + 1] | (this[offset] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val } - // pre-set for values that may exist in the future - Buffer.prototype.length = undefined - Buffer.prototype.parent = undefined + Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) - // toString(encoding, start=0, end=buffer.length) - Buffer.prototype.toString = function (encoding, start, end) { - var loweredCase = false + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) + } - start = start >>> 0 - end = end === undefined || end === Infinity ? this.length : end >>> 0 + Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) - if (!encoding) encoding = 'utf8' - if (start < 0) start = 0 - if (end > this.length) end = this.length - if (end <= start) return '' + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) + } - while (true) { - switch (encoding) { - case 'hex': - return hexSlice(this, start, end) + Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, true, 23, 4) + } - case 'utf8': - case 'utf-8': - return utf8Slice(this, start, end) + Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, false, 23, 4) + } - case 'ascii': - return asciiSlice(this, start, end) + Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, true, 52, 8) + } - case 'binary': - return binarySlice(this, start, end) + Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, false, 52, 8) + } - case 'base64': - return base64Slice(this, start, end) + function checkInt (buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance') + if (value > max || value < min) throw new RangeError('value is out of bounds') + if (offset + ext > buf.length) throw new RangeError('index out of range') + } - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return utf16leSlice(this, start, end) + Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) - default: - if (loweredCase) - throw new TypeError('Unknown encoding: ' + encoding) - encoding = (encoding + '').toLowerCase() - loweredCase = true - } + var mul = 1 + var i = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) >>> 0 & 0xFF } - } - Buffer.prototype.equals = function (b) { - if(!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') - return Buffer.compare(this, b) === 0 + return offset + byteLength } - Buffer.prototype.inspect = function () { - var str = '' - var max = exports.INSPECT_MAX_BYTES - if (this.length > 0) { - str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') - if (this.length > max) - str += ' ... ' + Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) + + var i = byteLength - 1 + var mul = 1 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) >>> 0 & 0xFF } - return '<Buffer ' + str + '>' - } - Buffer.prototype.compare = function (b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') - return Buffer.compare(this, b) + return offset + byteLength } - // `get` will be removed in Node 0.13+ - Buffer.prototype.get = function (offset) { - console.log('.get() is deprecated. Access using array indexes instead.') - return this.readUInt8(offset) + Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) + if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) + this[offset] = value + return offset + 1 } - // `set` will be removed in Node 0.13+ - Buffer.prototype.set = function (v, offset) { - console.log('.set() is deprecated. Access using array indexes instead.') - return this.writeUInt8(v, offset) + function objectWriteUInt16 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffff + value + 1 + for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) { + buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> + (littleEndian ? i : 1 - i) * 8 + } } - function hexWrite (buf, string, offset, length) { - offset = Number(offset) || 0 - var remaining = buf.length - offset - if (!length) { - length = remaining + Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = value + this[offset + 1] = (value >>> 8) } else { - length = Number(length) - if (length > remaining) { - length = remaining - } - } - - // must be an even number of digits - var strLen = string.length - if (strLen % 2 !== 0) throw new Error('Invalid hex string') - - if (length > strLen / 2) { - length = strLen / 2 + objectWriteUInt16(this, value, offset, true) } - for (var i = 0; i < length; i++) { - var byte = parseInt(string.substr(i * 2, 2), 16) - if (isNaN(byte)) throw new Error('Invalid hex string') - buf[offset + i] = byte - } - return i - } - - function utf8Write (buf, string, offset, length) { - var charsWritten = blitBuffer(utf8ToBytes(string), buf, offset, length) - return charsWritten - } - - function asciiWrite (buf, string, offset, length) { - var charsWritten = blitBuffer(asciiToBytes(string), buf, offset, length) - return charsWritten - } - - function binaryWrite (buf, string, offset, length) { - return asciiWrite(buf, string, offset, length) - } - - function base64Write (buf, string, offset, length) { - var charsWritten = blitBuffer(base64ToBytes(string), buf, offset, length) - return charsWritten - } - - function utf16leWrite (buf, string, offset, length) { - var charsWritten = blitBuffer(utf16leToBytes(string), buf, offset, length, 2) - return charsWritten + return offset + 2 } - Buffer.prototype.write = function (string, offset, length, encoding) { - // Support both (string, offset, length, encoding) - // and the legacy (string, encoding, offset, length) - if (isFinite(offset)) { - if (!isFinite(length)) { - encoding = length - length = undefined - } - } else { // legacy - var swap = encoding - encoding = offset - offset = length - length = swap - } - - offset = Number(offset) || 0 - var remaining = this.length - offset - if (!length) { - length = remaining + Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8) + this[offset + 1] = value } else { - length = Number(length) - if (length > remaining) { - length = remaining - } + objectWriteUInt16(this, value, offset, false) } - encoding = String(encoding || 'utf8').toLowerCase() + return offset + 2 + } - var ret - switch (encoding) { - case 'hex': - ret = hexWrite(this, string, offset, length) - break - case 'utf8': - case 'utf-8': - ret = utf8Write(this, string, offset, length) - break - case 'ascii': - ret = asciiWrite(this, string, offset, length) - break - case 'binary': - ret = binaryWrite(this, string, offset, length) - break - case 'base64': - ret = base64Write(this, string, offset, length) - break - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - ret = utf16leWrite(this, string, offset, length) - break - default: - throw new TypeError('Unknown encoding: ' + encoding) + function objectWriteUInt32 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffffffff + value + 1 + for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) { + buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff } - return ret } - Buffer.prototype.toJSON = function () { - return { - type: 'Buffer', - data: Array.prototype.slice.call(this._arr || this, 0) + Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset + 3] = (value >>> 24) + this[offset + 2] = (value >>> 16) + this[offset + 1] = (value >>> 8) + this[offset] = value + } else { + objectWriteUInt32(this, value, offset, true) } + return offset + 4 } - function base64Slice (buf, start, end) { - if (start === 0 && end === buf.length) { - return base64.fromByteArray(buf) + Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = value } else { - return base64.fromByteArray(buf.slice(start, end)) + objectWriteUInt32(this, value, offset, false) } + return offset + 4 } - function utf8Slice (buf, start, end) { - var res = '' - var tmp = '' - end = Math.min(buf.length, end) + Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkInt( + this, value, offset, byteLength, + Math.pow(2, 8 * byteLength - 1) - 1, + -Math.pow(2, 8 * byteLength - 1) + ) + } - for (var i = start; i < end; i++) { - if (buf[i] <= 0x7F) { - res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i]) - tmp = '' - } else { - tmp += '%' + buf[i].toString(16) - } + var i = 0 + var mul = 1 + var sub = value < 0 ? 1 : 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF } - return res + decodeUtf8Char(tmp) + return offset + byteLength } - function asciiSlice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) + Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkInt( + this, value, offset, byteLength, + Math.pow(2, 8 * byteLength - 1) - 1, + -Math.pow(2, 8 * byteLength - 1) + ) + } - for (var i = start; i < end; i++) { - ret += String.fromCharCode(buf[i]) + var i = byteLength - 1 + var mul = 1 + var sub = value < 0 ? 1 : 0 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF } - return ret - } - function binarySlice (buf, start, end) { - return asciiSlice(buf, start, end) + return offset + byteLength } - function hexSlice (buf, start, end) { - var len = buf.length - - if (!start || start < 0) start = 0 - if (!end || end < 0 || end > len) end = len - - var out = '' - for (var i = start; i < end; i++) { - out += toHex(buf[i]) - } - return out + Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) + if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) + if (value < 0) value = 0xff + value + 1 + this[offset] = value + return offset + 1 } - function utf16leSlice (buf, start, end) { - var bytes = buf.slice(start, end) - var res = '' - for (var i = 0; i < bytes.length; i += 2) { - res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) + Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = value + this[offset + 1] = (value >>> 8) + } else { + objectWriteUInt16(this, value, offset, true) } - return res + return offset + 2 } - Buffer.prototype.slice = function (start, end) { - var len = this.length - start = ~~start - end = end === undefined ? len : ~~end - - if (start < 0) { - start += len; - if (start < 0) - start = 0 - } else if (start > len) { - start = len - } - - if (end < 0) { - end += len - if (end < 0) - end = 0 - } else if (end > len) { - end = len + Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8) + this[offset + 1] = value + } else { + objectWriteUInt16(this, value, offset, false) } + return offset + 2 + } - if (end < start) - end = start - + Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) if (Buffer.TYPED_ARRAY_SUPPORT) { - return Buffer._augment(this.subarray(start, end)) + this[offset] = value + this[offset + 1] = (value >>> 8) + this[offset + 2] = (value >>> 16) + this[offset + 3] = (value >>> 24) } else { - var sliceLen = end - start - var newBuf = new Buffer(sliceLen, undefined, true) - for (var i = 0; i < sliceLen; i++) { - newBuf[i] = this[i + start] - } - return newBuf + objectWriteUInt32(this, value, offset, true) } + return offset + 4 } - /* - * Need to make sure that buffer isn't trying to write out of bounds. - */ - function checkOffset (offset, ext, length) { - if ((offset % 1) !== 0 || offset < 0) - throw new RangeError('offset is not uint') - if (offset + ext > length) - throw new RangeError('Trying to access beyond buffer length') + Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (value < 0) value = 0xffffffff + value + 1 + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = value + } else { + objectWriteUInt32(this, value, offset, false) + } + return offset + 4 } - Buffer.prototype.readUInt8 = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 1, this.length) - return this[offset] + function checkIEEE754 (buf, value, offset, ext, max, min) { + if (value > max || value < min) throw new RangeError('value is out of bounds') + if (offset + ext > buf.length) throw new RangeError('index out of range') + if (offset < 0) throw new RangeError('index out of range') } - Buffer.prototype.readUInt16LE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 2, this.length) - return this[offset] | (this[offset + 1] << 8) + function writeFloat (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) + } + ieee754.write(buf, value, offset, littleEndian, 23, 4) + return offset + 4 } - Buffer.prototype.readUInt16BE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 2, this.length) - return (this[offset] << 8) | this[offset + 1] + Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) } - Buffer.prototype.readUInt32LE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 4, this.length) - - return ((this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16)) + - (this[offset + 3] * 0x1000000) + Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) } - Buffer.prototype.readUInt32BE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 4, this.length) - - return (this[offset] * 0x1000000) + - ((this[offset + 1] << 16) | - (this[offset + 2] << 8) | - this[offset + 3]) + function writeDouble (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } + ieee754.write(buf, value, offset, littleEndian, 52, 8) + return offset + 8 } - Buffer.prototype.readInt8 = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 1, this.length) - if (!(this[offset] & 0x80)) - return (this[offset]) - return ((0xff - this[offset] + 1) * -1) + Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) } - Buffer.prototype.readInt16LE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 2, this.length) - var val = this[offset] | (this[offset + 1] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val + Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) } - Buffer.prototype.readInt16BE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 2, this.length) - var val = this[offset + 1] | (this[offset] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val + // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) + Buffer.prototype.copy = function copy (target, target_start, start, end) { + if (!start) start = 0 + if (!end && end !== 0) end = this.length + if (target_start >= target.length) target_start = target.length + if (!target_start) target_start = 0 + if (end > 0 && end < start) end = start + + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 + + // Fatal error conditions + if (target_start < 0) { + throw new RangeError('targetStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') + if (end < 0) throw new RangeError('sourceEnd out of bounds') + + // Are we oob? + if (end > this.length) end = this.length + if (target.length - target_start < end - start) { + end = target.length - target_start + start + } + + var len = end - start + + if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { + for (var i = 0; i < len; i++) { + target[i + target_start] = this[i + start] + } + } else { + target._set(this.subarray(start, start + len), target_start) + } + + return len } - Buffer.prototype.readInt32LE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 4, this.length) + // fill(value, start=0, end=buffer.length) + Buffer.prototype.fill = function fill (value, start, end) { + if (!value) value = 0 + if (!start) start = 0 + if (!end) end = this.length + + if (end < start) throw new RangeError('end < start') - return (this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16) | - (this[offset + 3] << 24) + // Fill 0 bytes; we're done + if (end === start) return + if (this.length === 0) return + + if (start < 0 || start >= this.length) throw new RangeError('start out of bounds') + if (end < 0 || end > this.length) throw new RangeError('end out of bounds') + + var i + if (typeof value === 'number') { + for (i = start; i < end; i++) { + this[i] = value + } + } else { + var bytes = utf8ToBytes(value.toString()) + var len = bytes.length + for (i = start; i < end; i++) { + this[i] = bytes[i % len] + } + } + + return this + } + + /** + * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance. + * Added in Node 0.12. Only available in browsers that support ArrayBuffer. + */ + Buffer.prototype.toArrayBuffer = function toArrayBuffer () { + if (typeof Uint8Array !== 'undefined') { + if (Buffer.TYPED_ARRAY_SUPPORT) { + return (new Buffer(this)).buffer + } else { + var buf = new Uint8Array(this.length) + for (var i = 0, len = buf.length; i < len; i += 1) { + buf[i] = this[i] + } + return buf.buffer + } + } else { + throw new TypeError('Buffer.toArrayBuffer not supported in this browser') + } + } + + // HELPER FUNCTIONS + // ================ + + var BP = Buffer.prototype + + /** + * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods + */ + Buffer._augment = function _augment (arr) { + arr.constructor = Buffer + arr._isBuffer = true + + // save reference to original Uint8Array set method before overwriting + arr._set = arr.set + + // deprecated, will be removed in node 0.13+ + arr.get = BP.get + arr.set = BP.set + + arr.write = BP.write + arr.toString = BP.toString + arr.toLocaleString = BP.toString + arr.toJSON = BP.toJSON + arr.equals = BP.equals + arr.compare = BP.compare + arr.indexOf = BP.indexOf + arr.copy = BP.copy + arr.slice = BP.slice + arr.readUIntLE = BP.readUIntLE + arr.readUIntBE = BP.readUIntBE + arr.readUInt8 = BP.readUInt8 + arr.readUInt16LE = BP.readUInt16LE + arr.readUInt16BE = BP.readUInt16BE + arr.readUInt32LE = BP.readUInt32LE + arr.readUInt32BE = BP.readUInt32BE + arr.readIntLE = BP.readIntLE + arr.readIntBE = BP.readIntBE + arr.readInt8 = BP.readInt8 + arr.readInt16LE = BP.readInt16LE + arr.readInt16BE = BP.readInt16BE + arr.readInt32LE = BP.readInt32LE + arr.readInt32BE = BP.readInt32BE + arr.readFloatLE = BP.readFloatLE + arr.readFloatBE = BP.readFloatBE + arr.readDoubleLE = BP.readDoubleLE + arr.readDoubleBE = BP.readDoubleBE + arr.writeUInt8 = BP.writeUInt8 + arr.writeUIntLE = BP.writeUIntLE + arr.writeUIntBE = BP.writeUIntBE + arr.writeUInt16LE = BP.writeUInt16LE + arr.writeUInt16BE = BP.writeUInt16BE + arr.writeUInt32LE = BP.writeUInt32LE + arr.writeUInt32BE = BP.writeUInt32BE + arr.writeIntLE = BP.writeIntLE + arr.writeIntBE = BP.writeIntBE + arr.writeInt8 = BP.writeInt8 + arr.writeInt16LE = BP.writeInt16LE + arr.writeInt16BE = BP.writeInt16BE + arr.writeInt32LE = BP.writeInt32LE + arr.writeInt32BE = BP.writeInt32BE + arr.writeFloatLE = BP.writeFloatLE + arr.writeFloatBE = BP.writeFloatBE + arr.writeDoubleLE = BP.writeDoubleLE + arr.writeDoubleBE = BP.writeDoubleBE + arr.fill = BP.fill + arr.inspect = BP.inspect + arr.toArrayBuffer = BP.toArrayBuffer + + return arr + } + + var INVALID_BASE64_RE = /[^+\/0-9A-z\-]/g + + function base64clean (str) { + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = stringtrim(str).replace(INVALID_BASE64_RE, '') + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '=' + } + return str + } + + function stringtrim (str) { + if (str.trim) return str.trim() + return str.replace(/^\s+|\s+$/g, '') + } + + function isArrayish (subject) { + return isArray(subject) || Buffer.isBuffer(subject) || + subject && typeof subject === 'object' && + typeof subject.length === 'number' + } + + function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) + } + + function utf8ToBytes (string, units) { + units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null + var bytes = [] + var i = 0 + + for (; i < length; i++) { + codePoint = string.charCodeAt(i) + + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (leadSurrogate) { + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = codePoint + continue + } else { + // valid surrogate pair + codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000 + leadSurrogate = null + } + } else { + // no lead yet + + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else { + // valid lead + leadSurrogate = codePoint + continue + } + } + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = null + } + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint) + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x200000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else { + throw new Error('Invalid code point') + } + } + + return bytes + } + + function asciiToBytes (str) { + var byteArray = [] + for (var i = 0; i < str.length; i++) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF) + } + return byteArray + } + + function utf16leToBytes (str, units) { + var c, hi, lo + var byteArray = [] + for (var i = 0; i < str.length; i++) { + if ((units -= 2) < 0) break + + c = str.charCodeAt(i) + hi = c >> 8 + lo = c % 256 + byteArray.push(lo) + byteArray.push(hi) + } + + return byteArray + } + + function base64ToBytes (str) { + return base64.toByteArray(base64clean(str)) + } + + function blitBuffer (src, dst, offset, length) { + for (var i = 0; i < length; i++) { + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i] + } + return i + } + + function decodeUtf8Char (str) { + try { + return decodeURIComponent(str) + } catch (err) { + return String.fromCharCode(0xFFFD) // UTF 8 invalid char + } + } + + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8).Buffer)) + +/***/ }, +/* 9 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function isBMP (buffer) { + return ('BM' === buffer.toString('ascii', 0, 2)); + } + + function calculate (buffer) { + return { + 'width': buffer.readUInt32LE(18), + 'height': buffer.readUInt32LE(22) + }; + } + + module.exports = { + 'detect': isBMP, + 'calculate': calculate + }; + + +/***/ }, +/* 10 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var gifRegexp = /^GIF8[7,9]a/; + function isGIF (buffer) { + var signature = buffer.toString('ascii', 0, 6); + return (gifRegexp.test(signature)); + } + + function calculate(buffer) { + return { + 'width': buffer.readUInt16LE(6), + 'height': buffer.readUInt16LE(8) + }; + } + + module.exports = { + 'detect': isGIF, + 'calculate': calculate + }; + +/***/ }, +/* 11 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + // NOTE: we only support baseline and progressive JPGs here + // due to the structure of the loader class, we only get a buffer + // with a maximum size of 4096 bytes. so if the SOF marker is outside + // if this range we can't detect the file size correctly. + + // TO-DO: handle all JFIFs + var validJFIFMarkers = { + 'ffdb': '0001010101', // Samsung D807 JPEG + 'ffe0': '4a46494600', // Standard JPEG + 'ffe1': '4578696600', // Camera JPEG, with EXIF data + 'ffe2': '4943435f50', // Canon EOS-1D JPEG + 'ffe3': '', // Samsung D500 JPEG + 'ffe8': '5350494646', // SPIFF JPEG + 'ffec': '4475636b79', // Photoshop JPEG + 'ffed': '50686f746f', // Adobe JPEG, Photoshop CMYK buffer + 'ffee': '41646f6265' // Adobe JPEG, Unrecognised (Lightroom??) + }; + + var red = ['\x1B[31m', '\x1B[39m']; + function isJPG (buffer) { //, filepath + var SOIMarker = buffer.toString('hex', 0, 2); + var JFIFMarker = buffer.toString('hex', 2, 4); + + // not a valid jpeg + if ('ffd8' !== SOIMarker) { + return false; + } + + // TO-DO: validate the end-bytes of a jpeg file + // use filepath, get the last bytes, check for ffd9 + var got = buffer.toString('hex', 6, 11); + var expected = JFIFMarker && validJFIFMarkers[JFIFMarker]; + if (expected === '') { + console.warn( + red[0] + + 'this looks like a unrecognised jpeg\n' + + 'please report the issue here\n' + + red[1], + '\thttps://github.com/netroy/image-size/issues/new\n' + ); + return false; + } + return (got === expected) || (JFIFMarker === 'ffdb'); + } + + function extractSize (buffer, i) { + return { + 'height' : buffer.readUInt16BE(i), + 'width' : buffer.readUInt16BE(i + 2) + }; + } + + function validateBuffer (buffer, i) { + // index should be within buffer limits + if (i > buffer.length) { + throw new TypeError('Corrupt JPG, exceeded buffer limits'); + } + // Every JPEG block must begin with a 0xFF + if (buffer[i] !== 0xFF) { + throw new TypeError('Invalid JPG, marker table corrupted'); + } + } + + function calculate (buffer) { + + // Skip 5 chars, they are for signature + buffer = buffer.slice(4); + + var i, next; + while (buffer.length) { + // read length of the next block + i = buffer.readUInt16BE(0); + + // ensure correct format + validateBuffer(buffer, i); + + // 0xFFC0 is baseline(SOF) + // 0xFFC2 is progressive(SOF2) + next = buffer[i + 1]; + if (next === 0xC0 || next === 0xC2) { + return extractSize(buffer, i + 5); + } + + // move to the next block + buffer = buffer.slice(i + 2); + } + + throw new TypeError('Invalid JPG, no size found'); + } + + module.exports = { + 'detect': isJPG, + 'calculate': calculate + }; + + +/***/ }, +/* 12 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var pngSignature = 'PNG\r\n\x1a\n'; + function isPNG (buffer) { + if (pngSignature === buffer.toString('ascii', 1, 8)) { + if ('IHDR' !== buffer.toString('ascii', 12, 16)) { + throw new TypeError('invalid png'); + } + return true; + } } - Buffer.prototype.readInt32BE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 4, this.length) - - return (this[offset] << 24) | - (this[offset + 1] << 16) | - (this[offset + 2] << 8) | - (this[offset + 3]) + function calculate (buffer) { + return { + 'width': buffer.readUInt32BE(16), + 'height': buffer.readUInt32BE(20) + }; } - Buffer.prototype.readFloatLE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, true, 23, 4) - } + module.exports = { + 'detect': isPNG, + 'calculate': calculate + }; - Buffer.prototype.readFloatBE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, false, 23, 4) - } - Buffer.prototype.readDoubleLE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, true, 52, 8) - } +/***/ }, +/* 13 */ +/***/ function(module, exports, __webpack_require__) { - Buffer.prototype.readDoubleBE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, false, 52, 8) - } + 'use strict'; - function checkInt (buf, value, offset, ext, max, min) { - if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance') - if (value > max || value < min) throw new TypeError('value is out of bounds') - if (offset + ext > buf.length) throw new TypeError('index out of range') + function isPSD (buffer) { + return ('8BPS' === buffer.toString('ascii', 0, 4)); } - Buffer.prototype.writeUInt8 = function (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 1, 0xff, 0) - if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) - this[offset] = value - return offset + 1 + function calculate (buffer) { + return { + 'width': buffer.readUInt32BE(18), + 'height': buffer.readUInt32BE(14) + }; } - function objectWriteUInt16 (buf, value, offset, littleEndian) { - if (value < 0) value = 0xffff + value + 1 - for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) { - buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> - (littleEndian ? i : 1 - i) * 8 - } - } + module.exports = { + 'detect': isPSD, + 'calculate': calculate + }; - Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 2, 0xffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = value - this[offset + 1] = (value >>> 8) - } else objectWriteUInt16(this, value, offset, true) - return offset + 2 - } - Buffer.prototype.writeUInt16BE = function (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 2, 0xffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 8) - this[offset + 1] = value - } else objectWriteUInt16(this, value, offset, false) - return offset + 2 - } +/***/ }, +/* 14 */ +/***/ function(module, exports, __webpack_require__) { - function objectWriteUInt32 (buf, value, offset, littleEndian) { - if (value < 0) value = 0xffffffff + value + 1 - for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) { - buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff - } - } + 'use strict'; - Buffer.prototype.writeUInt32LE = function (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 4, 0xffffffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset + 3] = (value >>> 24) - this[offset + 2] = (value >>> 16) - this[offset + 1] = (value >>> 8) - this[offset] = value - } else objectWriteUInt32(this, value, offset, true) - return offset + 4 + var svgReg = /<svg[^>]+[^>]*>/; + function isSVG (buffer) { + return svgReg.test(buffer); } - Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 4, 0xffffffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = value - } else objectWriteUInt32(this, value, offset, false) - return offset + 4 - } + var extractorRegExps = { + 'root': /<svg [^>]+>/, + 'width': /(^|\s)width\s*=\s*"(.+?)"/i, + 'height': /(^|\s)height\s*=\s*"(.+?)"/i, + 'viewbox': /(^|\s)viewbox\s*=\s*"(.+?)"/i + }; - Buffer.prototype.writeInt8 = function (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 1, 0x7f, -0x80) - if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) - if (value < 0) value = 0xff + value + 1 - this[offset] = value - return offset + 1 + function getRatio (viewbox) { + var ratio = 1; + if (viewbox && viewbox[2]) { + var dim = viewbox[2].split(/\s/g); + if (dim.length === 4) { + dim = dim.map(function (i) { + return parseInt(i, 10); + }); + ratio = (dim[2] - dim[0]) / (dim[3] - dim[1]); + } + } + return ratio; } - Buffer.prototype.writeInt16LE = function (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 2, 0x7fff, -0x8000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = value - this[offset + 1] = (value >>> 8) - } else objectWriteUInt16(this, value, offset, true) - return offset + 2 + function parse (buffer) { + var body = buffer.toString().replace(/[\r\n\s]+/g, ' '); + var section = body.match(extractorRegExps.root); + var root = section && section[0]; + if (root) { + var width = root.match(extractorRegExps.width); + var height = root.match(extractorRegExps.height); + var viewbox = root.match(extractorRegExps.viewbox); + var ratio = getRatio(viewbox); + return { + 'width': parseInt(width && width[2], 10) || 0, + 'height': parseInt(height && height[2], 10) || 0, + 'ratio': ratio + }; + } } - Buffer.prototype.writeInt16BE = function (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 2, 0x7fff, -0x8000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 8) - this[offset + 1] = value - } else objectWriteUInt16(this, value, offset, false) - return offset + 2 - } + function calculate (buffer) { - Buffer.prototype.writeInt32LE = function (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = value - this[offset + 1] = (value >>> 8) - this[offset + 2] = (value >>> 16) - this[offset + 3] = (value >>> 24) - } else objectWriteUInt32(this, value, offset, true) - return offset + 4 - } + var parsed = parse(buffer); + var width = parsed.width; + var height = parsed.height; + var ratio = parsed.ratio; - Buffer.prototype.writeInt32BE = function (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (value < 0) value = 0xffffffff + value + 1 - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = value - } else objectWriteUInt32(this, value, offset, false) - return offset + 4 + if (width && height) { + return { 'width': width, 'height': height }; + } else { + if (width) { + return { 'width': width, 'height': Math.floor(width / ratio) }; + } else if (height) { + return { 'width': Math.floor(height * ratio), 'height': height }; + } else { + throw new TypeError('invalid svg'); + } + } } - function checkIEEE754 (buf, value, offset, ext, max, min) { - if (value > max || value < min) throw new TypeError('value is out of bounds') - if (offset + ext > buf.length) throw new TypeError('index out of range') - } + module.exports = { + 'detect': isSVG, + 'calculate': calculate + }; - function writeFloat (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) - checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) - ieee754.write(buf, value, offset, littleEndian, 23, 4) - return offset + 4 - } - Buffer.prototype.writeFloatLE = function (value, offset, noAssert) { - return writeFloat(this, value, offset, true, noAssert) - } +/***/ }, +/* 15 */ +/***/ function(module, exports, __webpack_require__) { - Buffer.prototype.writeFloatBE = function (value, offset, noAssert) { - return writeFloat(this, value, offset, false, noAssert) - } + /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict'; - function writeDouble (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) - checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) - ieee754.write(buf, value, offset, littleEndian, 52, 8) - return offset + 8 - } + // based on http://www.compix.com/fileformattif.htm + // TO-DO: support big-endian as well - Buffer.prototype.writeDoubleLE = function (value, offset, noAssert) { - return writeDouble(this, value, offset, true, noAssert) - } + var fs = __webpack_require__(17); + var readUInt = __webpack_require__(18); - Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) { - return writeDouble(this, value, offset, false, noAssert) + function isTIFF (buffer) { + var hex4 = buffer.toString('hex', 0, 4); + return ('49492a00' === hex4 || '4d4d002a' === hex4); } - // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) - Buffer.prototype.copy = function (target, target_start, start, end) { - var source = this + // Read IFD (image-file-directory) into a buffer + function readIFD (buffer, filepath, isBigEndian) { - if (!start) start = 0 - if (!end && end !== 0) end = this.length - if (!target_start) target_start = 0 + var ifdOffset = readUInt(buffer, 32, 4, isBigEndian); - // Copy 0 bytes; we're done - if (end === start) return - if (target.length === 0 || source.length === 0) return + // read only till the end of the file + var bufferSize = 1024; + var fileSize = fs.statSync(filepath).size; + if (ifdOffset + bufferSize > fileSize) { + bufferSize = fileSize - ifdOffset - 10; + } - // Fatal error conditions - if (end < start) throw new TypeError('sourceEnd < sourceStart') - if (target_start < 0 || target_start >= target.length) - throw new TypeError('targetStart out of bounds') - if (start < 0 || start >= source.length) throw new TypeError('sourceStart out of bounds') - if (end < 0 || end > source.length) throw new TypeError('sourceEnd out of bounds') + // populate the buffer + var endBuffer = new Buffer(bufferSize); + var descriptor = fs.openSync(filepath, 'r'); + fs.readSync(descriptor, endBuffer, 0, bufferSize, ifdOffset); - // Are we oob? - if (end > this.length) - end = this.length - if (target.length - target_start < end - start) - end = target.length - target_start + start + // var ifdLength = readUInt(endBuffer, 16, 0, isBigEndian); + var ifdBuffer = endBuffer.slice(2); //, 2 + 12 * ifdLength); + return ifdBuffer; + } - var len = end - start + // TIFF values seem to be messed up on Big-Endian, this helps + function readValue (buffer, isBigEndian) { + var low = readUInt(buffer, 16, 8, isBigEndian); + var high = readUInt(buffer, 16, 10, isBigEndian); + return (high << 16) + low; + } - if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { - for (var i = 0; i < len; i++) { - target[i + target_start] = this[i + start] - } - } else { - target._set(this.subarray(start, start + len), target_start) + // move to the next tag + function nextTag (buffer) { + if (buffer.length > 24) { + return buffer.slice(12); } } - // fill(value, start=0, end=buffer.length) - Buffer.prototype.fill = function (value, start, end) { - if (!value) value = 0 - if (!start) start = 0 - if (!end) end = this.length - - if (end < start) throw new TypeError('end < start') + // Extract IFD tags from TIFF metadata + function extractTags (buffer, isBigEndian) { + var tags = {}; + var code, type, length; - // Fill 0 bytes; we're done - if (end === start) return - if (this.length === 0) return + while (buffer && buffer.length) { + code = readUInt(buffer, 16, 0, isBigEndian); + type = readUInt(buffer, 16, 2, isBigEndian); + length = readUInt(buffer, 32, 4, isBigEndian); - if (start < 0 || start >= this.length) throw new TypeError('start out of bounds') - if (end < 0 || end > this.length) throw new TypeError('end out of bounds') + // 0 means end of IFD + if (code === 0) { + break; + } else { + // 256 is width, 257 is height + // if (code === 256 || code === 257) { + if (length === 1 && type === 3) { + tags[code] = readValue(buffer, isBigEndian); + } - var i - if (typeof value === 'number') { - for (i = start; i < end; i++) { - this[i] = value - } - } else { - var bytes = utf8ToBytes(value.toString()) - var len = bytes.length - for (i = start; i < end; i++) { - this[i] = bytes[i % len] + // move to the next tag + buffer = nextTag(buffer); } } - - return this + return tags; } - /** - * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance. - * Added in Node 0.12. Only available in browsers that support ArrayBuffer. - */ - Buffer.prototype.toArrayBuffer = function () { - if (typeof Uint8Array !== 'undefined') { - if (Buffer.TYPED_ARRAY_SUPPORT) { - return (new Buffer(this)).buffer - } else { - var buf = new Uint8Array(this.length) - for (var i = 0, len = buf.length; i < len; i += 1) { - buf[i] = this[i] - } - return buf.buffer - } - } else { - throw new TypeError('Buffer.toArrayBuffer not supported in this browser') + // Test if the TIFF is Big Endian or Little Endian + function determineEndianness (buffer) { + var signature = buffer.toString('ascii', 0, 2); + if ('II' === signature) { + return 'LE'; + } else if ('MM' === signature) { + return 'BE'; } } - // HELPER FUNCTIONS - // ================ + function calculate (buffer, filepath) { - var BP = Buffer.prototype + if (!filepath) { + throw new TypeError('Tiff doesn\'t support buffer'); + } - /** - * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods - */ - Buffer._augment = function (arr) { - arr.constructor = Buffer - arr._isBuffer = true + // Determine BE/LE + var isBigEndian = determineEndianness(buffer) === 'BE'; - // save reference to original Uint8Array get/set methods before overwriting - arr._get = arr.get - arr._set = arr.set + // read the IFD + var ifdBuffer = readIFD(buffer, filepath, isBigEndian); - // deprecated, will be removed in node 0.13+ - arr.get = BP.get - arr.set = BP.set + // extract the tags from the IFD + var tags = extractTags(ifdBuffer, isBigEndian); - arr.write = BP.write - arr.toString = BP.toString - arr.toLocaleString = BP.toString - arr.toJSON = BP.toJSON - arr.equals = BP.equals - arr.compare = BP.compare - arr.copy = BP.copy - arr.slice = BP.slice - arr.readUInt8 = BP.readUInt8 - arr.readUInt16LE = BP.readUInt16LE - arr.readUInt16BE = BP.readUInt16BE - arr.readUInt32LE = BP.readUInt32LE - arr.readUInt32BE = BP.readUInt32BE - arr.readInt8 = BP.readInt8 - arr.readInt16LE = BP.readInt16LE - arr.readInt16BE = BP.readInt16BE - arr.readInt32LE = BP.readInt32LE - arr.readInt32BE = BP.readInt32BE - arr.readFloatLE = BP.readFloatLE - arr.readFloatBE = BP.readFloatBE - arr.readDoubleLE = BP.readDoubleLE - arr.readDoubleBE = BP.readDoubleBE - arr.writeUInt8 = BP.writeUInt8 - arr.writeUInt16LE = BP.writeUInt16LE - arr.writeUInt16BE = BP.writeUInt16BE - arr.writeUInt32LE = BP.writeUInt32LE - arr.writeUInt32BE = BP.writeUInt32BE - arr.writeInt8 = BP.writeInt8 - arr.writeInt16LE = BP.writeInt16LE - arr.writeInt16BE = BP.writeInt16BE - arr.writeInt32LE = BP.writeInt32LE - arr.writeInt32BE = BP.writeInt32BE - arr.writeFloatLE = BP.writeFloatLE - arr.writeFloatBE = BP.writeFloatBE - arr.writeDoubleLE = BP.writeDoubleLE - arr.writeDoubleBE = BP.writeDoubleBE - arr.fill = BP.fill - arr.inspect = BP.inspect - arr.toArrayBuffer = BP.toArrayBuffer + var width = tags[256]; + var height = tags[257]; - return arr + if (!width || !height) { + throw new TypeError('Invalid Tiff, missing tags'); + } + + return { + 'width': width, + 'height': height + }; } - var INVALID_BASE64_RE = /[^+\/0-9A-z]/g + module.exports = { + 'detect': isTIFF, + 'calculate': calculate + }; - function base64clean (str) { - // Node strips out invalid characters like \n and \t from the string, base64-js does not - str = stringtrim(str).replace(INVALID_BASE64_RE, '') - // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not - while (str.length % 4 !== 0) { - str = str + '=' - } - return str - } + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8).Buffer)) - function stringtrim (str) { - if (str.trim) return str.trim() - return str.replace(/^\s+|\s+$/g, '') - } +/***/ }, +/* 16 */ +/***/ function(module, exports, __webpack_require__) { - function isArrayish (subject) { - return isArray(subject) || Buffer.isBuffer(subject) || - subject && typeof subject === 'object' && - typeof subject.length === 'number' - } + 'use strict'; - function toHex (n) { - if (n < 16) return '0' + n.toString(16) - return n.toString(16) - } + // based on https://developers.google.com/speed/webp/docs/riff_container - function utf8ToBytes (str) { - var byteArray = [] - for (var i = 0; i < str.length; i++) { - var b = str.charCodeAt(i) - if (b <= 0x7F) { - byteArray.push(b) - } else { - var start = i - if (b >= 0xD800 && b <= 0xDFFF) i++ - var h = encodeURIComponent(str.slice(start, i+1)).substr(1).split('%') - for (var j = 0; j < h.length; j++) { - byteArray.push(parseInt(h[j], 16)) - } - } - } - return byteArray + function isWebP (buffer) { + var riffHeader = 'RIFF' === buffer.toString('ascii', 0, 4); + var webpHeader = 'WEBP' === buffer.toString('ascii', 8, 12); + var vp8Header = 'VP8' === buffer.toString('ascii', 12, 15); + return (riffHeader && webpHeader && vp8Header); } - function asciiToBytes (str) { - var byteArray = [] - for (var i = 0; i < str.length; i++) { - // Node's code seems to be doing this and not & 0x7F.. - byteArray.push(str.charCodeAt(i) & 0xFF) + function calculate (buffer) { + + var chunkHeader = buffer.toString('ascii', 12, 16); + buffer = buffer.slice(20, 30); + + // Lossless webp stream signature + if (chunkHeader === 'VP8 ' && buffer[0] !== 0x2f) { + return calculateLossy(buffer); } - return byteArray - } - function utf16leToBytes (str) { - var c, hi, lo - var byteArray = [] - for (var i = 0; i < str.length; i++) { - c = str.charCodeAt(i) - hi = c >> 8 - lo = c % 256 - byteArray.push(lo) - byteArray.push(hi) + // Lossy webp stream signature + var signature = buffer.toString('hex', 3, 6); + if (chunkHeader === 'VP8L' && signature !== '9d012a') { + return calculateLossless(buffer); } - return byteArray + return false; } - function base64ToBytes (str) { - return base64.toByteArray(str) + function calculateLossless (buffer) { + return { + 'width': 1 + (((buffer[2] & 0x3F) << 8) | buffer[1]), + 'height': 1 + (((buffer[4] & 0xF) << 10) | (buffer[3] << 2) | + ((buffer[2] & 0xC0) >> 6)) + }; } - function blitBuffer (src, dst, offset, length, unitSize) { - if (unitSize) length -= length % unitSize; - for (var i = 0; i < length; i++) { - if ((i + offset >= dst.length) || (i >= src.length)) - break - dst[i + offset] = src[i] - } - return i + function calculateLossy (buffer) { + // `& 0x3fff` returns the last 14 bits + // TO-DO: include webp scaling in the calculations + return { + 'width': buffer.readInt16LE(6) & 0x3fff, + 'height': buffer.readInt16LE(8) & 0x3fff + }; } - function decodeUtf8Char (str) { - try { - return decodeURIComponent(str) - } catch (err) { - return String.fromCharCode(0xFFFD) // UTF 8 invalid char - } - } - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(16).Buffer)) + module.exports = { + 'detect': isWebP, + 'calculate': calculate + }; + /***/ }, /* 17 */ /***/ function(module, exports, __webpack_require__) { - + /***/ }, /* 18 */ @@ -2324,69 +2603,40 @@ return /******/ (function(modules) { // webpackBootstrap // shim for using process in browser var process = module.exports = {}; + var queue = []; + var draining = false; - process.nextTick = (function () { - var canSetImmediate = typeof window !== 'undefined' - && window.setImmediate; - var canMutationObserver = typeof window !== 'undefined' - && window.MutationObserver; - var canPost = typeof window !== 'undefined' - && window.postMessage && window.addEventListener - ; - - if (canSetImmediate) { - return function (f) { return window.setImmediate(f) }; + function drainQueue() { + if (draining) { + return; } - - var queue = []; - - if (canMutationObserver) { - var hiddenDiv = document.createElement("div"); - var observer = new MutationObserver(function () { - var queueList = queue.slice(); - queue.length = 0; - queueList.forEach(function (fn) { - fn(); - }); - }); - - observer.observe(hiddenDiv, { attributes: true }); - - return function nextTick(fn) { - if (!queue.length) { - hiddenDiv.setAttribute('yes', 'no'); - } - queue.push(fn); - }; + draining = true; + var currentQueue; + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + var i = -1; + while (++i < len) { + currentQueue[i](); + } + len = queue.length; } - - if (canPost) { - window.addEventListener('message', function (ev) { - var source = ev.source; - if ((source === window || source === null) && ev.data === 'process-tick') { - ev.stopPropagation(); - if (queue.length > 0) { - var fn = queue.shift(); - fn(); - } - } - }, true); - - return function nextTick(fn) { - queue.push(fn); - window.postMessage('process-tick', '*'); - }; + draining = false; + } + process.nextTick = function (fun) { + queue.push(fun); + if (!draining) { + setTimeout(drainQueue, 0); } - - return function nextTick(fn) { - setTimeout(fn, 0); - }; - })(); + }; process.title = 'browser'; process.browser = true; process.env = {}; process.argv = []; + process.version = ''; // empty string to avoid regexp issues + process.versions = {}; function noop() {} @@ -2407,6 +2657,7 @@ return /******/ (function(modules) { // webpackBootstrap process.chdir = function (dir) { throw new Error('process.chdir is not supported'); }; + process.umask = function() { return 0; }; /***/ }, @@ -2556,12 +2807,16 @@ return /******/ (function(modules) { // webpackBootstrap var NUMBER = '0'.charCodeAt(0) var LOWER = 'a'.charCodeAt(0) var UPPER = 'A'.charCodeAt(0) + var PLUS_URL_SAFE = '-'.charCodeAt(0) + var SLASH_URL_SAFE = '_'.charCodeAt(0) function decode (elt) { var code = elt.charCodeAt(0) - if (code === PLUS) + if (code === PLUS || + code === PLUS_URL_SAFE) return 62 // '+' - if (code === SLASH) + if (code === SLASH || + code === SLASH_URL_SAFE) return 63 // '/' if (code < NUMBER) return -1 //no match @@ -2667,3 +2922,4 @@ return /******/ (function(modules) { // webpackBootstrap /***/ } /******/ ]) }); +; \ No newline at end of file diff --git a/dist/markdown-it-imsize.min.js b/dist/markdown-it-imsize.min.js index fd87b67f3db6155a8e92e24a561dc3aff99e0ff0..0396cfe73f449ba6a7d8d4a209e0abed3ffd455f 100644 --- a/dist/markdown-it-imsize.min.js +++ b/dist/markdown-it-imsize.min.js @@ -1,2 +1,2 @@ -(function webpackUniversalModuleDefinition(root,factory){if(typeof exports==="object"&&typeof module==="object")module.exports=factory();else if(typeof define==="function"&&define.amd)define(factory);else if(typeof exports==="object")exports["markdown-it-imsize.js"]=factory();else root["markdown-it-imsize.js"]=factory()})(this,function(){return function(modules){var installedModules={};function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={exports:{},id:moduleId,loaded:false};modules[moduleId].call(module.exports,module,module.exports,__webpack_require__);module.loaded=true;return module.exports}__webpack_require__.m=modules;__webpack_require__.c=installedModules;__webpack_require__.p="";return __webpack_require__(0)}([function(module,exports,__webpack_require__){"use strict";var sizeOf=__webpack_require__(3);var parseImageSize=__webpack_require__(1);var normalizeReference=__webpack_require__(2);function image_with_size(md,options){return function(state,silent){var code,href,label,labelEnd,labelStart,pos,ref,res,title,width="",height="",tokens,start,oldPos=state.pos,max=state.posMax;if(state.src.charCodeAt(state.pos)!==33){return false}if(state.src.charCodeAt(state.pos+1)!==91){return false}labelStart=state.pos+2;labelEnd=md.helpers.parseLinkLabel(state,state.pos+1,false);if(labelEnd<0){return false}pos=labelEnd+1;if(pos<max&&state.src.charCodeAt(pos)===40){pos++;for(;pos<max;pos++){code=state.src.charCodeAt(pos);if(code!==32&&code!==10){break}}if(pos>=max){return false}start=pos;res=md.helpers.parseLinkDestination(state.src,pos,state.posMax);if(res.ok&&state.md.inline.validateLink(res.str)){href=res.str;pos=res.pos}else{href=""}start=pos;for(;pos<max;pos++){code=state.src.charCodeAt(pos);if(code!==32&&code!==10){break}}res=md.helpers.parseLinkTitle(state.src,pos,state.posMax);if(pos<max&&start!==pos&&res.ok){title=res.str;pos=res.pos;for(;pos<max;pos++){code=state.src.charCodeAt(pos);if(code!==32&&code!==10){break}}}else{title=""}if(pos-1>=0){code=state.src.charCodeAt(pos-1);if(code===32){res=parseImageSize(state.src,pos,state.posMax);if(res.ok){width=res.width;height=res.height;pos=res.pos;for(;pos<max;pos++){code=state.src.charCodeAt(pos);if(code!==32&&code!==10){break}}}}}if(pos>=max||state.src.charCodeAt(pos)!==41){state.pos=oldPos;return false}pos++}else{if(typeof state.env.references==="undefined"){return false}for(;pos<max;pos++){code=state.src.charCodeAt(pos);if(code!==32&&code!==10){break}}if(pos<max&&state.src.charCodeAt(pos)===91){start=pos+1;pos=md.helpers.parseLinkLabel(state,pos);if(pos>=0){label=state.src.slice(start,pos++)}else{pos=labelEnd+1}}else{pos=labelEnd+1}if(!label){label=state.src.slice(labelStart,labelEnd)}ref=state.env.references[normalizeReference(label)];if(!ref){state.pos=oldPos;return false}href=ref.href;title=ref.title}if(!silent){state.pos=labelStart;state.posMax=labelEnd;var newState=new state.md.inline.State(state.src.slice(labelStart,labelEnd),state.md,state.env,tokens=[]);newState.md.inline.tokenize(newState);if(options){if(options.autofill&&width===""&&height===""){try{var dimensions=sizeOf(href);width=dimensions.width;height=dimensions.height}catch(e){}}}state.push({type:"image",src:href,title:title,tokens:tokens,level:state.level,width:width,height:height})}state.pos=pos;state.posMax=max;return true}}function tokenize_imsize(md){return function(tokens,idx,options,env,self){var src=' src="'+md.utils.escapeHtml(tokens[idx].src)+'"';var title="";if(tokens[idx].title){title=' title="'+md.utils.escapeHtml(md.utils.replaceEntities(tokens[idx].title))+'"'}var alt=' alt="'+self.renderInlineAsText(tokens[idx].tokens,options,env)+'"';var width=tokens[idx].width!==""?' width="'+tokens[idx].width+'"':"";var height=tokens[idx].height!==""?' height="'+tokens[idx].height+'"':"";var size=width+height;var suffix=options.xhtmlOut?" /":"";return"<img"+src+alt+title+size+suffix+">"}}module.exports=function imsize_plugin(md,options){md.renderer.rules.image=tokenize_imsize(md);md.inline.ruler.before("emphasis","image",image_with_size(md,options))}},function(module,exports,__webpack_require__){"use strict";function parseNextNumber(str,pos,max){var code,start=pos,result={ok:false,pos:pos,value:""};code=str.charCodeAt(pos);while(pos<max&&(code>=48&&code<=57)){code=str.charCodeAt(++pos)}result.ok=true;result.pos=pos;result.value=str.slice(start,pos);return result}module.exports=function parseImageSize(str,pos,max){var code,result={ok:false,pos:0,width:"",height:""};if(pos>=max){return result}code=str.charCodeAt(pos);if(code!==61){return result}pos++;code=str.charCodeAt(pos);if(code!==120&&(code<48||code>57)){return result}var resultW=parseNextNumber(str,pos,max);pos=resultW.pos;code=str.charCodeAt(pos);if(code!==120){return result}pos++;var resultH=parseNextNumber(str,pos,max);pos=resultH.pos;result.width=resultW.value;result.height=resultH.value;result.pos=pos;result.ok=true;return result}},function(module,exports,__webpack_require__){"use strict";module.exports=function normalizeReference(str){return str.trim().replace(/\s+/g," ").toUpperCase()}},function(module,exports,__webpack_require__){(function(Buffer){"use strict";var fs=__webpack_require__(17);var path=__webpack_require__(7);var detector=__webpack_require__(4);var handlers={};var types=__webpack_require__(6);types.forEach(function(type){handlers[type]=__webpack_require__(5)("./"+type)});var MaxBufferSize=128*1024;function lookup(buffer,filepath){var type=detector(buffer,filepath);if(type in handlers){var size=handlers[type].calculate(buffer,filepath);if(size!==false){size.type=type;return size}}throw new TypeError("Unsupported file type")}function asyncFileToBuffer(filepath,callback){fs.open(filepath,"r",function(err0,descriptor){if(err0){return callback(err0)}var size=fs.fstatSync(descriptor).size;var bufferSize=Math.min(size,MaxBufferSize);var buffer=new Buffer(bufferSize);fs.read(descriptor,buffer,0,bufferSize,0,function(err1){if(err1){return callback(err1)}fs.close(descriptor,function(err2){callback(err2,buffer)})})})}function syncFileToBuffer(filepath){var descriptor=fs.openSync(filepath,"r");var size=fs.fstatSync(descriptor).size;var bufferSize=Math.min(size,MaxBufferSize);var buffer=new Buffer(bufferSize);fs.readSync(descriptor,buffer,0,bufferSize,0);fs.closeSync(descriptor);return buffer}module.exports=function(input,callback){if(typeof input!=="string"){throw new TypeError("Input must be file name")}var filepath=path.resolve(input);if(typeof callback==="function"){asyncFileToBuffer(filepath,function(err,buffer){if(err){return callback(err)}var dimensions;try{dimensions=lookup(buffer,filepath)}catch(e){err=e}callback(err,dimensions)})}else{var buffer=syncFileToBuffer(filepath);return lookup(buffer,filepath)}}}).call(exports,__webpack_require__(16).Buffer)},function(module,exports,__webpack_require__){"use strict";var typeMap={};var types=__webpack_require__(6);types.forEach(function(type){typeMap[type]=__webpack_require__(5)("./"+type).detect});module.exports=function(buffer,filepath){var type,result;for(type in typeMap){if(type in typeMap){result=typeMap[type](buffer,filepath);if(result){return type}}}throw new TypeError("Unsupported type")}},function(module,exports,__webpack_require__){var map={"./bmp":8,"./bmp.js":8,"./gif":9,"./gif.js":9,"./jpg":10,"./jpg.js":10,"./png":11,"./png.js":11,"./psd":12,"./psd.js":12,"./svg":13,"./svg.js":13,"./tiff":14,"./tiff.js":14,"./webp":15,"./webp.js":15};function webpackContext(req){return __webpack_require__(webpackContextResolve(req))}function webpackContextResolve(req){return map[req]||function(){throw new Error("Cannot find module '"+req+"'.")}()}webpackContext.keys=function webpackContextKeys(){return Object.keys(map)};webpackContext.resolve=webpackContextResolve;module.exports=webpackContext;webpackContext.id=5},function(module,exports,__webpack_require__){"use strict";module.exports=["bmp","gif","jpg","png","tiff"]},function(module,exports,__webpack_require__){(function(process){function normalizeArray(parts,allowAboveRoot){var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if(last==="."){parts.splice(i,1)}else if(last===".."){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up--;up){parts.unshift("..")}}return parts}var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var splitPath=function(filename){return splitPathRe.exec(filename).slice(1)};exports.resolve=function(){var resolvedPath="",resolvedAbsolute=false;for(var i=arguments.length-1;i>=-1&&!resolvedAbsolute;i--){var path=i>=0?arguments[i]:process.cwd();if(typeof path!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!path){continue}resolvedPath=path+"/"+resolvedPath;resolvedAbsolute=path.charAt(0)==="/"}resolvedPath=normalizeArray(filter(resolvedPath.split("/"),function(p){return!!p}),!resolvedAbsolute).join("/");return(resolvedAbsolute?"/":"")+resolvedPath||"."};exports.normalize=function(path){var isAbsolute=exports.isAbsolute(path),trailingSlash=substr(path,-1)==="/";path=normalizeArray(filter(path.split("/"),function(p){return!!p}),!isAbsolute).join("/");if(!path&&!isAbsolute){path="."}if(path&&trailingSlash){path+="/"}return(isAbsolute?"/":"")+path};exports.isAbsolute=function(path){return path.charAt(0)==="/"};exports.join=function(){var paths=Array.prototype.slice.call(arguments,0);return exports.normalize(filter(paths,function(p,index){if(typeof p!=="string"){throw new TypeError("Arguments to path.join must be strings")}return p}).join("/"))};exports.relative=function(from,to){from=exports.resolve(from).substr(1);to=exports.resolve(to).substr(1);function trim(arr){var start=0;for(;start<arr.length;start++){if(arr[start]!=="")break}var end=arr.length-1;for(;end>=0;end--){if(arr[end]!=="")break}if(start>end)return[];return arr.slice(start,end-start+1)}var fromParts=trim(from.split("/"));var toParts=trim(to.split("/"));var length=Math.min(fromParts.length,toParts.length);var samePartsLength=length;for(var i=0;i<length;i++){if(fromParts[i]!==toParts[i]){samePartsLength=i;break}}var outputParts=[];for(var i=samePartsLength;i<fromParts.length;i++){outputParts.push("..")}outputParts=outputParts.concat(toParts.slice(samePartsLength));return outputParts.join("/")};exports.sep="/";exports.delimiter=":";exports.dirname=function(path){var result=splitPath(path),root=result[0],dir=result[1];if(!root&&!dir){return"."}if(dir){dir=dir.substr(0,dir.length-1)}return root+dir};exports.basename=function(path,ext){var f=splitPath(path)[2];if(ext&&f.substr(-1*ext.length)===ext){f=f.substr(0,f.length-ext.length)}return f};exports.extname=function(path){return splitPath(path)[3]};function filter(xs,f){if(xs.filter)return xs.filter(f);var res=[];for(var i=0;i<xs.length;i++){if(f(xs[i],i,xs))res.push(xs[i])}return res}var substr="ab".substr(-1)==="b"?function(str,start,len){return str.substr(start,len)}:function(str,start,len){if(start<0)start=str.length+start;return str.substr(start,len)}}).call(exports,__webpack_require__(19))},function(module,exports,__webpack_require__){"use strict";function isBMP(buffer){return"BM"===buffer.toString("ascii",0,2)}function calculate(buffer){return{width:buffer.readUInt32LE(18),height:buffer.readUInt32LE(22)}}module.exports={detect:isBMP,calculate:calculate}},function(module,exports,__webpack_require__){"use strict";var gifRegexp=/^GIF8[7,9]a/;function isGIF(buffer){var signature=buffer.toString("ascii",0,6);return gifRegexp.test(signature)}function calculate(buffer){return{width:buffer.readUInt16LE(6),height:buffer.readUInt16LE(8)}}module.exports={detect:isGIF,calculate:calculate}},function(module,exports,__webpack_require__){"use strict";var validJFIFMarkers={ffdb:"0001010101",ffe0:"4a46494600",ffe1:"4578696600",ffe2:"4943435f50",ffe3:"",ffe8:"5350494646",ffec:"4475636b79",ffed:"50686f746f",ffee:"41646f6265"};var red=["[31m","[39m"];function isJPG(buffer){var SOIMarker=buffer.toString("hex",0,2);var JFIFMarker=buffer.toString("hex",2,4);if("ffd8"!==SOIMarker){return false}var got=buffer.toString("hex",6,11);var expected=JFIFMarker&&validJFIFMarkers[JFIFMarker];if(expected===""){console.warn(red[0]+"this looks like a unrecognised jpeg\n"+"please report the issue here\n"+red[1]," https://github.com/netroy/image-size/issues/new\n");return false}return got===expected||JFIFMarker==="ffdb"}function extractSize(buffer,i){return{height:buffer.readUInt16BE(i),width:buffer.readUInt16BE(i+2)}}function validateBuffer(buffer,i){if(i>buffer.length){throw new TypeError("Corrupt JPG, exceeded buffer limits")}if(buffer[i]!==255){throw new TypeError("Invalid JPG, marker table corrupted")}}function calculate(buffer){buffer=buffer.slice(4);var i,next;while(buffer.length){i=buffer.readUInt16BE(0);validateBuffer(buffer,i);next=buffer[i+1];if(next===192||next===194){return extractSize(buffer,i+5)}buffer=buffer.slice(i+2)}throw new TypeError("Invalid JPG, no size found")}module.exports={detect:isJPG,calculate:calculate}},function(module,exports,__webpack_require__){"use strict";var pngSignature="PNG\r\n\n";function isPNG(buffer){if(pngSignature===buffer.toString("ascii",1,8)){if("IHDR"!==buffer.toString("ascii",12,16)){throw new TypeError("invalid png")}return true}}function calculate(buffer){return{width:buffer.readUInt32BE(16),height:buffer.readUInt32BE(20)}}module.exports={detect:isPNG,calculate:calculate}},function(module,exports,__webpack_require__){"use strict";function isPSD(buffer){return"8BPS"===buffer.toString("ascii",0,4)}function calculate(buffer){return{width:buffer.readUInt32BE(18),height:buffer.readUInt32BE(14)}}module.exports={detect:isPSD,calculate:calculate}},function(module,exports,__webpack_require__){"use strict";var svgReg=/<svg[^>]+[^>]*>/;function isSVG(buffer){return svgReg.test(buffer)}var extractorRegExps={root:/<svg [^>]+>/,width:/(^|\s)width\s*=\s*"(.+?)"/i,height:/(^|\s)height\s*=\s*"(.+?)"/i,viewbox:/(^|\s)viewbox\s*=\s*"(.+?)"/i};function getRatio(viewbox){var ratio=1;if(viewbox&&viewbox[2]){var dim=viewbox[2].split(/\s/g);if(dim.length===4){dim=dim.map(function(i){return parseInt(i,10)});ratio=(dim[2]-dim[0])/(dim[3]-dim[1])}}return ratio}function parse(buffer){var body=buffer.toString().replace(/[\r\n\s]+/g," ");var section=body.match(extractorRegExps.root);var root=section&§ion[0];if(root){var width=root.match(extractorRegExps.width);var height=root.match(extractorRegExps.height);var viewbox=root.match(extractorRegExps.viewbox);var ratio=getRatio(viewbox);return{width:parseInt(width&&width[2],10)||0,height:parseInt(height&&height[2],10)||0,ratio:ratio}}}function calculate(buffer){var parsed=parse(buffer);var width=parsed.width;var height=parsed.height;var ratio=parsed.ratio;if(width&&height){return{width:width,height:height}}else{if(width){return{width:width,height:Math.floor(width/ratio)}}else if(height){return{width:Math.floor(height*ratio),height:height}}else{throw new TypeError("invalid svg")}}}module.exports={detect:isSVG,calculate:calculate}},function(module,exports,__webpack_require__){(function(Buffer){"use strict";var fs=__webpack_require__(17);var readUInt=__webpack_require__(18);function isTIFF(buffer){var hex4=buffer.toString("hex",0,4);return"49492a00"===hex4||"4d4d002a"===hex4}function readIFD(buffer,filepath,isBigEndian){var ifdOffset=readUInt(buffer,32,4,isBigEndian);var bufferSize=1024;var fileSize=fs.statSync(filepath).size;if(ifdOffset+bufferSize>fileSize){bufferSize=fileSize-ifdOffset-10}var endBuffer=new Buffer(bufferSize);var descriptor=fs.openSync(filepath,"r");fs.readSync(descriptor,endBuffer,0,bufferSize,ifdOffset);var ifdBuffer=endBuffer.slice(2);return ifdBuffer}function readValue(buffer,isBigEndian){var low=readUInt(buffer,16,8,isBigEndian);var high=readUInt(buffer,16,10,isBigEndian);return(high<<16)+low}function nextTag(buffer){if(buffer.length>24){return buffer.slice(12)}}function extractTags(buffer,isBigEndian){var tags={};var code,type,length;while(buffer&&buffer.length){code=readUInt(buffer,16,0,isBigEndian);type=readUInt(buffer,16,2,isBigEndian);length=readUInt(buffer,32,4,isBigEndian);if(code===0){break}else{if(length===1&&type===3){tags[code]=readValue(buffer,isBigEndian)}buffer=nextTag(buffer)}}return tags}function determineEndianness(buffer){var signature=buffer.toString("ascii",0,2);if("II"===signature){return"LE"}else if("MM"===signature){return"BE"}}function calculate(buffer,filepath){if(!filepath){throw new TypeError("Tiff doesn't support buffer")}var isBigEndian=determineEndianness(buffer)==="BE";var ifdBuffer=readIFD(buffer,filepath,isBigEndian);var tags=extractTags(ifdBuffer,isBigEndian);var width=tags[256];var height=tags[257];if(!width||!height){throw new TypeError("Invalid Tiff, missing tags")}return{width:width,height:height}}module.exports={detect:isTIFF,calculate:calculate}}).call(exports,__webpack_require__(16).Buffer)},function(module,exports,__webpack_require__){"use strict";function isWebP(buffer){var riffHeader="RIFF"===buffer.toString("ascii",0,4);var webpHeader="WEBP"===buffer.toString("ascii",8,12);var vp8Header="VP8"===buffer.toString("ascii",12,15);return riffHeader&&webpHeader&&vp8Header}function calculate(buffer){var chunkHeader=buffer.toString("ascii",12,16);buffer=buffer.slice(20,30);if(chunkHeader==="VP8 "&&buffer[0]!==47){return calculateLossy(buffer)}var signature=buffer.toString("hex",3,6);if(chunkHeader==="VP8L"&&signature!=="9d012a"){return calculateLossless(buffer)}return false}function calculateLossless(buffer){return{width:1+((buffer[2]&63)<<8|buffer[1]),height:1+((buffer[4]&15)<<10|buffer[3]<<2|(buffer[2]&192)>>6)}}function calculateLossy(buffer){return{width:buffer.readInt16LE(6)&16383,height:buffer.readInt16LE(8)&16383}}module.exports={detect:isWebP,calculate:calculate}},function(module,exports,__webpack_require__){(function(Buffer){var base64=__webpack_require__(22);var ieee754=__webpack_require__(20);var isArray=__webpack_require__(21);exports.Buffer=Buffer;exports.SlowBuffer=Buffer;exports.INSPECT_MAX_BYTES=50;Buffer.poolSize=8192;var kMaxLength=1073741823;Buffer.TYPED_ARRAY_SUPPORT=function(){try{var buf=new ArrayBuffer(0);var arr=new Uint8Array(buf);arr.foo=function(){return 42};return 42===arr.foo()&&typeof arr.subarray==="function"&&new Uint8Array(1).subarray(1,1).byteLength===0}catch(e){return false}}();function Buffer(subject,encoding,noZero){if(!(this instanceof Buffer))return new Buffer(subject,encoding,noZero);var type=typeof subject;var length;if(type==="number")length=subject>0?subject>>>0:0;else if(type==="string"){if(encoding==="base64")subject=base64clean(subject);length=Buffer.byteLength(subject,encoding)}else if(type==="object"&&subject!==null){if(subject.type==="Buffer"&&isArray(subject.data))subject=subject.data;length=+subject.length>0?Math.floor(+subject.length):0}else throw new TypeError("must start with number, buffer, array or string");if(this.length>kMaxLength)throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+kMaxLength.toString(16)+" bytes");var buf;if(Buffer.TYPED_ARRAY_SUPPORT){buf=Buffer._augment(new Uint8Array(length))}else{buf=this;buf.length=length;buf._isBuffer=true}var i;if(Buffer.TYPED_ARRAY_SUPPORT&&typeof subject.byteLength==="number"){buf._set(subject)}else if(isArrayish(subject)){if(Buffer.isBuffer(subject)){for(i=0;i<length;i++)buf[i]=subject.readUInt8(i)}else{for(i=0;i<length;i++)buf[i]=(subject[i]%256+256)%256}}else if(type==="string"){buf.write(subject,0,encoding)}else if(type==="number"&&!Buffer.TYPED_ARRAY_SUPPORT&&!noZero){for(i=0;i<length;i++){buf[i]=0}}return buf}Buffer.isBuffer=function(b){return!!(b!=null&&b._isBuffer)};Buffer.compare=function(a,b){if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b))throw new TypeError("Arguments must be Buffers");var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);i<len&&a[i]===b[i];i++){}if(i!==len){x=a[i];y=b[i]}if(x<y)return-1;if(y<x)return 1;return 0};Buffer.isEncoding=function(encoding){switch(String(encoding).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return true;default:return false}};Buffer.concat=function(list,totalLength){if(!isArray(list))throw new TypeError("Usage: Buffer.concat(list[, length])");if(list.length===0){return new Buffer(0)}else if(list.length===1){return list[0]}var i;if(totalLength===undefined){totalLength=0;for(i=0;i<list.length;i++){totalLength+=list[i].length}}var buf=new Buffer(totalLength);var pos=0;for(i=0;i<list.length;i++){var item=list[i];item.copy(buf,pos);pos+=item.length}return buf};Buffer.byteLength=function(str,encoding){var ret;str=str+"";switch(encoding||"utf8"){case"ascii":case"binary":case"raw":ret=str.length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":ret=str.length*2;break;case"hex":ret=str.length>>>1;break;case"utf8":case"utf-8":ret=utf8ToBytes(str).length;break;case"base64":ret=base64ToBytes(str).length;break;default:ret=str.length}return ret};Buffer.prototype.length=undefined;Buffer.prototype.parent=undefined;Buffer.prototype.toString=function(encoding,start,end){var loweredCase=false;start=start>>>0;end=end===undefined||end===Infinity?this.length:end>>>0;if(!encoding)encoding="utf8";if(start<0)start=0;if(end>this.length)end=this.length;if(end<=start)return"";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"binary":return binarySlice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}};Buffer.prototype.equals=function(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");return Buffer.compare(this,b)===0};Buffer.prototype.inspect=function(){var str="";var max=exports.INSPECT_MAX_BYTES;if(this.length>0){str=this.toString("hex",0,max).match(/.{2}/g).join(" ");if(this.length>max)str+=" ... "}return"<Buffer "+str+">"};Buffer.prototype.compare=function(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");return Buffer.compare(this,b)};Buffer.prototype.get=function(offset){console.log(".get() is deprecated. Access using array indexes instead.");return this.readUInt8(offset)};Buffer.prototype.set=function(v,offset){console.log(".set() is deprecated. Access using array indexes instead.");return this.writeUInt8(v,offset)};function hexWrite(buf,string,offset,length){offset=Number(offset)||0;var remaining=buf.length-offset;if(!length){length=remaining}else{length=Number(length);if(length>remaining){length=remaining}}var strLen=string.length;if(strLen%2!==0)throw new Error("Invalid hex string");if(length>strLen/2){length=strLen/2}for(var i=0;i<length;i++){var byte=parseInt(string.substr(i*2,2),16);if(isNaN(byte))throw new Error("Invalid hex string");buf[offset+i]=byte}return i}function utf8Write(buf,string,offset,length){var charsWritten=blitBuffer(utf8ToBytes(string),buf,offset,length);return charsWritten}function asciiWrite(buf,string,offset,length){var charsWritten=blitBuffer(asciiToBytes(string),buf,offset,length);return charsWritten}function binaryWrite(buf,string,offset,length){return asciiWrite(buf,string,offset,length)}function base64Write(buf,string,offset,length){var charsWritten=blitBuffer(base64ToBytes(string),buf,offset,length);return charsWritten}function utf16leWrite(buf,string,offset,length){var charsWritten=blitBuffer(utf16leToBytes(string),buf,offset,length,2);return charsWritten}Buffer.prototype.write=function(string,offset,length,encoding){if(isFinite(offset)){if(!isFinite(length)){encoding=length;length=undefined}}else{var swap=encoding;encoding=offset;offset=length;length=swap}offset=Number(offset)||0;var remaining=this.length-offset;if(!length){length=remaining}else{length=Number(length);if(length>remaining){length=remaining}}encoding=String(encoding||"utf8").toLowerCase();var ret;switch(encoding){case"hex":ret=hexWrite(this,string,offset,length);break;case"utf8":case"utf-8":ret=utf8Write(this,string,offset,length);break;case"ascii":ret=asciiWrite(this,string,offset,length);break;case"binary":ret=binaryWrite(this,string,offset,length);break;case"base64":ret=base64Write(this,string,offset,length);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":ret=utf16leWrite(this,string,offset,length);break;default:throw new TypeError("Unknown encoding: "+encoding)}return ret};Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){var res="";var tmp="";end=Math.min(buf.length,end);for(var i=start;i<end;i++){if(buf[i]<=127){res+=decodeUtf8Char(tmp)+String.fromCharCode(buf[i]);tmp=""}else{tmp+="%"+buf[i].toString(16)}}return res+decodeUtf8Char(tmp)}function asciiSlice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;i++){ret+=String.fromCharCode(buf[i])}return ret}function binarySlice(buf,start,end){return asciiSlice(buf,start,end)}function hexSlice(buf,start,end){var len=buf.length;if(!start||start<0)start=0;if(!end||end<0||end>len)end=len;var out="";for(var i=start;i<end;i++){out+=toHex(buf[i])}return out}function utf16leSlice(buf,start,end){var bytes=buf.slice(start,end);var res="";for(var i=0;i<bytes.length;i+=2){res+=String.fromCharCode(bytes[i]+bytes[i+1]*256)}return res}Buffer.prototype.slice=function(start,end){var len=this.length;start=~~start;end=end===undefined?len:~~end;if(start<0){start+=len;if(start<0)start=0}else if(start>len){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(end<start)end=start;if(Buffer.TYPED_ARRAY_SUPPORT){return Buffer._augment(this.subarray(start,end))}else{var sliceLen=end-start;var newBuf=new Buffer(sliceLen,undefined,true);for(var i=0;i<sliceLen;i++){newBuf[i]=this[i+start]}return newBuf}};function checkOffset(offset,ext,length){if(offset%1!==0||offset<0)throw new RangeError("offset is not uint");if(offset+ext>length)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUInt8=function(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readInt8=function(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError("buffer must be a Buffer instance");if(value>max||value<min)throw new TypeError("value is out of bounds");if(offset+ext>buf.length)throw new TypeError("index out of range")}Buffer.prototype.writeUInt8=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,255,0);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);this[offset]=value;return offset+1};function objectWriteUInt16(buf,value,offset,littleEndian){if(value<0)value=65535+value+1;for(var i=0,j=Math.min(buf.length-offset,2);i<j;i++){buf[offset+i]=(value&255<<8*(littleEndian?i:1-i))>>>(littleEndian?i:1-i)*8}}Buffer.prototype.writeUInt16LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8}else objectWriteUInt16(this,value,offset,true);return offset+2};Buffer.prototype.writeUInt16BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value}else objectWriteUInt16(this,value,offset,false);return offset+2};function objectWriteUInt32(buf,value,offset,littleEndian){if(value<0)value=4294967295+value+1;for(var i=0,j=Math.min(buf.length-offset,4);i<j;i++){buf[offset+i]=value>>>(littleEndian?i:3-i)*8&255}}Buffer.prototype.writeUInt32LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value}else objectWriteUInt32(this,value,offset,true);return offset+4};Buffer.prototype.writeUInt32BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value}else objectWriteUInt32(this,value,offset,false);return offset+4};Buffer.prototype.writeInt8=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);if(value<0)value=255+value+1;this[offset]=value;return offset+1};Buffer.prototype.writeInt16LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8}else objectWriteUInt16(this,value,offset,true);return offset+2};Buffer.prototype.writeInt16BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value}else objectWriteUInt16(this,value,offset,false);return offset+2};Buffer.prototype.writeInt32LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24}else objectWriteUInt32(this,value,offset,true);return offset+4 -};Buffer.prototype.writeInt32BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value}else objectWriteUInt32(this,value,offset,false);return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(value>max||value<min)throw new TypeError("value is out of bounds");if(offset+ext>buf.length)throw new TypeError("index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){if(!noAssert)checkIEEE754(buf,value,offset,4,3.4028234663852886e38,-3.4028234663852886e38);ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){if(!noAssert)checkIEEE754(buf,value,offset,8,1.7976931348623157e308,-1.7976931348623157e308);ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.copy=function(target,target_start,start,end){var source=this;if(!start)start=0;if(!end&&end!==0)end=this.length;if(!target_start)target_start=0;if(end===start)return;if(target.length===0||source.length===0)return;if(end<start)throw new TypeError("sourceEnd < sourceStart");if(target_start<0||target_start>=target.length)throw new TypeError("targetStart out of bounds");if(start<0||start>=source.length)throw new TypeError("sourceStart out of bounds");if(end<0||end>source.length)throw new TypeError("sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-target_start<end-start)end=target.length-target_start+start;var len=end-start;if(len<1e3||!Buffer.TYPED_ARRAY_SUPPORT){for(var i=0;i<len;i++){target[i+target_start]=this[i+start]}}else{target._set(this.subarray(start,start+len),target_start)}};Buffer.prototype.fill=function(value,start,end){if(!value)value=0;if(!start)start=0;if(!end)end=this.length;if(end<start)throw new TypeError("end < start");if(end===start)return;if(this.length===0)return;if(start<0||start>=this.length)throw new TypeError("start out of bounds");if(end<0||end>this.length)throw new TypeError("end out of bounds");var i;if(typeof value==="number"){for(i=start;i<end;i++){this[i]=value}}else{var bytes=utf8ToBytes(value.toString());var len=bytes.length;for(i=start;i<end;i++){this[i]=bytes[i%len]}}return this};Buffer.prototype.toArrayBuffer=function(){if(typeof Uint8Array!=="undefined"){if(Buffer.TYPED_ARRAY_SUPPORT){return new Buffer(this).buffer}else{var buf=new Uint8Array(this.length);for(var i=0,len=buf.length;i<len;i+=1){buf[i]=this[i]}return buf.buffer}}else{throw new TypeError("Buffer.toArrayBuffer not supported in this browser")}};var BP=Buffer.prototype;Buffer._augment=function(arr){arr.constructor=Buffer;arr._isBuffer=true;arr._get=arr.get;arr._set=arr.set;arr.get=BP.get;arr.set=BP.set;arr.write=BP.write;arr.toString=BP.toString;arr.toLocaleString=BP.toString;arr.toJSON=BP.toJSON;arr.equals=BP.equals;arr.compare=BP.compare;arr.copy=BP.copy;arr.slice=BP.slice;arr.readUInt8=BP.readUInt8;arr.readUInt16LE=BP.readUInt16LE;arr.readUInt16BE=BP.readUInt16BE;arr.readUInt32LE=BP.readUInt32LE;arr.readUInt32BE=BP.readUInt32BE;arr.readInt8=BP.readInt8;arr.readInt16LE=BP.readInt16LE;arr.readInt16BE=BP.readInt16BE;arr.readInt32LE=BP.readInt32LE;arr.readInt32BE=BP.readInt32BE;arr.readFloatLE=BP.readFloatLE;arr.readFloatBE=BP.readFloatBE;arr.readDoubleLE=BP.readDoubleLE;arr.readDoubleBE=BP.readDoubleBE;arr.writeUInt8=BP.writeUInt8;arr.writeUInt16LE=BP.writeUInt16LE;arr.writeUInt16BE=BP.writeUInt16BE;arr.writeUInt32LE=BP.writeUInt32LE;arr.writeUInt32BE=BP.writeUInt32BE;arr.writeInt8=BP.writeInt8;arr.writeInt16LE=BP.writeInt16LE;arr.writeInt16BE=BP.writeInt16BE;arr.writeInt32LE=BP.writeInt32LE;arr.writeInt32BE=BP.writeInt32BE;arr.writeFloatLE=BP.writeFloatLE;arr.writeFloatBE=BP.writeFloatBE;arr.writeDoubleLE=BP.writeDoubleLE;arr.writeDoubleBE=BP.writeDoubleBE;arr.fill=BP.fill;arr.inspect=BP.inspect;arr.toArrayBuffer=BP.toArrayBuffer;return arr};var INVALID_BASE64_RE=/[^+\/0-9A-z]/g;function base64clean(str){str=stringtrim(str).replace(INVALID_BASE64_RE,"");while(str.length%4!==0){str=str+"="}return str}function stringtrim(str){if(str.trim)return str.trim();return str.replace(/^\s+|\s+$/g,"")}function isArrayish(subject){return isArray(subject)||Buffer.isBuffer(subject)||subject&&typeof subject==="object"&&typeof subject.length==="number"}function toHex(n){if(n<16)return"0"+n.toString(16);return n.toString(16)}function utf8ToBytes(str){var byteArray=[];for(var i=0;i<str.length;i++){var b=str.charCodeAt(i);if(b<=127){byteArray.push(b)}else{var start=i;if(b>=55296&&b<=57343)i++;var h=encodeURIComponent(str.slice(start,i+1)).substr(1).split("%");for(var j=0;j<h.length;j++){byteArray.push(parseInt(h[j],16))}}}return byteArray}function asciiToBytes(str){var byteArray=[];for(var i=0;i<str.length;i++){byteArray.push(str.charCodeAt(i)&255)}return byteArray}function utf16leToBytes(str){var c,hi,lo;var byteArray=[];for(var i=0;i<str.length;i++){c=str.charCodeAt(i);hi=c>>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(str)}function blitBuffer(src,dst,offset,length,unitSize){if(unitSize)length-=length%unitSize;for(var i=0;i<length;i++){if(i+offset>=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function decodeUtf8Char(str){try{return decodeURIComponent(str)}catch(err){return String.fromCharCode(65533)}}}).call(exports,__webpack_require__(16).Buffer)},function(module,exports,__webpack_require__){},function(module,exports,__webpack_require__){"use strict";module.exports=function(buffer,bits,offset,isBigEndian){offset=offset||0;var endian=!!isBigEndian?"BE":"LE";var method=buffer["readUInt"+bits+endian];return method.call(buffer,offset)}},function(module,exports,__webpack_require__){var process=module.exports={};process.nextTick=function(){var canSetImmediate=typeof window!=="undefined"&&window.setImmediate;var canMutationObserver=typeof window!=="undefined"&&window.MutationObserver;var canPost=typeof window!=="undefined"&&window.postMessage&&window.addEventListener;if(canSetImmediate){return function(f){return window.setImmediate(f)}}var queue=[];if(canMutationObserver){var hiddenDiv=document.createElement("div");var observer=new MutationObserver(function(){var queueList=queue.slice();queue.length=0;queueList.forEach(function(fn){fn()})});observer.observe(hiddenDiv,{attributes:true});return function nextTick(fn){if(!queue.length){hiddenDiv.setAttribute("yes","no")}queue.push(fn)}}if(canPost){window.addEventListener("message",function(ev){var source=ev.source;if((source===window||source===null)&&ev.data==="process-tick"){ev.stopPropagation();if(queue.length>0){var fn=queue.shift();fn()}}},true);return function nextTick(fn){queue.push(fn);window.postMessage("process-tick","*")}}return function nextTick(fn){setTimeout(fn,0)}}();process.title="browser";process.browser=true;process.env={};process.argv=[];function noop(){}process.on=noop;process.addListener=noop;process.once=noop;process.off=noop;process.removeListener=noop;process.removeAllListeners=noop;process.emit=noop;process.binding=function(name){throw new Error("process.binding is not supported")};process.cwd=function(){return"/"};process.chdir=function(dir){throw new Error("process.chdir is not supported")}},function(module,exports,__webpack_require__){exports.read=function(buffer,offset,isLE,mLen,nBytes){var e,m,eLen=nBytes*8-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,nBits=-7,i=isLE?nBytes-1:0,d=isLE?-1:1,s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8);m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8);if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c,eLen=nBytes*8-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0,i=isLE?0:nBytes-1,d=isLE?1:-1,s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8);e=e<<mLen|m;eLen+=mLen;for(;eLen>0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8);buffer[offset+i-d]|=s*128}},function(module,exports,__webpack_require__){var isArray=Array.isArray;var str=Object.prototype.toString;module.exports=isArray||function(val){return!!val&&"[object Array]"==str.call(val)}},function(module,exports,__webpack_require__){var lookup="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(exports){"use strict";var Arr=typeof Uint8Array!=="undefined"?Uint8Array:Array;var PLUS="+".charCodeAt(0);var SLASH="/".charCodeAt(0);var NUMBER="0".charCodeAt(0);var LOWER="a".charCodeAt(0);var UPPER="A".charCodeAt(0);function decode(elt){var code=elt.charCodeAt(0);if(code===PLUS)return 62;if(code===SLASH)return 63;if(code<NUMBER)return-1;if(code<NUMBER+10)return code-NUMBER+26+26;if(code<UPPER+26)return code-UPPER;if(code<LOWER+26)return code-LOWER+26}function b64ToByteArray(b64){var i,j,l,tmp,placeHolders,arr;if(b64.length%4>0){throw new Error("Invalid string. Length must be a multiple of 4")}var len=b64.length;placeHolders="="===b64.charAt(len-2)?2:"="===b64.charAt(len-1)?1:0;arr=new Arr(b64.length*3/4-placeHolders);l=placeHolders>0?b64.length-4:b64.length;var L=0;function push(v){arr[L++]=v}for(i=0,j=0;i<l;i+=4,j+=3){tmp=decode(b64.charAt(i))<<18|decode(b64.charAt(i+1))<<12|decode(b64.charAt(i+2))<<6|decode(b64.charAt(i+3));push((tmp&16711680)>>16);push((tmp&65280)>>8);push(tmp&255)}if(placeHolders===2){tmp=decode(b64.charAt(i))<<2|decode(b64.charAt(i+1))>>4;push(tmp&255)}else if(placeHolders===1){tmp=decode(b64.charAt(i))<<10|decode(b64.charAt(i+1))<<4|decode(b64.charAt(i+2))>>2;push(tmp>>8&255);push(tmp&255)}return arr}function uint8ToBase64(uint8){var i,extraBytes=uint8.length%3,output="",temp,length;function encode(num){return lookup.charAt(num)}function tripletToBase64(num){return encode(num>>18&63)+encode(num>>12&63)+encode(num>>6&63)+encode(num&63)}for(i=0,length=uint8.length-extraBytes;i<length;i+=3){temp=(uint8[i]<<16)+(uint8[i+1]<<8)+uint8[i+2];output+=tripletToBase64(temp)}switch(extraBytes){case 1:temp=uint8[uint8.length-1];output+=encode(temp>>2);output+=encode(temp<<4&63);output+="==";break;case 2:temp=(uint8[uint8.length-2]<<8)+uint8[uint8.length-1];output+=encode(temp>>10);output+=encode(temp>>4&63);output+=encode(temp<<2&63);output+="=";break}return output}exports.toByteArray=b64ToByteArray;exports.fromByteArray=uint8ToBase64})(false?this.base64js={}:exports)}])}); \ No newline at end of file +(function webpackUniversalModuleDefinition(root,factory){if(typeof exports==="object"&&typeof module==="object")module.exports=factory();else if(typeof define==="function"&&define.amd)define(factory);else if(typeof exports==="object")exports["markdown-it-imsize.js"]=factory();else root["markdown-it-imsize.js"]=factory()})(this,function(){return function(modules){var installedModules={};function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={exports:{},id:moduleId,loaded:false};modules[moduleId].call(module.exports,module,module.exports,__webpack_require__);module.loaded=true;return module.exports}__webpack_require__.m=modules;__webpack_require__.c=installedModules;__webpack_require__.p="";return __webpack_require__(0)}([function(module,exports,__webpack_require__){"use strict";var sizeOf=__webpack_require__(3);var parseImageSize=__webpack_require__(1);var normalizeReference=__webpack_require__(2);function image_with_size(md,options){return function(state,silent){var code,href,label,labelEnd,labelStart,pos,ref,res,title,width="",height="",tokens,start,oldPos=state.pos,max=state.posMax;if(state.src.charCodeAt(state.pos)!==33){return false}if(state.src.charCodeAt(state.pos+1)!==91){return false}labelStart=state.pos+2;labelEnd=md.helpers.parseLinkLabel(state,state.pos+1,false);if(labelEnd<0){return false}pos=labelEnd+1;if(pos<max&&state.src.charCodeAt(pos)===40){pos++;for(;pos<max;pos++){code=state.src.charCodeAt(pos);if(code!==32&&code!==10){break}}if(pos>=max){return false}start=pos;res=md.helpers.parseLinkDestination(state.src,pos,state.posMax);if(res.ok&&state.md.inline.validateLink(res.str)){href=res.str;pos=res.pos}else{href=""}start=pos;for(;pos<max;pos++){code=state.src.charCodeAt(pos);if(code!==32&&code!==10){break}}res=md.helpers.parseLinkTitle(state.src,pos,state.posMax);if(pos<max&&start!==pos&&res.ok){title=res.str;pos=res.pos;for(;pos<max;pos++){code=state.src.charCodeAt(pos);if(code!==32&&code!==10){break}}}else{title=""}if(pos-1>=0){code=state.src.charCodeAt(pos-1);if(code===32){res=parseImageSize(state.src,pos,state.posMax);if(res.ok){width=res.width;height=res.height;pos=res.pos;for(;pos<max;pos++){code=state.src.charCodeAt(pos);if(code!==32&&code!==10){break}}}}}if(pos>=max||state.src.charCodeAt(pos)!==41){state.pos=oldPos;return false}pos++}else{if(typeof state.env.references==="undefined"){return false}for(;pos<max;pos++){code=state.src.charCodeAt(pos);if(code!==32&&code!==10){break}}if(pos<max&&state.src.charCodeAt(pos)===91){start=pos+1;pos=md.helpers.parseLinkLabel(state,pos);if(pos>=0){label=state.src.slice(start,pos++)}else{pos=labelEnd+1}}else{pos=labelEnd+1}if(!label){label=state.src.slice(labelStart,labelEnd)}ref=state.env.references[normalizeReference(label)];if(!ref){state.pos=oldPos;return false}href=ref.href;title=ref.title}if(!silent){state.pos=labelStart;state.posMax=labelEnd;var newState=new state.md.inline.State(state.src.slice(labelStart,labelEnd),state.md,state.env,tokens=[]);newState.md.inline.tokenize(newState);if(options){if(options.autofill&&width===""&&height===""){try{var dimensions=sizeOf(href);width=dimensions.width;height=dimensions.height}catch(e){}}}state.push({type:"image",src:href,title:title,tokens:tokens,level:state.level,width:width,height:height})}state.pos=pos;state.posMax=max;return true}}function tokenize_imsize(md){return function(tokens,idx,options,env,self){var src=' src="'+md.utils.escapeHtml(tokens[idx].src)+'"';var title="";if(tokens[idx].title){title=' title="'+md.utils.escapeHtml(md.utils.replaceEntities(tokens[idx].title))+'"'}var alt=' alt="'+self.renderInlineAsText(tokens[idx].tokens,options,env)+'"';var width=tokens[idx].width!==""?' width="'+tokens[idx].width+'"':"";var height=tokens[idx].height!==""?' height="'+tokens[idx].height+'"':"";var size=width+height;var suffix=options.xhtmlOut?" /":"";return"<img"+src+alt+title+size+suffix+">"}}module.exports=function imsize_plugin(md,options){md.renderer.rules.image=tokenize_imsize(md);md.inline.ruler.before("emphasis","image",image_with_size(md,options))}},function(module,exports,__webpack_require__){"use strict";function parseNextNumber(str,pos,max){var code,start=pos,result={ok:false,pos:pos,value:""};code=str.charCodeAt(pos);while(pos<max&&(code>=48&&code<=57)||code===37){code=str.charCodeAt(++pos)}result.ok=true;result.pos=pos;result.value=str.slice(start,pos);return result}module.exports=function parseImageSize(str,pos,max){var code,result={ok:false,pos:0,width:"",height:""};if(pos>=max){return result}code=str.charCodeAt(pos);if(code!==61){return result}pos++;code=str.charCodeAt(pos);if(code!==120&&(code<48||code>57)){return result}var resultW=parseNextNumber(str,pos,max);pos=resultW.pos;code=str.charCodeAt(pos);if(code!==120){return result}pos++;var resultH=parseNextNumber(str,pos,max);pos=resultH.pos;result.width=resultW.value;result.height=resultH.value;result.pos=pos;result.ok=true;return result}},function(module,exports,__webpack_require__){"use strict";module.exports=function normalizeReference(str){return str.trim().replace(/\s+/g," ").toUpperCase()}},function(module,exports,__webpack_require__){(function(Buffer){"use strict";var fs=__webpack_require__(17);var path=__webpack_require__(7);var detector=__webpack_require__(4);var handlers={};var types=__webpack_require__(6);types.forEach(function(type){handlers[type]=__webpack_require__(5)("./"+type)});var MaxBufferSize=128*1024;function lookup(buffer,filepath){var type=detector(buffer,filepath);if(type in handlers){var size=handlers[type].calculate(buffer,filepath);if(size!==false){size.type=type;return size}}throw new TypeError("Unsupported file type")}function asyncFileToBuffer(filepath,callback){fs.open(filepath,"r",function(err0,descriptor){if(err0){return callback(err0)}var size=fs.fstatSync(descriptor).size;var bufferSize=Math.min(size,MaxBufferSize);var buffer=new Buffer(bufferSize);fs.read(descriptor,buffer,0,bufferSize,0,function(err1){if(err1){return callback(err1)}fs.close(descriptor,function(err2){callback(err2,buffer)})})})}function syncFileToBuffer(filepath){var descriptor=fs.openSync(filepath,"r");var size=fs.fstatSync(descriptor).size;var bufferSize=Math.min(size,MaxBufferSize);var buffer=new Buffer(bufferSize);fs.readSync(descriptor,buffer,0,bufferSize,0);fs.closeSync(descriptor);return buffer}module.exports=function(input,callback){if(typeof input!=="string"){throw new TypeError("Input must be file name")}var filepath=path.resolve(input);if(typeof callback==="function"){asyncFileToBuffer(filepath,function(err,buffer){if(err){return callback(err)}var dimensions;try{dimensions=lookup(buffer,filepath)}catch(e){err=e}callback(err,dimensions)})}else{var buffer=syncFileToBuffer(filepath);return lookup(buffer,filepath)}}}).call(exports,__webpack_require__(8).Buffer)},function(module,exports,__webpack_require__){"use strict";var typeMap={};var types=__webpack_require__(6);types.forEach(function(type){typeMap[type]=__webpack_require__(5)("./"+type).detect});module.exports=function(buffer,filepath){var type,result;for(type in typeMap){if(type in typeMap){result=typeMap[type](buffer,filepath);if(result){return type}}}throw new TypeError("Unsupported type")}},function(module,exports,__webpack_require__){var map={"./bmp":9,"./bmp.js":9,"./gif":10,"./gif.js":10,"./jpg":11,"./jpg.js":11,"./png":12,"./png.js":12,"./psd":13,"./psd.js":13,"./svg":14,"./svg.js":14,"./tiff":15,"./tiff.js":15,"./webp":16,"./webp.js":16};function webpackContext(req){return __webpack_require__(webpackContextResolve(req))}function webpackContextResolve(req){return map[req]||function(){throw new Error("Cannot find module '"+req+"'.")}()}webpackContext.keys=function webpackContextKeys(){return Object.keys(map)};webpackContext.resolve=webpackContextResolve;module.exports=webpackContext;webpackContext.id=5},function(module,exports,__webpack_require__){"use strict";module.exports=["bmp","gif","jpg","png","tiff"]},function(module,exports,__webpack_require__){(function(process){function normalizeArray(parts,allowAboveRoot){var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if(last==="."){parts.splice(i,1)}else if(last===".."){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up--;up){parts.unshift("..")}}return parts}var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var splitPath=function(filename){return splitPathRe.exec(filename).slice(1)};exports.resolve=function(){var resolvedPath="",resolvedAbsolute=false;for(var i=arguments.length-1;i>=-1&&!resolvedAbsolute;i--){var path=i>=0?arguments[i]:process.cwd();if(typeof path!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!path){continue}resolvedPath=path+"/"+resolvedPath;resolvedAbsolute=path.charAt(0)==="/"}resolvedPath=normalizeArray(filter(resolvedPath.split("/"),function(p){return!!p}),!resolvedAbsolute).join("/");return(resolvedAbsolute?"/":"")+resolvedPath||"."};exports.normalize=function(path){var isAbsolute=exports.isAbsolute(path),trailingSlash=substr(path,-1)==="/";path=normalizeArray(filter(path.split("/"),function(p){return!!p}),!isAbsolute).join("/");if(!path&&!isAbsolute){path="."}if(path&&trailingSlash){path+="/"}return(isAbsolute?"/":"")+path};exports.isAbsolute=function(path){return path.charAt(0)==="/"};exports.join=function(){var paths=Array.prototype.slice.call(arguments,0);return exports.normalize(filter(paths,function(p,index){if(typeof p!=="string"){throw new TypeError("Arguments to path.join must be strings")}return p}).join("/"))};exports.relative=function(from,to){from=exports.resolve(from).substr(1);to=exports.resolve(to).substr(1);function trim(arr){var start=0;for(;start<arr.length;start++){if(arr[start]!=="")break}var end=arr.length-1;for(;end>=0;end--){if(arr[end]!=="")break}if(start>end)return[];return arr.slice(start,end-start+1)}var fromParts=trim(from.split("/"));var toParts=trim(to.split("/"));var length=Math.min(fromParts.length,toParts.length);var samePartsLength=length;for(var i=0;i<length;i++){if(fromParts[i]!==toParts[i]){samePartsLength=i;break}}var outputParts=[];for(var i=samePartsLength;i<fromParts.length;i++){outputParts.push("..")}outputParts=outputParts.concat(toParts.slice(samePartsLength));return outputParts.join("/")};exports.sep="/";exports.delimiter=":";exports.dirname=function(path){var result=splitPath(path),root=result[0],dir=result[1];if(!root&&!dir){return"."}if(dir){dir=dir.substr(0,dir.length-1)}return root+dir};exports.basename=function(path,ext){var f=splitPath(path)[2];if(ext&&f.substr(-1*ext.length)===ext){f=f.substr(0,f.length-ext.length)}return f};exports.extname=function(path){return splitPath(path)[3]};function filter(xs,f){if(xs.filter)return xs.filter(f);var res=[];for(var i=0;i<xs.length;i++){if(f(xs[i],i,xs))res.push(xs[i])}return res}var substr="ab".substr(-1)==="b"?function(str,start,len){return str.substr(start,len)}:function(str,start,len){if(start<0)start=str.length+start;return str.substr(start,len)}}).call(exports,__webpack_require__(19))},function(module,exports,__webpack_require__){(function(Buffer){var base64=__webpack_require__(22);var ieee754=__webpack_require__(20);var isArray=__webpack_require__(21);exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;Buffer.poolSize=8192;var kMaxLength=1073741823;var rootParent={};Buffer.TYPED_ARRAY_SUPPORT=function(){try{var buf=new ArrayBuffer(0);var arr=new Uint8Array(buf);arr.foo=function(){return 42};return arr.foo()===42&&typeof arr.subarray==="function"&&new Uint8Array(1).subarray(1,1).byteLength===0}catch(e){return false}}();function Buffer(subject,encoding){var self=this;if(!(self instanceof Buffer))return new Buffer(subject,encoding);var type=typeof subject;var length;if(type==="number"){length=+subject}else if(type==="string"){length=Buffer.byteLength(subject,encoding)}else if(type==="object"&&subject!==null){if(subject.type==="Buffer"&&isArray(subject.data))subject=subject.data;length=+subject.length}else{throw new TypeError("must start with number, buffer, array or string")}if(length>kMaxLength){throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+kMaxLength.toString(16)+" bytes")}if(length<0)length=0;else length>>>=0;if(Buffer.TYPED_ARRAY_SUPPORT){self=Buffer._augment(new Uint8Array(length))}else{self.length=length;self._isBuffer=true}var i;if(Buffer.TYPED_ARRAY_SUPPORT&&typeof subject.byteLength==="number"){self._set(subject)}else if(isArrayish(subject)){if(Buffer.isBuffer(subject)){for(i=0;i<length;i++){self[i]=subject.readUInt8(i)}}else{for(i=0;i<length;i++){self[i]=(subject[i]%256+256)%256}}}else if(type==="string"){self.write(subject,0,encoding)}else if(type==="number"&&!Buffer.TYPED_ARRAY_SUPPORT){for(i=0;i<length;i++){self[i]=0}}if(length>0&&length<=Buffer.poolSize)self.parent=rootParent;return self}function SlowBuffer(subject,encoding){if(!(this instanceof SlowBuffer))return new SlowBuffer(subject,encoding);var buf=new Buffer(subject,encoding);delete buf.parent;return buf}Buffer.isBuffer=function isBuffer(b){return!!(b!=null&&b._isBuffer)};Buffer.compare=function compare(a,b){if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b)){throw new TypeError("Arguments must be Buffers")}if(a===b)return 0;var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);i<len&&a[i]===b[i];i++){}if(i!==len){x=a[i];y=b[i]}if(x<y)return-1;if(y<x)return 1;return 0};Buffer.isEncoding=function isEncoding(encoding){switch(String(encoding).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return true;default:return false}};Buffer.concat=function concat(list,totalLength){if(!isArray(list))throw new TypeError("list argument must be an Array of Buffers.");if(list.length===0){return new Buffer(0)}else if(list.length===1){return list[0]}var i;if(totalLength===undefined){totalLength=0;for(i=0;i<list.length;i++){totalLength+=list[i].length}}var buf=new Buffer(totalLength);var pos=0;for(i=0;i<list.length;i++){var item=list[i];item.copy(buf,pos);pos+=item.length}return buf};Buffer.byteLength=function byteLength(str,encoding){var ret;str=str+"";switch(encoding||"utf8"){case"ascii":case"binary":case"raw":ret=str.length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":ret=str.length*2;break;case"hex":ret=str.length>>>1;break;case"utf8":case"utf-8":ret=utf8ToBytes(str).length;break;case"base64":ret=base64ToBytes(str).length;break;default:ret=str.length}return ret};Buffer.prototype.length=undefined;Buffer.prototype.parent=undefined;Buffer.prototype.toString=function toString(encoding,start,end){var loweredCase=false;start=start>>>0;end=end===undefined||end===Infinity?this.length:end>>>0;if(!encoding)encoding="utf8";if(start<0)start=0;if(end>this.length)end=this.length;if(end<=start)return"";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"binary":return binarySlice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}};Buffer.prototype.equals=function equals(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");if(this===b)return true;return Buffer.compare(this,b)===0};Buffer.prototype.inspect=function inspect(){var str="";var max=exports.INSPECT_MAX_BYTES;if(this.length>0){str=this.toString("hex",0,max).match(/.{2}/g).join(" ");if(this.length>max)str+=" ... "}return"<Buffer "+str+">"};Buffer.prototype.compare=function compare(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");if(this===b)return 0;return Buffer.compare(this,b)};Buffer.prototype.indexOf=function indexOf(val,byteOffset){if(byteOffset>2147483647)byteOffset=2147483647;else if(byteOffset<-2147483648)byteOffset=-2147483648;byteOffset>>=0;if(this.length===0)return-1;if(byteOffset>=this.length)return-1;if(byteOffset<0)byteOffset=Math.max(this.length+byteOffset,0);if(typeof val==="string"){if(val.length===0)return-1;return String.prototype.indexOf.call(this,val,byteOffset)}if(Buffer.isBuffer(val)){return arrayIndexOf(this,val,byteOffset)}if(typeof val==="number"){if(Buffer.TYPED_ARRAY_SUPPORT&&Uint8Array.prototype.indexOf==="function"){return Uint8Array.prototype.indexOf.call(this,val,byteOffset)}return arrayIndexOf(this,[val],byteOffset)}function arrayIndexOf(arr,val,byteOffset){var foundIndex=-1;for(var i=0;byteOffset+i<arr.length;i++){if(arr[byteOffset+i]===val[foundIndex===-1?0:i-foundIndex]){if(foundIndex===-1)foundIndex=i;if(i-foundIndex+1===val.length)return byteOffset+foundIndex}else{foundIndex=-1}}return-1}throw new TypeError("val must be string, number or Buffer")};Buffer.prototype.get=function get(offset){console.log(".get() is deprecated. Access using array indexes instead.");return this.readUInt8(offset)};Buffer.prototype.set=function set(v,offset){console.log(".set() is deprecated. Access using array indexes instead.");return this.writeUInt8(v,offset)};function hexWrite(buf,string,offset,length){offset=Number(offset)||0;var remaining=buf.length-offset;if(!length){length=remaining}else{length=Number(length);if(length>remaining){length=remaining}}var strLen=string.length;if(strLen%2!==0)throw new Error("Invalid hex string");if(length>strLen/2){length=strLen/2}for(var i=0;i<length;i++){var parsed=parseInt(string.substr(i*2,2),16);if(isNaN(parsed))throw new Error("Invalid hex string");buf[offset+i]=parsed}return i}function utf8Write(buf,string,offset,length){var charsWritten=blitBuffer(utf8ToBytes(string,buf.length-offset),buf,offset,length);return charsWritten}function asciiWrite(buf,string,offset,length){var charsWritten=blitBuffer(asciiToBytes(string),buf,offset,length);return charsWritten}function binaryWrite(buf,string,offset,length){return asciiWrite(buf,string,offset,length)}function base64Write(buf,string,offset,length){var charsWritten=blitBuffer(base64ToBytes(string),buf,offset,length);return charsWritten}function utf16leWrite(buf,string,offset,length){var charsWritten=blitBuffer(utf16leToBytes(string,buf.length-offset),buf,offset,length);return charsWritten}Buffer.prototype.write=function write(string,offset,length,encoding){if(isFinite(offset)){if(!isFinite(length)){encoding=length;length=undefined}}else{var swap=encoding;encoding=offset;offset=length;length=swap}offset=Number(offset)||0;if(length<0||offset<0||offset>this.length){throw new RangeError("attempt to write outside buffer bounds")}var remaining=this.length-offset;if(!length){length=remaining}else{length=Number(length);if(length>remaining){length=remaining}}encoding=String(encoding||"utf8").toLowerCase();var ret;switch(encoding){case"hex":ret=hexWrite(this,string,offset,length);break;case"utf8":case"utf-8":ret=utf8Write(this,string,offset,length);break;case"ascii":ret=asciiWrite(this,string,offset,length);break;case"binary":ret=binaryWrite(this,string,offset,length);break;case"base64":ret=base64Write(this,string,offset,length);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":ret=utf16leWrite(this,string,offset,length);break;default:throw new TypeError("Unknown encoding: "+encoding)}return ret};Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){var res="";var tmp="";end=Math.min(buf.length,end);for(var i=start;i<end;i++){if(buf[i]<=127){res+=decodeUtf8Char(tmp)+String.fromCharCode(buf[i]);tmp=""}else{tmp+="%"+buf[i].toString(16)}}return res+decodeUtf8Char(tmp)}function asciiSlice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;i++){ret+=String.fromCharCode(buf[i]&127)}return ret}function binarySlice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;i++){ret+=String.fromCharCode(buf[i])}return ret}function hexSlice(buf,start,end){var len=buf.length;if(!start||start<0)start=0;if(!end||end<0||end>len)end=len;var out="";for(var i=start;i<end;i++){out+=toHex(buf[i])}return out}function utf16leSlice(buf,start,end){var bytes=buf.slice(start,end);var res="";for(var i=0;i<bytes.length;i+=2){res+=String.fromCharCode(bytes[i]+bytes[i+1]*256)}return res}Buffer.prototype.slice=function slice(start,end){var len=this.length;start=~~start;end=end===undefined?len:~~end;if(start<0){start+=len;if(start<0)start=0}else if(start>len){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(end<start)end=start;var newBuf;if(Buffer.TYPED_ARRAY_SUPPORT){newBuf=Buffer._augment(this.subarray(start,end))}else{var sliceLen=end-start;newBuf=new Buffer(sliceLen,undefined);for(var i=0;i<sliceLen;i++){newBuf[i]=this[i+start]}}if(newBuf.length)newBuf.parent=this.parent||this;return newBuf};function checkOffset(offset,ext,length){if(offset%1!==0||offset<0)throw new RangeError("offset is not uint");if(offset+ext>length)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function readUIntLE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i<byteLength&&(mul*=256)){val+=this[offset+i]*mul}return val};Buffer.prototype.readUIntBE=function readUIntBE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert){checkOffset(offset,byteLength,this.length)}var val=this[offset+--byteLength];var mul=1;while(byteLength>0&&(mul*=256)){val+=this[offset+--byteLength]*mul}return val};Buffer.prototype.readUInt8=function readUInt8(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function readUInt16LE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function readUInt16BE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function readUInt32LE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function readUInt32BE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function readIntLE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i<byteLength&&(mul*=256)){val+=this[offset+i]*mul}mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function readIntBE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256)){val+=this[offset+--i]*mul}mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function readInt8(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function readInt16LE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function readInt16BE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function readInt32LE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function readInt32BE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function readFloatLE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function readFloatBE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function readDoubleLE(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function readDoubleBE(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError("buffer must be a Buffer instance");if(value>max||value<min)throw new RangeError("value is out of bounds");if(offset+ext>buf.length)throw new RangeError("index out of range")}Buffer.prototype.writeUIntLE=function writeUIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength),0);var mul=1;var i=0;this[offset]=value&255;while(++i<byteLength&&(mul*=256)){this[offset+i]=value/mul>>>0&255}return offset+byteLength};Buffer.prototype.writeUIntBE=function writeUIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength),0);var i=byteLength-1;var mul=1;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){this[offset+i]=value/mul>>>0&255}return offset+byteLength};Buffer.prototype.writeUInt8=function writeUInt8(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,255,0);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);this[offset]=value;return offset+1};function objectWriteUInt16(buf,value,offset,littleEndian){if(value<0)value=65535+value+1;for(var i=0,j=Math.min(buf.length-offset,2);i<j;i++){buf[offset+i]=(value&255<<8*(littleEndian?i:1-i))>>>(littleEndian?i:1-i)*8}}Buffer.prototype.writeUInt16LE=function writeUInt16LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8}else{objectWriteUInt16(this,value,offset,true)}return offset+2};Buffer.prototype.writeUInt16BE=function writeUInt16BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value}else{objectWriteUInt16(this,value,offset,false)}return offset+2};function objectWriteUInt32(buf,value,offset,littleEndian){if(value<0)value=4294967295+value+1;for(var i=0,j=Math.min(buf.length-offset,4);i<j;i++){buf[offset+i]=value>>>(littleEndian?i:3-i)*8&255}}Buffer.prototype.writeUInt32LE=function writeUInt32LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value}else{objectWriteUInt32(this,value,offset,true)}return offset+4};Buffer.prototype.writeUInt32BE=function writeUInt32BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value}else{objectWriteUInt32(this,value,offset,false)}return offset+4};Buffer.prototype.writeIntLE=function writeIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength-1)-1,-Math.pow(2,8*byteLength-1))}var i=0;var mul=1;var sub=value<0?1:0;this[offset]=value&255;while(++i<byteLength&&(mul*=256)){this[offset+i]=(value/mul>>0)-sub&255}return offset+byteLength};Buffer.prototype.writeIntBE=function writeIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength-1)-1,-Math.pow(2,8*byteLength-1))}var i=byteLength-1;var mul=1;var sub=value<0?1:0;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){this[offset+i]=(value/mul>>0)-sub&255}return offset+byteLength};Buffer.prototype.writeInt8=function writeInt8(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);if(value<0)value=255+value+1;this[offset]=value;return offset+1};Buffer.prototype.writeInt16LE=function writeInt16LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8}else{objectWriteUInt16(this,value,offset,true)}return offset+2};Buffer.prototype.writeInt16BE=function writeInt16BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value}else{objectWriteUInt16(this,value,offset,false)}return offset+2};Buffer.prototype.writeInt32LE=function writeInt32LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24}else{objectWriteUInt32(this,value,offset,true)}return offset+4};Buffer.prototype.writeInt32BE=function writeInt32BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value}else{objectWriteUInt32(this,value,offset,false)}return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(value>max||value<min)throw new RangeError("value is out of bounds");if(offset+ext>buf.length)throw new RangeError("index out of range");if(offset<0)throw new RangeError("index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){if(!noAssert){checkIEEE754(buf,value,offset,4,3.4028234663852886e38,-3.4028234663852886e38)}ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function writeFloatLE(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function writeFloatBE(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){if(!noAssert){checkIEEE754(buf,value,offset,8,1.7976931348623157e308,-1.7976931348623157e308)}ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function writeDoubleLE(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function writeDoubleBE(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.copy=function copy(target,target_start,start,end){if(!start)start=0;if(!end&&end!==0)end=this.length;if(target_start>=target.length)target_start=target.length;if(!target_start)target_start=0;if(end>0&&end<start)end=start;if(end===start)return 0;if(target.length===0||this.length===0)return 0;if(target_start<0){throw new RangeError("targetStart out of bounds")}if(start<0||start>=this.length)throw new RangeError("sourceStart out of bounds"); +if(end<0)throw new RangeError("sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-target_start<end-start){end=target.length-target_start+start}var len=end-start;if(len<1e3||!Buffer.TYPED_ARRAY_SUPPORT){for(var i=0;i<len;i++){target[i+target_start]=this[i+start]}}else{target._set(this.subarray(start,start+len),target_start)}return len};Buffer.prototype.fill=function fill(value,start,end){if(!value)value=0;if(!start)start=0;if(!end)end=this.length;if(end<start)throw new RangeError("end < start");if(end===start)return;if(this.length===0)return;if(start<0||start>=this.length)throw new RangeError("start out of bounds");if(end<0||end>this.length)throw new RangeError("end out of bounds");var i;if(typeof value==="number"){for(i=start;i<end;i++){this[i]=value}}else{var bytes=utf8ToBytes(value.toString());var len=bytes.length;for(i=start;i<end;i++){this[i]=bytes[i%len]}}return this};Buffer.prototype.toArrayBuffer=function toArrayBuffer(){if(typeof Uint8Array!=="undefined"){if(Buffer.TYPED_ARRAY_SUPPORT){return new Buffer(this).buffer}else{var buf=new Uint8Array(this.length);for(var i=0,len=buf.length;i<len;i+=1){buf[i]=this[i]}return buf.buffer}}else{throw new TypeError("Buffer.toArrayBuffer not supported in this browser")}};var BP=Buffer.prototype;Buffer._augment=function _augment(arr){arr.constructor=Buffer;arr._isBuffer=true;arr._set=arr.set;arr.get=BP.get;arr.set=BP.set;arr.write=BP.write;arr.toString=BP.toString;arr.toLocaleString=BP.toString;arr.toJSON=BP.toJSON;arr.equals=BP.equals;arr.compare=BP.compare;arr.indexOf=BP.indexOf;arr.copy=BP.copy;arr.slice=BP.slice;arr.readUIntLE=BP.readUIntLE;arr.readUIntBE=BP.readUIntBE;arr.readUInt8=BP.readUInt8;arr.readUInt16LE=BP.readUInt16LE;arr.readUInt16BE=BP.readUInt16BE;arr.readUInt32LE=BP.readUInt32LE;arr.readUInt32BE=BP.readUInt32BE;arr.readIntLE=BP.readIntLE;arr.readIntBE=BP.readIntBE;arr.readInt8=BP.readInt8;arr.readInt16LE=BP.readInt16LE;arr.readInt16BE=BP.readInt16BE;arr.readInt32LE=BP.readInt32LE;arr.readInt32BE=BP.readInt32BE;arr.readFloatLE=BP.readFloatLE;arr.readFloatBE=BP.readFloatBE;arr.readDoubleLE=BP.readDoubleLE;arr.readDoubleBE=BP.readDoubleBE;arr.writeUInt8=BP.writeUInt8;arr.writeUIntLE=BP.writeUIntLE;arr.writeUIntBE=BP.writeUIntBE;arr.writeUInt16LE=BP.writeUInt16LE;arr.writeUInt16BE=BP.writeUInt16BE;arr.writeUInt32LE=BP.writeUInt32LE;arr.writeUInt32BE=BP.writeUInt32BE;arr.writeIntLE=BP.writeIntLE;arr.writeIntBE=BP.writeIntBE;arr.writeInt8=BP.writeInt8;arr.writeInt16LE=BP.writeInt16LE;arr.writeInt16BE=BP.writeInt16BE;arr.writeInt32LE=BP.writeInt32LE;arr.writeInt32BE=BP.writeInt32BE;arr.writeFloatLE=BP.writeFloatLE;arr.writeFloatBE=BP.writeFloatBE;arr.writeDoubleLE=BP.writeDoubleLE;arr.writeDoubleBE=BP.writeDoubleBE;arr.fill=BP.fill;arr.inspect=BP.inspect;arr.toArrayBuffer=BP.toArrayBuffer;return arr};var INVALID_BASE64_RE=/[^+\/0-9A-z\-]/g;function base64clean(str){str=stringtrim(str).replace(INVALID_BASE64_RE,"");if(str.length<2)return"";while(str.length%4!==0){str=str+"="}return str}function stringtrim(str){if(str.trim)return str.trim();return str.replace(/^\s+|\s+$/g,"")}function isArrayish(subject){return isArray(subject)||Buffer.isBuffer(subject)||subject&&typeof subject==="object"&&typeof subject.length==="number"}function toHex(n){if(n<16)return"0"+n.toString(16);return n.toString(16)}function utf8ToBytes(string,units){units=units||Infinity;var codePoint;var length=string.length;var leadSurrogate=null;var bytes=[];var i=0;for(;i<length;i++){codePoint=string.charCodeAt(i);if(codePoint>55295&&codePoint<57344){if(leadSurrogate){if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}else{codePoint=leadSurrogate-55296<<10|codePoint-56320|65536;leadSurrogate=null}}else{if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}else{leadSurrogate=codePoint;continue}}}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=null}if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<2097152){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i<str.length;i++){byteArray.push(str.charCodeAt(i)&255)}return byteArray}function utf16leToBytes(str,units){var c,hi,lo;var byteArray=[];for(var i=0;i<str.length;i++){if((units-=2)<0)break;c=str.charCodeAt(i);hi=c>>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length){for(var i=0;i<length;i++){if(i+offset>=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function decodeUtf8Char(str){try{return decodeURIComponent(str)}catch(err){return String.fromCharCode(65533)}}}).call(exports,__webpack_require__(8).Buffer)},function(module,exports,__webpack_require__){"use strict";function isBMP(buffer){return"BM"===buffer.toString("ascii",0,2)}function calculate(buffer){return{width:buffer.readUInt32LE(18),height:buffer.readUInt32LE(22)}}module.exports={detect:isBMP,calculate:calculate}},function(module,exports,__webpack_require__){"use strict";var gifRegexp=/^GIF8[7,9]a/;function isGIF(buffer){var signature=buffer.toString("ascii",0,6);return gifRegexp.test(signature)}function calculate(buffer){return{width:buffer.readUInt16LE(6),height:buffer.readUInt16LE(8)}}module.exports={detect:isGIF,calculate:calculate}},function(module,exports,__webpack_require__){"use strict";var validJFIFMarkers={ffdb:"0001010101",ffe0:"4a46494600",ffe1:"4578696600",ffe2:"4943435f50",ffe3:"",ffe8:"5350494646",ffec:"4475636b79",ffed:"50686f746f",ffee:"41646f6265"};var red=["[31m","[39m"];function isJPG(buffer){var SOIMarker=buffer.toString("hex",0,2);var JFIFMarker=buffer.toString("hex",2,4);if("ffd8"!==SOIMarker){return false}var got=buffer.toString("hex",6,11);var expected=JFIFMarker&&validJFIFMarkers[JFIFMarker];if(expected===""){console.warn(red[0]+"this looks like a unrecognised jpeg\n"+"please report the issue here\n"+red[1]," https://github.com/netroy/image-size/issues/new\n");return false}return got===expected||JFIFMarker==="ffdb"}function extractSize(buffer,i){return{height:buffer.readUInt16BE(i),width:buffer.readUInt16BE(i+2)}}function validateBuffer(buffer,i){if(i>buffer.length){throw new TypeError("Corrupt JPG, exceeded buffer limits")}if(buffer[i]!==255){throw new TypeError("Invalid JPG, marker table corrupted")}}function calculate(buffer){buffer=buffer.slice(4);var i,next;while(buffer.length){i=buffer.readUInt16BE(0);validateBuffer(buffer,i);next=buffer[i+1];if(next===192||next===194){return extractSize(buffer,i+5)}buffer=buffer.slice(i+2)}throw new TypeError("Invalid JPG, no size found")}module.exports={detect:isJPG,calculate:calculate}},function(module,exports,__webpack_require__){"use strict";var pngSignature="PNG\r\n\n";function isPNG(buffer){if(pngSignature===buffer.toString("ascii",1,8)){if("IHDR"!==buffer.toString("ascii",12,16)){throw new TypeError("invalid png")}return true}}function calculate(buffer){return{width:buffer.readUInt32BE(16),height:buffer.readUInt32BE(20)}}module.exports={detect:isPNG,calculate:calculate}},function(module,exports,__webpack_require__){"use strict";function isPSD(buffer){return"8BPS"===buffer.toString("ascii",0,4)}function calculate(buffer){return{width:buffer.readUInt32BE(18),height:buffer.readUInt32BE(14)}}module.exports={detect:isPSD,calculate:calculate}},function(module,exports,__webpack_require__){"use strict";var svgReg=/<svg[^>]+[^>]*>/;function isSVG(buffer){return svgReg.test(buffer)}var extractorRegExps={root:/<svg [^>]+>/,width:/(^|\s)width\s*=\s*"(.+?)"/i,height:/(^|\s)height\s*=\s*"(.+?)"/i,viewbox:/(^|\s)viewbox\s*=\s*"(.+?)"/i};function getRatio(viewbox){var ratio=1;if(viewbox&&viewbox[2]){var dim=viewbox[2].split(/\s/g);if(dim.length===4){dim=dim.map(function(i){return parseInt(i,10)});ratio=(dim[2]-dim[0])/(dim[3]-dim[1])}}return ratio}function parse(buffer){var body=buffer.toString().replace(/[\r\n\s]+/g," ");var section=body.match(extractorRegExps.root);var root=section&§ion[0];if(root){var width=root.match(extractorRegExps.width);var height=root.match(extractorRegExps.height);var viewbox=root.match(extractorRegExps.viewbox);var ratio=getRatio(viewbox);return{width:parseInt(width&&width[2],10)||0,height:parseInt(height&&height[2],10)||0,ratio:ratio}}}function calculate(buffer){var parsed=parse(buffer);var width=parsed.width;var height=parsed.height;var ratio=parsed.ratio;if(width&&height){return{width:width,height:height}}else{if(width){return{width:width,height:Math.floor(width/ratio)}}else if(height){return{width:Math.floor(height*ratio),height:height}}else{throw new TypeError("invalid svg")}}}module.exports={detect:isSVG,calculate:calculate}},function(module,exports,__webpack_require__){(function(Buffer){"use strict";var fs=__webpack_require__(17);var readUInt=__webpack_require__(18);function isTIFF(buffer){var hex4=buffer.toString("hex",0,4);return"49492a00"===hex4||"4d4d002a"===hex4}function readIFD(buffer,filepath,isBigEndian){var ifdOffset=readUInt(buffer,32,4,isBigEndian);var bufferSize=1024;var fileSize=fs.statSync(filepath).size;if(ifdOffset+bufferSize>fileSize){bufferSize=fileSize-ifdOffset-10}var endBuffer=new Buffer(bufferSize);var descriptor=fs.openSync(filepath,"r");fs.readSync(descriptor,endBuffer,0,bufferSize,ifdOffset);var ifdBuffer=endBuffer.slice(2);return ifdBuffer}function readValue(buffer,isBigEndian){var low=readUInt(buffer,16,8,isBigEndian);var high=readUInt(buffer,16,10,isBigEndian);return(high<<16)+low}function nextTag(buffer){if(buffer.length>24){return buffer.slice(12)}}function extractTags(buffer,isBigEndian){var tags={};var code,type,length;while(buffer&&buffer.length){code=readUInt(buffer,16,0,isBigEndian);type=readUInt(buffer,16,2,isBigEndian);length=readUInt(buffer,32,4,isBigEndian);if(code===0){break}else{if(length===1&&type===3){tags[code]=readValue(buffer,isBigEndian)}buffer=nextTag(buffer)}}return tags}function determineEndianness(buffer){var signature=buffer.toString("ascii",0,2);if("II"===signature){return"LE"}else if("MM"===signature){return"BE"}}function calculate(buffer,filepath){if(!filepath){throw new TypeError("Tiff doesn't support buffer")}var isBigEndian=determineEndianness(buffer)==="BE";var ifdBuffer=readIFD(buffer,filepath,isBigEndian);var tags=extractTags(ifdBuffer,isBigEndian);var width=tags[256];var height=tags[257];if(!width||!height){throw new TypeError("Invalid Tiff, missing tags")}return{width:width,height:height}}module.exports={detect:isTIFF,calculate:calculate}}).call(exports,__webpack_require__(8).Buffer)},function(module,exports,__webpack_require__){"use strict";function isWebP(buffer){var riffHeader="RIFF"===buffer.toString("ascii",0,4);var webpHeader="WEBP"===buffer.toString("ascii",8,12);var vp8Header="VP8"===buffer.toString("ascii",12,15);return riffHeader&&webpHeader&&vp8Header}function calculate(buffer){var chunkHeader=buffer.toString("ascii",12,16);buffer=buffer.slice(20,30);if(chunkHeader==="VP8 "&&buffer[0]!==47){return calculateLossy(buffer)}var signature=buffer.toString("hex",3,6);if(chunkHeader==="VP8L"&&signature!=="9d012a"){return calculateLossless(buffer)}return false}function calculateLossless(buffer){return{width:1+((buffer[2]&63)<<8|buffer[1]),height:1+((buffer[4]&15)<<10|buffer[3]<<2|(buffer[2]&192)>>6)}}function calculateLossy(buffer){return{width:buffer.readInt16LE(6)&16383,height:buffer.readInt16LE(8)&16383}}module.exports={detect:isWebP,calculate:calculate}},function(module,exports,__webpack_require__){},function(module,exports,__webpack_require__){"use strict";module.exports=function(buffer,bits,offset,isBigEndian){offset=offset||0;var endian=!!isBigEndian?"BE":"LE";var method=buffer["readUInt"+bits+endian];return method.call(buffer,offset)}},function(module,exports,__webpack_require__){var process=module.exports={};var queue=[];var draining=false;function drainQueue(){if(draining){return}draining=true;var currentQueue;var len=queue.length;while(len){currentQueue=queue;queue=[];var i=-1;while(++i<len){currentQueue[i]()}len=queue.length}draining=false}process.nextTick=function(fun){queue.push(fun);if(!draining){setTimeout(drainQueue,0)}};process.title="browser";process.browser=true;process.env={};process.argv=[];process.version="";process.versions={};function noop(){}process.on=noop;process.addListener=noop;process.once=noop;process.off=noop;process.removeListener=noop;process.removeAllListeners=noop;process.emit=noop;process.binding=function(name){throw new Error("process.binding is not supported")};process.cwd=function(){return"/"};process.chdir=function(dir){throw new Error("process.chdir is not supported")};process.umask=function(){return 0}},function(module,exports,__webpack_require__){exports.read=function(buffer,offset,isLE,mLen,nBytes){var e,m,eLen=nBytes*8-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,nBits=-7,i=isLE?nBytes-1:0,d=isLE?-1:1,s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8);m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8);if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c,eLen=nBytes*8-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0,i=isLE?0:nBytes-1,d=isLE?1:-1,s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8);e=e<<mLen|m;eLen+=mLen;for(;eLen>0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8);buffer[offset+i-d]|=s*128}},function(module,exports,__webpack_require__){var isArray=Array.isArray;var str=Object.prototype.toString;module.exports=isArray||function(val){return!!val&&"[object Array]"==str.call(val)}},function(module,exports,__webpack_require__){var lookup="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(exports){"use strict";var Arr=typeof Uint8Array!=="undefined"?Uint8Array:Array;var PLUS="+".charCodeAt(0);var SLASH="/".charCodeAt(0);var NUMBER="0".charCodeAt(0);var LOWER="a".charCodeAt(0);var UPPER="A".charCodeAt(0);var PLUS_URL_SAFE="-".charCodeAt(0);var SLASH_URL_SAFE="_".charCodeAt(0);function decode(elt){var code=elt.charCodeAt(0);if(code===PLUS||code===PLUS_URL_SAFE)return 62;if(code===SLASH||code===SLASH_URL_SAFE)return 63;if(code<NUMBER)return-1;if(code<NUMBER+10)return code-NUMBER+26+26;if(code<UPPER+26)return code-UPPER;if(code<LOWER+26)return code-LOWER+26}function b64ToByteArray(b64){var i,j,l,tmp,placeHolders,arr;if(b64.length%4>0){throw new Error("Invalid string. Length must be a multiple of 4")}var len=b64.length;placeHolders="="===b64.charAt(len-2)?2:"="===b64.charAt(len-1)?1:0;arr=new Arr(b64.length*3/4-placeHolders);l=placeHolders>0?b64.length-4:b64.length;var L=0;function push(v){arr[L++]=v}for(i=0,j=0;i<l;i+=4,j+=3){tmp=decode(b64.charAt(i))<<18|decode(b64.charAt(i+1))<<12|decode(b64.charAt(i+2))<<6|decode(b64.charAt(i+3));push((tmp&16711680)>>16);push((tmp&65280)>>8);push(tmp&255)}if(placeHolders===2){tmp=decode(b64.charAt(i))<<2|decode(b64.charAt(i+1))>>4;push(tmp&255)}else if(placeHolders===1){tmp=decode(b64.charAt(i))<<10|decode(b64.charAt(i+1))<<4|decode(b64.charAt(i+2))>>2;push(tmp>>8&255);push(tmp&255)}return arr}function uint8ToBase64(uint8){var i,extraBytes=uint8.length%3,output="",temp,length;function encode(num){return lookup.charAt(num)}function tripletToBase64(num){return encode(num>>18&63)+encode(num>>12&63)+encode(num>>6&63)+encode(num&63)}for(i=0,length=uint8.length-extraBytes;i<length;i+=3){temp=(uint8[i]<<16)+(uint8[i+1]<<8)+uint8[i+2];output+=tripletToBase64(temp)}switch(extraBytes){case 1:temp=uint8[uint8.length-1];output+=encode(temp>>2);output+=encode(temp<<4&63);output+="==";break;case 2:temp=(uint8[uint8.length-2]<<8)+uint8[uint8.length-1];output+=encode(temp>>10);output+=encode(temp>>4&63);output+=encode(temp<<2&63);output+="=";break}return output}exports.toByteArray=b64ToByteArray;exports.fromByteArray=uint8ToBase64})(false?this.base64js={}:exports)}])}); \ No newline at end of file