UNPKG

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