diff --git a/bower.json b/bower.json index b4887ae886122c2a2a54e76b160c42ec7b6ecb65..c461a2c55f71d3edb7ebf282488a6be2c20bf5c5 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "markdown-it-imsize", - "version": "0.1.0", + "version": "1.1.0", "authors": [ "tatsy <tatsy.mail@gmail.com>" ], @@ -16,6 +16,8 @@ "node_modules", "bower_components", "test", - "tests" + "helpers", + "Makefile", + "index*" ] } diff --git a/dist/markdown-it-imsize.js b/dist/markdown-it-imsize.js new file mode 100644 index 0000000000000000000000000000000000000000..9d7e7360c3e25c2eb7da5834e281872ee8b422de --- /dev/null +++ b/dist/markdown-it-imsize.js @@ -0,0 +1,2268 @@ +(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ + +},{}],2:[function(require,module,exports){ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org> + * @license MIT + */ + +var base64 = require('base64-js') +var ieee754 = require('ieee754') +var isArray = require('is-array') + +exports.Buffer = Buffer +exports.SlowBuffer = SlowBuffer +exports.INSPECT_MAX_BYTES = 50 +Buffer.poolSize = 8192 // not used by this implementation + +var kMaxLength = 0x3fffffff +var rootParent = {} + +/** + * 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 + } +})() + +/** + * 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) + + var type = typeof subject + + // Find the length + var length + 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') + } + + 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 // Coerce to uint32. + + var self = this + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Preferred: Return an augmented `Uint8Array` instance for best performance + /*eslint-disable consistent-this */ + self = Buffer._augment(new Uint8Array(length)) + /*eslint-enable consistent-this */ + } else { + // Fallback: Return THIS instance of Buffer (created by `new`) + self.length = length + self._isBuffer = true + } + + 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 && !noZero) { + for (i = 0; i < length; i++) { + self[i] = 0 + } + } + + if (length > 0 && length <= Buffer.poolSize) + self.parent = rootParent + + return self +} + +function SlowBuffer (subject, encoding, noZero) { + if (!(this instanceof SlowBuffer)) + return new SlowBuffer(subject, encoding, noZero) + + var buf = new Buffer(subject, encoding, noZero) + delete buf.parent + 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') + + 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 (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 +} + +// pre-set for values that may exist in the future +Buffer.prototype.length = undefined +Buffer.prototype.parent = undefined + +// toString(encoding, start=0, end=buffer.length) +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') + if (this === b) return true + 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') + if (this === b) return 0 + return Buffer.compare(this, b) +} + +// `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) +} + +// `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 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 + } + } + + // 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 + } + 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.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, 2) + return charsWritten +} + +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 + + 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 () { + 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] <= 0x7F) { + 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] & 0x7F) + } + 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 (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, true) + for (var i = 0; i < sliceLen; i++) { + newBuf[i] = this[i + start] + } + } + + if (newBuf.length) + newBuf.parent = this.parent || this + + return newBuf +} + +/* + * 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.readUIntLE = function (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 + + return val +} + +Buffer.prototype.readUIntBE = function (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 *= 0x100)) + val += this[offset + --byteLength] * mul + + return val +} + +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] * 0x1000000) +} + +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]) +} + +Buffer.prototype.readIntLE = function (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 + + if (val >= mul) + val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readIntBE = function (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 *= 0x100)) + val += this[offset + --i] * mul + mul *= 0x80 + + if (val >= mul) + val -= Math.pow(2, 8 * byteLength) + + return val +} + +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.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.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 +} + +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 RangeError('value is out of bounds') + if (offset + ext > buf.length) throw new RangeError('index out of range') +} + +Buffer.prototype.writeUIntLE = function (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 & 0xFF + while (++i < byteLength && (mul *= 0x100)) + this[offset + i] = (value / mul) >>> 0 & 0xFF + + return offset + byteLength +} + +Buffer.prototype.writeUIntBE = function (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 offset + byteLength +} + +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 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 + } +} + +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 +} + +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 + } +} + +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 +} + +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 +} + +Buffer.prototype.writeIntLE = function (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 & 0xFF + while (++i < byteLength && (mul *= 0x100)) + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + + return offset + byteLength +} + +Buffer.prototype.writeIntBE = function (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 & 0xFF + while (--i >= 0 && (mul *= 0x100)) + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + + return offset + byteLength +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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.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) +} + +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.7976931348623157E+308, -1.7976931348623157E+308) + 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) +} + +// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +Buffer.prototype.copy = function (target, target_start, start, end) { + var self = this // source + + 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 || self.length === 0) return 0 + + // Fatal error conditions + if (target_start < 0) + throw new RangeError('targetStart out of bounds') + if (start < 0 || start >= self.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 +} + +// 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 RangeError('end < start') + + // 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 () { + 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 (arr) { + arr.constructor = Buffer + arr._isBuffer = true + + // save reference to original Uint8Array get/set methods before overwriting + arr._get = arr.get + 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.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, 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(0xFFFD) // UTF 8 invalid char + } +} + +},{"base64-js":3,"ieee754":4,"is-array":5}],3:[function(require,module,exports){ +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 //no match + 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') + } + + // the number of equal signs (place holders) + // if there are two placeholders, than the two characters before it + // represent one byte + // if there is only one, then the three characters before it represent 2 bytes + // this is just a cheap hack to not do indexOf twice + var len = b64.length + placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0 + + // base64 is 4/3 + up to two characters of the original data + arr = new Arr(b64.length * 3 / 4 - placeHolders) + + // if there are placeholders, only get up to the last complete 4 chars + 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 & 0xFF0000) >> 16) + push((tmp & 0xFF00) >> 8) + push(tmp & 0xFF) + } + + if (placeHolders === 2) { + tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4) + push(tmp & 0xFF) + } 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) & 0xFF) + push(tmp & 0xFF) + } + + return arr + } + + function uint8ToBase64 (uint8) { + var i, + extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes + output = "", + temp, length + + function encode (num) { + return lookup.charAt(num) + } + + function tripletToBase64 (num) { + return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F) + } + + // go through the array every three bytes, we'll deal with trailing stuff later + 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) + } + + // pad the end with zeros, but make sure to not forget the extra bytes + switch (extraBytes) { + case 1: + temp = uint8[uint8.length - 1] + output += encode(temp >> 2) + output += encode((temp << 4) & 0x3F) + output += '==' + break + case 2: + temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]) + output += encode(temp >> 10) + output += encode((temp >> 4) & 0x3F) + output += encode((temp << 2) & 0x3F) + output += '=' + break + } + + return output + } + + exports.toByteArray = b64ToByteArray + exports.fromByteArray = uint8ToBase64 +}(typeof exports === 'undefined' ? (this.base64js = {}) : exports)) + +},{}],4:[function(require,module,exports){ +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 & 0xff, i += d, m /= 256, mLen -= 8); + + e = (e << mLen) | m; + eLen += mLen; + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8); + + buffer[offset + i - d] |= s * 128; +}; + +},{}],5:[function(require,module,exports){ + +/** + * isArray + */ + +var isArray = Array.isArray; + +/** + * toString + */ + +var str = Object.prototype.toString; + +/** + * Whether or not the given `val` + * is an array. + * + * example: + * + * isArray([]); + * // > true + * isArray(arguments); + * // > false + * isArray(''); + * // > false + * + * @param {mixed} val + * @return {bool} + */ + +module.exports = isArray || function (val) { + return !! val && '[object Array]' == str.call(val); +}; + +},{}],6:[function(require,module,exports){ +(function (process){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// resolves . and .. elements in a path array with directory names there +// must be no slashes, empty elements, or device names (c:\) in the array +// (so also no leading and trailing slashes - it does not distinguish +// relative and absolute paths) +function normalizeArray(parts, allowAboveRoot) { + // if the path tries to go above the root, `up` ends up > 0 + 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 the path is allowed to go above the root, restore leading ..s + if (allowAboveRoot) { + for (; up--; up) { + parts.unshift('..'); + } + } + + return parts; +} + +// Split a filename into [root, dir, basename, ext], unix version +// 'root' is just a slash, or nothing. +var splitPathRe = + /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/; +var splitPath = function(filename) { + return splitPathRe.exec(filename).slice(1); +}; + +// path.resolve([from ...], to) +// posix version +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(); + + // Skip empty and invalid entries + 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) === '/'; + } + + // At this point the path should be resolved to a full absolute path, but + // handle relative paths to be safe (might happen when process.cwd() fails) + + // Normalize the path + resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) { + return !!p; + }), !resolvedAbsolute).join('/'); + + return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.'; +}; + +// path.normalize(path) +// posix version +exports.normalize = function(path) { + var isAbsolute = exports.isAbsolute(path), + trailingSlash = substr(path, -1) === '/'; + + // Normalize the path + path = normalizeArray(filter(path.split('/'), function(p) { + return !!p; + }), !isAbsolute).join('/'); + + if (!path && !isAbsolute) { + path = '.'; + } + if (path && trailingSlash) { + path += '/'; + } + + return (isAbsolute ? '/' : '') + path; +}; + +// posix version +exports.isAbsolute = function(path) { + return path.charAt(0) === '/'; +}; + +// posix version +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('/')); +}; + + +// path.relative(from, to) +// posix version +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) { + // No dirname whatsoever + return '.'; + } + + if (dir) { + // It has a dirname, strip trailing slash + dir = dir.substr(0, dir.length - 1); + } + + return root + dir; +}; + + +exports.basename = function(path, ext) { + var f = splitPath(path)[2]; + // TODO: make this comparison case-insensitive on windows? + 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; +} + +// String.prototype.substr - negative index don't work in IE8 +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(this,require('_process')) +},{"_process":7}],7:[function(require,module,exports){ +// shim for using process in browser + +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 = ''; // empty string to avoid regexp issues + +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'); +}; + +// TODO(shtylman) +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + +},{}],8:[function(require,module,exports){ + +'use strict'; +// Hepler to [reference labels]. No better place for this code :) +// It's only for refs/links and should not be exported anywhere. +module.exports = function normalizeReference(str) { + // use .toUpperCase() instead of .toLowerCase() + // here to avoid a conflict with Object.prototype + // members (most notably, `__proto__`) + return str.trim().replace(/\s+/g, ' ').toUpperCase(); +}; + +},{}],9:[function(require,module,exports){ +// Parse image size +// +'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 >= 0x30 /* 0 */ && code <= 0x39 /* 9 */)) { + 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 !== 0x3d /* = */) { return result; } + + pos++; + + // size must follow = without any white spaces as follows + // (1) =300x200 + // (2) =300x + // (3) =x200 + code = str.charCodeAt(pos); + if (code !== 0x78 /* x */ && (code < 0x30 || code > 0x39) /* [0-9] */) { + return result; + } + + // parse width + var resultW = parseNextNumber(str, pos, max); + pos = resultW.pos; + + // next charactor must be 'x' + code = str.charCodeAt(pos); + if (code !== 0x78 /* x */) { return result; } + + pos++; + + // parse height + 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; +}; + +},{}],10:[function(require,module,exports){ +// Process  +// ^^^^^^^^ this size specification + +'use strict'; + +var sizeOf = require('image-size'); + +var parseImageSize = require('./helpers/parse_image_size'); +var normalizeReference = require('./helpers/normalize_reference.js'); + +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) !== 0x21/* ! */) { return false; } + if (state.src.charCodeAt(state.pos + 1) !== 0x5B/* [ */) { return false; } + + labelStart = state.pos + 2; + labelEnd = md.helpers.parseLinkLabel(state, state.pos + 1, false); + + // parser failed to find ']', so it's not a valid link + if (labelEnd < 0) { return false; } + + pos = labelEnd + 1; + if (pos < max && state.src.charCodeAt(pos) === 0x28/* ( */) { + + // + // Inline link + // + + // [link]( <href> "title" ) + // ^^ skipping these spaces + pos++; + for (; pos < max; pos++) { + code = state.src.charCodeAt(pos); + if (code !== 0x20 && code !== 0x0A) { break; } + } + if (pos >= max) { return false; } + + // [link]( <href> "title" ) + // ^^^^^^ parsing link destination + 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 = ''; + } + + // [link]( <href> "title" ) + // ^^ skipping these spaces + start = pos; + for (; pos < max; pos++) { + code = state.src.charCodeAt(pos); + if (code !== 0x20 && code !== 0x0A) { break; } + } + + // [link]( <href> "title" ) + // ^^^^^^^ parsing link title + res = md.helpers.parseLinkTitle(state.src, pos, state.posMax); + if (pos < max && start !== pos && res.ok) { + title = res.str; + pos = res.pos; + + // [link]( <href> "title" ) + // ^^ skipping these spaces + for (; pos < max; pos++) { + code = state.src.charCodeAt(pos); + if (code !== 0x20 && code !== 0x0A) { break; } + } + } else { + title = ''; + } + + // [link]( <href> "title" =WxH ) + // ^^^^ parsing image size + if (pos - 1 >= 0) { + code = state.src.charCodeAt(pos - 1); + + // there must be at least one white spaces + // between previous field and the size + if (code === 0x20) { + res = parseImageSize(state.src, pos, state.posMax); + if (res.ok) { + width = res.width; + height = res.height; + pos = res.pos; + + // [link]( <href> "title" =WxH ) + // ^^ skipping these spaces + for (; pos < max; pos++) { + code = state.src.charCodeAt(pos); + if (code !== 0x20 && code !== 0x0A) { break; } + } + } + } + } + + if (pos >= max || state.src.charCodeAt(pos) !== 0x29/* ) */) { + state.pos = oldPos; + return false; + } + pos++; + + } else { + // + // Link reference + // + if (typeof state.env.references === 'undefined') { return false; } + + // [foo] [bar] + // ^^ optional whitespace (can include newlines) + for (; pos < max; pos++) { + code = state.src.charCodeAt(pos); + if (code !== 0x20 && code !== 0x0A) { break; } + } + + if (pos < max && state.src.charCodeAt(pos) === 0x5B/* [ */) { + 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; + } + + // covers label === '' and label === undefined + // (collapsed reference link and shortcut reference link respectively) + 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; + } + + // + // We found the end of the link, and know for a fact it's a valid link; + // so all that's left to do is to call tokenizer. + // + 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 'autofill' option is specified + // and width/height are both blank, + // they are filled automatically + 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)); +}; + +},{"./helpers/normalize_reference.js":8,"./helpers/parse_image_size":9,"image-size":11}],11:[function(require,module,exports){ +(function (process,Buffer){ +'use strict'; + +var fs = require('fs'); +var path = require('path'); + +var libpath = process.env.TEST_COV ? '../lib-cov/' : '../lib/'; +var detector = require(libpath + 'detector'); + +var handlers = {}; +var types = require(libpath + 'types'); + +// load all available handlers +types.forEach(function (type) { + handlers[type] = require(libpath + 'types/' + type); +}); + +// Maximum buffer size, with a default of 128 kilobytes. +// TO-DO: make this adaptive based on the initial signature of the image +var MaxBufferSize = 128*1024; + +function lookup (buffer, filepath) { + // detect the file type.. don't rely on the extension + var type = detector(buffer, filepath); + + // find an appropriate handler for this file type + if (type in handlers) { + var size = handlers[type].calculate(buffer, filepath); + if (size !== false) { + size.type = type; + return size; + } + } + + // throw up, if we don't understand the file + throw new TypeError('unsupported file type'); +} + +function asyncFileToBuffer (filepath, callback) { + // open the file in read only mode + fs.open(filepath, 'r', function (err, descriptor) { + if (err) { return callback(err); } + var size = fs.fstatSync(descriptor).size; + var bufferSize = Math.min(size, MaxBufferSize); + var buffer = new Buffer(bufferSize); + // read first buffer block from the file, asynchronously + fs.read(descriptor, buffer, 0, bufferSize, 0, function (err) { + if (err) { return callback(err); } + // close the file, we are done + fs.close(descriptor, function (err) { + callback(err, buffer); + }); + }); + }); +} + +function syncFileToBuffer (filepath) { + // read from the file, synchronously + 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; +} + +/** + * @params input - buffer or relative/absolute path of the image file + * @params callback - optional function for async detection + */ +module.exports = function (input, callback) { + + // Handle buffer input + if (input instanceof Buffer) { + return lookup(input); + } + + // input should be a string at this point + if (typeof input !== 'string') { + throw new TypeError('invalid invocation'); + } + + // resolve the file path + var filepath = path.resolve(input); + + if (typeof callback === 'function') { + asyncFileToBuffer(filepath, function (err, buffer) { + if (err) { return callback(err); } + + // return the dimensions + var dimensions; + try { + dimensions = lookup(buffer, filepath); + } catch (e) { + err = e; + } + callback(err, dimensions); + }); + } else { + var buffer = syncFileToBuffer(filepath); + return lookup(buffer, filepath); + } +}; + +}).call(this,require('_process'),require("buffer").Buffer) +},{"_process":7,"buffer":2,"fs":1,"path":6}]},{},[10]); diff --git a/dist/markdown-it-imsize.min.js b/dist/markdown-it-imsize.min.js new file mode 100644 index 0000000000000000000000000000000000000000..7b001f68804e38c98c3daa93fd2b5f2e45e0c76d --- /dev/null +++ b/dist/markdown-it-imsize.min.js @@ -0,0 +1,262 @@ +!function t(r,e,n){function i(s,a){if(!e[s]){if(!r[s]){var u="function"==typeof require&&require +if(!a&&u)return u(s,!0) +if(o)return o(s,!0) +var h=new Error("Cannot find module '"+s+"'") +throw h.code="MODULE_NOT_FOUND",h}var f=e[s]={exports:{}} +r[s][0].call(f.exports,function(t){var e=r[s][1][t] +return i(e?e:t)},f,f.exports,t,r,e,n)}return e[s].exports}for(var o="function"==typeof require&&require,s=0;s<n.length;s++)i(n[s]) +return i}({1:[function(){},{}],2:[function(t,r,e){function n(t,r,e){if(!(this instanceof n))return new n(t,r,e) +var i,o=typeof t +if("number"===o)i=+t +else if("string"===o)i=n.byteLength(t,r) +else{if("object"!==o||null===t)throw new TypeError("must start with number, buffer, array or string") +"Buffer"===t.type&&x(t.data)&&(t=t.data),i=+t.length}if(i>D)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+D.toString(16)+" bytes") +0>i?i=0:i>>>=0 +var s=this +n.TYPED_ARRAY_SUPPORT?s=n._augment(new Uint8Array(i)):(s.length=i,s._isBuffer=!0) +var a +if(n.TYPED_ARRAY_SUPPORT&&"number"==typeof t.byteLength)s._set(t) +else if(L(t))if(n.isBuffer(t))for(a=0;i>a;a++)s[a]=t.readUInt8(a) +else for(a=0;i>a;a++)s[a]=(t[a]%256+256)%256 +else if("string"===o)s.write(t,0,r) +else if("number"===o&&!n.TYPED_ARRAY_SUPPORT&&!e)for(a=0;i>a;a++)s[a]=0 +return i>0&&i<=n.poolSize&&(s.parent=O),s}function i(t,r,e){if(!(this instanceof i))return new i(t,r,e) +var o=new n(t,r,e) +return delete o.parent,o}function o(t,r,e,n){e=Number(e)||0 +var i=t.length-e +n?(n=Number(n),n>i&&(n=i)):n=i +var o=r.length +if(o%2!==0)throw new Error("Invalid hex string") +n>o/2&&(n=o/2) +for(var s=0;n>s;s++){var a=parseInt(r.substr(2*s,2),16) +if(isNaN(a))throw new Error("Invalid hex string") +t[e+s]=a}return s}function s(t,r,e,n){var i=C(_(r,t.length-e),t,e,n) +return i}function a(t,r,e,n){var i=C(T(r),t,e,n) +return i}function u(t,r,e,n){return a(t,r,e,n)}function h(t,r,e,n){var i=C(P(r),t,e,n) +return i}function f(t,r,e,n){var i=C(S(r,t.length-e),t,e,n,2) +return i}function c(t,r,e){return k.fromByteArray(0===r&&e===t.length?t:t.slice(r,e))}function l(t,r,e){var n="",i="" +e=Math.min(t.length,e) +for(var o=r;e>o;o++)t[o]<=127?(n+=M(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16) +return n+M(i)}function p(t,r,e){var n="" +e=Math.min(t.length,e) +for(var i=r;e>i;i++)n+=String.fromCharCode(127&t[i]) +return n}function g(t,r,e){var n="" +e=Math.min(t.length,e) +for(var i=r;e>i;i++)n+=String.fromCharCode(t[i]) +return n}function w(t,r,e){var n=t.length;(!r||0>r)&&(r=0),(!e||0>e||e>n)&&(e=n) +for(var i="",o=r;e>o;o++)i+=R(t[o]) +return i}function d(t,r,e){for(var n=t.slice(r,e),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]) +return i}function E(t,r,e){if(t%1!==0||0>t)throw new RangeError("offset is not uint") +if(t+r>e)throw new RangeError("Trying to access beyond buffer length")}function v(t,r,e,i,o,s){if(!n.isBuffer(t))throw new TypeError("buffer must be a Buffer instance") +if(r>o||s>r)throw new RangeError("value is out of bounds") +if(e+i>t.length)throw new RangeError("index out of range")}function y(t,r,e,n){0>r&&(r=65535+r+1) +for(var i=0,o=Math.min(t.length-e,2);o>i;i++)t[e+i]=(r&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function A(t,r,e,n){0>r&&(r=4294967295+r+1) +for(var i=0,o=Math.min(t.length-e,4);o>i;i++)t[e+i]=r>>>8*(n?i:3-i)&255}function b(t,r,e,n,i,o){if(r>i||o>r)throw new RangeError("value is out of bounds") +if(e+n>t.length)throw new RangeError("index out of range") +if(0>e)throw new RangeError("index out of range")}function I(t,r,e,n,i){return i||b(t,r,e,4,3.4028234663852886e38,-3.4028234663852886e38),Y.write(t,r,e,n,23,4),e+4}function m(t,r,e,n,i){return i||b(t,r,e,8,1.7976931348623157e308,-1.7976931348623157e308),Y.write(t,r,e,n,52,8),e+8}function B(t){if(t=U(t).replace(j,""),t.length<2)return"" +for(;t.length%4!==0;)t+="=" +return t}function U(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function L(t){return x(t)||n.isBuffer(t)||t&&"object"==typeof t&&"number"==typeof t.length}function R(t){return 16>t?"0"+t.toString(16):t.toString(16)}function _(t,r){r=r||1/0 +for(var e,n=t.length,i=null,o=[],s=0;n>s;s++){if(e=t.charCodeAt(s),e>55295&&57344>e){if(!i){if(e>56319){(r-=3)>-1&&o.push(239,191,189) +continue}if(s+1===n){(r-=3)>-1&&o.push(239,191,189) +continue}i=e +continue}if(56320>e){(r-=3)>-1&&o.push(239,191,189),i=e +continue}e=i-55296<<10|e-56320|65536,i=null}else i&&((r-=3)>-1&&o.push(239,191,189),i=null) +if(128>e){if((r-=1)<0)break +o.push(e)}else if(2048>e){if((r-=2)<0)break +o.push(e>>6|192,63&e|128)}else if(65536>e){if((r-=3)<0)break +o.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(2097152>e))throw new Error("Invalid code point") +if((r-=4)<0)break +o.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return o}function T(t){for(var r=[],e=0;e<t.length;e++)r.push(255&t.charCodeAt(e)) +return r}function S(t,r){for(var e,n,i,o=[],s=0;s<t.length&&!((r-=2)<0);s++)e=t.charCodeAt(s),n=e>>8,i=e%256,o.push(i),o.push(n) +return o}function P(t){return k.toByteArray(B(t))}function C(t,r,e,n,i){i&&(n-=n%i) +for(var o=0;n>o&&!(o+e>=r.length||o>=t.length);o++)r[o+e]=t[o] +return o}function M(t){try{return decodeURIComponent(t)}catch(r){return String.fromCharCode(65533)}}var k=t("base64-js"),Y=t("ieee754"),x=t("is-array") +e.Buffer=n,e.SlowBuffer=i,e.INSPECT_MAX_BYTES=50,n.poolSize=8192 +var D=1073741823,O={} +n.TYPED_ARRAY_SUPPORT=function(){try{var t=new ArrayBuffer(0),r=new Uint8Array(t) +return r.foo=function(){return 42},42===r.foo()&&"function"==typeof r.subarray&&0===new Uint8Array(1).subarray(1,1).byteLength}catch(e){return!1}}(),n.isBuffer=function(t){return!(null==t||!t._isBuffer)},n.compare=function(t,r){if(!n.isBuffer(t)||!n.isBuffer(r))throw new TypeError("Arguments must be Buffers") +if(t===r)return 0 +for(var e=t.length,i=r.length,o=0,s=Math.min(e,i);s>o&&t[o]===r[o];o++);return o!==s&&(e=t[o],i=r[o]),i>e?-1:e>i?1:0},n.isEncoding=function(t){switch(String(t).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!0 +default:return!1}},n.concat=function(t,r){if(!x(t))throw new TypeError("Usage: Buffer.concat(list[, length])") +if(0===t.length)return new n(0) +if(1===t.length)return t[0] +var e +if(void 0===r)for(r=0,e=0;e<t.length;e++)r+=t[e].length +var i=new n(r),o=0 +for(e=0;e<t.length;e++){var s=t[e] +s.copy(i,o),o+=s.length}return i},n.byteLength=function(t,r){var e +switch(t+="",r||"utf8"){case"ascii":case"binary":case"raw":e=t.length +break +case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":e=2*t.length +break +case"hex":e=t.length>>>1 +break +case"utf8":case"utf-8":e=_(t).length +break +case"base64":e=P(t).length +break +default:e=t.length}return e},n.prototype.length=void 0,n.prototype.parent=void 0,n.prototype.toString=function(t,r,e){var n=!1 +if(r>>>=0,e=void 0===e||1/0===e?this.length:e>>>0,t||(t="utf8"),0>r&&(r=0),e>this.length&&(e=this.length),r>=e)return"" +for(;;)switch(t){case"hex":return w(this,r,e) +case"utf8":case"utf-8":return l(this,r,e) +case"ascii":return p(this,r,e) +case"binary":return g(this,r,e) +case"base64":return c(this,r,e) +case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return d(this,r,e) +default:if(n)throw new TypeError("Unknown encoding: "+t) +t=(t+"").toLowerCase(),n=!0}},n.prototype.equals=function(t){if(!n.isBuffer(t))throw new TypeError("Argument must be a Buffer") +return this===t?!0:0===n.compare(this,t)},n.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES +return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},n.prototype.compare=function(t){if(!n.isBuffer(t))throw new TypeError("Argument must be a Buffer") +return this===t?0:n.compare(this,t)},n.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},n.prototype.set=function(t,r){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,r)},n.prototype.write=function(t,r,e,n){if(isFinite(r))isFinite(e)||(n=e,e=void 0) +else{var i=n +n=r,r=e,e=i}if(r=Number(r)||0,0>e||0>r||r>this.length)throw new RangeError("attempt to write outside buffer bounds") +var c=this.length-r +e?(e=Number(e),e>c&&(e=c)):e=c,n=String(n||"utf8").toLowerCase() +var l +switch(n){case"hex":l=o(this,t,r,e) +break +case"utf8":case"utf-8":l=s(this,t,r,e) +break +case"ascii":l=a(this,t,r,e) +break +case"binary":l=u(this,t,r,e) +break +case"base64":l=h(this,t,r,e) +break +case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":l=f(this,t,r,e) +break +default:throw new TypeError("Unknown encoding: "+n)}return l},n.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},n.prototype.slice=function(t,r){var e=this.length +t=~~t,r=void 0===r?e:~~r,0>t?(t+=e,0>t&&(t=0)):t>e&&(t=e),0>r?(r+=e,0>r&&(r=0)):r>e&&(r=e),t>r&&(r=t) +var i +if(n.TYPED_ARRAY_SUPPORT)i=n._augment(this.subarray(t,r)) +else{var o=r-t +i=new n(o,void 0,!0) +for(var s=0;o>s;s++)i[s]=this[s+t]}return i.length&&(i.parent=this.parent||this),i},n.prototype.readUIntLE=function(t,r,e){t>>>=0,r>>>=0,e||E(t,r,this.length) +for(var n=this[t],i=1,o=0;++o<r&&(i*=256);)n+=this[t+o]*i +return n},n.prototype.readUIntBE=function(t,r,e){t>>>=0,r>>>=0,e||E(t,r,this.length) +for(var n=this[t+--r],i=1;r>0&&(i*=256);)n+=this[t+--r]*i +return n},n.prototype.readUInt8=function(t,r){return r||E(t,1,this.length),this[t]},n.prototype.readUInt16LE=function(t,r){return r||E(t,2,this.length),this[t]|this[t+1]<<8},n.prototype.readUInt16BE=function(t,r){return r||E(t,2,this.length),this[t]<<8|this[t+1]},n.prototype.readUInt32LE=function(t,r){return r||E(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},n.prototype.readUInt32BE=function(t,r){return r||E(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},n.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||E(t,r,this.length) +for(var n=this[t],i=1,o=0;++o<r&&(i*=256);)n+=this[t+o]*i +return i*=128,n>=i&&(n-=Math.pow(2,8*r)),n},n.prototype.readIntBE=function(t,r,e){t>>>=0,r>>>=0,e||E(t,r,this.length) +for(var n=r,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i +return i*=128,o>=i&&(o-=Math.pow(2,8*r)),o},n.prototype.readInt8=function(t,r){return r||E(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},n.prototype.readInt16LE=function(t,r){r||E(t,2,this.length) +var e=this[t]|this[t+1]<<8 +return 32768&e?4294901760|e:e},n.prototype.readInt16BE=function(t,r){r||E(t,2,this.length) +var e=this[t+1]|this[t]<<8 +return 32768&e?4294901760|e:e},n.prototype.readInt32LE=function(t,r){return r||E(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},n.prototype.readInt32BE=function(t,r){return r||E(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},n.prototype.readFloatLE=function(t,r){return r||E(t,4,this.length),Y.read(this,t,!0,23,4)},n.prototype.readFloatBE=function(t,r){return r||E(t,4,this.length),Y.read(this,t,!1,23,4)},n.prototype.readDoubleLE=function(t,r){return r||E(t,8,this.length),Y.read(this,t,!0,52,8)},n.prototype.readDoubleBE=function(t,r){return r||E(t,8,this.length),Y.read(this,t,!1,52,8)},n.prototype.writeUIntLE=function(t,r,e,n){t=+t,r>>>=0,e>>>=0,n||v(this,t,r,e,Math.pow(2,8*e),0) +var i=1,o=0 +for(this[r]=255&t;++o<e&&(i*=256);)this[r+o]=t/i>>>0&255 +return r+e},n.prototype.writeUIntBE=function(t,r,e,n){t=+t,r>>>=0,e>>>=0,n||v(this,t,r,e,Math.pow(2,8*e),0) +var i=e-1,o=1 +for(this[r+i]=255&t;--i>=0&&(o*=256);)this[r+i]=t/o>>>0&255 +return r+e},n.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||v(this,t,r,1,255,0),n.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=t,r+1},n.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||v(this,t,r,2,65535,0),n.TYPED_ARRAY_SUPPORT?(this[r]=t,this[r+1]=t>>>8):y(this,t,r,!0),r+2},n.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||v(this,t,r,2,65535,0),n.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=t):y(this,t,r,!1),r+2},n.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||v(this,t,r,4,4294967295,0),n.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t):A(this,t,r,!0),r+4},n.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||v(this,t,r,4,4294967295,0),n.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t):A(this,t,r,!1),r+4},n.prototype.writeIntLE=function(t,r,e,n){t=+t,r>>>=0,n||v(this,t,r,e,Math.pow(2,8*e-1)-1,-Math.pow(2,8*e-1)) +var i=0,o=1,s=0>t?1:0 +for(this[r]=255&t;++i<e&&(o*=256);)this[r+i]=(t/o>>0)-s&255 +return r+e},n.prototype.writeIntBE=function(t,r,e,n){t=+t,r>>>=0,n||v(this,t,r,e,Math.pow(2,8*e-1)-1,-Math.pow(2,8*e-1)) +var i=e-1,o=1,s=0>t?1:0 +for(this[r+i]=255&t;--i>=0&&(o*=256);)this[r+i]=(t/o>>0)-s&255 +return r+e},n.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||v(this,t,r,1,127,-128),n.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[r]=t,r+1},n.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||v(this,t,r,2,32767,-32768),n.TYPED_ARRAY_SUPPORT?(this[r]=t,this[r+1]=t>>>8):y(this,t,r,!0),r+2},n.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||v(this,t,r,2,32767,-32768),n.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=t):y(this,t,r,!1),r+2},n.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||v(this,t,r,4,2147483647,-2147483648),n.TYPED_ARRAY_SUPPORT?(this[r]=t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):A(this,t,r,!0),r+4},n.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||v(this,t,r,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),n.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t):A(this,t,r,!1),r+4},n.prototype.writeFloatLE=function(t,r,e){return I(this,t,r,!0,e)},n.prototype.writeFloatBE=function(t,r,e){return I(this,t,r,!1,e)},n.prototype.writeDoubleLE=function(t,r,e){return m(this,t,r,!0,e)},n.prototype.writeDoubleBE=function(t,r,e){return m(this,t,r,!1,e)},n.prototype.copy=function(t,r,e,i){var o=this +if(e||(e=0),i||0===i||(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&e>i&&(i=e),i===e)return 0 +if(0===t.length||0===o.length)return 0 +if(0>r)throw new RangeError("targetStart out of bounds") +if(0>e||e>=o.length)throw new RangeError("sourceStart out of bounds") +if(0>i)throw new RangeError("sourceEnd out of bounds") +i>this.length&&(i=this.length),t.length-r<i-e&&(i=t.length-r+e) +var s=i-e +if(1e3>s||!n.TYPED_ARRAY_SUPPORT)for(var a=0;s>a;a++)t[a+r]=this[a+e] +else t._set(this.subarray(e,e+s),r) +return s},n.prototype.fill=function(t,r,e){if(t||(t=0),r||(r=0),e||(e=this.length),r>e)throw new RangeError("end < start") +if(e!==r&&0!==this.length){if(0>r||r>=this.length)throw new RangeError("start out of bounds") +if(0>e||e>this.length)throw new RangeError("end out of bounds") +var n +if("number"==typeof t)for(n=r;e>n;n++)this[n]=t +else{var i=_(t.toString()),o=i.length +for(n=r;e>n;n++)this[n]=i[n%o]}return this}},n.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(n.TYPED_ARRAY_SUPPORT)return new n(this).buffer +for(var t=new Uint8Array(this.length),r=0,e=t.length;e>r;r+=1)t[r]=this[r] +return t.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")} +var N=n.prototype +n._augment=function(t){return t.constructor=n,t._isBuffer=!0,t._get=t.get,t._set=t.set,t.get=N.get,t.set=N.set,t.write=N.write,t.toString=N.toString,t.toLocaleString=N.toString,t.toJSON=N.toJSON,t.equals=N.equals,t.compare=N.compare,t.copy=N.copy,t.slice=N.slice,t.readUIntLE=N.readUIntLE,t.readUIntBE=N.readUIntBE,t.readUInt8=N.readUInt8,t.readUInt16LE=N.readUInt16LE,t.readUInt16BE=N.readUInt16BE,t.readUInt32LE=N.readUInt32LE,t.readUInt32BE=N.readUInt32BE,t.readIntLE=N.readIntLE,t.readIntBE=N.readIntBE,t.readInt8=N.readInt8,t.readInt16LE=N.readInt16LE,t.readInt16BE=N.readInt16BE,t.readInt32LE=N.readInt32LE,t.readInt32BE=N.readInt32BE,t.readFloatLE=N.readFloatLE,t.readFloatBE=N.readFloatBE,t.readDoubleLE=N.readDoubleLE,t.readDoubleBE=N.readDoubleBE,t.writeUInt8=N.writeUInt8,t.writeUIntLE=N.writeUIntLE,t.writeUIntBE=N.writeUIntBE,t.writeUInt16LE=N.writeUInt16LE,t.writeUInt16BE=N.writeUInt16BE,t.writeUInt32LE=N.writeUInt32LE,t.writeUInt32BE=N.writeUInt32BE,t.writeIntLE=N.writeIntLE,t.writeIntBE=N.writeIntBE,t.writeInt8=N.writeInt8,t.writeInt16LE=N.writeInt16LE,t.writeInt16BE=N.writeInt16BE,t.writeInt32LE=N.writeInt32LE,t.writeInt32BE=N.writeInt32BE,t.writeFloatLE=N.writeFloatLE,t.writeFloatBE=N.writeFloatBE,t.writeDoubleLE=N.writeDoubleLE,t.writeDoubleBE=N.writeDoubleBE,t.fill=N.fill,t.inspect=N.inspect,t.toArrayBuffer=N.toArrayBuffer,t} +var j=/[^+\/0-9A-z\-]/g},{"base64-js":3,ieee754:4,"is-array":5}],3:[function(t,r,e){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" +!function(t){"use strict" +function r(t){var r=t.charCodeAt(0) +return r===s||r===c?62:r===a||r===l?63:u>r?-1:u+10>r?r-u+26+26:f+26>r?r-f:h+26>r?r-h+26:void 0}function e(t){function e(t){h[c++]=t}var n,i,s,a,u,h +if(t.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4") +var f=t.length +u="="===t.charAt(f-2)?2:"="===t.charAt(f-1)?1:0,h=new o(3*t.length/4-u),s=u>0?t.length-4:t.length +var c=0 +for(n=0,i=0;s>n;n+=4,i+=3)a=r(t.charAt(n))<<18|r(t.charAt(n+1))<<12|r(t.charAt(n+2))<<6|r(t.charAt(n+3)),e((16711680&a)>>16),e((65280&a)>>8),e(255&a) +return 2===u?(a=r(t.charAt(n))<<2|r(t.charAt(n+1))>>4,e(255&a)):1===u&&(a=r(t.charAt(n))<<10|r(t.charAt(n+1))<<4|r(t.charAt(n+2))>>2,e(a>>8&255),e(255&a)),h}function i(t){function r(t){return n.charAt(t)}function e(t){return r(t>>18&63)+r(t>>12&63)+r(t>>6&63)+r(63&t)}var i,o,s,a=t.length%3,u="" +for(i=0,s=t.length-a;s>i;i+=3)o=(t[i]<<16)+(t[i+1]<<8)+t[i+2],u+=e(o) +switch(a){case 1:o=t[t.length-1],u+=r(o>>2),u+=r(o<<4&63),u+="==" +break +case 2:o=(t[t.length-2]<<8)+t[t.length-1],u+=r(o>>10),u+=r(o>>4&63),u+=r(o<<2&63),u+="="}return u}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="+".charCodeAt(0),a="/".charCodeAt(0),u="0".charCodeAt(0),h="a".charCodeAt(0),f="A".charCodeAt(0),c="-".charCodeAt(0),l="_".charCodeAt(0) +t.toByteArray=e,t.fromByteArray=i}("undefined"==typeof e?this.base64js={}:e)},{}],4:[function(t,r,e){e.read=function(t,r,e,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,h=u>>1,f=-7,c=e?i-1:0,l=e?-1:1,p=t[r+c] +for(c+=l,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+t[r+c],c+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+t[r+c],c+=l,f-=8);if(0===o)o=1-h +else{if(o===u)return s?0/0:1/0*(p?-1:1) +s+=Math.pow(2,n),o-=h}return(p?-1:1)*s*Math.pow(2,o-n)},e.write=function(t,r,e,n,i,o){var s,a,u,h=8*o-i-1,f=(1<<h)-1,c=f>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,g=n?1:-1,w=0>r||0===r&&0>1/r?1:0 +for(r=Math.abs(r),isNaN(r)||1/0===r?(a=isNaN(r)?1:0,s=f):(s=Math.floor(Math.log(r)/Math.LN2),r*(u=Math.pow(2,-s))<1&&(s--,u*=2),r+=s+c>=1?l/u:l*Math.pow(2,1-c),r*u>=2&&(s++,u/=2),s+c>=f?(a=0,s=f):s+c>=1?(a=(r*u-1)*Math.pow(2,i),s+=c):(a=r*Math.pow(2,c-1)*Math.pow(2,i),s=0));i>=8;t[e+p]=255&a,p+=g,a/=256,i-=8);for(s=s<<i|a,h+=i;h>0;t[e+p]=255&s,p+=g,s/=256,h-=8);t[e+p-g]|=128*w}},{}],5:[function(t,r){var e=Array.isArray,n=Object.prototype.toString +r.exports=e||function(t){return!!t&&"[object Array]"==n.call(t)}},{}],6:[function(t,r,e){(function(t){function r(t,r){for(var e=0,n=t.length-1;n>=0;n--){var i=t[n] +"."===i?t.splice(n,1):".."===i?(t.splice(n,1),e++):e&&(t.splice(n,1),e--)}if(r)for(;e--;e)t.unshift("..") +return t}function n(t,r){if(t.filter)return t.filter(r) +for(var e=[],n=0;n<t.length;n++)r(t[n],n,t)&&e.push(t[n]) +return e}var i=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,o=function(t){return i.exec(t).slice(1)} +e.resolve=function(){for(var e="",i=!1,o=arguments.length-1;o>=-1&&!i;o--){var s=o>=0?arguments[o]:t.cwd() +if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings") +s&&(e=s+"/"+e,i="/"===s.charAt(0))}return e=r(n(e.split("/"),function(t){return!!t}),!i).join("/"),(i?"/":"")+e||"."},e.normalize=function(t){var i=e.isAbsolute(t),o="/"===s(t,-1) +return t=r(n(t.split("/"),function(t){return!!t}),!i).join("/"),t||i||(t="."),t&&o&&(t+="/"),(i?"/":"")+t},e.isAbsolute=function(t){return"/"===t.charAt(0)},e.join=function(){var t=Array.prototype.slice.call(arguments,0) +return e.normalize(n(t,function(t){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings") +return t}).join("/"))},e.relative=function(t,r){function n(t){for(var r=0;r<t.length&&""===t[r];r++);for(var e=t.length-1;e>=0&&""===t[e];e--);return r>e?[]:t.slice(r,e-r+1)}t=e.resolve(t).substr(1),r=e.resolve(r).substr(1) +for(var i=n(t.split("/")),o=n(r.split("/")),s=Math.min(i.length,o.length),a=s,u=0;s>u;u++)if(i[u]!==o[u]){a=u +break}for(var h=[],u=a;u<i.length;u++)h.push("..") +return h=h.concat(o.slice(a)),h.join("/")},e.sep="/",e.delimiter=":",e.dirname=function(t){var r=o(t),e=r[0],n=r[1] +return e||n?(n&&(n=n.substr(0,n.length-1)),e+n):"."},e.basename=function(t,r){var e=o(t)[2] +return r&&e.substr(-1*r.length)===r&&(e=e.substr(0,e.length-r.length)),e},e.extname=function(t){return o(t)[3]} +var s="b"==="ab".substr(-1)?function(t,r,e){return t.substr(r,e)}:function(t,r,e){return 0>r&&(r=t.length+r),t.substr(r,e)}}).call(this,t("_process"))},{_process:7}],7:[function(t,r){function e(){if(!s){s=!0 +for(var t,r=o.length;r;){t=o,o=[] +for(var e=-1;++e<r;)t[e]() +r=o.length}s=!1}}function n(){}var i=r.exports={},o=[],s=!1 +i.nextTick=function(t){o.push(t),s||setTimeout(e,0)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.on=n,i.addListener=n,i.once=n,i.off=n,i.removeListener=n,i.removeAllListeners=n,i.emit=n,i.binding=function(){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}],8:[function(t,r){"use strict" +r.exports=function(t){return t.trim().replace(/\s+/g," ").toUpperCase()}},{}],9:[function(t,r){"use strict" +function e(t,r,e){var n,i=r,o={ok:!1,pos:r,value:""} +for(n=t.charCodeAt(r);e>r&&n>=48&&57>=n;)n=t.charCodeAt(++r) +return o.ok=!0,o.pos=r,o.value=t.slice(i,r),o}r.exports=function(t,r,n){var i,o={ok:!1,pos:0,width:"",height:""} +if(r>=n)return o +if(i=t.charCodeAt(r),61!==i)return o +if(r++,i=t.charCodeAt(r),120!==i&&(48>i||i>57))return o +var s=e(t,r,n) +if(r=s.pos,i=t.charCodeAt(r),120!==i)return o +r++ +var a=e(t,r,n) +return r=a.pos,o.width=s.value,o.height=a.value,o.pos=r,o.ok=!0,o}},{}],10:[function(t,r){"use strict" +function e(t,r){return function(e,n){var a,u,h,f,c,l,p,g,w,d,E,v="",y="",A=e.pos,b=e.posMax +if(33!==e.src.charCodeAt(e.pos))return!1 +if(91!==e.src.charCodeAt(e.pos+1))return!1 +if(c=e.pos+2,f=t.helpers.parseLinkLabel(e,e.pos+1,!1),0>f)return!1 +if(l=f+1,b>l&&40===e.src.charCodeAt(l)){for(l++;b>l&&(a=e.src.charCodeAt(l),32===a||10===a);l++);if(l>=b)return!1 +for(E=l,g=t.helpers.parseLinkDestination(e.src,l,e.posMax),g.ok&&e.md.inline.validateLink(g.str)?(u=g.str,l=g.pos):u="",E=l;b>l&&(a=e.src.charCodeAt(l),32===a||10===a);l++);if(g=t.helpers.parseLinkTitle(e.src,l,e.posMax),b>l&&E!==l&&g.ok)for(w=g.str,l=g.pos;b>l&&(a=e.src.charCodeAt(l),32===a||10===a);l++);else w="" +if(l-1>=0&&(a=e.src.charCodeAt(l-1),32===a&&(g=o(e.src,l,e.posMax),g.ok)))for(v=g.width,y=g.height,l=g.pos;b>l&&(a=e.src.charCodeAt(l),32===a||10===a);l++);if(l>=b||41!==e.src.charCodeAt(l))return e.pos=A,!1 +l++}else{if("undefined"==typeof e.env.references)return!1 +for(;b>l&&(a=e.src.charCodeAt(l),32===a||10===a);l++);if(b>l&&91===e.src.charCodeAt(l)?(E=l+1,l=t.helpers.parseLinkLabel(e,l),l>=0?h=e.src.slice(E,l++):l=f+1):l=f+1,h||(h=e.src.slice(c,f)),p=e.env.references[s(h)],!p)return e.pos=A,!1 +u=p.href,w=p.title}if(!n){e.pos=c,e.posMax=f +var I=new e.md.inline.State(e.src.slice(c,f),e.md,e.env,d=[]) +if(I.md.inline.tokenize(I),r&&r.autofill&&""===v&&""===y)try{var m=i(u) +v=m.width,y=m.height}catch(B){}e.push({type:"image",src:u,title:w,tokens:d,level:e.level,width:v,height:y})}return e.pos=l,e.posMax=b,!0}}function n(t){return function(r,e,n,i,o){var s=' src="'+t.utils.escapeHtml(r[e].src)+'"',a="" +r[e].title&&(a=' title="'+t.utils.escapeHtml(t.utils.replaceEntities(r[e].title))+'"') +var u=' alt="'+o.renderInlineAsText(r[e].tokens,n,i)+'"',h=""!==r[e].width?' width="'+r[e].width+'"':"",f=""!==r[e].height?' height="'+r[e].height+'"':"",c=h+f,l=n.xhtmlOut?" /":"" +return"<img"+s+u+a+c+l+">"}}var i=t("image-size"),o=t("./helpers/parse_image_size"),s=t("./helpers/normalize_reference.js") +r.exports=function(t,r){t.renderer.rules.image=n(t),t.inline.ruler.before("emphasis","image",e(t,r))}},{"./helpers/normalize_reference.js":8,"./helpers/parse_image_size":9,"image-size":11}],11:[function(t,r){(function(e,n){"use strict" +function i(t,r){var e=f(t,r) +if(e in c){var n=c[e].calculate(t,r) +if(n!==!1)return n.type=e,n}throw new TypeError("unsupported file type")}function o(t,r){a.open(t,"r",function(t,e){if(t)return r(t) +var i=a.fstatSync(e).size,o=Math.min(i,p),s=new n(o) +a.read(e,s,0,o,0,function(t){return t?r(t):void a.close(e,function(t){r(t,s)})})})}function s(t){var r=a.openSync(t,"r"),e=a.fstatSync(r).size,i=Math.min(e,p),o=new n(i) +return a.readSync(r,o,0,i,0),a.closeSync(r),o}var a=t("fs"),u=t("path"),h=e.env.TEST_COV?"../lib-cov/":"../lib/",f=t(h+"detector"),c={},l=t(h+"types") +l.forEach(function(r){c[r]=t(h+"types/"+r)}) +var p=131072 +r.exports=function(t,r){if(t instanceof n)return i(t) +if("string"!=typeof t)throw new TypeError("invalid invocation") +var e=u.resolve(t) +if("function"!=typeof r){var a=s(e) +return i(a,e)}o(e,function(t,n){if(t)return r(t) +var o +try{o=i(n,e)}catch(s){t=s}r(t,o)})}}).call(this,t("_process"),t("buffer").Buffer)},{_process:7,buffer:2,fs:1,path:6}]},{},[10])