UNPKG

285 kBJavaScriptView Raw
1/******/ (function(modules) { // webpackBootstrap
2/******/ // The module cache
3/******/ var installedModules = {};
4/******/
5/******/ // The require function
6/******/ function __webpack_require__(moduleId) {
7/******/
8/******/ // Check if module is in cache
9/******/ if(installedModules[moduleId]) {
10/******/ return installedModules[moduleId].exports;
11/******/ }
12/******/ // Create a new module (and put it into the cache)
13/******/ var module = installedModules[moduleId] = {
14/******/ i: moduleId,
15/******/ l: false,
16/******/ exports: {}
17/******/ };
18/******/
19/******/ // Execute the module function
20/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21/******/
22/******/ // Flag the module as loaded
23/******/ module.l = true;
24/******/
25/******/ // Return the exports of the module
26/******/ return module.exports;
27/******/ }
28/******/
29/******/
30/******/ // expose the modules object (__webpack_modules__)
31/******/ __webpack_require__.m = modules;
32/******/
33/******/ // expose the module cache
34/******/ __webpack_require__.c = installedModules;
35/******/
36/******/ // define getter function for harmony exports
37/******/ __webpack_require__.d = function(exports, name, getter) {
38/******/ if(!__webpack_require__.o(exports, name)) {
39/******/ Object.defineProperty(exports, name, {
40/******/ configurable: false,
41/******/ enumerable: true,
42/******/ get: getter
43/******/ });
44/******/ }
45/******/ };
46/******/
47/******/ // getDefaultExport function for compatibility with non-harmony modules
48/******/ __webpack_require__.n = function(module) {
49/******/ var getter = module && module.__esModule ?
50/******/ function getDefault() { return module['default']; } :
51/******/ function getModuleExports() { return module; };
52/******/ __webpack_require__.d(getter, 'a', getter);
53/******/ return getter;
54/******/ };
55/******/
56/******/ // Object.prototype.hasOwnProperty.call
57/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
58/******/
59/******/ // __webpack_public_path__
60/******/ __webpack_require__.p = "";
61/******/
62/******/ // Load entry module and return exports
63/******/ return __webpack_require__(__webpack_require__.s = 21);
64/******/ })
65/************************************************************************/
66/******/ ([
67/* 0 */
68/***/ (function(module, exports) {
69
70var g;
71
72// This works in non-strict mode
73g = (function() {
74 return this;
75})();
76
77try {
78 // This works if eval is allowed (see CSP)
79 g = g || Function("return this")() || (1,eval)("this");
80} catch(e) {
81 // This works if the window reference is available
82 if(typeof window === "object")
83 g = window;
84}
85
86// g can still be undefined, but nothing to do about it...
87// We return undefined, instead of nothing here, so it's
88// easier to handle this case. if(!global) { ...}
89
90module.exports = g;
91
92
93/***/ }),
94/* 1 */
95/***/ (function(module, exports) {
96
97// shim for using process in browser
98var process = module.exports = {};
99
100// cached from whatever global is present so that test runners that stub it
101// don't break things. But we need to wrap it in a try catch in case it is
102// wrapped in strict mode code which doesn't define any globals. It's inside a
103// function because try/catches deoptimize in certain engines.
104
105var cachedSetTimeout;
106var cachedClearTimeout;
107
108function defaultSetTimout() {
109 throw new Error('setTimeout has not been defined');
110}
111function defaultClearTimeout () {
112 throw new Error('clearTimeout has not been defined');
113}
114(function () {
115 try {
116 if (typeof setTimeout === 'function') {
117 cachedSetTimeout = setTimeout;
118 } else {
119 cachedSetTimeout = defaultSetTimout;
120 }
121 } catch (e) {
122 cachedSetTimeout = defaultSetTimout;
123 }
124 try {
125 if (typeof clearTimeout === 'function') {
126 cachedClearTimeout = clearTimeout;
127 } else {
128 cachedClearTimeout = defaultClearTimeout;
129 }
130 } catch (e) {
131 cachedClearTimeout = defaultClearTimeout;
132 }
133} ())
134function runTimeout(fun) {
135 if (cachedSetTimeout === setTimeout) {
136 //normal enviroments in sane situations
137 return setTimeout(fun, 0);
138 }
139 // if setTimeout wasn't available but was latter defined
140 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
141 cachedSetTimeout = setTimeout;
142 return setTimeout(fun, 0);
143 }
144 try {
145 // when when somebody has screwed with setTimeout but no I.E. maddness
146 return cachedSetTimeout(fun, 0);
147 } catch(e){
148 try {
149 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
150 return cachedSetTimeout.call(null, fun, 0);
151 } catch(e){
152 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
153 return cachedSetTimeout.call(this, fun, 0);
154 }
155 }
156
157
158}
159function runClearTimeout(marker) {
160 if (cachedClearTimeout === clearTimeout) {
161 //normal enviroments in sane situations
162 return clearTimeout(marker);
163 }
164 // if clearTimeout wasn't available but was latter defined
165 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
166 cachedClearTimeout = clearTimeout;
167 return clearTimeout(marker);
168 }
169 try {
170 // when when somebody has screwed with setTimeout but no I.E. maddness
171 return cachedClearTimeout(marker);
172 } catch (e){
173 try {
174 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
175 return cachedClearTimeout.call(null, marker);
176 } catch (e){
177 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
178 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
179 return cachedClearTimeout.call(this, marker);
180 }
181 }
182
183
184
185}
186var queue = [];
187var draining = false;
188var currentQueue;
189var queueIndex = -1;
190
191function cleanUpNextTick() {
192 if (!draining || !currentQueue) {
193 return;
194 }
195 draining = false;
196 if (currentQueue.length) {
197 queue = currentQueue.concat(queue);
198 } else {
199 queueIndex = -1;
200 }
201 if (queue.length) {
202 drainQueue();
203 }
204}
205
206function drainQueue() {
207 if (draining) {
208 return;
209 }
210 var timeout = runTimeout(cleanUpNextTick);
211 draining = true;
212
213 var len = queue.length;
214 while(len) {
215 currentQueue = queue;
216 queue = [];
217 while (++queueIndex < len) {
218 if (currentQueue) {
219 currentQueue[queueIndex].run();
220 }
221 }
222 queueIndex = -1;
223 len = queue.length;
224 }
225 currentQueue = null;
226 draining = false;
227 runClearTimeout(timeout);
228}
229
230process.nextTick = function (fun) {
231 var args = new Array(arguments.length - 1);
232 if (arguments.length > 1) {
233 for (var i = 1; i < arguments.length; i++) {
234 args[i - 1] = arguments[i];
235 }
236 }
237 queue.push(new Item(fun, args));
238 if (queue.length === 1 && !draining) {
239 runTimeout(drainQueue);
240 }
241};
242
243// v8 likes predictible objects
244function Item(fun, array) {
245 this.fun = fun;
246 this.array = array;
247}
248Item.prototype.run = function () {
249 this.fun.apply(null, this.array);
250};
251process.title = 'browser';
252process.browser = true;
253process.env = {};
254process.argv = [];
255process.version = ''; // empty string to avoid regexp issues
256process.versions = {};
257
258function noop() {}
259
260process.on = noop;
261process.addListener = noop;
262process.once = noop;
263process.off = noop;
264process.removeListener = noop;
265process.removeAllListeners = noop;
266process.emit = noop;
267process.prependListener = noop;
268process.prependOnceListener = noop;
269
270process.listeners = function (name) { return [] }
271
272process.binding = function (name) {
273 throw new Error('process.binding is not supported');
274};
275
276process.cwd = function () { return '/' };
277process.chdir = function (dir) {
278 throw new Error('process.chdir is not supported');
279};
280process.umask = function() { return 0; };
281
282
283/***/ }),
284/* 2 */
285/***/ (function(module, exports, __webpack_require__) {
286
287"use strict";
288/* WEBPACK VAR INJECTION */(function(global) {/*!
289 * The buffer module from node.js, for the browser.
290 *
291 * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
292 * @license MIT
293 */
294/* eslint-disable no-proto */
295
296
297
298var base64 = __webpack_require__(23)
299var ieee754 = __webpack_require__(24)
300var isArray = __webpack_require__(25)
301
302exports.Buffer = Buffer
303exports.SlowBuffer = SlowBuffer
304exports.INSPECT_MAX_BYTES = 50
305
306/**
307 * If `Buffer.TYPED_ARRAY_SUPPORT`:
308 * === true Use Uint8Array implementation (fastest)
309 * === false Use Object implementation (most compatible, even IE6)
310 *
311 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
312 * Opera 11.6+, iOS 4.2+.
313 *
314 * Due to various browser bugs, sometimes the Object implementation will be used even
315 * when the browser supports typed arrays.
316 *
317 * Note:
318 *
319 * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
320 * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
321 *
322 * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
323 *
324 * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
325 * incorrect length in some situations.
326
327 * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
328 * get the Object implementation, which is slower but behaves correctly.
329 */
330Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
331 ? global.TYPED_ARRAY_SUPPORT
332 : typedArraySupport()
333
334/*
335 * Export kMaxLength after typed array support is determined.
336 */
337exports.kMaxLength = kMaxLength()
338
339function typedArraySupport () {
340 try {
341 var arr = new Uint8Array(1)
342 arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
343 return arr.foo() === 42 && // typed array instances can be augmented
344 typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
345 arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
346 } catch (e) {
347 return false
348 }
349}
350
351function kMaxLength () {
352 return Buffer.TYPED_ARRAY_SUPPORT
353 ? 0x7fffffff
354 : 0x3fffffff
355}
356
357function createBuffer (that, length) {
358 if (kMaxLength() < length) {
359 throw new RangeError('Invalid typed array length')
360 }
361 if (Buffer.TYPED_ARRAY_SUPPORT) {
362 // Return an augmented `Uint8Array` instance, for best performance
363 that = new Uint8Array(length)
364 that.__proto__ = Buffer.prototype
365 } else {
366 // Fallback: Return an object instance of the Buffer class
367 if (that === null) {
368 that = new Buffer(length)
369 }
370 that.length = length
371 }
372
373 return that
374}
375
376/**
377 * The Buffer constructor returns instances of `Uint8Array` that have their
378 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
379 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
380 * and the `Uint8Array` methods. Square bracket notation works as expected -- it
381 * returns a single octet.
382 *
383 * The `Uint8Array` prototype remains unmodified.
384 */
385
386function Buffer (arg, encodingOrOffset, length) {
387 if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
388 return new Buffer(arg, encodingOrOffset, length)
389 }
390
391 // Common case.
392 if (typeof arg === 'number') {
393 if (typeof encodingOrOffset === 'string') {
394 throw new Error(
395 'If encoding is specified then the first argument must be a string'
396 )
397 }
398 return allocUnsafe(this, arg)
399 }
400 return from(this, arg, encodingOrOffset, length)
401}
402
403Buffer.poolSize = 8192 // not used by this implementation
404
405// TODO: Legacy, not needed anymore. Remove in next major version.
406Buffer._augment = function (arr) {
407 arr.__proto__ = Buffer.prototype
408 return arr
409}
410
411function from (that, value, encodingOrOffset, length) {
412 if (typeof value === 'number') {
413 throw new TypeError('"value" argument must not be a number')
414 }
415
416 if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
417 return fromArrayBuffer(that, value, encodingOrOffset, length)
418 }
419
420 if (typeof value === 'string') {
421 return fromString(that, value, encodingOrOffset)
422 }
423
424 return fromObject(that, value)
425}
426
427/**
428 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
429 * if value is a number.
430 * Buffer.from(str[, encoding])
431 * Buffer.from(array)
432 * Buffer.from(buffer)
433 * Buffer.from(arrayBuffer[, byteOffset[, length]])
434 **/
435Buffer.from = function (value, encodingOrOffset, length) {
436 return from(null, value, encodingOrOffset, length)
437}
438
439if (Buffer.TYPED_ARRAY_SUPPORT) {
440 Buffer.prototype.__proto__ = Uint8Array.prototype
441 Buffer.__proto__ = Uint8Array
442 if (typeof Symbol !== 'undefined' && Symbol.species &&
443 Buffer[Symbol.species] === Buffer) {
444 // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
445 Object.defineProperty(Buffer, Symbol.species, {
446 value: null,
447 configurable: true
448 })
449 }
450}
451
452function assertSize (size) {
453 if (typeof size !== 'number') {
454 throw new TypeError('"size" argument must be a number')
455 } else if (size < 0) {
456 throw new RangeError('"size" argument must not be negative')
457 }
458}
459
460function alloc (that, size, fill, encoding) {
461 assertSize(size)
462 if (size <= 0) {
463 return createBuffer(that, size)
464 }
465 if (fill !== undefined) {
466 // Only pay attention to encoding if it's a string. This
467 // prevents accidentally sending in a number that would
468 // be interpretted as a start offset.
469 return typeof encoding === 'string'
470 ? createBuffer(that, size).fill(fill, encoding)
471 : createBuffer(that, size).fill(fill)
472 }
473 return createBuffer(that, size)
474}
475
476/**
477 * Creates a new filled Buffer instance.
478 * alloc(size[, fill[, encoding]])
479 **/
480Buffer.alloc = function (size, fill, encoding) {
481 return alloc(null, size, fill, encoding)
482}
483
484function allocUnsafe (that, size) {
485 assertSize(size)
486 that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
487 if (!Buffer.TYPED_ARRAY_SUPPORT) {
488 for (var i = 0; i < size; ++i) {
489 that[i] = 0
490 }
491 }
492 return that
493}
494
495/**
496 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
497 * */
498Buffer.allocUnsafe = function (size) {
499 return allocUnsafe(null, size)
500}
501/**
502 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
503 */
504Buffer.allocUnsafeSlow = function (size) {
505 return allocUnsafe(null, size)
506}
507
508function fromString (that, string, encoding) {
509 if (typeof encoding !== 'string' || encoding === '') {
510 encoding = 'utf8'
511 }
512
513 if (!Buffer.isEncoding(encoding)) {
514 throw new TypeError('"encoding" must be a valid string encoding')
515 }
516
517 var length = byteLength(string, encoding) | 0
518 that = createBuffer(that, length)
519
520 var actual = that.write(string, encoding)
521
522 if (actual !== length) {
523 // Writing a hex string, for example, that contains invalid characters will
524 // cause everything after the first invalid character to be ignored. (e.g.
525 // 'abxxcd' will be treated as 'ab')
526 that = that.slice(0, actual)
527 }
528
529 return that
530}
531
532function fromArrayLike (that, array) {
533 var length = array.length < 0 ? 0 : checked(array.length) | 0
534 that = createBuffer(that, length)
535 for (var i = 0; i < length; i += 1) {
536 that[i] = array[i] & 255
537 }
538 return that
539}
540
541function fromArrayBuffer (that, array, byteOffset, length) {
542 array.byteLength // this throws if `array` is not a valid ArrayBuffer
543
544 if (byteOffset < 0 || array.byteLength < byteOffset) {
545 throw new RangeError('\'offset\' is out of bounds')
546 }
547
548 if (array.byteLength < byteOffset + (length || 0)) {
549 throw new RangeError('\'length\' is out of bounds')
550 }
551
552 if (byteOffset === undefined && length === undefined) {
553 array = new Uint8Array(array)
554 } else if (length === undefined) {
555 array = new Uint8Array(array, byteOffset)
556 } else {
557 array = new Uint8Array(array, byteOffset, length)
558 }
559
560 if (Buffer.TYPED_ARRAY_SUPPORT) {
561 // Return an augmented `Uint8Array` instance, for best performance
562 that = array
563 that.__proto__ = Buffer.prototype
564 } else {
565 // Fallback: Return an object instance of the Buffer class
566 that = fromArrayLike(that, array)
567 }
568 return that
569}
570
571function fromObject (that, obj) {
572 if (Buffer.isBuffer(obj)) {
573 var len = checked(obj.length) | 0
574 that = createBuffer(that, len)
575
576 if (that.length === 0) {
577 return that
578 }
579
580 obj.copy(that, 0, 0, len)
581 return that
582 }
583
584 if (obj) {
585 if ((typeof ArrayBuffer !== 'undefined' &&
586 obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
587 if (typeof obj.length !== 'number' || isnan(obj.length)) {
588 return createBuffer(that, 0)
589 }
590 return fromArrayLike(that, obj)
591 }
592
593 if (obj.type === 'Buffer' && isArray(obj.data)) {
594 return fromArrayLike(that, obj.data)
595 }
596 }
597
598 throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
599}
600
601function checked (length) {
602 // Note: cannot use `length < kMaxLength()` here because that fails when
603 // length is NaN (which is otherwise coerced to zero.)
604 if (length >= kMaxLength()) {
605 throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
606 'size: 0x' + kMaxLength().toString(16) + ' bytes')
607 }
608 return length | 0
609}
610
611function SlowBuffer (length) {
612 if (+length != length) { // eslint-disable-line eqeqeq
613 length = 0
614 }
615 return Buffer.alloc(+length)
616}
617
618Buffer.isBuffer = function isBuffer (b) {
619 return !!(b != null && b._isBuffer)
620}
621
622Buffer.compare = function compare (a, b) {
623 if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
624 throw new TypeError('Arguments must be Buffers')
625 }
626
627 if (a === b) return 0
628
629 var x = a.length
630 var y = b.length
631
632 for (var i = 0, len = Math.min(x, y); i < len; ++i) {
633 if (a[i] !== b[i]) {
634 x = a[i]
635 y = b[i]
636 break
637 }
638 }
639
640 if (x < y) return -1
641 if (y < x) return 1
642 return 0
643}
644
645Buffer.isEncoding = function isEncoding (encoding) {
646 switch (String(encoding).toLowerCase()) {
647 case 'hex':
648 case 'utf8':
649 case 'utf-8':
650 case 'ascii':
651 case 'latin1':
652 case 'binary':
653 case 'base64':
654 case 'ucs2':
655 case 'ucs-2':
656 case 'utf16le':
657 case 'utf-16le':
658 return true
659 default:
660 return false
661 }
662}
663
664Buffer.concat = function concat (list, length) {
665 if (!isArray(list)) {
666 throw new TypeError('"list" argument must be an Array of Buffers')
667 }
668
669 if (list.length === 0) {
670 return Buffer.alloc(0)
671 }
672
673 var i
674 if (length === undefined) {
675 length = 0
676 for (i = 0; i < list.length; ++i) {
677 length += list[i].length
678 }
679 }
680
681 var buffer = Buffer.allocUnsafe(length)
682 var pos = 0
683 for (i = 0; i < list.length; ++i) {
684 var buf = list[i]
685 if (!Buffer.isBuffer(buf)) {
686 throw new TypeError('"list" argument must be an Array of Buffers')
687 }
688 buf.copy(buffer, pos)
689 pos += buf.length
690 }
691 return buffer
692}
693
694function byteLength (string, encoding) {
695 if (Buffer.isBuffer(string)) {
696 return string.length
697 }
698 if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
699 (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
700 return string.byteLength
701 }
702 if (typeof string !== 'string') {
703 string = '' + string
704 }
705
706 var len = string.length
707 if (len === 0) return 0
708
709 // Use a for loop to avoid recursion
710 var loweredCase = false
711 for (;;) {
712 switch (encoding) {
713 case 'ascii':
714 case 'latin1':
715 case 'binary':
716 return len
717 case 'utf8':
718 case 'utf-8':
719 case undefined:
720 return utf8ToBytes(string).length
721 case 'ucs2':
722 case 'ucs-2':
723 case 'utf16le':
724 case 'utf-16le':
725 return len * 2
726 case 'hex':
727 return len >>> 1
728 case 'base64':
729 return base64ToBytes(string).length
730 default:
731 if (loweredCase) return utf8ToBytes(string).length // assume utf8
732 encoding = ('' + encoding).toLowerCase()
733 loweredCase = true
734 }
735 }
736}
737Buffer.byteLength = byteLength
738
739function slowToString (encoding, start, end) {
740 var loweredCase = false
741
742 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
743 // property of a typed array.
744
745 // This behaves neither like String nor Uint8Array in that we set start/end
746 // to their upper/lower bounds if the value passed is out of range.
747 // undefined is handled specially as per ECMA-262 6th Edition,
748 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
749 if (start === undefined || start < 0) {
750 start = 0
751 }
752 // Return early if start > this.length. Done here to prevent potential uint32
753 // coercion fail below.
754 if (start > this.length) {
755 return ''
756 }
757
758 if (end === undefined || end > this.length) {
759 end = this.length
760 }
761
762 if (end <= 0) {
763 return ''
764 }
765
766 // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
767 end >>>= 0
768 start >>>= 0
769
770 if (end <= start) {
771 return ''
772 }
773
774 if (!encoding) encoding = 'utf8'
775
776 while (true) {
777 switch (encoding) {
778 case 'hex':
779 return hexSlice(this, start, end)
780
781 case 'utf8':
782 case 'utf-8':
783 return utf8Slice(this, start, end)
784
785 case 'ascii':
786 return asciiSlice(this, start, end)
787
788 case 'latin1':
789 case 'binary':
790 return latin1Slice(this, start, end)
791
792 case 'base64':
793 return base64Slice(this, start, end)
794
795 case 'ucs2':
796 case 'ucs-2':
797 case 'utf16le':
798 case 'utf-16le':
799 return utf16leSlice(this, start, end)
800
801 default:
802 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
803 encoding = (encoding + '').toLowerCase()
804 loweredCase = true
805 }
806 }
807}
808
809// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
810// Buffer instances.
811Buffer.prototype._isBuffer = true
812
813function swap (b, n, m) {
814 var i = b[n]
815 b[n] = b[m]
816 b[m] = i
817}
818
819Buffer.prototype.swap16 = function swap16 () {
820 var len = this.length
821 if (len % 2 !== 0) {
822 throw new RangeError('Buffer size must be a multiple of 16-bits')
823 }
824 for (var i = 0; i < len; i += 2) {
825 swap(this, i, i + 1)
826 }
827 return this
828}
829
830Buffer.prototype.swap32 = function swap32 () {
831 var len = this.length
832 if (len % 4 !== 0) {
833 throw new RangeError('Buffer size must be a multiple of 32-bits')
834 }
835 for (var i = 0; i < len; i += 4) {
836 swap(this, i, i + 3)
837 swap(this, i + 1, i + 2)
838 }
839 return this
840}
841
842Buffer.prototype.swap64 = function swap64 () {
843 var len = this.length
844 if (len % 8 !== 0) {
845 throw new RangeError('Buffer size must be a multiple of 64-bits')
846 }
847 for (var i = 0; i < len; i += 8) {
848 swap(this, i, i + 7)
849 swap(this, i + 1, i + 6)
850 swap(this, i + 2, i + 5)
851 swap(this, i + 3, i + 4)
852 }
853 return this
854}
855
856Buffer.prototype.toString = function toString () {
857 var length = this.length | 0
858 if (length === 0) return ''
859 if (arguments.length === 0) return utf8Slice(this, 0, length)
860 return slowToString.apply(this, arguments)
861}
862
863Buffer.prototype.equals = function equals (b) {
864 if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
865 if (this === b) return true
866 return Buffer.compare(this, b) === 0
867}
868
869Buffer.prototype.inspect = function inspect () {
870 var str = ''
871 var max = exports.INSPECT_MAX_BYTES
872 if (this.length > 0) {
873 str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
874 if (this.length > max) str += ' ... '
875 }
876 return '<Buffer ' + str + '>'
877}
878
879Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
880 if (!Buffer.isBuffer(target)) {
881 throw new TypeError('Argument must be a Buffer')
882 }
883
884 if (start === undefined) {
885 start = 0
886 }
887 if (end === undefined) {
888 end = target ? target.length : 0
889 }
890 if (thisStart === undefined) {
891 thisStart = 0
892 }
893 if (thisEnd === undefined) {
894 thisEnd = this.length
895 }
896
897 if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
898 throw new RangeError('out of range index')
899 }
900
901 if (thisStart >= thisEnd && start >= end) {
902 return 0
903 }
904 if (thisStart >= thisEnd) {
905 return -1
906 }
907 if (start >= end) {
908 return 1
909 }
910
911 start >>>= 0
912 end >>>= 0
913 thisStart >>>= 0
914 thisEnd >>>= 0
915
916 if (this === target) return 0
917
918 var x = thisEnd - thisStart
919 var y = end - start
920 var len = Math.min(x, y)
921
922 var thisCopy = this.slice(thisStart, thisEnd)
923 var targetCopy = target.slice(start, end)
924
925 for (var i = 0; i < len; ++i) {
926 if (thisCopy[i] !== targetCopy[i]) {
927 x = thisCopy[i]
928 y = targetCopy[i]
929 break
930 }
931 }
932
933 if (x < y) return -1
934 if (y < x) return 1
935 return 0
936}
937
938// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
939// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
940//
941// Arguments:
942// - buffer - a Buffer to search
943// - val - a string, Buffer, or number
944// - byteOffset - an index into `buffer`; will be clamped to an int32
945// - encoding - an optional encoding, relevant is val is a string
946// - dir - true for indexOf, false for lastIndexOf
947function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
948 // Empty buffer means no match
949 if (buffer.length === 0) return -1
950
951 // Normalize byteOffset
952 if (typeof byteOffset === 'string') {
953 encoding = byteOffset
954 byteOffset = 0
955 } else if (byteOffset > 0x7fffffff) {
956 byteOffset = 0x7fffffff
957 } else if (byteOffset < -0x80000000) {
958 byteOffset = -0x80000000
959 }
960 byteOffset = +byteOffset // Coerce to Number.
961 if (isNaN(byteOffset)) {
962 // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
963 byteOffset = dir ? 0 : (buffer.length - 1)
964 }
965
966 // Normalize byteOffset: negative offsets start from the end of the buffer
967 if (byteOffset < 0) byteOffset = buffer.length + byteOffset
968 if (byteOffset >= buffer.length) {
969 if (dir) return -1
970 else byteOffset = buffer.length - 1
971 } else if (byteOffset < 0) {
972 if (dir) byteOffset = 0
973 else return -1
974 }
975
976 // Normalize val
977 if (typeof val === 'string') {
978 val = Buffer.from(val, encoding)
979 }
980
981 // Finally, search either indexOf (if dir is true) or lastIndexOf
982 if (Buffer.isBuffer(val)) {
983 // Special case: looking for empty string/buffer always fails
984 if (val.length === 0) {
985 return -1
986 }
987 return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
988 } else if (typeof val === 'number') {
989 val = val & 0xFF // Search for a byte value [0-255]
990 if (Buffer.TYPED_ARRAY_SUPPORT &&
991 typeof Uint8Array.prototype.indexOf === 'function') {
992 if (dir) {
993 return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
994 } else {
995 return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
996 }
997 }
998 return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
999 }
1000
1001 throw new TypeError('val must be string, number or Buffer')
1002}
1003
1004function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
1005 var indexSize = 1
1006 var arrLength = arr.length
1007 var valLength = val.length
1008
1009 if (encoding !== undefined) {
1010 encoding = String(encoding).toLowerCase()
1011 if (encoding === 'ucs2' || encoding === 'ucs-2' ||
1012 encoding === 'utf16le' || encoding === 'utf-16le') {
1013 if (arr.length < 2 || val.length < 2) {
1014 return -1
1015 }
1016 indexSize = 2
1017 arrLength /= 2
1018 valLength /= 2
1019 byteOffset /= 2
1020 }
1021 }
1022
1023 function read (buf, i) {
1024 if (indexSize === 1) {
1025 return buf[i]
1026 } else {
1027 return buf.readUInt16BE(i * indexSize)
1028 }
1029 }
1030
1031 var i
1032 if (dir) {
1033 var foundIndex = -1
1034 for (i = byteOffset; i < arrLength; i++) {
1035 if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
1036 if (foundIndex === -1) foundIndex = i
1037 if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
1038 } else {
1039 if (foundIndex !== -1) i -= i - foundIndex
1040 foundIndex = -1
1041 }
1042 }
1043 } else {
1044 if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
1045 for (i = byteOffset; i >= 0; i--) {
1046 var found = true
1047 for (var j = 0; j < valLength; j++) {
1048 if (read(arr, i + j) !== read(val, j)) {
1049 found = false
1050 break
1051 }
1052 }
1053 if (found) return i
1054 }
1055 }
1056
1057 return -1
1058}
1059
1060Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
1061 return this.indexOf(val, byteOffset, encoding) !== -1
1062}
1063
1064Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
1065 return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
1066}
1067
1068Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
1069 return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
1070}
1071
1072function hexWrite (buf, string, offset, length) {
1073 offset = Number(offset) || 0
1074 var remaining = buf.length - offset
1075 if (!length) {
1076 length = remaining
1077 } else {
1078 length = Number(length)
1079 if (length > remaining) {
1080 length = remaining
1081 }
1082 }
1083
1084 // must be an even number of digits
1085 var strLen = string.length
1086 if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
1087
1088 if (length > strLen / 2) {
1089 length = strLen / 2
1090 }
1091 for (var i = 0; i < length; ++i) {
1092 var parsed = parseInt(string.substr(i * 2, 2), 16)
1093 if (isNaN(parsed)) return i
1094 buf[offset + i] = parsed
1095 }
1096 return i
1097}
1098
1099function utf8Write (buf, string, offset, length) {
1100 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
1101}
1102
1103function asciiWrite (buf, string, offset, length) {
1104 return blitBuffer(asciiToBytes(string), buf, offset, length)
1105}
1106
1107function latin1Write (buf, string, offset, length) {
1108 return asciiWrite(buf, string, offset, length)
1109}
1110
1111function base64Write (buf, string, offset, length) {
1112 return blitBuffer(base64ToBytes(string), buf, offset, length)
1113}
1114
1115function ucs2Write (buf, string, offset, length) {
1116 return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
1117}
1118
1119Buffer.prototype.write = function write (string, offset, length, encoding) {
1120 // Buffer#write(string)
1121 if (offset === undefined) {
1122 encoding = 'utf8'
1123 length = this.length
1124 offset = 0
1125 // Buffer#write(string, encoding)
1126 } else if (length === undefined && typeof offset === 'string') {
1127 encoding = offset
1128 length = this.length
1129 offset = 0
1130 // Buffer#write(string, offset[, length][, encoding])
1131 } else if (isFinite(offset)) {
1132 offset = offset | 0
1133 if (isFinite(length)) {
1134 length = length | 0
1135 if (encoding === undefined) encoding = 'utf8'
1136 } else {
1137 encoding = length
1138 length = undefined
1139 }
1140 // legacy write(string, encoding, offset, length) - remove in v0.13
1141 } else {
1142 throw new Error(
1143 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
1144 )
1145 }
1146
1147 var remaining = this.length - offset
1148 if (length === undefined || length > remaining) length = remaining
1149
1150 if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
1151 throw new RangeError('Attempt to write outside buffer bounds')
1152 }
1153
1154 if (!encoding) encoding = 'utf8'
1155
1156 var loweredCase = false
1157 for (;;) {
1158 switch (encoding) {
1159 case 'hex':
1160 return hexWrite(this, string, offset, length)
1161
1162 case 'utf8':
1163 case 'utf-8':
1164 return utf8Write(this, string, offset, length)
1165
1166 case 'ascii':
1167 return asciiWrite(this, string, offset, length)
1168
1169 case 'latin1':
1170 case 'binary':
1171 return latin1Write(this, string, offset, length)
1172
1173 case 'base64':
1174 // Warning: maxLength not taken into account in base64Write
1175 return base64Write(this, string, offset, length)
1176
1177 case 'ucs2':
1178 case 'ucs-2':
1179 case 'utf16le':
1180 case 'utf-16le':
1181 return ucs2Write(this, string, offset, length)
1182
1183 default:
1184 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
1185 encoding = ('' + encoding).toLowerCase()
1186 loweredCase = true
1187 }
1188 }
1189}
1190
1191Buffer.prototype.toJSON = function toJSON () {
1192 return {
1193 type: 'Buffer',
1194 data: Array.prototype.slice.call(this._arr || this, 0)
1195 }
1196}
1197
1198function base64Slice (buf, start, end) {
1199 if (start === 0 && end === buf.length) {
1200 return base64.fromByteArray(buf)
1201 } else {
1202 return base64.fromByteArray(buf.slice(start, end))
1203 }
1204}
1205
1206function utf8Slice (buf, start, end) {
1207 end = Math.min(buf.length, end)
1208 var res = []
1209
1210 var i = start
1211 while (i < end) {
1212 var firstByte = buf[i]
1213 var codePoint = null
1214 var bytesPerSequence = (firstByte > 0xEF) ? 4
1215 : (firstByte > 0xDF) ? 3
1216 : (firstByte > 0xBF) ? 2
1217 : 1
1218
1219 if (i + bytesPerSequence <= end) {
1220 var secondByte, thirdByte, fourthByte, tempCodePoint
1221
1222 switch (bytesPerSequence) {
1223 case 1:
1224 if (firstByte < 0x80) {
1225 codePoint = firstByte
1226 }
1227 break
1228 case 2:
1229 secondByte = buf[i + 1]
1230 if ((secondByte & 0xC0) === 0x80) {
1231 tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
1232 if (tempCodePoint > 0x7F) {
1233 codePoint = tempCodePoint
1234 }
1235 }
1236 break
1237 case 3:
1238 secondByte = buf[i + 1]
1239 thirdByte = buf[i + 2]
1240 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
1241 tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
1242 if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
1243 codePoint = tempCodePoint
1244 }
1245 }
1246 break
1247 case 4:
1248 secondByte = buf[i + 1]
1249 thirdByte = buf[i + 2]
1250 fourthByte = buf[i + 3]
1251 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
1252 tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
1253 if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
1254 codePoint = tempCodePoint
1255 }
1256 }
1257 }
1258 }
1259
1260 if (codePoint === null) {
1261 // we did not generate a valid codePoint so insert a
1262 // replacement char (U+FFFD) and advance only 1 byte
1263 codePoint = 0xFFFD
1264 bytesPerSequence = 1
1265 } else if (codePoint > 0xFFFF) {
1266 // encode to utf16 (surrogate pair dance)
1267 codePoint -= 0x10000
1268 res.push(codePoint >>> 10 & 0x3FF | 0xD800)
1269 codePoint = 0xDC00 | codePoint & 0x3FF
1270 }
1271
1272 res.push(codePoint)
1273 i += bytesPerSequence
1274 }
1275
1276 return decodeCodePointsArray(res)
1277}
1278
1279// Based on http://stackoverflow.com/a/22747272/680742, the browser with
1280// the lowest limit is Chrome, with 0x10000 args.
1281// We go 1 magnitude less, for safety
1282var MAX_ARGUMENTS_LENGTH = 0x1000
1283
1284function decodeCodePointsArray (codePoints) {
1285 var len = codePoints.length
1286 if (len <= MAX_ARGUMENTS_LENGTH) {
1287 return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
1288 }
1289
1290 // Decode in chunks to avoid "call stack size exceeded".
1291 var res = ''
1292 var i = 0
1293 while (i < len) {
1294 res += String.fromCharCode.apply(
1295 String,
1296 codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
1297 )
1298 }
1299 return res
1300}
1301
1302function asciiSlice (buf, start, end) {
1303 var ret = ''
1304 end = Math.min(buf.length, end)
1305
1306 for (var i = start; i < end; ++i) {
1307 ret += String.fromCharCode(buf[i] & 0x7F)
1308 }
1309 return ret
1310}
1311
1312function latin1Slice (buf, start, end) {
1313 var ret = ''
1314 end = Math.min(buf.length, end)
1315
1316 for (var i = start; i < end; ++i) {
1317 ret += String.fromCharCode(buf[i])
1318 }
1319 return ret
1320}
1321
1322function hexSlice (buf, start, end) {
1323 var len = buf.length
1324
1325 if (!start || start < 0) start = 0
1326 if (!end || end < 0 || end > len) end = len
1327
1328 var out = ''
1329 for (var i = start; i < end; ++i) {
1330 out += toHex(buf[i])
1331 }
1332 return out
1333}
1334
1335function utf16leSlice (buf, start, end) {
1336 var bytes = buf.slice(start, end)
1337 var res = ''
1338 for (var i = 0; i < bytes.length; i += 2) {
1339 res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
1340 }
1341 return res
1342}
1343
1344Buffer.prototype.slice = function slice (start, end) {
1345 var len = this.length
1346 start = ~~start
1347 end = end === undefined ? len : ~~end
1348
1349 if (start < 0) {
1350 start += len
1351 if (start < 0) start = 0
1352 } else if (start > len) {
1353 start = len
1354 }
1355
1356 if (end < 0) {
1357 end += len
1358 if (end < 0) end = 0
1359 } else if (end > len) {
1360 end = len
1361 }
1362
1363 if (end < start) end = start
1364
1365 var newBuf
1366 if (Buffer.TYPED_ARRAY_SUPPORT) {
1367 newBuf = this.subarray(start, end)
1368 newBuf.__proto__ = Buffer.prototype
1369 } else {
1370 var sliceLen = end - start
1371 newBuf = new Buffer(sliceLen, undefined)
1372 for (var i = 0; i < sliceLen; ++i) {
1373 newBuf[i] = this[i + start]
1374 }
1375 }
1376
1377 return newBuf
1378}
1379
1380/*
1381 * Need to make sure that buffer isn't trying to write out of bounds.
1382 */
1383function checkOffset (offset, ext, length) {
1384 if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
1385 if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
1386}
1387
1388Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
1389 offset = offset | 0
1390 byteLength = byteLength | 0
1391 if (!noAssert) checkOffset(offset, byteLength, this.length)
1392
1393 var val = this[offset]
1394 var mul = 1
1395 var i = 0
1396 while (++i < byteLength && (mul *= 0x100)) {
1397 val += this[offset + i] * mul
1398 }
1399
1400 return val
1401}
1402
1403Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
1404 offset = offset | 0
1405 byteLength = byteLength | 0
1406 if (!noAssert) {
1407 checkOffset(offset, byteLength, this.length)
1408 }
1409
1410 var val = this[offset + --byteLength]
1411 var mul = 1
1412 while (byteLength > 0 && (mul *= 0x100)) {
1413 val += this[offset + --byteLength] * mul
1414 }
1415
1416 return val
1417}
1418
1419Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
1420 if (!noAssert) checkOffset(offset, 1, this.length)
1421 return this[offset]
1422}
1423
1424Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
1425 if (!noAssert) checkOffset(offset, 2, this.length)
1426 return this[offset] | (this[offset + 1] << 8)
1427}
1428
1429Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
1430 if (!noAssert) checkOffset(offset, 2, this.length)
1431 return (this[offset] << 8) | this[offset + 1]
1432}
1433
1434Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
1435 if (!noAssert) checkOffset(offset, 4, this.length)
1436
1437 return ((this[offset]) |
1438 (this[offset + 1] << 8) |
1439 (this[offset + 2] << 16)) +
1440 (this[offset + 3] * 0x1000000)
1441}
1442
1443Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
1444 if (!noAssert) checkOffset(offset, 4, this.length)
1445
1446 return (this[offset] * 0x1000000) +
1447 ((this[offset + 1] << 16) |
1448 (this[offset + 2] << 8) |
1449 this[offset + 3])
1450}
1451
1452Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
1453 offset = offset | 0
1454 byteLength = byteLength | 0
1455 if (!noAssert) checkOffset(offset, byteLength, this.length)
1456
1457 var val = this[offset]
1458 var mul = 1
1459 var i = 0
1460 while (++i < byteLength && (mul *= 0x100)) {
1461 val += this[offset + i] * mul
1462 }
1463 mul *= 0x80
1464
1465 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1466
1467 return val
1468}
1469
1470Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
1471 offset = offset | 0
1472 byteLength = byteLength | 0
1473 if (!noAssert) checkOffset(offset, byteLength, this.length)
1474
1475 var i = byteLength
1476 var mul = 1
1477 var val = this[offset + --i]
1478 while (i > 0 && (mul *= 0x100)) {
1479 val += this[offset + --i] * mul
1480 }
1481 mul *= 0x80
1482
1483 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1484
1485 return val
1486}
1487
1488Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
1489 if (!noAssert) checkOffset(offset, 1, this.length)
1490 if (!(this[offset] & 0x80)) return (this[offset])
1491 return ((0xff - this[offset] + 1) * -1)
1492}
1493
1494Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
1495 if (!noAssert) checkOffset(offset, 2, this.length)
1496 var val = this[offset] | (this[offset + 1] << 8)
1497 return (val & 0x8000) ? val | 0xFFFF0000 : val
1498}
1499
1500Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
1501 if (!noAssert) checkOffset(offset, 2, this.length)
1502 var val = this[offset + 1] | (this[offset] << 8)
1503 return (val & 0x8000) ? val | 0xFFFF0000 : val
1504}
1505
1506Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
1507 if (!noAssert) checkOffset(offset, 4, this.length)
1508
1509 return (this[offset]) |
1510 (this[offset + 1] << 8) |
1511 (this[offset + 2] << 16) |
1512 (this[offset + 3] << 24)
1513}
1514
1515Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
1516 if (!noAssert) checkOffset(offset, 4, this.length)
1517
1518 return (this[offset] << 24) |
1519 (this[offset + 1] << 16) |
1520 (this[offset + 2] << 8) |
1521 (this[offset + 3])
1522}
1523
1524Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
1525 if (!noAssert) checkOffset(offset, 4, this.length)
1526 return ieee754.read(this, offset, true, 23, 4)
1527}
1528
1529Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
1530 if (!noAssert) checkOffset(offset, 4, this.length)
1531 return ieee754.read(this, offset, false, 23, 4)
1532}
1533
1534Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
1535 if (!noAssert) checkOffset(offset, 8, this.length)
1536 return ieee754.read(this, offset, true, 52, 8)
1537}
1538
1539Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
1540 if (!noAssert) checkOffset(offset, 8, this.length)
1541 return ieee754.read(this, offset, false, 52, 8)
1542}
1543
1544function checkInt (buf, value, offset, ext, max, min) {
1545 if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
1546 if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
1547 if (offset + ext > buf.length) throw new RangeError('Index out of range')
1548}
1549
1550Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
1551 value = +value
1552 offset = offset | 0
1553 byteLength = byteLength | 0
1554 if (!noAssert) {
1555 var maxBytes = Math.pow(2, 8 * byteLength) - 1
1556 checkInt(this, value, offset, byteLength, maxBytes, 0)
1557 }
1558
1559 var mul = 1
1560 var i = 0
1561 this[offset] = value & 0xFF
1562 while (++i < byteLength && (mul *= 0x100)) {
1563 this[offset + i] = (value / mul) & 0xFF
1564 }
1565
1566 return offset + byteLength
1567}
1568
1569Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
1570 value = +value
1571 offset = offset | 0
1572 byteLength = byteLength | 0
1573 if (!noAssert) {
1574 var maxBytes = Math.pow(2, 8 * byteLength) - 1
1575 checkInt(this, value, offset, byteLength, maxBytes, 0)
1576 }
1577
1578 var i = byteLength - 1
1579 var mul = 1
1580 this[offset + i] = value & 0xFF
1581 while (--i >= 0 && (mul *= 0x100)) {
1582 this[offset + i] = (value / mul) & 0xFF
1583 }
1584
1585 return offset + byteLength
1586}
1587
1588Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
1589 value = +value
1590 offset = offset | 0
1591 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
1592 if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
1593 this[offset] = (value & 0xff)
1594 return offset + 1
1595}
1596
1597function objectWriteUInt16 (buf, value, offset, littleEndian) {
1598 if (value < 0) value = 0xffff + value + 1
1599 for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
1600 buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
1601 (littleEndian ? i : 1 - i) * 8
1602 }
1603}
1604
1605Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
1606 value = +value
1607 offset = offset | 0
1608 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1609 if (Buffer.TYPED_ARRAY_SUPPORT) {
1610 this[offset] = (value & 0xff)
1611 this[offset + 1] = (value >>> 8)
1612 } else {
1613 objectWriteUInt16(this, value, offset, true)
1614 }
1615 return offset + 2
1616}
1617
1618Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
1619 value = +value
1620 offset = offset | 0
1621 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1622 if (Buffer.TYPED_ARRAY_SUPPORT) {
1623 this[offset] = (value >>> 8)
1624 this[offset + 1] = (value & 0xff)
1625 } else {
1626 objectWriteUInt16(this, value, offset, false)
1627 }
1628 return offset + 2
1629}
1630
1631function objectWriteUInt32 (buf, value, offset, littleEndian) {
1632 if (value < 0) value = 0xffffffff + value + 1
1633 for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
1634 buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
1635 }
1636}
1637
1638Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
1639 value = +value
1640 offset = offset | 0
1641 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1642 if (Buffer.TYPED_ARRAY_SUPPORT) {
1643 this[offset + 3] = (value >>> 24)
1644 this[offset + 2] = (value >>> 16)
1645 this[offset + 1] = (value >>> 8)
1646 this[offset] = (value & 0xff)
1647 } else {
1648 objectWriteUInt32(this, value, offset, true)
1649 }
1650 return offset + 4
1651}
1652
1653Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
1654 value = +value
1655 offset = offset | 0
1656 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1657 if (Buffer.TYPED_ARRAY_SUPPORT) {
1658 this[offset] = (value >>> 24)
1659 this[offset + 1] = (value >>> 16)
1660 this[offset + 2] = (value >>> 8)
1661 this[offset + 3] = (value & 0xff)
1662 } else {
1663 objectWriteUInt32(this, value, offset, false)
1664 }
1665 return offset + 4
1666}
1667
1668Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
1669 value = +value
1670 offset = offset | 0
1671 if (!noAssert) {
1672 var limit = Math.pow(2, 8 * byteLength - 1)
1673
1674 checkInt(this, value, offset, byteLength, limit - 1, -limit)
1675 }
1676
1677 var i = 0
1678 var mul = 1
1679 var sub = 0
1680 this[offset] = value & 0xFF
1681 while (++i < byteLength && (mul *= 0x100)) {
1682 if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
1683 sub = 1
1684 }
1685 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1686 }
1687
1688 return offset + byteLength
1689}
1690
1691Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
1692 value = +value
1693 offset = offset | 0
1694 if (!noAssert) {
1695 var limit = Math.pow(2, 8 * byteLength - 1)
1696
1697 checkInt(this, value, offset, byteLength, limit - 1, -limit)
1698 }
1699
1700 var i = byteLength - 1
1701 var mul = 1
1702 var sub = 0
1703 this[offset + i] = value & 0xFF
1704 while (--i >= 0 && (mul *= 0x100)) {
1705 if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
1706 sub = 1
1707 }
1708 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1709 }
1710
1711 return offset + byteLength
1712}
1713
1714Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
1715 value = +value
1716 offset = offset | 0
1717 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
1718 if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
1719 if (value < 0) value = 0xff + value + 1
1720 this[offset] = (value & 0xff)
1721 return offset + 1
1722}
1723
1724Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
1725 value = +value
1726 offset = offset | 0
1727 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1728 if (Buffer.TYPED_ARRAY_SUPPORT) {
1729 this[offset] = (value & 0xff)
1730 this[offset + 1] = (value >>> 8)
1731 } else {
1732 objectWriteUInt16(this, value, offset, true)
1733 }
1734 return offset + 2
1735}
1736
1737Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
1738 value = +value
1739 offset = offset | 0
1740 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1741 if (Buffer.TYPED_ARRAY_SUPPORT) {
1742 this[offset] = (value >>> 8)
1743 this[offset + 1] = (value & 0xff)
1744 } else {
1745 objectWriteUInt16(this, value, offset, false)
1746 }
1747 return offset + 2
1748}
1749
1750Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
1751 value = +value
1752 offset = offset | 0
1753 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
1754 if (Buffer.TYPED_ARRAY_SUPPORT) {
1755 this[offset] = (value & 0xff)
1756 this[offset + 1] = (value >>> 8)
1757 this[offset + 2] = (value >>> 16)
1758 this[offset + 3] = (value >>> 24)
1759 } else {
1760 objectWriteUInt32(this, value, offset, true)
1761 }
1762 return offset + 4
1763}
1764
1765Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
1766 value = +value
1767 offset = offset | 0
1768 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
1769 if (value < 0) value = 0xffffffff + value + 1
1770 if (Buffer.TYPED_ARRAY_SUPPORT) {
1771 this[offset] = (value >>> 24)
1772 this[offset + 1] = (value >>> 16)
1773 this[offset + 2] = (value >>> 8)
1774 this[offset + 3] = (value & 0xff)
1775 } else {
1776 objectWriteUInt32(this, value, offset, false)
1777 }
1778 return offset + 4
1779}
1780
1781function checkIEEE754 (buf, value, offset, ext, max, min) {
1782 if (offset + ext > buf.length) throw new RangeError('Index out of range')
1783 if (offset < 0) throw new RangeError('Index out of range')
1784}
1785
1786function writeFloat (buf, value, offset, littleEndian, noAssert) {
1787 if (!noAssert) {
1788 checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
1789 }
1790 ieee754.write(buf, value, offset, littleEndian, 23, 4)
1791 return offset + 4
1792}
1793
1794Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
1795 return writeFloat(this, value, offset, true, noAssert)
1796}
1797
1798Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
1799 return writeFloat(this, value, offset, false, noAssert)
1800}
1801
1802function writeDouble (buf, value, offset, littleEndian, noAssert) {
1803 if (!noAssert) {
1804 checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
1805 }
1806 ieee754.write(buf, value, offset, littleEndian, 52, 8)
1807 return offset + 8
1808}
1809
1810Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
1811 return writeDouble(this, value, offset, true, noAssert)
1812}
1813
1814Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
1815 return writeDouble(this, value, offset, false, noAssert)
1816}
1817
1818// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
1819Buffer.prototype.copy = function copy (target, targetStart, start, end) {
1820 if (!start) start = 0
1821 if (!end && end !== 0) end = this.length
1822 if (targetStart >= target.length) targetStart = target.length
1823 if (!targetStart) targetStart = 0
1824 if (end > 0 && end < start) end = start
1825
1826 // Copy 0 bytes; we're done
1827 if (end === start) return 0
1828 if (target.length === 0 || this.length === 0) return 0
1829
1830 // Fatal error conditions
1831 if (targetStart < 0) {
1832 throw new RangeError('targetStart out of bounds')
1833 }
1834 if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
1835 if (end < 0) throw new RangeError('sourceEnd out of bounds')
1836
1837 // Are we oob?
1838 if (end > this.length) end = this.length
1839 if (target.length - targetStart < end - start) {
1840 end = target.length - targetStart + start
1841 }
1842
1843 var len = end - start
1844 var i
1845
1846 if (this === target && start < targetStart && targetStart < end) {
1847 // descending copy from end
1848 for (i = len - 1; i >= 0; --i) {
1849 target[i + targetStart] = this[i + start]
1850 }
1851 } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
1852 // ascending copy from start
1853 for (i = 0; i < len; ++i) {
1854 target[i + targetStart] = this[i + start]
1855 }
1856 } else {
1857 Uint8Array.prototype.set.call(
1858 target,
1859 this.subarray(start, start + len),
1860 targetStart
1861 )
1862 }
1863
1864 return len
1865}
1866
1867// Usage:
1868// buffer.fill(number[, offset[, end]])
1869// buffer.fill(buffer[, offset[, end]])
1870// buffer.fill(string[, offset[, end]][, encoding])
1871Buffer.prototype.fill = function fill (val, start, end, encoding) {
1872 // Handle string cases:
1873 if (typeof val === 'string') {
1874 if (typeof start === 'string') {
1875 encoding = start
1876 start = 0
1877 end = this.length
1878 } else if (typeof end === 'string') {
1879 encoding = end
1880 end = this.length
1881 }
1882 if (val.length === 1) {
1883 var code = val.charCodeAt(0)
1884 if (code < 256) {
1885 val = code
1886 }
1887 }
1888 if (encoding !== undefined && typeof encoding !== 'string') {
1889 throw new TypeError('encoding must be a string')
1890 }
1891 if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
1892 throw new TypeError('Unknown encoding: ' + encoding)
1893 }
1894 } else if (typeof val === 'number') {
1895 val = val & 255
1896 }
1897
1898 // Invalid ranges are not set to a default, so can range check early.
1899 if (start < 0 || this.length < start || this.length < end) {
1900 throw new RangeError('Out of range index')
1901 }
1902
1903 if (end <= start) {
1904 return this
1905 }
1906
1907 start = start >>> 0
1908 end = end === undefined ? this.length : end >>> 0
1909
1910 if (!val) val = 0
1911
1912 var i
1913 if (typeof val === 'number') {
1914 for (i = start; i < end; ++i) {
1915 this[i] = val
1916 }
1917 } else {
1918 var bytes = Buffer.isBuffer(val)
1919 ? val
1920 : utf8ToBytes(new Buffer(val, encoding).toString())
1921 var len = bytes.length
1922 for (i = 0; i < end - start; ++i) {
1923 this[i + start] = bytes[i % len]
1924 }
1925 }
1926
1927 return this
1928}
1929
1930// HELPER FUNCTIONS
1931// ================
1932
1933var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
1934
1935function base64clean (str) {
1936 // Node strips out invalid characters like \n and \t from the string, base64-js does not
1937 str = stringtrim(str).replace(INVALID_BASE64_RE, '')
1938 // Node converts strings with length < 2 to ''
1939 if (str.length < 2) return ''
1940 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
1941 while (str.length % 4 !== 0) {
1942 str = str + '='
1943 }
1944 return str
1945}
1946
1947function stringtrim (str) {
1948 if (str.trim) return str.trim()
1949 return str.replace(/^\s+|\s+$/g, '')
1950}
1951
1952function toHex (n) {
1953 if (n < 16) return '0' + n.toString(16)
1954 return n.toString(16)
1955}
1956
1957function utf8ToBytes (string, units) {
1958 units = units || Infinity
1959 var codePoint
1960 var length = string.length
1961 var leadSurrogate = null
1962 var bytes = []
1963
1964 for (var i = 0; i < length; ++i) {
1965 codePoint = string.charCodeAt(i)
1966
1967 // is surrogate component
1968 if (codePoint > 0xD7FF && codePoint < 0xE000) {
1969 // last char was a lead
1970 if (!leadSurrogate) {
1971 // no lead yet
1972 if (codePoint > 0xDBFF) {
1973 // unexpected trail
1974 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1975 continue
1976 } else if (i + 1 === length) {
1977 // unpaired lead
1978 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1979 continue
1980 }
1981
1982 // valid lead
1983 leadSurrogate = codePoint
1984
1985 continue
1986 }
1987
1988 // 2 leads in a row
1989 if (codePoint < 0xDC00) {
1990 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1991 leadSurrogate = codePoint
1992 continue
1993 }
1994
1995 // valid surrogate pair
1996 codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
1997 } else if (leadSurrogate) {
1998 // valid bmp char, but last char was a lead
1999 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2000 }
2001
2002 leadSurrogate = null
2003
2004 // encode utf8
2005 if (codePoint < 0x80) {
2006 if ((units -= 1) < 0) break
2007 bytes.push(codePoint)
2008 } else if (codePoint < 0x800) {
2009 if ((units -= 2) < 0) break
2010 bytes.push(
2011 codePoint >> 0x6 | 0xC0,
2012 codePoint & 0x3F | 0x80
2013 )
2014 } else if (codePoint < 0x10000) {
2015 if ((units -= 3) < 0) break
2016 bytes.push(
2017 codePoint >> 0xC | 0xE0,
2018 codePoint >> 0x6 & 0x3F | 0x80,
2019 codePoint & 0x3F | 0x80
2020 )
2021 } else if (codePoint < 0x110000) {
2022 if ((units -= 4) < 0) break
2023 bytes.push(
2024 codePoint >> 0x12 | 0xF0,
2025 codePoint >> 0xC & 0x3F | 0x80,
2026 codePoint >> 0x6 & 0x3F | 0x80,
2027 codePoint & 0x3F | 0x80
2028 )
2029 } else {
2030 throw new Error('Invalid code point')
2031 }
2032 }
2033
2034 return bytes
2035}
2036
2037function asciiToBytes (str) {
2038 var byteArray = []
2039 for (var i = 0; i < str.length; ++i) {
2040 // Node's code seems to be doing this and not & 0x7F..
2041 byteArray.push(str.charCodeAt(i) & 0xFF)
2042 }
2043 return byteArray
2044}
2045
2046function utf16leToBytes (str, units) {
2047 var c, hi, lo
2048 var byteArray = []
2049 for (var i = 0; i < str.length; ++i) {
2050 if ((units -= 2) < 0) break
2051
2052 c = str.charCodeAt(i)
2053 hi = c >> 8
2054 lo = c % 256
2055 byteArray.push(lo)
2056 byteArray.push(hi)
2057 }
2058
2059 return byteArray
2060}
2061
2062function base64ToBytes (str) {
2063 return base64.toByteArray(base64clean(str))
2064}
2065
2066function blitBuffer (src, dst, offset, length) {
2067 for (var i = 0; i < length; ++i) {
2068 if ((i + offset >= dst.length) || (i >= src.length)) break
2069 dst[i + offset] = src[i]
2070 }
2071 return i
2072}
2073
2074function isnan (val) {
2075 return val !== val // eslint-disable-line no-self-compare
2076}
2077
2078/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
2079
2080/***/ }),
2081/* 3 */
2082/***/ (function(module, exports, __webpack_require__) {
2083
2084"use strict";
2085// Copyright Joyent, Inc. and other Node contributors.
2086//
2087// Permission is hereby granted, free of charge, to any person obtaining a
2088// copy of this software and associated documentation files (the
2089// "Software"), to deal in the Software without restriction, including
2090// without limitation the rights to use, copy, modify, merge, publish,
2091// distribute, sublicense, and/or sell copies of the Software, and to permit
2092// persons to whom the Software is furnished to do so, subject to the
2093// following conditions:
2094//
2095// The above copyright notice and this permission notice shall be included
2096// in all copies or substantial portions of the Software.
2097//
2098// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
2099// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2100// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
2101// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
2102// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
2103// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2104// USE OR OTHER DEALINGS IN THE SOFTWARE.
2105
2106// a duplex stream is just a stream that is both readable and writable.
2107// Since JS doesn't have multiple prototypal inheritance, this class
2108// prototypally inherits from Readable, and then parasitically from
2109// Writable.
2110
2111
2112
2113/*<replacement>*/
2114
2115var pna = __webpack_require__(6);
2116/*</replacement>*/
2117
2118/*<replacement>*/
2119var objectKeys = Object.keys || function (obj) {
2120 var keys = [];
2121 for (var key in obj) {
2122 keys.push(key);
2123 }return keys;
2124};
2125/*</replacement>*/
2126
2127module.exports = Duplex;
2128
2129/*<replacement>*/
2130var util = __webpack_require__(4);
2131util.inherits = __webpack_require__(5);
2132/*</replacement>*/
2133
2134var Readable = __webpack_require__(15);
2135var Writable = __webpack_require__(18);
2136
2137util.inherits(Duplex, Readable);
2138
2139{
2140 // avoid scope creep, the keys array can then be collected
2141 var keys = objectKeys(Writable.prototype);
2142 for (var v = 0; v < keys.length; v++) {
2143 var method = keys[v];
2144 if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
2145 }
2146}
2147
2148function Duplex(options) {
2149 if (!(this instanceof Duplex)) return new Duplex(options);
2150
2151 Readable.call(this, options);
2152 Writable.call(this, options);
2153
2154 if (options && options.readable === false) this.readable = false;
2155
2156 if (options && options.writable === false) this.writable = false;
2157
2158 this.allowHalfOpen = true;
2159 if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
2160
2161 this.once('end', onend);
2162}
2163
2164Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
2165 // making it explicit this property is not enumerable
2166 // because otherwise some prototype manipulation in
2167 // userland will fail
2168 enumerable: false,
2169 get: function () {
2170 return this._writableState.highWaterMark;
2171 }
2172});
2173
2174// the no-half-open enforcer
2175function onend() {
2176 // if we allow half-open state, or if the writable side ended,
2177 // then we're ok.
2178 if (this.allowHalfOpen || this._writableState.ended) return;
2179
2180 // no more data can be written.
2181 // But allow more writes to happen in this tick.
2182 pna.nextTick(onEndNT, this);
2183}
2184
2185function onEndNT(self) {
2186 self.end();
2187}
2188
2189Object.defineProperty(Duplex.prototype, 'destroyed', {
2190 get: function () {
2191 if (this._readableState === undefined || this._writableState === undefined) {
2192 return false;
2193 }
2194 return this._readableState.destroyed && this._writableState.destroyed;
2195 },
2196 set: function (value) {
2197 // we ignore the value if the stream
2198 // has not been initialized yet
2199 if (this._readableState === undefined || this._writableState === undefined) {
2200 return;
2201 }
2202
2203 // backward compatibility, the user is explicitly
2204 // managing destroyed
2205 this._readableState.destroyed = value;
2206 this._writableState.destroyed = value;
2207 }
2208});
2209
2210Duplex.prototype._destroy = function (err, cb) {
2211 this.push(null);
2212 this.end();
2213
2214 pna.nextTick(cb, err);
2215};
2216
2217/***/ }),
2218/* 4 */
2219/***/ (function(module, exports, __webpack_require__) {
2220
2221/* WEBPACK VAR INJECTION */(function(Buffer) {// Copyright Joyent, Inc. and other Node contributors.
2222//
2223// Permission is hereby granted, free of charge, to any person obtaining a
2224// copy of this software and associated documentation files (the
2225// "Software"), to deal in the Software without restriction, including
2226// without limitation the rights to use, copy, modify, merge, publish,
2227// distribute, sublicense, and/or sell copies of the Software, and to permit
2228// persons to whom the Software is furnished to do so, subject to the
2229// following conditions:
2230//
2231// The above copyright notice and this permission notice shall be included
2232// in all copies or substantial portions of the Software.
2233//
2234// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
2235// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2236// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
2237// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
2238// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
2239// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2240// USE OR OTHER DEALINGS IN THE SOFTWARE.
2241
2242// NOTE: These type checking functions intentionally don't use `instanceof`
2243// because it is fragile and can be easily faked with `Object.create()`.
2244
2245function isArray(arg) {
2246 if (Array.isArray) {
2247 return Array.isArray(arg);
2248 }
2249 return objectToString(arg) === '[object Array]';
2250}
2251exports.isArray = isArray;
2252
2253function isBoolean(arg) {
2254 return typeof arg === 'boolean';
2255}
2256exports.isBoolean = isBoolean;
2257
2258function isNull(arg) {
2259 return arg === null;
2260}
2261exports.isNull = isNull;
2262
2263function isNullOrUndefined(arg) {
2264 return arg == null;
2265}
2266exports.isNullOrUndefined = isNullOrUndefined;
2267
2268function isNumber(arg) {
2269 return typeof arg === 'number';
2270}
2271exports.isNumber = isNumber;
2272
2273function isString(arg) {
2274 return typeof arg === 'string';
2275}
2276exports.isString = isString;
2277
2278function isSymbol(arg) {
2279 return typeof arg === 'symbol';
2280}
2281exports.isSymbol = isSymbol;
2282
2283function isUndefined(arg) {
2284 return arg === void 0;
2285}
2286exports.isUndefined = isUndefined;
2287
2288function isRegExp(re) {
2289 return objectToString(re) === '[object RegExp]';
2290}
2291exports.isRegExp = isRegExp;
2292
2293function isObject(arg) {
2294 return typeof arg === 'object' && arg !== null;
2295}
2296exports.isObject = isObject;
2297
2298function isDate(d) {
2299 return objectToString(d) === '[object Date]';
2300}
2301exports.isDate = isDate;
2302
2303function isError(e) {
2304 return (objectToString(e) === '[object Error]' || e instanceof Error);
2305}
2306exports.isError = isError;
2307
2308function isFunction(arg) {
2309 return typeof arg === 'function';
2310}
2311exports.isFunction = isFunction;
2312
2313function isPrimitive(arg) {
2314 return arg === null ||
2315 typeof arg === 'boolean' ||
2316 typeof arg === 'number' ||
2317 typeof arg === 'string' ||
2318 typeof arg === 'symbol' || // ES6 symbol
2319 typeof arg === 'undefined';
2320}
2321exports.isPrimitive = isPrimitive;
2322
2323exports.isBuffer = Buffer.isBuffer;
2324
2325function objectToString(o) {
2326 return Object.prototype.toString.call(o);
2327}
2328
2329/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2).Buffer))
2330
2331/***/ }),
2332/* 5 */
2333/***/ (function(module, exports) {
2334
2335if (typeof Object.create === 'function') {
2336 // implementation from standard node.js 'util' module
2337 module.exports = function inherits(ctor, superCtor) {
2338 ctor.super_ = superCtor
2339 ctor.prototype = Object.create(superCtor.prototype, {
2340 constructor: {
2341 value: ctor,
2342 enumerable: false,
2343 writable: true,
2344 configurable: true
2345 }
2346 });
2347 };
2348} else {
2349 // old school shim for old browsers
2350 module.exports = function inherits(ctor, superCtor) {
2351 ctor.super_ = superCtor
2352 var TempCtor = function () {}
2353 TempCtor.prototype = superCtor.prototype
2354 ctor.prototype = new TempCtor()
2355 ctor.prototype.constructor = ctor
2356 }
2357}
2358
2359
2360/***/ }),
2361/* 6 */
2362/***/ (function(module, exports, __webpack_require__) {
2363
2364"use strict";
2365/* WEBPACK VAR INJECTION */(function(process) {
2366
2367if (!process.version ||
2368 process.version.indexOf('v0.') === 0 ||
2369 process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
2370 module.exports = { nextTick: nextTick };
2371} else {
2372 module.exports = process
2373}
2374
2375function nextTick(fn, arg1, arg2, arg3) {
2376 if (typeof fn !== 'function') {
2377 throw new TypeError('"callback" argument must be a function');
2378 }
2379 var len = arguments.length;
2380 var args, i;
2381 switch (len) {
2382 case 0:
2383 case 1:
2384 return process.nextTick(fn);
2385 case 2:
2386 return process.nextTick(function afterTickOne() {
2387 fn.call(null, arg1);
2388 });
2389 case 3:
2390 return process.nextTick(function afterTickTwo() {
2391 fn.call(null, arg1, arg2);
2392 });
2393 case 4:
2394 return process.nextTick(function afterTickThree() {
2395 fn.call(null, arg1, arg2, arg3);
2396 });
2397 default:
2398 args = new Array(len - 1);
2399 i = 0;
2400 while (i < args.length) {
2401 args[i++] = arguments[i];
2402 }
2403 return process.nextTick(function afterTick() {
2404 fn.apply(null, args);
2405 });
2406 }
2407}
2408
2409
2410/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)))
2411
2412/***/ }),
2413/* 7 */
2414/***/ (function(module, exports, __webpack_require__) {
2415
2416"use strict";
2417// Copyright Joyent, Inc. and other Node contributors.
2418//
2419// Permission is hereby granted, free of charge, to any person obtaining a
2420// copy of this software and associated documentation files (the
2421// "Software"), to deal in the Software without restriction, including
2422// without limitation the rights to use, copy, modify, merge, publish,
2423// distribute, sublicense, and/or sell copies of the Software, and to permit
2424// persons to whom the Software is furnished to do so, subject to the
2425// following conditions:
2426//
2427// The above copyright notice and this permission notice shall be included
2428// in all copies or substantial portions of the Software.
2429//
2430// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
2431// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2432// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
2433// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
2434// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
2435// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2436// USE OR OTHER DEALINGS IN THE SOFTWARE.
2437
2438
2439
2440var punycode = __webpack_require__(30);
2441var util = __webpack_require__(32);
2442
2443exports.parse = urlParse;
2444exports.resolve = urlResolve;
2445exports.resolveObject = urlResolveObject;
2446exports.format = urlFormat;
2447
2448exports.Url = Url;
2449
2450function Url() {
2451 this.protocol = null;
2452 this.slashes = null;
2453 this.auth = null;
2454 this.host = null;
2455 this.port = null;
2456 this.hostname = null;
2457 this.hash = null;
2458 this.search = null;
2459 this.query = null;
2460 this.pathname = null;
2461 this.path = null;
2462 this.href = null;
2463}
2464
2465// Reference: RFC 3986, RFC 1808, RFC 2396
2466
2467// define these here so at least they only have to be
2468// compiled once on the first module load.
2469var protocolPattern = /^([a-z0-9.+-]+:)/i,
2470 portPattern = /:[0-9]*$/,
2471
2472 // Special case for a simple path URL
2473 simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
2474
2475 // RFC 2396: characters reserved for delimiting URLs.
2476 // We actually just auto-escape these.
2477 delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
2478
2479 // RFC 2396: characters not allowed for various reasons.
2480 unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
2481
2482 // Allowed by RFCs, but cause of XSS attacks. Always escape these.
2483 autoEscape = ['\''].concat(unwise),
2484 // Characters that are never ever allowed in a hostname.
2485 // Note that any invalid chars are also handled, but these
2486 // are the ones that are *expected* to be seen, so we fast-path
2487 // them.
2488 nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
2489 hostEndingChars = ['/', '?', '#'],
2490 hostnameMaxLen = 255,
2491 hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
2492 hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
2493 // protocols that can allow "unsafe" and "unwise" chars.
2494 unsafeProtocol = {
2495 'javascript': true,
2496 'javascript:': true
2497 },
2498 // protocols that never have a hostname.
2499 hostlessProtocol = {
2500 'javascript': true,
2501 'javascript:': true
2502 },
2503 // protocols that always contain a // bit.
2504 slashedProtocol = {
2505 'http': true,
2506 'https': true,
2507 'ftp': true,
2508 'gopher': true,
2509 'file': true,
2510 'http:': true,
2511 'https:': true,
2512 'ftp:': true,
2513 'gopher:': true,
2514 'file:': true
2515 },
2516 querystring = __webpack_require__(33);
2517
2518function urlParse(url, parseQueryString, slashesDenoteHost) {
2519 if (url && util.isObject(url) && url instanceof Url) return url;
2520
2521 var u = new Url;
2522 u.parse(url, parseQueryString, slashesDenoteHost);
2523 return u;
2524}
2525
2526Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
2527 if (!util.isString(url)) {
2528 throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
2529 }
2530
2531 // Copy chrome, IE, opera backslash-handling behavior.
2532 // Back slashes before the query string get converted to forward slashes
2533 // See: https://code.google.com/p/chromium/issues/detail?id=25916
2534 var queryIndex = url.indexOf('?'),
2535 splitter =
2536 (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',
2537 uSplit = url.split(splitter),
2538 slashRegex = /\\/g;
2539 uSplit[0] = uSplit[0].replace(slashRegex, '/');
2540 url = uSplit.join(splitter);
2541
2542 var rest = url;
2543
2544 // trim before proceeding.
2545 // This is to support parse stuff like " http://foo.com \n"
2546 rest = rest.trim();
2547
2548 if (!slashesDenoteHost && url.split('#').length === 1) {
2549 // Try fast path regexp
2550 var simplePath = simplePathPattern.exec(rest);
2551 if (simplePath) {
2552 this.path = rest;
2553 this.href = rest;
2554 this.pathname = simplePath[1];
2555 if (simplePath[2]) {
2556 this.search = simplePath[2];
2557 if (parseQueryString) {
2558 this.query = querystring.parse(this.search.substr(1));
2559 } else {
2560 this.query = this.search.substr(1);
2561 }
2562 } else if (parseQueryString) {
2563 this.search = '';
2564 this.query = {};
2565 }
2566 return this;
2567 }
2568 }
2569
2570 var proto = protocolPattern.exec(rest);
2571 if (proto) {
2572 proto = proto[0];
2573 var lowerProto = proto.toLowerCase();
2574 this.protocol = lowerProto;
2575 rest = rest.substr(proto.length);
2576 }
2577
2578 // figure out if it's got a host
2579 // user@server is *always* interpreted as a hostname, and url
2580 // resolution will treat //foo/bar as host=foo,path=bar because that's
2581 // how the browser resolves relative URLs.
2582 if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
2583 var slashes = rest.substr(0, 2) === '//';
2584 if (slashes && !(proto && hostlessProtocol[proto])) {
2585 rest = rest.substr(2);
2586 this.slashes = true;
2587 }
2588 }
2589
2590 if (!hostlessProtocol[proto] &&
2591 (slashes || (proto && !slashedProtocol[proto]))) {
2592
2593 // there's a hostname.
2594 // the first instance of /, ?, ;, or # ends the host.
2595 //
2596 // If there is an @ in the hostname, then non-host chars *are* allowed
2597 // to the left of the last @ sign, unless some host-ending character
2598 // comes *before* the @-sign.
2599 // URLs are obnoxious.
2600 //
2601 // ex:
2602 // http://a@b@c/ => user:a@b host:c
2603 // http://a@b?@c => user:a host:c path:/?@c
2604
2605 // v0.12 TODO(isaacs): This is not quite how Chrome does things.
2606 // Review our test case against browsers more comprehensively.
2607
2608 // find the first instance of any hostEndingChars
2609 var hostEnd = -1;
2610 for (var i = 0; i < hostEndingChars.length; i++) {
2611 var hec = rest.indexOf(hostEndingChars[i]);
2612 if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
2613 hostEnd = hec;
2614 }
2615
2616 // at this point, either we have an explicit point where the
2617 // auth portion cannot go past, or the last @ char is the decider.
2618 var auth, atSign;
2619 if (hostEnd === -1) {
2620 // atSign can be anywhere.
2621 atSign = rest.lastIndexOf('@');
2622 } else {
2623 // atSign must be in auth portion.
2624 // http://a@b/c@d => host:b auth:a path:/c@d
2625 atSign = rest.lastIndexOf('@', hostEnd);
2626 }
2627
2628 // Now we have a portion which is definitely the auth.
2629 // Pull that off.
2630 if (atSign !== -1) {
2631 auth = rest.slice(0, atSign);
2632 rest = rest.slice(atSign + 1);
2633 this.auth = decodeURIComponent(auth);
2634 }
2635
2636 // the host is the remaining to the left of the first non-host char
2637 hostEnd = -1;
2638 for (var i = 0; i < nonHostChars.length; i++) {
2639 var hec = rest.indexOf(nonHostChars[i]);
2640 if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
2641 hostEnd = hec;
2642 }
2643 // if we still have not hit it, then the entire thing is a host.
2644 if (hostEnd === -1)
2645 hostEnd = rest.length;
2646
2647 this.host = rest.slice(0, hostEnd);
2648 rest = rest.slice(hostEnd);
2649
2650 // pull out port.
2651 this.parseHost();
2652
2653 // we've indicated that there is a hostname,
2654 // so even if it's empty, it has to be present.
2655 this.hostname = this.hostname || '';
2656
2657 // if hostname begins with [ and ends with ]
2658 // assume that it's an IPv6 address.
2659 var ipv6Hostname = this.hostname[0] === '[' &&
2660 this.hostname[this.hostname.length - 1] === ']';
2661
2662 // validate a little.
2663 if (!ipv6Hostname) {
2664 var hostparts = this.hostname.split(/\./);
2665 for (var i = 0, l = hostparts.length; i < l; i++) {
2666 var part = hostparts[i];
2667 if (!part) continue;
2668 if (!part.match(hostnamePartPattern)) {
2669 var newpart = '';
2670 for (var j = 0, k = part.length; j < k; j++) {
2671 if (part.charCodeAt(j) > 127) {
2672 // we replace non-ASCII char with a temporary placeholder
2673 // we need this to make sure size of hostname is not
2674 // broken by replacing non-ASCII by nothing
2675 newpart += 'x';
2676 } else {
2677 newpart += part[j];
2678 }
2679 }
2680 // we test again with ASCII char only
2681 if (!newpart.match(hostnamePartPattern)) {
2682 var validParts = hostparts.slice(0, i);
2683 var notHost = hostparts.slice(i + 1);
2684 var bit = part.match(hostnamePartStart);
2685 if (bit) {
2686 validParts.push(bit[1]);
2687 notHost.unshift(bit[2]);
2688 }
2689 if (notHost.length) {
2690 rest = '/' + notHost.join('.') + rest;
2691 }
2692 this.hostname = validParts.join('.');
2693 break;
2694 }
2695 }
2696 }
2697 }
2698
2699 if (this.hostname.length > hostnameMaxLen) {
2700 this.hostname = '';
2701 } else {
2702 // hostnames are always lower case.
2703 this.hostname = this.hostname.toLowerCase();
2704 }
2705
2706 if (!ipv6Hostname) {
2707 // IDNA Support: Returns a punycoded representation of "domain".
2708 // It only converts parts of the domain name that
2709 // have non-ASCII characters, i.e. it doesn't matter if
2710 // you call it with a domain that already is ASCII-only.
2711 this.hostname = punycode.toASCII(this.hostname);
2712 }
2713
2714 var p = this.port ? ':' + this.port : '';
2715 var h = this.hostname || '';
2716 this.host = h + p;
2717 this.href += this.host;
2718
2719 // strip [ and ] from the hostname
2720 // the host field still retains them, though
2721 if (ipv6Hostname) {
2722 this.hostname = this.hostname.substr(1, this.hostname.length - 2);
2723 if (rest[0] !== '/') {
2724 rest = '/' + rest;
2725 }
2726 }
2727 }
2728
2729 // now rest is set to the post-host stuff.
2730 // chop off any delim chars.
2731 if (!unsafeProtocol[lowerProto]) {
2732
2733 // First, make 100% sure that any "autoEscape" chars get
2734 // escaped, even if encodeURIComponent doesn't think they
2735 // need to be.
2736 for (var i = 0, l = autoEscape.length; i < l; i++) {
2737 var ae = autoEscape[i];
2738 if (rest.indexOf(ae) === -1)
2739 continue;
2740 var esc = encodeURIComponent(ae);
2741 if (esc === ae) {
2742 esc = escape(ae);
2743 }
2744 rest = rest.split(ae).join(esc);
2745 }
2746 }
2747
2748
2749 // chop off from the tail first.
2750 var hash = rest.indexOf('#');
2751 if (hash !== -1) {
2752 // got a fragment string.
2753 this.hash = rest.substr(hash);
2754 rest = rest.slice(0, hash);
2755 }
2756 var qm = rest.indexOf('?');
2757 if (qm !== -1) {
2758 this.search = rest.substr(qm);
2759 this.query = rest.substr(qm + 1);
2760 if (parseQueryString) {
2761 this.query = querystring.parse(this.query);
2762 }
2763 rest = rest.slice(0, qm);
2764 } else if (parseQueryString) {
2765 // no query string, but parseQueryString still requested
2766 this.search = '';
2767 this.query = {};
2768 }
2769 if (rest) this.pathname = rest;
2770 if (slashedProtocol[lowerProto] &&
2771 this.hostname && !this.pathname) {
2772 this.pathname = '/';
2773 }
2774
2775 //to support http.request
2776 if (this.pathname || this.search) {
2777 var p = this.pathname || '';
2778 var s = this.search || '';
2779 this.path = p + s;
2780 }
2781
2782 // finally, reconstruct the href based on what has been validated.
2783 this.href = this.format();
2784 return this;
2785};
2786
2787// format a parsed object into a url string
2788function urlFormat(obj) {
2789 // ensure it's an object, and not a string url.
2790 // If it's an obj, this is a no-op.
2791 // this way, you can call url_format() on strings
2792 // to clean up potentially wonky urls.
2793 if (util.isString(obj)) obj = urlParse(obj);
2794 if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
2795 return obj.format();
2796}
2797
2798Url.prototype.format = function() {
2799 var auth = this.auth || '';
2800 if (auth) {
2801 auth = encodeURIComponent(auth);
2802 auth = auth.replace(/%3A/i, ':');
2803 auth += '@';
2804 }
2805
2806 var protocol = this.protocol || '',
2807 pathname = this.pathname || '',
2808 hash = this.hash || '',
2809 host = false,
2810 query = '';
2811
2812 if (this.host) {
2813 host = auth + this.host;
2814 } else if (this.hostname) {
2815 host = auth + (this.hostname.indexOf(':') === -1 ?
2816 this.hostname :
2817 '[' + this.hostname + ']');
2818 if (this.port) {
2819 host += ':' + this.port;
2820 }
2821 }
2822
2823 if (this.query &&
2824 util.isObject(this.query) &&
2825 Object.keys(this.query).length) {
2826 query = querystring.stringify(this.query);
2827 }
2828
2829 var search = this.search || (query && ('?' + query)) || '';
2830
2831 if (protocol && protocol.substr(-1) !== ':') protocol += ':';
2832
2833 // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
2834 // unless they had them to begin with.
2835 if (this.slashes ||
2836 (!protocol || slashedProtocol[protocol]) && host !== false) {
2837 host = '//' + (host || '');
2838 if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
2839 } else if (!host) {
2840 host = '';
2841 }
2842
2843 if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
2844 if (search && search.charAt(0) !== '?') search = '?' + search;
2845
2846 pathname = pathname.replace(/[?#]/g, function(match) {
2847 return encodeURIComponent(match);
2848 });
2849 search = search.replace('#', '%23');
2850
2851 return protocol + host + pathname + search + hash;
2852};
2853
2854function urlResolve(source, relative) {
2855 return urlParse(source, false, true).resolve(relative);
2856}
2857
2858Url.prototype.resolve = function(relative) {
2859 return this.resolveObject(urlParse(relative, false, true)).format();
2860};
2861
2862function urlResolveObject(source, relative) {
2863 if (!source) return relative;
2864 return urlParse(source, false, true).resolveObject(relative);
2865}
2866
2867Url.prototype.resolveObject = function(relative) {
2868 if (util.isString(relative)) {
2869 var rel = new Url();
2870 rel.parse(relative, false, true);
2871 relative = rel;
2872 }
2873
2874 var result = new Url();
2875 var tkeys = Object.keys(this);
2876 for (var tk = 0; tk < tkeys.length; tk++) {
2877 var tkey = tkeys[tk];
2878 result[tkey] = this[tkey];
2879 }
2880
2881 // hash is always overridden, no matter what.
2882 // even href="" will remove it.
2883 result.hash = relative.hash;
2884
2885 // if the relative url is empty, then there's nothing left to do here.
2886 if (relative.href === '') {
2887 result.href = result.format();
2888 return result;
2889 }
2890
2891 // hrefs like //foo/bar always cut to the protocol.
2892 if (relative.slashes && !relative.protocol) {
2893 // take everything except the protocol from relative
2894 var rkeys = Object.keys(relative);
2895 for (var rk = 0; rk < rkeys.length; rk++) {
2896 var rkey = rkeys[rk];
2897 if (rkey !== 'protocol')
2898 result[rkey] = relative[rkey];
2899 }
2900
2901 //urlParse appends trailing / to urls like http://www.example.com
2902 if (slashedProtocol[result.protocol] &&
2903 result.hostname && !result.pathname) {
2904 result.path = result.pathname = '/';
2905 }
2906
2907 result.href = result.format();
2908 return result;
2909 }
2910
2911 if (relative.protocol && relative.protocol !== result.protocol) {
2912 // if it's a known url protocol, then changing
2913 // the protocol does weird things
2914 // first, if it's not file:, then we MUST have a host,
2915 // and if there was a path
2916 // to begin with, then we MUST have a path.
2917 // if it is file:, then the host is dropped,
2918 // because that's known to be hostless.
2919 // anything else is assumed to be absolute.
2920 if (!slashedProtocol[relative.protocol]) {
2921 var keys = Object.keys(relative);
2922 for (var v = 0; v < keys.length; v++) {
2923 var k = keys[v];
2924 result[k] = relative[k];
2925 }
2926 result.href = result.format();
2927 return result;
2928 }
2929
2930 result.protocol = relative.protocol;
2931 if (!relative.host && !hostlessProtocol[relative.protocol]) {
2932 var relPath = (relative.pathname || '').split('/');
2933 while (relPath.length && !(relative.host = relPath.shift()));
2934 if (!relative.host) relative.host = '';
2935 if (!relative.hostname) relative.hostname = '';
2936 if (relPath[0] !== '') relPath.unshift('');
2937 if (relPath.length < 2) relPath.unshift('');
2938 result.pathname = relPath.join('/');
2939 } else {
2940 result.pathname = relative.pathname;
2941 }
2942 result.search = relative.search;
2943 result.query = relative.query;
2944 result.host = relative.host || '';
2945 result.auth = relative.auth;
2946 result.hostname = relative.hostname || relative.host;
2947 result.port = relative.port;
2948 // to support http.request
2949 if (result.pathname || result.search) {
2950 var p = result.pathname || '';
2951 var s = result.search || '';
2952 result.path = p + s;
2953 }
2954 result.slashes = result.slashes || relative.slashes;
2955 result.href = result.format();
2956 return result;
2957 }
2958
2959 var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
2960 isRelAbs = (
2961 relative.host ||
2962 relative.pathname && relative.pathname.charAt(0) === '/'
2963 ),
2964 mustEndAbs = (isRelAbs || isSourceAbs ||
2965 (result.host && relative.pathname)),
2966 removeAllDots = mustEndAbs,
2967 srcPath = result.pathname && result.pathname.split('/') || [],
2968 relPath = relative.pathname && relative.pathname.split('/') || [],
2969 psychotic = result.protocol && !slashedProtocol[result.protocol];
2970
2971 // if the url is a non-slashed url, then relative
2972 // links like ../.. should be able
2973 // to crawl up to the hostname, as well. This is strange.
2974 // result.protocol has already been set by now.
2975 // Later on, put the first path part into the host field.
2976 if (psychotic) {
2977 result.hostname = '';
2978 result.port = null;
2979 if (result.host) {
2980 if (srcPath[0] === '') srcPath[0] = result.host;
2981 else srcPath.unshift(result.host);
2982 }
2983 result.host = '';
2984 if (relative.protocol) {
2985 relative.hostname = null;
2986 relative.port = null;
2987 if (relative.host) {
2988 if (relPath[0] === '') relPath[0] = relative.host;
2989 else relPath.unshift(relative.host);
2990 }
2991 relative.host = null;
2992 }
2993 mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
2994 }
2995
2996 if (isRelAbs) {
2997 // it's absolute.
2998 result.host = (relative.host || relative.host === '') ?
2999 relative.host : result.host;
3000 result.hostname = (relative.hostname || relative.hostname === '') ?
3001 relative.hostname : result.hostname;
3002 result.search = relative.search;
3003 result.query = relative.query;
3004 srcPath = relPath;
3005 // fall through to the dot-handling below.
3006 } else if (relPath.length) {
3007 // it's relative
3008 // throw away the existing file, and take the new path instead.
3009 if (!srcPath) srcPath = [];
3010 srcPath.pop();
3011 srcPath = srcPath.concat(relPath);
3012 result.search = relative.search;
3013 result.query = relative.query;
3014 } else if (!util.isNullOrUndefined(relative.search)) {
3015 // just pull out the search.
3016 // like href='?foo'.
3017 // Put this after the other two cases because it simplifies the booleans
3018 if (psychotic) {
3019 result.hostname = result.host = srcPath.shift();
3020 //occationaly the auth can get stuck only in host
3021 //this especially happens in cases like
3022 //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
3023 var authInHost = result.host && result.host.indexOf('@') > 0 ?
3024 result.host.split('@') : false;
3025 if (authInHost) {
3026 result.auth = authInHost.shift();
3027 result.host = result.hostname = authInHost.shift();
3028 }
3029 }
3030 result.search = relative.search;
3031 result.query = relative.query;
3032 //to support http.request
3033 if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
3034 result.path = (result.pathname ? result.pathname : '') +
3035 (result.search ? result.search : '');
3036 }
3037 result.href = result.format();
3038 return result;
3039 }
3040
3041 if (!srcPath.length) {
3042 // no path at all. easy.
3043 // we've already handled the other stuff above.
3044 result.pathname = null;
3045 //to support http.request
3046 if (result.search) {
3047 result.path = '/' + result.search;
3048 } else {
3049 result.path = null;
3050 }
3051 result.href = result.format();
3052 return result;
3053 }
3054
3055 // if a url ENDs in . or .., then it must get a trailing slash.
3056 // however, if it ends in anything else non-slashy,
3057 // then it must NOT get a trailing slash.
3058 var last = srcPath.slice(-1)[0];
3059 var hasTrailingSlash = (
3060 (result.host || relative.host || srcPath.length > 1) &&
3061 (last === '.' || last === '..') || last === '');
3062
3063 // strip single dots, resolve double dots to parent dir
3064 // if the path tries to go above the root, `up` ends up > 0
3065 var up = 0;
3066 for (var i = srcPath.length; i >= 0; i--) {
3067 last = srcPath[i];
3068 if (last === '.') {
3069 srcPath.splice(i, 1);
3070 } else if (last === '..') {
3071 srcPath.splice(i, 1);
3072 up++;
3073 } else if (up) {
3074 srcPath.splice(i, 1);
3075 up--;
3076 }
3077 }
3078
3079 // if the path is allowed to go above the root, restore leading ..s
3080 if (!mustEndAbs && !removeAllDots) {
3081 for (; up--; up) {
3082 srcPath.unshift('..');
3083 }
3084 }
3085
3086 if (mustEndAbs && srcPath[0] !== '' &&
3087 (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
3088 srcPath.unshift('');
3089 }
3090
3091 if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
3092 srcPath.push('');
3093 }
3094
3095 var isAbsolute = srcPath[0] === '' ||
3096 (srcPath[0] && srcPath[0].charAt(0) === '/');
3097
3098 // put the host back
3099 if (psychotic) {
3100 result.hostname = result.host = isAbsolute ? '' :
3101 srcPath.length ? srcPath.shift() : '';
3102 //occationaly the auth can get stuck only in host
3103 //this especially happens in cases like
3104 //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
3105 var authInHost = result.host && result.host.indexOf('@') > 0 ?
3106 result.host.split('@') : false;
3107 if (authInHost) {
3108 result.auth = authInHost.shift();
3109 result.host = result.hostname = authInHost.shift();
3110 }
3111 }
3112
3113 mustEndAbs = mustEndAbs || (result.host && srcPath.length);
3114
3115 if (mustEndAbs && !isAbsolute) {
3116 srcPath.unshift('');
3117 }
3118
3119 if (!srcPath.length) {
3120 result.pathname = null;
3121 result.path = null;
3122 } else {
3123 result.pathname = srcPath.join('/');
3124 }
3125
3126 //to support request.http
3127 if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
3128 result.path = (result.pathname ? result.pathname : '') +
3129 (result.search ? result.search : '');
3130 }
3131 result.auth = relative.auth || result.auth;
3132 result.slashes = result.slashes || relative.slashes;
3133 result.href = result.format();
3134 return result;
3135};
3136
3137Url.prototype.parseHost = function() {
3138 var host = this.host;
3139 var port = portPattern.exec(host);
3140 if (port) {
3141 port = port[0];
3142 if (port !== ':') {
3143 this.port = port.substr(1);
3144 }
3145 host = host.substr(0, host.length - port.length);
3146 }
3147 if (host) this.hostname = host;
3148};
3149
3150
3151/***/ }),
3152/* 8 */
3153/***/ (function(module, exports) {
3154
3155// Copyright Joyent, Inc. and other Node contributors.
3156//
3157// Permission is hereby granted, free of charge, to any person obtaining a
3158// copy of this software and associated documentation files (the
3159// "Software"), to deal in the Software without restriction, including
3160// without limitation the rights to use, copy, modify, merge, publish,
3161// distribute, sublicense, and/or sell copies of the Software, and to permit
3162// persons to whom the Software is furnished to do so, subject to the
3163// following conditions:
3164//
3165// The above copyright notice and this permission notice shall be included
3166// in all copies or substantial portions of the Software.
3167//
3168// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
3169// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3170// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
3171// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
3172// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
3173// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
3174// USE OR OTHER DEALINGS IN THE SOFTWARE.
3175
3176function EventEmitter() {
3177 this._events = this._events || {};
3178 this._maxListeners = this._maxListeners || undefined;
3179}
3180module.exports = EventEmitter;
3181
3182// Backwards-compat with node 0.10.x
3183EventEmitter.EventEmitter = EventEmitter;
3184
3185EventEmitter.prototype._events = undefined;
3186EventEmitter.prototype._maxListeners = undefined;
3187
3188// By default EventEmitters will print a warning if more than 10 listeners are
3189// added to it. This is a useful default which helps finding memory leaks.
3190EventEmitter.defaultMaxListeners = 10;
3191
3192// Obviously not all Emitters should be limited to 10. This function allows
3193// that to be increased. Set to zero for unlimited.
3194EventEmitter.prototype.setMaxListeners = function(n) {
3195 if (!isNumber(n) || n < 0 || isNaN(n))
3196 throw TypeError('n must be a positive number');
3197 this._maxListeners = n;
3198 return this;
3199};
3200
3201EventEmitter.prototype.emit = function(type) {
3202 var er, handler, len, args, i, listeners;
3203
3204 if (!this._events)
3205 this._events = {};
3206
3207 // If there is no 'error' event listener then throw.
3208 if (type === 'error') {
3209 if (!this._events.error ||
3210 (isObject(this._events.error) && !this._events.error.length)) {
3211 er = arguments[1];
3212 if (er instanceof Error) {
3213 throw er; // Unhandled 'error' event
3214 } else {
3215 // At least give some kind of context to the user
3216 var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
3217 err.context = er;
3218 throw err;
3219 }
3220 }
3221 }
3222
3223 handler = this._events[type];
3224
3225 if (isUndefined(handler))
3226 return false;
3227
3228 if (isFunction(handler)) {
3229 switch (arguments.length) {
3230 // fast cases
3231 case 1:
3232 handler.call(this);
3233 break;
3234 case 2:
3235 handler.call(this, arguments[1]);
3236 break;
3237 case 3:
3238 handler.call(this, arguments[1], arguments[2]);
3239 break;
3240 // slower
3241 default:
3242 args = Array.prototype.slice.call(arguments, 1);
3243 handler.apply(this, args);
3244 }
3245 } else if (isObject(handler)) {
3246 args = Array.prototype.slice.call(arguments, 1);
3247 listeners = handler.slice();
3248 len = listeners.length;
3249 for (i = 0; i < len; i++)
3250 listeners[i].apply(this, args);
3251 }
3252
3253 return true;
3254};
3255
3256EventEmitter.prototype.addListener = function(type, listener) {
3257 var m;
3258
3259 if (!isFunction(listener))
3260 throw TypeError('listener must be a function');
3261
3262 if (!this._events)
3263 this._events = {};
3264
3265 // To avoid recursion in the case that type === "newListener"! Before
3266 // adding it to the listeners, first emit "newListener".
3267 if (this._events.newListener)
3268 this.emit('newListener', type,
3269 isFunction(listener.listener) ?
3270 listener.listener : listener);
3271
3272 if (!this._events[type])
3273 // Optimize the case of one listener. Don't need the extra array object.
3274 this._events[type] = listener;
3275 else if (isObject(this._events[type]))
3276 // If we've already got an array, just append.
3277 this._events[type].push(listener);
3278 else
3279 // Adding the second element, need to change to array.
3280 this._events[type] = [this._events[type], listener];
3281
3282 // Check for listener leak
3283 if (isObject(this._events[type]) && !this._events[type].warned) {
3284 if (!isUndefined(this._maxListeners)) {
3285 m = this._maxListeners;
3286 } else {
3287 m = EventEmitter.defaultMaxListeners;
3288 }
3289
3290 if (m && m > 0 && this._events[type].length > m) {
3291 this._events[type].warned = true;
3292 console.error('(node) warning: possible EventEmitter memory ' +
3293 'leak detected. %d listeners added. ' +
3294 'Use emitter.setMaxListeners() to increase limit.',
3295 this._events[type].length);
3296 if (typeof console.trace === 'function') {
3297 // not supported in IE 10
3298 console.trace();
3299 }
3300 }
3301 }
3302
3303 return this;
3304};
3305
3306EventEmitter.prototype.on = EventEmitter.prototype.addListener;
3307
3308EventEmitter.prototype.once = function(type, listener) {
3309 if (!isFunction(listener))
3310 throw TypeError('listener must be a function');
3311
3312 var fired = false;
3313
3314 function g() {
3315 this.removeListener(type, g);
3316
3317 if (!fired) {
3318 fired = true;
3319 listener.apply(this, arguments);
3320 }
3321 }
3322
3323 g.listener = listener;
3324 this.on(type, g);
3325
3326 return this;
3327};
3328
3329// emits a 'removeListener' event iff the listener was removed
3330EventEmitter.prototype.removeListener = function(type, listener) {
3331 var list, position, length, i;
3332
3333 if (!isFunction(listener))
3334 throw TypeError('listener must be a function');
3335
3336 if (!this._events || !this._events[type])
3337 return this;
3338
3339 list = this._events[type];
3340 length = list.length;
3341 position = -1;
3342
3343 if (list === listener ||
3344 (isFunction(list.listener) && list.listener === listener)) {
3345 delete this._events[type];
3346 if (this._events.removeListener)
3347 this.emit('removeListener', type, listener);
3348
3349 } else if (isObject(list)) {
3350 for (i = length; i-- > 0;) {
3351 if (list[i] === listener ||
3352 (list[i].listener && list[i].listener === listener)) {
3353 position = i;
3354 break;
3355 }
3356 }
3357
3358 if (position < 0)
3359 return this;
3360
3361 if (list.length === 1) {
3362 list.length = 0;
3363 delete this._events[type];
3364 } else {
3365 list.splice(position, 1);
3366 }
3367
3368 if (this._events.removeListener)
3369 this.emit('removeListener', type, listener);
3370 }
3371
3372 return this;
3373};
3374
3375EventEmitter.prototype.removeAllListeners = function(type) {
3376 var key, listeners;
3377
3378 if (!this._events)
3379 return this;
3380
3381 // not listening for removeListener, no need to emit
3382 if (!this._events.removeListener) {
3383 if (arguments.length === 0)
3384 this._events = {};
3385 else if (this._events[type])
3386 delete this._events[type];
3387 return this;
3388 }
3389
3390 // emit removeListener for all listeners on all events
3391 if (arguments.length === 0) {
3392 for (key in this._events) {
3393 if (key === 'removeListener') continue;
3394 this.removeAllListeners(key);
3395 }
3396 this.removeAllListeners('removeListener');
3397 this._events = {};
3398 return this;
3399 }
3400
3401 listeners = this._events[type];
3402
3403 if (isFunction(listeners)) {
3404 this.removeListener(type, listeners);
3405 } else if (listeners) {
3406 // LIFO order
3407 while (listeners.length)
3408 this.removeListener(type, listeners[listeners.length - 1]);
3409 }
3410 delete this._events[type];
3411
3412 return this;
3413};
3414
3415EventEmitter.prototype.listeners = function(type) {
3416 var ret;
3417 if (!this._events || !this._events[type])
3418 ret = [];
3419 else if (isFunction(this._events[type]))
3420 ret = [this._events[type]];
3421 else
3422 ret = this._events[type].slice();
3423 return ret;
3424};
3425
3426EventEmitter.prototype.listenerCount = function(type) {
3427 if (this._events) {
3428 var evlistener = this._events[type];
3429
3430 if (isFunction(evlistener))
3431 return 1;
3432 else if (evlistener)
3433 return evlistener.length;
3434 }
3435 return 0;
3436};
3437
3438EventEmitter.listenerCount = function(emitter, type) {
3439 return emitter.listenerCount(type);
3440};
3441
3442function isFunction(arg) {
3443 return typeof arg === 'function';
3444}
3445
3446function isNumber(arg) {
3447 return typeof arg === 'number';
3448}
3449
3450function isObject(arg) {
3451 return typeof arg === 'object' && arg !== null;
3452}
3453
3454function isUndefined(arg) {
3455 return arg === void 0;
3456}
3457
3458
3459/***/ }),
3460/* 9 */
3461/***/ (function(module, exports, __webpack_require__) {
3462
3463/* eslint-disable node/no-deprecated-api */
3464var buffer = __webpack_require__(2)
3465var Buffer = buffer.Buffer
3466
3467// alternative to using Object.keys for old browsers
3468function copyProps (src, dst) {
3469 for (var key in src) {
3470 dst[key] = src[key]
3471 }
3472}
3473if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
3474 module.exports = buffer
3475} else {
3476 // Copy properties from require('buffer')
3477 copyProps(buffer, exports)
3478 exports.Buffer = SafeBuffer
3479}
3480
3481function SafeBuffer (arg, encodingOrOffset, length) {
3482 return Buffer(arg, encodingOrOffset, length)
3483}
3484
3485// Copy static methods from Buffer
3486copyProps(Buffer, SafeBuffer)
3487
3488SafeBuffer.from = function (arg, encodingOrOffset, length) {
3489 if (typeof arg === 'number') {
3490 throw new TypeError('Argument must not be a number')
3491 }
3492 return Buffer(arg, encodingOrOffset, length)
3493}
3494
3495SafeBuffer.alloc = function (size, fill, encoding) {
3496 if (typeof size !== 'number') {
3497 throw new TypeError('Argument must be a number')
3498 }
3499 var buf = Buffer(size)
3500 if (fill !== undefined) {
3501 if (typeof encoding === 'string') {
3502 buf.fill(fill, encoding)
3503 } else {
3504 buf.fill(fill)
3505 }
3506 } else {
3507 buf.fill(0)
3508 }
3509 return buf
3510}
3511
3512SafeBuffer.allocUnsafe = function (size) {
3513 if (typeof size !== 'number') {
3514 throw new TypeError('Argument must be a number')
3515 }
3516 return Buffer(size)
3517}
3518
3519SafeBuffer.allocUnsafeSlow = function (size) {
3520 if (typeof size !== 'number') {
3521 throw new TypeError('Argument must be a number')
3522 }
3523 return buffer.SlowBuffer(size)
3524}
3525
3526
3527/***/ }),
3528/* 10 */
3529/***/ (function(module, exports, __webpack_require__) {
3530
3531/* WEBPACK VAR INJECTION */(function(global) {var ClientRequest = __webpack_require__(37)
3532var response = __webpack_require__(13)
3533var extend = __webpack_require__(48)
3534var statusCodes = __webpack_require__(49)
3535var url = __webpack_require__(7)
3536
3537var http = exports
3538
3539http.request = function (opts, cb) {
3540 if (typeof opts === 'string')
3541 opts = url.parse(opts)
3542 else
3543 opts = extend(opts)
3544
3545 // Normally, the page is loaded from http or https, so not specifying a protocol
3546 // will result in a (valid) protocol-relative url. However, this won't work if
3547 // the protocol is something else, like 'file:'
3548 var defaultProtocol = global.location.protocol.search(/^https?:$/) === -1 ? 'http:' : ''
3549
3550 var protocol = opts.protocol || defaultProtocol
3551 var host = opts.hostname || opts.host
3552 var port = opts.port
3553 var path = opts.path || '/'
3554
3555 // Necessary for IPv6 addresses
3556 if (host && host.indexOf(':') !== -1)
3557 host = '[' + host + ']'
3558
3559 // This may be a relative url. The browser should always be able to interpret it correctly.
3560 opts.url = (host ? (protocol + '//' + host) : '') + (port ? ':' + port : '') + path
3561 opts.method = (opts.method || 'GET').toUpperCase()
3562 opts.headers = opts.headers || {}
3563
3564 // Also valid opts.auth, opts.mode
3565
3566 var req = new ClientRequest(opts)
3567 if (cb)
3568 req.on('response', cb)
3569 return req
3570}
3571
3572http.get = function get (opts, cb) {
3573 var req = http.request(opts, cb)
3574 req.end()
3575 return req
3576}
3577
3578http.ClientRequest = ClientRequest
3579http.IncomingMessage = response.IncomingMessage
3580
3581http.Agent = function () {}
3582http.Agent.defaultMaxSockets = 4
3583
3584http.globalAgent = new http.Agent()
3585
3586http.STATUS_CODES = statusCodes
3587
3588http.METHODS = [
3589 'CHECKOUT',
3590 'CONNECT',
3591 'COPY',
3592 'DELETE',
3593 'GET',
3594 'HEAD',
3595 'LOCK',
3596 'M-SEARCH',
3597 'MERGE',
3598 'MKACTIVITY',
3599 'MKCOL',
3600 'MOVE',
3601 'NOTIFY',
3602 'OPTIONS',
3603 'PATCH',
3604 'POST',
3605 'PROPFIND',
3606 'PROPPATCH',
3607 'PURGE',
3608 'PUT',
3609 'REPORT',
3610 'SEARCH',
3611 'SUBSCRIBE',
3612 'TRACE',
3613 'UNLOCK',
3614 'UNSUBSCRIBE'
3615]
3616/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
3617
3618/***/ }),
3619/* 11 */
3620/***/ (function(module, exports, __webpack_require__) {
3621
3622/* WEBPACK VAR INJECTION */(function(global) {exports.fetch = isFunction(global.fetch) && isFunction(global.ReadableStream)
3623
3624exports.writableStream = isFunction(global.WritableStream)
3625
3626exports.abortController = isFunction(global.AbortController)
3627
3628exports.blobConstructor = false
3629try {
3630 new Blob([new ArrayBuffer(1)])
3631 exports.blobConstructor = true
3632} catch (e) {}
3633
3634// The xhr request to example.com may violate some restrictive CSP configurations,
3635// so if we're running in a browser that supports `fetch`, avoid calling getXHR()
3636// and assume support for certain features below.
3637var xhr
3638function getXHR () {
3639 // Cache the xhr value
3640 if (xhr !== undefined) return xhr
3641
3642 if (global.XMLHttpRequest) {
3643 xhr = new global.XMLHttpRequest()
3644 // If XDomainRequest is available (ie only, where xhr might not work
3645 // cross domain), use the page location. Otherwise use example.com
3646 // Note: this doesn't actually make an http request.
3647 try {
3648 xhr.open('GET', global.XDomainRequest ? '/' : 'https://example.com')
3649 } catch(e) {
3650 xhr = null
3651 }
3652 } else {
3653 // Service workers don't have XHR
3654 xhr = null
3655 }
3656 return xhr
3657}
3658
3659function checkTypeSupport (type) {
3660 var xhr = getXHR()
3661 if (!xhr) return false
3662 try {
3663 xhr.responseType = type
3664 return xhr.responseType === type
3665 } catch (e) {}
3666 return false
3667}
3668
3669// For some strange reason, Safari 7.0 reports typeof global.ArrayBuffer === 'object'.
3670// Safari 7.1 appears to have fixed this bug.
3671var haveArrayBuffer = typeof global.ArrayBuffer !== 'undefined'
3672var haveSlice = haveArrayBuffer && isFunction(global.ArrayBuffer.prototype.slice)
3673
3674// If fetch is supported, then arraybuffer will be supported too. Skip calling
3675// checkTypeSupport(), since that calls getXHR().
3676exports.arraybuffer = exports.fetch || (haveArrayBuffer && checkTypeSupport('arraybuffer'))
3677
3678// These next two tests unavoidably show warnings in Chrome. Since fetch will always
3679// be used if it's available, just return false for these to avoid the warnings.
3680exports.msstream = !exports.fetch && haveSlice && checkTypeSupport('ms-stream')
3681exports.mozchunkedarraybuffer = !exports.fetch && haveArrayBuffer &&
3682 checkTypeSupport('moz-chunked-arraybuffer')
3683
3684// If fetch is supported, then overrideMimeType will be supported too. Skip calling
3685// getXHR().
3686exports.overrideMimeType = exports.fetch || (getXHR() ? isFunction(getXHR().overrideMimeType) : false)
3687
3688exports.vbArray = isFunction(global.VBArray)
3689
3690function isFunction (value) {
3691 return typeof value === 'function'
3692}
3693
3694xhr = null // Help gc
3695
3696/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
3697
3698/***/ }),
3699/* 12 */
3700/***/ (function(module, exports) {
3701
3702if (typeof Object.create === 'function') {
3703 // implementation from standard node.js 'util' module
3704 module.exports = function inherits(ctor, superCtor) {
3705 ctor.super_ = superCtor
3706 ctor.prototype = Object.create(superCtor.prototype, {
3707 constructor: {
3708 value: ctor,
3709 enumerable: false,
3710 writable: true,
3711 configurable: true
3712 }
3713 });
3714 };
3715} else {
3716 // old school shim for old browsers
3717 module.exports = function inherits(ctor, superCtor) {
3718 ctor.super_ = superCtor
3719 var TempCtor = function () {}
3720 TempCtor.prototype = superCtor.prototype
3721 ctor.prototype = new TempCtor()
3722 ctor.prototype.constructor = ctor
3723 }
3724}
3725
3726
3727/***/ }),
3728/* 13 */
3729/***/ (function(module, exports, __webpack_require__) {
3730
3731/* WEBPACK VAR INJECTION */(function(process, Buffer, global) {var capability = __webpack_require__(11)
3732var inherits = __webpack_require__(12)
3733var stream = __webpack_require__(14)
3734
3735var rStates = exports.readyStates = {
3736 UNSENT: 0,
3737 OPENED: 1,
3738 HEADERS_RECEIVED: 2,
3739 LOADING: 3,
3740 DONE: 4
3741}
3742
3743var IncomingMessage = exports.IncomingMessage = function (xhr, response, mode, fetchTimer) {
3744 var self = this
3745 stream.Readable.call(self)
3746
3747 self._mode = mode
3748 self.headers = {}
3749 self.rawHeaders = []
3750 self.trailers = {}
3751 self.rawTrailers = []
3752
3753 // Fake the 'close' event, but only once 'end' fires
3754 self.on('end', function () {
3755 // The nextTick is necessary to prevent the 'request' module from causing an infinite loop
3756 process.nextTick(function () {
3757 self.emit('close')
3758 })
3759 })
3760
3761 if (mode === 'fetch') {
3762 self._fetchResponse = response
3763
3764 self.url = response.url
3765 self.statusCode = response.status
3766 self.statusMessage = response.statusText
3767
3768 response.headers.forEach(function (header, key){
3769 self.headers[key.toLowerCase()] = header
3770 self.rawHeaders.push(key, header)
3771 })
3772
3773 if (capability.writableStream) {
3774 var writable = new WritableStream({
3775 write: function (chunk) {
3776 return new Promise(function (resolve, reject) {
3777 if (self._destroyed) {
3778 reject()
3779 } else if(self.push(new Buffer(chunk))) {
3780 resolve()
3781 } else {
3782 self._resumeFetch = resolve
3783 }
3784 })
3785 },
3786 close: function () {
3787 global.clearTimeout(fetchTimer)
3788 if (!self._destroyed)
3789 self.push(null)
3790 },
3791 abort: function (err) {
3792 if (!self._destroyed)
3793 self.emit('error', err)
3794 }
3795 })
3796
3797 try {
3798 response.body.pipeTo(writable).catch(function (err) {
3799 global.clearTimeout(fetchTimer)
3800 if (!self._destroyed)
3801 self.emit('error', err)
3802 })
3803 return
3804 } catch (e) {} // pipeTo method isn't defined. Can't find a better way to feature test this
3805 }
3806 // fallback for when writableStream or pipeTo aren't available
3807 var reader = response.body.getReader()
3808 function read () {
3809 reader.read().then(function (result) {
3810 if (self._destroyed)
3811 return
3812 if (result.done) {
3813 global.clearTimeout(fetchTimer)
3814 self.push(null)
3815 return
3816 }
3817 self.push(new Buffer(result.value))
3818 read()
3819 }).catch(function (err) {
3820 global.clearTimeout(fetchTimer)
3821 if (!self._destroyed)
3822 self.emit('error', err)
3823 })
3824 }
3825 read()
3826 } else {
3827 self._xhr = xhr
3828 self._pos = 0
3829
3830 self.url = xhr.responseURL
3831 self.statusCode = xhr.status
3832 self.statusMessage = xhr.statusText
3833 var headers = xhr.getAllResponseHeaders().split(/\r?\n/)
3834 headers.forEach(function (header) {
3835 var matches = header.match(/^([^:]+):\s*(.*)/)
3836 if (matches) {
3837 var key = matches[1].toLowerCase()
3838 if (key === 'set-cookie') {
3839 if (self.headers[key] === undefined) {
3840 self.headers[key] = []
3841 }
3842 self.headers[key].push(matches[2])
3843 } else if (self.headers[key] !== undefined) {
3844 self.headers[key] += ', ' + matches[2]
3845 } else {
3846 self.headers[key] = matches[2]
3847 }
3848 self.rawHeaders.push(matches[1], matches[2])
3849 }
3850 })
3851
3852 self._charset = 'x-user-defined'
3853 if (!capability.overrideMimeType) {
3854 var mimeType = self.rawHeaders['mime-type']
3855 if (mimeType) {
3856 var charsetMatch = mimeType.match(/;\s*charset=([^;])(;|$)/)
3857 if (charsetMatch) {
3858 self._charset = charsetMatch[1].toLowerCase()
3859 }
3860 }
3861 if (!self._charset)
3862 self._charset = 'utf-8' // best guess
3863 }
3864 }
3865}
3866
3867inherits(IncomingMessage, stream.Readable)
3868
3869IncomingMessage.prototype._read = function () {
3870 var self = this
3871
3872 var resolve = self._resumeFetch
3873 if (resolve) {
3874 self._resumeFetch = null
3875 resolve()
3876 }
3877}
3878
3879IncomingMessage.prototype._onXHRProgress = function () {
3880 var self = this
3881
3882 var xhr = self._xhr
3883
3884 var response = null
3885 switch (self._mode) {
3886 case 'text:vbarray': // For IE9
3887 if (xhr.readyState !== rStates.DONE)
3888 break
3889 try {
3890 // This fails in IE8
3891 response = new global.VBArray(xhr.responseBody).toArray()
3892 } catch (e) {}
3893 if (response !== null) {
3894 self.push(new Buffer(response))
3895 break
3896 }
3897 // Falls through in IE8
3898 case 'text':
3899 try { // This will fail when readyState = 3 in IE9. Switch mode and wait for readyState = 4
3900 response = xhr.responseText
3901 } catch (e) {
3902 self._mode = 'text:vbarray'
3903 break
3904 }
3905 if (response.length > self._pos) {
3906 var newData = response.substr(self._pos)
3907 if (self._charset === 'x-user-defined') {
3908 var buffer = new Buffer(newData.length)
3909 for (var i = 0; i < newData.length; i++)
3910 buffer[i] = newData.charCodeAt(i) & 0xff
3911
3912 self.push(buffer)
3913 } else {
3914 self.push(newData, self._charset)
3915 }
3916 self._pos = response.length
3917 }
3918 break
3919 case 'arraybuffer':
3920 if (xhr.readyState !== rStates.DONE || !xhr.response)
3921 break
3922 response = xhr.response
3923 self.push(new Buffer(new Uint8Array(response)))
3924 break
3925 case 'moz-chunked-arraybuffer': // take whole
3926 response = xhr.response
3927 if (xhr.readyState !== rStates.LOADING || !response)
3928 break
3929 self.push(new Buffer(new Uint8Array(response)))
3930 break
3931 case 'ms-stream':
3932 response = xhr.response
3933 if (xhr.readyState !== rStates.LOADING)
3934 break
3935 var reader = new global.MSStreamReader()
3936 reader.onprogress = function () {
3937 if (reader.result.byteLength > self._pos) {
3938 self.push(new Buffer(new Uint8Array(reader.result.slice(self._pos))))
3939 self._pos = reader.result.byteLength
3940 }
3941 }
3942 reader.onload = function () {
3943 self.push(null)
3944 }
3945 // reader.onerror = ??? // TODO: this
3946 reader.readAsArrayBuffer(response)
3947 break
3948 }
3949
3950 // The ms-stream case handles end separately in reader.onload()
3951 if (self._xhr.readyState === rStates.DONE && self._mode !== 'ms-stream') {
3952 self.push(null)
3953 }
3954}
3955
3956/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1), __webpack_require__(2).Buffer, __webpack_require__(0)))
3957
3958/***/ }),
3959/* 14 */
3960/***/ (function(module, exports, __webpack_require__) {
3961
3962exports = module.exports = __webpack_require__(15);
3963exports.Stream = exports;
3964exports.Readable = exports;
3965exports.Writable = __webpack_require__(18);
3966exports.Duplex = __webpack_require__(3);
3967exports.Transform = __webpack_require__(20);
3968exports.PassThrough = __webpack_require__(46);
3969
3970
3971/***/ }),
3972/* 15 */
3973/***/ (function(module, exports, __webpack_require__) {
3974
3975"use strict";
3976/* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors.
3977//
3978// Permission is hereby granted, free of charge, to any person obtaining a
3979// copy of this software and associated documentation files (the
3980// "Software"), to deal in the Software without restriction, including
3981// without limitation the rights to use, copy, modify, merge, publish,
3982// distribute, sublicense, and/or sell copies of the Software, and to permit
3983// persons to whom the Software is furnished to do so, subject to the
3984// following conditions:
3985//
3986// The above copyright notice and this permission notice shall be included
3987// in all copies or substantial portions of the Software.
3988//
3989// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
3990// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3991// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
3992// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
3993// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
3994// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
3995// USE OR OTHER DEALINGS IN THE SOFTWARE.
3996
3997
3998
3999/*<replacement>*/
4000
4001var pna = __webpack_require__(6);
4002/*</replacement>*/
4003
4004module.exports = Readable;
4005
4006/*<replacement>*/
4007var isArray = __webpack_require__(38);
4008/*</replacement>*/
4009
4010/*<replacement>*/
4011var Duplex;
4012/*</replacement>*/
4013
4014Readable.ReadableState = ReadableState;
4015
4016/*<replacement>*/
4017var EE = __webpack_require__(8).EventEmitter;
4018
4019var EElistenerCount = function (emitter, type) {
4020 return emitter.listeners(type).length;
4021};
4022/*</replacement>*/
4023
4024/*<replacement>*/
4025var Stream = __webpack_require__(16);
4026/*</replacement>*/
4027
4028/*<replacement>*/
4029
4030var Buffer = __webpack_require__(9).Buffer;
4031var OurUint8Array = global.Uint8Array || function () {};
4032function _uint8ArrayToBuffer(chunk) {
4033 return Buffer.from(chunk);
4034}
4035function _isUint8Array(obj) {
4036 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
4037}
4038
4039/*</replacement>*/
4040
4041/*<replacement>*/
4042var util = __webpack_require__(4);
4043util.inherits = __webpack_require__(5);
4044/*</replacement>*/
4045
4046/*<replacement>*/
4047var debugUtil = __webpack_require__(39);
4048var debug = void 0;
4049if (debugUtil && debugUtil.debuglog) {
4050 debug = debugUtil.debuglog('stream');
4051} else {
4052 debug = function () {};
4053}
4054/*</replacement>*/
4055
4056var BufferList = __webpack_require__(40);
4057var destroyImpl = __webpack_require__(17);
4058var StringDecoder;
4059
4060util.inherits(Readable, Stream);
4061
4062var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
4063
4064function prependListener(emitter, event, fn) {
4065 // Sadly this is not cacheable as some libraries bundle their own
4066 // event emitter implementation with them.
4067 if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
4068
4069 // This is a hack to make sure that our error handler is attached before any
4070 // userland ones. NEVER DO THIS. This is here only because this code needs
4071 // to continue to work with older versions of Node.js that do not include
4072 // the prependListener() method. The goal is to eventually remove this hack.
4073 if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
4074}
4075
4076function ReadableState(options, stream) {
4077 Duplex = Duplex || __webpack_require__(3);
4078
4079 options = options || {};
4080
4081 // Duplex streams are both readable and writable, but share
4082 // the same options object.
4083 // However, some cases require setting options to different
4084 // values for the readable and the writable sides of the duplex stream.
4085 // These options can be provided separately as readableXXX and writableXXX.
4086 var isDuplex = stream instanceof Duplex;
4087
4088 // object stream flag. Used to make read(n) ignore n and to
4089 // make all the buffer merging and length checks go away
4090 this.objectMode = !!options.objectMode;
4091
4092 if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
4093
4094 // the point at which it stops calling _read() to fill the buffer
4095 // Note: 0 is a valid value, means "don't call _read preemptively ever"
4096 var hwm = options.highWaterMark;
4097 var readableHwm = options.readableHighWaterMark;
4098 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
4099
4100 if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
4101
4102 // cast to ints.
4103 this.highWaterMark = Math.floor(this.highWaterMark);
4104
4105 // A linked list is used to store data chunks instead of an array because the
4106 // linked list can remove elements from the beginning faster than
4107 // array.shift()
4108 this.buffer = new BufferList();
4109 this.length = 0;
4110 this.pipes = null;
4111 this.pipesCount = 0;
4112 this.flowing = null;
4113 this.ended = false;
4114 this.endEmitted = false;
4115 this.reading = false;
4116
4117 // a flag to be able to tell if the event 'readable'/'data' is emitted
4118 // immediately, or on a later tick. We set this to true at first, because
4119 // any actions that shouldn't happen until "later" should generally also
4120 // not happen before the first read call.
4121 this.sync = true;
4122
4123 // whenever we return null, then we set a flag to say
4124 // that we're awaiting a 'readable' event emission.
4125 this.needReadable = false;
4126 this.emittedReadable = false;
4127 this.readableListening = false;
4128 this.resumeScheduled = false;
4129
4130 // has it been destroyed
4131 this.destroyed = false;
4132
4133 // Crypto is kind of old and crusty. Historically, its default string
4134 // encoding is 'binary' so we have to make this configurable.
4135 // Everything else in the universe uses 'utf8', though.
4136 this.defaultEncoding = options.defaultEncoding || 'utf8';
4137
4138 // the number of writers that are awaiting a drain event in .pipe()s
4139 this.awaitDrain = 0;
4140
4141 // if true, a maybeReadMore has been scheduled
4142 this.readingMore = false;
4143
4144 this.decoder = null;
4145 this.encoding = null;
4146 if (options.encoding) {
4147 if (!StringDecoder) StringDecoder = __webpack_require__(19).StringDecoder;
4148 this.decoder = new StringDecoder(options.encoding);
4149 this.encoding = options.encoding;
4150 }
4151}
4152
4153function Readable(options) {
4154 Duplex = Duplex || __webpack_require__(3);
4155
4156 if (!(this instanceof Readable)) return new Readable(options);
4157
4158 this._readableState = new ReadableState(options, this);
4159
4160 // legacy
4161 this.readable = true;
4162
4163 if (options) {
4164 if (typeof options.read === 'function') this._read = options.read;
4165
4166 if (typeof options.destroy === 'function') this._destroy = options.destroy;
4167 }
4168
4169 Stream.call(this);
4170}
4171
4172Object.defineProperty(Readable.prototype, 'destroyed', {
4173 get: function () {
4174 if (this._readableState === undefined) {
4175 return false;
4176 }
4177 return this._readableState.destroyed;
4178 },
4179 set: function (value) {
4180 // we ignore the value if the stream
4181 // has not been initialized yet
4182 if (!this._readableState) {
4183 return;
4184 }
4185
4186 // backward compatibility, the user is explicitly
4187 // managing destroyed
4188 this._readableState.destroyed = value;
4189 }
4190});
4191
4192Readable.prototype.destroy = destroyImpl.destroy;
4193Readable.prototype._undestroy = destroyImpl.undestroy;
4194Readable.prototype._destroy = function (err, cb) {
4195 this.push(null);
4196 cb(err);
4197};
4198
4199// Manually shove something into the read() buffer.
4200// This returns true if the highWaterMark has not been hit yet,
4201// similar to how Writable.write() returns true if you should
4202// write() some more.
4203Readable.prototype.push = function (chunk, encoding) {
4204 var state = this._readableState;
4205 var skipChunkCheck;
4206
4207 if (!state.objectMode) {
4208 if (typeof chunk === 'string') {
4209 encoding = encoding || state.defaultEncoding;
4210 if (encoding !== state.encoding) {
4211 chunk = Buffer.from(chunk, encoding);
4212 encoding = '';
4213 }
4214 skipChunkCheck = true;
4215 }
4216 } else {
4217 skipChunkCheck = true;
4218 }
4219
4220 return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
4221};
4222
4223// Unshift should *always* be something directly out of read()
4224Readable.prototype.unshift = function (chunk) {
4225 return readableAddChunk(this, chunk, null, true, false);
4226};
4227
4228function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
4229 var state = stream._readableState;
4230 if (chunk === null) {
4231 state.reading = false;
4232 onEofChunk(stream, state);
4233 } else {
4234 var er;
4235 if (!skipChunkCheck) er = chunkInvalid(state, chunk);
4236 if (er) {
4237 stream.emit('error', er);
4238 } else if (state.objectMode || chunk && chunk.length > 0) {
4239 if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
4240 chunk = _uint8ArrayToBuffer(chunk);
4241 }
4242
4243 if (addToFront) {
4244 if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
4245 } else if (state.ended) {
4246 stream.emit('error', new Error('stream.push() after EOF'));
4247 } else {
4248 state.reading = false;
4249 if (state.decoder && !encoding) {
4250 chunk = state.decoder.write(chunk);
4251 if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
4252 } else {
4253 addChunk(stream, state, chunk, false);
4254 }
4255 }
4256 } else if (!addToFront) {
4257 state.reading = false;
4258 }
4259 }
4260
4261 return needMoreData(state);
4262}
4263
4264function addChunk(stream, state, chunk, addToFront) {
4265 if (state.flowing && state.length === 0 && !state.sync) {
4266 stream.emit('data', chunk);
4267 stream.read(0);
4268 } else {
4269 // update the buffer info.
4270 state.length += state.objectMode ? 1 : chunk.length;
4271 if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
4272
4273 if (state.needReadable) emitReadable(stream);
4274 }
4275 maybeReadMore(stream, state);
4276}
4277
4278function chunkInvalid(state, chunk) {
4279 var er;
4280 if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
4281 er = new TypeError('Invalid non-string/buffer chunk');
4282 }
4283 return er;
4284}
4285
4286// if it's past the high water mark, we can push in some more.
4287// Also, if we have no data yet, we can stand some
4288// more bytes. This is to work around cases where hwm=0,
4289// such as the repl. Also, if the push() triggered a
4290// readable event, and the user called read(largeNumber) such that
4291// needReadable was set, then we ought to push more, so that another
4292// 'readable' event will be triggered.
4293function needMoreData(state) {
4294 return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
4295}
4296
4297Readable.prototype.isPaused = function () {
4298 return this._readableState.flowing === false;
4299};
4300
4301// backwards compatibility.
4302Readable.prototype.setEncoding = function (enc) {
4303 if (!StringDecoder) StringDecoder = __webpack_require__(19).StringDecoder;
4304 this._readableState.decoder = new StringDecoder(enc);
4305 this._readableState.encoding = enc;
4306 return this;
4307};
4308
4309// Don't raise the hwm > 8MB
4310var MAX_HWM = 0x800000;
4311function computeNewHighWaterMark(n) {
4312 if (n >= MAX_HWM) {
4313 n = MAX_HWM;
4314 } else {
4315 // Get the next highest power of 2 to prevent increasing hwm excessively in
4316 // tiny amounts
4317 n--;
4318 n |= n >>> 1;
4319 n |= n >>> 2;
4320 n |= n >>> 4;
4321 n |= n >>> 8;
4322 n |= n >>> 16;
4323 n++;
4324 }
4325 return n;
4326}
4327
4328// This function is designed to be inlinable, so please take care when making
4329// changes to the function body.
4330function howMuchToRead(n, state) {
4331 if (n <= 0 || state.length === 0 && state.ended) return 0;
4332 if (state.objectMode) return 1;
4333 if (n !== n) {
4334 // Only flow one buffer at a time
4335 if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
4336 }
4337 // If we're asking for more than the current hwm, then raise the hwm.
4338 if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
4339 if (n <= state.length) return n;
4340 // Don't have enough
4341 if (!state.ended) {
4342 state.needReadable = true;
4343 return 0;
4344 }
4345 return state.length;
4346}
4347
4348// you can override either this method, or the async _read(n) below.
4349Readable.prototype.read = function (n) {
4350 debug('read', n);
4351 n = parseInt(n, 10);
4352 var state = this._readableState;
4353 var nOrig = n;
4354
4355 if (n !== 0) state.emittedReadable = false;
4356
4357 // if we're doing read(0) to trigger a readable event, but we
4358 // already have a bunch of data in the buffer, then just trigger
4359 // the 'readable' event and move on.
4360 if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
4361 debug('read: emitReadable', state.length, state.ended);
4362 if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
4363 return null;
4364 }
4365
4366 n = howMuchToRead(n, state);
4367
4368 // if we've ended, and we're now clear, then finish it up.
4369 if (n === 0 && state.ended) {
4370 if (state.length === 0) endReadable(this);
4371 return null;
4372 }
4373
4374 // All the actual chunk generation logic needs to be
4375 // *below* the call to _read. The reason is that in certain
4376 // synthetic stream cases, such as passthrough streams, _read
4377 // may be a completely synchronous operation which may change
4378 // the state of the read buffer, providing enough data when
4379 // before there was *not* enough.
4380 //
4381 // So, the steps are:
4382 // 1. Figure out what the state of things will be after we do
4383 // a read from the buffer.
4384 //
4385 // 2. If that resulting state will trigger a _read, then call _read.
4386 // Note that this may be asynchronous, or synchronous. Yes, it is
4387 // deeply ugly to write APIs this way, but that still doesn't mean
4388 // that the Readable class should behave improperly, as streams are
4389 // designed to be sync/async agnostic.
4390 // Take note if the _read call is sync or async (ie, if the read call
4391 // has returned yet), so that we know whether or not it's safe to emit
4392 // 'readable' etc.
4393 //
4394 // 3. Actually pull the requested chunks out of the buffer and return.
4395
4396 // if we need a readable event, then we need to do some reading.
4397 var doRead = state.needReadable;
4398 debug('need readable', doRead);
4399
4400 // if we currently have less than the highWaterMark, then also read some
4401 if (state.length === 0 || state.length - n < state.highWaterMark) {
4402 doRead = true;
4403 debug('length less than watermark', doRead);
4404 }
4405
4406 // however, if we've ended, then there's no point, and if we're already
4407 // reading, then it's unnecessary.
4408 if (state.ended || state.reading) {
4409 doRead = false;
4410 debug('reading or ended', doRead);
4411 } else if (doRead) {
4412 debug('do read');
4413 state.reading = true;
4414 state.sync = true;
4415 // if the length is currently zero, then we *need* a readable event.
4416 if (state.length === 0) state.needReadable = true;
4417 // call internal read method
4418 this._read(state.highWaterMark);
4419 state.sync = false;
4420 // If _read pushed data synchronously, then `reading` will be false,
4421 // and we need to re-evaluate how much data we can return to the user.
4422 if (!state.reading) n = howMuchToRead(nOrig, state);
4423 }
4424
4425 var ret;
4426 if (n > 0) ret = fromList(n, state);else ret = null;
4427
4428 if (ret === null) {
4429 state.needReadable = true;
4430 n = 0;
4431 } else {
4432 state.length -= n;
4433 }
4434
4435 if (state.length === 0) {
4436 // If we have nothing in the buffer, then we want to know
4437 // as soon as we *do* get something into the buffer.
4438 if (!state.ended) state.needReadable = true;
4439
4440 // If we tried to read() past the EOF, then emit end on the next tick.
4441 if (nOrig !== n && state.ended) endReadable(this);
4442 }
4443
4444 if (ret !== null) this.emit('data', ret);
4445
4446 return ret;
4447};
4448
4449function onEofChunk(stream, state) {
4450 if (state.ended) return;
4451 if (state.decoder) {
4452 var chunk = state.decoder.end();
4453 if (chunk && chunk.length) {
4454 state.buffer.push(chunk);
4455 state.length += state.objectMode ? 1 : chunk.length;
4456 }
4457 }
4458 state.ended = true;
4459
4460 // emit 'readable' now to make sure it gets picked up.
4461 emitReadable(stream);
4462}
4463
4464// Don't emit readable right away in sync mode, because this can trigger
4465// another read() call => stack overflow. This way, it might trigger
4466// a nextTick recursion warning, but that's not so bad.
4467function emitReadable(stream) {
4468 var state = stream._readableState;
4469 state.needReadable = false;
4470 if (!state.emittedReadable) {
4471 debug('emitReadable', state.flowing);
4472 state.emittedReadable = true;
4473 if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
4474 }
4475}
4476
4477function emitReadable_(stream) {
4478 debug('emit readable');
4479 stream.emit('readable');
4480 flow(stream);
4481}
4482
4483// at this point, the user has presumably seen the 'readable' event,
4484// and called read() to consume some data. that may have triggered
4485// in turn another _read(n) call, in which case reading = true if
4486// it's in progress.
4487// However, if we're not ended, or reading, and the length < hwm,
4488// then go ahead and try to read some more preemptively.
4489function maybeReadMore(stream, state) {
4490 if (!state.readingMore) {
4491 state.readingMore = true;
4492 pna.nextTick(maybeReadMore_, stream, state);
4493 }
4494}
4495
4496function maybeReadMore_(stream, state) {
4497 var len = state.length;
4498 while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
4499 debug('maybeReadMore read 0');
4500 stream.read(0);
4501 if (len === state.length)
4502 // didn't get any data, stop spinning.
4503 break;else len = state.length;
4504 }
4505 state.readingMore = false;
4506}
4507
4508// abstract method. to be overridden in specific implementation classes.
4509// call cb(er, data) where data is <= n in length.
4510// for virtual (non-string, non-buffer) streams, "length" is somewhat
4511// arbitrary, and perhaps not very meaningful.
4512Readable.prototype._read = function (n) {
4513 this.emit('error', new Error('_read() is not implemented'));
4514};
4515
4516Readable.prototype.pipe = function (dest, pipeOpts) {
4517 var src = this;
4518 var state = this._readableState;
4519
4520 switch (state.pipesCount) {
4521 case 0:
4522 state.pipes = dest;
4523 break;
4524 case 1:
4525 state.pipes = [state.pipes, dest];
4526 break;
4527 default:
4528 state.pipes.push(dest);
4529 break;
4530 }
4531 state.pipesCount += 1;
4532 debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
4533
4534 var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
4535
4536 var endFn = doEnd ? onend : unpipe;
4537 if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
4538
4539 dest.on('unpipe', onunpipe);
4540 function onunpipe(readable, unpipeInfo) {
4541 debug('onunpipe');
4542 if (readable === src) {
4543 if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
4544 unpipeInfo.hasUnpiped = true;
4545 cleanup();
4546 }
4547 }
4548 }
4549
4550 function onend() {
4551 debug('onend');
4552 dest.end();
4553 }
4554
4555 // when the dest drains, it reduces the awaitDrain counter
4556 // on the source. This would be more elegant with a .once()
4557 // handler in flow(), but adding and removing repeatedly is
4558 // too slow.
4559 var ondrain = pipeOnDrain(src);
4560 dest.on('drain', ondrain);
4561
4562 var cleanedUp = false;
4563 function cleanup() {
4564 debug('cleanup');
4565 // cleanup event handlers once the pipe is broken
4566 dest.removeListener('close', onclose);
4567 dest.removeListener('finish', onfinish);
4568 dest.removeListener('drain', ondrain);
4569 dest.removeListener('error', onerror);
4570 dest.removeListener('unpipe', onunpipe);
4571 src.removeListener('end', onend);
4572 src.removeListener('end', unpipe);
4573 src.removeListener('data', ondata);
4574
4575 cleanedUp = true;
4576
4577 // if the reader is waiting for a drain event from this
4578 // specific writer, then it would cause it to never start
4579 // flowing again.
4580 // So, if this is awaiting a drain, then we just call it now.
4581 // If we don't know, then assume that we are waiting for one.
4582 if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
4583 }
4584
4585 // If the user pushes more data while we're writing to dest then we'll end up
4586 // in ondata again. However, we only want to increase awaitDrain once because
4587 // dest will only emit one 'drain' event for the multiple writes.
4588 // => Introduce a guard on increasing awaitDrain.
4589 var increasedAwaitDrain = false;
4590 src.on('data', ondata);
4591 function ondata(chunk) {
4592 debug('ondata');
4593 increasedAwaitDrain = false;
4594 var ret = dest.write(chunk);
4595 if (false === ret && !increasedAwaitDrain) {
4596 // If the user unpiped during `dest.write()`, it is possible
4597 // to get stuck in a permanently paused state if that write
4598 // also returned false.
4599 // => Check whether `dest` is still a piping destination.
4600 if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
4601 debug('false write response, pause', src._readableState.awaitDrain);
4602 src._readableState.awaitDrain++;
4603 increasedAwaitDrain = true;
4604 }
4605 src.pause();
4606 }
4607 }
4608
4609 // if the dest has an error, then stop piping into it.
4610 // however, don't suppress the throwing behavior for this.
4611 function onerror(er) {
4612 debug('onerror', er);
4613 unpipe();
4614 dest.removeListener('error', onerror);
4615 if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
4616 }
4617
4618 // Make sure our error handler is attached before userland ones.
4619 prependListener(dest, 'error', onerror);
4620
4621 // Both close and finish should trigger unpipe, but only once.
4622 function onclose() {
4623 dest.removeListener('finish', onfinish);
4624 unpipe();
4625 }
4626 dest.once('close', onclose);
4627 function onfinish() {
4628 debug('onfinish');
4629 dest.removeListener('close', onclose);
4630 unpipe();
4631 }
4632 dest.once('finish', onfinish);
4633
4634 function unpipe() {
4635 debug('unpipe');
4636 src.unpipe(dest);
4637 }
4638
4639 // tell the dest that it's being piped to
4640 dest.emit('pipe', src);
4641
4642 // start the flow if it hasn't been started already.
4643 if (!state.flowing) {
4644 debug('pipe resume');
4645 src.resume();
4646 }
4647
4648 return dest;
4649};
4650
4651function pipeOnDrain(src) {
4652 return function () {
4653 var state = src._readableState;
4654 debug('pipeOnDrain', state.awaitDrain);
4655 if (state.awaitDrain) state.awaitDrain--;
4656 if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
4657 state.flowing = true;
4658 flow(src);
4659 }
4660 };
4661}
4662
4663Readable.prototype.unpipe = function (dest) {
4664 var state = this._readableState;
4665 var unpipeInfo = { hasUnpiped: false };
4666
4667 // if we're not piping anywhere, then do nothing.
4668 if (state.pipesCount === 0) return this;
4669
4670 // just one destination. most common case.
4671 if (state.pipesCount === 1) {
4672 // passed in one, but it's not the right one.
4673 if (dest && dest !== state.pipes) return this;
4674
4675 if (!dest) dest = state.pipes;
4676
4677 // got a match.
4678 state.pipes = null;
4679 state.pipesCount = 0;
4680 state.flowing = false;
4681 if (dest) dest.emit('unpipe', this, unpipeInfo);
4682 return this;
4683 }
4684
4685 // slow case. multiple pipe destinations.
4686
4687 if (!dest) {
4688 // remove all.
4689 var dests = state.pipes;
4690 var len = state.pipesCount;
4691 state.pipes = null;
4692 state.pipesCount = 0;
4693 state.flowing = false;
4694
4695 for (var i = 0; i < len; i++) {
4696 dests[i].emit('unpipe', this, unpipeInfo);
4697 }return this;
4698 }
4699
4700 // try to find the right one.
4701 var index = indexOf(state.pipes, dest);
4702 if (index === -1) return this;
4703
4704 state.pipes.splice(index, 1);
4705 state.pipesCount -= 1;
4706 if (state.pipesCount === 1) state.pipes = state.pipes[0];
4707
4708 dest.emit('unpipe', this, unpipeInfo);
4709
4710 return this;
4711};
4712
4713// set up data events if they are asked for
4714// Ensure readable listeners eventually get something
4715Readable.prototype.on = function (ev, fn) {
4716 var res = Stream.prototype.on.call(this, ev, fn);
4717
4718 if (ev === 'data') {
4719 // Start flowing on next tick if stream isn't explicitly paused
4720 if (this._readableState.flowing !== false) this.resume();
4721 } else if (ev === 'readable') {
4722 var state = this._readableState;
4723 if (!state.endEmitted && !state.readableListening) {
4724 state.readableListening = state.needReadable = true;
4725 state.emittedReadable = false;
4726 if (!state.reading) {
4727 pna.nextTick(nReadingNextTick, this);
4728 } else if (state.length) {
4729 emitReadable(this);
4730 }
4731 }
4732 }
4733
4734 return res;
4735};
4736Readable.prototype.addListener = Readable.prototype.on;
4737
4738function nReadingNextTick(self) {
4739 debug('readable nexttick read 0');
4740 self.read(0);
4741}
4742
4743// pause() and resume() are remnants of the legacy readable stream API
4744// If the user uses them, then switch into old mode.
4745Readable.prototype.resume = function () {
4746 var state = this._readableState;
4747 if (!state.flowing) {
4748 debug('resume');
4749 state.flowing = true;
4750 resume(this, state);
4751 }
4752 return this;
4753};
4754
4755function resume(stream, state) {
4756 if (!state.resumeScheduled) {
4757 state.resumeScheduled = true;
4758 pna.nextTick(resume_, stream, state);
4759 }
4760}
4761
4762function resume_(stream, state) {
4763 if (!state.reading) {
4764 debug('resume read 0');
4765 stream.read(0);
4766 }
4767
4768 state.resumeScheduled = false;
4769 state.awaitDrain = 0;
4770 stream.emit('resume');
4771 flow(stream);
4772 if (state.flowing && !state.reading) stream.read(0);
4773}
4774
4775Readable.prototype.pause = function () {
4776 debug('call pause flowing=%j', this._readableState.flowing);
4777 if (false !== this._readableState.flowing) {
4778 debug('pause');
4779 this._readableState.flowing = false;
4780 this.emit('pause');
4781 }
4782 return this;
4783};
4784
4785function flow(stream) {
4786 var state = stream._readableState;
4787 debug('flow', state.flowing);
4788 while (state.flowing && stream.read() !== null) {}
4789}
4790
4791// wrap an old-style stream as the async data source.
4792// This is *not* part of the readable stream interface.
4793// It is an ugly unfortunate mess of history.
4794Readable.prototype.wrap = function (stream) {
4795 var _this = this;
4796
4797 var state = this._readableState;
4798 var paused = false;
4799
4800 stream.on('end', function () {
4801 debug('wrapped end');
4802 if (state.decoder && !state.ended) {
4803 var chunk = state.decoder.end();
4804 if (chunk && chunk.length) _this.push(chunk);
4805 }
4806
4807 _this.push(null);
4808 });
4809
4810 stream.on('data', function (chunk) {
4811 debug('wrapped data');
4812 if (state.decoder) chunk = state.decoder.write(chunk);
4813
4814 // don't skip over falsy values in objectMode
4815 if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
4816
4817 var ret = _this.push(chunk);
4818 if (!ret) {
4819 paused = true;
4820 stream.pause();
4821 }
4822 });
4823
4824 // proxy all the other methods.
4825 // important when wrapping filters and duplexes.
4826 for (var i in stream) {
4827 if (this[i] === undefined && typeof stream[i] === 'function') {
4828 this[i] = function (method) {
4829 return function () {
4830 return stream[method].apply(stream, arguments);
4831 };
4832 }(i);
4833 }
4834 }
4835
4836 // proxy certain important events.
4837 for (var n = 0; n < kProxyEvents.length; n++) {
4838 stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
4839 }
4840
4841 // when we try to consume some more bytes, simply unpause the
4842 // underlying stream.
4843 this._read = function (n) {
4844 debug('wrapped _read', n);
4845 if (paused) {
4846 paused = false;
4847 stream.resume();
4848 }
4849 };
4850
4851 return this;
4852};
4853
4854Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
4855 // making it explicit this property is not enumerable
4856 // because otherwise some prototype manipulation in
4857 // userland will fail
4858 enumerable: false,
4859 get: function () {
4860 return this._readableState.highWaterMark;
4861 }
4862});
4863
4864// exposed for testing purposes only.
4865Readable._fromList = fromList;
4866
4867// Pluck off n bytes from an array of buffers.
4868// Length is the combined lengths of all the buffers in the list.
4869// This function is designed to be inlinable, so please take care when making
4870// changes to the function body.
4871function fromList(n, state) {
4872 // nothing buffered
4873 if (state.length === 0) return null;
4874
4875 var ret;
4876 if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
4877 // read it all, truncate the list
4878 if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
4879 state.buffer.clear();
4880 } else {
4881 // read part of list
4882 ret = fromListPartial(n, state.buffer, state.decoder);
4883 }
4884
4885 return ret;
4886}
4887
4888// Extracts only enough buffered data to satisfy the amount requested.
4889// This function is designed to be inlinable, so please take care when making
4890// changes to the function body.
4891function fromListPartial(n, list, hasStrings) {
4892 var ret;
4893 if (n < list.head.data.length) {
4894 // slice is the same for buffers and strings
4895 ret = list.head.data.slice(0, n);
4896 list.head.data = list.head.data.slice(n);
4897 } else if (n === list.head.data.length) {
4898 // first chunk is a perfect match
4899 ret = list.shift();
4900 } else {
4901 // result spans more than one buffer
4902 ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
4903 }
4904 return ret;
4905}
4906
4907// Copies a specified amount of characters from the list of buffered data
4908// chunks.
4909// This function is designed to be inlinable, so please take care when making
4910// changes to the function body.
4911function copyFromBufferString(n, list) {
4912 var p = list.head;
4913 var c = 1;
4914 var ret = p.data;
4915 n -= ret.length;
4916 while (p = p.next) {
4917 var str = p.data;
4918 var nb = n > str.length ? str.length : n;
4919 if (nb === str.length) ret += str;else ret += str.slice(0, n);
4920 n -= nb;
4921 if (n === 0) {
4922 if (nb === str.length) {
4923 ++c;
4924 if (p.next) list.head = p.next;else list.head = list.tail = null;
4925 } else {
4926 list.head = p;
4927 p.data = str.slice(nb);
4928 }
4929 break;
4930 }
4931 ++c;
4932 }
4933 list.length -= c;
4934 return ret;
4935}
4936
4937// Copies a specified amount of bytes from the list of buffered data chunks.
4938// This function is designed to be inlinable, so please take care when making
4939// changes to the function body.
4940function copyFromBuffer(n, list) {
4941 var ret = Buffer.allocUnsafe(n);
4942 var p = list.head;
4943 var c = 1;
4944 p.data.copy(ret);
4945 n -= p.data.length;
4946 while (p = p.next) {
4947 var buf = p.data;
4948 var nb = n > buf.length ? buf.length : n;
4949 buf.copy(ret, ret.length - n, 0, nb);
4950 n -= nb;
4951 if (n === 0) {
4952 if (nb === buf.length) {
4953 ++c;
4954 if (p.next) list.head = p.next;else list.head = list.tail = null;
4955 } else {
4956 list.head = p;
4957 p.data = buf.slice(nb);
4958 }
4959 break;
4960 }
4961 ++c;
4962 }
4963 list.length -= c;
4964 return ret;
4965}
4966
4967function endReadable(stream) {
4968 var state = stream._readableState;
4969
4970 // If we get here before consuming all the bytes, then that is a
4971 // bug in node. Should never happen.
4972 if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
4973
4974 if (!state.endEmitted) {
4975 state.ended = true;
4976 pna.nextTick(endReadableNT, state, stream);
4977 }
4978}
4979
4980function endReadableNT(state, stream) {
4981 // Check that we didn't get one last unshift.
4982 if (!state.endEmitted && state.length === 0) {
4983 state.endEmitted = true;
4984 stream.readable = false;
4985 stream.emit('end');
4986 }
4987}
4988
4989function indexOf(xs, x) {
4990 for (var i = 0, l = xs.length; i < l; i++) {
4991 if (xs[i] === x) return i;
4992 }
4993 return -1;
4994}
4995/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0), __webpack_require__(1)))
4996
4997/***/ }),
4998/* 16 */
4999/***/ (function(module, exports, __webpack_require__) {
5000
5001module.exports = __webpack_require__(8).EventEmitter;
5002
5003
5004/***/ }),
5005/* 17 */
5006/***/ (function(module, exports, __webpack_require__) {
5007
5008"use strict";
5009
5010
5011/*<replacement>*/
5012
5013var pna = __webpack_require__(6);
5014/*</replacement>*/
5015
5016// undocumented cb() API, needed for core, not for public API
5017function destroy(err, cb) {
5018 var _this = this;
5019
5020 var readableDestroyed = this._readableState && this._readableState.destroyed;
5021 var writableDestroyed = this._writableState && this._writableState.destroyed;
5022
5023 if (readableDestroyed || writableDestroyed) {
5024 if (cb) {
5025 cb(err);
5026 } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
5027 pna.nextTick(emitErrorNT, this, err);
5028 }
5029 return this;
5030 }
5031
5032 // we set destroyed to true before firing error callbacks in order
5033 // to make it re-entrance safe in case destroy() is called within callbacks
5034
5035 if (this._readableState) {
5036 this._readableState.destroyed = true;
5037 }
5038
5039 // if this is a duplex stream mark the writable part as destroyed as well
5040 if (this._writableState) {
5041 this._writableState.destroyed = true;
5042 }
5043
5044 this._destroy(err || null, function (err) {
5045 if (!cb && err) {
5046 pna.nextTick(emitErrorNT, _this, err);
5047 if (_this._writableState) {
5048 _this._writableState.errorEmitted = true;
5049 }
5050 } else if (cb) {
5051 cb(err);
5052 }
5053 });
5054
5055 return this;
5056}
5057
5058function undestroy() {
5059 if (this._readableState) {
5060 this._readableState.destroyed = false;
5061 this._readableState.reading = false;
5062 this._readableState.ended = false;
5063 this._readableState.endEmitted = false;
5064 }
5065
5066 if (this._writableState) {
5067 this._writableState.destroyed = false;
5068 this._writableState.ended = false;
5069 this._writableState.ending = false;
5070 this._writableState.finished = false;
5071 this._writableState.errorEmitted = false;
5072 }
5073}
5074
5075function emitErrorNT(self, err) {
5076 self.emit('error', err);
5077}
5078
5079module.exports = {
5080 destroy: destroy,
5081 undestroy: undestroy
5082};
5083
5084/***/ }),
5085/* 18 */
5086/***/ (function(module, exports, __webpack_require__) {
5087
5088"use strict";
5089/* WEBPACK VAR INJECTION */(function(process, setImmediate, global) {// Copyright Joyent, Inc. and other Node contributors.
5090//
5091// Permission is hereby granted, free of charge, to any person obtaining a
5092// copy of this software and associated documentation files (the
5093// "Software"), to deal in the Software without restriction, including
5094// without limitation the rights to use, copy, modify, merge, publish,
5095// distribute, sublicense, and/or sell copies of the Software, and to permit
5096// persons to whom the Software is furnished to do so, subject to the
5097// following conditions:
5098//
5099// The above copyright notice and this permission notice shall be included
5100// in all copies or substantial portions of the Software.
5101//
5102// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
5103// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
5104// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
5105// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
5106// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
5107// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
5108// USE OR OTHER DEALINGS IN THE SOFTWARE.
5109
5110// A bit simpler than readable streams.
5111// Implement an async ._write(chunk, encoding, cb), and it'll handle all
5112// the drain event emission and buffering.
5113
5114
5115
5116/*<replacement>*/
5117
5118var pna = __webpack_require__(6);
5119/*</replacement>*/
5120
5121module.exports = Writable;
5122
5123/* <replacement> */
5124function WriteReq(chunk, encoding, cb) {
5125 this.chunk = chunk;
5126 this.encoding = encoding;
5127 this.callback = cb;
5128 this.next = null;
5129}
5130
5131// It seems a linked list but it is not
5132// there will be only 2 of these for each stream
5133function CorkedRequest(state) {
5134 var _this = this;
5135
5136 this.next = null;
5137 this.entry = null;
5138 this.finish = function () {
5139 onCorkedFinish(_this, state);
5140 };
5141}
5142/* </replacement> */
5143
5144/*<replacement>*/
5145var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
5146/*</replacement>*/
5147
5148/*<replacement>*/
5149var Duplex;
5150/*</replacement>*/
5151
5152Writable.WritableState = WritableState;
5153
5154/*<replacement>*/
5155var util = __webpack_require__(4);
5156util.inherits = __webpack_require__(5);
5157/*</replacement>*/
5158
5159/*<replacement>*/
5160var internalUtil = {
5161 deprecate: __webpack_require__(44)
5162};
5163/*</replacement>*/
5164
5165/*<replacement>*/
5166var Stream = __webpack_require__(16);
5167/*</replacement>*/
5168
5169/*<replacement>*/
5170
5171var Buffer = __webpack_require__(9).Buffer;
5172var OurUint8Array = global.Uint8Array || function () {};
5173function _uint8ArrayToBuffer(chunk) {
5174 return Buffer.from(chunk);
5175}
5176function _isUint8Array(obj) {
5177 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
5178}
5179
5180/*</replacement>*/
5181
5182var destroyImpl = __webpack_require__(17);
5183
5184util.inherits(Writable, Stream);
5185
5186function nop() {}
5187
5188function WritableState(options, stream) {
5189 Duplex = Duplex || __webpack_require__(3);
5190
5191 options = options || {};
5192
5193 // Duplex streams are both readable and writable, but share
5194 // the same options object.
5195 // However, some cases require setting options to different
5196 // values for the readable and the writable sides of the duplex stream.
5197 // These options can be provided separately as readableXXX and writableXXX.
5198 var isDuplex = stream instanceof Duplex;
5199
5200 // object stream flag to indicate whether or not this stream
5201 // contains buffers or objects.
5202 this.objectMode = !!options.objectMode;
5203
5204 if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
5205
5206 // the point at which write() starts returning false
5207 // Note: 0 is a valid value, means that we always return false if
5208 // the entire buffer is not flushed immediately on write()
5209 var hwm = options.highWaterMark;
5210 var writableHwm = options.writableHighWaterMark;
5211 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
5212
5213 if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
5214
5215 // cast to ints.
5216 this.highWaterMark = Math.floor(this.highWaterMark);
5217
5218 // if _final has been called
5219 this.finalCalled = false;
5220
5221 // drain event flag.
5222 this.needDrain = false;
5223 // at the start of calling end()
5224 this.ending = false;
5225 // when end() has been called, and returned
5226 this.ended = false;
5227 // when 'finish' is emitted
5228 this.finished = false;
5229
5230 // has it been destroyed
5231 this.destroyed = false;
5232
5233 // should we decode strings into buffers before passing to _write?
5234 // this is here so that some node-core streams can optimize string
5235 // handling at a lower level.
5236 var noDecode = options.decodeStrings === false;
5237 this.decodeStrings = !noDecode;
5238
5239 // Crypto is kind of old and crusty. Historically, its default string
5240 // encoding is 'binary' so we have to make this configurable.
5241 // Everything else in the universe uses 'utf8', though.
5242 this.defaultEncoding = options.defaultEncoding || 'utf8';
5243
5244 // not an actual buffer we keep track of, but a measurement
5245 // of how much we're waiting to get pushed to some underlying
5246 // socket or file.
5247 this.length = 0;
5248
5249 // a flag to see when we're in the middle of a write.
5250 this.writing = false;
5251
5252 // when true all writes will be buffered until .uncork() call
5253 this.corked = 0;
5254
5255 // a flag to be able to tell if the onwrite cb is called immediately,
5256 // or on a later tick. We set this to true at first, because any
5257 // actions that shouldn't happen until "later" should generally also
5258 // not happen before the first write call.
5259 this.sync = true;
5260
5261 // a flag to know if we're processing previously buffered items, which
5262 // may call the _write() callback in the same tick, so that we don't
5263 // end up in an overlapped onwrite situation.
5264 this.bufferProcessing = false;
5265
5266 // the callback that's passed to _write(chunk,cb)
5267 this.onwrite = function (er) {
5268 onwrite(stream, er);
5269 };
5270
5271 // the callback that the user supplies to write(chunk,encoding,cb)
5272 this.writecb = null;
5273
5274 // the amount that is being written when _write is called.
5275 this.writelen = 0;
5276
5277 this.bufferedRequest = null;
5278 this.lastBufferedRequest = null;
5279
5280 // number of pending user-supplied write callbacks
5281 // this must be 0 before 'finish' can be emitted
5282 this.pendingcb = 0;
5283
5284 // emit prefinish if the only thing we're waiting for is _write cbs
5285 // This is relevant for synchronous Transform streams
5286 this.prefinished = false;
5287
5288 // True if the error was already emitted and should not be thrown again
5289 this.errorEmitted = false;
5290
5291 // count buffered requests
5292 this.bufferedRequestCount = 0;
5293
5294 // allocate the first CorkedRequest, there is always
5295 // one allocated and free to use, and we maintain at most two
5296 this.corkedRequestsFree = new CorkedRequest(this);
5297}
5298
5299WritableState.prototype.getBuffer = function getBuffer() {
5300 var current = this.bufferedRequest;
5301 var out = [];
5302 while (current) {
5303 out.push(current);
5304 current = current.next;
5305 }
5306 return out;
5307};
5308
5309(function () {
5310 try {
5311 Object.defineProperty(WritableState.prototype, 'buffer', {
5312 get: internalUtil.deprecate(function () {
5313 return this.getBuffer();
5314 }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
5315 });
5316 } catch (_) {}
5317})();
5318
5319// Test _writableState for inheritance to account for Duplex streams,
5320// whose prototype chain only points to Readable.
5321var realHasInstance;
5322if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
5323 realHasInstance = Function.prototype[Symbol.hasInstance];
5324 Object.defineProperty(Writable, Symbol.hasInstance, {
5325 value: function (object) {
5326 if (realHasInstance.call(this, object)) return true;
5327 if (this !== Writable) return false;
5328
5329 return object && object._writableState instanceof WritableState;
5330 }
5331 });
5332} else {
5333 realHasInstance = function (object) {
5334 return object instanceof this;
5335 };
5336}
5337
5338function Writable(options) {
5339 Duplex = Duplex || __webpack_require__(3);
5340
5341 // Writable ctor is applied to Duplexes, too.
5342 // `realHasInstance` is necessary because using plain `instanceof`
5343 // would return false, as no `_writableState` property is attached.
5344
5345 // Trying to use the custom `instanceof` for Writable here will also break the
5346 // Node.js LazyTransform implementation, which has a non-trivial getter for
5347 // `_writableState` that would lead to infinite recursion.
5348 if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
5349 return new Writable(options);
5350 }
5351
5352 this._writableState = new WritableState(options, this);
5353
5354 // legacy.
5355 this.writable = true;
5356
5357 if (options) {
5358 if (typeof options.write === 'function') this._write = options.write;
5359
5360 if (typeof options.writev === 'function') this._writev = options.writev;
5361
5362 if (typeof options.destroy === 'function') this._destroy = options.destroy;
5363
5364 if (typeof options.final === 'function') this._final = options.final;
5365 }
5366
5367 Stream.call(this);
5368}
5369
5370// Otherwise people can pipe Writable streams, which is just wrong.
5371Writable.prototype.pipe = function () {
5372 this.emit('error', new Error('Cannot pipe, not readable'));
5373};
5374
5375function writeAfterEnd(stream, cb) {
5376 var er = new Error('write after end');
5377 // TODO: defer error events consistently everywhere, not just the cb
5378 stream.emit('error', er);
5379 pna.nextTick(cb, er);
5380}
5381
5382// Checks that a user-supplied chunk is valid, especially for the particular
5383// mode the stream is in. Currently this means that `null` is never accepted
5384// and undefined/non-string values are only allowed in object mode.
5385function validChunk(stream, state, chunk, cb) {
5386 var valid = true;
5387 var er = false;
5388
5389 if (chunk === null) {
5390 er = new TypeError('May not write null values to stream');
5391 } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
5392 er = new TypeError('Invalid non-string/buffer chunk');
5393 }
5394 if (er) {
5395 stream.emit('error', er);
5396 pna.nextTick(cb, er);
5397 valid = false;
5398 }
5399 return valid;
5400}
5401
5402Writable.prototype.write = function (chunk, encoding, cb) {
5403 var state = this._writableState;
5404 var ret = false;
5405 var isBuf = !state.objectMode && _isUint8Array(chunk);
5406
5407 if (isBuf && !Buffer.isBuffer(chunk)) {
5408 chunk = _uint8ArrayToBuffer(chunk);
5409 }
5410
5411 if (typeof encoding === 'function') {
5412 cb = encoding;
5413 encoding = null;
5414 }
5415
5416 if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
5417
5418 if (typeof cb !== 'function') cb = nop;
5419
5420 if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
5421 state.pendingcb++;
5422 ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
5423 }
5424
5425 return ret;
5426};
5427
5428Writable.prototype.cork = function () {
5429 var state = this._writableState;
5430
5431 state.corked++;
5432};
5433
5434Writable.prototype.uncork = function () {
5435 var state = this._writableState;
5436
5437 if (state.corked) {
5438 state.corked--;
5439
5440 if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
5441 }
5442};
5443
5444Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
5445 // node::ParseEncoding() requires lower case.
5446 if (typeof encoding === 'string') encoding = encoding.toLowerCase();
5447 if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
5448 this._writableState.defaultEncoding = encoding;
5449 return this;
5450};
5451
5452function decodeChunk(state, chunk, encoding) {
5453 if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
5454 chunk = Buffer.from(chunk, encoding);
5455 }
5456 return chunk;
5457}
5458
5459Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
5460 // making it explicit this property is not enumerable
5461 // because otherwise some prototype manipulation in
5462 // userland will fail
5463 enumerable: false,
5464 get: function () {
5465 return this._writableState.highWaterMark;
5466 }
5467});
5468
5469// if we're already writing something, then just put this
5470// in the queue, and wait our turn. Otherwise, call _write
5471// If we return false, then we need a drain event, so set that flag.
5472function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
5473 if (!isBuf) {
5474 var newChunk = decodeChunk(state, chunk, encoding);
5475 if (chunk !== newChunk) {
5476 isBuf = true;
5477 encoding = 'buffer';
5478 chunk = newChunk;
5479 }
5480 }
5481 var len = state.objectMode ? 1 : chunk.length;
5482
5483 state.length += len;
5484
5485 var ret = state.length < state.highWaterMark;
5486 // we must ensure that previous needDrain will not be reset to false.
5487 if (!ret) state.needDrain = true;
5488
5489 if (state.writing || state.corked) {
5490 var last = state.lastBufferedRequest;
5491 state.lastBufferedRequest = {
5492 chunk: chunk,
5493 encoding: encoding,
5494 isBuf: isBuf,
5495 callback: cb,
5496 next: null
5497 };
5498 if (last) {
5499 last.next = state.lastBufferedRequest;
5500 } else {
5501 state.bufferedRequest = state.lastBufferedRequest;
5502 }
5503 state.bufferedRequestCount += 1;
5504 } else {
5505 doWrite(stream, state, false, len, chunk, encoding, cb);
5506 }
5507
5508 return ret;
5509}
5510
5511function doWrite(stream, state, writev, len, chunk, encoding, cb) {
5512 state.writelen = len;
5513 state.writecb = cb;
5514 state.writing = true;
5515 state.sync = true;
5516 if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
5517 state.sync = false;
5518}
5519
5520function onwriteError(stream, state, sync, er, cb) {
5521 --state.pendingcb;
5522
5523 if (sync) {
5524 // defer the callback if we are being called synchronously
5525 // to avoid piling up things on the stack
5526 pna.nextTick(cb, er);
5527 // this can emit finish, and it will always happen
5528 // after error
5529 pna.nextTick(finishMaybe, stream, state);
5530 stream._writableState.errorEmitted = true;
5531 stream.emit('error', er);
5532 } else {
5533 // the caller expect this to happen before if
5534 // it is async
5535 cb(er);
5536 stream._writableState.errorEmitted = true;
5537 stream.emit('error', er);
5538 // this can emit finish, but finish must
5539 // always follow error
5540 finishMaybe(stream, state);
5541 }
5542}
5543
5544function onwriteStateUpdate(state) {
5545 state.writing = false;
5546 state.writecb = null;
5547 state.length -= state.writelen;
5548 state.writelen = 0;
5549}
5550
5551function onwrite(stream, er) {
5552 var state = stream._writableState;
5553 var sync = state.sync;
5554 var cb = state.writecb;
5555
5556 onwriteStateUpdate(state);
5557
5558 if (er) onwriteError(stream, state, sync, er, cb);else {
5559 // Check if we're actually ready to finish, but don't emit yet
5560 var finished = needFinish(state);
5561
5562 if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
5563 clearBuffer(stream, state);
5564 }
5565
5566 if (sync) {
5567 /*<replacement>*/
5568 asyncWrite(afterWrite, stream, state, finished, cb);
5569 /*</replacement>*/
5570 } else {
5571 afterWrite(stream, state, finished, cb);
5572 }
5573 }
5574}
5575
5576function afterWrite(stream, state, finished, cb) {
5577 if (!finished) onwriteDrain(stream, state);
5578 state.pendingcb--;
5579 cb();
5580 finishMaybe(stream, state);
5581}
5582
5583// Must force callback to be called on nextTick, so that we don't
5584// emit 'drain' before the write() consumer gets the 'false' return
5585// value, and has a chance to attach a 'drain' listener.
5586function onwriteDrain(stream, state) {
5587 if (state.length === 0 && state.needDrain) {
5588 state.needDrain = false;
5589 stream.emit('drain');
5590 }
5591}
5592
5593// if there's something in the buffer waiting, then process it
5594function clearBuffer(stream, state) {
5595 state.bufferProcessing = true;
5596 var entry = state.bufferedRequest;
5597
5598 if (stream._writev && entry && entry.next) {
5599 // Fast case, write everything using _writev()
5600 var l = state.bufferedRequestCount;
5601 var buffer = new Array(l);
5602 var holder = state.corkedRequestsFree;
5603 holder.entry = entry;
5604
5605 var count = 0;
5606 var allBuffers = true;
5607 while (entry) {
5608 buffer[count] = entry;
5609 if (!entry.isBuf) allBuffers = false;
5610 entry = entry.next;
5611 count += 1;
5612 }
5613 buffer.allBuffers = allBuffers;
5614
5615 doWrite(stream, state, true, state.length, buffer, '', holder.finish);
5616
5617 // doWrite is almost always async, defer these to save a bit of time
5618 // as the hot path ends with doWrite
5619 state.pendingcb++;
5620 state.lastBufferedRequest = null;
5621 if (holder.next) {
5622 state.corkedRequestsFree = holder.next;
5623 holder.next = null;
5624 } else {
5625 state.corkedRequestsFree = new CorkedRequest(state);
5626 }
5627 state.bufferedRequestCount = 0;
5628 } else {
5629 // Slow case, write chunks one-by-one
5630 while (entry) {
5631 var chunk = entry.chunk;
5632 var encoding = entry.encoding;
5633 var cb = entry.callback;
5634 var len = state.objectMode ? 1 : chunk.length;
5635
5636 doWrite(stream, state, false, len, chunk, encoding, cb);
5637 entry = entry.next;
5638 state.bufferedRequestCount--;
5639 // if we didn't call the onwrite immediately, then
5640 // it means that we need to wait until it does.
5641 // also, that means that the chunk and cb are currently
5642 // being processed, so move the buffer counter past them.
5643 if (state.writing) {
5644 break;
5645 }
5646 }
5647
5648 if (entry === null) state.lastBufferedRequest = null;
5649 }
5650
5651 state.bufferedRequest = entry;
5652 state.bufferProcessing = false;
5653}
5654
5655Writable.prototype._write = function (chunk, encoding, cb) {
5656 cb(new Error('_write() is not implemented'));
5657};
5658
5659Writable.prototype._writev = null;
5660
5661Writable.prototype.end = function (chunk, encoding, cb) {
5662 var state = this._writableState;
5663
5664 if (typeof chunk === 'function') {
5665 cb = chunk;
5666 chunk = null;
5667 encoding = null;
5668 } else if (typeof encoding === 'function') {
5669 cb = encoding;
5670 encoding = null;
5671 }
5672
5673 if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
5674
5675 // .end() fully uncorks
5676 if (state.corked) {
5677 state.corked = 1;
5678 this.uncork();
5679 }
5680
5681 // ignore unnecessary end() calls.
5682 if (!state.ending && !state.finished) endWritable(this, state, cb);
5683};
5684
5685function needFinish(state) {
5686 return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
5687}
5688function callFinal(stream, state) {
5689 stream._final(function (err) {
5690 state.pendingcb--;
5691 if (err) {
5692 stream.emit('error', err);
5693 }
5694 state.prefinished = true;
5695 stream.emit('prefinish');
5696 finishMaybe(stream, state);
5697 });
5698}
5699function prefinish(stream, state) {
5700 if (!state.prefinished && !state.finalCalled) {
5701 if (typeof stream._final === 'function') {
5702 state.pendingcb++;
5703 state.finalCalled = true;
5704 pna.nextTick(callFinal, stream, state);
5705 } else {
5706 state.prefinished = true;
5707 stream.emit('prefinish');
5708 }
5709 }
5710}
5711
5712function finishMaybe(stream, state) {
5713 var need = needFinish(state);
5714 if (need) {
5715 prefinish(stream, state);
5716 if (state.pendingcb === 0) {
5717 state.finished = true;
5718 stream.emit('finish');
5719 }
5720 }
5721 return need;
5722}
5723
5724function endWritable(stream, state, cb) {
5725 state.ending = true;
5726 finishMaybe(stream, state);
5727 if (cb) {
5728 if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
5729 }
5730 state.ended = true;
5731 stream.writable = false;
5732}
5733
5734function onCorkedFinish(corkReq, state, err) {
5735 var entry = corkReq.entry;
5736 corkReq.entry = null;
5737 while (entry) {
5738 var cb = entry.callback;
5739 state.pendingcb--;
5740 cb(err);
5741 entry = entry.next;
5742 }
5743 if (state.corkedRequestsFree) {
5744 state.corkedRequestsFree.next = corkReq;
5745 } else {
5746 state.corkedRequestsFree = corkReq;
5747 }
5748}
5749
5750Object.defineProperty(Writable.prototype, 'destroyed', {
5751 get: function () {
5752 if (this._writableState === undefined) {
5753 return false;
5754 }
5755 return this._writableState.destroyed;
5756 },
5757 set: function (value) {
5758 // we ignore the value if the stream
5759 // has not been initialized yet
5760 if (!this._writableState) {
5761 return;
5762 }
5763
5764 // backward compatibility, the user is explicitly
5765 // managing destroyed
5766 this._writableState.destroyed = value;
5767 }
5768});
5769
5770Writable.prototype.destroy = destroyImpl.destroy;
5771Writable.prototype._undestroy = destroyImpl.undestroy;
5772Writable.prototype._destroy = function (err, cb) {
5773 this.end();
5774 cb(err);
5775};
5776/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1), __webpack_require__(42).setImmediate, __webpack_require__(0)))
5777
5778/***/ }),
5779/* 19 */
5780/***/ (function(module, exports, __webpack_require__) {
5781
5782"use strict";
5783// Copyright Joyent, Inc. and other Node contributors.
5784//
5785// Permission is hereby granted, free of charge, to any person obtaining a
5786// copy of this software and associated documentation files (the
5787// "Software"), to deal in the Software without restriction, including
5788// without limitation the rights to use, copy, modify, merge, publish,
5789// distribute, sublicense, and/or sell copies of the Software, and to permit
5790// persons to whom the Software is furnished to do so, subject to the
5791// following conditions:
5792//
5793// The above copyright notice and this permission notice shall be included
5794// in all copies or substantial portions of the Software.
5795//
5796// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
5797// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
5798// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
5799// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
5800// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
5801// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
5802// USE OR OTHER DEALINGS IN THE SOFTWARE.
5803
5804
5805
5806/*<replacement>*/
5807
5808var Buffer = __webpack_require__(45).Buffer;
5809/*</replacement>*/
5810
5811var isEncoding = Buffer.isEncoding || function (encoding) {
5812 encoding = '' + encoding;
5813 switch (encoding && encoding.toLowerCase()) {
5814 case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
5815 return true;
5816 default:
5817 return false;
5818 }
5819};
5820
5821function _normalizeEncoding(enc) {
5822 if (!enc) return 'utf8';
5823 var retried;
5824 while (true) {
5825 switch (enc) {
5826 case 'utf8':
5827 case 'utf-8':
5828 return 'utf8';
5829 case 'ucs2':
5830 case 'ucs-2':
5831 case 'utf16le':
5832 case 'utf-16le':
5833 return 'utf16le';
5834 case 'latin1':
5835 case 'binary':
5836 return 'latin1';
5837 case 'base64':
5838 case 'ascii':
5839 case 'hex':
5840 return enc;
5841 default:
5842 if (retried) return; // undefined
5843 enc = ('' + enc).toLowerCase();
5844 retried = true;
5845 }
5846 }
5847};
5848
5849// Do not cache `Buffer.isEncoding` when checking encoding names as some
5850// modules monkey-patch it to support additional encodings
5851function normalizeEncoding(enc) {
5852 var nenc = _normalizeEncoding(enc);
5853 if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
5854 return nenc || enc;
5855}
5856
5857// StringDecoder provides an interface for efficiently splitting a series of
5858// buffers into a series of JS strings without breaking apart multi-byte
5859// characters.
5860exports.StringDecoder = StringDecoder;
5861function StringDecoder(encoding) {
5862 this.encoding = normalizeEncoding(encoding);
5863 var nb;
5864 switch (this.encoding) {
5865 case 'utf16le':
5866 this.text = utf16Text;
5867 this.end = utf16End;
5868 nb = 4;
5869 break;
5870 case 'utf8':
5871 this.fillLast = utf8FillLast;
5872 nb = 4;
5873 break;
5874 case 'base64':
5875 this.text = base64Text;
5876 this.end = base64End;
5877 nb = 3;
5878 break;
5879 default:
5880 this.write = simpleWrite;
5881 this.end = simpleEnd;
5882 return;
5883 }
5884 this.lastNeed = 0;
5885 this.lastTotal = 0;
5886 this.lastChar = Buffer.allocUnsafe(nb);
5887}
5888
5889StringDecoder.prototype.write = function (buf) {
5890 if (buf.length === 0) return '';
5891 var r;
5892 var i;
5893 if (this.lastNeed) {
5894 r = this.fillLast(buf);
5895 if (r === undefined) return '';
5896 i = this.lastNeed;
5897 this.lastNeed = 0;
5898 } else {
5899 i = 0;
5900 }
5901 if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
5902 return r || '';
5903};
5904
5905StringDecoder.prototype.end = utf8End;
5906
5907// Returns only complete characters in a Buffer
5908StringDecoder.prototype.text = utf8Text;
5909
5910// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
5911StringDecoder.prototype.fillLast = function (buf) {
5912 if (this.lastNeed <= buf.length) {
5913 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
5914 return this.lastChar.toString(this.encoding, 0, this.lastTotal);
5915 }
5916 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
5917 this.lastNeed -= buf.length;
5918};
5919
5920// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
5921// continuation byte. If an invalid byte is detected, -2 is returned.
5922function utf8CheckByte(byte) {
5923 if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
5924 return byte >> 6 === 0x02 ? -1 : -2;
5925}
5926
5927// Checks at most 3 bytes at the end of a Buffer in order to detect an
5928// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
5929// needed to complete the UTF-8 character (if applicable) are returned.
5930function utf8CheckIncomplete(self, buf, i) {
5931 var j = buf.length - 1;
5932 if (j < i) return 0;
5933 var nb = utf8CheckByte(buf[j]);
5934 if (nb >= 0) {
5935 if (nb > 0) self.lastNeed = nb - 1;
5936 return nb;
5937 }
5938 if (--j < i || nb === -2) return 0;
5939 nb = utf8CheckByte(buf[j]);
5940 if (nb >= 0) {
5941 if (nb > 0) self.lastNeed = nb - 2;
5942 return nb;
5943 }
5944 if (--j < i || nb === -2) return 0;
5945 nb = utf8CheckByte(buf[j]);
5946 if (nb >= 0) {
5947 if (nb > 0) {
5948 if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
5949 }
5950 return nb;
5951 }
5952 return 0;
5953}
5954
5955// Validates as many continuation bytes for a multi-byte UTF-8 character as
5956// needed or are available. If we see a non-continuation byte where we expect
5957// one, we "replace" the validated continuation bytes we've seen so far with
5958// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
5959// behavior. The continuation byte check is included three times in the case
5960// where all of the continuation bytes for a character exist in the same buffer.
5961// It is also done this way as a slight performance increase instead of using a
5962// loop.
5963function utf8CheckExtraBytes(self, buf, p) {
5964 if ((buf[0] & 0xC0) !== 0x80) {
5965 self.lastNeed = 0;
5966 return '\ufffd';
5967 }
5968 if (self.lastNeed > 1 && buf.length > 1) {
5969 if ((buf[1] & 0xC0) !== 0x80) {
5970 self.lastNeed = 1;
5971 return '\ufffd';
5972 }
5973 if (self.lastNeed > 2 && buf.length > 2) {
5974 if ((buf[2] & 0xC0) !== 0x80) {
5975 self.lastNeed = 2;
5976 return '\ufffd';
5977 }
5978 }
5979 }
5980}
5981
5982// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
5983function utf8FillLast(buf) {
5984 var p = this.lastTotal - this.lastNeed;
5985 var r = utf8CheckExtraBytes(this, buf, p);
5986 if (r !== undefined) return r;
5987 if (this.lastNeed <= buf.length) {
5988 buf.copy(this.lastChar, p, 0, this.lastNeed);
5989 return this.lastChar.toString(this.encoding, 0, this.lastTotal);
5990 }
5991 buf.copy(this.lastChar, p, 0, buf.length);
5992 this.lastNeed -= buf.length;
5993}
5994
5995// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
5996// partial character, the character's bytes are buffered until the required
5997// number of bytes are available.
5998function utf8Text(buf, i) {
5999 var total = utf8CheckIncomplete(this, buf, i);
6000 if (!this.lastNeed) return buf.toString('utf8', i);
6001 this.lastTotal = total;
6002 var end = buf.length - (total - this.lastNeed);
6003 buf.copy(this.lastChar, 0, end);
6004 return buf.toString('utf8', i, end);
6005}
6006
6007// For UTF-8, a replacement character is added when ending on a partial
6008// character.
6009function utf8End(buf) {
6010 var r = buf && buf.length ? this.write(buf) : '';
6011 if (this.lastNeed) return r + '\ufffd';
6012 return r;
6013}
6014
6015// UTF-16LE typically needs two bytes per character, but even if we have an even
6016// number of bytes available, we need to check if we end on a leading/high
6017// surrogate. In that case, we need to wait for the next two bytes in order to
6018// decode the last character properly.
6019function utf16Text(buf, i) {
6020 if ((buf.length - i) % 2 === 0) {
6021 var r = buf.toString('utf16le', i);
6022 if (r) {
6023 var c = r.charCodeAt(r.length - 1);
6024 if (c >= 0xD800 && c <= 0xDBFF) {
6025 this.lastNeed = 2;
6026 this.lastTotal = 4;
6027 this.lastChar[0] = buf[buf.length - 2];
6028 this.lastChar[1] = buf[buf.length - 1];
6029 return r.slice(0, -1);
6030 }
6031 }
6032 return r;
6033 }
6034 this.lastNeed = 1;
6035 this.lastTotal = 2;
6036 this.lastChar[0] = buf[buf.length - 1];
6037 return buf.toString('utf16le', i, buf.length - 1);
6038}
6039
6040// For UTF-16LE we do not explicitly append special replacement characters if we
6041// end on a partial character, we simply let v8 handle that.
6042function utf16End(buf) {
6043 var r = buf && buf.length ? this.write(buf) : '';
6044 if (this.lastNeed) {
6045 var end = this.lastTotal - this.lastNeed;
6046 return r + this.lastChar.toString('utf16le', 0, end);
6047 }
6048 return r;
6049}
6050
6051function base64Text(buf, i) {
6052 var n = (buf.length - i) % 3;
6053 if (n === 0) return buf.toString('base64', i);
6054 this.lastNeed = 3 - n;
6055 this.lastTotal = 3;
6056 if (n === 1) {
6057 this.lastChar[0] = buf[buf.length - 1];
6058 } else {
6059 this.lastChar[0] = buf[buf.length - 2];
6060 this.lastChar[1] = buf[buf.length - 1];
6061 }
6062 return buf.toString('base64', i, buf.length - n);
6063}
6064
6065function base64End(buf) {
6066 var r = buf && buf.length ? this.write(buf) : '';
6067 if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
6068 return r;
6069}
6070
6071// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
6072function simpleWrite(buf) {
6073 return buf.toString(this.encoding);
6074}
6075
6076function simpleEnd(buf) {
6077 return buf && buf.length ? this.write(buf) : '';
6078}
6079
6080/***/ }),
6081/* 20 */
6082/***/ (function(module, exports, __webpack_require__) {
6083
6084"use strict";
6085// Copyright Joyent, Inc. and other Node contributors.
6086//
6087// Permission is hereby granted, free of charge, to any person obtaining a
6088// copy of this software and associated documentation files (the
6089// "Software"), to deal in the Software without restriction, including
6090// without limitation the rights to use, copy, modify, merge, publish,
6091// distribute, sublicense, and/or sell copies of the Software, and to permit
6092// persons to whom the Software is furnished to do so, subject to the
6093// following conditions:
6094//
6095// The above copyright notice and this permission notice shall be included
6096// in all copies or substantial portions of the Software.
6097//
6098// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
6099// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
6100// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
6101// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
6102// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
6103// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
6104// USE OR OTHER DEALINGS IN THE SOFTWARE.
6105
6106// a transform stream is a readable/writable stream where you do
6107// something with the data. Sometimes it's called a "filter",
6108// but that's not a great name for it, since that implies a thing where
6109// some bits pass through, and others are simply ignored. (That would
6110// be a valid example of a transform, of course.)
6111//
6112// While the output is causally related to the input, it's not a
6113// necessarily symmetric or synchronous transformation. For example,
6114// a zlib stream might take multiple plain-text writes(), and then
6115// emit a single compressed chunk some time in the future.
6116//
6117// Here's how this works:
6118//
6119// The Transform stream has all the aspects of the readable and writable
6120// stream classes. When you write(chunk), that calls _write(chunk,cb)
6121// internally, and returns false if there's a lot of pending writes
6122// buffered up. When you call read(), that calls _read(n) until
6123// there's enough pending readable data buffered up.
6124//
6125// In a transform stream, the written data is placed in a buffer. When
6126// _read(n) is called, it transforms the queued up data, calling the
6127// buffered _write cb's as it consumes chunks. If consuming a single
6128// written chunk would result in multiple output chunks, then the first
6129// outputted bit calls the readcb, and subsequent chunks just go into
6130// the read buffer, and will cause it to emit 'readable' if necessary.
6131//
6132// This way, back-pressure is actually determined by the reading side,
6133// since _read has to be called to start processing a new chunk. However,
6134// a pathological inflate type of transform can cause excessive buffering
6135// here. For example, imagine a stream where every byte of input is
6136// interpreted as an integer from 0-255, and then results in that many
6137// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
6138// 1kb of data being output. In this case, you could write a very small
6139// amount of input, and end up with a very large amount of output. In
6140// such a pathological inflating mechanism, there'd be no way to tell
6141// the system to stop doing the transform. A single 4MB write could
6142// cause the system to run out of memory.
6143//
6144// However, even in such a pathological case, only a single written chunk
6145// would be consumed, and then the rest would wait (un-transformed) until
6146// the results of the previous transformed chunk were consumed.
6147
6148
6149
6150module.exports = Transform;
6151
6152var Duplex = __webpack_require__(3);
6153
6154/*<replacement>*/
6155var util = __webpack_require__(4);
6156util.inherits = __webpack_require__(5);
6157/*</replacement>*/
6158
6159util.inherits(Transform, Duplex);
6160
6161function afterTransform(er, data) {
6162 var ts = this._transformState;
6163 ts.transforming = false;
6164
6165 var cb = ts.writecb;
6166
6167 if (!cb) {
6168 return this.emit('error', new Error('write callback called multiple times'));
6169 }
6170
6171 ts.writechunk = null;
6172 ts.writecb = null;
6173
6174 if (data != null) // single equals check for both `null` and `undefined`
6175 this.push(data);
6176
6177 cb(er);
6178
6179 var rs = this._readableState;
6180 rs.reading = false;
6181 if (rs.needReadable || rs.length < rs.highWaterMark) {
6182 this._read(rs.highWaterMark);
6183 }
6184}
6185
6186function Transform(options) {
6187 if (!(this instanceof Transform)) return new Transform(options);
6188
6189 Duplex.call(this, options);
6190
6191 this._transformState = {
6192 afterTransform: afterTransform.bind(this),
6193 needTransform: false,
6194 transforming: false,
6195 writecb: null,
6196 writechunk: null,
6197 writeencoding: null
6198 };
6199
6200 // start out asking for a readable event once data is transformed.
6201 this._readableState.needReadable = true;
6202
6203 // we have implemented the _read method, and done the other things
6204 // that Readable wants before the first _read call, so unset the
6205 // sync guard flag.
6206 this._readableState.sync = false;
6207
6208 if (options) {
6209 if (typeof options.transform === 'function') this._transform = options.transform;
6210
6211 if (typeof options.flush === 'function') this._flush = options.flush;
6212 }
6213
6214 // When the writable side finishes, then flush out anything remaining.
6215 this.on('prefinish', prefinish);
6216}
6217
6218function prefinish() {
6219 var _this = this;
6220
6221 if (typeof this._flush === 'function') {
6222 this._flush(function (er, data) {
6223 done(_this, er, data);
6224 });
6225 } else {
6226 done(this, null, null);
6227 }
6228}
6229
6230Transform.prototype.push = function (chunk, encoding) {
6231 this._transformState.needTransform = false;
6232 return Duplex.prototype.push.call(this, chunk, encoding);
6233};
6234
6235// This is the part where you do stuff!
6236// override this function in implementation classes.
6237// 'chunk' is an input chunk.
6238//
6239// Call `push(newChunk)` to pass along transformed output
6240// to the readable side. You may call 'push' zero or more times.
6241//
6242// Call `cb(err)` when you are done with this chunk. If you pass
6243// an error, then that'll put the hurt on the whole operation. If you
6244// never call cb(), then you'll never get another chunk.
6245Transform.prototype._transform = function (chunk, encoding, cb) {
6246 throw new Error('_transform() is not implemented');
6247};
6248
6249Transform.prototype._write = function (chunk, encoding, cb) {
6250 var ts = this._transformState;
6251 ts.writecb = cb;
6252 ts.writechunk = chunk;
6253 ts.writeencoding = encoding;
6254 if (!ts.transforming) {
6255 var rs = this._readableState;
6256 if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
6257 }
6258};
6259
6260// Doesn't matter what the args are here.
6261// _transform does all the work.
6262// That we got here means that the readable side wants more data.
6263Transform.prototype._read = function (n) {
6264 var ts = this._transformState;
6265
6266 if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
6267 ts.transforming = true;
6268 this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
6269 } else {
6270 // mark that we need a transform, so that any data that comes in
6271 // will get processed, now that we've asked for it.
6272 ts.needTransform = true;
6273 }
6274};
6275
6276Transform.prototype._destroy = function (err, cb) {
6277 var _this2 = this;
6278
6279 Duplex.prototype._destroy.call(this, err, function (err2) {
6280 cb(err2);
6281 _this2.emit('close');
6282 });
6283};
6284
6285function done(stream, er, data) {
6286 if (er) return stream.emit('error', er);
6287
6288 if (data != null) // single equals check for both `null` and `undefined`
6289 stream.push(data);
6290
6291 // if there's nothing in the write buffer, then that means
6292 // that nothing more will ever be provided
6293 if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
6294
6295 if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
6296
6297 return stream.push(null);
6298}
6299
6300/***/ }),
6301/* 21 */
6302/***/ (function(module, exports, __webpack_require__) {
6303
6304var EventSource = __webpack_require__(22)
6305
6306if (typeof window === 'object') {
6307 window.EventSourcePolyfill = EventSource
6308 if (!window.EventSource) window.EventSource = EventSource
6309 module.exports = window.EventSource
6310} else {
6311 module.exports = EventSource
6312}
6313
6314
6315/***/ }),
6316/* 22 */
6317/***/ (function(module, exports, __webpack_require__) {
6318
6319/* WEBPACK VAR INJECTION */(function(process, Buffer) {var original = __webpack_require__(26)
6320var parse = __webpack_require__(7).parse
6321var events = __webpack_require__(8)
6322var https = __webpack_require__(36)
6323var http = __webpack_require__(10)
6324var util = __webpack_require__(50)
6325
6326var httpsOptions = [
6327 'pfx', 'key', 'passphrase', 'cert', 'ca', 'ciphers',
6328 'rejectUnauthorized', 'secureProtocol', 'servername'
6329]
6330
6331var bom = [239, 187, 191]
6332var colon = 58
6333var space = 32
6334var lineFeed = 10
6335var carriageReturn = 13
6336
6337function hasBom (buf) {
6338 return bom.every(function (charCode, index) {
6339 return buf[index] === charCode
6340 })
6341}
6342
6343/**
6344 * Creates a new EventSource object
6345 *
6346 * @param {String} url the URL to which to connect
6347 * @param {Object} [eventSourceInitDict] extra init params. See README for details.
6348 * @api public
6349 **/
6350function EventSource (url, eventSourceInitDict) {
6351 var readyState = EventSource.CONNECTING
6352 Object.defineProperty(this, 'readyState', {
6353 get: function () {
6354 return readyState
6355 }
6356 })
6357
6358 Object.defineProperty(this, 'url', {
6359 get: function () {
6360 return url
6361 }
6362 })
6363
6364 var self = this
6365 self.reconnectInterval = 1000
6366
6367 function onConnectionClosed () {
6368 if (readyState === EventSource.CLOSED) return
6369 readyState = EventSource.CONNECTING
6370 _emit('error', new Event('error'))
6371
6372 // The url may have been changed by a temporary
6373 // redirect. If that's the case, revert it now.
6374 if (reconnectUrl) {
6375 url = reconnectUrl
6376 reconnectUrl = null
6377 }
6378 setTimeout(function () {
6379 if (readyState !== EventSource.CONNECTING) {
6380 return
6381 }
6382 connect()
6383 }, self.reconnectInterval)
6384 }
6385
6386 var req
6387 var lastEventId = ''
6388 if (eventSourceInitDict && eventSourceInitDict.headers && eventSourceInitDict.headers['Last-Event-ID']) {
6389 lastEventId = eventSourceInitDict.headers['Last-Event-ID']
6390 delete eventSourceInitDict.headers['Last-Event-ID']
6391 }
6392
6393 var discardTrailingNewline = false
6394 var data = ''
6395 var eventName = ''
6396
6397 var reconnectUrl = null
6398
6399 function connect () {
6400 var options = parse(url)
6401 var isSecure = options.protocol === 'https:'
6402 options.headers = { 'Cache-Control': 'no-cache', 'Accept': 'text/event-stream' }
6403 if (lastEventId) options.headers['Last-Event-ID'] = lastEventId
6404 if (eventSourceInitDict && eventSourceInitDict.headers) {
6405 for (var i in eventSourceInitDict.headers) {
6406 var header = eventSourceInitDict.headers[i]
6407 if (header) {
6408 options.headers[i] = header
6409 }
6410 }
6411 }
6412
6413 // Legacy: this should be specified as `eventSourceInitDict.https.rejectUnauthorized`,
6414 // but for now exists as a backwards-compatibility layer
6415 options.rejectUnauthorized = !(eventSourceInitDict && !eventSourceInitDict.rejectUnauthorized)
6416
6417 // If specify http proxy, make the request to sent to the proxy server,
6418 // and include the original url in path and Host headers
6419 var useProxy = eventSourceInitDict && eventSourceInitDict.proxy
6420 if (useProxy) {
6421 var proxy = parse(eventSourceInitDict.proxy)
6422 isSecure = proxy.protocol === 'https:'
6423
6424 options.protocol = isSecure ? 'https:' : 'http:'
6425 options.path = url
6426 options.headers.Host = options.host
6427 options.hostname = proxy.hostname
6428 options.host = proxy.host
6429 options.port = proxy.port
6430 }
6431
6432 // If https options are specified, merge them into the request options
6433 if (eventSourceInitDict && eventSourceInitDict.https) {
6434 for (var optName in eventSourceInitDict.https) {
6435 if (httpsOptions.indexOf(optName) === -1) {
6436 continue
6437 }
6438
6439 var option = eventSourceInitDict.https[optName]
6440 if (option !== undefined) {
6441 options[optName] = option
6442 }
6443 }
6444 }
6445
6446 // Pass this on to the XHR
6447 if (eventSourceInitDict && eventSourceInitDict.withCredentials !== undefined) {
6448 options.withCredentials = eventSourceInitDict.withCredentials
6449 }
6450
6451 req = (isSecure ? https : http).request(options, function (res) {
6452 // Handle HTTP errors
6453 if (res.statusCode === 500 || res.statusCode === 502 || res.statusCode === 503 || res.statusCode === 504) {
6454 _emit('error', new Event('error', {status: res.statusCode}))
6455 onConnectionClosed()
6456 return
6457 }
6458
6459 // Handle HTTP redirects
6460 if (res.statusCode === 301 || res.statusCode === 302 || res.statusCode === 307) {
6461 if (!res.headers.location) {
6462 // Server sent redirect response without Location header.
6463 _emit('error', new Event('error', {status: res.statusCode}))
6464 return
6465 }
6466 if (res.statusCode === 307) reconnectUrl = url
6467 url = res.headers.location
6468 process.nextTick(connect)
6469 return
6470 }
6471
6472 if (res.statusCode !== 200) {
6473 _emit('error', new Event('error', {status: res.statusCode}))
6474 return self.close()
6475 }
6476
6477 readyState = EventSource.OPEN
6478 res.on('close', function () {
6479 res.removeAllListeners('close')
6480 res.removeAllListeners('end')
6481 onConnectionClosed()
6482 })
6483
6484 res.on('end', function () {
6485 res.removeAllListeners('close')
6486 res.removeAllListeners('end')
6487 onConnectionClosed()
6488 })
6489 _emit('open', new Event('open'))
6490
6491 // text/event-stream parser adapted from webkit's
6492 // Source/WebCore/page/EventSource.cpp
6493 var isFirst = true
6494 var buf
6495 res.on('data', function (chunk) {
6496 buf = buf ? Buffer.concat([buf, chunk]) : chunk
6497 if (isFirst && hasBom(buf)) {
6498 buf = buf.slice(bom.length)
6499 }
6500
6501 isFirst = false
6502 var pos = 0
6503 var length = buf.length
6504
6505 while (pos < length) {
6506 if (discardTrailingNewline) {
6507 if (buf[pos] === lineFeed) {
6508 ++pos
6509 }
6510 discardTrailingNewline = false
6511 }
6512
6513 var lineLength = -1
6514 var fieldLength = -1
6515 var c
6516
6517 for (var i = pos; lineLength < 0 && i < length; ++i) {
6518 c = buf[i]
6519 if (c === colon) {
6520 if (fieldLength < 0) {
6521 fieldLength = i - pos
6522 }
6523 } else if (c === carriageReturn) {
6524 discardTrailingNewline = true
6525 lineLength = i - pos
6526 } else if (c === lineFeed) {
6527 lineLength = i - pos
6528 }
6529 }
6530
6531 if (lineLength < 0) {
6532 break
6533 }
6534
6535 parseEventStreamLine(buf, pos, fieldLength, lineLength)
6536
6537 pos += lineLength + 1
6538 }
6539
6540 if (pos === length) {
6541 buf = void 0
6542 } else if (pos > 0) {
6543 buf = buf.slice(pos)
6544 }
6545 })
6546 })
6547
6548 req.on('error', onConnectionClosed)
6549 if (req.setNoDelay) req.setNoDelay(true)
6550 req.end()
6551 }
6552
6553 connect()
6554
6555 function _emit () {
6556 if (self.listeners(arguments[0]).length > 0) {
6557 self.emit.apply(self, arguments)
6558 }
6559 }
6560
6561 this._close = function () {
6562 if (readyState === EventSource.CLOSED) return
6563 readyState = EventSource.CLOSED
6564 if (req.abort) req.abort()
6565 if (req.xhr && req.xhr.abort) req.xhr.abort()
6566 }
6567
6568 function parseEventStreamLine (buf, pos, fieldLength, lineLength) {
6569 if (lineLength === 0) {
6570 if (data.length > 0) {
6571 var type = eventName || 'message'
6572 _emit(type, new MessageEvent(type, {
6573 data: data.slice(0, -1), // remove trailing newline
6574 lastEventId: lastEventId,
6575 origin: original(url)
6576 }))
6577 data = ''
6578 }
6579 eventName = void 0
6580 } else if (fieldLength > 0) {
6581 var noValue = fieldLength < 0
6582 var step = 0
6583 var field = buf.slice(pos, pos + (noValue ? lineLength : fieldLength)).toString()
6584
6585 if (noValue) {
6586 step = lineLength
6587 } else if (buf[pos + fieldLength + 1] !== space) {
6588 step = fieldLength + 1
6589 } else {
6590 step = fieldLength + 2
6591 }
6592 pos += step
6593
6594 var valueLength = lineLength - step
6595 var value = buf.slice(pos, pos + valueLength).toString()
6596
6597 if (field === 'data') {
6598 data += value + '\n'
6599 } else if (field === 'event') {
6600 eventName = value
6601 } else if (field === 'id') {
6602 lastEventId = value
6603 } else if (field === 'retry') {
6604 var retry = parseInt(value, 10)
6605 if (!Number.isNaN(retry)) {
6606 self.reconnectInterval = retry
6607 }
6608 }
6609 }
6610 }
6611}
6612
6613module.exports = EventSource
6614
6615util.inherits(EventSource, events.EventEmitter)
6616EventSource.prototype.constructor = EventSource; // make stacktraces readable
6617
6618['open', 'error', 'message'].forEach(function (method) {
6619 Object.defineProperty(EventSource.prototype, 'on' + method, {
6620 /**
6621 * Returns the current listener
6622 *
6623 * @return {Mixed} the set function or undefined
6624 * @api private
6625 */
6626 get: function get () {
6627 var listener = this.listeners(method)[0]
6628 return listener ? (listener._listener ? listener._listener : listener) : undefined
6629 },
6630
6631 /**
6632 * Start listening for events
6633 *
6634 * @param {Function} listener the listener
6635 * @return {Mixed} the set function or undefined
6636 * @api private
6637 */
6638 set: function set (listener) {
6639 this.removeAllListeners(method)
6640 this.addEventListener(method, listener)
6641 }
6642 })
6643})
6644
6645/**
6646 * Ready states
6647 */
6648Object.defineProperty(EventSource, 'CONNECTING', {enumerable: true, value: 0})
6649Object.defineProperty(EventSource, 'OPEN', {enumerable: true, value: 1})
6650Object.defineProperty(EventSource, 'CLOSED', {enumerable: true, value: 2})
6651
6652EventSource.prototype.CONNECTING = 0
6653EventSource.prototype.OPEN = 1
6654EventSource.prototype.CLOSED = 2
6655
6656/**
6657 * Closes the connection, if one is made, and sets the readyState attribute to 2 (closed)
6658 *
6659 * @see https://developer.mozilla.org/en-US/docs/Web/API/EventSource/close
6660 * @api public
6661 */
6662EventSource.prototype.close = function () {
6663 this._close()
6664}
6665
6666/**
6667 * Emulates the W3C Browser based WebSocket interface using addEventListener.
6668 *
6669 * @param {String} type A string representing the event type to listen out for
6670 * @param {Function} listener callback
6671 * @see https://developer.mozilla.org/en/DOM/element.addEventListener
6672 * @see http://dev.w3.org/html5/websockets/#the-websocket-interface
6673 * @api public
6674 */
6675EventSource.prototype.addEventListener = function addEventListener (type, listener) {
6676 if (typeof listener === 'function') {
6677 // store a reference so we can return the original function again
6678 listener._listener = listener
6679 this.on(type, listener)
6680 }
6681}
6682
6683/**
6684 * Emulates the W3C Browser based WebSocket interface using removeEventListener.
6685 *
6686 * @param {String} type A string representing the event type to remove
6687 * @param {Function} listener callback
6688 * @see https://developer.mozilla.org/en/DOM/element.removeEventListener
6689 * @see http://dev.w3.org/html5/websockets/#the-websocket-interface
6690 * @api public
6691 */
6692EventSource.prototype.removeEventListener = function removeEventListener (type, listener) {
6693 if (typeof listener === 'function') {
6694 listener._listener = undefined
6695 this.removeListener(type, listener)
6696 }
6697}
6698
6699/**
6700 * W3C Event
6701 *
6702 * @see http://www.w3.org/TR/DOM-Level-3-Events/#interface-Event
6703 * @api private
6704 */
6705function Event (type, optionalProperties) {
6706 Object.defineProperty(this, 'type', { writable: false, value: type, enumerable: true })
6707 if (optionalProperties) {
6708 for (var f in optionalProperties) {
6709 if (optionalProperties.hasOwnProperty(f)) {
6710 Object.defineProperty(this, f, { writable: false, value: optionalProperties[f], enumerable: true })
6711 }
6712 }
6713 }
6714}
6715
6716/**
6717 * W3C MessageEvent
6718 *
6719 * @see http://www.w3.org/TR/webmessaging/#event-definitions
6720 * @api private
6721 */
6722function MessageEvent (type, eventInitDict) {
6723 Object.defineProperty(this, 'type', { writable: false, value: type, enumerable: true })
6724 for (var f in eventInitDict) {
6725 if (eventInitDict.hasOwnProperty(f)) {
6726 Object.defineProperty(this, f, { writable: false, value: eventInitDict[f], enumerable: true })
6727 }
6728 }
6729}
6730
6731/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1), __webpack_require__(2).Buffer))
6732
6733/***/ }),
6734/* 23 */
6735/***/ (function(module, exports, __webpack_require__) {
6736
6737"use strict";
6738
6739
6740exports.byteLength = byteLength
6741exports.toByteArray = toByteArray
6742exports.fromByteArray = fromByteArray
6743
6744var lookup = []
6745var revLookup = []
6746var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
6747
6748var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
6749for (var i = 0, len = code.length; i < len; ++i) {
6750 lookup[i] = code[i]
6751 revLookup[code.charCodeAt(i)] = i
6752}
6753
6754// Support decoding URL-safe base64 strings, as Node.js does.
6755// See: https://en.wikipedia.org/wiki/Base64#URL_applications
6756revLookup['-'.charCodeAt(0)] = 62
6757revLookup['_'.charCodeAt(0)] = 63
6758
6759function getLens (b64) {
6760 var len = b64.length
6761
6762 if (len % 4 > 0) {
6763 throw new Error('Invalid string. Length must be a multiple of 4')
6764 }
6765
6766 // Trim off extra bytes after placeholder bytes are found
6767 // See: https://github.com/beatgammit/base64-js/issues/42
6768 var validLen = b64.indexOf('=')
6769 if (validLen === -1) validLen = len
6770
6771 var placeHoldersLen = validLen === len
6772 ? 0
6773 : 4 - (validLen % 4)
6774
6775 return [validLen, placeHoldersLen]
6776}
6777
6778// base64 is 4/3 + up to two characters of the original data
6779function byteLength (b64) {
6780 var lens = getLens(b64)
6781 var validLen = lens[0]
6782 var placeHoldersLen = lens[1]
6783 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
6784}
6785
6786function _byteLength (b64, validLen, placeHoldersLen) {
6787 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
6788}
6789
6790function toByteArray (b64) {
6791 var tmp
6792 var lens = getLens(b64)
6793 var validLen = lens[0]
6794 var placeHoldersLen = lens[1]
6795
6796 var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
6797
6798 var curByte = 0
6799
6800 // if there are placeholders, only get up to the last complete 4 chars
6801 var len = placeHoldersLen > 0
6802 ? validLen - 4
6803 : validLen
6804
6805 for (var i = 0; i < len; i += 4) {
6806 tmp =
6807 (revLookup[b64.charCodeAt(i)] << 18) |
6808 (revLookup[b64.charCodeAt(i + 1)] << 12) |
6809 (revLookup[b64.charCodeAt(i + 2)] << 6) |
6810 revLookup[b64.charCodeAt(i + 3)]
6811 arr[curByte++] = (tmp >> 16) & 0xFF
6812 arr[curByte++] = (tmp >> 8) & 0xFF
6813 arr[curByte++] = tmp & 0xFF
6814 }
6815
6816 if (placeHoldersLen === 2) {
6817 tmp =
6818 (revLookup[b64.charCodeAt(i)] << 2) |
6819 (revLookup[b64.charCodeAt(i + 1)] >> 4)
6820 arr[curByte++] = tmp & 0xFF
6821 }
6822
6823 if (placeHoldersLen === 1) {
6824 tmp =
6825 (revLookup[b64.charCodeAt(i)] << 10) |
6826 (revLookup[b64.charCodeAt(i + 1)] << 4) |
6827 (revLookup[b64.charCodeAt(i + 2)] >> 2)
6828 arr[curByte++] = (tmp >> 8) & 0xFF
6829 arr[curByte++] = tmp & 0xFF
6830 }
6831
6832 return arr
6833}
6834
6835function tripletToBase64 (num) {
6836 return lookup[num >> 18 & 0x3F] +
6837 lookup[num >> 12 & 0x3F] +
6838 lookup[num >> 6 & 0x3F] +
6839 lookup[num & 0x3F]
6840}
6841
6842function encodeChunk (uint8, start, end) {
6843 var tmp
6844 var output = []
6845 for (var i = start; i < end; i += 3) {
6846 tmp =
6847 ((uint8[i] << 16) & 0xFF0000) +
6848 ((uint8[i + 1] << 8) & 0xFF00) +
6849 (uint8[i + 2] & 0xFF)
6850 output.push(tripletToBase64(tmp))
6851 }
6852 return output.join('')
6853}
6854
6855function fromByteArray (uint8) {
6856 var tmp
6857 var len = uint8.length
6858 var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
6859 var parts = []
6860 var maxChunkLength = 16383 // must be multiple of 3
6861
6862 // go through the array every three bytes, we'll deal with trailing stuff later
6863 for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
6864 parts.push(encodeChunk(
6865 uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
6866 ))
6867 }
6868
6869 // pad the end with zeros, but make sure to not forget the extra bytes
6870 if (extraBytes === 1) {
6871 tmp = uint8[len - 1]
6872 parts.push(
6873 lookup[tmp >> 2] +
6874 lookup[(tmp << 4) & 0x3F] +
6875 '=='
6876 )
6877 } else if (extraBytes === 2) {
6878 tmp = (uint8[len - 2] << 8) + uint8[len - 1]
6879 parts.push(
6880 lookup[tmp >> 10] +
6881 lookup[(tmp >> 4) & 0x3F] +
6882 lookup[(tmp << 2) & 0x3F] +
6883 '='
6884 )
6885 }
6886
6887 return parts.join('')
6888}
6889
6890
6891/***/ }),
6892/* 24 */
6893/***/ (function(module, exports) {
6894
6895exports.read = function (buffer, offset, isLE, mLen, nBytes) {
6896 var e, m
6897 var eLen = (nBytes * 8) - mLen - 1
6898 var eMax = (1 << eLen) - 1
6899 var eBias = eMax >> 1
6900 var nBits = -7
6901 var i = isLE ? (nBytes - 1) : 0
6902 var d = isLE ? -1 : 1
6903 var s = buffer[offset + i]
6904
6905 i += d
6906
6907 e = s & ((1 << (-nBits)) - 1)
6908 s >>= (-nBits)
6909 nBits += eLen
6910 for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
6911
6912 m = e & ((1 << (-nBits)) - 1)
6913 e >>= (-nBits)
6914 nBits += mLen
6915 for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
6916
6917 if (e === 0) {
6918 e = 1 - eBias
6919 } else if (e === eMax) {
6920 return m ? NaN : ((s ? -1 : 1) * Infinity)
6921 } else {
6922 m = m + Math.pow(2, mLen)
6923 e = e - eBias
6924 }
6925 return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
6926}
6927
6928exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
6929 var e, m, c
6930 var eLen = (nBytes * 8) - mLen - 1
6931 var eMax = (1 << eLen) - 1
6932 var eBias = eMax >> 1
6933 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
6934 var i = isLE ? 0 : (nBytes - 1)
6935 var d = isLE ? 1 : -1
6936 var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
6937
6938 value = Math.abs(value)
6939
6940 if (isNaN(value) || value === Infinity) {
6941 m = isNaN(value) ? 1 : 0
6942 e = eMax
6943 } else {
6944 e = Math.floor(Math.log(value) / Math.LN2)
6945 if (value * (c = Math.pow(2, -e)) < 1) {
6946 e--
6947 c *= 2
6948 }
6949 if (e + eBias >= 1) {
6950 value += rt / c
6951 } else {
6952 value += rt * Math.pow(2, 1 - eBias)
6953 }
6954 if (value * c >= 2) {
6955 e++
6956 c /= 2
6957 }
6958
6959 if (e + eBias >= eMax) {
6960 m = 0
6961 e = eMax
6962 } else if (e + eBias >= 1) {
6963 m = ((value * c) - 1) * Math.pow(2, mLen)
6964 e = e + eBias
6965 } else {
6966 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
6967 e = 0
6968 }
6969 }
6970
6971 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
6972
6973 e = (e << mLen) | m
6974 eLen += mLen
6975 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
6976
6977 buffer[offset + i - d] |= s * 128
6978}
6979
6980
6981/***/ }),
6982/* 25 */
6983/***/ (function(module, exports) {
6984
6985var toString = {}.toString;
6986
6987module.exports = Array.isArray || function (arr) {
6988 return toString.call(arr) == '[object Array]';
6989};
6990
6991
6992/***/ }),
6993/* 26 */
6994/***/ (function(module, exports, __webpack_require__) {
6995
6996"use strict";
6997
6998
6999var parse = __webpack_require__(27);
7000
7001/**
7002 * Transform an URL to a valid origin value.
7003 *
7004 * @param {String|Object} url URL to transform to it's origin.
7005 * @returns {String} The origin.
7006 * @api public
7007 */
7008function origin(url) {
7009 if ('string' === typeof url) url = parse(url);
7010
7011 //
7012 // 6.2. ASCII Serialization of an Origin
7013 // http://tools.ietf.org/html/rfc6454#section-6.2
7014 //
7015 if (!url.protocol || !url.hostname) return 'null';
7016
7017 //
7018 // 4. Origin of a URI
7019 // http://tools.ietf.org/html/rfc6454#section-4
7020 //
7021 // States that url.scheme, host should be converted to lower case. This also
7022 // makes it easier to match origins as everything is just lower case.
7023 //
7024 return (url.protocol +'//'+ url.host).toLowerCase();
7025}
7026
7027/**
7028 * Check if the origins are the same.
7029 *
7030 * @param {String} a URL or origin of a.
7031 * @param {String} b URL or origin of b.
7032 * @returns {Boolean}
7033 * @api public
7034 */
7035origin.same = function same(a, b) {
7036 return origin(a) === origin(b);
7037};
7038
7039//
7040// Expose the origin
7041//
7042module.exports = origin;
7043
7044
7045/***/ }),
7046/* 27 */
7047/***/ (function(module, exports, __webpack_require__) {
7048
7049"use strict";
7050/* WEBPACK VAR INJECTION */(function(global) {
7051
7052var required = __webpack_require__(28)
7053 , qs = __webpack_require__(29)
7054 , protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i
7055 , slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//;
7056
7057/**
7058 * These are the parse rules for the URL parser, it informs the parser
7059 * about:
7060 *
7061 * 0. The char it Needs to parse, if it's a string it should be done using
7062 * indexOf, RegExp using exec and NaN means set as current value.
7063 * 1. The property we should set when parsing this value.
7064 * 2. Indication if it's backwards or forward parsing, when set as number it's
7065 * the value of extra chars that should be split off.
7066 * 3. Inherit from location if non existing in the parser.
7067 * 4. `toLowerCase` the resulting value.
7068 */
7069var rules = [
7070 ['#', 'hash'], // Extract from the back.
7071 ['?', 'query'], // Extract from the back.
7072 function sanitize(address) { // Sanitize what is left of the address
7073 return address.replace('\\', '/');
7074 },
7075 ['/', 'pathname'], // Extract from the back.
7076 ['@', 'auth', 1], // Extract from the front.
7077 [NaN, 'host', undefined, 1, 1], // Set left over value.
7078 [/:(\d+)$/, 'port', undefined, 1], // RegExp the back.
7079 [NaN, 'hostname', undefined, 1, 1] // Set left over.
7080];
7081
7082/**
7083 * These properties should not be copied or inherited from. This is only needed
7084 * for all non blob URL's as a blob URL does not include a hash, only the
7085 * origin.
7086 *
7087 * @type {Object}
7088 * @private
7089 */
7090var ignore = { hash: 1, query: 1 };
7091
7092/**
7093 * The location object differs when your code is loaded through a normal page,
7094 * Worker or through a worker using a blob. And with the blobble begins the
7095 * trouble as the location object will contain the URL of the blob, not the
7096 * location of the page where our code is loaded in. The actual origin is
7097 * encoded in the `pathname` so we can thankfully generate a good "default"
7098 * location from it so we can generate proper relative URL's again.
7099 *
7100 * @param {Object|String} loc Optional default location object.
7101 * @returns {Object} lolcation object.
7102 * @public
7103 */
7104function lolcation(loc) {
7105 var location = global && global.location || {};
7106 loc = loc || location;
7107
7108 var finaldestination = {}
7109 , type = typeof loc
7110 , key;
7111
7112 if ('blob:' === loc.protocol) {
7113 finaldestination = new Url(unescape(loc.pathname), {});
7114 } else if ('string' === type) {
7115 finaldestination = new Url(loc, {});
7116 for (key in ignore) delete finaldestination[key];
7117 } else if ('object' === type) {
7118 for (key in loc) {
7119 if (key in ignore) continue;
7120 finaldestination[key] = loc[key];
7121 }
7122
7123 if (finaldestination.slashes === undefined) {
7124 finaldestination.slashes = slashes.test(loc.href);
7125 }
7126 }
7127
7128 return finaldestination;
7129}
7130
7131/**
7132 * @typedef ProtocolExtract
7133 * @type Object
7134 * @property {String} protocol Protocol matched in the URL, in lowercase.
7135 * @property {Boolean} slashes `true` if protocol is followed by "//", else `false`.
7136 * @property {String} rest Rest of the URL that is not part of the protocol.
7137 */
7138
7139/**
7140 * Extract protocol information from a URL with/without double slash ("//").
7141 *
7142 * @param {String} address URL we want to extract from.
7143 * @return {ProtocolExtract} Extracted information.
7144 * @private
7145 */
7146function extractProtocol(address) {
7147 var match = protocolre.exec(address);
7148
7149 return {
7150 protocol: match[1] ? match[1].toLowerCase() : '',
7151 slashes: !!match[2],
7152 rest: match[3]
7153 };
7154}
7155
7156/**
7157 * Resolve a relative URL pathname against a base URL pathname.
7158 *
7159 * @param {String} relative Pathname of the relative URL.
7160 * @param {String} base Pathname of the base URL.
7161 * @return {String} Resolved pathname.
7162 * @private
7163 */
7164function resolve(relative, base) {
7165 var path = (base || '/').split('/').slice(0, -1).concat(relative.split('/'))
7166 , i = path.length
7167 , last = path[i - 1]
7168 , unshift = false
7169 , up = 0;
7170
7171 while (i--) {
7172 if (path[i] === '.') {
7173 path.splice(i, 1);
7174 } else if (path[i] === '..') {
7175 path.splice(i, 1);
7176 up++;
7177 } else if (up) {
7178 if (i === 0) unshift = true;
7179 path.splice(i, 1);
7180 up--;
7181 }
7182 }
7183
7184 if (unshift) path.unshift('');
7185 if (last === '.' || last === '..') path.push('');
7186
7187 return path.join('/');
7188}
7189
7190/**
7191 * The actual URL instance. Instead of returning an object we've opted-in to
7192 * create an actual constructor as it's much more memory efficient and
7193 * faster and it pleases my OCD.
7194 *
7195 * It is worth noting that we should not use `URL` as class name to prevent
7196 * clashes with the global URL instance that got introduced in browsers.
7197 *
7198 * @constructor
7199 * @param {String} address URL we want to parse.
7200 * @param {Object|String} location Location defaults for relative paths.
7201 * @param {Boolean|Function} parser Parser for the query string.
7202 * @private
7203 */
7204function Url(address, location, parser) {
7205 if (!(this instanceof Url)) {
7206 return new Url(address, location, parser);
7207 }
7208
7209 var relative, extracted, parse, instruction, index, key
7210 , instructions = rules.slice()
7211 , type = typeof location
7212 , url = this
7213 , i = 0;
7214
7215 //
7216 // The following if statements allows this module two have compatibility with
7217 // 2 different API:
7218 //
7219 // 1. Node.js's `url.parse` api which accepts a URL, boolean as arguments
7220 // where the boolean indicates that the query string should also be parsed.
7221 //
7222 // 2. The `URL` interface of the browser which accepts a URL, object as
7223 // arguments. The supplied object will be used as default values / fall-back
7224 // for relative paths.
7225 //
7226 if ('object' !== type && 'string' !== type) {
7227 parser = location;
7228 location = null;
7229 }
7230
7231 if (parser && 'function' !== typeof parser) parser = qs.parse;
7232
7233 location = lolcation(location);
7234
7235 //
7236 // Extract protocol information before running the instructions.
7237 //
7238 extracted = extractProtocol(address || '');
7239 relative = !extracted.protocol && !extracted.slashes;
7240 url.slashes = extracted.slashes || relative && location.slashes;
7241 url.protocol = extracted.protocol || location.protocol || '';
7242 address = extracted.rest;
7243
7244 //
7245 // When the authority component is absent the URL starts with a path
7246 // component.
7247 //
7248 if (!extracted.slashes) instructions[3] = [/(.*)/, 'pathname'];
7249
7250 for (; i < instructions.length; i++) {
7251 instruction = instructions[i];
7252
7253 if (typeof instruction === 'function') {
7254 address = instruction(address);
7255 continue;
7256 }
7257
7258 parse = instruction[0];
7259 key = instruction[1];
7260
7261 if (parse !== parse) {
7262 url[key] = address;
7263 } else if ('string' === typeof parse) {
7264 if (~(index = address.indexOf(parse))) {
7265 if ('number' === typeof instruction[2]) {
7266 url[key] = address.slice(0, index);
7267 address = address.slice(index + instruction[2]);
7268 } else {
7269 url[key] = address.slice(index);
7270 address = address.slice(0, index);
7271 }
7272 }
7273 } else if ((index = parse.exec(address))) {
7274 url[key] = index[1];
7275 address = address.slice(0, index.index);
7276 }
7277
7278 url[key] = url[key] || (
7279 relative && instruction[3] ? location[key] || '' : ''
7280 );
7281
7282 //
7283 // Hostname, host and protocol should be lowercased so they can be used to
7284 // create a proper `origin`.
7285 //
7286 if (instruction[4]) url[key] = url[key].toLowerCase();
7287 }
7288
7289 //
7290 // Also parse the supplied query string in to an object. If we're supplied
7291 // with a custom parser as function use that instead of the default build-in
7292 // parser.
7293 //
7294 if (parser) url.query = parser(url.query);
7295
7296 //
7297 // If the URL is relative, resolve the pathname against the base URL.
7298 //
7299 if (
7300 relative
7301 && location.slashes
7302 && url.pathname.charAt(0) !== '/'
7303 && (url.pathname !== '' || location.pathname !== '')
7304 ) {
7305 url.pathname = resolve(url.pathname, location.pathname);
7306 }
7307
7308 //
7309 // We should not add port numbers if they are already the default port number
7310 // for a given protocol. As the host also contains the port number we're going
7311 // override it with the hostname which contains no port number.
7312 //
7313 if (!required(url.port, url.protocol)) {
7314 url.host = url.hostname;
7315 url.port = '';
7316 }
7317
7318 //
7319 // Parse down the `auth` for the username and password.
7320 //
7321 url.username = url.password = '';
7322 if (url.auth) {
7323 instruction = url.auth.split(':');
7324 url.username = instruction[0] || '';
7325 url.password = instruction[1] || '';
7326 }
7327
7328 url.origin = url.protocol && url.host && url.protocol !== 'file:'
7329 ? url.protocol +'//'+ url.host
7330 : 'null';
7331
7332 //
7333 // The href is just the compiled result.
7334 //
7335 url.href = url.toString();
7336}
7337
7338/**
7339 * This is convenience method for changing properties in the URL instance to
7340 * insure that they all propagate correctly.
7341 *
7342 * @param {String} part Property we need to adjust.
7343 * @param {Mixed} value The newly assigned value.
7344 * @param {Boolean|Function} fn When setting the query, it will be the function
7345 * used to parse the query.
7346 * When setting the protocol, double slash will be
7347 * removed from the final url if it is true.
7348 * @returns {URL} URL instance for chaining.
7349 * @public
7350 */
7351function set(part, value, fn) {
7352 var url = this;
7353
7354 switch (part) {
7355 case 'query':
7356 if ('string' === typeof value && value.length) {
7357 value = (fn || qs.parse)(value);
7358 }
7359
7360 url[part] = value;
7361 break;
7362
7363 case 'port':
7364 url[part] = value;
7365
7366 if (!required(value, url.protocol)) {
7367 url.host = url.hostname;
7368 url[part] = '';
7369 } else if (value) {
7370 url.host = url.hostname +':'+ value;
7371 }
7372
7373 break;
7374
7375 case 'hostname':
7376 url[part] = value;
7377
7378 if (url.port) value += ':'+ url.port;
7379 url.host = value;
7380 break;
7381
7382 case 'host':
7383 url[part] = value;
7384
7385 if (/:\d+$/.test(value)) {
7386 value = value.split(':');
7387 url.port = value.pop();
7388 url.hostname = value.join(':');
7389 } else {
7390 url.hostname = value;
7391 url.port = '';
7392 }
7393
7394 break;
7395
7396 case 'protocol':
7397 url.protocol = value.toLowerCase();
7398 url.slashes = !fn;
7399 break;
7400
7401 case 'pathname':
7402 case 'hash':
7403 if (value) {
7404 var char = part === 'pathname' ? '/' : '#';
7405 url[part] = value.charAt(0) !== char ? char + value : value;
7406 } else {
7407 url[part] = value;
7408 }
7409 break;
7410
7411 default:
7412 url[part] = value;
7413 }
7414
7415 for (var i = 0; i < rules.length; i++) {
7416 var ins = rules[i];
7417
7418 if (ins[4]) url[ins[1]] = url[ins[1]].toLowerCase();
7419 }
7420
7421 url.origin = url.protocol && url.host && url.protocol !== 'file:'
7422 ? url.protocol +'//'+ url.host
7423 : 'null';
7424
7425 url.href = url.toString();
7426
7427 return url;
7428}
7429
7430/**
7431 * Transform the properties back in to a valid and full URL string.
7432 *
7433 * @param {Function} stringify Optional query stringify function.
7434 * @returns {String} Compiled version of the URL.
7435 * @public
7436 */
7437function toString(stringify) {
7438 if (!stringify || 'function' !== typeof stringify) stringify = qs.stringify;
7439
7440 var query
7441 , url = this
7442 , protocol = url.protocol;
7443
7444 if (protocol && protocol.charAt(protocol.length - 1) !== ':') protocol += ':';
7445
7446 var result = protocol + (url.slashes ? '//' : '');
7447
7448 if (url.username) {
7449 result += url.username;
7450 if (url.password) result += ':'+ url.password;
7451 result += '@';
7452 }
7453
7454 result += url.host + url.pathname;
7455
7456 query = 'object' === typeof url.query ? stringify(url.query) : url.query;
7457 if (query) result += '?' !== query.charAt(0) ? '?'+ query : query;
7458
7459 if (url.hash) result += url.hash;
7460
7461 return result;
7462}
7463
7464Url.prototype = { set: set, toString: toString };
7465
7466//
7467// Expose the URL parser and some additional properties that might be useful for
7468// others or testing.
7469//
7470Url.extractProtocol = extractProtocol;
7471Url.location = lolcation;
7472Url.qs = qs;
7473
7474module.exports = Url;
7475
7476/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
7477
7478/***/ }),
7479/* 28 */
7480/***/ (function(module, exports, __webpack_require__) {
7481
7482"use strict";
7483
7484
7485/**
7486 * Check if we're required to add a port number.
7487 *
7488 * @see https://url.spec.whatwg.org/#default-port
7489 * @param {Number|String} port Port number we need to check
7490 * @param {String} protocol Protocol we need to check against.
7491 * @returns {Boolean} Is it a default port for the given protocol
7492 * @api private
7493 */
7494module.exports = function required(port, protocol) {
7495 protocol = protocol.split(':')[0];
7496 port = +port;
7497
7498 if (!port) return false;
7499
7500 switch (protocol) {
7501 case 'http':
7502 case 'ws':
7503 return port !== 80;
7504
7505 case 'https':
7506 case 'wss':
7507 return port !== 443;
7508
7509 case 'ftp':
7510 return port !== 21;
7511
7512 case 'gopher':
7513 return port !== 70;
7514
7515 case 'file':
7516 return false;
7517 }
7518
7519 return port !== 0;
7520};
7521
7522
7523/***/ }),
7524/* 29 */
7525/***/ (function(module, exports, __webpack_require__) {
7526
7527"use strict";
7528
7529
7530var has = Object.prototype.hasOwnProperty;
7531
7532/**
7533 * Decode a URI encoded string.
7534 *
7535 * @param {String} input The URI encoded string.
7536 * @returns {String} The decoded string.
7537 * @api private
7538 */
7539function decode(input) {
7540 return decodeURIComponent(input.replace(/\+/g, ' '));
7541}
7542
7543/**
7544 * Simple query string parser.
7545 *
7546 * @param {String} query The query string that needs to be parsed.
7547 * @returns {Object}
7548 * @api public
7549 */
7550function querystring(query) {
7551 var parser = /([^=?&]+)=?([^&]*)/g
7552 , result = {}
7553 , part;
7554
7555 while (part = parser.exec(query)) {
7556 var key = decode(part[1])
7557 , value = decode(part[2]);
7558
7559 //
7560 // Prevent overriding of existing properties. This ensures that build-in
7561 // methods like `toString` or __proto__ are not overriden by malicious
7562 // querystrings.
7563 //
7564 if (key in result) continue;
7565 result[key] = value;
7566 }
7567
7568 return result;
7569}
7570
7571/**
7572 * Transform a query string to an object.
7573 *
7574 * @param {Object} obj Object that should be transformed.
7575 * @param {String} prefix Optional prefix.
7576 * @returns {String}
7577 * @api public
7578 */
7579function querystringify(obj, prefix) {
7580 prefix = prefix || '';
7581
7582 var pairs = [];
7583
7584 //
7585 // Optionally prefix with a '?' if needed
7586 //
7587 if ('string' !== typeof prefix) prefix = '?';
7588
7589 for (var key in obj) {
7590 if (has.call(obj, key)) {
7591 pairs.push(encodeURIComponent(key) +'='+ encodeURIComponent(obj[key]));
7592 }
7593 }
7594
7595 return pairs.length ? prefix + pairs.join('&') : '';
7596}
7597
7598//
7599// Expose the module.
7600//
7601exports.stringify = querystringify;
7602exports.parse = querystring;
7603
7604
7605/***/ }),
7606/* 30 */
7607/***/ (function(module, exports, __webpack_require__) {
7608
7609/* WEBPACK VAR INJECTION */(function(module, global) {var __WEBPACK_AMD_DEFINE_RESULT__;/*! https://mths.be/punycode v1.4.1 by @mathias */
7610;(function(root) {
7611
7612 /** Detect free variables */
7613 var freeExports = typeof exports == 'object' && exports &&
7614 !exports.nodeType && exports;
7615 var freeModule = typeof module == 'object' && module &&
7616 !module.nodeType && module;
7617 var freeGlobal = typeof global == 'object' && global;
7618 if (
7619 freeGlobal.global === freeGlobal ||
7620 freeGlobal.window === freeGlobal ||
7621 freeGlobal.self === freeGlobal
7622 ) {
7623 root = freeGlobal;
7624 }
7625
7626 /**
7627 * The `punycode` object.
7628 * @name punycode
7629 * @type Object
7630 */
7631 var punycode,
7632
7633 /** Highest positive signed 32-bit float value */
7634 maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
7635
7636 /** Bootstring parameters */
7637 base = 36,
7638 tMin = 1,
7639 tMax = 26,
7640 skew = 38,
7641 damp = 700,
7642 initialBias = 72,
7643 initialN = 128, // 0x80
7644 delimiter = '-', // '\x2D'
7645
7646 /** Regular expressions */
7647 regexPunycode = /^xn--/,
7648 regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
7649 regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
7650
7651 /** Error messages */
7652 errors = {
7653 'overflow': 'Overflow: input needs wider integers to process',
7654 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
7655 'invalid-input': 'Invalid input'
7656 },
7657
7658 /** Convenience shortcuts */
7659 baseMinusTMin = base - tMin,
7660 floor = Math.floor,
7661 stringFromCharCode = String.fromCharCode,
7662
7663 /** Temporary variable */
7664 key;
7665
7666 /*--------------------------------------------------------------------------*/
7667
7668 /**
7669 * A generic error utility function.
7670 * @private
7671 * @param {String} type The error type.
7672 * @returns {Error} Throws a `RangeError` with the applicable error message.
7673 */
7674 function error(type) {
7675 throw new RangeError(errors[type]);
7676 }
7677
7678 /**
7679 * A generic `Array#map` utility function.
7680 * @private
7681 * @param {Array} array The array to iterate over.
7682 * @param {Function} callback The function that gets called for every array
7683 * item.
7684 * @returns {Array} A new array of values returned by the callback function.
7685 */
7686 function map(array, fn) {
7687 var length = array.length;
7688 var result = [];
7689 while (length--) {
7690 result[length] = fn(array[length]);
7691 }
7692 return result;
7693 }
7694
7695 /**
7696 * A simple `Array#map`-like wrapper to work with domain name strings or email
7697 * addresses.
7698 * @private
7699 * @param {String} domain The domain name or email address.
7700 * @param {Function} callback The function that gets called for every
7701 * character.
7702 * @returns {Array} A new string of characters returned by the callback
7703 * function.
7704 */
7705 function mapDomain(string, fn) {
7706 var parts = string.split('@');
7707 var result = '';
7708 if (parts.length > 1) {
7709 // In email addresses, only the domain name should be punycoded. Leave
7710 // the local part (i.e. everything up to `@`) intact.
7711 result = parts[0] + '@';
7712 string = parts[1];
7713 }
7714 // Avoid `split(regex)` for IE8 compatibility. See #17.
7715 string = string.replace(regexSeparators, '\x2E');
7716 var labels = string.split('.');
7717 var encoded = map(labels, fn).join('.');
7718 return result + encoded;
7719 }
7720
7721 /**
7722 * Creates an array containing the numeric code points of each Unicode
7723 * character in the string. While JavaScript uses UCS-2 internally,
7724 * this function will convert a pair of surrogate halves (each of which
7725 * UCS-2 exposes as separate characters) into a single code point,
7726 * matching UTF-16.
7727 * @see `punycode.ucs2.encode`
7728 * @see <https://mathiasbynens.be/notes/javascript-encoding>
7729 * @memberOf punycode.ucs2
7730 * @name decode
7731 * @param {String} string The Unicode input string (UCS-2).
7732 * @returns {Array} The new array of code points.
7733 */
7734 function ucs2decode(string) {
7735 var output = [],
7736 counter = 0,
7737 length = string.length,
7738 value,
7739 extra;
7740 while (counter < length) {
7741 value = string.charCodeAt(counter++);
7742 if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
7743 // high surrogate, and there is a next character
7744 extra = string.charCodeAt(counter++);
7745 if ((extra & 0xFC00) == 0xDC00) { // low surrogate
7746 output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
7747 } else {
7748 // unmatched surrogate; only append this code unit, in case the next
7749 // code unit is the high surrogate of a surrogate pair
7750 output.push(value);
7751 counter--;
7752 }
7753 } else {
7754 output.push(value);
7755 }
7756 }
7757 return output;
7758 }
7759
7760 /**
7761 * Creates a string based on an array of numeric code points.
7762 * @see `punycode.ucs2.decode`
7763 * @memberOf punycode.ucs2
7764 * @name encode
7765 * @param {Array} codePoints The array of numeric code points.
7766 * @returns {String} The new Unicode string (UCS-2).
7767 */
7768 function ucs2encode(array) {
7769 return map(array, function(value) {
7770 var output = '';
7771 if (value > 0xFFFF) {
7772 value -= 0x10000;
7773 output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
7774 value = 0xDC00 | value & 0x3FF;
7775 }
7776 output += stringFromCharCode(value);
7777 return output;
7778 }).join('');
7779 }
7780
7781 /**
7782 * Converts a basic code point into a digit/integer.
7783 * @see `digitToBasic()`
7784 * @private
7785 * @param {Number} codePoint The basic numeric code point value.
7786 * @returns {Number} The numeric value of a basic code point (for use in
7787 * representing integers) in the range `0` to `base - 1`, or `base` if
7788 * the code point does not represent a value.
7789 */
7790 function basicToDigit(codePoint) {
7791 if (codePoint - 48 < 10) {
7792 return codePoint - 22;
7793 }
7794 if (codePoint - 65 < 26) {
7795 return codePoint - 65;
7796 }
7797 if (codePoint - 97 < 26) {
7798 return codePoint - 97;
7799 }
7800 return base;
7801 }
7802
7803 /**
7804 * Converts a digit/integer into a basic code point.
7805 * @see `basicToDigit()`
7806 * @private
7807 * @param {Number} digit The numeric value of a basic code point.
7808 * @returns {Number} The basic code point whose value (when used for
7809 * representing integers) is `digit`, which needs to be in the range
7810 * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
7811 * used; else, the lowercase form is used. The behavior is undefined
7812 * if `flag` is non-zero and `digit` has no uppercase form.
7813 */
7814 function digitToBasic(digit, flag) {
7815 // 0..25 map to ASCII a..z or A..Z
7816 // 26..35 map to ASCII 0..9
7817 return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
7818 }
7819
7820 /**
7821 * Bias adaptation function as per section 3.4 of RFC 3492.
7822 * https://tools.ietf.org/html/rfc3492#section-3.4
7823 * @private
7824 */
7825 function adapt(delta, numPoints, firstTime) {
7826 var k = 0;
7827 delta = firstTime ? floor(delta / damp) : delta >> 1;
7828 delta += floor(delta / numPoints);
7829 for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
7830 delta = floor(delta / baseMinusTMin);
7831 }
7832 return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
7833 }
7834
7835 /**
7836 * Converts a Punycode string of ASCII-only symbols to a string of Unicode
7837 * symbols.
7838 * @memberOf punycode
7839 * @param {String} input The Punycode string of ASCII-only symbols.
7840 * @returns {String} The resulting string of Unicode symbols.
7841 */
7842 function decode(input) {
7843 // Don't use UCS-2
7844 var output = [],
7845 inputLength = input.length,
7846 out,
7847 i = 0,
7848 n = initialN,
7849 bias = initialBias,
7850 basic,
7851 j,
7852 index,
7853 oldi,
7854 w,
7855 k,
7856 digit,
7857 t,
7858 /** Cached calculation results */
7859 baseMinusT;
7860
7861 // Handle the basic code points: let `basic` be the number of input code
7862 // points before the last delimiter, or `0` if there is none, then copy
7863 // the first basic code points to the output.
7864
7865 basic = input.lastIndexOf(delimiter);
7866 if (basic < 0) {
7867 basic = 0;
7868 }
7869
7870 for (j = 0; j < basic; ++j) {
7871 // if it's not a basic code point
7872 if (input.charCodeAt(j) >= 0x80) {
7873 error('not-basic');
7874 }
7875 output.push(input.charCodeAt(j));
7876 }
7877
7878 // Main decoding loop: start just after the last delimiter if any basic code
7879 // points were copied; start at the beginning otherwise.
7880
7881 for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
7882
7883 // `index` is the index of the next character to be consumed.
7884 // Decode a generalized variable-length integer into `delta`,
7885 // which gets added to `i`. The overflow checking is easier
7886 // if we increase `i` as we go, then subtract off its starting
7887 // value at the end to obtain `delta`.
7888 for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
7889
7890 if (index >= inputLength) {
7891 error('invalid-input');
7892 }
7893
7894 digit = basicToDigit(input.charCodeAt(index++));
7895
7896 if (digit >= base || digit > floor((maxInt - i) / w)) {
7897 error('overflow');
7898 }
7899
7900 i += digit * w;
7901 t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
7902
7903 if (digit < t) {
7904 break;
7905 }
7906
7907 baseMinusT = base - t;
7908 if (w > floor(maxInt / baseMinusT)) {
7909 error('overflow');
7910 }
7911
7912 w *= baseMinusT;
7913
7914 }
7915
7916 out = output.length + 1;
7917 bias = adapt(i - oldi, out, oldi == 0);
7918
7919 // `i` was supposed to wrap around from `out` to `0`,
7920 // incrementing `n` each time, so we'll fix that now:
7921 if (floor(i / out) > maxInt - n) {
7922 error('overflow');
7923 }
7924
7925 n += floor(i / out);
7926 i %= out;
7927
7928 // Insert `n` at position `i` of the output
7929 output.splice(i++, 0, n);
7930
7931 }
7932
7933 return ucs2encode(output);
7934 }
7935
7936 /**
7937 * Converts a string of Unicode symbols (e.g. a domain name label) to a
7938 * Punycode string of ASCII-only symbols.
7939 * @memberOf punycode
7940 * @param {String} input The string of Unicode symbols.
7941 * @returns {String} The resulting Punycode string of ASCII-only symbols.
7942 */
7943 function encode(input) {
7944 var n,
7945 delta,
7946 handledCPCount,
7947 basicLength,
7948 bias,
7949 j,
7950 m,
7951 q,
7952 k,
7953 t,
7954 currentValue,
7955 output = [],
7956 /** `inputLength` will hold the number of code points in `input`. */
7957 inputLength,
7958 /** Cached calculation results */
7959 handledCPCountPlusOne,
7960 baseMinusT,
7961 qMinusT;
7962
7963 // Convert the input in UCS-2 to Unicode
7964 input = ucs2decode(input);
7965
7966 // Cache the length
7967 inputLength = input.length;
7968
7969 // Initialize the state
7970 n = initialN;
7971 delta = 0;
7972 bias = initialBias;
7973
7974 // Handle the basic code points
7975 for (j = 0; j < inputLength; ++j) {
7976 currentValue = input[j];
7977 if (currentValue < 0x80) {
7978 output.push(stringFromCharCode(currentValue));
7979 }
7980 }
7981
7982 handledCPCount = basicLength = output.length;
7983
7984 // `handledCPCount` is the number of code points that have been handled;
7985 // `basicLength` is the number of basic code points.
7986
7987 // Finish the basic string - if it is not empty - with a delimiter
7988 if (basicLength) {
7989 output.push(delimiter);
7990 }
7991
7992 // Main encoding loop:
7993 while (handledCPCount < inputLength) {
7994
7995 // All non-basic code points < n have been handled already. Find the next
7996 // larger one:
7997 for (m = maxInt, j = 0; j < inputLength; ++j) {
7998 currentValue = input[j];
7999 if (currentValue >= n && currentValue < m) {
8000 m = currentValue;
8001 }
8002 }
8003
8004 // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
8005 // but guard against overflow
8006 handledCPCountPlusOne = handledCPCount + 1;
8007 if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
8008 error('overflow');
8009 }
8010
8011 delta += (m - n) * handledCPCountPlusOne;
8012 n = m;
8013
8014 for (j = 0; j < inputLength; ++j) {
8015 currentValue = input[j];
8016
8017 if (currentValue < n && ++delta > maxInt) {
8018 error('overflow');
8019 }
8020
8021 if (currentValue == n) {
8022 // Represent delta as a generalized variable-length integer
8023 for (q = delta, k = base; /* no condition */; k += base) {
8024 t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
8025 if (q < t) {
8026 break;
8027 }
8028 qMinusT = q - t;
8029 baseMinusT = base - t;
8030 output.push(
8031 stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
8032 );
8033 q = floor(qMinusT / baseMinusT);
8034 }
8035
8036 output.push(stringFromCharCode(digitToBasic(q, 0)));
8037 bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
8038 delta = 0;
8039 ++handledCPCount;
8040 }
8041 }
8042
8043 ++delta;
8044 ++n;
8045
8046 }
8047 return output.join('');
8048 }
8049
8050 /**
8051 * Converts a Punycode string representing a domain name or an email address
8052 * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
8053 * it doesn't matter if you call it on a string that has already been
8054 * converted to Unicode.
8055 * @memberOf punycode
8056 * @param {String} input The Punycoded domain name or email address to
8057 * convert to Unicode.
8058 * @returns {String} The Unicode representation of the given Punycode
8059 * string.
8060 */
8061 function toUnicode(input) {
8062 return mapDomain(input, function(string) {
8063 return regexPunycode.test(string)
8064 ? decode(string.slice(4).toLowerCase())
8065 : string;
8066 });
8067 }
8068
8069 /**
8070 * Converts a Unicode string representing a domain name or an email address to
8071 * Punycode. Only the non-ASCII parts of the domain name will be converted,
8072 * i.e. it doesn't matter if you call it with a domain that's already in
8073 * ASCII.
8074 * @memberOf punycode
8075 * @param {String} input The domain name or email address to convert, as a
8076 * Unicode string.
8077 * @returns {String} The Punycode representation of the given domain name or
8078 * email address.
8079 */
8080 function toASCII(input) {
8081 return mapDomain(input, function(string) {
8082 return regexNonASCII.test(string)
8083 ? 'xn--' + encode(string)
8084 : string;
8085 });
8086 }
8087
8088 /*--------------------------------------------------------------------------*/
8089
8090 /** Define the public API */
8091 punycode = {
8092 /**
8093 * A string representing the current Punycode.js version number.
8094 * @memberOf punycode
8095 * @type String
8096 */
8097 'version': '1.4.1',
8098 /**
8099 * An object of methods to convert from JavaScript's internal character
8100 * representation (UCS-2) to Unicode code points, and back.
8101 * @see <https://mathiasbynens.be/notes/javascript-encoding>
8102 * @memberOf punycode
8103 * @type Object
8104 */
8105 'ucs2': {
8106 'decode': ucs2decode,
8107 'encode': ucs2encode
8108 },
8109 'decode': decode,
8110 'encode': encode,
8111 'toASCII': toASCII,
8112 'toUnicode': toUnicode
8113 };
8114
8115 /** Expose `punycode` */
8116 // Some AMD build optimizers, like r.js, check for specific condition patterns
8117 // like the following:
8118 if (
8119 true
8120 ) {
8121 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
8122 return punycode;
8123 }).call(exports, __webpack_require__, exports, module),
8124 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
8125 } else if (freeExports && freeModule) {
8126 if (module.exports == freeExports) {
8127 // in Node.js, io.js, or RingoJS v0.8.0+
8128 freeModule.exports = punycode;
8129 } else {
8130 // in Narwhal or RingoJS v0.7.0-
8131 for (key in punycode) {
8132 punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
8133 }
8134 }
8135 } else {
8136 // in Rhino or a web browser
8137 root.punycode = punycode;
8138 }
8139
8140}(this));
8141
8142/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(31)(module), __webpack_require__(0)))
8143
8144/***/ }),
8145/* 31 */
8146/***/ (function(module, exports) {
8147
8148module.exports = function(module) {
8149 if(!module.webpackPolyfill) {
8150 module.deprecate = function() {};
8151 module.paths = [];
8152 // module.parent = undefined by default
8153 if(!module.children) module.children = [];
8154 Object.defineProperty(module, "loaded", {
8155 enumerable: true,
8156 get: function() {
8157 return module.l;
8158 }
8159 });
8160 Object.defineProperty(module, "id", {
8161 enumerable: true,
8162 get: function() {
8163 return module.i;
8164 }
8165 });
8166 module.webpackPolyfill = 1;
8167 }
8168 return module;
8169};
8170
8171
8172/***/ }),
8173/* 32 */
8174/***/ (function(module, exports, __webpack_require__) {
8175
8176"use strict";
8177
8178
8179module.exports = {
8180 isString: function(arg) {
8181 return typeof(arg) === 'string';
8182 },
8183 isObject: function(arg) {
8184 return typeof(arg) === 'object' && arg !== null;
8185 },
8186 isNull: function(arg) {
8187 return arg === null;
8188 },
8189 isNullOrUndefined: function(arg) {
8190 return arg == null;
8191 }
8192};
8193
8194
8195/***/ }),
8196/* 33 */
8197/***/ (function(module, exports, __webpack_require__) {
8198
8199"use strict";
8200
8201
8202exports.decode = exports.parse = __webpack_require__(34);
8203exports.encode = exports.stringify = __webpack_require__(35);
8204
8205
8206/***/ }),
8207/* 34 */
8208/***/ (function(module, exports, __webpack_require__) {
8209
8210"use strict";
8211// Copyright Joyent, Inc. and other Node contributors.
8212//
8213// Permission is hereby granted, free of charge, to any person obtaining a
8214// copy of this software and associated documentation files (the
8215// "Software"), to deal in the Software without restriction, including
8216// without limitation the rights to use, copy, modify, merge, publish,
8217// distribute, sublicense, and/or sell copies of the Software, and to permit
8218// persons to whom the Software is furnished to do so, subject to the
8219// following conditions:
8220//
8221// The above copyright notice and this permission notice shall be included
8222// in all copies or substantial portions of the Software.
8223//
8224// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
8225// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
8226// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
8227// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
8228// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
8229// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
8230// USE OR OTHER DEALINGS IN THE SOFTWARE.
8231
8232
8233
8234// If obj.hasOwnProperty has been overridden, then calling
8235// obj.hasOwnProperty(prop) will break.
8236// See: https://github.com/joyent/node/issues/1707
8237function hasOwnProperty(obj, prop) {
8238 return Object.prototype.hasOwnProperty.call(obj, prop);
8239}
8240
8241module.exports = function(qs, sep, eq, options) {
8242 sep = sep || '&';
8243 eq = eq || '=';
8244 var obj = {};
8245
8246 if (typeof qs !== 'string' || qs.length === 0) {
8247 return obj;
8248 }
8249
8250 var regexp = /\+/g;
8251 qs = qs.split(sep);
8252
8253 var maxKeys = 1000;
8254 if (options && typeof options.maxKeys === 'number') {
8255 maxKeys = options.maxKeys;
8256 }
8257
8258 var len = qs.length;
8259 // maxKeys <= 0 means that we should not limit keys count
8260 if (maxKeys > 0 && len > maxKeys) {
8261 len = maxKeys;
8262 }
8263
8264 for (var i = 0; i < len; ++i) {
8265 var x = qs[i].replace(regexp, '%20'),
8266 idx = x.indexOf(eq),
8267 kstr, vstr, k, v;
8268
8269 if (idx >= 0) {
8270 kstr = x.substr(0, idx);
8271 vstr = x.substr(idx + 1);
8272 } else {
8273 kstr = x;
8274 vstr = '';
8275 }
8276
8277 k = decodeURIComponent(kstr);
8278 v = decodeURIComponent(vstr);
8279
8280 if (!hasOwnProperty(obj, k)) {
8281 obj[k] = v;
8282 } else if (isArray(obj[k])) {
8283 obj[k].push(v);
8284 } else {
8285 obj[k] = [obj[k], v];
8286 }
8287 }
8288
8289 return obj;
8290};
8291
8292var isArray = Array.isArray || function (xs) {
8293 return Object.prototype.toString.call(xs) === '[object Array]';
8294};
8295
8296
8297/***/ }),
8298/* 35 */
8299/***/ (function(module, exports, __webpack_require__) {
8300
8301"use strict";
8302// Copyright Joyent, Inc. and other Node contributors.
8303//
8304// Permission is hereby granted, free of charge, to any person obtaining a
8305// copy of this software and associated documentation files (the
8306// "Software"), to deal in the Software without restriction, including
8307// without limitation the rights to use, copy, modify, merge, publish,
8308// distribute, sublicense, and/or sell copies of the Software, and to permit
8309// persons to whom the Software is furnished to do so, subject to the
8310// following conditions:
8311//
8312// The above copyright notice and this permission notice shall be included
8313// in all copies or substantial portions of the Software.
8314//
8315// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
8316// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
8317// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
8318// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
8319// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
8320// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
8321// USE OR OTHER DEALINGS IN THE SOFTWARE.
8322
8323
8324
8325var stringifyPrimitive = function(v) {
8326 switch (typeof v) {
8327 case 'string':
8328 return v;
8329
8330 case 'boolean':
8331 return v ? 'true' : 'false';
8332
8333 case 'number':
8334 return isFinite(v) ? v : '';
8335
8336 default:
8337 return '';
8338 }
8339};
8340
8341module.exports = function(obj, sep, eq, name) {
8342 sep = sep || '&';
8343 eq = eq || '=';
8344 if (obj === null) {
8345 obj = undefined;
8346 }
8347
8348 if (typeof obj === 'object') {
8349 return map(objectKeys(obj), function(k) {
8350 var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
8351 if (isArray(obj[k])) {
8352 return map(obj[k], function(v) {
8353 return ks + encodeURIComponent(stringifyPrimitive(v));
8354 }).join(sep);
8355 } else {
8356 return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
8357 }
8358 }).join(sep);
8359
8360 }
8361
8362 if (!name) return '';
8363 return encodeURIComponent(stringifyPrimitive(name)) + eq +
8364 encodeURIComponent(stringifyPrimitive(obj));
8365};
8366
8367var isArray = Array.isArray || function (xs) {
8368 return Object.prototype.toString.call(xs) === '[object Array]';
8369};
8370
8371function map (xs, f) {
8372 if (xs.map) return xs.map(f);
8373 var res = [];
8374 for (var i = 0; i < xs.length; i++) {
8375 res.push(f(xs[i], i));
8376 }
8377 return res;
8378}
8379
8380var objectKeys = Object.keys || function (obj) {
8381 var res = [];
8382 for (var key in obj) {
8383 if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
8384 }
8385 return res;
8386};
8387
8388
8389/***/ }),
8390/* 36 */
8391/***/ (function(module, exports, __webpack_require__) {
8392
8393var http = __webpack_require__(10)
8394var url = __webpack_require__(7)
8395
8396var https = module.exports
8397
8398for (var key in http) {
8399 if (http.hasOwnProperty(key)) https[key] = http[key]
8400}
8401
8402https.request = function (params, cb) {
8403 params = validateParams(params)
8404 return http.request.call(this, params, cb)
8405}
8406
8407https.get = function (params, cb) {
8408 params = validateParams(params)
8409 return http.get.call(this, params, cb)
8410}
8411
8412function validateParams (params) {
8413 if (typeof params === 'string') {
8414 params = url.parse(params)
8415 }
8416 if (!params.protocol) {
8417 params.protocol = 'https:'
8418 }
8419 if (params.protocol !== 'https:') {
8420 throw new Error('Protocol "' + params.protocol + '" not supported. Expected "https:"')
8421 }
8422 return params
8423}
8424
8425
8426/***/ }),
8427/* 37 */
8428/***/ (function(module, exports, __webpack_require__) {
8429
8430/* WEBPACK VAR INJECTION */(function(Buffer, global, process) {var capability = __webpack_require__(11)
8431var inherits = __webpack_require__(12)
8432var response = __webpack_require__(13)
8433var stream = __webpack_require__(14)
8434var toArrayBuffer = __webpack_require__(47)
8435
8436var IncomingMessage = response.IncomingMessage
8437var rStates = response.readyStates
8438
8439function decideMode (preferBinary, useFetch) {
8440 if (capability.fetch && useFetch) {
8441 return 'fetch'
8442 } else if (capability.mozchunkedarraybuffer) {
8443 return 'moz-chunked-arraybuffer'
8444 } else if (capability.msstream) {
8445 return 'ms-stream'
8446 } else if (capability.arraybuffer && preferBinary) {
8447 return 'arraybuffer'
8448 } else if (capability.vbArray && preferBinary) {
8449 return 'text:vbarray'
8450 } else {
8451 return 'text'
8452 }
8453}
8454
8455var ClientRequest = module.exports = function (opts) {
8456 var self = this
8457 stream.Writable.call(self)
8458
8459 self._opts = opts
8460 self._body = []
8461 self._headers = {}
8462 if (opts.auth)
8463 self.setHeader('Authorization', 'Basic ' + new Buffer(opts.auth).toString('base64'))
8464 Object.keys(opts.headers).forEach(function (name) {
8465 self.setHeader(name, opts.headers[name])
8466 })
8467
8468 var preferBinary
8469 var useFetch = true
8470 if (opts.mode === 'disable-fetch' || ('requestTimeout' in opts && !capability.abortController)) {
8471 // If the use of XHR should be preferred. Not typically needed.
8472 useFetch = false
8473 preferBinary = true
8474 } else if (opts.mode === 'prefer-streaming') {
8475 // If streaming is a high priority but binary compatibility and
8476 // the accuracy of the 'content-type' header aren't
8477 preferBinary = false
8478 } else if (opts.mode === 'allow-wrong-content-type') {
8479 // If streaming is more important than preserving the 'content-type' header
8480 preferBinary = !capability.overrideMimeType
8481 } else if (!opts.mode || opts.mode === 'default' || opts.mode === 'prefer-fast') {
8482 // Use binary if text streaming may corrupt data or the content-type header, or for speed
8483 preferBinary = true
8484 } else {
8485 throw new Error('Invalid value for opts.mode')
8486 }
8487 self._mode = decideMode(preferBinary, useFetch)
8488 self._fetchTimer = null
8489
8490 self.on('finish', function () {
8491 self._onFinish()
8492 })
8493}
8494
8495inherits(ClientRequest, stream.Writable)
8496
8497ClientRequest.prototype.setHeader = function (name, value) {
8498 var self = this
8499 var lowerName = name.toLowerCase()
8500 // This check is not necessary, but it prevents warnings from browsers about setting unsafe
8501 // headers. To be honest I'm not entirely sure hiding these warnings is a good thing, but
8502 // http-browserify did it, so I will too.
8503 if (unsafeHeaders.indexOf(lowerName) !== -1)
8504 return
8505
8506 self._headers[lowerName] = {
8507 name: name,
8508 value: value
8509 }
8510}
8511
8512ClientRequest.prototype.getHeader = function (name) {
8513 var header = this._headers[name.toLowerCase()]
8514 if (header)
8515 return header.value
8516 return null
8517}
8518
8519ClientRequest.prototype.removeHeader = function (name) {
8520 var self = this
8521 delete self._headers[name.toLowerCase()]
8522}
8523
8524ClientRequest.prototype._onFinish = function () {
8525 var self = this
8526
8527 if (self._destroyed)
8528 return
8529 var opts = self._opts
8530
8531 var headersObj = self._headers
8532 var body = null
8533 if (opts.method !== 'GET' && opts.method !== 'HEAD') {
8534 if (capability.arraybuffer) {
8535 body = toArrayBuffer(Buffer.concat(self._body))
8536 } else if (capability.blobConstructor) {
8537 body = new global.Blob(self._body.map(function (buffer) {
8538 return toArrayBuffer(buffer)
8539 }), {
8540 type: (headersObj['content-type'] || {}).value || ''
8541 })
8542 } else {
8543 // get utf8 string
8544 body = Buffer.concat(self._body).toString()
8545 }
8546 }
8547
8548 // create flattened list of headers
8549 var headersList = []
8550 Object.keys(headersObj).forEach(function (keyName) {
8551 var name = headersObj[keyName].name
8552 var value = headersObj[keyName].value
8553 if (Array.isArray(value)) {
8554 value.forEach(function (v) {
8555 headersList.push([name, v])
8556 })
8557 } else {
8558 headersList.push([name, value])
8559 }
8560 })
8561
8562 if (self._mode === 'fetch') {
8563 var signal = null
8564 var fetchTimer = null
8565 if (capability.abortController) {
8566 var controller = new AbortController()
8567 signal = controller.signal
8568 self._fetchAbortController = controller
8569
8570 if ('requestTimeout' in opts && opts.requestTimeout !== 0) {
8571 self._fetchTimer = global.setTimeout(function () {
8572 self.emit('requestTimeout')
8573 if (self._fetchAbortController)
8574 self._fetchAbortController.abort()
8575 }, opts.requestTimeout)
8576 }
8577 }
8578
8579 global.fetch(self._opts.url, {
8580 method: self._opts.method,
8581 headers: headersList,
8582 body: body || undefined,
8583 mode: 'cors',
8584 credentials: opts.withCredentials ? 'include' : 'same-origin',
8585 signal: signal
8586 }).then(function (response) {
8587 self._fetchResponse = response
8588 self._connect()
8589 }, function (reason) {
8590 global.clearTimeout(self._fetchTimer)
8591 if (!self._destroyed)
8592 self.emit('error', reason)
8593 })
8594 } else {
8595 var xhr = self._xhr = new global.XMLHttpRequest()
8596 try {
8597 xhr.open(self._opts.method, self._opts.url, true)
8598 } catch (err) {
8599 process.nextTick(function () {
8600 self.emit('error', err)
8601 })
8602 return
8603 }
8604
8605 // Can't set responseType on really old browsers
8606 if ('responseType' in xhr)
8607 xhr.responseType = self._mode.split(':')[0]
8608
8609 if ('withCredentials' in xhr)
8610 xhr.withCredentials = !!opts.withCredentials
8611
8612 if (self._mode === 'text' && 'overrideMimeType' in xhr)
8613 xhr.overrideMimeType('text/plain; charset=x-user-defined')
8614
8615 if ('requestTimeout' in opts) {
8616 xhr.timeout = opts.requestTimeout
8617 xhr.ontimeout = function () {
8618 self.emit('requestTimeout')
8619 }
8620 }
8621
8622 headersList.forEach(function (header) {
8623 xhr.setRequestHeader(header[0], header[1])
8624 })
8625
8626 self._response = null
8627 xhr.onreadystatechange = function () {
8628 switch (xhr.readyState) {
8629 case rStates.LOADING:
8630 case rStates.DONE:
8631 self._onXHRProgress()
8632 break
8633 }
8634 }
8635 // Necessary for streaming in Firefox, since xhr.response is ONLY defined
8636 // in onprogress, not in onreadystatechange with xhr.readyState = 3
8637 if (self._mode === 'moz-chunked-arraybuffer') {
8638 xhr.onprogress = function () {
8639 self._onXHRProgress()
8640 }
8641 }
8642
8643 xhr.onerror = function () {
8644 if (self._destroyed)
8645 return
8646 self.emit('error', new Error('XHR error'))
8647 }
8648
8649 try {
8650 xhr.send(body)
8651 } catch (err) {
8652 process.nextTick(function () {
8653 self.emit('error', err)
8654 })
8655 return
8656 }
8657 }
8658}
8659
8660/**
8661 * Checks if xhr.status is readable and non-zero, indicating no error.
8662 * Even though the spec says it should be available in readyState 3,
8663 * accessing it throws an exception in IE8
8664 */
8665function statusValid (xhr) {
8666 try {
8667 var status = xhr.status
8668 return (status !== null && status !== 0)
8669 } catch (e) {
8670 return false
8671 }
8672}
8673
8674ClientRequest.prototype._onXHRProgress = function () {
8675 var self = this
8676
8677 if (!statusValid(self._xhr) || self._destroyed)
8678 return
8679
8680 if (!self._response)
8681 self._connect()
8682
8683 self._response._onXHRProgress()
8684}
8685
8686ClientRequest.prototype._connect = function () {
8687 var self = this
8688
8689 if (self._destroyed)
8690 return
8691
8692 self._response = new IncomingMessage(self._xhr, self._fetchResponse, self._mode, self._fetchTimer)
8693 self._response.on('error', function(err) {
8694 self.emit('error', err)
8695 })
8696
8697 self.emit('response', self._response)
8698}
8699
8700ClientRequest.prototype._write = function (chunk, encoding, cb) {
8701 var self = this
8702
8703 self._body.push(chunk)
8704 cb()
8705}
8706
8707ClientRequest.prototype.abort = ClientRequest.prototype.destroy = function () {
8708 var self = this
8709 self._destroyed = true
8710 global.clearTimeout(self._fetchTimer)
8711 if (self._response)
8712 self._response._destroyed = true
8713 if (self._xhr)
8714 self._xhr.abort()
8715 else if (self._fetchAbortController)
8716 self._fetchAbortController.abort()
8717}
8718
8719ClientRequest.prototype.end = function (data, encoding, cb) {
8720 var self = this
8721 if (typeof data === 'function') {
8722 cb = data
8723 data = undefined
8724 }
8725
8726 stream.Writable.prototype.end.call(self, data, encoding, cb)
8727}
8728
8729ClientRequest.prototype.flushHeaders = function () {}
8730ClientRequest.prototype.setTimeout = function () {}
8731ClientRequest.prototype.setNoDelay = function () {}
8732ClientRequest.prototype.setSocketKeepAlive = function () {}
8733
8734// Taken from http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader%28%29-method
8735var unsafeHeaders = [
8736 'accept-charset',
8737 'accept-encoding',
8738 'access-control-request-headers',
8739 'access-control-request-method',
8740 'connection',
8741 'content-length',
8742 'cookie',
8743 'cookie2',
8744 'date',
8745 'dnt',
8746 'expect',
8747 'host',
8748 'keep-alive',
8749 'origin',
8750 'referer',
8751 'te',
8752 'trailer',
8753 'transfer-encoding',
8754 'upgrade',
8755 'via'
8756]
8757
8758/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2).Buffer, __webpack_require__(0), __webpack_require__(1)))
8759
8760/***/ }),
8761/* 38 */
8762/***/ (function(module, exports) {
8763
8764var toString = {}.toString;
8765
8766module.exports = Array.isArray || function (arr) {
8767 return toString.call(arr) == '[object Array]';
8768};
8769
8770
8771/***/ }),
8772/* 39 */
8773/***/ (function(module, exports) {
8774
8775/* (ignored) */
8776
8777/***/ }),
8778/* 40 */
8779/***/ (function(module, exports, __webpack_require__) {
8780
8781"use strict";
8782
8783
8784function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8785
8786var Buffer = __webpack_require__(9).Buffer;
8787var util = __webpack_require__(41);
8788
8789function copyBuffer(src, target, offset) {
8790 src.copy(target, offset);
8791}
8792
8793module.exports = function () {
8794 function BufferList() {
8795 _classCallCheck(this, BufferList);
8796
8797 this.head = null;
8798 this.tail = null;
8799 this.length = 0;
8800 }
8801
8802 BufferList.prototype.push = function push(v) {
8803 var entry = { data: v, next: null };
8804 if (this.length > 0) this.tail.next = entry;else this.head = entry;
8805 this.tail = entry;
8806 ++this.length;
8807 };
8808
8809 BufferList.prototype.unshift = function unshift(v) {
8810 var entry = { data: v, next: this.head };
8811 if (this.length === 0) this.tail = entry;
8812 this.head = entry;
8813 ++this.length;
8814 };
8815
8816 BufferList.prototype.shift = function shift() {
8817 if (this.length === 0) return;
8818 var ret = this.head.data;
8819 if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
8820 --this.length;
8821 return ret;
8822 };
8823
8824 BufferList.prototype.clear = function clear() {
8825 this.head = this.tail = null;
8826 this.length = 0;
8827 };
8828
8829 BufferList.prototype.join = function join(s) {
8830 if (this.length === 0) return '';
8831 var p = this.head;
8832 var ret = '' + p.data;
8833 while (p = p.next) {
8834 ret += s + p.data;
8835 }return ret;
8836 };
8837
8838 BufferList.prototype.concat = function concat(n) {
8839 if (this.length === 0) return Buffer.alloc(0);
8840 if (this.length === 1) return this.head.data;
8841 var ret = Buffer.allocUnsafe(n >>> 0);
8842 var p = this.head;
8843 var i = 0;
8844 while (p) {
8845 copyBuffer(p.data, ret, i);
8846 i += p.data.length;
8847 p = p.next;
8848 }
8849 return ret;
8850 };
8851
8852 return BufferList;
8853}();
8854
8855if (util && util.inspect && util.inspect.custom) {
8856 module.exports.prototype[util.inspect.custom] = function () {
8857 var obj = util.inspect({ length: this.length });
8858 return this.constructor.name + ' ' + obj;
8859 };
8860}
8861
8862/***/ }),
8863/* 41 */
8864/***/ (function(module, exports) {
8865
8866/* (ignored) */
8867
8868/***/ }),
8869/* 42 */
8870/***/ (function(module, exports, __webpack_require__) {
8871
8872/* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) ||
8873 (typeof self !== "undefined" && self) ||
8874 window;
8875var apply = Function.prototype.apply;
8876
8877// DOM APIs, for completeness
8878
8879exports.setTimeout = function() {
8880 return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);
8881};
8882exports.setInterval = function() {
8883 return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);
8884};
8885exports.clearTimeout =
8886exports.clearInterval = function(timeout) {
8887 if (timeout) {
8888 timeout.close();
8889 }
8890};
8891
8892function Timeout(id, clearFn) {
8893 this._id = id;
8894 this._clearFn = clearFn;
8895}
8896Timeout.prototype.unref = Timeout.prototype.ref = function() {};
8897Timeout.prototype.close = function() {
8898 this._clearFn.call(scope, this._id);
8899};
8900
8901// Does not start the time, just sets up the members needed.
8902exports.enroll = function(item, msecs) {
8903 clearTimeout(item._idleTimeoutId);
8904 item._idleTimeout = msecs;
8905};
8906
8907exports.unenroll = function(item) {
8908 clearTimeout(item._idleTimeoutId);
8909 item._idleTimeout = -1;
8910};
8911
8912exports._unrefActive = exports.active = function(item) {
8913 clearTimeout(item._idleTimeoutId);
8914
8915 var msecs = item._idleTimeout;
8916 if (msecs >= 0) {
8917 item._idleTimeoutId = setTimeout(function onTimeout() {
8918 if (item._onTimeout)
8919 item._onTimeout();
8920 }, msecs);
8921 }
8922};
8923
8924// setimmediate attaches itself to the global object
8925__webpack_require__(43);
8926// On some exotic environments, it's not clear which object `setimmediate` was
8927// able to install onto. Search each possibility in the same order as the
8928// `setimmediate` library.
8929exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) ||
8930 (typeof global !== "undefined" && global.setImmediate) ||
8931 (this && this.setImmediate);
8932exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
8933 (typeof global !== "undefined" && global.clearImmediate) ||
8934 (this && this.clearImmediate);
8935
8936/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
8937
8938/***/ }),
8939/* 43 */
8940/***/ (function(module, exports, __webpack_require__) {
8941
8942/* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
8943 "use strict";
8944
8945 if (global.setImmediate) {
8946 return;
8947 }
8948
8949 var nextHandle = 1; // Spec says greater than zero
8950 var tasksByHandle = {};
8951 var currentlyRunningATask = false;
8952 var doc = global.document;
8953 var registerImmediate;
8954
8955 function setImmediate(callback) {
8956 // Callback can either be a function or a string
8957 if (typeof callback !== "function") {
8958 callback = new Function("" + callback);
8959 }
8960 // Copy function arguments
8961 var args = new Array(arguments.length - 1);
8962 for (var i = 0; i < args.length; i++) {
8963 args[i] = arguments[i + 1];
8964 }
8965 // Store and register the task
8966 var task = { callback: callback, args: args };
8967 tasksByHandle[nextHandle] = task;
8968 registerImmediate(nextHandle);
8969 return nextHandle++;
8970 }
8971
8972 function clearImmediate(handle) {
8973 delete tasksByHandle[handle];
8974 }
8975
8976 function run(task) {
8977 var callback = task.callback;
8978 var args = task.args;
8979 switch (args.length) {
8980 case 0:
8981 callback();
8982 break;
8983 case 1:
8984 callback(args[0]);
8985 break;
8986 case 2:
8987 callback(args[0], args[1]);
8988 break;
8989 case 3:
8990 callback(args[0], args[1], args[2]);
8991 break;
8992 default:
8993 callback.apply(undefined, args);
8994 break;
8995 }
8996 }
8997
8998 function runIfPresent(handle) {
8999 // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
9000 // So if we're currently running a task, we'll need to delay this invocation.
9001 if (currentlyRunningATask) {
9002 // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
9003 // "too much recursion" error.
9004 setTimeout(runIfPresent, 0, handle);
9005 } else {
9006 var task = tasksByHandle[handle];
9007 if (task) {
9008 currentlyRunningATask = true;
9009 try {
9010 run(task);
9011 } finally {
9012 clearImmediate(handle);
9013 currentlyRunningATask = false;
9014 }
9015 }
9016 }
9017 }
9018
9019 function installNextTickImplementation() {
9020 registerImmediate = function(handle) {
9021 process.nextTick(function () { runIfPresent(handle); });
9022 };
9023 }
9024
9025 function canUsePostMessage() {
9026 // The test against `importScripts` prevents this implementation from being installed inside a web worker,
9027 // where `global.postMessage` means something completely different and can't be used for this purpose.
9028 if (global.postMessage && !global.importScripts) {
9029 var postMessageIsAsynchronous = true;
9030 var oldOnMessage = global.onmessage;
9031 global.onmessage = function() {
9032 postMessageIsAsynchronous = false;
9033 };
9034 global.postMessage("", "*");
9035 global.onmessage = oldOnMessage;
9036 return postMessageIsAsynchronous;
9037 }
9038 }
9039
9040 function installPostMessageImplementation() {
9041 // Installs an event handler on `global` for the `message` event: see
9042 // * https://developer.mozilla.org/en/DOM/window.postMessage
9043 // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
9044
9045 var messagePrefix = "setImmediate$" + Math.random() + "$";
9046 var onGlobalMessage = function(event) {
9047 if (event.source === global &&
9048 typeof event.data === "string" &&
9049 event.data.indexOf(messagePrefix) === 0) {
9050 runIfPresent(+event.data.slice(messagePrefix.length));
9051 }
9052 };
9053
9054 if (global.addEventListener) {
9055 global.addEventListener("message", onGlobalMessage, false);
9056 } else {
9057 global.attachEvent("onmessage", onGlobalMessage);
9058 }
9059
9060 registerImmediate = function(handle) {
9061 global.postMessage(messagePrefix + handle, "*");
9062 };
9063 }
9064
9065 function installMessageChannelImplementation() {
9066 var channel = new MessageChannel();
9067 channel.port1.onmessage = function(event) {
9068 var handle = event.data;
9069 runIfPresent(handle);
9070 };
9071
9072 registerImmediate = function(handle) {
9073 channel.port2.postMessage(handle);
9074 };
9075 }
9076
9077 function installReadyStateChangeImplementation() {
9078 var html = doc.documentElement;
9079 registerImmediate = function(handle) {
9080 // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
9081 // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
9082 var script = doc.createElement("script");
9083 script.onreadystatechange = function () {
9084 runIfPresent(handle);
9085 script.onreadystatechange = null;
9086 html.removeChild(script);
9087 script = null;
9088 };
9089 html.appendChild(script);
9090 };
9091 }
9092
9093 function installSetTimeoutImplementation() {
9094 registerImmediate = function(handle) {
9095 setTimeout(runIfPresent, 0, handle);
9096 };
9097 }
9098
9099 // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
9100 var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
9101 attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
9102
9103 // Don't get fooled by e.g. browserify environments.
9104 if ({}.toString.call(global.process) === "[object process]") {
9105 // For Node.js before 0.9
9106 installNextTickImplementation();
9107
9108 } else if (canUsePostMessage()) {
9109 // For non-IE10 modern browsers
9110 installPostMessageImplementation();
9111
9112 } else if (global.MessageChannel) {
9113 // For web workers, where supported
9114 installMessageChannelImplementation();
9115
9116 } else if (doc && "onreadystatechange" in doc.createElement("script")) {
9117 // For IE 6–8
9118 installReadyStateChangeImplementation();
9119
9120 } else {
9121 // For older browsers
9122 installSetTimeoutImplementation();
9123 }
9124
9125 attachTo.setImmediate = setImmediate;
9126 attachTo.clearImmediate = clearImmediate;
9127}(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
9128
9129/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0), __webpack_require__(1)))
9130
9131/***/ }),
9132/* 44 */
9133/***/ (function(module, exports, __webpack_require__) {
9134
9135/* WEBPACK VAR INJECTION */(function(global) {
9136/**
9137 * Module exports.
9138 */
9139
9140module.exports = deprecate;
9141
9142/**
9143 * Mark that a method should not be used.
9144 * Returns a modified function which warns once by default.
9145 *
9146 * If `localStorage.noDeprecation = true` is set, then it is a no-op.
9147 *
9148 * If `localStorage.throwDeprecation = true` is set, then deprecated functions
9149 * will throw an Error when invoked.
9150 *
9151 * If `localStorage.traceDeprecation = true` is set, then deprecated functions
9152 * will invoke `console.trace()` instead of `console.error()`.
9153 *
9154 * @param {Function} fn - the function to deprecate
9155 * @param {String} msg - the string to print to the console when `fn` is invoked
9156 * @returns {Function} a new "deprecated" version of `fn`
9157 * @api public
9158 */
9159
9160function deprecate (fn, msg) {
9161 if (config('noDeprecation')) {
9162 return fn;
9163 }
9164
9165 var warned = false;
9166 function deprecated() {
9167 if (!warned) {
9168 if (config('throwDeprecation')) {
9169 throw new Error(msg);
9170 } else if (config('traceDeprecation')) {
9171 console.trace(msg);
9172 } else {
9173 console.warn(msg);
9174 }
9175 warned = true;
9176 }
9177 return fn.apply(this, arguments);
9178 }
9179
9180 return deprecated;
9181}
9182
9183/**
9184 * Checks `localStorage` for boolean values for the given `name`.
9185 *
9186 * @param {String} name
9187 * @returns {Boolean}
9188 * @api private
9189 */
9190
9191function config (name) {
9192 // accessing global.localStorage can trigger a DOMException in sandboxed iframes
9193 try {
9194 if (!global.localStorage) return false;
9195 } catch (_) {
9196 return false;
9197 }
9198 var val = global.localStorage[name];
9199 if (null == val) return false;
9200 return String(val).toLowerCase() === 'true';
9201}
9202
9203/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
9204
9205/***/ }),
9206/* 45 */
9207/***/ (function(module, exports, __webpack_require__) {
9208
9209/* eslint-disable node/no-deprecated-api */
9210var buffer = __webpack_require__(2)
9211var Buffer = buffer.Buffer
9212
9213// alternative to using Object.keys for old browsers
9214function copyProps (src, dst) {
9215 for (var key in src) {
9216 dst[key] = src[key]
9217 }
9218}
9219if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
9220 module.exports = buffer
9221} else {
9222 // Copy properties from require('buffer')
9223 copyProps(buffer, exports)
9224 exports.Buffer = SafeBuffer
9225}
9226
9227function SafeBuffer (arg, encodingOrOffset, length) {
9228 return Buffer(arg, encodingOrOffset, length)
9229}
9230
9231// Copy static methods from Buffer
9232copyProps(Buffer, SafeBuffer)
9233
9234SafeBuffer.from = function (arg, encodingOrOffset, length) {
9235 if (typeof arg === 'number') {
9236 throw new TypeError('Argument must not be a number')
9237 }
9238 return Buffer(arg, encodingOrOffset, length)
9239}
9240
9241SafeBuffer.alloc = function (size, fill, encoding) {
9242 if (typeof size !== 'number') {
9243 throw new TypeError('Argument must be a number')
9244 }
9245 var buf = Buffer(size)
9246 if (fill !== undefined) {
9247 if (typeof encoding === 'string') {
9248 buf.fill(fill, encoding)
9249 } else {
9250 buf.fill(fill)
9251 }
9252 } else {
9253 buf.fill(0)
9254 }
9255 return buf
9256}
9257
9258SafeBuffer.allocUnsafe = function (size) {
9259 if (typeof size !== 'number') {
9260 throw new TypeError('Argument must be a number')
9261 }
9262 return Buffer(size)
9263}
9264
9265SafeBuffer.allocUnsafeSlow = function (size) {
9266 if (typeof size !== 'number') {
9267 throw new TypeError('Argument must be a number')
9268 }
9269 return buffer.SlowBuffer(size)
9270}
9271
9272
9273/***/ }),
9274/* 46 */
9275/***/ (function(module, exports, __webpack_require__) {
9276
9277"use strict";
9278// Copyright Joyent, Inc. and other Node contributors.
9279//
9280// Permission is hereby granted, free of charge, to any person obtaining a
9281// copy of this software and associated documentation files (the
9282// "Software"), to deal in the Software without restriction, including
9283// without limitation the rights to use, copy, modify, merge, publish,
9284// distribute, sublicense, and/or sell copies of the Software, and to permit
9285// persons to whom the Software is furnished to do so, subject to the
9286// following conditions:
9287//
9288// The above copyright notice and this permission notice shall be included
9289// in all copies or substantial portions of the Software.
9290//
9291// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
9292// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
9293// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
9294// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
9295// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
9296// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
9297// USE OR OTHER DEALINGS IN THE SOFTWARE.
9298
9299// a passthrough stream.
9300// basically just the most minimal sort of Transform stream.
9301// Every written chunk gets output as-is.
9302
9303
9304
9305module.exports = PassThrough;
9306
9307var Transform = __webpack_require__(20);
9308
9309/*<replacement>*/
9310var util = __webpack_require__(4);
9311util.inherits = __webpack_require__(5);
9312/*</replacement>*/
9313
9314util.inherits(PassThrough, Transform);
9315
9316function PassThrough(options) {
9317 if (!(this instanceof PassThrough)) return new PassThrough(options);
9318
9319 Transform.call(this, options);
9320}
9321
9322PassThrough.prototype._transform = function (chunk, encoding, cb) {
9323 cb(null, chunk);
9324};
9325
9326/***/ }),
9327/* 47 */
9328/***/ (function(module, exports, __webpack_require__) {
9329
9330var Buffer = __webpack_require__(2).Buffer
9331
9332module.exports = function (buf) {
9333 // If the buffer is backed by a Uint8Array, a faster version will work
9334 if (buf instanceof Uint8Array) {
9335 // If the buffer isn't a subarray, return the underlying ArrayBuffer
9336 if (buf.byteOffset === 0 && buf.byteLength === buf.buffer.byteLength) {
9337 return buf.buffer
9338 } else if (typeof buf.buffer.slice === 'function') {
9339 // Otherwise we need to get a proper copy
9340 return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength)
9341 }
9342 }
9343
9344 if (Buffer.isBuffer(buf)) {
9345 // This is the slow version that will work with any Buffer
9346 // implementation (even in old browsers)
9347 var arrayCopy = new Uint8Array(buf.length)
9348 var len = buf.length
9349 for (var i = 0; i < len; i++) {
9350 arrayCopy[i] = buf[i]
9351 }
9352 return arrayCopy.buffer
9353 } else {
9354 throw new Error('Argument must be a Buffer')
9355 }
9356}
9357
9358
9359/***/ }),
9360/* 48 */
9361/***/ (function(module, exports) {
9362
9363module.exports = extend
9364
9365var hasOwnProperty = Object.prototype.hasOwnProperty;
9366
9367function extend() {
9368 var target = {}
9369
9370 for (var i = 0; i < arguments.length; i++) {
9371 var source = arguments[i]
9372
9373 for (var key in source) {
9374 if (hasOwnProperty.call(source, key)) {
9375 target[key] = source[key]
9376 }
9377 }
9378 }
9379
9380 return target
9381}
9382
9383
9384/***/ }),
9385/* 49 */
9386/***/ (function(module, exports) {
9387
9388module.exports = {
9389 "100": "Continue",
9390 "101": "Switching Protocols",
9391 "102": "Processing",
9392 "200": "OK",
9393 "201": "Created",
9394 "202": "Accepted",
9395 "203": "Non-Authoritative Information",
9396 "204": "No Content",
9397 "205": "Reset Content",
9398 "206": "Partial Content",
9399 "207": "Multi-Status",
9400 "208": "Already Reported",
9401 "226": "IM Used",
9402 "300": "Multiple Choices",
9403 "301": "Moved Permanently",
9404 "302": "Found",
9405 "303": "See Other",
9406 "304": "Not Modified",
9407 "305": "Use Proxy",
9408 "307": "Temporary Redirect",
9409 "308": "Permanent Redirect",
9410 "400": "Bad Request",
9411 "401": "Unauthorized",
9412 "402": "Payment Required",
9413 "403": "Forbidden",
9414 "404": "Not Found",
9415 "405": "Method Not Allowed",
9416 "406": "Not Acceptable",
9417 "407": "Proxy Authentication Required",
9418 "408": "Request Timeout",
9419 "409": "Conflict",
9420 "410": "Gone",
9421 "411": "Length Required",
9422 "412": "Precondition Failed",
9423 "413": "Payload Too Large",
9424 "414": "URI Too Long",
9425 "415": "Unsupported Media Type",
9426 "416": "Range Not Satisfiable",
9427 "417": "Expectation Failed",
9428 "418": "I'm a teapot",
9429 "421": "Misdirected Request",
9430 "422": "Unprocessable Entity",
9431 "423": "Locked",
9432 "424": "Failed Dependency",
9433 "425": "Unordered Collection",
9434 "426": "Upgrade Required",
9435 "428": "Precondition Required",
9436 "429": "Too Many Requests",
9437 "431": "Request Header Fields Too Large",
9438 "451": "Unavailable For Legal Reasons",
9439 "500": "Internal Server Error",
9440 "501": "Not Implemented",
9441 "502": "Bad Gateway",
9442 "503": "Service Unavailable",
9443 "504": "Gateway Timeout",
9444 "505": "HTTP Version Not Supported",
9445 "506": "Variant Also Negotiates",
9446 "507": "Insufficient Storage",
9447 "508": "Loop Detected",
9448 "509": "Bandwidth Limit Exceeded",
9449 "510": "Not Extended",
9450 "511": "Network Authentication Required"
9451}
9452
9453
9454/***/ }),
9455/* 50 */
9456/***/ (function(module, exports, __webpack_require__) {
9457
9458/* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors.
9459//
9460// Permission is hereby granted, free of charge, to any person obtaining a
9461// copy of this software and associated documentation files (the
9462// "Software"), to deal in the Software without restriction, including
9463// without limitation the rights to use, copy, modify, merge, publish,
9464// distribute, sublicense, and/or sell copies of the Software, and to permit
9465// persons to whom the Software is furnished to do so, subject to the
9466// following conditions:
9467//
9468// The above copyright notice and this permission notice shall be included
9469// in all copies or substantial portions of the Software.
9470//
9471// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
9472// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
9473// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
9474// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
9475// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
9476// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
9477// USE OR OTHER DEALINGS IN THE SOFTWARE.
9478
9479var formatRegExp = /%[sdj%]/g;
9480exports.format = function(f) {
9481 if (!isString(f)) {
9482 var objects = [];
9483 for (var i = 0; i < arguments.length; i++) {
9484 objects.push(inspect(arguments[i]));
9485 }
9486 return objects.join(' ');
9487 }
9488
9489 var i = 1;
9490 var args = arguments;
9491 var len = args.length;
9492 var str = String(f).replace(formatRegExp, function(x) {
9493 if (x === '%%') return '%';
9494 if (i >= len) return x;
9495 switch (x) {
9496 case '%s': return String(args[i++]);
9497 case '%d': return Number(args[i++]);
9498 case '%j':
9499 try {
9500 return JSON.stringify(args[i++]);
9501 } catch (_) {
9502 return '[Circular]';
9503 }
9504 default:
9505 return x;
9506 }
9507 });
9508 for (var x = args[i]; i < len; x = args[++i]) {
9509 if (isNull(x) || !isObject(x)) {
9510 str += ' ' + x;
9511 } else {
9512 str += ' ' + inspect(x);
9513 }
9514 }
9515 return str;
9516};
9517
9518
9519// Mark that a method should not be used.
9520// Returns a modified function which warns once by default.
9521// If --no-deprecation is set, then it is a no-op.
9522exports.deprecate = function(fn, msg) {
9523 // Allow for deprecating things in the process of starting up.
9524 if (isUndefined(global.process)) {
9525 return function() {
9526 return exports.deprecate(fn, msg).apply(this, arguments);
9527 };
9528 }
9529
9530 if (process.noDeprecation === true) {
9531 return fn;
9532 }
9533
9534 var warned = false;
9535 function deprecated() {
9536 if (!warned) {
9537 if (process.throwDeprecation) {
9538 throw new Error(msg);
9539 } else if (process.traceDeprecation) {
9540 console.trace(msg);
9541 } else {
9542 console.error(msg);
9543 }
9544 warned = true;
9545 }
9546 return fn.apply(this, arguments);
9547 }
9548
9549 return deprecated;
9550};
9551
9552
9553var debugs = {};
9554var debugEnviron;
9555exports.debuglog = function(set) {
9556 if (isUndefined(debugEnviron))
9557 debugEnviron = process.env.NODE_DEBUG || '';
9558 set = set.toUpperCase();
9559 if (!debugs[set]) {
9560 if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
9561 var pid = process.pid;
9562 debugs[set] = function() {
9563 var msg = exports.format.apply(exports, arguments);
9564 console.error('%s %d: %s', set, pid, msg);
9565 };
9566 } else {
9567 debugs[set] = function() {};
9568 }
9569 }
9570 return debugs[set];
9571};
9572
9573
9574/**
9575 * Echos the value of a value. Trys to print the value out
9576 * in the best way possible given the different types.
9577 *
9578 * @param {Object} obj The object to print out.
9579 * @param {Object} opts Optional options object that alters the output.
9580 */
9581/* legacy: obj, showHidden, depth, colors*/
9582function inspect(obj, opts) {
9583 // default options
9584 var ctx = {
9585 seen: [],
9586 stylize: stylizeNoColor
9587 };
9588 // legacy...
9589 if (arguments.length >= 3) ctx.depth = arguments[2];
9590 if (arguments.length >= 4) ctx.colors = arguments[3];
9591 if (isBoolean(opts)) {
9592 // legacy...
9593 ctx.showHidden = opts;
9594 } else if (opts) {
9595 // got an "options" object
9596 exports._extend(ctx, opts);
9597 }
9598 // set default options
9599 if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
9600 if (isUndefined(ctx.depth)) ctx.depth = 2;
9601 if (isUndefined(ctx.colors)) ctx.colors = false;
9602 if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
9603 if (ctx.colors) ctx.stylize = stylizeWithColor;
9604 return formatValue(ctx, obj, ctx.depth);
9605}
9606exports.inspect = inspect;
9607
9608
9609// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
9610inspect.colors = {
9611 'bold' : [1, 22],
9612 'italic' : [3, 23],
9613 'underline' : [4, 24],
9614 'inverse' : [7, 27],
9615 'white' : [37, 39],
9616 'grey' : [90, 39],
9617 'black' : [30, 39],
9618 'blue' : [34, 39],
9619 'cyan' : [36, 39],
9620 'green' : [32, 39],
9621 'magenta' : [35, 39],
9622 'red' : [31, 39],
9623 'yellow' : [33, 39]
9624};
9625
9626// Don't use 'blue' not visible on cmd.exe
9627inspect.styles = {
9628 'special': 'cyan',
9629 'number': 'yellow',
9630 'boolean': 'yellow',
9631 'undefined': 'grey',
9632 'null': 'bold',
9633 'string': 'green',
9634 'date': 'magenta',
9635 // "name": intentionally not styling
9636 'regexp': 'red'
9637};
9638
9639
9640function stylizeWithColor(str, styleType) {
9641 var style = inspect.styles[styleType];
9642
9643 if (style) {
9644 return '\u001b[' + inspect.colors[style][0] + 'm' + str +
9645 '\u001b[' + inspect.colors[style][1] + 'm';
9646 } else {
9647 return str;
9648 }
9649}
9650
9651
9652function stylizeNoColor(str, styleType) {
9653 return str;
9654}
9655
9656
9657function arrayToHash(array) {
9658 var hash = {};
9659
9660 array.forEach(function(val, idx) {
9661 hash[val] = true;
9662 });
9663
9664 return hash;
9665}
9666
9667
9668function formatValue(ctx, value, recurseTimes) {
9669 // Provide a hook for user-specified inspect functions.
9670 // Check that value is an object with an inspect function on it
9671 if (ctx.customInspect &&
9672 value &&
9673 isFunction(value.inspect) &&
9674 // Filter out the util module, it's inspect function is special
9675 value.inspect !== exports.inspect &&
9676 // Also filter out any prototype objects using the circular check.
9677 !(value.constructor && value.constructor.prototype === value)) {
9678 var ret = value.inspect(recurseTimes, ctx);
9679 if (!isString(ret)) {
9680 ret = formatValue(ctx, ret, recurseTimes);
9681 }
9682 return ret;
9683 }
9684
9685 // Primitive types cannot have properties
9686 var primitive = formatPrimitive(ctx, value);
9687 if (primitive) {
9688 return primitive;
9689 }
9690
9691 // Look up the keys of the object.
9692 var keys = Object.keys(value);
9693 var visibleKeys = arrayToHash(keys);
9694
9695 if (ctx.showHidden) {
9696 keys = Object.getOwnPropertyNames(value);
9697 }
9698
9699 // IE doesn't make error fields non-enumerable
9700 // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
9701 if (isError(value)
9702 && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
9703 return formatError(value);
9704 }
9705
9706 // Some type of object without properties can be shortcutted.
9707 if (keys.length === 0) {
9708 if (isFunction(value)) {
9709 var name = value.name ? ': ' + value.name : '';
9710 return ctx.stylize('[Function' + name + ']', 'special');
9711 }
9712 if (isRegExp(value)) {
9713 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
9714 }
9715 if (isDate(value)) {
9716 return ctx.stylize(Date.prototype.toString.call(value), 'date');
9717 }
9718 if (isError(value)) {
9719 return formatError(value);
9720 }
9721 }
9722
9723 var base = '', array = false, braces = ['{', '}'];
9724
9725 // Make Array say that they are Array
9726 if (isArray(value)) {
9727 array = true;
9728 braces = ['[', ']'];
9729 }
9730
9731 // Make functions say that they are functions
9732 if (isFunction(value)) {
9733 var n = value.name ? ': ' + value.name : '';
9734 base = ' [Function' + n + ']';
9735 }
9736
9737 // Make RegExps say that they are RegExps
9738 if (isRegExp(value)) {
9739 base = ' ' + RegExp.prototype.toString.call(value);
9740 }
9741
9742 // Make dates with properties first say the date
9743 if (isDate(value)) {
9744 base = ' ' + Date.prototype.toUTCString.call(value);
9745 }
9746
9747 // Make error with message first say the error
9748 if (isError(value)) {
9749 base = ' ' + formatError(value);
9750 }
9751
9752 if (keys.length === 0 && (!array || value.length == 0)) {
9753 return braces[0] + base + braces[1];
9754 }
9755
9756 if (recurseTimes < 0) {
9757 if (isRegExp(value)) {
9758 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
9759 } else {
9760 return ctx.stylize('[Object]', 'special');
9761 }
9762 }
9763
9764 ctx.seen.push(value);
9765
9766 var output;
9767 if (array) {
9768 output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
9769 } else {
9770 output = keys.map(function(key) {
9771 return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
9772 });
9773 }
9774
9775 ctx.seen.pop();
9776
9777 return reduceToSingleString(output, base, braces);
9778}
9779
9780
9781function formatPrimitive(ctx, value) {
9782 if (isUndefined(value))
9783 return ctx.stylize('undefined', 'undefined');
9784 if (isString(value)) {
9785 var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
9786 .replace(/'/g, "\\'")
9787 .replace(/\\"/g, '"') + '\'';
9788 return ctx.stylize(simple, 'string');
9789 }
9790 if (isNumber(value))
9791 return ctx.stylize('' + value, 'number');
9792 if (isBoolean(value))
9793 return ctx.stylize('' + value, 'boolean');
9794 // For some reason typeof null is "object", so special case here.
9795 if (isNull(value))
9796 return ctx.stylize('null', 'null');
9797}
9798
9799
9800function formatError(value) {
9801 return '[' + Error.prototype.toString.call(value) + ']';
9802}
9803
9804
9805function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
9806 var output = [];
9807 for (var i = 0, l = value.length; i < l; ++i) {
9808 if (hasOwnProperty(value, String(i))) {
9809 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
9810 String(i), true));
9811 } else {
9812 output.push('');
9813 }
9814 }
9815 keys.forEach(function(key) {
9816 if (!key.match(/^\d+$/)) {
9817 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
9818 key, true));
9819 }
9820 });
9821 return output;
9822}
9823
9824
9825function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
9826 var name, str, desc;
9827 desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
9828 if (desc.get) {
9829 if (desc.set) {
9830 str = ctx.stylize('[Getter/Setter]', 'special');
9831 } else {
9832 str = ctx.stylize('[Getter]', 'special');
9833 }
9834 } else {
9835 if (desc.set) {
9836 str = ctx.stylize('[Setter]', 'special');
9837 }
9838 }
9839 if (!hasOwnProperty(visibleKeys, key)) {
9840 name = '[' + key + ']';
9841 }
9842 if (!str) {
9843 if (ctx.seen.indexOf(desc.value) < 0) {
9844 if (isNull(recurseTimes)) {
9845 str = formatValue(ctx, desc.value, null);
9846 } else {
9847 str = formatValue(ctx, desc.value, recurseTimes - 1);
9848 }
9849 if (str.indexOf('\n') > -1) {
9850 if (array) {
9851 str = str.split('\n').map(function(line) {
9852 return ' ' + line;
9853 }).join('\n').substr(2);
9854 } else {
9855 str = '\n' + str.split('\n').map(function(line) {
9856 return ' ' + line;
9857 }).join('\n');
9858 }
9859 }
9860 } else {
9861 str = ctx.stylize('[Circular]', 'special');
9862 }
9863 }
9864 if (isUndefined(name)) {
9865 if (array && key.match(/^\d+$/)) {
9866 return str;
9867 }
9868 name = JSON.stringify('' + key);
9869 if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
9870 name = name.substr(1, name.length - 2);
9871 name = ctx.stylize(name, 'name');
9872 } else {
9873 name = name.replace(/'/g, "\\'")
9874 .replace(/\\"/g, '"')
9875 .replace(/(^"|"$)/g, "'");
9876 name = ctx.stylize(name, 'string');
9877 }
9878 }
9879
9880 return name + ': ' + str;
9881}
9882
9883
9884function reduceToSingleString(output, base, braces) {
9885 var numLinesEst = 0;
9886 var length = output.reduce(function(prev, cur) {
9887 numLinesEst++;
9888 if (cur.indexOf('\n') >= 0) numLinesEst++;
9889 return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
9890 }, 0);
9891
9892 if (length > 60) {
9893 return braces[0] +
9894 (base === '' ? '' : base + '\n ') +
9895 ' ' +
9896 output.join(',\n ') +
9897 ' ' +
9898 braces[1];
9899 }
9900
9901 return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
9902}
9903
9904
9905// NOTE: These type checking functions intentionally don't use `instanceof`
9906// because it is fragile and can be easily faked with `Object.create()`.
9907function isArray(ar) {
9908 return Array.isArray(ar);
9909}
9910exports.isArray = isArray;
9911
9912function isBoolean(arg) {
9913 return typeof arg === 'boolean';
9914}
9915exports.isBoolean = isBoolean;
9916
9917function isNull(arg) {
9918 return arg === null;
9919}
9920exports.isNull = isNull;
9921
9922function isNullOrUndefined(arg) {
9923 return arg == null;
9924}
9925exports.isNullOrUndefined = isNullOrUndefined;
9926
9927function isNumber(arg) {
9928 return typeof arg === 'number';
9929}
9930exports.isNumber = isNumber;
9931
9932function isString(arg) {
9933 return typeof arg === 'string';
9934}
9935exports.isString = isString;
9936
9937function isSymbol(arg) {
9938 return typeof arg === 'symbol';
9939}
9940exports.isSymbol = isSymbol;
9941
9942function isUndefined(arg) {
9943 return arg === void 0;
9944}
9945exports.isUndefined = isUndefined;
9946
9947function isRegExp(re) {
9948 return isObject(re) && objectToString(re) === '[object RegExp]';
9949}
9950exports.isRegExp = isRegExp;
9951
9952function isObject(arg) {
9953 return typeof arg === 'object' && arg !== null;
9954}
9955exports.isObject = isObject;
9956
9957function isDate(d) {
9958 return isObject(d) && objectToString(d) === '[object Date]';
9959}
9960exports.isDate = isDate;
9961
9962function isError(e) {
9963 return isObject(e) &&
9964 (objectToString(e) === '[object Error]' || e instanceof Error);
9965}
9966exports.isError = isError;
9967
9968function isFunction(arg) {
9969 return typeof arg === 'function';
9970}
9971exports.isFunction = isFunction;
9972
9973function isPrimitive(arg) {
9974 return arg === null ||
9975 typeof arg === 'boolean' ||
9976 typeof arg === 'number' ||
9977 typeof arg === 'string' ||
9978 typeof arg === 'symbol' || // ES6 symbol
9979 typeof arg === 'undefined';
9980}
9981exports.isPrimitive = isPrimitive;
9982
9983exports.isBuffer = __webpack_require__(51);
9984
9985function objectToString(o) {
9986 return Object.prototype.toString.call(o);
9987}
9988
9989
9990function pad(n) {
9991 return n < 10 ? '0' + n.toString(10) : n.toString(10);
9992}
9993
9994
9995var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
9996 'Oct', 'Nov', 'Dec'];
9997
9998// 26 Feb 16:19:34
9999function timestamp() {
10000 var d = new Date();
10001 var time = [pad(d.getHours()),
10002 pad(d.getMinutes()),
10003 pad(d.getSeconds())].join(':');
10004 return [d.getDate(), months[d.getMonth()], time].join(' ');
10005}
10006
10007
10008// log is just a thin wrapper to console.log that prepends a timestamp
10009exports.log = function() {
10010 console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
10011};
10012
10013
10014/**
10015 * Inherit the prototype methods from one constructor into another.
10016 *
10017 * The Function.prototype.inherits from lang.js rewritten as a standalone
10018 * function (not on Function.prototype). NOTE: If this file is to be loaded
10019 * during bootstrapping this function needs to be rewritten using some native
10020 * functions as prototype setup using normal JavaScript does not work as
10021 * expected during bootstrapping (see mirror.js in r114903).
10022 *
10023 * @param {function} ctor Constructor function which needs to inherit the
10024 * prototype.
10025 * @param {function} superCtor Constructor function to inherit prototype from.
10026 */
10027exports.inherits = __webpack_require__(52);
10028
10029exports._extend = function(origin, add) {
10030 // Don't do anything if add isn't an object
10031 if (!add || !isObject(add)) return origin;
10032
10033 var keys = Object.keys(add);
10034 var i = keys.length;
10035 while (i--) {
10036 origin[keys[i]] = add[keys[i]];
10037 }
10038 return origin;
10039};
10040
10041function hasOwnProperty(obj, prop) {
10042 return Object.prototype.hasOwnProperty.call(obj, prop);
10043}
10044
10045/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0), __webpack_require__(1)))
10046
10047/***/ }),
10048/* 51 */
10049/***/ (function(module, exports) {
10050
10051module.exports = function isBuffer(arg) {
10052 return arg && typeof arg === 'object'
10053 && typeof arg.copy === 'function'
10054 && typeof arg.fill === 'function'
10055 && typeof arg.readUInt8 === 'function';
10056}
10057
10058/***/ }),
10059/* 52 */
10060/***/ (function(module, exports) {
10061
10062if (typeof Object.create === 'function') {
10063 // implementation from standard node.js 'util' module
10064 module.exports = function inherits(ctor, superCtor) {
10065 ctor.super_ = superCtor
10066 ctor.prototype = Object.create(superCtor.prototype, {
10067 constructor: {
10068 value: ctor,
10069 enumerable: false,
10070 writable: true,
10071 configurable: true
10072 }
10073 });
10074 };
10075} else {
10076 // old school shim for old browsers
10077 module.exports = function inherits(ctor, superCtor) {
10078 ctor.super_ = superCtor
10079 var TempCtor = function () {}
10080 TempCtor.prototype = superCtor.prototype
10081 ctor.prototype = new TempCtor()
10082 ctor.prototype.constructor = ctor
10083 }
10084}
10085
10086
10087/***/ })
10088/******/ ]);