UNPKG

1 MBJavaScriptView Raw
1// Aliyun OSS SDK for JavaScript v6.8.0
2// Copyright Aliyun.com, Inc. or its affiliates. All Rights Reserved.
3// License at https://github.com/ali-sdk/ali-oss/blob/master/LICENSE
4(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.OSS = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
5'use strict';
6
7var OSS = require('./browser/client');
8OSS.Buffer = require('buffer').Buffer;
9OSS.urllib = require('../shims/xhr');
10OSS.version = require('./browser/version').version;
11
12module.exports = OSS;
13
14},{"../shims/xhr":334,"./browser/client":2,"./browser/version":5,"buffer":70}],2:[function(require,module,exports){
15(function (process,Buffer){
16'use strict';
17
18var _promise = require('babel-runtime/core-js/promise');
19
20var _promise2 = _interopRequireDefault(_promise);
21
22var _regenerator = require('babel-runtime/regenerator');
23
24var _regenerator2 = _interopRequireDefault(_regenerator);
25
26var _assign = require('babel-runtime/core-js/object/assign');
27
28var _assign2 = _interopRequireDefault(_assign);
29
30function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
32var debug = require('debug')('ali-oss');
33var crypto = require('./../../shims/crypto/crypto.js');
34var path = require('path');
35var copy = require('copy-to');
36var mime = require('mime');
37var xml = require('xml2js');
38var AgentKeepalive = require('agentkeepalive');
39var merge = require('merge-descriptors');
40var urlutil = require('url');
41var is = require('is-type-of');
42var platform = require('platform');
43var utility = require('utility');
44var urllib = require('urllib');
45var pkg = require('./version');
46var dateFormat = require('dateformat');
47var bowser = require('bowser');
48var signUtils = require('../common/signUtils');
49var _isIP = require('../common/utils/isIP');
50var _initOptions = require('../common/client/initOptions');
51
52var globalHttpAgent = new AgentKeepalive();
53
54function getHeader(headers, name) {
55 return headers[name] || headers[name.toLowerCase()];
56}
57
58function _unSupportBrowserTip() {
59 var name = platform.name,
60 version = platform.version;
61
62 if (name && name.toLowerCase && name.toLowerCase() === 'ie' && version.split('.')[0] < 10) {
63 // eslint-disable-next-line no-console
64 console.warn('ali-oss does not support the current browser');
65 }
66}
67// check local web protocol,if https secure default set true , if http secure default set false
68function isHttpsWebProtocol() {
69 // for web worker not use window.location.
70 // eslint-disable-next-line no-restricted-globals
71 return location && location.protocol === 'https:';
72}
73
74function Client(options, ctx) {
75 _unSupportBrowserTip();
76 if (!(this instanceof Client)) {
77 return new Client(options, ctx);
78 }
79 if (options && options.inited) {
80 this.options = options;
81 } else {
82 this.options = Client.initOptions(options);
83 }
84
85 this.options.cancelFlag = false; // cancel flag: if true need to be cancelled, default false
86
87 // support custom agent and urllib client
88 if (this.options.urllib) {
89 this.urllib = this.options.urllib;
90 } else {
91 this.urllib = urllib;
92 this.agent = this.options.agent || globalHttpAgent;
93 }
94 this.ctx = ctx;
95 this.userAgent = this._getUserAgent();
96
97 // record the time difference between client and server
98 this.options.amendTimeSkewed = 0;
99}
100
101/**
102 * Expose `Client`
103 */
104
105module.exports = Client;
106
107Client.initOptions = function initOptions(options) {
108 if (!options.stsToken) {
109 console.warn('Please use STS Token for safety, see more details at https://help.aliyun.com/document_detail/32077.html');
110 }
111 var opts = (0, _assign2.default)({
112 secure: isHttpsWebProtocol(),
113 // for browser compatibility disable fetch.
114 useFetch: false
115 }, options);
116
117 return _initOptions(opts);
118};
119
120/**
121 * prototype
122 */
123
124var proto = Client.prototype;
125
126// mount debug on proto
127proto.debug = debug;
128
129/**
130 * Object operations
131 */
132merge(proto, require('./object'));
133/**
134 * Bucket operations
135 */
136merge(proto, require('../common/bucket/getBucketWebsite'));
137merge(proto, require('../common/bucket/putBucketWebsite'));
138merge(proto, require('../common/bucket/deleteBucketWebsite'));
139
140// lifecycle
141merge(proto, require('../common/bucket/getBucketLifecycle'));
142merge(proto, require('../common/bucket/putBucketLifecycle'));
143merge(proto, require('../common/bucket/deleteBucketLifecycle'));
144
145// multiversion
146merge(proto, require('../common/bucket/putBucketVersioning'));
147merge(proto, require('../common/bucket/getBucketVersioning'));
148
149// multipart upload
150merge(proto, require('./managed-upload'));
151/**
152 * Multipart operations
153 */
154merge(proto, require('../common/multipart'));
155
156/**
157 * Common module parallel
158 */
159merge(proto, require('../common/parallel'));
160
161/**
162 * get OSS signature
163 * @param {String} stringToSign
164 * @return {String} the signature
165 */
166proto.signature = function signature(stringToSign) {
167 this.debug('authorization stringToSign: %s', stringToSign, 'info');
168
169 return signUtils.computeSignature(this.options.accessKeySecret, stringToSign);
170};
171
172/**
173 * get author header
174 *
175 * "Authorization: OSS " + Access Key Id + ":" + Signature
176 *
177 * Signature = base64(hmac-sha1(Access Key Secret + "\n"
178 * + VERB + "\n"
179 * + CONTENT-MD5 + "\n"
180 * + CONTENT-TYPE + "\n"
181 * + DATE + "\n"
182 * + CanonicalizedOSSHeaders
183 * + CanonicalizedResource))
184 *
185 * @param {String} method
186 * @param {String} resource
187 * @param {Object} header
188 * @return {String}
189 *
190 * @api private
191 */
192
193proto.authorization = function authorization(method, resource, subres, headers) {
194 var stringToSign = signUtils.buildCanonicalString(method.toUpperCase(), resource, {
195 headers: headers,
196 parameters: subres
197 });
198
199 return signUtils.authorization(this.options.accessKeyId, this.options.accessKeySecret, stringToSign);
200};
201
202/**
203 * create request params
204 * See `request`
205 * @api private
206 */
207
208proto.createRequest = function createRequest(params) {
209 var headers = {
210 'x-oss-date': dateFormat(+new Date() + this.options.amendTimeSkewed, 'UTC:ddd, dd mmm yyyy HH:MM:ss \'GMT\''),
211 'x-oss-user-agent': this.userAgent
212 };
213
214 if (this.options.isRequestPay) {
215 (0, _assign2.default)(headers, { 'x-oss-request-payer': 'requester' });
216 }
217
218 if (this.options.stsToken) {
219 headers['x-oss-security-token'] = this.options.stsToken;
220 }
221
222 copy(params.headers).to(headers);
223
224 if (!getHeader(headers, 'Content-Type')) {
225 if (params.mime === mime.default_type) {
226 params.mime = '';
227 }
228
229 if (params.mime && params.mime.indexOf('/') > 0) {
230 headers['Content-Type'] = params.mime;
231 } else {
232 headers['Content-Type'] = mime.getType(params.mime || path.extname(params.object || '')) || 'application/octet-stream';
233 }
234 }
235
236 if (params.content) {
237 headers['Content-Md5'] = crypto.createHash('md5').update(Buffer.from(params.content, 'utf8')).digest('base64');
238 if (!headers['Content-Length']) {
239 headers['Content-Length'] = params.content.length;
240 }
241 }
242
243 var authResource = this._getResource(params);
244 headers.authorization = this.authorization(params.method, authResource, params.subres, headers);
245
246 var url = this._getReqUrl(params);
247 this.debug('request %s %s, with headers %j, !!stream: %s', params.method, url, headers, !!params.stream, 'info');
248 var timeout = params.timeout || this.options.timeout;
249 var reqParams = {
250 agent: this.agent,
251 method: params.method,
252 content: params.content,
253 stream: params.stream,
254 headers: headers,
255 timeout: timeout,
256 writeStream: params.writeStream,
257 customResponse: params.customResponse,
258 ctx: params.ctx || this.ctx
259 };
260
261 return {
262 url: url,
263 params: reqParams
264 };
265};
266
267/**
268 * request oss server
269 * @param {Object} params
270 * - {String} object
271 * - {String} bucket
272 * - {Object} [headers]
273 * - {Object} [query]
274 * - {Buffer} [content]
275 * - {Stream} [stream]
276 * - {Stream} [writeStream]
277 * - {String} [mime]
278 * - {Boolean} [xmlResponse]
279 * - {Boolean} [customResponse]
280 * - {Number} [timeout]
281 * - {Object} [ctx] request context, default is `this.ctx`
282 *
283 * @api private
284 */
285
286proto.request = function request(params) {
287 var reqParams, result, reqErr, useStream, err, parseData;
288 return _regenerator2.default.async(function request$(_context) {
289 while (1) {
290 switch (_context.prev = _context.next) {
291 case 0:
292 reqParams = this.createRequest(params);
293
294
295 if (!this.options.useFetch) {
296 reqParams.params.mode = 'disable-fetch';
297 }
298 result = void 0;
299 reqErr = void 0;
300 useStream = !!params.stream;
301 _context.prev = 5;
302 _context.next = 8;
303 return _regenerator2.default.awrap(this.urllib.request(reqParams.url, reqParams.params));
304
305 case 8:
306 result = _context.sent;
307
308 this.debug('response %s %s, got %s, headers: %j', params.method, reqParams.url, result.status, result.headers, 'info');
309 _context.next = 15;
310 break;
311
312 case 12:
313 _context.prev = 12;
314 _context.t0 = _context['catch'](5);
315
316 reqErr = _context.t0;
317
318 case 15:
319 err = void 0;
320
321 if (!(result && params.successStatuses && params.successStatuses.indexOf(result.status) === -1)) {
322 _context.next = 28;
323 break;
324 }
325
326 _context.next = 19;
327 return _regenerator2.default.awrap(this.requestError(result));
328
329 case 19:
330 err = _context.sent;
331
332 if (!(err.code === 'RequestTimeTooSkewed' && !useStream)) {
333 _context.next = 25;
334 break;
335 }
336
337 this.options.amendTimeSkewed = +new Date(err.serverTime) - new Date();
338 _context.next = 24;
339 return _regenerator2.default.awrap(this.request(params));
340
341 case 24:
342 return _context.abrupt('return', _context.sent);
343
344 case 25:
345 err.params = params;
346 _context.next = 32;
347 break;
348
349 case 28:
350 if (!reqErr) {
351 _context.next = 32;
352 break;
353 }
354
355 _context.next = 31;
356 return _regenerator2.default.awrap(this.requestError(reqErr));
357
358 case 31:
359 err = _context.sent;
360
361 case 32:
362 if (!err) {
363 _context.next = 34;
364 break;
365 }
366
367 throw err;
368
369 case 34:
370 if (!params.xmlResponse) {
371 _context.next = 39;
372 break;
373 }
374
375 _context.next = 37;
376 return _regenerator2.default.awrap(this.parseXML(result.data));
377
378 case 37:
379 parseData = _context.sent;
380
381 result.data = parseData;
382
383 case 39:
384 return _context.abrupt('return', result);
385
386 case 40:
387 case 'end':
388 return _context.stop();
389 }
390 }
391 }, null, this, [[5, 12]]);
392};
393
394proto._getResource = function _getResource(params) {
395 var resource = '/';
396 if (params.bucket) resource += params.bucket + '/';
397 if (params.object) resource += params.object;
398
399 return resource;
400};
401
402proto._isIP = _isIP;
403
404proto._escape = function _escape(name) {
405 return utility.encodeURIComponent(name).replace(/%2F/g, '/');
406};
407
408proto._getReqUrl = function _getReqUrl(params) {
409 var ep = {};
410 copy(this.options.endpoint).to(ep);
411 var isIP = this._isIP(ep.hostname);
412 var isCname = this.options.cname;
413 if (params.bucket && !isCname && !isIP) {
414 ep.host = params.bucket + '.' + ep.host;
415 }
416
417 var reourcePath = '/';
418 if (params.bucket && isIP) {
419 reourcePath += params.bucket + '/';
420 }
421
422 if (params.object) {
423 // Preserve '/' in result url
424 reourcePath += this._escape(params.object).replace(/\+/g, '%2B');
425 }
426 ep.pathname = reourcePath;
427
428 var query = {};
429 if (params.query) {
430 merge(query, params.query);
431 }
432
433 if (params.subres) {
434 var subresAsQuery = {};
435 if (is.string(params.subres)) {
436 subresAsQuery[params.subres] = '';
437 } else if (is.array(params.subres)) {
438 params.subres.forEach(function (k) {
439 subresAsQuery[k] = '';
440 });
441 } else {
442 subresAsQuery = params.subres;
443 }
444 merge(query, subresAsQuery);
445 }
446
447 ep.query = query;
448
449 return urlutil.format(ep);
450};
451
452/*
453 * Get User-Agent for browser & node.js
454 * @example
455 * aliyun-sdk-nodejs/4.1.2 Node.js 5.3.0 on Darwin 64-bit
456 * aliyun-sdk-js/4.1.2 Safari 9.0 on Apple iPhone(iOS 9.2.1)
457 * aliyun-sdk-js/4.1.2 Chrome 43.0.2357.134 32-bit on Windows Server 2008 R2 / 7 64-bit
458 */
459
460proto._getUserAgent = function _getUserAgent() {
461 var agent = process && process.browser ? 'js' : 'nodejs';
462 var sdk = 'aliyun-sdk-' + agent + '/' + pkg.version;
463 var plat = platform.description;
464 if (!plat && process) {
465 plat = 'Node.js ' + process.version.slice(1) + ' on ' + process.platform + ' ' + process.arch;
466 }
467
468 return this._checkUserAgent(sdk + ' ' + plat);
469};
470
471proto._checkUserAgent = function _checkUserAgent(ua) {
472 var userAgent = ua.replace(/\u03b1/, 'alpha').replace(/\u03b2/, 'beta');
473 return userAgent;
474};
475
476/*
477 * Check Browser And Version
478 * @param {String} [name] browser name: like IE, Chrome, Firefox
479 * @param {String} [version] browser major version: like 10(IE 10.x), 55(Chrome 55.x), 50(Firefox 50.x)
480 * @return {Bool} true or false
481 * @api private
482 */
483
484proto.checkBrowserAndVersion = function checkBrowserAndVersion(name, version) {
485 return bowser.name === name && bowser.version.split('.')[0] === version;
486};
487
488/**
489 * thunkify xml.parseString
490 * @param {String|Buffer} str
491 *
492 * @api private
493 */
494
495proto.parseXML = function parseXMLThunk(str) {
496 return new _promise2.default(function (resolve, reject) {
497 if (Buffer.isBuffer(str)) {
498 str = str.toString();
499 }
500 xml.parseString(str, {
501 explicitRoot: false,
502 explicitArray: false
503 }, function (err, result) {
504 if (err) {
505 reject(err);
506 } else {
507 resolve(result);
508 }
509 });
510 });
511};
512
513/**
514 * generater a request error with request response
515 * @param {Object} result
516 *
517 * @api private
518 */
519
520proto.requestError = function requestError(result) {
521 var err, message, info, msg;
522 return _regenerator2.default.async(function requestError$(_context2) {
523 while (1) {
524 switch (_context2.prev = _context2.next) {
525 case 0:
526 err = null;
527
528 if (!(!result.data || !result.data.length)) {
529 _context2.next = 5;
530 break;
531 }
532
533 if (result.status === -1 || result.status === -2) {
534 // -1 is net error , -2 is timeout
535 err = new Error(result.message);
536 err.name = result.name;
537 err.status = result.status;
538 err.code = result.name;
539 } else {
540 // HEAD not exists resource
541 if (result.status === 404) {
542 err = new Error('Object not exists');
543 err.name = 'NoSuchKeyError';
544 err.status = 404;
545 err.code = 'NoSuchKey';
546 } else if (result.status === 412) {
547 err = new Error('Pre condition failed');
548 err.name = 'PreconditionFailedError';
549 err.status = 412;
550 err.code = 'PreconditionFailed';
551 } else {
552 err = new Error('Unknow error, status: ' + result.status);
553 err.name = 'UnknowError';
554 err.status = result.status;
555 }
556 err.requestId = result.headers['x-oss-request-id'];
557 err.host = '';
558 }
559 _context2.next = 33;
560 break;
561
562 case 5:
563 message = String(result.data);
564
565 this.debug('request response error data: %s', message, 'error');
566
567 info = void 0;
568 _context2.prev = 8;
569 _context2.next = 11;
570 return _regenerator2.default.awrap(this.parseXML(message));
571
572 case 11:
573 _context2.t0 = _context2.sent;
574
575 if (_context2.t0) {
576 _context2.next = 14;
577 break;
578 }
579
580 _context2.t0 = {};
581
582 case 14:
583 info = _context2.t0;
584 _context2.next = 24;
585 break;
586
587 case 17:
588 _context2.prev = 17;
589 _context2.t1 = _context2['catch'](8);
590
591 this.debug(message, 'error');
592 _context2.t1.message += '\nraw xml: ' + message;
593 _context2.t1.status = result.status;
594 _context2.t1.requestId = result.headers['x-oss-request-id'];
595 return _context2.abrupt('return', _context2.t1);
596
597 case 24:
598 msg = info.Message || 'unknow request error, status: ' + result.status;
599
600 if (info.Condition) {
601 msg += ' (condition: ' + info.Condition + ')';
602 }
603 err = new Error(msg);
604 err.name = info.Code ? info.Code + 'Error' : 'UnknowError';
605 err.status = result.status;
606 err.code = info.Code;
607 err.requestId = info.RequestId;
608 err.hostId = info.HostId;
609 err.serverTime = info.ServerTime;
610
611 case 33:
612
613 this.debug('generate error %j', err, 'error');
614 return _context2.abrupt('return', err);
615
616 case 35:
617 case 'end':
618 return _context2.stop();
619 }
620 }
621 }, null, this, [[8, 17]]);
622};
623
624}).call(this,require('_process'),require("buffer").Buffer)
625},{"../common/bucket/deleteBucketLifecycle":6,"../common/bucket/deleteBucketWebsite":7,"../common/bucket/getBucketLifecycle":8,"../common/bucket/getBucketVersioning":9,"../common/bucket/getBucketWebsite":10,"../common/bucket/putBucketLifecycle":11,"../common/bucket/putBucketVersioning":12,"../common/bucket/putBucketWebsite":13,"../common/client/initOptions":15,"../common/multipart":18,"../common/parallel":29,"../common/signUtils":30,"../common/utils/isIP":40,"./../../shims/crypto/crypto.js":328,"./managed-upload":3,"./object":4,"./version":5,"_process":249,"agentkeepalive":43,"babel-runtime/core-js/object/assign":49,"babel-runtime/core-js/promise":56,"babel-runtime/regenerator":65,"bowser":67,"buffer":70,"copy-to":73,"dateformat":187,"debug":188,"is-type-of":233,"merge-descriptors":237,"mime":332,"path":246,"platform":247,"url":279,"urllib":334,"utility":333,"xml2js":293}],3:[function(require,module,exports){
626(function (Buffer){
627'use strict';
628
629var _from = require('babel-runtime/core-js/array/from');
630
631var _from2 = _interopRequireDefault(_from);
632
633var _promise = require('babel-runtime/core-js/promise');
634
635var _promise2 = _interopRequireDefault(_promise);
636
637var _regenerator = require('babel-runtime/regenerator');
638
639var _regenerator2 = _interopRequireDefault(_regenerator);
640
641function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
642
643// var debug = require('debug')('ali-oss:multipart');
644var is = require('is-type-of');
645var util = require('util');
646var path = require('path');
647var mime = require('mime');
648var copy = require('copy-to');
649var isBlob = require('../common/utils/isBlob');
650var isFile = require('../common/utils/isFile');
651
652var proto = exports;
653
654/**
655 * Multipart operations
656 */
657
658/**
659 * Upload a file to OSS using multipart uploads
660 * @param {String} name
661 * @param {String|File} file
662 * @param {Object} options
663 * {Object} options.callback The callback parameter is composed of a JSON string encoded in Base64
664 * {String} options.callback.url the OSS sends a callback request to this URL
665 * {String} options.callback.host The host header value for initiating callback requests
666 * {String} options.callback.body The value of the request body when a callback is initiated
667 * {String} options.callback.contentType The Content-Type of the callback requests initiatiated
668 * {Object} options.callback.customValue Custom parameters are a map of key-values, e.g:
669 * customValue = {
670 * key1: 'value1',
671 * key2: 'value2'
672 * }
673 */
674proto.multipartUpload = function multipartUpload(name, file, options) {
675 var minPartSize, fileSize, stream, result, ret, initResult, uploadId, partSize, checkpoint;
676 return _regenerator2.default.async(function multipartUpload$(_context) {
677 while (1) {
678 switch (_context.prev = _context.next) {
679 case 0:
680 this.resetCancelFlag();
681 options = options || {};
682
683 if (!(options.checkpoint && options.checkpoint.uploadId)) {
684 _context.next = 6;
685 break;
686 }
687
688 _context.next = 5;
689 return _regenerator2.default.awrap(this._resumeMultipart(options.checkpoint, options));
690
691 case 5:
692 return _context.abrupt('return', _context.sent);
693
694 case 6:
695 minPartSize = 100 * 1024;
696
697
698 if (!options.mime) {
699 if (isFile(file)) {
700 options.mime = mime.getType(path.extname(file.name));
701 } else if (isBlob(file)) {
702 options.mime = file.type;
703 } else {
704 options.mime = mime.getType(path.extname(file));
705 }
706 }
707
708 options.headers = options.headers || {};
709 this._convertMetaToHeaders(options.meta, options.headers);
710
711 _context.next = 12;
712 return _regenerator2.default.awrap(this._getFileSize(file));
713
714 case 12:
715 fileSize = _context.sent;
716
717 if (!(fileSize < minPartSize)) {
718 _context.next = 25;
719 break;
720 }
721
722 stream = this._createStream(file, 0, fileSize);
723
724 options.contentLength = fileSize;
725
726 _context.next = 18;
727 return _regenerator2.default.awrap(this.putStream(name, stream, options));
728
729 case 18:
730 result = _context.sent;
731
732 if (!(options && options.progress)) {
733 _context.next = 22;
734 break;
735 }
736
737 _context.next = 22;
738 return _regenerator2.default.awrap(options.progress(1));
739
740 case 22:
741 ret = {
742 res: result.res,
743 bucket: this.options.bucket,
744 name: name,
745 etag: result.res.headers.etag
746 };
747
748
749 if (options.headers && options.headers['x-oss-callback'] || options.callback) {
750 ret.data = result.data;
751 }
752
753 return _context.abrupt('return', ret);
754
755 case 25:
756 if (!(options.partSize && !(parseInt(options.partSize, 10) === options.partSize))) {
757 _context.next = 27;
758 break;
759 }
760
761 throw new Error('partSize must be int number');
762
763 case 27:
764 if (!(options.partSize && options.partSize < minPartSize)) {
765 _context.next = 29;
766 break;
767 }
768
769 throw new Error('partSize must not be smaller than ' + minPartSize);
770
771 case 29:
772 _context.next = 31;
773 return _regenerator2.default.awrap(this.initMultipartUpload(name, options));
774
775 case 31:
776 initResult = _context.sent;
777 uploadId = initResult.uploadId;
778 partSize = this._getPartSize(fileSize, options.partSize);
779 checkpoint = {
780 file: file,
781 name: name,
782 fileSize: fileSize,
783 partSize: partSize,
784 uploadId: uploadId,
785 doneParts: []
786 };
787
788 if (!(options && options.progress)) {
789 _context.next = 38;
790 break;
791 }
792
793 _context.next = 38;
794 return _regenerator2.default.awrap(options.progress(0, checkpoint, initResult.res));
795
796 case 38:
797 _context.next = 40;
798 return _regenerator2.default.awrap(this._resumeMultipart(checkpoint, options));
799
800 case 40:
801 return _context.abrupt('return', _context.sent);
802
803 case 41:
804 case 'end':
805 return _context.stop();
806 }
807 }
808 }, null, this);
809};
810
811/*
812 * Resume multipart upload from checkpoint. The checkpoint will be
813 * updated after each successful part upload.
814 * @param {Object} checkpoint the checkpoint
815 * @param {Object} options
816 */
817proto._resumeMultipart = function _resumeMultipart(checkpoint, options) {
818 var that, file, fileSize, partSize, uploadId, doneParts, name, internalDoneParts, partOffs, numParts, multipartFinish, uploadPartJob, all, done, todo, defaultParallel, parallel, jobErr;
819 return _regenerator2.default.async(function _resumeMultipart$(_context3) {
820 while (1) {
821 switch (_context3.prev = _context3.next) {
822 case 0:
823 that = this;
824
825 if (!this.isCancel()) {
826 _context3.next = 3;
827 break;
828 }
829
830 throw this._makeCancelEvent();
831
832 case 3:
833 file = checkpoint.file, fileSize = checkpoint.fileSize, partSize = checkpoint.partSize, uploadId = checkpoint.uploadId, doneParts = checkpoint.doneParts, name = checkpoint.name;
834 internalDoneParts = [];
835
836
837 if (doneParts.length > 0) {
838 copy(doneParts).to(internalDoneParts);
839 }
840
841 partOffs = this._divideParts(fileSize, partSize);
842 numParts = partOffs.length;
843 multipartFinish = false;
844
845 uploadPartJob = function uploadPartJob(self, partNo) {
846 var _this = this;
847
848 return new _promise2.default(function _callee(resolve, reject) {
849 var pi, data, result, tempErr;
850 return _regenerator2.default.async(function _callee$(_context2) {
851 while (1) {
852 switch (_context2.prev = _context2.next) {
853 case 0:
854 _context2.prev = 0;
855
856 if (self.isCancel()) {
857 _context2.next = 18;
858 break;
859 }
860
861 pi = partOffs[partNo - 1];
862 data = {
863 stream: self._createStream(file, pi.start, pi.end),
864 size: pi.end - pi.start
865 };
866 _context2.next = 6;
867 return _regenerator2.default.awrap(self._uploadPart(name, uploadId, partNo, data));
868
869 case 6:
870 result = _context2.sent;
871
872 if (!(!self.isCancel() && !multipartFinish)) {
873 _context2.next = 15;
874 break;
875 }
876
877 checkpoint.doneParts.push({
878 number: partNo,
879 etag: result.res.headers.etag
880 });
881
882 if (!options.progress) {
883 _context2.next = 12;
884 break;
885 }
886
887 _context2.next = 12;
888 return _regenerator2.default.awrap(options.progress(doneParts.length / numParts, checkpoint, result.res));
889
890 case 12:
891
892 resolve({
893 number: partNo,
894 etag: result.res.headers.etag
895 });
896 _context2.next = 16;
897 break;
898
899 case 15:
900 resolve();
901
902 case 16:
903 _context2.next = 19;
904 break;
905
906 case 18:
907 resolve();
908
909 case 19:
910 _context2.next = 30;
911 break;
912
913 case 21:
914 _context2.prev = 21;
915 _context2.t0 = _context2['catch'](0);
916 tempErr = new Error();
917
918 tempErr.name = _context2.t0.name;
919 tempErr.message = _context2.t0.message;
920 tempErr.stack = _context2.t0.stack;
921 tempErr.partNum = partNo;
922 copy(_context2.t0).to(tempErr);
923 reject(tempErr);
924
925 case 30:
926 case 'end':
927 return _context2.stop();
928 }
929 }
930 }, null, _this, [[0, 21]]);
931 });
932 };
933
934 all = (0, _from2.default)(new Array(numParts), function (x, i) {
935 return i + 1;
936 });
937 done = internalDoneParts.map(function (p) {
938 return p.number;
939 });
940 todo = all.filter(function (p) {
941 return done.indexOf(p) < 0;
942 });
943 defaultParallel = 5;
944 parallel = options.parallel || defaultParallel;
945
946 // upload in parallel
947
948 _context3.next = 17;
949 return _regenerator2.default.awrap(this._parallel(todo, parallel, function (value) {
950 return new _promise2.default(function (resolve, reject) {
951 uploadPartJob(that, value).then(function (result) {
952 if (result) {
953 internalDoneParts.push(result);
954 }
955 resolve();
956 }).catch(function (err) {
957 reject(err);
958 });
959 });
960 }));
961
962 case 17:
963 jobErr = _context3.sent;
964
965 multipartFinish = true;
966
967 if (!this.isCancel()) {
968 _context3.next = 22;
969 break;
970 }
971
972 uploadPartJob = null;
973 throw this._makeCancelEvent();
974
975 case 22:
976 if (!(jobErr && jobErr.length > 0)) {
977 _context3.next = 25;
978 break;
979 }
980
981 jobErr[0].message = 'Failed to upload some parts with error: ' + jobErr[0].toString() + ' part_num: ' + jobErr[0].partNum;
982 throw jobErr[0];
983
984 case 25:
985 _context3.next = 27;
986 return _regenerator2.default.awrap(this.completeMultipartUpload(name, uploadId, internalDoneParts, options));
987
988 case 27:
989 return _context3.abrupt('return', _context3.sent);
990
991 case 28:
992 case 'end':
993 return _context3.stop();
994 }
995 }
996 }, null, this);
997};
998
999/**
1000 * Get file size
1001 */
1002proto._getFileSize = function _getFileSize(file) {
1003 return _regenerator2.default.async(function _getFileSize$(_context4) {
1004 while (1) {
1005 switch (_context4.prev = _context4.next) {
1006 case 0:
1007 if (!is.buffer(file)) {
1008 _context4.next = 4;
1009 break;
1010 }
1011
1012 return _context4.abrupt('return', file.length);
1013
1014 case 4:
1015 if (!(isBlob(file) || isFile(file))) {
1016 _context4.next = 6;
1017 break;
1018 }
1019
1020 return _context4.abrupt('return', file.size);
1021
1022 case 6:
1023 throw new Error('_getFileSize requires Buffer/File/Blob.');
1024
1025 case 7:
1026 case 'end':
1027 return _context4.stop();
1028 }
1029 }
1030 }, null, this);
1031};
1032
1033/*
1034 * Readable stream for Web File
1035 */
1036
1037var _require = require('stream'),
1038 Readable = _require.Readable;
1039
1040function WebFileReadStream(file, options) {
1041 if (!(this instanceof WebFileReadStream)) {
1042 return new WebFileReadStream(file, options);
1043 }
1044
1045 Readable.call(this, options);
1046
1047 this.file = file;
1048 this.reader = new FileReader();
1049 this.start = 0;
1050 this.finish = false;
1051 this.fileBuffer = null;
1052}
1053util.inherits(WebFileReadStream, Readable);
1054
1055WebFileReadStream.prototype.readFileAndPush = function readFileAndPush(size) {
1056 if (this.fileBuffer) {
1057 var pushRet = true;
1058 while (pushRet && this.fileBuffer && this.start < this.fileBuffer.length) {
1059 var start = this.start;
1060
1061 var end = start + size;
1062 end = end > this.fileBuffer.length ? this.fileBuffer.length : end;
1063 this.start = end;
1064 pushRet = this.push(this.fileBuffer.slice(start, end));
1065 }
1066 }
1067};
1068
1069WebFileReadStream.prototype._read = function _read(size) {
1070 if (this.file && this.start >= this.file.size || this.fileBuffer && this.start >= this.fileBuffer.length || this.finish || this.start === 0 && !this.file) {
1071 if (!this.finish) {
1072 this.fileBuffer = null;
1073 this.finish = true;
1074 }
1075 this.push(null);
1076 return;
1077 }
1078
1079 var defaultReadSize = 16 * 1024;
1080 size = size || defaultReadSize;
1081
1082 var that = this;
1083 this.reader.onload = function onload(e) {
1084 that.fileBuffer = Buffer.from(new Uint8Array(e.target.result));
1085 that.file = null;
1086 that.readFileAndPush(size);
1087 };
1088
1089 if (this.start === 0) {
1090 this.reader.readAsArrayBuffer(this.file);
1091 } else {
1092 this.readFileAndPush(size);
1093 }
1094};
1095
1096proto._createStream = function _createStream(file, start, end) {
1097 if (isBlob(file) || isFile(file)) {
1098 return new WebFileReadStream(file.slice(start, end));
1099 }
1100 // else if (is.string(file)) {
1101 // return fs.createReadStream(file, {
1102 // start: start,
1103 // end: end - 1
1104 // });
1105 // }
1106
1107 throw new Error('_createStream requires File/Blob.');
1108};
1109
1110proto._getPartSize = function _getPartSize(fileSize, partSize) {
1111 var maxNumParts = 10 * 1000;
1112 var defaultPartSize = 1024 * 1024;
1113
1114 if (!partSize) {
1115 return defaultPartSize;
1116 }
1117
1118 return Math.max(Math.ceil(fileSize / maxNumParts), partSize);
1119};
1120
1121proto._divideParts = function _divideParts(fileSize, partSize) {
1122 var numParts = Math.ceil(fileSize / partSize);
1123
1124 var partOffs = [];
1125 for (var i = 0; i < numParts; i++) {
1126 var start = partSize * i;
1127 var end = Math.min(start + partSize, fileSize);
1128
1129 partOffs.push({
1130 start: start,
1131 end: end
1132 });
1133 }
1134
1135 return partOffs;
1136};
1137
1138}).call(this,require("buffer").Buffer)
1139},{"../common/utils/isBlob":38,"../common/utils/isFile":39,"babel-runtime/core-js/array/from":47,"babel-runtime/core-js/promise":56,"babel-runtime/regenerator":65,"buffer":70,"copy-to":73,"is-type-of":233,"mime":332,"path":246,"stream":271,"util":287}],4:[function(require,module,exports){
1140'use strict';
1141
1142var _promise = require('babel-runtime/core-js/promise');
1143
1144var _promise2 = _interopRequireDefault(_promise);
1145
1146var _keys = require('babel-runtime/core-js/object/keys');
1147
1148var _keys2 = _interopRequireDefault(_keys);
1149
1150var _assign = require('babel-runtime/core-js/object/assign');
1151
1152var _assign2 = _interopRequireDefault(_assign);
1153
1154var _regenerator = require('babel-runtime/regenerator');
1155
1156var _regenerator2 = _interopRequireDefault(_regenerator);
1157
1158function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1159
1160// const debug = require('debug')('ali-oss:object');
1161var utility = require('utility');
1162var fs = require('fs');
1163var is = require('is-type-of');
1164var urlutil = require('url');
1165var copy = require('copy-to');
1166var path = require('path');
1167var mime = require('mime');
1168var callback = require('../common/callback');
1169var signHelper = require('../common/signUtils');
1170var merge = require('merge-descriptors');
1171var isBlob = require('../common/utils/isBlob');
1172var isFile = require('../common/utils/isFile');
1173
1174// var assert = require('assert');
1175
1176
1177var proto = exports;
1178
1179/**
1180 * Object operations
1181 */
1182
1183/**
1184 * append an object from String(file path)/Buffer/ReadableStream
1185 * @param {String} name the object key
1186 * @param {Mixed} file String(file path)/Buffer/ReadableStream
1187 * @param {Object} options
1188 * @return {Object}
1189 */
1190proto.append = function append(name, file, options) {
1191 var result;
1192 return _regenerator2.default.async(function append$(_context) {
1193 while (1) {
1194 switch (_context.prev = _context.next) {
1195 case 0:
1196 options = options || {};
1197 if (options.position === undefined) options.position = '0';
1198 options.subres = {
1199 append: '',
1200 position: options.position
1201 };
1202 options.method = 'POST';
1203
1204 _context.next = 6;
1205 return _regenerator2.default.awrap(this.put(name, file, options));
1206
1207 case 6:
1208 result = _context.sent;
1209
1210 result.nextAppendPosition = result.res.headers['x-oss-next-append-position'];
1211 return _context.abrupt('return', result);
1212
1213 case 9:
1214 case 'end':
1215 return _context.stop();
1216 }
1217 }
1218 }, null, this);
1219};
1220
1221/**
1222 * put an object from String(file path)/Buffer/ReadableStream
1223 * @param {String} name the object key
1224 * @param {Mixed} file String(file path)/Buffer/ReadableStream
1225 * @param {Object} options
1226 * {Object} options.callback The callback parameter is composed of a JSON string encoded in Base64
1227 * {String} options.callback.url the OSS sends a callback request to this URL
1228 * {String} options.callback.host The host header value for initiating callback requests
1229 * {String} options.callback.body The value of the request body when a callback is initiated
1230 * {String} options.callback.contentType The Content-Type of the callback requests initiatiated
1231 * {Object} options.callback.customValue Custom parameters are a map of key-values, e.g:
1232 * customValue = {
1233 * key1: 'value1',
1234 * key2: 'value2'
1235 * }
1236 * @return {Object}
1237 */
1238proto.put = function put(name, file, options) {
1239 var content, stream, _result, method, params, result, ret;
1240
1241 return _regenerator2.default.async(function put$(_context2) {
1242 while (1) {
1243 switch (_context2.prev = _context2.next) {
1244 case 0:
1245 content = void 0;
1246
1247 options = options || {};
1248 name = this._objectName(name);
1249
1250 if (!is.buffer(file)) {
1251 _context2.next = 7;
1252 break;
1253 }
1254
1255 content = file;
1256 _context2.next = 30;
1257 break;
1258
1259 case 7:
1260 if (!(isBlob(file) || isFile(file))) {
1261 _context2.next = 29;
1262 break;
1263 }
1264
1265 if (!options.mime) {
1266 if (isFile(file)) {
1267 options.mime = mime.getType(path.extname(file.name));
1268 } else {
1269 options.mime = file.type;
1270 }
1271 }
1272
1273 stream = this._createStream(file, 0, file.size);
1274 _context2.next = 12;
1275 return _regenerator2.default.awrap(this._getFileSize(file));
1276
1277 case 12:
1278 options.contentLength = _context2.sent;
1279 _context2.prev = 13;
1280 _context2.next = 16;
1281 return _regenerator2.default.awrap(this.putStream(name, stream, options));
1282
1283 case 16:
1284 _result = _context2.sent;
1285 return _context2.abrupt('return', _result);
1286
1287 case 20:
1288 _context2.prev = 20;
1289 _context2.t0 = _context2['catch'](13);
1290
1291 if (!(_context2.t0.code === 'RequestTimeTooSkewed')) {
1292 _context2.next = 27;
1293 break;
1294 }
1295
1296 this.options.amendTimeSkewed = +new Date(_context2.t0.serverTime) - new Date();
1297 _context2.next = 26;
1298 return _regenerator2.default.awrap(this.put(name, file, options));
1299
1300 case 26:
1301 return _context2.abrupt('return', _context2.sent);
1302
1303 case 27:
1304 _context2.next = 30;
1305 break;
1306
1307 case 29:
1308 throw new TypeError('Must provide Buffer/Blob/File for put.');
1309
1310 case 30:
1311
1312 options.headers = options.headers || {};
1313 this._convertMetaToHeaders(options.meta, options.headers);
1314
1315 method = options.method || 'PUT';
1316 params = this._objectRequestParams(method, name, options);
1317
1318 callback.encodeCallback(params, options);
1319 params.mime = options.mime;
1320 params.content = content;
1321 params.successStatuses = [200];
1322
1323 _context2.next = 40;
1324 return _regenerator2.default.awrap(this.request(params));
1325
1326 case 40:
1327 result = _context2.sent;
1328 ret = {
1329 name: name,
1330 url: this._objectUrl(name),
1331 res: result.res
1332 };
1333
1334
1335 if (params.headers && params.headers['x-oss-callback']) {
1336 ret.data = JSON.parse(result.data.toString());
1337 }
1338
1339 return _context2.abrupt('return', ret);
1340
1341 case 44:
1342 case 'end':
1343 return _context2.stop();
1344 }
1345 }
1346 }, null, this, [[13, 20]]);
1347};
1348
1349/**
1350 * put an object from ReadableStream. If `options.contentLength` is
1351 * not provided, chunked encoding is used.
1352 * @param {String} name the object key
1353 * @param {Readable} stream the ReadableStream
1354 * @param {Object} options
1355 * @return {Object}
1356 */
1357proto.putStream = function putStream(name, stream, options) {
1358 var method, params, result, ret;
1359 return _regenerator2.default.async(function putStream$(_context3) {
1360 while (1) {
1361 switch (_context3.prev = _context3.next) {
1362 case 0:
1363 options = options || {};
1364 options.headers = options.headers || {};
1365 name = this._objectName(name);
1366 if (options.contentLength) {
1367 options.headers['Content-Length'] = options.contentLength;
1368 } else {
1369 options.headers['Transfer-Encoding'] = 'chunked';
1370 }
1371 this._convertMetaToHeaders(options.meta, options.headers);
1372
1373 method = options.method || 'PUT';
1374 params = this._objectRequestParams(method, name, options);
1375
1376 callback.encodeCallback(params, options);
1377 params.mime = options.mime;
1378 params.stream = stream;
1379 params.successStatuses = [200];
1380
1381 _context3.next = 13;
1382 return _regenerator2.default.awrap(this.request(params));
1383
1384 case 13:
1385 result = _context3.sent;
1386 ret = {
1387 name: name,
1388 url: this._objectUrl(name),
1389 res: result.res
1390 };
1391
1392
1393 if (params.headers && params.headers['x-oss-callback']) {
1394 ret.data = JSON.parse(result.data.toString());
1395 }
1396
1397 return _context3.abrupt('return', ret);
1398
1399 case 17:
1400 case 'end':
1401 return _context3.stop();
1402 }
1403 }
1404 }, null, this);
1405};
1406
1407merge(proto, require('../common/object/copyObject'));
1408merge(proto, require('../common/object/getObjectTagging'));
1409merge(proto, require('../common/object/putObjectTagging'));
1410merge(proto, require('../common/object/deleteObjectTagging'));
1411merge(proto, require('../common/image'));
1412merge(proto, require('../common/object/getBucketVersions'));
1413merge(proto, require('../common/object/getACL'));
1414merge(proto, require('../common/object/putACL'));
1415merge(proto, require('../common/object/head'));
1416merge(proto, require('../common/object/delete'));
1417merge(proto, require('../common/object/get'));
1418
1419proto.putMeta = function putMeta(name, meta, options) {
1420 var copyResult;
1421 return _regenerator2.default.async(function putMeta$(_context4) {
1422 while (1) {
1423 switch (_context4.prev = _context4.next) {
1424 case 0:
1425 _context4.next = 2;
1426 return _regenerator2.default.awrap(this.copy(name, name, {
1427 meta: meta || {},
1428 timeout: options && options.timeout,
1429 ctx: options && options.ctx
1430 }));
1431
1432 case 2:
1433 copyResult = _context4.sent;
1434 return _context4.abrupt('return', copyResult);
1435
1436 case 4:
1437 case 'end':
1438 return _context4.stop();
1439 }
1440 }
1441 }, null, this);
1442};
1443
1444proto.list = function list(query, options) {
1445 var params, result, objects, that, prefixes;
1446 return _regenerator2.default.async(function list$(_context5) {
1447 while (1) {
1448 switch (_context5.prev = _context5.next) {
1449 case 0:
1450 // prefix, marker, max-keys, delimiter
1451
1452 params = this._objectRequestParams('GET', '', options);
1453
1454 params.query = query;
1455 params.xmlResponse = true;
1456 params.successStatuses = [200];
1457
1458 _context5.next = 6;
1459 return _regenerator2.default.awrap(this.request(params));
1460
1461 case 6:
1462 result = _context5.sent;
1463 objects = result.data.Contents;
1464 that = this;
1465
1466 if (objects) {
1467 if (!Array.isArray(objects)) {
1468 objects = [objects];
1469 }
1470 objects = objects.map(function (obj) {
1471 return {
1472 name: obj.Key,
1473 url: that._objectUrl(obj.Key),
1474 lastModified: obj.LastModified,
1475 etag: obj.ETag,
1476 type: obj.Type,
1477 size: Number(obj.Size),
1478 storageClass: obj.StorageClass,
1479 owner: {
1480 id: obj.Owner.ID,
1481 displayName: obj.Owner.DisplayName
1482 }
1483 };
1484 });
1485 }
1486 prefixes = result.data.CommonPrefixes || null;
1487
1488 if (prefixes) {
1489 if (!Array.isArray(prefixes)) {
1490 prefixes = [prefixes];
1491 }
1492 prefixes = prefixes.map(function (item) {
1493 return item.Prefix;
1494 });
1495 }
1496 return _context5.abrupt('return', {
1497 res: result.res,
1498 objects: objects,
1499 prefixes: prefixes,
1500 nextMarker: result.data.NextMarker || null,
1501 isTruncated: result.data.IsTruncated === 'true'
1502 });
1503
1504 case 13:
1505 case 'end':
1506 return _context5.stop();
1507 }
1508 }
1509 }, null, this);
1510};
1511
1512/**
1513 * Restore Object
1514 * @param {String} name the object key
1515 * @param {Object} options
1516 * @returns {{res}}
1517 */
1518proto.restore = function restore(name, options) {
1519 var params, result;
1520 return _regenerator2.default.async(function restore$(_context6) {
1521 while (1) {
1522 switch (_context6.prev = _context6.next) {
1523 case 0:
1524 options = options || {};
1525 options.subres = (0, _assign2.default)({ restore: '' }, options.subres);
1526 if (options.versionId) {
1527 options.subres.versionId = options.versionId;
1528 }
1529 params = this._objectRequestParams('POST', name, options);
1530
1531 params.successStatuses = [202];
1532
1533 _context6.next = 7;
1534 return _regenerator2.default.awrap(this.request(params));
1535
1536 case 7:
1537 result = _context6.sent;
1538 return _context6.abrupt('return', {
1539 res: result.res
1540 });
1541
1542 case 9:
1543 case 'end':
1544 return _context6.stop();
1545 }
1546 }
1547 }, null, this);
1548};
1549
1550proto.signatureUrl = function signatureUrl(name, options) {
1551 options = options || {};
1552 name = this._objectName(name);
1553 options.method = options.method || 'GET';
1554 var expires = utility.timestamp() + (options.expires || 1800);
1555 var params = {
1556 bucket: this.options.bucket,
1557 object: name
1558 };
1559
1560 var resource = this._getResource(params);
1561
1562 if (this.options.stsToken) {
1563 options['security-token'] = this.options.stsToken;
1564 }
1565
1566 var signRes = signHelper._signatureForURL(this.options.accessKeySecret, options, resource, expires);
1567
1568 var url = urlutil.parse(this._getReqUrl(params));
1569 url.query = {
1570 OSSAccessKeyId: this.options.accessKeyId,
1571 Expires: expires,
1572 Signature: signRes.Signature
1573 };
1574
1575 copy(signRes.subResource).to(url.query);
1576
1577 return url.format();
1578};
1579
1580/**
1581 * Get Object url by name
1582 * @param {String} name - object name
1583 * @param {String} [baseUrl] - If provide `baseUrl`,
1584 * will use `baseUrl` instead the default `endpoint`.
1585 * @return {String} object url
1586 */
1587proto.getObjectUrl = function getObjectUrl(name, baseUrl) {
1588 if (!baseUrl) {
1589 baseUrl = this.options.endpoint.format();
1590 } else if (baseUrl[baseUrl.length - 1] !== '/') {
1591 baseUrl += '/';
1592 }
1593 return baseUrl + this._escape(this._objectName(name));
1594};
1595
1596proto._objectUrl = function _objectUrl(name) {
1597 return this._getReqUrl({ bucket: this.options.bucket, object: name });
1598};
1599
1600/**
1601 * Get Object url by name
1602 * @param {String} name - object name
1603 * @param {String} [baseUrl] - If provide `baseUrl`, will use `baseUrl` instead the default `endpoint and bucket`.
1604 * @return {String} object url include bucket
1605 */
1606proto.generateObjectUrl = function (name, baseUrl) {
1607 if (!baseUrl) {
1608 baseUrl = this.options.endpoint.format();
1609 var copyUrl = urlutil.parse(baseUrl);
1610 var bucket = this.options.bucket;
1611
1612
1613 copyUrl.hostname = bucket + '.' + copyUrl.hostname;
1614 copyUrl.host = bucket + '.' + copyUrl.host;
1615 baseUrl = copyUrl.format();
1616 } else if (baseUrl[baseUrl.length - 1] !== '/') {
1617 baseUrl += '/';
1618 }
1619 return baseUrl + this._escape(this._objectName(name));
1620};
1621
1622/**
1623 * generator request params
1624 * @return {Object} params
1625 *
1626 * @api private
1627 */
1628
1629proto._objectRequestParams = function _objectRequestParams(method, name, options) {
1630 if (!this.options.bucket) {
1631 throw new Error('Please create a bucket first');
1632 }
1633
1634 options = options || {};
1635 name = this._objectName(name);
1636 var params = {
1637 object: name,
1638 bucket: this.options.bucket,
1639 method: method,
1640 subres: options && options.subres,
1641 timeout: options && options.timeout,
1642 ctx: options && options.ctx
1643 };
1644
1645 if (options.headers) {
1646 params.headers = {};
1647 copy(options.headers).to(params.headers);
1648 }
1649 return params;
1650};
1651
1652proto._objectName = function _objectName(name) {
1653 return name.replace(/^\/+/, '');
1654};
1655
1656proto._convertMetaToHeaders = function _convertMetaToHeaders(meta, headers) {
1657 if (!meta) {
1658 return;
1659 }
1660
1661 (0, _keys2.default)(meta).forEach(function (k) {
1662 headers['x-oss-meta-' + k] = meta[k];
1663 });
1664};
1665
1666proto._deleteFileSafe = function _deleteFileSafe(filepath) {
1667 var _this = this;
1668
1669 return new _promise2.default(function (resolve) {
1670 fs.exists(filepath, function (exists) {
1671 if (!exists) {
1672 resolve();
1673 } else {
1674 fs.unlink(filepath, function (err) {
1675 if (err) {
1676 _this.debug('unlink %j error: %s', filepath, err, 'error');
1677 }
1678 resolve();
1679 });
1680 }
1681 });
1682 });
1683};
1684
1685},{"../common/callback":14,"../common/image":16,"../common/object/copyObject":19,"../common/object/delete":20,"../common/object/deleteObjectTagging":21,"../common/object/get":22,"../common/object/getACL":23,"../common/object/getBucketVersions":24,"../common/object/getObjectTagging":25,"../common/object/head":26,"../common/object/putACL":27,"../common/object/putObjectTagging":28,"../common/signUtils":30,"../common/utils/isBlob":38,"../common/utils/isFile":39,"babel-runtime/core-js/object/assign":49,"babel-runtime/core-js/object/keys":55,"babel-runtime/core-js/promise":56,"babel-runtime/regenerator":65,"copy-to":73,"fs":68,"is-type-of":233,"merge-descriptors":237,"mime":332,"path":246,"url":279,"utility":333}],5:[function(require,module,exports){
1686"use strict";
1687
1688exports.version = "6.8.0";
1689
1690},{}],6:[function(require,module,exports){
1691'use strict';
1692
1693var _regenerator = require('babel-runtime/regenerator');
1694
1695var _regenerator2 = _interopRequireDefault(_regenerator);
1696
1697function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1698
1699var _checkBucketName = require('../utils/checkBucketName');
1700
1701var proto = exports;
1702
1703proto.deleteBucketLifecycle = function deleteBucketLifecycle(name, options) {
1704 var params, result;
1705 return _regenerator2.default.async(function deleteBucketLifecycle$(_context) {
1706 while (1) {
1707 switch (_context.prev = _context.next) {
1708 case 0:
1709 _checkBucketName(name);
1710 params = this._bucketRequestParams('DELETE', name, 'lifecycle', options);
1711
1712 params.successStatuses = [204];
1713 _context.next = 5;
1714 return _regenerator2.default.awrap(this.request(params));
1715
1716 case 5:
1717 result = _context.sent;
1718 return _context.abrupt('return', {
1719 res: result.res
1720 });
1721
1722 case 7:
1723 case 'end':
1724 return _context.stop();
1725 }
1726 }
1727 }, null, this);
1728};
1729
1730},{"../utils/checkBucketName":31,"babel-runtime/regenerator":65}],7:[function(require,module,exports){
1731'use strict';
1732
1733var _regenerator = require('babel-runtime/regenerator');
1734
1735var _regenerator2 = _interopRequireDefault(_regenerator);
1736
1737function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1738
1739var _checkBucketName = require('../utils/checkBucketName');
1740
1741var proto = exports;
1742
1743proto.deleteBucketWebsite = function deleteBucketWebsite(name, options) {
1744 var params, result;
1745 return _regenerator2.default.async(function deleteBucketWebsite$(_context) {
1746 while (1) {
1747 switch (_context.prev = _context.next) {
1748 case 0:
1749 _checkBucketName(name);
1750 params = this._bucketRequestParams('DELETE', name, 'website', options);
1751
1752 params.successStatuses = [204];
1753 _context.next = 5;
1754 return _regenerator2.default.awrap(this.request(params));
1755
1756 case 5:
1757 result = _context.sent;
1758 return _context.abrupt('return', {
1759 res: result.res
1760 });
1761
1762 case 7:
1763 case 'end':
1764 return _context.stop();
1765 }
1766 }
1767 }, null, this);
1768};
1769
1770},{"../utils/checkBucketName":31,"babel-runtime/regenerator":65}],8:[function(require,module,exports){
1771'use strict';
1772
1773var _regenerator = require('babel-runtime/regenerator');
1774
1775var _regenerator2 = _interopRequireDefault(_regenerator);
1776
1777function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1778
1779var _checkBucketName = require('../utils/checkBucketName');
1780var isArray = require('../utils/isArray');
1781var formatObjKey = require('../utils/formatObjKey');
1782
1783var proto = exports;
1784
1785proto.getBucketLifecycle = function getBucketLifecycle(name, options) {
1786 var params, result, rules;
1787 return _regenerator2.default.async(function getBucketLifecycle$(_context) {
1788 while (1) {
1789 switch (_context.prev = _context.next) {
1790 case 0:
1791 _checkBucketName(name);
1792 params = this._bucketRequestParams('GET', name, 'lifecycle', options);
1793
1794 params.successStatuses = [200];
1795 params.xmlResponse = true;
1796 _context.next = 6;
1797 return _regenerator2.default.awrap(this.request(params));
1798
1799 case 6:
1800 result = _context.sent;
1801 rules = result.data.Rule || null;
1802
1803 if (rules) {
1804 if (!isArray(rules)) {
1805 rules = [rules];
1806 }
1807 rules = rules.map(function (_) {
1808 if (_.ID) {
1809 _.id = _.ID;
1810 delete _.ID;
1811 }
1812 if (_.Tag && !isArray(_.Tag)) {
1813 _.Tag = [_.Tag];
1814 }
1815 return formatObjKey(_, 'firstLowerCase');
1816 });
1817 }
1818 return _context.abrupt('return', {
1819 rules: rules,
1820 res: result.res
1821 });
1822
1823 case 10:
1824 case 'end':
1825 return _context.stop();
1826 }
1827 }
1828 }, null, this);
1829};
1830
1831},{"../utils/checkBucketName":31,"../utils/formatObjKey":35,"../utils/isArray":37,"babel-runtime/regenerator":65}],9:[function(require,module,exports){
1832'use strict';
1833
1834var _regenerator = require('babel-runtime/regenerator');
1835
1836var _regenerator2 = _interopRequireDefault(_regenerator);
1837
1838function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1839
1840var _checkBucketName = require('../utils/checkBucketName');
1841
1842var proto = exports;
1843/**
1844 * getBucketVersioning
1845 * @param {String} bucketName - bucket name
1846 */
1847
1848proto.getBucketVersioning = function getBucketVersioning(bucketName, options) {
1849 var params, result, versionStatus;
1850 return _regenerator2.default.async(function getBucketVersioning$(_context) {
1851 while (1) {
1852 switch (_context.prev = _context.next) {
1853 case 0:
1854 _checkBucketName(bucketName);
1855 params = this._bucketRequestParams('GET', bucketName, 'versioning', options);
1856
1857 params.xmlResponse = true;
1858 params.successStatuses = [200];
1859 _context.next = 6;
1860 return _regenerator2.default.awrap(this.request(params));
1861
1862 case 6:
1863 result = _context.sent;
1864 versionStatus = result.data.Status;
1865 return _context.abrupt('return', {
1866 status: result.status,
1867 versionStatus: versionStatus,
1868 res: result.res
1869 });
1870
1871 case 9:
1872 case 'end':
1873 return _context.stop();
1874 }
1875 }
1876 }, null, this);
1877};
1878
1879},{"../utils/checkBucketName":31,"babel-runtime/regenerator":65}],10:[function(require,module,exports){
1880'use strict';
1881
1882var _regenerator = require('babel-runtime/regenerator');
1883
1884var _regenerator2 = _interopRequireDefault(_regenerator);
1885
1886function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1887
1888var _checkBucketName = require('../utils/checkBucketName');
1889var isObject = require('../utils/isObject');
1890
1891var proto = exports;
1892
1893proto.getBucketWebsite = function getBucketWebsite(name, options) {
1894 var params, result, routingRules;
1895 return _regenerator2.default.async(function getBucketWebsite$(_context) {
1896 while (1) {
1897 switch (_context.prev = _context.next) {
1898 case 0:
1899 _checkBucketName(name);
1900 params = this._bucketRequestParams('GET', name, 'website', options);
1901
1902 params.successStatuses = [200];
1903 params.xmlResponse = true;
1904 _context.next = 6;
1905 return _regenerator2.default.awrap(this.request(params));
1906
1907 case 6:
1908 result = _context.sent;
1909 routingRules = [];
1910
1911 if (result.data.RoutingRules && result.data.RoutingRules.RoutingRule) {
1912 if (isObject(result.data.RoutingRules.RoutingRule)) {
1913 routingRules = [result.data.RoutingRules.RoutingRule];
1914 } else {
1915 routingRules = result.data.RoutingRules.RoutingRule;
1916 }
1917 }
1918 return _context.abrupt('return', {
1919 index: result.data.IndexDocument && result.data.IndexDocument.Suffix || '',
1920 supportSubDir: result.data.IndexDocument && result.data.IndexDocument.SupportSubDir || 'false',
1921 type: result.data.IndexDocument && result.data.IndexDocument.Type,
1922 routingRules: routingRules,
1923 error: result.data.ErrorDocument && result.data.ErrorDocument.Key || null,
1924 res: result.res
1925 });
1926
1927 case 10:
1928 case 'end':
1929 return _context.stop();
1930 }
1931 }
1932 }, null, this);
1933};
1934
1935},{"../utils/checkBucketName":31,"../utils/isObject":41,"babel-runtime/regenerator":65}],11:[function(require,module,exports){
1936'use strict';
1937
1938var _regenerator = require('babel-runtime/regenerator');
1939
1940var _regenerator2 = _interopRequireDefault(_regenerator);
1941
1942function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1943
1944/* eslint-disable no-use-before-define */
1945var _checkBucketName = require('../utils/checkBucketName');
1946var isArray = require('../utils/isArray');
1947var deepCopy = require('../utils/deepCopy');
1948var isObject = require('../utils/isObject');
1949var obj2xml = require('../utils/obj2xml');
1950var checkObjectTag = require('../utils/checkObjectTag');
1951var getStrBytesCount = require('../utils/getStrBytesCount');
1952
1953var proto = exports;
1954
1955proto.putBucketLifecycle = function putBucketLifecycle(name, rules, options) {
1956 var params, Rule, paramXMLObj, paramXML, result;
1957 return _regenerator2.default.async(function putBucketLifecycle$(_context) {
1958 while (1) {
1959 switch (_context.prev = _context.next) {
1960 case 0:
1961 _checkBucketName(name);
1962
1963 if (isArray(rules)) {
1964 _context.next = 3;
1965 break;
1966 }
1967
1968 throw new Error('rules must be Array');
1969
1970 case 3:
1971 params = this._bucketRequestParams('PUT', name, 'lifecycle', options);
1972 Rule = [];
1973 paramXMLObj = {
1974 LifecycleConfiguration: {
1975 Rule: Rule
1976 }
1977 };
1978
1979
1980 rules.forEach(function (_) {
1981 defaultDaysAndDate2Expiration(_); // todo delete, 兼容旧版本
1982 checkRule(_);
1983 if (_.id) {
1984 _.ID = _.id;
1985 delete _.id;
1986 }
1987 Rule.push(_);
1988 });
1989
1990 paramXML = obj2xml(paramXMLObj, {
1991 headers: true,
1992 firstUpperCase: true
1993 });
1994
1995
1996 params.content = paramXML;
1997 params.mime = 'xml';
1998 params.successStatuses = [200];
1999 _context.next = 13;
2000 return _regenerator2.default.awrap(this.request(params));
2001
2002 case 13:
2003 result = _context.sent;
2004 return _context.abrupt('return', {
2005 res: result.res
2006 });
2007
2008 case 15:
2009 case 'end':
2010 return _context.stop();
2011 }
2012 }
2013 }, null, this);
2014};
2015
2016// todo delete, 兼容旧版本
2017function defaultDaysAndDate2Expiration(obj) {
2018 if (obj.days) {
2019 obj.expiration = {
2020 days: obj.days
2021 };
2022 }
2023 if (obj.date) {
2024 obj.expiration = {
2025 createdBeforeDate: obj.date
2026 };
2027 }
2028}
2029
2030function checkDaysAndDate(obj, key) {
2031 var days = obj.days,
2032 createdBeforeDate = obj.createdBeforeDate;
2033
2034 if (!days && !createdBeforeDate) {
2035 throw new Error(key + ' must includes days or createdBeforeDate');
2036 } else if (days && !/^[1-9][0-9]*$/.test(days)) {
2037 throw new Error('days must be a positive integer');
2038 } else if (createdBeforeDate && !/\d{4}-\d{2}-\d{2}T00:00:00.000Z/.test(createdBeforeDate)) {
2039 throw new Error('createdBeforeDate must be date and conform to iso8601 format');
2040 }
2041}
2042
2043function handleCheckTag(tag) {
2044 if (!isArray(tag) && !isObject(tag)) {
2045 throw new Error('tag must be Object or Array');
2046 }
2047 tag = isObject(tag) ? [tag] : tag;
2048 var tagObj = {};
2049 var tagClone = deepCopy(tag);
2050 tagClone.forEach(function (v) {
2051 tagObj[v.key] = v.value;
2052 });
2053
2054 checkObjectTag(tagObj);
2055}
2056
2057function checkRule(rule) {
2058 if (rule.id && getStrBytesCount(rule.id) > 255) throw new Error('ID is composed of 255 bytes at most');
2059
2060 if (rule.prefix === '' || rule.prefix === undefined) throw new Error('Rule must includes prefix');
2061
2062 if (!['Enabled', 'Disabled'].includes(rule.status)) throw new Error('Status must be Enabled or Disabled');
2063
2064 if (rule.transition) {
2065 if (!['IA', 'Archive'].includes(rule.transition.storageClass)) throw new Error('StorageClass must be IA or Archive');
2066 checkDaysAndDate(rule.transition, 'Transition');
2067 }
2068
2069 if (rule.expiration) {
2070 if (!rule.expiration.expiredObjectDeleteMarker) {
2071 checkDaysAndDate(rule.expiration, 'Expiration');
2072 } else if (rule.expiration.days || rule.expiration.createdBeforeDate) {
2073 throw new Error('expiredObjectDeleteMarker cannot be used with days or createdBeforeDate');
2074 }
2075 }
2076
2077 if (rule.abortMultipartUpload) {
2078 checkDaysAndDate(rule.abortMultipartUpload, 'AbortMultipartUpload');
2079 }
2080
2081 if (!rule.expiration && !rule.abortMultipartUpload && !rule.transition && !rule.noncurrentVersionTransition) {
2082 throw new Error('Rule must includes expiration or abortMultipartUpload or transition or noncurrentVersionTransition');
2083 }
2084
2085 if (rule.tag) {
2086 if (rule.abortMultipartUpload) {
2087 throw new Error('Tag cannot be used with abortMultipartUpload');
2088 }
2089 handleCheckTag(rule.tag);
2090 }
2091}
2092
2093},{"../utils/checkBucketName":31,"../utils/checkObjectTag":32,"../utils/deepCopy":34,"../utils/getStrBytesCount":36,"../utils/isArray":37,"../utils/isObject":41,"../utils/obj2xml":42,"babel-runtime/regenerator":65}],12:[function(require,module,exports){
2094'use strict';
2095
2096var _regenerator = require('babel-runtime/regenerator');
2097
2098var _regenerator2 = _interopRequireDefault(_regenerator);
2099
2100function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2101
2102var _checkBucketName = require('../utils/checkBucketName');
2103var obj2xml = require('../utils/obj2xml');
2104
2105var proto = exports;
2106/**
2107 * putBucketVersioning
2108 * @param {String} name - bucket name
2109 * @param {String} status
2110 * @param {Object} options
2111 */
2112
2113proto.putBucketVersioning = function putBucketVersioning(name, status) {
2114 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2115 var params, paramXMLObj, result;
2116 return _regenerator2.default.async(function putBucketVersioning$(_context) {
2117 while (1) {
2118 switch (_context.prev = _context.next) {
2119 case 0:
2120 _checkBucketName(name);
2121
2122 if (['Enabled', 'Suspended'].includes(status)) {
2123 _context.next = 3;
2124 break;
2125 }
2126
2127 throw new Error('status must be Enabled or Suspended');
2128
2129 case 3:
2130 params = this._bucketRequestParams('PUT', name, 'versioning', options);
2131 paramXMLObj = {
2132 VersioningConfiguration: {
2133 Status: status
2134 }
2135 };
2136
2137
2138 params.mime = 'xml';
2139 params.content = obj2xml(paramXMLObj, {
2140 headers: true
2141 });
2142
2143 _context.next = 9;
2144 return _regenerator2.default.awrap(this.request(params));
2145
2146 case 9:
2147 result = _context.sent;
2148 return _context.abrupt('return', {
2149 res: result.res,
2150 status: result.status
2151 });
2152
2153 case 11:
2154 case 'end':
2155 return _context.stop();
2156 }
2157 }
2158 }, null, this);
2159};
2160
2161},{"../utils/checkBucketName":31,"../utils/obj2xml":42,"babel-runtime/regenerator":65}],13:[function(require,module,exports){
2162'use strict';
2163
2164var _regenerator = require('babel-runtime/regenerator');
2165
2166var _regenerator2 = _interopRequireDefault(_regenerator);
2167
2168function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2169
2170var _checkBucketName = require('../utils/checkBucketName');
2171var obj2xml = require('../utils/obj2xml');
2172var isArray = require('../utils/isArray');
2173
2174var proto = exports;
2175proto.putBucketWebsite = function putBucketWebsite(name) {
2176 var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2177 var options = arguments[2];
2178 var params, IndexDocument, WebsiteConfiguration, website, result;
2179 return _regenerator2.default.async(function putBucketWebsite$(_context) {
2180 while (1) {
2181 switch (_context.prev = _context.next) {
2182 case 0:
2183 _checkBucketName(name);
2184 params = this._bucketRequestParams('PUT', name, 'website', options);
2185 IndexDocument = {
2186 Suffix: config.index || 'index.html'
2187 };
2188 WebsiteConfiguration = {
2189 IndexDocument: IndexDocument
2190 };
2191 website = {
2192 WebsiteConfiguration: WebsiteConfiguration
2193 };
2194
2195
2196 if (config.supportSubDir) {
2197 IndexDocument.SupportSubDir = config.supportSubDir;
2198 }
2199
2200 if (config.type) {
2201 IndexDocument.Type = config.type;
2202 }
2203
2204 if (config.error) {
2205 WebsiteConfiguration.ErrorDocument = {
2206 Key: config.error
2207 };
2208 }
2209
2210 if (!(config.routingRules !== undefined)) {
2211 _context.next = 12;
2212 break;
2213 }
2214
2215 if (isArray(config.routingRules)) {
2216 _context.next = 11;
2217 break;
2218 }
2219
2220 throw new Error('RoutingRules must be Array');
2221
2222 case 11:
2223 WebsiteConfiguration.RoutingRules = {
2224 RoutingRule: config.routingRules
2225 };
2226
2227 case 12:
2228
2229 website = obj2xml(website);
2230 params.content = website;
2231 params.mime = 'xml';
2232 params.successStatuses = [200];
2233 _context.next = 18;
2234 return _regenerator2.default.awrap(this.request(params));
2235
2236 case 18:
2237 result = _context.sent;
2238 return _context.abrupt('return', {
2239 res: result.res
2240 });
2241
2242 case 20:
2243 case 'end':
2244 return _context.stop();
2245 }
2246 }
2247 }, null, this);
2248};
2249
2250},{"../utils/checkBucketName":31,"../utils/isArray":37,"../utils/obj2xml":42,"babel-runtime/regenerator":65}],14:[function(require,module,exports){
2251(function (Buffer){
2252'use strict';
2253
2254var _keys = require('babel-runtime/core-js/object/keys');
2255
2256var _keys2 = _interopRequireDefault(_keys);
2257
2258var _stringify = require('babel-runtime/core-js/json/stringify');
2259
2260var _stringify2 = _interopRequireDefault(_stringify);
2261
2262function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2263
2264exports.encodeCallback = function encodeCallback(reqParams, options) {
2265 reqParams.headers = reqParams.headers || {};
2266 if (!Object.prototype.hasOwnProperty.call(reqParams.headers, 'x-oss-callback')) {
2267 if (options.callback) {
2268 var json = {
2269 callbackUrl: encodeURI(options.callback.url),
2270 callbackBody: options.callback.body
2271 };
2272 if (options.callback.host) {
2273 json.callbackHost = options.callback.host;
2274 }
2275 if (options.callback.contentType) {
2276 json.callbackBodyType = options.callback.contentType;
2277 }
2278 var callback = Buffer.from((0, _stringify2.default)(json)).toString('base64');
2279 reqParams.headers['x-oss-callback'] = callback;
2280
2281 if (options.callback.customValue) {
2282 var callbackVar = {};
2283 (0, _keys2.default)(options.callback.customValue).forEach(function (key) {
2284 callbackVar['x:' + key] = options.callback.customValue[key];
2285 });
2286 reqParams.headers['x-oss-callback-var'] = Buffer.from((0, _stringify2.default)(callbackVar)).toString('base64');
2287 }
2288 }
2289 }
2290};
2291
2292}).call(this,require("buffer").Buffer)
2293},{"babel-runtime/core-js/json/stringify":48,"babel-runtime/core-js/object/keys":55,"buffer":70}],15:[function(require,module,exports){
2294'use strict';
2295
2296var _assign = require('babel-runtime/core-js/object/assign');
2297
2298var _assign2 = _interopRequireDefault(_assign);
2299
2300function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2301
2302var ms = require('humanize-ms');
2303var urlutil = require('url');
2304var _checkBucketName = require('../utils/checkBucketName');
2305
2306function setEndpoint(endpoint, secure) {
2307 var url = urlutil.parse(endpoint);
2308
2309 if (!url.protocol) {
2310 url = urlutil.parse('http' + (secure ? 's' : '') + '://' + endpoint);
2311 }
2312
2313 if (url.protocol !== 'http:' && url.protocol !== 'https:') {
2314 throw new Error('Endpoint protocol must be http or https.');
2315 }
2316
2317 return url;
2318}
2319
2320function setRegion(region, internal, secure) {
2321 var protocol = secure ? 'https://' : 'http://';
2322 var suffix = internal ? '-internal.aliyuncs.com' : '.aliyuncs.com';
2323 var prefix = 'vpc100-oss-cn-';
2324 // aliyun VPC region: https://help.aliyun.com/knowledge_detail/38740.html
2325 if (region.substr(0, prefix.length) === prefix) {
2326 suffix = '.aliyuncs.com';
2327 }
2328
2329 return urlutil.parse(protocol + region + suffix);
2330}
2331
2332module.exports = function (options) {
2333 if (!options || !options.accessKeyId || !options.accessKeySecret) {
2334 throw new Error('require accessKeyId, accessKeySecret');
2335 }
2336 if (options.bucket) {
2337 _checkBucketName(options.bucket);
2338 }
2339 var opts = (0, _assign2.default)({
2340 region: 'oss-cn-hangzhou',
2341 internal: false,
2342 secure: false,
2343 timeout: 60000,
2344 bucket: null,
2345 endpoint: null,
2346 cname: false,
2347 isRequestPay: false,
2348 sldEnable: false
2349 }, options);
2350
2351 opts.accessKeyId = opts.accessKeyId.trim();
2352 opts.accessKeySecret = opts.accessKeySecret.trim();
2353
2354 if (opts.timeout) {
2355 opts.timeout = ms(opts.timeout);
2356 }
2357
2358 if (opts.endpoint) {
2359 opts.endpoint = setEndpoint(opts.endpoint, opts.secure);
2360 } else if (opts.region) {
2361 opts.endpoint = setRegion(opts.region, opts.internal, opts.secure);
2362 } else {
2363 throw new Error('require options.endpoint or options.region');
2364 }
2365
2366 opts.inited = true;
2367 return opts;
2368};
2369
2370},{"../utils/checkBucketName":31,"babel-runtime/core-js/object/assign":49,"humanize-ms":224,"url":279}],16:[function(require,module,exports){
2371'use strict';
2372
2373var merge = require('merge-descriptors');
2374
2375var proto = exports;
2376
2377merge(proto, require('./processObjectSave'));
2378
2379},{"./processObjectSave":17,"merge-descriptors":237}],17:[function(require,module,exports){
2380'use strict';
2381
2382var _regenerator = require('babel-runtime/regenerator');
2383
2384var _regenerator2 = _interopRequireDefault(_regenerator);
2385
2386function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2387
2388/* eslint-disable no-use-before-define */
2389var _checkBucketName = require('../utils/checkBucketName');
2390var querystring = require('querystring');
2391
2392var _require = require('js-base64'),
2393 str2Base64 = _require.Base64.encode;
2394
2395var proto = exports;
2396
2397proto.processObjectSave = function processObjectSave(sourceObject, targetObject, process, targetBucket) {
2398 var params, bucketParam, content, result;
2399 return _regenerator2.default.async(function processObjectSave$(_context) {
2400 while (1) {
2401 switch (_context.prev = _context.next) {
2402 case 0:
2403 checkArgs(sourceObject, 'sourceObject');
2404 checkArgs(targetObject, 'targetObject');
2405 checkArgs(process, 'process');
2406 targetObject = this._objectName(targetObject);
2407 if (targetBucket) {
2408 _checkBucketName(targetBucket);
2409 }
2410
2411 params = this._objectRequestParams('POST', sourceObject, {
2412 subres: 'x-oss-process'
2413 });
2414 bucketParam = targetBucket ? ',b_' + str2Base64(targetBucket) : '';
2415
2416 targetObject = str2Base64(targetObject);
2417
2418 content = {
2419 'x-oss-process': process + '|sys/saveas,o_' + targetObject + bucketParam
2420 };
2421
2422 params.content = querystring.stringify(content);
2423
2424 _context.next = 12;
2425 return _regenerator2.default.awrap(this.request(params));
2426
2427 case 12:
2428 result = _context.sent;
2429 return _context.abrupt('return', {
2430 res: result.res,
2431 status: result.res.status
2432 });
2433
2434 case 14:
2435 case 'end':
2436 return _context.stop();
2437 }
2438 }
2439 }, null, this);
2440};
2441
2442function checkArgs(name, key) {
2443 if (!name) {
2444 throw new Error(key + ' is required');
2445 }
2446 if (typeof name !== 'string') {
2447 throw new Error(key + ' must be String');
2448 }
2449}
2450
2451},{"../utils/checkBucketName":31,"babel-runtime/regenerator":65,"js-base64":236,"querystring":253}],18:[function(require,module,exports){
2452'use strict';
2453
2454var _regenerator = require('babel-runtime/regenerator');
2455
2456var _regenerator2 = _interopRequireDefault(_regenerator);
2457
2458function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2459
2460var copy = require('copy-to');
2461var callback = require('./callback');
2462var deepCopy = require('./utils/deepCopy');
2463
2464var proto = exports;
2465
2466/**
2467 * List the on-going multipart uploads
2468 * https://help.aliyun.com/document_detail/31997.html
2469 * @param {Object} options
2470 * @return {Array} the multipart uploads
2471 */
2472proto.listUploads = function listUploads(query, options) {
2473 var opt, params, result, uploads;
2474 return _regenerator2.default.async(function listUploads$(_context) {
2475 while (1) {
2476 switch (_context.prev = _context.next) {
2477 case 0:
2478 options = options || {};
2479 opt = {};
2480
2481 copy(options).to(opt);
2482 opt.subres = 'uploads';
2483 params = this._objectRequestParams('GET', '', opt);
2484
2485 params.query = query;
2486 params.xmlResponse = true;
2487 params.successStatuses = [200];
2488
2489 _context.next = 10;
2490 return _regenerator2.default.awrap(this.request(params));
2491
2492 case 10:
2493 result = _context.sent;
2494 uploads = result.data.Upload || [];
2495
2496 if (!Array.isArray(uploads)) {
2497 uploads = [uploads];
2498 }
2499 uploads = uploads.map(function (up) {
2500 return {
2501 name: up.Key,
2502 uploadId: up.UploadId,
2503 initiated: up.Initiated
2504 };
2505 });
2506
2507 return _context.abrupt('return', {
2508 res: result.res,
2509 uploads: uploads,
2510 bucket: result.data.Bucket,
2511 nextKeyMarker: result.data.NextKeyMarker,
2512 nextUploadIdMarker: result.data.NextUploadIdMarker,
2513 isTruncated: result.data.IsTruncated === 'true'
2514 });
2515
2516 case 15:
2517 case 'end':
2518 return _context.stop();
2519 }
2520 }
2521 }, null, this);
2522};
2523
2524/**
2525 * List the done uploadPart parts
2526 * @param {String} name object name
2527 * @param {String} uploadId multipart upload id
2528 * @param {Object} query
2529 * {Number} query.max-parts The maximum part number in the response of the OSS. Default value: 1000
2530 * {Number} query.part-number-marker Starting position of a specific list.
2531 * {String} query.encoding-type Specify the encoding of the returned content and the encoding type.
2532 * @param {Object} options
2533 * @return {Object} result
2534 */
2535proto.listParts = function listParts(name, uploadId, query, options) {
2536 var opt, params, result;
2537 return _regenerator2.default.async(function listParts$(_context2) {
2538 while (1) {
2539 switch (_context2.prev = _context2.next) {
2540 case 0:
2541 options = options || {};
2542 opt = {};
2543
2544 copy(options).to(opt);
2545 opt.subres = {
2546 uploadId: uploadId
2547 };
2548 params = this._objectRequestParams('GET', name, opt);
2549
2550 params.query = query;
2551 params.xmlResponse = true;
2552 params.successStatuses = [200];
2553
2554 _context2.next = 10;
2555 return _regenerator2.default.awrap(this.request(params));
2556
2557 case 10:
2558 result = _context2.sent;
2559 return _context2.abrupt('return', {
2560 res: result.res,
2561 uploadId: result.data.UploadId,
2562 bucket: result.data.Bucket,
2563 name: result.data.Key,
2564 partNumberMarker: result.data.PartNumberMarker,
2565 nextPartNumberMarker: result.data.NextPartNumberMarker,
2566 maxParts: result.data.MaxParts,
2567 isTruncated: result.data.IsTruncated,
2568 parts: result.data.Part || []
2569 });
2570
2571 case 12:
2572 case 'end':
2573 return _context2.stop();
2574 }
2575 }
2576 }, null, this);
2577};
2578
2579/**
2580 * Abort a multipart upload transaction
2581 * @param {String} name the object name
2582 * @param {String} uploadId the upload id
2583 * @param {Object} options
2584 */
2585proto.abortMultipartUpload = function abortMultipartUpload(name, uploadId, options) {
2586 var opt, params, result;
2587 return _regenerator2.default.async(function abortMultipartUpload$(_context3) {
2588 while (1) {
2589 switch (_context3.prev = _context3.next) {
2590 case 0:
2591 this._stop();
2592 options = options || {};
2593 opt = {};
2594
2595 copy(options).to(opt);
2596 opt.subres = { uploadId: uploadId };
2597 params = this._objectRequestParams('DELETE', name, opt);
2598
2599 params.successStatuses = [204];
2600
2601 _context3.next = 9;
2602 return _regenerator2.default.awrap(this.request(params));
2603
2604 case 9:
2605 result = _context3.sent;
2606 return _context3.abrupt('return', {
2607 res: result.res
2608 });
2609
2610 case 11:
2611 case 'end':
2612 return _context3.stop();
2613 }
2614 }
2615 }, null, this);
2616};
2617
2618/**
2619 * Initiate a multipart upload transaction
2620 * @param {String} name the object name
2621 * @param {Object} options
2622 * @return {String} upload id
2623 */
2624proto.initMultipartUpload = function initMultipartUpload(name, options) {
2625 var opt, params, result;
2626 return _regenerator2.default.async(function initMultipartUpload$(_context4) {
2627 while (1) {
2628 switch (_context4.prev = _context4.next) {
2629 case 0:
2630 options = options || {};
2631 opt = {};
2632
2633 copy(options).to(opt);
2634 opt.headers = opt.headers || {};
2635 this._convertMetaToHeaders(options.meta, opt.headers);
2636
2637 opt.subres = 'uploads';
2638 params = this._objectRequestParams('POST', name, opt);
2639
2640 params.mime = options.mime;
2641 params.xmlResponse = true;
2642 params.successStatuses = [200];
2643
2644 _context4.next = 12;
2645 return _regenerator2.default.awrap(this.request(params));
2646
2647 case 12:
2648 result = _context4.sent;
2649 return _context4.abrupt('return', {
2650 res: result.res,
2651 bucket: result.data.Bucket,
2652 name: result.data.Key,
2653 uploadId: result.data.UploadId
2654 });
2655
2656 case 14:
2657 case 'end':
2658 return _context4.stop();
2659 }
2660 }
2661 }, null, this);
2662};
2663
2664/**
2665 * Upload a part in a multipart upload transaction
2666 * @param {String} name the object name
2667 * @param {String} uploadId the upload id
2668 * @param {Integer} partNo the part number
2669 * @param {File} file upload File, whole File
2670 * @param {Integer} start part start bytes e.g: 102400
2671 * @param {Integer} end part end bytes e.g: 204800
2672 * @param {Object} options
2673 */
2674proto.uploadPart = function uploadPart(name, uploadId, partNo, file, start, end, options) {
2675 var data;
2676 return _regenerator2.default.async(function uploadPart$(_context5) {
2677 while (1) {
2678 switch (_context5.prev = _context5.next) {
2679 case 0:
2680 data = {
2681 stream: this._createStream(file, start, end),
2682 size: end - start
2683 };
2684 _context5.next = 3;
2685 return _regenerator2.default.awrap(this._uploadPart(name, uploadId, partNo, data, options));
2686
2687 case 3:
2688 return _context5.abrupt('return', _context5.sent);
2689
2690 case 4:
2691 case 'end':
2692 return _context5.stop();
2693 }
2694 }
2695 }, null, this);
2696};
2697
2698/**
2699 * Complete a multipart upload transaction
2700 * @param {String} name the object name
2701 * @param {String} uploadId the upload id
2702 * @param {Array} parts the uploaded parts, each in the structure:
2703 * {Integer} number partNo
2704 * {String} etag part etag uploadPartCopy result.res.header.etag
2705 * @param {Object} options
2706 * {Object} options.callback The callback parameter is composed of a JSON string encoded in Base64
2707 * {String} options.callback.url the OSS sends a callback request to this URL
2708 * {String} options.callback.host The host header value for initiating callback requests
2709 * {String} options.callback.body The value of the request body when a callback is initiated
2710 * {String} options.callback.contentType The Content-Type of the callback requests initiatiated
2711 * {Object} options.callback.customValue Custom parameters are a map of key-values, e.g:
2712 * customValue = {
2713 * key1: 'value1',
2714 * key2: 'value2'
2715 * }
2716 */
2717proto.completeMultipartUpload = function completeMultipartUpload(name, uploadId, parts, options) {
2718 var completeParts, xml, i, p, opt, params, result, ret;
2719 return _regenerator2.default.async(function completeMultipartUpload$(_context6) {
2720 while (1) {
2721 switch (_context6.prev = _context6.next) {
2722 case 0:
2723 completeParts = parts.concat().sort(function (a, b) {
2724 return a.number - b.number;
2725 }).filter(function (item, index, arr) {
2726 return !index || item.number !== arr[index - 1].number;
2727 });
2728 xml = '<?xml version="1.0" encoding="UTF-8"?>\n<CompleteMultipartUpload>\n';
2729
2730 for (i = 0; i < completeParts.length; i++) {
2731 p = completeParts[i];
2732
2733 xml += '<Part>\n';
2734 xml += '<PartNumber>' + p.number + '</PartNumber>\n';
2735 xml += '<ETag>' + p.etag + '</ETag>\n';
2736 xml += '</Part>\n';
2737 }
2738 xml += '</CompleteMultipartUpload>';
2739
2740 options = options || {};
2741 opt = {};
2742
2743 opt = deepCopy(options);
2744 if (opt.headers) delete opt.headers['x-oss-server-side-encryption'];
2745 opt.subres = { uploadId: uploadId };
2746
2747 params = this._objectRequestParams('POST', name, opt);
2748
2749 callback.encodeCallback(params, opt);
2750 params.mime = 'xml';
2751 params.content = xml;
2752
2753 if (!(params.headers && params.headers['x-oss-callback'])) {
2754 params.xmlResponse = true;
2755 }
2756 params.successStatuses = [200];
2757 _context6.next = 17;
2758 return _regenerator2.default.awrap(this.request(params));
2759
2760 case 17:
2761 result = _context6.sent;
2762 ret = {
2763 res: result.res,
2764 bucket: params.bucket,
2765 name: name,
2766 etag: result.res.headers.etag
2767 };
2768
2769
2770 if (params.headers && params.headers['x-oss-callback']) {
2771 ret.data = JSON.parse(result.data.toString());
2772 }
2773
2774 return _context6.abrupt('return', ret);
2775
2776 case 21:
2777 case 'end':
2778 return _context6.stop();
2779 }
2780 }
2781 }, null, this);
2782};
2783
2784/**
2785 * Upload a part in a multipart upload transaction
2786 * @param {String} name the object name
2787 * @param {String} uploadId the upload id
2788 * @param {Integer} partNo the part number
2789 * @param {Object} data the body data
2790 * @param {Object} options
2791 */
2792proto._uploadPart = function _uploadPart(name, uploadId, partNo, data, options) {
2793 var opt, params, result;
2794 return _regenerator2.default.async(function _uploadPart$(_context7) {
2795 while (1) {
2796 switch (_context7.prev = _context7.next) {
2797 case 0:
2798 options = options || {};
2799 opt = {};
2800
2801 copy(options).to(opt);
2802 opt.headers = {
2803 'Content-Length': data.size
2804 };
2805
2806 opt.subres = {
2807 partNumber: partNo,
2808 uploadId: uploadId
2809 };
2810 params = this._objectRequestParams('PUT', name, opt);
2811
2812 params.mime = opt.mime;
2813 params.stream = data.stream;
2814 params.successStatuses = [200];
2815
2816 _context7.next = 11;
2817 return _regenerator2.default.awrap(this.request(params));
2818
2819 case 11:
2820 result = _context7.sent;
2821
2822 if (result.res.headers.etag) {
2823 _context7.next = 14;
2824 break;
2825 }
2826
2827 throw new Error('Please set the etag of expose-headers in OSS \n https://help.aliyun.com/document_detail/32069.html');
2828
2829 case 14:
2830
2831 data.stream = null;
2832 params.stream = null;
2833 return _context7.abrupt('return', {
2834 name: name,
2835 etag: result.res.headers.etag,
2836 res: result.res
2837 });
2838
2839 case 17:
2840 case 'end':
2841 return _context7.stop();
2842 }
2843 }
2844 }, null, this);
2845};
2846
2847},{"./callback":14,"./utils/deepCopy":34,"babel-runtime/regenerator":65,"copy-to":73}],19:[function(require,module,exports){
2848'use strict';
2849
2850var _regenerator = require('babel-runtime/regenerator');
2851
2852var _regenerator2 = _interopRequireDefault(_regenerator);
2853
2854var _keys = require('babel-runtime/core-js/object/keys');
2855
2856var _keys2 = _interopRequireDefault(_keys);
2857
2858var _typeof2 = require('babel-runtime/helpers/typeof');
2859
2860var _typeof3 = _interopRequireDefault(_typeof2);
2861
2862function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2863
2864var _checkBucketName = require('../utils/checkBucketName');
2865
2866var proto = exports;
2867
2868proto.copy = function copy(name, sourceName, bucketName, options) {
2869 var params, result, data;
2870 return _regenerator2.default.async(function copy$(_context) {
2871 while (1) {
2872 switch (_context.prev = _context.next) {
2873 case 0:
2874 if ((typeof bucketName === 'undefined' ? 'undefined' : (0, _typeof3.default)(bucketName)) === 'object') {
2875 options = bucketName; // 兼容旧版本,旧版本第三个参数为options
2876 }
2877 options = options || {};
2878 options.headers = options.headers || {};
2879
2880 (0, _keys2.default)(options.headers).forEach(function (key) {
2881 options.headers['x-oss-copy-source-' + key.toLowerCase()] = options.headers[key];
2882 });
2883 if (options.meta) {
2884 options.headers['x-oss-metadata-directive'] = 'REPLACE';
2885 }
2886 this._convertMetaToHeaders(options.meta, options.headers);
2887
2888 sourceName = this._getSourceName(sourceName, bucketName);
2889
2890 if (options.versionId) {
2891 sourceName = sourceName + '?versionId=' + options.versionId;
2892 }
2893
2894 options.headers['x-oss-copy-source'] = sourceName;
2895
2896 params = this._objectRequestParams('PUT', name, options);
2897
2898 params.xmlResponse = true;
2899 params.successStatuses = [200, 304];
2900
2901 _context.next = 14;
2902 return _regenerator2.default.awrap(this.request(params));
2903
2904 case 14:
2905 result = _context.sent;
2906 data = result.data;
2907
2908 if (data) {
2909 data = {
2910 etag: data.ETag,
2911 lastModified: data.LastModified
2912 };
2913 }
2914
2915 return _context.abrupt('return', {
2916 data: data,
2917 res: result.res
2918 });
2919
2920 case 18:
2921 case 'end':
2922 return _context.stop();
2923 }
2924 }
2925 }, null, this);
2926};
2927
2928// todo delete
2929proto._getSourceName = function _getSourceName(sourceName, bucketName) {
2930 if (typeof bucketName === 'string') {
2931 sourceName = this._objectName(sourceName);
2932 } else if (sourceName[0] !== '/') {
2933 bucketName = this.options.bucket;
2934 } else {
2935 bucketName = sourceName.replace(/\/(.+?)(\/.*)/, '$1');
2936 sourceName = sourceName.replace(/(\/.+?\/)(.*)/, '$2');
2937 }
2938
2939 _checkBucketName(bucketName);
2940
2941 sourceName = encodeURI(sourceName);
2942
2943 sourceName = '/' + bucketName + '/' + sourceName;
2944 return sourceName;
2945};
2946
2947},{"../utils/checkBucketName":31,"babel-runtime/core-js/object/keys":55,"babel-runtime/helpers/typeof":64,"babel-runtime/regenerator":65}],20:[function(require,module,exports){
2948'use strict';
2949
2950var _regenerator = require('babel-runtime/regenerator');
2951
2952var _regenerator2 = _interopRequireDefault(_regenerator);
2953
2954var _assign = require('babel-runtime/core-js/object/assign');
2955
2956var _assign2 = _interopRequireDefault(_assign);
2957
2958function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2959
2960var proto = exports;
2961/**
2962 * delete
2963 * @param {String} name - object name
2964 * @param {Object} options
2965 * @param {{res}}
2966 */
2967
2968proto.delete = function _delete(name) {
2969 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2970 var params, result;
2971 return _regenerator2.default.async(function _delete$(_context) {
2972 while (1) {
2973 switch (_context.prev = _context.next) {
2974 case 0:
2975 options.subres = (0, _assign2.default)({}, options.subres);
2976 if (options.versionId) {
2977 options.subres.versionId = options.versionId;
2978 }
2979 params = this._objectRequestParams('DELETE', name, options);
2980
2981 params.successStatuses = [204];
2982
2983 _context.next = 6;
2984 return _regenerator2.default.awrap(this.request(params));
2985
2986 case 6:
2987 result = _context.sent;
2988 return _context.abrupt('return', {
2989 res: result.res
2990 });
2991
2992 case 8:
2993 case 'end':
2994 return _context.stop();
2995 }
2996 }
2997 }, null, this);
2998};
2999
3000},{"babel-runtime/core-js/object/assign":49,"babel-runtime/regenerator":65}],21:[function(require,module,exports){
3001'use strict';
3002
3003var _regenerator = require('babel-runtime/regenerator');
3004
3005var _regenerator2 = _interopRequireDefault(_regenerator);
3006
3007var _assign = require('babel-runtime/core-js/object/assign');
3008
3009var _assign2 = _interopRequireDefault(_assign);
3010
3011function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3012
3013var proto = exports;
3014/**
3015 * deleteObjectTagging
3016 * @param {String} name - object name
3017 * @param {Object} options
3018 */
3019
3020proto.deleteObjectTagging = function deleteObjectTagging(name) {
3021 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3022 var params, result;
3023 return _regenerator2.default.async(function deleteObjectTagging$(_context) {
3024 while (1) {
3025 switch (_context.prev = _context.next) {
3026 case 0:
3027 options.subres = (0, _assign2.default)({ tagging: '' }, options.subres);
3028 if (options.versionId) {
3029 options.subres.versionId = options.versionId;
3030 }
3031 name = this._objectName(name);
3032 params = this._objectRequestParams('DELETE', name, options);
3033
3034 params.successStatuses = [204];
3035 _context.next = 7;
3036 return _regenerator2.default.awrap(this.request(params));
3037
3038 case 7:
3039 result = _context.sent;
3040 return _context.abrupt('return', {
3041 status: result.status,
3042 res: result.res
3043 });
3044
3045 case 9:
3046 case 'end':
3047 return _context.stop();
3048 }
3049 }
3050 }, null, this);
3051};
3052
3053},{"babel-runtime/core-js/object/assign":49,"babel-runtime/regenerator":65}],22:[function(require,module,exports){
3054'use strict';
3055
3056var _regenerator = require('babel-runtime/regenerator');
3057
3058var _regenerator2 = _interopRequireDefault(_regenerator);
3059
3060var _assign = require('babel-runtime/core-js/object/assign');
3061
3062var _assign2 = _interopRequireDefault(_assign);
3063
3064function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3065
3066var fs = require('fs');
3067var is = require('is-type-of');
3068
3069var proto = exports;
3070/**
3071 * get
3072 * @param {String} name - object name
3073 * @param {String | Stream} file
3074 * @param {Object} options
3075 * @param {{res}}
3076 */
3077proto.get = function get(name, file) {
3078 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3079 var writeStream, needDestroy, result, params;
3080 return _regenerator2.default.async(function get$(_context) {
3081 while (1) {
3082 switch (_context.prev = _context.next) {
3083 case 0:
3084 writeStream = null;
3085 needDestroy = false;
3086
3087
3088 if (is.writableStream(file)) {
3089 writeStream = file;
3090 } else if (is.string(file)) {
3091 writeStream = fs.createWriteStream(file);
3092 needDestroy = true;
3093 } else {
3094 // get(name, options)
3095 options = file;
3096 }
3097
3098 options = options || {};
3099
3100 options.subres = (0, _assign2.default)({}, options.subres);
3101 if (options.versionId) {
3102 options.subres.versionId = options.versionId;
3103 }
3104 if (options.process) {
3105 options.subres['x-oss-process'] = options.process;
3106 }
3107
3108 result = void 0;
3109 _context.prev = 8;
3110 params = this._objectRequestParams('GET', name, options);
3111
3112 params.writeStream = writeStream;
3113 params.successStatuses = [200, 206, 304];
3114
3115 _context.next = 14;
3116 return _regenerator2.default.awrap(this.request(params));
3117
3118 case 14:
3119 result = _context.sent;
3120
3121
3122 if (needDestroy) {
3123 writeStream.destroy();
3124 }
3125 _context.next = 25;
3126 break;
3127
3128 case 18:
3129 _context.prev = 18;
3130 _context.t0 = _context['catch'](8);
3131
3132 if (!needDestroy) {
3133 _context.next = 24;
3134 break;
3135 }
3136
3137 writeStream.destroy();
3138 // should delete the exists file before throw error
3139 _context.next = 24;
3140 return _regenerator2.default.awrap(this._deleteFileSafe(file));
3141
3142 case 24:
3143 throw _context.t0;
3144
3145 case 25:
3146 return _context.abrupt('return', {
3147 res: result.res,
3148 content: result.data
3149 });
3150
3151 case 26:
3152 case 'end':
3153 return _context.stop();
3154 }
3155 }
3156 }, null, this, [[8, 18]]);
3157};
3158
3159},{"babel-runtime/core-js/object/assign":49,"babel-runtime/regenerator":65,"fs":68,"is-type-of":233}],23:[function(require,module,exports){
3160'use strict';
3161
3162var _regenerator = require('babel-runtime/regenerator');
3163
3164var _regenerator2 = _interopRequireDefault(_regenerator);
3165
3166var _assign = require('babel-runtime/core-js/object/assign');
3167
3168var _assign2 = _interopRequireDefault(_assign);
3169
3170function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3171
3172var proto = exports;
3173
3174/*
3175 * Get object's ACL
3176 * @param {String} name the object key
3177 * @param {Object} options
3178 * @return {Object}
3179 */
3180proto.getACL = function getACL(name) {
3181 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3182 var params, result;
3183 return _regenerator2.default.async(function getACL$(_context) {
3184 while (1) {
3185 switch (_context.prev = _context.next) {
3186 case 0:
3187 options.subres = (0, _assign2.default)({ acl: '' }, options.subres);
3188 if (options.versionId) {
3189 options.subres.versionId = options.versionId;
3190 }
3191 name = this._objectName(name);
3192
3193 params = this._objectRequestParams('GET', name, options);
3194
3195 params.successStatuses = [200];
3196 params.xmlResponse = true;
3197
3198 _context.next = 8;
3199 return _regenerator2.default.awrap(this.request(params));
3200
3201 case 8:
3202 result = _context.sent;
3203 return _context.abrupt('return', {
3204 acl: result.data.AccessControlList.Grant,
3205 owner: {
3206 id: result.data.Owner.ID,
3207 displayName: result.data.Owner.DisplayName
3208 },
3209 res: result.res
3210 });
3211
3212 case 10:
3213 case 'end':
3214 return _context.stop();
3215 }
3216 }
3217 }, null, this);
3218};
3219
3220},{"babel-runtime/core-js/object/assign":49,"babel-runtime/regenerator":65}],24:[function(require,module,exports){
3221'use strict';
3222
3223var _keys = require('babel-runtime/core-js/object/keys');
3224
3225var _keys2 = _interopRequireDefault(_keys);
3226
3227var _regenerator = require('babel-runtime/regenerator');
3228
3229var _regenerator2 = _interopRequireDefault(_regenerator);
3230
3231var _assign = require('babel-runtime/core-js/object/assign');
3232
3233var _assign2 = _interopRequireDefault(_assign);
3234
3235function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3236
3237/* eslint-disable no-use-before-define */
3238var proto = exports;
3239var isObject = require('../utils/isObject');
3240
3241proto.getBucketVersions = getBucketVersions;
3242proto.listObjectVersions = getBucketVersions;
3243
3244function getBucketVersions() {
3245 var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3246 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3247 var params, result, objects, deleteMarker, that;
3248 return _regenerator2.default.async(function getBucketVersions$(_context) {
3249 while (1) {
3250 switch (_context.prev = _context.next) {
3251 case 0:
3252 if (!(query.versionIdMarker && query.keyMarker === undefined)) {
3253 _context.next = 2;
3254 break;
3255 }
3256
3257 throw new Error('A version-id marker cannot be specified without a key marker');
3258
3259 case 2:
3260
3261 options.subres = (0, _assign2.default)({ versions: '' }, options.subres);
3262 if (options.versionId) {
3263 options.subres.versionId = options.versionId;
3264 }
3265 params = this._objectRequestParams('GET', '', options);
3266
3267 params.xmlResponse = true;
3268 params.successStatuses = [200];
3269
3270 params.query = formatQuery(query);
3271
3272 _context.next = 10;
3273 return _regenerator2.default.awrap(this.request(params));
3274
3275 case 10:
3276 result = _context.sent;
3277 objects = result.data.Version || [];
3278 deleteMarker = result.data.DeleteMarker || [];
3279 that = this;
3280
3281 if (objects) {
3282 if (!Array.isArray(objects)) {
3283 objects = [objects];
3284 }
3285 objects = objects.map(function (obj) {
3286 return {
3287 name: obj.Key,
3288 url: that._objectUrl(obj.Key),
3289 lastModified: obj.LastModified,
3290 isLatest: obj.IsLatest === 'true',
3291 versionId: obj.VersionId,
3292 etag: obj.ETag,
3293 type: obj.Type,
3294 size: Number(obj.Size),
3295 storageClass: obj.StorageClass,
3296 owner: {
3297 id: obj.Owner.ID,
3298 displayName: obj.Owner.DisplayName
3299 }
3300 };
3301 });
3302 }
3303 if (deleteMarker) {
3304 if (!Array.isArray(deleteMarker)) {
3305 deleteMarker = [deleteMarker];
3306 }
3307 deleteMarker = deleteMarker.map(function (obj) {
3308 return {
3309 name: obj.Key,
3310 lastModified: obj.LastModified,
3311 versionId: obj.VersionId,
3312 owner: {
3313 id: obj.Owner.ID,
3314 displayName: obj.Owner.DisplayName
3315 }
3316 };
3317 });
3318 }
3319 return _context.abrupt('return', {
3320 res: result.res,
3321 objects: objects,
3322 deleteMarker: deleteMarker,
3323 nextMarker: result.data.NextMarker || null,
3324 NextVersionIdMarker: result.data.NextVersionIdMarker || null,
3325 isTruncated: result.data.IsTruncated === 'true'
3326 });
3327
3328 case 17:
3329 case 'end':
3330 return _context.stop();
3331 }
3332 }
3333 }, null, this);
3334}
3335
3336function camel2Line(name) {
3337 return name.replace(/([A-Z])/g, '-$1').toLowerCase();
3338}
3339
3340function formatQuery() {
3341 var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3342
3343 var obj = {};
3344 if (isObject(query)) {
3345 (0, _keys2.default)(query).forEach(function (key) {
3346 obj[camel2Line(key)] = query[key];
3347 });
3348 }
3349
3350 return obj;
3351}
3352
3353},{"../utils/isObject":41,"babel-runtime/core-js/object/assign":49,"babel-runtime/core-js/object/keys":55,"babel-runtime/regenerator":65}],25:[function(require,module,exports){
3354'use strict';
3355
3356var _regenerator = require('babel-runtime/regenerator');
3357
3358var _regenerator2 = _interopRequireDefault(_regenerator);
3359
3360var _assign = require('babel-runtime/core-js/object/assign');
3361
3362var _assign2 = _interopRequireDefault(_assign);
3363
3364function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3365
3366var proto = exports;
3367var isObject = require('../utils/isObject');
3368/**
3369 * getObjectTagging
3370 * @param {String} name - object name
3371 * @param {Object} options
3372 * @return {Object}
3373 */
3374
3375proto.getObjectTagging = function getObjectTagging(name) {
3376 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3377 var params, result, Tagging, Tag, tag;
3378 return _regenerator2.default.async(function getObjectTagging$(_context) {
3379 while (1) {
3380 switch (_context.prev = _context.next) {
3381 case 0:
3382 options.subres = (0, _assign2.default)({ tagging: '' }, options.subres);
3383 if (options.versionId) {
3384 options.subres.versionId = options.versionId;
3385 }
3386 name = this._objectName(name);
3387 params = this._objectRequestParams('GET', name, options);
3388
3389 params.successStatuses = [200];
3390 _context.next = 7;
3391 return _regenerator2.default.awrap(this.request(params));
3392
3393 case 7:
3394 result = _context.sent;
3395 _context.next = 10;
3396 return _regenerator2.default.awrap(this.parseXML(result.data));
3397
3398 case 10:
3399 Tagging = _context.sent;
3400 Tag = Tagging.TagSet.Tag;
3401
3402 Tag = Tag && isObject(Tag) ? [Tag] : Tag || [];
3403
3404 tag = {};
3405
3406
3407 Tag.forEach(function (item) {
3408 tag[item.Key] = item.Value;
3409 });
3410
3411 return _context.abrupt('return', {
3412 status: result.status,
3413 res: result.res,
3414 tag: tag
3415 });
3416
3417 case 16:
3418 case 'end':
3419 return _context.stop();
3420 }
3421 }
3422 }, null, this);
3423};
3424
3425},{"../utils/isObject":41,"babel-runtime/core-js/object/assign":49,"babel-runtime/regenerator":65}],26:[function(require,module,exports){
3426'use strict';
3427
3428var _regenerator = require('babel-runtime/regenerator');
3429
3430var _regenerator2 = _interopRequireDefault(_regenerator);
3431
3432var _keys = require('babel-runtime/core-js/object/keys');
3433
3434var _keys2 = _interopRequireDefault(_keys);
3435
3436var _assign = require('babel-runtime/core-js/object/assign');
3437
3438var _assign2 = _interopRequireDefault(_assign);
3439
3440function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3441
3442var proto = exports;
3443/**
3444 * head
3445 * @param {String} name - object name
3446 * @param {Object} options
3447 * @param {{res}}
3448 */
3449
3450proto.head = function head(name) {
3451 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3452 var params, result, data;
3453 return _regenerator2.default.async(function head$(_context) {
3454 while (1) {
3455 switch (_context.prev = _context.next) {
3456 case 0:
3457 options.subres = (0, _assign2.default)({}, options.subres);
3458 if (options.versionId) {
3459 options.subres.versionId = options.versionId;
3460 }
3461 params = this._objectRequestParams('HEAD', name, options);
3462
3463 params.successStatuses = [200, 304];
3464
3465 _context.next = 6;
3466 return _regenerator2.default.awrap(this.request(params));
3467
3468 case 6:
3469 result = _context.sent;
3470 data = {
3471 meta: null,
3472 res: result.res,
3473 status: result.status
3474 };
3475
3476
3477 if (result.status === 200) {
3478 (0, _keys2.default)(result.headers).forEach(function (k) {
3479 if (k.indexOf('x-oss-meta-') === 0) {
3480 if (!data.meta) {
3481 data.meta = {};
3482 }
3483 data.meta[k.substring(11)] = result.headers[k];
3484 }
3485 });
3486 }
3487 return _context.abrupt('return', data);
3488
3489 case 10:
3490 case 'end':
3491 return _context.stop();
3492 }
3493 }
3494 }, null, this);
3495};
3496
3497},{"babel-runtime/core-js/object/assign":49,"babel-runtime/core-js/object/keys":55,"babel-runtime/regenerator":65}],27:[function(require,module,exports){
3498'use strict';
3499
3500var _regenerator = require('babel-runtime/regenerator');
3501
3502var _regenerator2 = _interopRequireDefault(_regenerator);
3503
3504var _assign = require('babel-runtime/core-js/object/assign');
3505
3506var _assign2 = _interopRequireDefault(_assign);
3507
3508function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3509
3510var proto = exports;
3511
3512/*
3513 * Set object's ACL
3514 * @param {String} name the object key
3515 * @param {String} acl the object ACL
3516 * @param {Object} options
3517 */
3518proto.putACL = function putACL(name, acl, options) {
3519 var params, result;
3520 return _regenerator2.default.async(function putACL$(_context) {
3521 while (1) {
3522 switch (_context.prev = _context.next) {
3523 case 0:
3524 options = options || {};
3525 options.subres = (0, _assign2.default)({ acl: '' }, options.subres);
3526 if (options.versionId) {
3527 options.subres.versionId = options.versionId;
3528 }
3529 options.headers = options.headers || {};
3530 options.headers['x-oss-object-acl'] = acl;
3531 name = this._objectName(name);
3532
3533 params = this._objectRequestParams('PUT', name, options);
3534
3535 params.successStatuses = [200];
3536
3537 _context.next = 10;
3538 return _regenerator2.default.awrap(this.request(params));
3539
3540 case 10:
3541 result = _context.sent;
3542 return _context.abrupt('return', {
3543 res: result.res
3544 });
3545
3546 case 12:
3547 case 'end':
3548 return _context.stop();
3549 }
3550 }
3551 }, null, this);
3552};
3553
3554},{"babel-runtime/core-js/object/assign":49,"babel-runtime/regenerator":65}],28:[function(require,module,exports){
3555'use strict';
3556
3557var _regenerator = require('babel-runtime/regenerator');
3558
3559var _regenerator2 = _interopRequireDefault(_regenerator);
3560
3561var _keys = require('babel-runtime/core-js/object/keys');
3562
3563var _keys2 = _interopRequireDefault(_keys);
3564
3565var _assign = require('babel-runtime/core-js/object/assign');
3566
3567var _assign2 = _interopRequireDefault(_assign);
3568
3569function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3570
3571var obj2xml = require('../utils/obj2xml');
3572var checkTag = require('../utils/checkObjectTag');
3573
3574var proto = exports;
3575/**
3576 * putObjectTagging
3577 * @param {String} name - object name
3578 * @param {Object} tag - object tag, eg: `{a: "1", b: "2"}`
3579 * @param {Object} options
3580 */
3581
3582proto.putObjectTagging = function putObjectTagging(name, tag) {
3583 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3584 var params, paramXMLObj, result;
3585 return _regenerator2.default.async(function putObjectTagging$(_context) {
3586 while (1) {
3587 switch (_context.prev = _context.next) {
3588 case 0:
3589 checkTag(tag);
3590
3591 options.subres = (0, _assign2.default)({ tagging: '' }, options.subres);
3592 if (options.versionId) {
3593 options.subres.versionId = options.versionId;
3594 }
3595 name = this._objectName(name);
3596 params = this._objectRequestParams('PUT', name, options);
3597
3598 params.successStatuses = [200];
3599 tag = (0, _keys2.default)(tag).map(function (key) {
3600 return {
3601 Key: key,
3602 Value: tag[key]
3603 };
3604 });
3605
3606 paramXMLObj = {
3607 Tagging: {
3608 TagSet: {
3609 Tag: tag
3610 }
3611 }
3612 };
3613
3614
3615 params.mime = 'xml';
3616 params.content = obj2xml(paramXMLObj);
3617
3618 _context.next = 12;
3619 return _regenerator2.default.awrap(this.request(params));
3620
3621 case 12:
3622 result = _context.sent;
3623 return _context.abrupt('return', {
3624 res: result.res,
3625 status: result.status
3626 });
3627
3628 case 14:
3629 case 'end':
3630 return _context.stop();
3631 }
3632 }
3633 }, null, this);
3634};
3635
3636},{"../utils/checkObjectTag":32,"../utils/obj2xml":42,"babel-runtime/core-js/object/assign":49,"babel-runtime/core-js/object/keys":55,"babel-runtime/regenerator":65}],29:[function(require,module,exports){
3637'use strict';
3638
3639var _regenerator = require('babel-runtime/regenerator');
3640
3641var _regenerator2 = _interopRequireDefault(_regenerator);
3642
3643var _promise = require('babel-runtime/core-js/promise');
3644
3645var _promise2 = _interopRequireDefault(_promise);
3646
3647function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3648
3649var proto = exports;
3650
3651proto._parallelNode = function _parallelNode(todo, parallel, fn, sourceData) {
3652 var that, jobErr, jobs, tempBatch, remainder, batch, taskIndex, i;
3653 return _regenerator2.default.async(function _parallelNode$(_context) {
3654 while (1) {
3655 switch (_context.prev = _context.next) {
3656 case 0:
3657 that = this;
3658 // upload in parallel
3659
3660 jobErr = [];
3661 jobs = [];
3662 tempBatch = todo.length / parallel;
3663 remainder = todo.length % parallel;
3664 batch = remainder === 0 ? tempBatch : (todo.length - remainder) / parallel + 1;
3665 taskIndex = 1;
3666 i = 0;
3667
3668 case 8:
3669 if (!(i < todo.length)) {
3670 _context.next = 26;
3671 break;
3672 }
3673
3674 if (!that.isCancel()) {
3675 _context.next = 11;
3676 break;
3677 }
3678
3679 return _context.abrupt('break', 26);
3680
3681 case 11:
3682
3683 if (sourceData) {
3684 jobs.push(fn(that, todo[i], sourceData));
3685 } else {
3686 jobs.push(fn(that, todo[i]));
3687 }
3688
3689 if (!(jobs.length === parallel || taskIndex === batch && i === todo.length - 1)) {
3690 _context.next = 23;
3691 break;
3692 }
3693
3694 _context.prev = 13;
3695
3696 taskIndex += 1;
3697 /* eslint no-await-in-loop: [0] */
3698 _context.next = 17;
3699 return _regenerator2.default.awrap(_promise2.default.all(jobs));
3700
3701 case 17:
3702 _context.next = 22;
3703 break;
3704
3705 case 19:
3706 _context.prev = 19;
3707 _context.t0 = _context['catch'](13);
3708
3709 jobErr.push(_context.t0);
3710
3711 case 22:
3712 jobs = [];
3713
3714 case 23:
3715 i++;
3716 _context.next = 8;
3717 break;
3718
3719 case 26:
3720 return _context.abrupt('return', jobErr);
3721
3722 case 27:
3723 case 'end':
3724 return _context.stop();
3725 }
3726 }
3727 }, null, this, [[13, 19]]);
3728};
3729
3730proto._parallel = function _parallel(todo, parallel, jobPromise) {
3731 var that = this;
3732 return new _promise2.default(function (resolve) {
3733 var _jobErr = [];
3734 if (parallel <= 0 || !todo) {
3735 resolve(_jobErr);
3736 return;
3737 }
3738
3739 function onlyOnce(fn) {
3740 return function () {
3741 if (fn === null) throw new Error('Callback was already called.');
3742 var callFn = fn;
3743 fn = null;
3744
3745 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
3746 args[_key] = arguments[_key];
3747 }
3748
3749 callFn.apply(this, args);
3750 };
3751 }
3752
3753 function createArrayIterator(coll) {
3754 var i = -1;
3755 var len = coll.length;
3756 return function next() {
3757 return ++i < len && !that.isCancel() ? { value: coll[i], key: i } : null;
3758 };
3759 }
3760
3761 var nextElem = createArrayIterator(todo);
3762 var done = false;
3763 var running = 0;
3764 var looping = false;
3765
3766 function iterateeCallback(err, value) {
3767 running -= 1;
3768 if (err) {
3769 done = true;
3770 _jobErr.push(err);
3771 resolve(_jobErr);
3772 } else if (value === {} || done && running <= 0) {
3773 done = true;
3774 resolve(_jobErr);
3775 } else if (!looping) {
3776 /* eslint no-use-before-define: [0] */
3777 if (that.isCancel()) {
3778 resolve(_jobErr);
3779 } else {
3780 replenish();
3781 }
3782 }
3783 }
3784
3785 function iteratee(value, callback) {
3786 jobPromise(value).then(function (result) {
3787 callback(null, result);
3788 }).catch(function (err) {
3789 callback(err);
3790 });
3791 }
3792
3793 function replenish() {
3794 looping = true;
3795 while (running < parallel && !done && !that.isCancel()) {
3796 var elem = nextElem();
3797 if (elem === null || _jobErr.length > 0) {
3798 done = true;
3799 if (running <= 0) {
3800 resolve(_jobErr);
3801 }
3802 return;
3803 }
3804 running += 1;
3805 iteratee(elem.value, onlyOnce(iterateeCallback));
3806 }
3807 looping = false;
3808 }
3809
3810 replenish();
3811 });
3812};
3813
3814/**
3815 * cancel operation, now can use with multipartUpload
3816 * @param {Object} abort
3817 * {String} anort.name object key
3818 * {String} anort.uploadId upload id
3819 * {String} anort.options timeout
3820 */
3821proto.cancel = function cancel(abort) {
3822 this.options.cancelFlag = true;
3823 if (abort) {
3824 this.abortMultipartUpload(abort.name, abort.uploadId, abort.options);
3825 }
3826};
3827
3828proto.isCancel = function isCancel() {
3829 return this.options.cancelFlag;
3830};
3831
3832proto.resetCancelFlag = function resetCancelFlag() {
3833 this.options.cancelFlag = false;
3834};
3835
3836proto._stop = function _stop() {
3837 this.options.cancelFlag = true;
3838};
3839
3840// cancel is not error , so create an object
3841proto._makeCancelEvent = function _makeCancelEvent() {
3842 var cancelEvent = {
3843 status: 0,
3844 name: 'cancel'
3845 };
3846 return cancelEvent;
3847};
3848
3849},{"babel-runtime/core-js/promise":56,"babel-runtime/regenerator":65}],30:[function(require,module,exports){
3850(function (Buffer){
3851'use strict';
3852
3853var _stringify = require('babel-runtime/core-js/json/stringify');
3854
3855var _stringify2 = _interopRequireDefault(_stringify);
3856
3857var _keys = require('babel-runtime/core-js/object/keys');
3858
3859var _keys2 = _interopRequireDefault(_keys);
3860
3861function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3862
3863var crypto = require('./../../shims/crypto/crypto.js');
3864var is = require('is-type-of');
3865
3866/**
3867 *
3868 * @param {String} resourcePath
3869 * @param {Object} parameters
3870 * @return
3871 */
3872exports.buildCanonicalizedResource = function buildCanonicalizedResource(resourcePath, parameters) {
3873 var canonicalizedResource = '' + resourcePath;
3874 var separatorString = '?';
3875
3876 if (is.string(parameters) && parameters.trim() !== '') {
3877 canonicalizedResource += separatorString + parameters;
3878 } else if (is.array(parameters)) {
3879 parameters.sort();
3880 canonicalizedResource += separatorString + parameters.join('&');
3881 } else if (parameters) {
3882 var compareFunc = function compareFunc(entry1, entry2) {
3883 if (entry1[0] > entry2[0]) {
3884 return 1;
3885 } else if (entry1[0] < entry2[0]) {
3886 return -1;
3887 }
3888 return 0;
3889 };
3890 var processFunc = function processFunc(key) {
3891 canonicalizedResource += separatorString + key;
3892 if (parameters[key]) {
3893 canonicalizedResource += '=' + parameters[key];
3894 }
3895 separatorString = '&';
3896 };
3897 (0, _keys2.default)(parameters).sort(compareFunc).forEach(processFunc);
3898 }
3899
3900 return canonicalizedResource;
3901};
3902
3903/**
3904 * @param {String} method
3905 * @param {String} resourcePath
3906 * @param {Object} request
3907 * @param {String} expires
3908 * @return {String} canonicalString
3909 */
3910exports.buildCanonicalString = function canonicalString(method, resourcePath, request, expires) {
3911 request = request || {};
3912 var headers = request.headers || {};
3913 var OSS_PREFIX = 'x-oss-';
3914 var ossHeaders = [];
3915 var headersToSign = {};
3916
3917 var signContent = [method.toUpperCase(), headers['Content-Md5'] || '', headers['Content-Type'] || headers['Content-Type'.toLowerCase()], expires || headers['x-oss-date']];
3918
3919 (0, _keys2.default)(headers).forEach(function (key) {
3920 var lowerKey = key.toLowerCase();
3921 if (lowerKey.indexOf(OSS_PREFIX) === 0) {
3922 headersToSign[lowerKey] = String(headers[key]).trim();
3923 }
3924 });
3925
3926 (0, _keys2.default)(headersToSign).sort().forEach(function (key) {
3927 ossHeaders.push(key + ':' + headersToSign[key]);
3928 });
3929
3930 signContent = signContent.concat(ossHeaders);
3931
3932 signContent.push(this.buildCanonicalizedResource(resourcePath, request.parameters));
3933
3934 return signContent.join('\n');
3935};
3936
3937/**
3938 * @param {String} accessKeySecret
3939 * @param {String} canonicalString
3940 */
3941exports.computeSignature = function computeSignature(accessKeySecret, canonicalString) {
3942 var signature = crypto.createHmac('sha1', accessKeySecret);
3943 return signature.update(Buffer.from(canonicalString, 'utf8')).digest('base64');
3944};
3945
3946/**
3947 * @param {String} accessKeyId
3948 * @param {String} accessKeySecret
3949 * @param {String} canonicalString
3950 */
3951exports.authorization = function authorization(accessKeyId, accessKeySecret, canonicalString) {
3952 return 'OSS ' + accessKeyId + ':' + this.computeSignature(accessKeySecret, canonicalString);
3953};
3954
3955/**
3956 *
3957 * @param {String} accessKeySecret
3958 * @param {Object} options
3959 * @param {String} resource
3960 * @param {Number} expires
3961 */
3962exports._signatureForURL = function _signatureForURL(accessKeySecret) {
3963 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3964 var resource = arguments[2];
3965 var expires = arguments[3];
3966
3967 var headers = {};
3968 var _options$subResource = options.subResource,
3969 subResource = _options$subResource === undefined ? {} : _options$subResource;
3970
3971
3972 if (options.process) {
3973 var processKeyword = 'x-oss-process';
3974 subResource[processKeyword] = options.process;
3975 }
3976
3977 if (options.trafficLimit) {
3978 var trafficLimitKey = 'x-oss-traffic-limit';
3979 subResource[trafficLimitKey] = options.trafficLimit;
3980 }
3981
3982 if (options.response) {
3983 (0, _keys2.default)(options.response).forEach(function (k) {
3984 var key = 'response-' + k.toLowerCase();
3985 subResource[key] = options.response[k];
3986 });
3987 }
3988
3989 (0, _keys2.default)(options).forEach(function (key) {
3990 var lowerKey = key.toLowerCase();
3991 var value = options[key];
3992 if (lowerKey.indexOf('x-oss-') === 0) {
3993 headers[lowerKey] = value;
3994 } else if (lowerKey.indexOf('content-md5') === 0) {
3995 headers[key] = value;
3996 } else if (lowerKey.indexOf('content-type') === 0) {
3997 headers[key] = value;
3998 }
3999 });
4000
4001 if (Object.prototype.hasOwnProperty.call(options, 'security-token')) {
4002 subResource['security-token'] = options['security-token'];
4003 }
4004
4005 if (Object.prototype.hasOwnProperty.call(options, 'callback')) {
4006 var json = {
4007 callbackUrl: encodeURI(options.callback.url),
4008 callbackBody: options.callback.body
4009 };
4010 if (options.callback.host) {
4011 json.callbackHost = options.callback.host;
4012 }
4013 if (options.callback.contentType) {
4014 json.callbackBodyType = options.callback.contentType;
4015 }
4016 subResource.callback = Buffer.from((0, _stringify2.default)(json)).toString('base64');
4017
4018 if (options.callback.customValue) {
4019 var callbackVar = {};
4020 (0, _keys2.default)(options.callback.customValue).forEach(function (key) {
4021 callbackVar['x:' + key] = options.callback.customValue[key];
4022 });
4023 subResource['callback-var'] = Buffer.from((0, _stringify2.default)(callbackVar)).toString('base64');
4024 }
4025 }
4026
4027 var canonicalString = this.buildCanonicalString(options.method, resource, {
4028 headers: headers,
4029 parameters: subResource
4030 }, expires.toString());
4031
4032 return {
4033 Signature: this.computeSignature(accessKeySecret, canonicalString),
4034 subResource: subResource
4035 };
4036};
4037
4038}).call(this,require("buffer").Buffer)
4039},{"./../../shims/crypto/crypto.js":328,"babel-runtime/core-js/json/stringify":48,"babel-runtime/core-js/object/keys":55,"buffer":70,"is-type-of":233}],31:[function(require,module,exports){
4040'use strict';
4041
4042/**
4043 * check Bucket Name
4044 */
4045
4046module.exports = function (name, createBucket) {
4047 var bucketRegex = createBucket ? /^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/ : /^[a-z0-9_][a-z0-9-_]{1,61}[a-z0-9_]$/;
4048 if (!bucketRegex.test(name)) {
4049 throw new Error('The bucket must be conform to the specifications');
4050 }
4051};
4052
4053},{}],32:[function(require,module,exports){
4054'use strict';
4055
4056var _entries = require('babel-runtime/core-js/object/entries');
4057
4058var _entries2 = _interopRequireDefault(_entries);
4059
4060function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4061
4062var checkValid = require('./checkValid');
4063var isObject = require('./isObject');
4064
4065var commonRules = [{
4066 validator: function validator(value) {
4067 if (typeof value !== 'string') {
4068 throw new Error('the key and value of the tag must be String');
4069 }
4070 }
4071}, {
4072 pattern: /^[a-zA-Z0-9 +-=._:/]+$/,
4073 msg: 'tag can contain letters, numbers, spaces, and the following symbols: plus sign (+), hyphen (-), equal sign (=), period (.), underscore (_), colon (:), and forward slash (/)'
4074}];
4075
4076var rules = {
4077 key: [].concat(commonRules, [{
4078 pattern: /^.{1,128}$/,
4079 msg: 'tag key can be a maximum of 128 bytes in length'
4080 }]),
4081 value: [].concat(commonRules, [{
4082 pattern: /^.{0,256}$/,
4083 msg: 'tag value can be a maximum of 256 bytes in length'
4084 }])
4085};
4086
4087module.exports = function checkTag(tag) {
4088 if (!isObject(tag)) {
4089 throw new Error('tag must be Object');
4090 }
4091
4092 var entries = (0, _entries2.default)(tag);
4093
4094 if (entries.length > 10) {
4095 throw new Error('maximum of 10 tags for a object');
4096 }
4097
4098 var rulesIndexKey = ['key', 'value'];
4099
4100 entries.forEach(function (keyValue) {
4101 keyValue.forEach(function (item, index) {
4102 checkValid(item, rules[rulesIndexKey[index]]);
4103 });
4104 });
4105};
4106
4107},{"./checkValid":33,"./isObject":41,"babel-runtime/core-js/object/entries":52}],33:[function(require,module,exports){
4108"use strict";
4109
4110module.exports = function checkValid(_value, _rules) {
4111 _rules.forEach(function (rule) {
4112 if (rule.validator) {
4113 rule.validator(_value);
4114 } else if (rule.pattern && !rule.pattern.test(_value)) {
4115 throw new Error(rule.msg);
4116 }
4117 });
4118};
4119
4120},{}],34:[function(require,module,exports){
4121'use strict';
4122
4123var _keys = require('babel-runtime/core-js/object/keys');
4124
4125var _keys2 = _interopRequireDefault(_keys);
4126
4127var _typeof2 = require('babel-runtime/helpers/typeof');
4128
4129var _typeof3 = _interopRequireDefault(_typeof2);
4130
4131function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4132
4133module.exports = function deepCopy(obj) {
4134 var cache = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
4135
4136 if (obj === null || (typeof obj === 'undefined' ? 'undefined' : (0, _typeof3.default)(obj)) !== 'object') {
4137 return obj;
4138 }
4139 var hit = cache.filter(function (c) {
4140 return c.original === obj;
4141 })[0];
4142 if (hit) {
4143 return hit.copy;
4144 }
4145 var copy = Array.isArray(obj) ? [] : {};
4146 cache.push({
4147 original: obj,
4148 copy: copy
4149 });
4150
4151 (0, _keys2.default)(obj).forEach(function (key) {
4152 copy[key] = deepCopy(obj[key], cache);
4153 });
4154
4155 return copy;
4156};
4157
4158},{"babel-runtime/core-js/object/keys":55,"babel-runtime/helpers/typeof":64}],35:[function(require,module,exports){
4159'use strict';
4160
4161var _keys = require('babel-runtime/core-js/object/keys');
4162
4163var _keys2 = _interopRequireDefault(_keys);
4164
4165var _typeof2 = require('babel-runtime/helpers/typeof');
4166
4167var _typeof3 = _interopRequireDefault(_typeof2);
4168
4169function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4170
4171/* eslint-disable no-use-before-define */
4172module.exports = function formatObjKey(obj, type) {
4173 if (obj === null || (typeof obj === 'undefined' ? 'undefined' : (0, _typeof3.default)(obj)) !== 'object') {
4174 return obj;
4175 }
4176
4177 var o = void 0;
4178 if (Array.isArray(obj)) {
4179 o = [];
4180 for (var i = 0; i < obj.length; i++) {
4181 o.push(formatObjKey(obj[i], type));
4182 }
4183 } else {
4184 o = {};
4185 (0, _keys2.default)(obj).forEach(function (key) {
4186 o[handelFormat(key, type)] = formatObjKey(obj[key], type);
4187 });
4188 }
4189 return o;
4190};
4191
4192function handelFormat(key, type) {
4193 if (type === 'firstUpperCase') {
4194 key = key.replace(/^./, function (_) {
4195 return _.toUpperCase();
4196 });
4197 } else if (type === 'firstLowerCase') {
4198 key = key.replace(/^./, function (_) {
4199 return _.toLowerCase();
4200 });
4201 }
4202 return key;
4203}
4204
4205},{"babel-runtime/core-js/object/keys":55,"babel-runtime/helpers/typeof":64}],36:[function(require,module,exports){
4206"use strict";
4207
4208module.exports = function getStrBytesCount(str) {
4209 var bytesCount = 0;
4210 for (var i = 0; i < str.length; i++) {
4211 var c = str.charAt(i);
4212 if (/^[\u00-\uff]$/.test(c)) {
4213 bytesCount += 1;
4214 } else {
4215 bytesCount += 2;
4216 }
4217 }
4218 return bytesCount;
4219};
4220
4221},{}],37:[function(require,module,exports){
4222'use strict';
4223
4224module.exports = function isArray(obj) {
4225 return Object.prototype.toString.call(obj) === '[object Array]';
4226};
4227
4228},{}],38:[function(require,module,exports){
4229'use strict';
4230
4231module.exports = function isBlob(blob) {
4232 return typeof Blob !== 'undefined' && blob instanceof Blob;
4233};
4234
4235},{}],39:[function(require,module,exports){
4236'use strict';
4237
4238module.exports = function isFile(obj) {
4239 return typeof File !== 'undefined' && obj instanceof File;
4240};
4241
4242},{}],40:[function(require,module,exports){
4243"use strict";
4244
4245// it provide commont methods for node and browser , we will add more solutions later in this file
4246/**
4247 * Judge isIP include ipv4 or ipv6
4248 * @param {String} options
4249 * @return {Array} the multipart uploads
4250 */
4251module.exports = function (host) {
4252 var ipv4Regex = /^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}$/;
4253 var ipv6Regex = /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/;
4254 var isIP = ipv4Regex.test(host) || ipv6Regex.test(host);
4255 return isIP;
4256};
4257
4258},{}],41:[function(require,module,exports){
4259'use strict';
4260
4261module.exports = function isObject(obj) {
4262 return Object.prototype.toString.call(obj) === '[object Object]';
4263};
4264
4265},{}],42:[function(require,module,exports){
4266'use strict';
4267
4268var _keys = require('babel-runtime/core-js/object/keys');
4269
4270var _keys2 = _interopRequireDefault(_keys);
4271
4272function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4273
4274var formatObjKey = require('./formatObjKey');
4275
4276function type(params) {
4277 return Object.prototype.toString.call(params).replace(/(.*? |])/g, '').toLowerCase();
4278}
4279
4280function obj2xml(obj, options) {
4281 var s = '';
4282 if (options && options.headers) {
4283 s = '<?xml version="1.0" encoding="UTF-8"?>\n';
4284 }
4285 if (options && options.firstUpperCase) {
4286 obj = formatObjKey(obj, 'firstUpperCase');
4287 }
4288 if (type(obj) === 'object') {
4289 (0, _keys2.default)(obj).forEach(function (key) {
4290 if (type(obj[key]) === 'string' || type(obj[key]) === 'number') {
4291 s += '<' + key + '>' + obj[key] + '</' + key + '>';
4292 } else if (type(obj[key]) === 'object') {
4293 s += '<' + key + '>' + obj2xml(obj[key]) + '</' + key + '>';
4294 } else if (type(obj[key]) === 'array') {
4295 s += obj[key].map(function (keyChild) {
4296 return '<' + key + '>' + obj2xml(keyChild) + '</' + key + '>';
4297 }).join('');
4298 } else {
4299 s += '<' + key + '>' + obj[key].toString() + '</' + key + '>';
4300 }
4301 });
4302 } else {
4303 s += obj.toString();
4304 }
4305 return s;
4306}
4307
4308module.exports = obj2xml;
4309
4310},{"./formatObjKey":35,"babel-runtime/core-js/object/keys":55}],43:[function(require,module,exports){
4311module.exports = noop;
4312module.exports.HttpsAgent = noop;
4313
4314// Noop function for browser since native api's don't use agents.
4315function noop () {}
4316
4317},{}],44:[function(require,module,exports){
4318module.exports = require('./register')().Promise
4319
4320},{"./register":46}],45:[function(require,module,exports){
4321"use strict"
4322 // global key for user preferred registration
4323var REGISTRATION_KEY = '@@any-promise/REGISTRATION',
4324 // Prior registration (preferred or detected)
4325 registered = null
4326
4327/**
4328 * Registers the given implementation. An implementation must
4329 * be registered prior to any call to `require("any-promise")`,
4330 * typically on application load.
4331 *
4332 * If called with no arguments, will return registration in
4333 * following priority:
4334 *
4335 * For Node.js:
4336 *
4337 * 1. Previous registration
4338 * 2. global.Promise if node.js version >= 0.12
4339 * 3. Auto detected promise based on first sucessful require of
4340 * known promise libraries. Note this is a last resort, as the
4341 * loaded library is non-deterministic. node.js >= 0.12 will
4342 * always use global.Promise over this priority list.
4343 * 4. Throws error.
4344 *
4345 * For Browser:
4346 *
4347 * 1. Previous registration
4348 * 2. window.Promise
4349 * 3. Throws error.
4350 *
4351 * Options:
4352 *
4353 * Promise: Desired Promise constructor
4354 * global: Boolean - Should the registration be cached in a global variable to
4355 * allow cross dependency/bundle registration? (default true)
4356 */
4357module.exports = function(root, loadImplementation){
4358 return function register(implementation, opts){
4359 implementation = implementation || null
4360 opts = opts || {}
4361 // global registration unless explicitly {global: false} in options (default true)
4362 var registerGlobal = opts.global !== false;
4363
4364 // load any previous global registration
4365 if(registered === null && registerGlobal){
4366 registered = root[REGISTRATION_KEY] || null
4367 }
4368
4369 if(registered !== null
4370 && implementation !== null
4371 && registered.implementation !== implementation){
4372 // Throw error if attempting to redefine implementation
4373 throw new Error('any-promise already defined as "'+registered.implementation+
4374 '". You can only register an implementation before the first '+
4375 ' call to require("any-promise") and an implementation cannot be changed')
4376 }
4377
4378 if(registered === null){
4379 // use provided implementation
4380 if(implementation !== null && typeof opts.Promise !== 'undefined'){
4381 registered = {
4382 Promise: opts.Promise,
4383 implementation: implementation
4384 }
4385 } else {
4386 // require implementation if implementation is specified but not provided
4387 registered = loadImplementation(implementation)
4388 }
4389
4390 if(registerGlobal){
4391 // register preference globally in case multiple installations
4392 root[REGISTRATION_KEY] = registered
4393 }
4394 }
4395
4396 return registered
4397 }
4398}
4399
4400},{}],46:[function(require,module,exports){
4401"use strict";
4402module.exports = require('./loader')(window, loadImplementation)
4403
4404/**
4405 * Browser specific loadImplementation. Always uses `window.Promise`
4406 *
4407 * To register a custom implementation, must register with `Promise` option.
4408 */
4409function loadImplementation(){
4410 if(typeof window.Promise === 'undefined'){
4411 throw new Error("any-promise browser requires a polyfill or explicit registration"+
4412 " e.g: require('any-promise/register/bluebird')")
4413 }
4414 return {
4415 Promise: window.Promise,
4416 implementation: 'window.Promise'
4417 }
4418}
4419
4420},{"./loader":45}],47:[function(require,module,exports){
4421module.exports = { "default": require("core-js/library/fn/array/from"), __esModule: true };
4422},{"core-js/library/fn/array/from":74}],48:[function(require,module,exports){
4423module.exports = { "default": require("core-js/library/fn/json/stringify"), __esModule: true };
4424},{"core-js/library/fn/json/stringify":75}],49:[function(require,module,exports){
4425module.exports = { "default": require("core-js/library/fn/object/assign"), __esModule: true };
4426},{"core-js/library/fn/object/assign":76}],50:[function(require,module,exports){
4427module.exports = { "default": require("core-js/library/fn/object/create"), __esModule: true };
4428},{"core-js/library/fn/object/create":77}],51:[function(require,module,exports){
4429module.exports = { "default": require("core-js/library/fn/object/define-property"), __esModule: true };
4430},{"core-js/library/fn/object/define-property":78}],52:[function(require,module,exports){
4431module.exports = { "default": require("core-js/library/fn/object/entries"), __esModule: true };
4432},{"core-js/library/fn/object/entries":79}],53:[function(require,module,exports){
4433module.exports = { "default": require("core-js/library/fn/object/get-own-property-names"), __esModule: true };
4434},{"core-js/library/fn/object/get-own-property-names":80}],54:[function(require,module,exports){
4435module.exports = { "default": require("core-js/library/fn/object/get-prototype-of"), __esModule: true };
4436},{"core-js/library/fn/object/get-prototype-of":81}],55:[function(require,module,exports){
4437module.exports = { "default": require("core-js/library/fn/object/keys"), __esModule: true };
4438},{"core-js/library/fn/object/keys":82}],56:[function(require,module,exports){
4439module.exports = { "default": require("core-js/library/fn/promise"), __esModule: true };
4440},{"core-js/library/fn/promise":83}],57:[function(require,module,exports){
4441module.exports = { "default": require("core-js/library/fn/set-immediate"), __esModule: true };
4442},{"core-js/library/fn/set-immediate":84}],58:[function(require,module,exports){
4443module.exports = { "default": require("core-js/library/fn/string/from-code-point"), __esModule: true };
4444},{"core-js/library/fn/string/from-code-point":85}],59:[function(require,module,exports){
4445module.exports = { "default": require("core-js/library/fn/symbol"), __esModule: true };
4446},{"core-js/library/fn/symbol":87}],60:[function(require,module,exports){
4447module.exports = { "default": require("core-js/library/fn/symbol/has-instance"), __esModule: true };
4448},{"core-js/library/fn/symbol/has-instance":86}],61:[function(require,module,exports){
4449module.exports = { "default": require("core-js/library/fn/symbol/iterator"), __esModule: true };
4450},{"core-js/library/fn/symbol/iterator":88}],62:[function(require,module,exports){
4451"use strict";
4452
4453exports.__esModule = true;
4454
4455exports.default = function (instance, Constructor) {
4456 if (!(instance instanceof Constructor)) {
4457 throw new TypeError("Cannot call a class as a function");
4458 }
4459};
4460},{}],63:[function(require,module,exports){
4461"use strict";
4462
4463exports.__esModule = true;
4464
4465var _defineProperty = require("../core-js/object/define-property");
4466
4467var _defineProperty2 = _interopRequireDefault(_defineProperty);
4468
4469function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4470
4471exports.default = function () {
4472 function defineProperties(target, props) {
4473 for (var i = 0; i < props.length; i++) {
4474 var descriptor = props[i];
4475 descriptor.enumerable = descriptor.enumerable || false;
4476 descriptor.configurable = true;
4477 if ("value" in descriptor) descriptor.writable = true;
4478 (0, _defineProperty2.default)(target, descriptor.key, descriptor);
4479 }
4480 }
4481
4482 return function (Constructor, protoProps, staticProps) {
4483 if (protoProps) defineProperties(Constructor.prototype, protoProps);
4484 if (staticProps) defineProperties(Constructor, staticProps);
4485 return Constructor;
4486 };
4487}();
4488},{"../core-js/object/define-property":51}],64:[function(require,module,exports){
4489"use strict";
4490
4491exports.__esModule = true;
4492
4493var _iterator = require("../core-js/symbol/iterator");
4494
4495var _iterator2 = _interopRequireDefault(_iterator);
4496
4497var _symbol = require("../core-js/symbol");
4498
4499var _symbol2 = _interopRequireDefault(_symbol);
4500
4501var _typeof = typeof _symbol2.default === "function" && typeof _iterator2.default === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj; };
4502
4503function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4504
4505exports.default = typeof _symbol2.default === "function" && _typeof(_iterator2.default) === "symbol" ? function (obj) {
4506 return typeof obj === "undefined" ? "undefined" : _typeof(obj);
4507} : function (obj) {
4508 return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof(obj);
4509};
4510},{"../core-js/symbol":59,"../core-js/symbol/iterator":61}],65:[function(require,module,exports){
4511module.exports = require("regenerator-runtime");
4512
4513},{"regenerator-runtime":267}],66:[function(require,module,exports){
4514'use strict'
4515
4516exports.byteLength = byteLength
4517exports.toByteArray = toByteArray
4518exports.fromByteArray = fromByteArray
4519
4520var lookup = []
4521var revLookup = []
4522var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
4523
4524var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
4525for (var i = 0, len = code.length; i < len; ++i) {
4526 lookup[i] = code[i]
4527 revLookup[code.charCodeAt(i)] = i
4528}
4529
4530// Support decoding URL-safe base64 strings, as Node.js does.
4531// See: https://en.wikipedia.org/wiki/Base64#URL_applications
4532revLookup['-'.charCodeAt(0)] = 62
4533revLookup['_'.charCodeAt(0)] = 63
4534
4535function getLens (b64) {
4536 var len = b64.length
4537
4538 if (len % 4 > 0) {
4539 throw new Error('Invalid string. Length must be a multiple of 4')
4540 }
4541
4542 // Trim off extra bytes after placeholder bytes are found
4543 // See: https://github.com/beatgammit/base64-js/issues/42
4544 var validLen = b64.indexOf('=')
4545 if (validLen === -1) validLen = len
4546
4547 var placeHoldersLen = validLen === len
4548 ? 0
4549 : 4 - (validLen % 4)
4550
4551 return [validLen, placeHoldersLen]
4552}
4553
4554// base64 is 4/3 + up to two characters of the original data
4555function byteLength (b64) {
4556 var lens = getLens(b64)
4557 var validLen = lens[0]
4558 var placeHoldersLen = lens[1]
4559 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
4560}
4561
4562function _byteLength (b64, validLen, placeHoldersLen) {
4563 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
4564}
4565
4566function toByteArray (b64) {
4567 var tmp
4568 var lens = getLens(b64)
4569 var validLen = lens[0]
4570 var placeHoldersLen = lens[1]
4571
4572 var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
4573
4574 var curByte = 0
4575
4576 // if there are placeholders, only get up to the last complete 4 chars
4577 var len = placeHoldersLen > 0
4578 ? validLen - 4
4579 : validLen
4580
4581 for (var i = 0; i < len; i += 4) {
4582 tmp =
4583 (revLookup[b64.charCodeAt(i)] << 18) |
4584 (revLookup[b64.charCodeAt(i + 1)] << 12) |
4585 (revLookup[b64.charCodeAt(i + 2)] << 6) |
4586 revLookup[b64.charCodeAt(i + 3)]
4587 arr[curByte++] = (tmp >> 16) & 0xFF
4588 arr[curByte++] = (tmp >> 8) & 0xFF
4589 arr[curByte++] = tmp & 0xFF
4590 }
4591
4592 if (placeHoldersLen === 2) {
4593 tmp =
4594 (revLookup[b64.charCodeAt(i)] << 2) |
4595 (revLookup[b64.charCodeAt(i + 1)] >> 4)
4596 arr[curByte++] = tmp & 0xFF
4597 }
4598
4599 if (placeHoldersLen === 1) {
4600 tmp =
4601 (revLookup[b64.charCodeAt(i)] << 10) |
4602 (revLookup[b64.charCodeAt(i + 1)] << 4) |
4603 (revLookup[b64.charCodeAt(i + 2)] >> 2)
4604 arr[curByte++] = (tmp >> 8) & 0xFF
4605 arr[curByte++] = tmp & 0xFF
4606 }
4607
4608 return arr
4609}
4610
4611function tripletToBase64 (num) {
4612 return lookup[num >> 18 & 0x3F] +
4613 lookup[num >> 12 & 0x3F] +
4614 lookup[num >> 6 & 0x3F] +
4615 lookup[num & 0x3F]
4616}
4617
4618function encodeChunk (uint8, start, end) {
4619 var tmp
4620 var output = []
4621 for (var i = start; i < end; i += 3) {
4622 tmp =
4623 ((uint8[i] << 16) & 0xFF0000) +
4624 ((uint8[i + 1] << 8) & 0xFF00) +
4625 (uint8[i + 2] & 0xFF)
4626 output.push(tripletToBase64(tmp))
4627 }
4628 return output.join('')
4629}
4630
4631function fromByteArray (uint8) {
4632 var tmp
4633 var len = uint8.length
4634 var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
4635 var parts = []
4636 var maxChunkLength = 16383 // must be multiple of 3
4637
4638 // go through the array every three bytes, we'll deal with trailing stuff later
4639 for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
4640 parts.push(encodeChunk(
4641 uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
4642 ))
4643 }
4644
4645 // pad the end with zeros, but make sure to not forget the extra bytes
4646 if (extraBytes === 1) {
4647 tmp = uint8[len - 1]
4648 parts.push(
4649 lookup[tmp >> 2] +
4650 lookup[(tmp << 4) & 0x3F] +
4651 '=='
4652 )
4653 } else if (extraBytes === 2) {
4654 tmp = (uint8[len - 2] << 8) + uint8[len - 1]
4655 parts.push(
4656 lookup[tmp >> 10] +
4657 lookup[(tmp >> 4) & 0x3F] +
4658 lookup[(tmp << 2) & 0x3F] +
4659 '='
4660 )
4661 }
4662
4663 return parts.join('')
4664}
4665
4666},{}],67:[function(require,module,exports){
4667/*!
4668 * Bowser - a browser detector
4669 * https://github.com/ded/bowser
4670 * MIT License | (c) Dustin Diaz 2015
4671 */
4672
4673!function (root, name, definition) {
4674 if (typeof module != 'undefined' && module.exports) module.exports = definition()
4675 else if (typeof define == 'function' && define.amd) define(name, definition)
4676 else root[name] = definition()
4677}(this, 'bowser', function () {
4678 /**
4679 * See useragents.js for examples of navigator.userAgent
4680 */
4681
4682 var t = true
4683
4684 function detect(ua) {
4685
4686 function getFirstMatch(regex) {
4687 var match = ua.match(regex);
4688 return (match && match.length > 1 && match[1]) || '';
4689 }
4690
4691 function getSecondMatch(regex) {
4692 var match = ua.match(regex);
4693 return (match && match.length > 1 && match[2]) || '';
4694 }
4695
4696 var iosdevice = getFirstMatch(/(ipod|iphone|ipad)/i).toLowerCase()
4697 , likeAndroid = /like android/i.test(ua)
4698 , android = !likeAndroid && /android/i.test(ua)
4699 , nexusMobile = /nexus\s*[0-6]\s*/i.test(ua)
4700 , nexusTablet = !nexusMobile && /nexus\s*[0-9]+/i.test(ua)
4701 , chromeos = /CrOS/.test(ua)
4702 , silk = /silk/i.test(ua)
4703 , sailfish = /sailfish/i.test(ua)
4704 , tizen = /tizen/i.test(ua)
4705 , webos = /(web|hpw)(o|0)s/i.test(ua)
4706 , windowsphone = /windows phone/i.test(ua)
4707 , samsungBrowser = /SamsungBrowser/i.test(ua)
4708 , windows = !windowsphone && /windows/i.test(ua)
4709 , mac = !iosdevice && !silk && /macintosh/i.test(ua)
4710 , linux = !android && !sailfish && !tizen && !webos && /linux/i.test(ua)
4711 , edgeVersion = getSecondMatch(/edg([ea]|ios)\/(\d+(\.\d+)?)/i)
4712 , versionIdentifier = getFirstMatch(/version\/(\d+(\.\d+)?)/i)
4713 , tablet = /tablet/i.test(ua) && !/tablet pc/i.test(ua)
4714 , mobile = !tablet && /[^-]mobi/i.test(ua)
4715 , xbox = /xbox/i.test(ua)
4716 , result
4717
4718 if (/opera/i.test(ua)) {
4719 // an old Opera
4720 result = {
4721 name: 'Opera'
4722 , opera: t
4723 , version: versionIdentifier || getFirstMatch(/(?:opera|opr|opios)[\s\/](\d+(\.\d+)?)/i)
4724 }
4725 } else if (/opr\/|opios/i.test(ua)) {
4726 // a new Opera
4727 result = {
4728 name: 'Opera'
4729 , opera: t
4730 , version: getFirstMatch(/(?:opr|opios)[\s\/](\d+(\.\d+)?)/i) || versionIdentifier
4731 }
4732 }
4733 else if (/SamsungBrowser/i.test(ua)) {
4734 result = {
4735 name: 'Samsung Internet for Android'
4736 , samsungBrowser: t
4737 , version: versionIdentifier || getFirstMatch(/(?:SamsungBrowser)[\s\/](\d+(\.\d+)?)/i)
4738 }
4739 }
4740 else if (/Whale/i.test(ua)) {
4741 result = {
4742 name: 'NAVER Whale browser'
4743 , whale: t
4744 , version: getFirstMatch(/(?:whale)[\s\/](\d+(?:\.\d+)+)/i)
4745 }
4746 }
4747 else if (/MZBrowser/i.test(ua)) {
4748 result = {
4749 name: 'MZ Browser'
4750 , mzbrowser: t
4751 , version: getFirstMatch(/(?:MZBrowser)[\s\/](\d+(?:\.\d+)+)/i)
4752 }
4753 }
4754 else if (/coast/i.test(ua)) {
4755 result = {
4756 name: 'Opera Coast'
4757 , coast: t
4758 , version: versionIdentifier || getFirstMatch(/(?:coast)[\s\/](\d+(\.\d+)?)/i)
4759 }
4760 }
4761 else if (/focus/i.test(ua)) {
4762 result = {
4763 name: 'Focus'
4764 , focus: t
4765 , version: getFirstMatch(/(?:focus)[\s\/](\d+(?:\.\d+)+)/i)
4766 }
4767 }
4768 else if (/yabrowser/i.test(ua)) {
4769 result = {
4770 name: 'Yandex Browser'
4771 , yandexbrowser: t
4772 , version: versionIdentifier || getFirstMatch(/(?:yabrowser)[\s\/](\d+(\.\d+)?)/i)
4773 }
4774 }
4775 else if (/ucbrowser/i.test(ua)) {
4776 result = {
4777 name: 'UC Browser'
4778 , ucbrowser: t
4779 , version: getFirstMatch(/(?:ucbrowser)[\s\/](\d+(?:\.\d+)+)/i)
4780 }
4781 }
4782 else if (/mxios/i.test(ua)) {
4783 result = {
4784 name: 'Maxthon'
4785 , maxthon: t
4786 , version: getFirstMatch(/(?:mxios)[\s\/](\d+(?:\.\d+)+)/i)
4787 }
4788 }
4789 else if (/epiphany/i.test(ua)) {
4790 result = {
4791 name: 'Epiphany'
4792 , epiphany: t
4793 , version: getFirstMatch(/(?:epiphany)[\s\/](\d+(?:\.\d+)+)/i)
4794 }
4795 }
4796 else if (/puffin/i.test(ua)) {
4797 result = {
4798 name: 'Puffin'
4799 , puffin: t
4800 , version: getFirstMatch(/(?:puffin)[\s\/](\d+(?:\.\d+)?)/i)
4801 }
4802 }
4803 else if (/sleipnir/i.test(ua)) {
4804 result = {
4805 name: 'Sleipnir'
4806 , sleipnir: t
4807 , version: getFirstMatch(/(?:sleipnir)[\s\/](\d+(?:\.\d+)+)/i)
4808 }
4809 }
4810 else if (/k-meleon/i.test(ua)) {
4811 result = {
4812 name: 'K-Meleon'
4813 , kMeleon: t
4814 , version: getFirstMatch(/(?:k-meleon)[\s\/](\d+(?:\.\d+)+)/i)
4815 }
4816 }
4817 else if (windowsphone) {
4818 result = {
4819 name: 'Windows Phone'
4820 , osname: 'Windows Phone'
4821 , windowsphone: t
4822 }
4823 if (edgeVersion) {
4824 result.msedge = t
4825 result.version = edgeVersion
4826 }
4827 else {
4828 result.msie = t
4829 result.version = getFirstMatch(/iemobile\/(\d+(\.\d+)?)/i)
4830 }
4831 }
4832 else if (/msie|trident/i.test(ua)) {
4833 result = {
4834 name: 'Internet Explorer'
4835 , msie: t
4836 , version: getFirstMatch(/(?:msie |rv:)(\d+(\.\d+)?)/i)
4837 }
4838 } else if (chromeos) {
4839 result = {
4840 name: 'Chrome'
4841 , osname: 'Chrome OS'
4842 , chromeos: t
4843 , chromeBook: t
4844 , chrome: t
4845 , version: getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)
4846 }
4847 } else if (/edg([ea]|ios)/i.test(ua)) {
4848 result = {
4849 name: 'Microsoft Edge'
4850 , msedge: t
4851 , version: edgeVersion
4852 }
4853 }
4854 else if (/vivaldi/i.test(ua)) {
4855 result = {
4856 name: 'Vivaldi'
4857 , vivaldi: t
4858 , version: getFirstMatch(/vivaldi\/(\d+(\.\d+)?)/i) || versionIdentifier
4859 }
4860 }
4861 else if (sailfish) {
4862 result = {
4863 name: 'Sailfish'
4864 , osname: 'Sailfish OS'
4865 , sailfish: t
4866 , version: getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i)
4867 }
4868 }
4869 else if (/seamonkey\//i.test(ua)) {
4870 result = {
4871 name: 'SeaMonkey'
4872 , seamonkey: t
4873 , version: getFirstMatch(/seamonkey\/(\d+(\.\d+)?)/i)
4874 }
4875 }
4876 else if (/firefox|iceweasel|fxios/i.test(ua)) {
4877 result = {
4878 name: 'Firefox'
4879 , firefox: t
4880 , version: getFirstMatch(/(?:firefox|iceweasel|fxios)[ \/](\d+(\.\d+)?)/i)
4881 }
4882 if (/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(ua)) {
4883 result.firefoxos = t
4884 result.osname = 'Firefox OS'
4885 }
4886 }
4887 else if (silk) {
4888 result = {
4889 name: 'Amazon Silk'
4890 , silk: t
4891 , version : getFirstMatch(/silk\/(\d+(\.\d+)?)/i)
4892 }
4893 }
4894 else if (/phantom/i.test(ua)) {
4895 result = {
4896 name: 'PhantomJS'
4897 , phantom: t
4898 , version: getFirstMatch(/phantomjs\/(\d+(\.\d+)?)/i)
4899 }
4900 }
4901 else if (/slimerjs/i.test(ua)) {
4902 result = {
4903 name: 'SlimerJS'
4904 , slimer: t
4905 , version: getFirstMatch(/slimerjs\/(\d+(\.\d+)?)/i)
4906 }
4907 }
4908 else if (/blackberry|\bbb\d+/i.test(ua) || /rim\stablet/i.test(ua)) {
4909 result = {
4910 name: 'BlackBerry'
4911 , osname: 'BlackBerry OS'
4912 , blackberry: t
4913 , version: versionIdentifier || getFirstMatch(/blackberry[\d]+\/(\d+(\.\d+)?)/i)
4914 }
4915 }
4916 else if (webos) {
4917 result = {
4918 name: 'WebOS'
4919 , osname: 'WebOS'
4920 , webos: t
4921 , version: versionIdentifier || getFirstMatch(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)
4922 };
4923 /touchpad\//i.test(ua) && (result.touchpad = t)
4924 }
4925 else if (/bada/i.test(ua)) {
4926 result = {
4927 name: 'Bada'
4928 , osname: 'Bada'
4929 , bada: t
4930 , version: getFirstMatch(/dolfin\/(\d+(\.\d+)?)/i)
4931 };
4932 }
4933 else if (tizen) {
4934 result = {
4935 name: 'Tizen'
4936 , osname: 'Tizen'
4937 , tizen: t
4938 , version: getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i) || versionIdentifier
4939 };
4940 }
4941 else if (/qupzilla/i.test(ua)) {
4942 result = {
4943 name: 'QupZilla'
4944 , qupzilla: t
4945 , version: getFirstMatch(/(?:qupzilla)[\s\/](\d+(?:\.\d+)+)/i) || versionIdentifier
4946 }
4947 }
4948 else if (/chromium/i.test(ua)) {
4949 result = {
4950 name: 'Chromium'
4951 , chromium: t
4952 , version: getFirstMatch(/(?:chromium)[\s\/](\d+(?:\.\d+)?)/i) || versionIdentifier
4953 }
4954 }
4955 else if (/chrome|crios|crmo/i.test(ua)) {
4956 result = {
4957 name: 'Chrome'
4958 , chrome: t
4959 , version: getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)
4960 }
4961 }
4962 else if (android) {
4963 result = {
4964 name: 'Android'
4965 , version: versionIdentifier
4966 }
4967 }
4968 else if (/safari|applewebkit/i.test(ua)) {
4969 result = {
4970 name: 'Safari'
4971 , safari: t
4972 }
4973 if (versionIdentifier) {
4974 result.version = versionIdentifier
4975 }
4976 }
4977 else if (iosdevice) {
4978 result = {
4979 name : iosdevice == 'iphone' ? 'iPhone' : iosdevice == 'ipad' ? 'iPad' : 'iPod'
4980 }
4981 // WTF: version is not part of user agent in web apps
4982 if (versionIdentifier) {
4983 result.version = versionIdentifier
4984 }
4985 }
4986 else if(/googlebot/i.test(ua)) {
4987 result = {
4988 name: 'Googlebot'
4989 , googlebot: t
4990 , version: getFirstMatch(/googlebot\/(\d+(\.\d+))/i) || versionIdentifier
4991 }
4992 }
4993 else {
4994 result = {
4995 name: getFirstMatch(/^(.*)\/(.*) /),
4996 version: getSecondMatch(/^(.*)\/(.*) /)
4997 };
4998 }
4999
5000 // set webkit or gecko flag for browsers based on these engines
5001 if (!result.msedge && /(apple)?webkit/i.test(ua)) {
5002 if (/(apple)?webkit\/537\.36/i.test(ua)) {
5003 result.name = result.name || "Blink"
5004 result.blink = t
5005 } else {
5006 result.name = result.name || "Webkit"
5007 result.webkit = t
5008 }
5009 if (!result.version && versionIdentifier) {
5010 result.version = versionIdentifier
5011 }
5012 } else if (!result.opera && /gecko\//i.test(ua)) {
5013 result.name = result.name || "Gecko"
5014 result.gecko = t
5015 result.version = result.version || getFirstMatch(/gecko\/(\d+(\.\d+)?)/i)
5016 }
5017
5018 // set OS flags for platforms that have multiple browsers
5019 if (!result.windowsphone && (android || result.silk)) {
5020 result.android = t
5021 result.osname = 'Android'
5022 } else if (!result.windowsphone && iosdevice) {
5023 result[iosdevice] = t
5024 result.ios = t
5025 result.osname = 'iOS'
5026 } else if (mac) {
5027 result.mac = t
5028 result.osname = 'macOS'
5029 } else if (xbox) {
5030 result.xbox = t
5031 result.osname = 'Xbox'
5032 } else if (windows) {
5033 result.windows = t
5034 result.osname = 'Windows'
5035 } else if (linux) {
5036 result.linux = t
5037 result.osname = 'Linux'
5038 }
5039
5040 function getWindowsVersion (s) {
5041 switch (s) {
5042 case 'NT': return 'NT'
5043 case 'XP': return 'XP'
5044 case 'NT 5.0': return '2000'
5045 case 'NT 5.1': return 'XP'
5046 case 'NT 5.2': return '2003'
5047 case 'NT 6.0': return 'Vista'
5048 case 'NT 6.1': return '7'
5049 case 'NT 6.2': return '8'
5050 case 'NT 6.3': return '8.1'
5051 case 'NT 10.0': return '10'
5052 default: return undefined
5053 }
5054 }
5055
5056 // OS version extraction
5057 var osVersion = '';
5058 if (result.windows) {
5059 osVersion = getWindowsVersion(getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i))
5060 } else if (result.windowsphone) {
5061 osVersion = getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i);
5062 } else if (result.mac) {
5063 osVersion = getFirstMatch(/Mac OS X (\d+([_\.\s]\d+)*)/i);
5064 osVersion = osVersion.replace(/[_\s]/g, '.');
5065 } else if (iosdevice) {
5066 osVersion = getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i);
5067 osVersion = osVersion.replace(/[_\s]/g, '.');
5068 } else if (android) {
5069 osVersion = getFirstMatch(/android[ \/-](\d+(\.\d+)*)/i);
5070 } else if (result.webos) {
5071 osVersion = getFirstMatch(/(?:web|hpw)os\/(\d+(\.\d+)*)/i);
5072 } else if (result.blackberry) {
5073 osVersion = getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i);
5074 } else if (result.bada) {
5075 osVersion = getFirstMatch(/bada\/(\d+(\.\d+)*)/i);
5076 } else if (result.tizen) {
5077 osVersion = getFirstMatch(/tizen[\/\s](\d+(\.\d+)*)/i);
5078 }
5079 if (osVersion) {
5080 result.osversion = osVersion;
5081 }
5082
5083 // device type extraction
5084 var osMajorVersion = !result.windows && osVersion.split('.')[0];
5085 if (
5086 tablet
5087 || nexusTablet
5088 || iosdevice == 'ipad'
5089 || (android && (osMajorVersion == 3 || (osMajorVersion >= 4 && !mobile)))
5090 || result.silk
5091 ) {
5092 result.tablet = t
5093 } else if (
5094 mobile
5095 || iosdevice == 'iphone'
5096 || iosdevice == 'ipod'
5097 || android
5098 || nexusMobile
5099 || result.blackberry
5100 || result.webos
5101 || result.bada
5102 ) {
5103 result.mobile = t
5104 }
5105
5106 // Graded Browser Support
5107 // http://developer.yahoo.com/yui/articles/gbs
5108 if (result.msedge ||
5109 (result.msie && result.version >= 10) ||
5110 (result.yandexbrowser && result.version >= 15) ||
5111 (result.vivaldi && result.version >= 1.0) ||
5112 (result.chrome && result.version >= 20) ||
5113 (result.samsungBrowser && result.version >= 4) ||
5114 (result.whale && compareVersions([result.version, '1.0']) === 1) ||
5115 (result.mzbrowser && compareVersions([result.version, '6.0']) === 1) ||
5116 (result.focus && compareVersions([result.version, '1.0']) === 1) ||
5117 (result.firefox && result.version >= 20.0) ||
5118 (result.safari && result.version >= 6) ||
5119 (result.opera && result.version >= 10.0) ||
5120 (result.ios && result.osversion && result.osversion.split(".")[0] >= 6) ||
5121 (result.blackberry && result.version >= 10.1)
5122 || (result.chromium && result.version >= 20)
5123 ) {
5124 result.a = t;
5125 }
5126 else if ((result.msie && result.version < 10) ||
5127 (result.chrome && result.version < 20) ||
5128 (result.firefox && result.version < 20.0) ||
5129 (result.safari && result.version < 6) ||
5130 (result.opera && result.version < 10.0) ||
5131 (result.ios && result.osversion && result.osversion.split(".")[0] < 6)
5132 || (result.chromium && result.version < 20)
5133 ) {
5134 result.c = t
5135 } else result.x = t
5136
5137 return result
5138 }
5139
5140 var bowser = detect(typeof navigator !== 'undefined' ? navigator.userAgent || '' : '')
5141
5142 bowser.test = function (browserList) {
5143 for (var i = 0; i < browserList.length; ++i) {
5144 var browserItem = browserList[i];
5145 if (typeof browserItem=== 'string') {
5146 if (browserItem in bowser) {
5147 return true;
5148 }
5149 }
5150 }
5151 return false;
5152 }
5153
5154 /**
5155 * Get version precisions count
5156 *
5157 * @example
5158 * getVersionPrecision("1.10.3") // 3
5159 *
5160 * @param {string} version
5161 * @return {number}
5162 */
5163 function getVersionPrecision(version) {
5164 return version.split(".").length;
5165 }
5166
5167 /**
5168 * Array::map polyfill
5169 *
5170 * @param {Array} arr
5171 * @param {Function} iterator
5172 * @return {Array}
5173 */
5174 function map(arr, iterator) {
5175 var result = [], i;
5176 if (Array.prototype.map) {
5177 return Array.prototype.map.call(arr, iterator);
5178 }
5179 for (i = 0; i < arr.length; i++) {
5180 result.push(iterator(arr[i]));
5181 }
5182 return result;
5183 }
5184
5185 /**
5186 * Calculate browser version weight
5187 *
5188 * @example
5189 * compareVersions(['1.10.2.1', '1.8.2.1.90']) // 1
5190 * compareVersions(['1.010.2.1', '1.09.2.1.90']); // 1
5191 * compareVersions(['1.10.2.1', '1.10.2.1']); // 0
5192 * compareVersions(['1.10.2.1', '1.0800.2']); // -1
5193 *
5194 * @param {Array<String>} versions versions to compare
5195 * @return {Number} comparison result
5196 */
5197 function compareVersions(versions) {
5198 // 1) get common precision for both versions, for example for "10.0" and "9" it should be 2
5199 var precision = Math.max(getVersionPrecision(versions[0]), getVersionPrecision(versions[1]));
5200 var chunks = map(versions, function (version) {
5201 var delta = precision - getVersionPrecision(version);
5202
5203 // 2) "9" -> "9.0" (for precision = 2)
5204 version = version + new Array(delta + 1).join(".0");
5205
5206 // 3) "9.0" -> ["000000000"", "000000009"]
5207 return map(version.split("."), function (chunk) {
5208 return new Array(20 - chunk.length).join("0") + chunk;
5209 }).reverse();
5210 });
5211
5212 // iterate in reverse order by reversed chunks array
5213 while (--precision >= 0) {
5214 // 4) compare: "000000009" > "000000010" = false (but "9" > "10" = true)
5215 if (chunks[0][precision] > chunks[1][precision]) {
5216 return 1;
5217 }
5218 else if (chunks[0][precision] === chunks[1][precision]) {
5219 if (precision === 0) {
5220 // all version chunks are same
5221 return 0;
5222 }
5223 }
5224 else {
5225 return -1;
5226 }
5227 }
5228 }
5229
5230 /**
5231 * Check if browser is unsupported
5232 *
5233 * @example
5234 * bowser.isUnsupportedBrowser({
5235 * msie: "10",
5236 * firefox: "23",
5237 * chrome: "29",
5238 * safari: "5.1",
5239 * opera: "16",
5240 * phantom: "534"
5241 * });
5242 *
5243 * @param {Object} minVersions map of minimal version to browser
5244 * @param {Boolean} [strictMode = false] flag to return false if browser wasn't found in map
5245 * @param {String} [ua] user agent string
5246 * @return {Boolean}
5247 */
5248 function isUnsupportedBrowser(minVersions, strictMode, ua) {
5249 var _bowser = bowser;
5250
5251 // make strictMode param optional with ua param usage
5252 if (typeof strictMode === 'string') {
5253 ua = strictMode;
5254 strictMode = void(0);
5255 }
5256
5257 if (strictMode === void(0)) {
5258 strictMode = false;
5259 }
5260 if (ua) {
5261 _bowser = detect(ua);
5262 }
5263
5264 var version = "" + _bowser.version;
5265 for (var browser in minVersions) {
5266 if (minVersions.hasOwnProperty(browser)) {
5267 if (_bowser[browser]) {
5268 if (typeof minVersions[browser] !== 'string') {
5269 throw new Error('Browser version in the minVersion map should be a string: ' + browser + ': ' + String(minVersions));
5270 }
5271
5272 // browser version and min supported version.
5273 return compareVersions([version, minVersions[browser]]) < 0;
5274 }
5275 }
5276 }
5277
5278 return strictMode; // not found
5279 }
5280
5281 /**
5282 * Check if browser is supported
5283 *
5284 * @param {Object} minVersions map of minimal version to browser
5285 * @param {Boolean} [strictMode = false] flag to return false if browser wasn't found in map
5286 * @param {String} [ua] user agent string
5287 * @return {Boolean}
5288 */
5289 function check(minVersions, strictMode, ua) {
5290 return !isUnsupportedBrowser(minVersions, strictMode, ua);
5291 }
5292
5293 bowser.isUnsupportedBrowser = isUnsupportedBrowser;
5294 bowser.compareVersions = compareVersions;
5295 bowser.check = check;
5296
5297 /*
5298 * Set our detect method to the main bowser object so we can
5299 * reuse it to test other user agents.
5300 * This is needed to implement future tests.
5301 */
5302 bowser._detect = detect;
5303
5304 /*
5305 * Set our detect public method to the main bowser object
5306 * This is needed to implement bowser in server side
5307 */
5308 bowser.detect = detect;
5309 return bowser
5310});
5311
5312},{}],68:[function(require,module,exports){
5313
5314},{}],69:[function(require,module,exports){
5315// Copyright Joyent, Inc. and other Node contributors.
5316//
5317// Permission is hereby granted, free of charge, to any person obtaining a
5318// copy of this software and associated documentation files (the
5319// "Software"), to deal in the Software without restriction, including
5320// without limitation the rights to use, copy, modify, merge, publish,
5321// distribute, sublicense, and/or sell copies of the Software, and to permit
5322// persons to whom the Software is furnished to do so, subject to the
5323// following conditions:
5324//
5325// The above copyright notice and this permission notice shall be included
5326// in all copies or substantial portions of the Software.
5327//
5328// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
5329// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
5330// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
5331// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
5332// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
5333// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
5334// USE OR OTHER DEALINGS IN THE SOFTWARE.
5335
5336var Buffer = require('buffer').Buffer;
5337
5338var isBufferEncoding = Buffer.isEncoding
5339 || function(encoding) {
5340 switch (encoding && encoding.toLowerCase()) {
5341 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;
5342 default: return false;
5343 }
5344 }
5345
5346
5347function assertEncoding(encoding) {
5348 if (encoding && !isBufferEncoding(encoding)) {
5349 throw new Error('Unknown encoding: ' + encoding);
5350 }
5351}
5352
5353// StringDecoder provides an interface for efficiently splitting a series of
5354// buffers into a series of JS strings without breaking apart multi-byte
5355// characters. CESU-8 is handled as part of the UTF-8 encoding.
5356//
5357// @TODO Handling all encodings inside a single object makes it very difficult
5358// to reason about this code, so it should be split up in the future.
5359// @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code
5360// points as used by CESU-8.
5361var StringDecoder = exports.StringDecoder = function(encoding) {
5362 this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
5363 assertEncoding(encoding);
5364 switch (this.encoding) {
5365 case 'utf8':
5366 // CESU-8 represents each of Surrogate Pair by 3-bytes
5367 this.surrogateSize = 3;
5368 break;
5369 case 'ucs2':
5370 case 'utf16le':
5371 // UTF-16 represents each of Surrogate Pair by 2-bytes
5372 this.surrogateSize = 2;
5373 this.detectIncompleteChar = utf16DetectIncompleteChar;
5374 break;
5375 case 'base64':
5376 // Base-64 stores 3 bytes in 4 chars, and pads the remainder.
5377 this.surrogateSize = 3;
5378 this.detectIncompleteChar = base64DetectIncompleteChar;
5379 break;
5380 default:
5381 this.write = passThroughWrite;
5382 return;
5383 }
5384
5385 // Enough space to store all bytes of a single character. UTF-8 needs 4
5386 // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate).
5387 this.charBuffer = new Buffer(6);
5388 // Number of bytes received for the current incomplete multi-byte character.
5389 this.charReceived = 0;
5390 // Number of bytes expected for the current incomplete multi-byte character.
5391 this.charLength = 0;
5392};
5393
5394
5395// write decodes the given buffer and returns it as JS string that is
5396// guaranteed to not contain any partial multi-byte characters. Any partial
5397// character found at the end of the buffer is buffered up, and will be
5398// returned when calling write again with the remaining bytes.
5399//
5400// Note: Converting a Buffer containing an orphan surrogate to a String
5401// currently works, but converting a String to a Buffer (via `new Buffer`, or
5402// Buffer#write) will replace incomplete surrogates with the unicode
5403// replacement character. See https://codereview.chromium.org/121173009/ .
5404StringDecoder.prototype.write = function(buffer) {
5405 var charStr = '';
5406 // if our last write ended with an incomplete multibyte character
5407 while (this.charLength) {
5408 // determine how many remaining bytes this buffer has to offer for this char
5409 var available = (buffer.length >= this.charLength - this.charReceived) ?
5410 this.charLength - this.charReceived :
5411 buffer.length;
5412
5413 // add the new bytes to the char buffer
5414 buffer.copy(this.charBuffer, this.charReceived, 0, available);
5415 this.charReceived += available;
5416
5417 if (this.charReceived < this.charLength) {
5418 // still not enough chars in this buffer? wait for more ...
5419 return '';
5420 }
5421
5422 // remove bytes belonging to the current character from the buffer
5423 buffer = buffer.slice(available, buffer.length);
5424
5425 // get the character that was split
5426 charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
5427
5428 // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
5429 var charCode = charStr.charCodeAt(charStr.length - 1);
5430 if (charCode >= 0xD800 && charCode <= 0xDBFF) {
5431 this.charLength += this.surrogateSize;
5432 charStr = '';
5433 continue;
5434 }
5435 this.charReceived = this.charLength = 0;
5436
5437 // if there are no more bytes in this buffer, just emit our char
5438 if (buffer.length === 0) {
5439 return charStr;
5440 }
5441 break;
5442 }
5443
5444 // determine and set charLength / charReceived
5445 this.detectIncompleteChar(buffer);
5446
5447 var end = buffer.length;
5448 if (this.charLength) {
5449 // buffer the incomplete character bytes we got
5450 buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
5451 end -= this.charReceived;
5452 }
5453
5454 charStr += buffer.toString(this.encoding, 0, end);
5455
5456 var end = charStr.length - 1;
5457 var charCode = charStr.charCodeAt(end);
5458 // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
5459 if (charCode >= 0xD800 && charCode <= 0xDBFF) {
5460 var size = this.surrogateSize;
5461 this.charLength += size;
5462 this.charReceived += size;
5463 this.charBuffer.copy(this.charBuffer, size, 0, size);
5464 buffer.copy(this.charBuffer, 0, 0, size);
5465 return charStr.substring(0, end);
5466 }
5467
5468 // or just emit the charStr
5469 return charStr;
5470};
5471
5472// detectIncompleteChar determines if there is an incomplete UTF-8 character at
5473// the end of the given buffer. If so, it sets this.charLength to the byte
5474// length that character, and sets this.charReceived to the number of bytes
5475// that are available for this character.
5476StringDecoder.prototype.detectIncompleteChar = function(buffer) {
5477 // determine how many bytes we have to check at the end of this buffer
5478 var i = (buffer.length >= 3) ? 3 : buffer.length;
5479
5480 // Figure out if one of the last i bytes of our buffer announces an
5481 // incomplete char.
5482 for (; i > 0; i--) {
5483 var c = buffer[buffer.length - i];
5484
5485 // See http://en.wikipedia.org/wiki/UTF-8#Description
5486
5487 // 110XXXXX
5488 if (i == 1 && c >> 5 == 0x06) {
5489 this.charLength = 2;
5490 break;
5491 }
5492
5493 // 1110XXXX
5494 if (i <= 2 && c >> 4 == 0x0E) {
5495 this.charLength = 3;
5496 break;
5497 }
5498
5499 // 11110XXX
5500 if (i <= 3 && c >> 3 == 0x1E) {
5501 this.charLength = 4;
5502 break;
5503 }
5504 }
5505 this.charReceived = i;
5506};
5507
5508StringDecoder.prototype.end = function(buffer) {
5509 var res = '';
5510 if (buffer && buffer.length)
5511 res = this.write(buffer);
5512
5513 if (this.charReceived) {
5514 var cr = this.charReceived;
5515 var buf = this.charBuffer;
5516 var enc = this.encoding;
5517 res += buf.slice(0, cr).toString(enc);
5518 }
5519
5520 return res;
5521};
5522
5523function passThroughWrite(buffer) {
5524 return buffer.toString(this.encoding);
5525}
5526
5527function utf16DetectIncompleteChar(buffer) {
5528 this.charReceived = buffer.length % 2;
5529 this.charLength = this.charReceived ? 2 : 0;
5530}
5531
5532function base64DetectIncompleteChar(buffer) {
5533 this.charReceived = buffer.length % 3;
5534 this.charLength = this.charReceived ? 3 : 0;
5535}
5536
5537},{"buffer":70}],70:[function(require,module,exports){
5538(function (global){
5539/*!
5540 * The buffer module from node.js, for the browser.
5541 *
5542 * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
5543 * @license MIT
5544 */
5545/* eslint-disable no-proto */
5546
5547'use strict'
5548
5549var base64 = require('base64-js')
5550var ieee754 = require('ieee754')
5551var isArray = require('isarray')
5552
5553exports.Buffer = Buffer
5554exports.SlowBuffer = SlowBuffer
5555exports.INSPECT_MAX_BYTES = 50
5556
5557/**
5558 * If `Buffer.TYPED_ARRAY_SUPPORT`:
5559 * === true Use Uint8Array implementation (fastest)
5560 * === false Use Object implementation (most compatible, even IE6)
5561 *
5562 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
5563 * Opera 11.6+, iOS 4.2+.
5564 *
5565 * Due to various browser bugs, sometimes the Object implementation will be used even
5566 * when the browser supports typed arrays.
5567 *
5568 * Note:
5569 *
5570 * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
5571 * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
5572 *
5573 * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
5574 *
5575 * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
5576 * incorrect length in some situations.
5577
5578 * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
5579 * get the Object implementation, which is slower but behaves correctly.
5580 */
5581Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
5582 ? global.TYPED_ARRAY_SUPPORT
5583 : typedArraySupport()
5584
5585/*
5586 * Export kMaxLength after typed array support is determined.
5587 */
5588exports.kMaxLength = kMaxLength()
5589
5590function typedArraySupport () {
5591 try {
5592 var arr = new Uint8Array(1)
5593 arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
5594 return arr.foo() === 42 && // typed array instances can be augmented
5595 typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
5596 arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
5597 } catch (e) {
5598 return false
5599 }
5600}
5601
5602function kMaxLength () {
5603 return Buffer.TYPED_ARRAY_SUPPORT
5604 ? 0x7fffffff
5605 : 0x3fffffff
5606}
5607
5608function createBuffer (that, length) {
5609 if (kMaxLength() < length) {
5610 throw new RangeError('Invalid typed array length')
5611 }
5612 if (Buffer.TYPED_ARRAY_SUPPORT) {
5613 // Return an augmented `Uint8Array` instance, for best performance
5614 that = new Uint8Array(length)
5615 that.__proto__ = Buffer.prototype
5616 } else {
5617 // Fallback: Return an object instance of the Buffer class
5618 if (that === null) {
5619 that = new Buffer(length)
5620 }
5621 that.length = length
5622 }
5623
5624 return that
5625}
5626
5627/**
5628 * The Buffer constructor returns instances of `Uint8Array` that have their
5629 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
5630 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
5631 * and the `Uint8Array` methods. Square bracket notation works as expected -- it
5632 * returns a single octet.
5633 *
5634 * The `Uint8Array` prototype remains unmodified.
5635 */
5636
5637function Buffer (arg, encodingOrOffset, length) {
5638 if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
5639 return new Buffer(arg, encodingOrOffset, length)
5640 }
5641
5642 // Common case.
5643 if (typeof arg === 'number') {
5644 if (typeof encodingOrOffset === 'string') {
5645 throw new Error(
5646 'If encoding is specified then the first argument must be a string'
5647 )
5648 }
5649 return allocUnsafe(this, arg)
5650 }
5651 return from(this, arg, encodingOrOffset, length)
5652}
5653
5654Buffer.poolSize = 8192 // not used by this implementation
5655
5656// TODO: Legacy, not needed anymore. Remove in next major version.
5657Buffer._augment = function (arr) {
5658 arr.__proto__ = Buffer.prototype
5659 return arr
5660}
5661
5662function from (that, value, encodingOrOffset, length) {
5663 if (typeof value === 'number') {
5664 throw new TypeError('"value" argument must not be a number')
5665 }
5666
5667 if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
5668 return fromArrayBuffer(that, value, encodingOrOffset, length)
5669 }
5670
5671 if (typeof value === 'string') {
5672 return fromString(that, value, encodingOrOffset)
5673 }
5674
5675 return fromObject(that, value)
5676}
5677
5678/**
5679 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
5680 * if value is a number.
5681 * Buffer.from(str[, encoding])
5682 * Buffer.from(array)
5683 * Buffer.from(buffer)
5684 * Buffer.from(arrayBuffer[, byteOffset[, length]])
5685 **/
5686Buffer.from = function (value, encodingOrOffset, length) {
5687 return from(null, value, encodingOrOffset, length)
5688}
5689
5690if (Buffer.TYPED_ARRAY_SUPPORT) {
5691 Buffer.prototype.__proto__ = Uint8Array.prototype
5692 Buffer.__proto__ = Uint8Array
5693 if (typeof Symbol !== 'undefined' && Symbol.species &&
5694 Buffer[Symbol.species] === Buffer) {
5695 // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
5696 Object.defineProperty(Buffer, Symbol.species, {
5697 value: null,
5698 configurable: true
5699 })
5700 }
5701}
5702
5703function assertSize (size) {
5704 if (typeof size !== 'number') {
5705 throw new TypeError('"size" argument must be a number')
5706 } else if (size < 0) {
5707 throw new RangeError('"size" argument must not be negative')
5708 }
5709}
5710
5711function alloc (that, size, fill, encoding) {
5712 assertSize(size)
5713 if (size <= 0) {
5714 return createBuffer(that, size)
5715 }
5716 if (fill !== undefined) {
5717 // Only pay attention to encoding if it's a string. This
5718 // prevents accidentally sending in a number that would
5719 // be interpretted as a start offset.
5720 return typeof encoding === 'string'
5721 ? createBuffer(that, size).fill(fill, encoding)
5722 : createBuffer(that, size).fill(fill)
5723 }
5724 return createBuffer(that, size)
5725}
5726
5727/**
5728 * Creates a new filled Buffer instance.
5729 * alloc(size[, fill[, encoding]])
5730 **/
5731Buffer.alloc = function (size, fill, encoding) {
5732 return alloc(null, size, fill, encoding)
5733}
5734
5735function allocUnsafe (that, size) {
5736 assertSize(size)
5737 that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
5738 if (!Buffer.TYPED_ARRAY_SUPPORT) {
5739 for (var i = 0; i < size; ++i) {
5740 that[i] = 0
5741 }
5742 }
5743 return that
5744}
5745
5746/**
5747 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
5748 * */
5749Buffer.allocUnsafe = function (size) {
5750 return allocUnsafe(null, size)
5751}
5752/**
5753 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
5754 */
5755Buffer.allocUnsafeSlow = function (size) {
5756 return allocUnsafe(null, size)
5757}
5758
5759function fromString (that, string, encoding) {
5760 if (typeof encoding !== 'string' || encoding === '') {
5761 encoding = 'utf8'
5762 }
5763
5764 if (!Buffer.isEncoding(encoding)) {
5765 throw new TypeError('"encoding" must be a valid string encoding')
5766 }
5767
5768 var length = byteLength(string, encoding) | 0
5769 that = createBuffer(that, length)
5770
5771 var actual = that.write(string, encoding)
5772
5773 if (actual !== length) {
5774 // Writing a hex string, for example, that contains invalid characters will
5775 // cause everything after the first invalid character to be ignored. (e.g.
5776 // 'abxxcd' will be treated as 'ab')
5777 that = that.slice(0, actual)
5778 }
5779
5780 return that
5781}
5782
5783function fromArrayLike (that, array) {
5784 var length = array.length < 0 ? 0 : checked(array.length) | 0
5785 that = createBuffer(that, length)
5786 for (var i = 0; i < length; i += 1) {
5787 that[i] = array[i] & 255
5788 }
5789 return that
5790}
5791
5792function fromArrayBuffer (that, array, byteOffset, length) {
5793 array.byteLength // this throws if `array` is not a valid ArrayBuffer
5794
5795 if (byteOffset < 0 || array.byteLength < byteOffset) {
5796 throw new RangeError('\'offset\' is out of bounds')
5797 }
5798
5799 if (array.byteLength < byteOffset + (length || 0)) {
5800 throw new RangeError('\'length\' is out of bounds')
5801 }
5802
5803 if (byteOffset === undefined && length === undefined) {
5804 array = new Uint8Array(array)
5805 } else if (length === undefined) {
5806 array = new Uint8Array(array, byteOffset)
5807 } else {
5808 array = new Uint8Array(array, byteOffset, length)
5809 }
5810
5811 if (Buffer.TYPED_ARRAY_SUPPORT) {
5812 // Return an augmented `Uint8Array` instance, for best performance
5813 that = array
5814 that.__proto__ = Buffer.prototype
5815 } else {
5816 // Fallback: Return an object instance of the Buffer class
5817 that = fromArrayLike(that, array)
5818 }
5819 return that
5820}
5821
5822function fromObject (that, obj) {
5823 if (Buffer.isBuffer(obj)) {
5824 var len = checked(obj.length) | 0
5825 that = createBuffer(that, len)
5826
5827 if (that.length === 0) {
5828 return that
5829 }
5830
5831 obj.copy(that, 0, 0, len)
5832 return that
5833 }
5834
5835 if (obj) {
5836 if ((typeof ArrayBuffer !== 'undefined' &&
5837 obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
5838 if (typeof obj.length !== 'number' || isnan(obj.length)) {
5839 return createBuffer(that, 0)
5840 }
5841 return fromArrayLike(that, obj)
5842 }
5843
5844 if (obj.type === 'Buffer' && isArray(obj.data)) {
5845 return fromArrayLike(that, obj.data)
5846 }
5847 }
5848
5849 throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
5850}
5851
5852function checked (length) {
5853 // Note: cannot use `length < kMaxLength()` here because that fails when
5854 // length is NaN (which is otherwise coerced to zero.)
5855 if (length >= kMaxLength()) {
5856 throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
5857 'size: 0x' + kMaxLength().toString(16) + ' bytes')
5858 }
5859 return length | 0
5860}
5861
5862function SlowBuffer (length) {
5863 if (+length != length) { // eslint-disable-line eqeqeq
5864 length = 0
5865 }
5866 return Buffer.alloc(+length)
5867}
5868
5869Buffer.isBuffer = function isBuffer (b) {
5870 return !!(b != null && b._isBuffer)
5871}
5872
5873Buffer.compare = function compare (a, b) {
5874 if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
5875 throw new TypeError('Arguments must be Buffers')
5876 }
5877
5878 if (a === b) return 0
5879
5880 var x = a.length
5881 var y = b.length
5882
5883 for (var i = 0, len = Math.min(x, y); i < len; ++i) {
5884 if (a[i] !== b[i]) {
5885 x = a[i]
5886 y = b[i]
5887 break
5888 }
5889 }
5890
5891 if (x < y) return -1
5892 if (y < x) return 1
5893 return 0
5894}
5895
5896Buffer.isEncoding = function isEncoding (encoding) {
5897 switch (String(encoding).toLowerCase()) {
5898 case 'hex':
5899 case 'utf8':
5900 case 'utf-8':
5901 case 'ascii':
5902 case 'latin1':
5903 case 'binary':
5904 case 'base64':
5905 case 'ucs2':
5906 case 'ucs-2':
5907 case 'utf16le':
5908 case 'utf-16le':
5909 return true
5910 default:
5911 return false
5912 }
5913}
5914
5915Buffer.concat = function concat (list, length) {
5916 if (!isArray(list)) {
5917 throw new TypeError('"list" argument must be an Array of Buffers')
5918 }
5919
5920 if (list.length === 0) {
5921 return Buffer.alloc(0)
5922 }
5923
5924 var i
5925 if (length === undefined) {
5926 length = 0
5927 for (i = 0; i < list.length; ++i) {
5928 length += list[i].length
5929 }
5930 }
5931
5932 var buffer = Buffer.allocUnsafe(length)
5933 var pos = 0
5934 for (i = 0; i < list.length; ++i) {
5935 var buf = list[i]
5936 if (!Buffer.isBuffer(buf)) {
5937 throw new TypeError('"list" argument must be an Array of Buffers')
5938 }
5939 buf.copy(buffer, pos)
5940 pos += buf.length
5941 }
5942 return buffer
5943}
5944
5945function byteLength (string, encoding) {
5946 if (Buffer.isBuffer(string)) {
5947 return string.length
5948 }
5949 if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
5950 (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
5951 return string.byteLength
5952 }
5953 if (typeof string !== 'string') {
5954 string = '' + string
5955 }
5956
5957 var len = string.length
5958 if (len === 0) return 0
5959
5960 // Use a for loop to avoid recursion
5961 var loweredCase = false
5962 for (;;) {
5963 switch (encoding) {
5964 case 'ascii':
5965 case 'latin1':
5966 case 'binary':
5967 return len
5968 case 'utf8':
5969 case 'utf-8':
5970 case undefined:
5971 return utf8ToBytes(string).length
5972 case 'ucs2':
5973 case 'ucs-2':
5974 case 'utf16le':
5975 case 'utf-16le':
5976 return len * 2
5977 case 'hex':
5978 return len >>> 1
5979 case 'base64':
5980 return base64ToBytes(string).length
5981 default:
5982 if (loweredCase) return utf8ToBytes(string).length // assume utf8
5983 encoding = ('' + encoding).toLowerCase()
5984 loweredCase = true
5985 }
5986 }
5987}
5988Buffer.byteLength = byteLength
5989
5990function slowToString (encoding, start, end) {
5991 var loweredCase = false
5992
5993 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
5994 // property of a typed array.
5995
5996 // This behaves neither like String nor Uint8Array in that we set start/end
5997 // to their upper/lower bounds if the value passed is out of range.
5998 // undefined is handled specially as per ECMA-262 6th Edition,
5999 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
6000 if (start === undefined || start < 0) {
6001 start = 0
6002 }
6003 // Return early if start > this.length. Done here to prevent potential uint32
6004 // coercion fail below.
6005 if (start > this.length) {
6006 return ''
6007 }
6008
6009 if (end === undefined || end > this.length) {
6010 end = this.length
6011 }
6012
6013 if (end <= 0) {
6014 return ''
6015 }
6016
6017 // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
6018 end >>>= 0
6019 start >>>= 0
6020
6021 if (end <= start) {
6022 return ''
6023 }
6024
6025 if (!encoding) encoding = 'utf8'
6026
6027 while (true) {
6028 switch (encoding) {
6029 case 'hex':
6030 return hexSlice(this, start, end)
6031
6032 case 'utf8':
6033 case 'utf-8':
6034 return utf8Slice(this, start, end)
6035
6036 case 'ascii':
6037 return asciiSlice(this, start, end)
6038
6039 case 'latin1':
6040 case 'binary':
6041 return latin1Slice(this, start, end)
6042
6043 case 'base64':
6044 return base64Slice(this, start, end)
6045
6046 case 'ucs2':
6047 case 'ucs-2':
6048 case 'utf16le':
6049 case 'utf-16le':
6050 return utf16leSlice(this, start, end)
6051
6052 default:
6053 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
6054 encoding = (encoding + '').toLowerCase()
6055 loweredCase = true
6056 }
6057 }
6058}
6059
6060// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
6061// Buffer instances.
6062Buffer.prototype._isBuffer = true
6063
6064function swap (b, n, m) {
6065 var i = b[n]
6066 b[n] = b[m]
6067 b[m] = i
6068}
6069
6070Buffer.prototype.swap16 = function swap16 () {
6071 var len = this.length
6072 if (len % 2 !== 0) {
6073 throw new RangeError('Buffer size must be a multiple of 16-bits')
6074 }
6075 for (var i = 0; i < len; i += 2) {
6076 swap(this, i, i + 1)
6077 }
6078 return this
6079}
6080
6081Buffer.prototype.swap32 = function swap32 () {
6082 var len = this.length
6083 if (len % 4 !== 0) {
6084 throw new RangeError('Buffer size must be a multiple of 32-bits')
6085 }
6086 for (var i = 0; i < len; i += 4) {
6087 swap(this, i, i + 3)
6088 swap(this, i + 1, i + 2)
6089 }
6090 return this
6091}
6092
6093Buffer.prototype.swap64 = function swap64 () {
6094 var len = this.length
6095 if (len % 8 !== 0) {
6096 throw new RangeError('Buffer size must be a multiple of 64-bits')
6097 }
6098 for (var i = 0; i < len; i += 8) {
6099 swap(this, i, i + 7)
6100 swap(this, i + 1, i + 6)
6101 swap(this, i + 2, i + 5)
6102 swap(this, i + 3, i + 4)
6103 }
6104 return this
6105}
6106
6107Buffer.prototype.toString = function toString () {
6108 var length = this.length | 0
6109 if (length === 0) return ''
6110 if (arguments.length === 0) return utf8Slice(this, 0, length)
6111 return slowToString.apply(this, arguments)
6112}
6113
6114Buffer.prototype.equals = function equals (b) {
6115 if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
6116 if (this === b) return true
6117 return Buffer.compare(this, b) === 0
6118}
6119
6120Buffer.prototype.inspect = function inspect () {
6121 var str = ''
6122 var max = exports.INSPECT_MAX_BYTES
6123 if (this.length > 0) {
6124 str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
6125 if (this.length > max) str += ' ... '
6126 }
6127 return '<Buffer ' + str + '>'
6128}
6129
6130Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
6131 if (!Buffer.isBuffer(target)) {
6132 throw new TypeError('Argument must be a Buffer')
6133 }
6134
6135 if (start === undefined) {
6136 start = 0
6137 }
6138 if (end === undefined) {
6139 end = target ? target.length : 0
6140 }
6141 if (thisStart === undefined) {
6142 thisStart = 0
6143 }
6144 if (thisEnd === undefined) {
6145 thisEnd = this.length
6146 }
6147
6148 if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
6149 throw new RangeError('out of range index')
6150 }
6151
6152 if (thisStart >= thisEnd && start >= end) {
6153 return 0
6154 }
6155 if (thisStart >= thisEnd) {
6156 return -1
6157 }
6158 if (start >= end) {
6159 return 1
6160 }
6161
6162 start >>>= 0
6163 end >>>= 0
6164 thisStart >>>= 0
6165 thisEnd >>>= 0
6166
6167 if (this === target) return 0
6168
6169 var x = thisEnd - thisStart
6170 var y = end - start
6171 var len = Math.min(x, y)
6172
6173 var thisCopy = this.slice(thisStart, thisEnd)
6174 var targetCopy = target.slice(start, end)
6175
6176 for (var i = 0; i < len; ++i) {
6177 if (thisCopy[i] !== targetCopy[i]) {
6178 x = thisCopy[i]
6179 y = targetCopy[i]
6180 break
6181 }
6182 }
6183
6184 if (x < y) return -1
6185 if (y < x) return 1
6186 return 0
6187}
6188
6189// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
6190// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
6191//
6192// Arguments:
6193// - buffer - a Buffer to search
6194// - val - a string, Buffer, or number
6195// - byteOffset - an index into `buffer`; will be clamped to an int32
6196// - encoding - an optional encoding, relevant is val is a string
6197// - dir - true for indexOf, false for lastIndexOf
6198function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
6199 // Empty buffer means no match
6200 if (buffer.length === 0) return -1
6201
6202 // Normalize byteOffset
6203 if (typeof byteOffset === 'string') {
6204 encoding = byteOffset
6205 byteOffset = 0
6206 } else if (byteOffset > 0x7fffffff) {
6207 byteOffset = 0x7fffffff
6208 } else if (byteOffset < -0x80000000) {
6209 byteOffset = -0x80000000
6210 }
6211 byteOffset = +byteOffset // Coerce to Number.
6212 if (isNaN(byteOffset)) {
6213 // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
6214 byteOffset = dir ? 0 : (buffer.length - 1)
6215 }
6216
6217 // Normalize byteOffset: negative offsets start from the end of the buffer
6218 if (byteOffset < 0) byteOffset = buffer.length + byteOffset
6219 if (byteOffset >= buffer.length) {
6220 if (dir) return -1
6221 else byteOffset = buffer.length - 1
6222 } else if (byteOffset < 0) {
6223 if (dir) byteOffset = 0
6224 else return -1
6225 }
6226
6227 // Normalize val
6228 if (typeof val === 'string') {
6229 val = Buffer.from(val, encoding)
6230 }
6231
6232 // Finally, search either indexOf (if dir is true) or lastIndexOf
6233 if (Buffer.isBuffer(val)) {
6234 // Special case: looking for empty string/buffer always fails
6235 if (val.length === 0) {
6236 return -1
6237 }
6238 return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
6239 } else if (typeof val === 'number') {
6240 val = val & 0xFF // Search for a byte value [0-255]
6241 if (Buffer.TYPED_ARRAY_SUPPORT &&
6242 typeof Uint8Array.prototype.indexOf === 'function') {
6243 if (dir) {
6244 return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
6245 } else {
6246 return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
6247 }
6248 }
6249 return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
6250 }
6251
6252 throw new TypeError('val must be string, number or Buffer')
6253}
6254
6255function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
6256 var indexSize = 1
6257 var arrLength = arr.length
6258 var valLength = val.length
6259
6260 if (encoding !== undefined) {
6261 encoding = String(encoding).toLowerCase()
6262 if (encoding === 'ucs2' || encoding === 'ucs-2' ||
6263 encoding === 'utf16le' || encoding === 'utf-16le') {
6264 if (arr.length < 2 || val.length < 2) {
6265 return -1
6266 }
6267 indexSize = 2
6268 arrLength /= 2
6269 valLength /= 2
6270 byteOffset /= 2
6271 }
6272 }
6273
6274 function read (buf, i) {
6275 if (indexSize === 1) {
6276 return buf[i]
6277 } else {
6278 return buf.readUInt16BE(i * indexSize)
6279 }
6280 }
6281
6282 var i
6283 if (dir) {
6284 var foundIndex = -1
6285 for (i = byteOffset; i < arrLength; i++) {
6286 if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
6287 if (foundIndex === -1) foundIndex = i
6288 if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
6289 } else {
6290 if (foundIndex !== -1) i -= i - foundIndex
6291 foundIndex = -1
6292 }
6293 }
6294 } else {
6295 if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
6296 for (i = byteOffset; i >= 0; i--) {
6297 var found = true
6298 for (var j = 0; j < valLength; j++) {
6299 if (read(arr, i + j) !== read(val, j)) {
6300 found = false
6301 break
6302 }
6303 }
6304 if (found) return i
6305 }
6306 }
6307
6308 return -1
6309}
6310
6311Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
6312 return this.indexOf(val, byteOffset, encoding) !== -1
6313}
6314
6315Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
6316 return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
6317}
6318
6319Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
6320 return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
6321}
6322
6323function hexWrite (buf, string, offset, length) {
6324 offset = Number(offset) || 0
6325 var remaining = buf.length - offset
6326 if (!length) {
6327 length = remaining
6328 } else {
6329 length = Number(length)
6330 if (length > remaining) {
6331 length = remaining
6332 }
6333 }
6334
6335 // must be an even number of digits
6336 var strLen = string.length
6337 if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
6338
6339 if (length > strLen / 2) {
6340 length = strLen / 2
6341 }
6342 for (var i = 0; i < length; ++i) {
6343 var parsed = parseInt(string.substr(i * 2, 2), 16)
6344 if (isNaN(parsed)) return i
6345 buf[offset + i] = parsed
6346 }
6347 return i
6348}
6349
6350function utf8Write (buf, string, offset, length) {
6351 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
6352}
6353
6354function asciiWrite (buf, string, offset, length) {
6355 return blitBuffer(asciiToBytes(string), buf, offset, length)
6356}
6357
6358function latin1Write (buf, string, offset, length) {
6359 return asciiWrite(buf, string, offset, length)
6360}
6361
6362function base64Write (buf, string, offset, length) {
6363 return blitBuffer(base64ToBytes(string), buf, offset, length)
6364}
6365
6366function ucs2Write (buf, string, offset, length) {
6367 return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
6368}
6369
6370Buffer.prototype.write = function write (string, offset, length, encoding) {
6371 // Buffer#write(string)
6372 if (offset === undefined) {
6373 encoding = 'utf8'
6374 length = this.length
6375 offset = 0
6376 // Buffer#write(string, encoding)
6377 } else if (length === undefined && typeof offset === 'string') {
6378 encoding = offset
6379 length = this.length
6380 offset = 0
6381 // Buffer#write(string, offset[, length][, encoding])
6382 } else if (isFinite(offset)) {
6383 offset = offset | 0
6384 if (isFinite(length)) {
6385 length = length | 0
6386 if (encoding === undefined) encoding = 'utf8'
6387 } else {
6388 encoding = length
6389 length = undefined
6390 }
6391 // legacy write(string, encoding, offset, length) - remove in v0.13
6392 } else {
6393 throw new Error(
6394 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
6395 )
6396 }
6397
6398 var remaining = this.length - offset
6399 if (length === undefined || length > remaining) length = remaining
6400
6401 if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
6402 throw new RangeError('Attempt to write outside buffer bounds')
6403 }
6404
6405 if (!encoding) encoding = 'utf8'
6406
6407 var loweredCase = false
6408 for (;;) {
6409 switch (encoding) {
6410 case 'hex':
6411 return hexWrite(this, string, offset, length)
6412
6413 case 'utf8':
6414 case 'utf-8':
6415 return utf8Write(this, string, offset, length)
6416
6417 case 'ascii':
6418 return asciiWrite(this, string, offset, length)
6419
6420 case 'latin1':
6421 case 'binary':
6422 return latin1Write(this, string, offset, length)
6423
6424 case 'base64':
6425 // Warning: maxLength not taken into account in base64Write
6426 return base64Write(this, string, offset, length)
6427
6428 case 'ucs2':
6429 case 'ucs-2':
6430 case 'utf16le':
6431 case 'utf-16le':
6432 return ucs2Write(this, string, offset, length)
6433
6434 default:
6435 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
6436 encoding = ('' + encoding).toLowerCase()
6437 loweredCase = true
6438 }
6439 }
6440}
6441
6442Buffer.prototype.toJSON = function toJSON () {
6443 return {
6444 type: 'Buffer',
6445 data: Array.prototype.slice.call(this._arr || this, 0)
6446 }
6447}
6448
6449function base64Slice (buf, start, end) {
6450 if (start === 0 && end === buf.length) {
6451 return base64.fromByteArray(buf)
6452 } else {
6453 return base64.fromByteArray(buf.slice(start, end))
6454 }
6455}
6456
6457function utf8Slice (buf, start, end) {
6458 end = Math.min(buf.length, end)
6459 var res = []
6460
6461 var i = start
6462 while (i < end) {
6463 var firstByte = buf[i]
6464 var codePoint = null
6465 var bytesPerSequence = (firstByte > 0xEF) ? 4
6466 : (firstByte > 0xDF) ? 3
6467 : (firstByte > 0xBF) ? 2
6468 : 1
6469
6470 if (i + bytesPerSequence <= end) {
6471 var secondByte, thirdByte, fourthByte, tempCodePoint
6472
6473 switch (bytesPerSequence) {
6474 case 1:
6475 if (firstByte < 0x80) {
6476 codePoint = firstByte
6477 }
6478 break
6479 case 2:
6480 secondByte = buf[i + 1]
6481 if ((secondByte & 0xC0) === 0x80) {
6482 tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
6483 if (tempCodePoint > 0x7F) {
6484 codePoint = tempCodePoint
6485 }
6486 }
6487 break
6488 case 3:
6489 secondByte = buf[i + 1]
6490 thirdByte = buf[i + 2]
6491 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
6492 tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
6493 if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
6494 codePoint = tempCodePoint
6495 }
6496 }
6497 break
6498 case 4:
6499 secondByte = buf[i + 1]
6500 thirdByte = buf[i + 2]
6501 fourthByte = buf[i + 3]
6502 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
6503 tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
6504 if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
6505 codePoint = tempCodePoint
6506 }
6507 }
6508 }
6509 }
6510
6511 if (codePoint === null) {
6512 // we did not generate a valid codePoint so insert a
6513 // replacement char (U+FFFD) and advance only 1 byte
6514 codePoint = 0xFFFD
6515 bytesPerSequence = 1
6516 } else if (codePoint > 0xFFFF) {
6517 // encode to utf16 (surrogate pair dance)
6518 codePoint -= 0x10000
6519 res.push(codePoint >>> 10 & 0x3FF | 0xD800)
6520 codePoint = 0xDC00 | codePoint & 0x3FF
6521 }
6522
6523 res.push(codePoint)
6524 i += bytesPerSequence
6525 }
6526
6527 return decodeCodePointsArray(res)
6528}
6529
6530// Based on http://stackoverflow.com/a/22747272/680742, the browser with
6531// the lowest limit is Chrome, with 0x10000 args.
6532// We go 1 magnitude less, for safety
6533var MAX_ARGUMENTS_LENGTH = 0x1000
6534
6535function decodeCodePointsArray (codePoints) {
6536 var len = codePoints.length
6537 if (len <= MAX_ARGUMENTS_LENGTH) {
6538 return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
6539 }
6540
6541 // Decode in chunks to avoid "call stack size exceeded".
6542 var res = ''
6543 var i = 0
6544 while (i < len) {
6545 res += String.fromCharCode.apply(
6546 String,
6547 codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
6548 )
6549 }
6550 return res
6551}
6552
6553function asciiSlice (buf, start, end) {
6554 var ret = ''
6555 end = Math.min(buf.length, end)
6556
6557 for (var i = start; i < end; ++i) {
6558 ret += String.fromCharCode(buf[i] & 0x7F)
6559 }
6560 return ret
6561}
6562
6563function latin1Slice (buf, start, end) {
6564 var ret = ''
6565 end = Math.min(buf.length, end)
6566
6567 for (var i = start; i < end; ++i) {
6568 ret += String.fromCharCode(buf[i])
6569 }
6570 return ret
6571}
6572
6573function hexSlice (buf, start, end) {
6574 var len = buf.length
6575
6576 if (!start || start < 0) start = 0
6577 if (!end || end < 0 || end > len) end = len
6578
6579 var out = ''
6580 for (var i = start; i < end; ++i) {
6581 out += toHex(buf[i])
6582 }
6583 return out
6584}
6585
6586function utf16leSlice (buf, start, end) {
6587 var bytes = buf.slice(start, end)
6588 var res = ''
6589 for (var i = 0; i < bytes.length; i += 2) {
6590 res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
6591 }
6592 return res
6593}
6594
6595Buffer.prototype.slice = function slice (start, end) {
6596 var len = this.length
6597 start = ~~start
6598 end = end === undefined ? len : ~~end
6599
6600 if (start < 0) {
6601 start += len
6602 if (start < 0) start = 0
6603 } else if (start > len) {
6604 start = len
6605 }
6606
6607 if (end < 0) {
6608 end += len
6609 if (end < 0) end = 0
6610 } else if (end > len) {
6611 end = len
6612 }
6613
6614 if (end < start) end = start
6615
6616 var newBuf
6617 if (Buffer.TYPED_ARRAY_SUPPORT) {
6618 newBuf = this.subarray(start, end)
6619 newBuf.__proto__ = Buffer.prototype
6620 } else {
6621 var sliceLen = end - start
6622 newBuf = new Buffer(sliceLen, undefined)
6623 for (var i = 0; i < sliceLen; ++i) {
6624 newBuf[i] = this[i + start]
6625 }
6626 }
6627
6628 return newBuf
6629}
6630
6631/*
6632 * Need to make sure that buffer isn't trying to write out of bounds.
6633 */
6634function checkOffset (offset, ext, length) {
6635 if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
6636 if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
6637}
6638
6639Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
6640 offset = offset | 0
6641 byteLength = byteLength | 0
6642 if (!noAssert) checkOffset(offset, byteLength, this.length)
6643
6644 var val = this[offset]
6645 var mul = 1
6646 var i = 0
6647 while (++i < byteLength && (mul *= 0x100)) {
6648 val += this[offset + i] * mul
6649 }
6650
6651 return val
6652}
6653
6654Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
6655 offset = offset | 0
6656 byteLength = byteLength | 0
6657 if (!noAssert) {
6658 checkOffset(offset, byteLength, this.length)
6659 }
6660
6661 var val = this[offset + --byteLength]
6662 var mul = 1
6663 while (byteLength > 0 && (mul *= 0x100)) {
6664 val += this[offset + --byteLength] * mul
6665 }
6666
6667 return val
6668}
6669
6670Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
6671 if (!noAssert) checkOffset(offset, 1, this.length)
6672 return this[offset]
6673}
6674
6675Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
6676 if (!noAssert) checkOffset(offset, 2, this.length)
6677 return this[offset] | (this[offset + 1] << 8)
6678}
6679
6680Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
6681 if (!noAssert) checkOffset(offset, 2, this.length)
6682 return (this[offset] << 8) | this[offset + 1]
6683}
6684
6685Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
6686 if (!noAssert) checkOffset(offset, 4, this.length)
6687
6688 return ((this[offset]) |
6689 (this[offset + 1] << 8) |
6690 (this[offset + 2] << 16)) +
6691 (this[offset + 3] * 0x1000000)
6692}
6693
6694Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
6695 if (!noAssert) checkOffset(offset, 4, this.length)
6696
6697 return (this[offset] * 0x1000000) +
6698 ((this[offset + 1] << 16) |
6699 (this[offset + 2] << 8) |
6700 this[offset + 3])
6701}
6702
6703Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
6704 offset = offset | 0
6705 byteLength = byteLength | 0
6706 if (!noAssert) checkOffset(offset, byteLength, this.length)
6707
6708 var val = this[offset]
6709 var mul = 1
6710 var i = 0
6711 while (++i < byteLength && (mul *= 0x100)) {
6712 val += this[offset + i] * mul
6713 }
6714 mul *= 0x80
6715
6716 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
6717
6718 return val
6719}
6720
6721Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
6722 offset = offset | 0
6723 byteLength = byteLength | 0
6724 if (!noAssert) checkOffset(offset, byteLength, this.length)
6725
6726 var i = byteLength
6727 var mul = 1
6728 var val = this[offset + --i]
6729 while (i > 0 && (mul *= 0x100)) {
6730 val += this[offset + --i] * mul
6731 }
6732 mul *= 0x80
6733
6734 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
6735
6736 return val
6737}
6738
6739Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
6740 if (!noAssert) checkOffset(offset, 1, this.length)
6741 if (!(this[offset] & 0x80)) return (this[offset])
6742 return ((0xff - this[offset] + 1) * -1)
6743}
6744
6745Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
6746 if (!noAssert) checkOffset(offset, 2, this.length)
6747 var val = this[offset] | (this[offset + 1] << 8)
6748 return (val & 0x8000) ? val | 0xFFFF0000 : val
6749}
6750
6751Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
6752 if (!noAssert) checkOffset(offset, 2, this.length)
6753 var val = this[offset + 1] | (this[offset] << 8)
6754 return (val & 0x8000) ? val | 0xFFFF0000 : val
6755}
6756
6757Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
6758 if (!noAssert) checkOffset(offset, 4, this.length)
6759
6760 return (this[offset]) |
6761 (this[offset + 1] << 8) |
6762 (this[offset + 2] << 16) |
6763 (this[offset + 3] << 24)
6764}
6765
6766Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
6767 if (!noAssert) checkOffset(offset, 4, this.length)
6768
6769 return (this[offset] << 24) |
6770 (this[offset + 1] << 16) |
6771 (this[offset + 2] << 8) |
6772 (this[offset + 3])
6773}
6774
6775Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
6776 if (!noAssert) checkOffset(offset, 4, this.length)
6777 return ieee754.read(this, offset, true, 23, 4)
6778}
6779
6780Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
6781 if (!noAssert) checkOffset(offset, 4, this.length)
6782 return ieee754.read(this, offset, false, 23, 4)
6783}
6784
6785Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
6786 if (!noAssert) checkOffset(offset, 8, this.length)
6787 return ieee754.read(this, offset, true, 52, 8)
6788}
6789
6790Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
6791 if (!noAssert) checkOffset(offset, 8, this.length)
6792 return ieee754.read(this, offset, false, 52, 8)
6793}
6794
6795function checkInt (buf, value, offset, ext, max, min) {
6796 if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
6797 if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
6798 if (offset + ext > buf.length) throw new RangeError('Index out of range')
6799}
6800
6801Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
6802 value = +value
6803 offset = offset | 0
6804 byteLength = byteLength | 0
6805 if (!noAssert) {
6806 var maxBytes = Math.pow(2, 8 * byteLength) - 1
6807 checkInt(this, value, offset, byteLength, maxBytes, 0)
6808 }
6809
6810 var mul = 1
6811 var i = 0
6812 this[offset] = value & 0xFF
6813 while (++i < byteLength && (mul *= 0x100)) {
6814 this[offset + i] = (value / mul) & 0xFF
6815 }
6816
6817 return offset + byteLength
6818}
6819
6820Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
6821 value = +value
6822 offset = offset | 0
6823 byteLength = byteLength | 0
6824 if (!noAssert) {
6825 var maxBytes = Math.pow(2, 8 * byteLength) - 1
6826 checkInt(this, value, offset, byteLength, maxBytes, 0)
6827 }
6828
6829 var i = byteLength - 1
6830 var mul = 1
6831 this[offset + i] = value & 0xFF
6832 while (--i >= 0 && (mul *= 0x100)) {
6833 this[offset + i] = (value / mul) & 0xFF
6834 }
6835
6836 return offset + byteLength
6837}
6838
6839Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
6840 value = +value
6841 offset = offset | 0
6842 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
6843 if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
6844 this[offset] = (value & 0xff)
6845 return offset + 1
6846}
6847
6848function objectWriteUInt16 (buf, value, offset, littleEndian) {
6849 if (value < 0) value = 0xffff + value + 1
6850 for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
6851 buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
6852 (littleEndian ? i : 1 - i) * 8
6853 }
6854}
6855
6856Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
6857 value = +value
6858 offset = offset | 0
6859 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
6860 if (Buffer.TYPED_ARRAY_SUPPORT) {
6861 this[offset] = (value & 0xff)
6862 this[offset + 1] = (value >>> 8)
6863 } else {
6864 objectWriteUInt16(this, value, offset, true)
6865 }
6866 return offset + 2
6867}
6868
6869Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
6870 value = +value
6871 offset = offset | 0
6872 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
6873 if (Buffer.TYPED_ARRAY_SUPPORT) {
6874 this[offset] = (value >>> 8)
6875 this[offset + 1] = (value & 0xff)
6876 } else {
6877 objectWriteUInt16(this, value, offset, false)
6878 }
6879 return offset + 2
6880}
6881
6882function objectWriteUInt32 (buf, value, offset, littleEndian) {
6883 if (value < 0) value = 0xffffffff + value + 1
6884 for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
6885 buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
6886 }
6887}
6888
6889Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
6890 value = +value
6891 offset = offset | 0
6892 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
6893 if (Buffer.TYPED_ARRAY_SUPPORT) {
6894 this[offset + 3] = (value >>> 24)
6895 this[offset + 2] = (value >>> 16)
6896 this[offset + 1] = (value >>> 8)
6897 this[offset] = (value & 0xff)
6898 } else {
6899 objectWriteUInt32(this, value, offset, true)
6900 }
6901 return offset + 4
6902}
6903
6904Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
6905 value = +value
6906 offset = offset | 0
6907 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
6908 if (Buffer.TYPED_ARRAY_SUPPORT) {
6909 this[offset] = (value >>> 24)
6910 this[offset + 1] = (value >>> 16)
6911 this[offset + 2] = (value >>> 8)
6912 this[offset + 3] = (value & 0xff)
6913 } else {
6914 objectWriteUInt32(this, value, offset, false)
6915 }
6916 return offset + 4
6917}
6918
6919Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
6920 value = +value
6921 offset = offset | 0
6922 if (!noAssert) {
6923 var limit = Math.pow(2, 8 * byteLength - 1)
6924
6925 checkInt(this, value, offset, byteLength, limit - 1, -limit)
6926 }
6927
6928 var i = 0
6929 var mul = 1
6930 var sub = 0
6931 this[offset] = value & 0xFF
6932 while (++i < byteLength && (mul *= 0x100)) {
6933 if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
6934 sub = 1
6935 }
6936 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
6937 }
6938
6939 return offset + byteLength
6940}
6941
6942Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
6943 value = +value
6944 offset = offset | 0
6945 if (!noAssert) {
6946 var limit = Math.pow(2, 8 * byteLength - 1)
6947
6948 checkInt(this, value, offset, byteLength, limit - 1, -limit)
6949 }
6950
6951 var i = byteLength - 1
6952 var mul = 1
6953 var sub = 0
6954 this[offset + i] = value & 0xFF
6955 while (--i >= 0 && (mul *= 0x100)) {
6956 if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
6957 sub = 1
6958 }
6959 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
6960 }
6961
6962 return offset + byteLength
6963}
6964
6965Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
6966 value = +value
6967 offset = offset | 0
6968 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
6969 if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
6970 if (value < 0) value = 0xff + value + 1
6971 this[offset] = (value & 0xff)
6972 return offset + 1
6973}
6974
6975Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
6976 value = +value
6977 offset = offset | 0
6978 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
6979 if (Buffer.TYPED_ARRAY_SUPPORT) {
6980 this[offset] = (value & 0xff)
6981 this[offset + 1] = (value >>> 8)
6982 } else {
6983 objectWriteUInt16(this, value, offset, true)
6984 }
6985 return offset + 2
6986}
6987
6988Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
6989 value = +value
6990 offset = offset | 0
6991 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
6992 if (Buffer.TYPED_ARRAY_SUPPORT) {
6993 this[offset] = (value >>> 8)
6994 this[offset + 1] = (value & 0xff)
6995 } else {
6996 objectWriteUInt16(this, value, offset, false)
6997 }
6998 return offset + 2
6999}
7000
7001Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
7002 value = +value
7003 offset = offset | 0
7004 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
7005 if (Buffer.TYPED_ARRAY_SUPPORT) {
7006 this[offset] = (value & 0xff)
7007 this[offset + 1] = (value >>> 8)
7008 this[offset + 2] = (value >>> 16)
7009 this[offset + 3] = (value >>> 24)
7010 } else {
7011 objectWriteUInt32(this, value, offset, true)
7012 }
7013 return offset + 4
7014}
7015
7016Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
7017 value = +value
7018 offset = offset | 0
7019 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
7020 if (value < 0) value = 0xffffffff + value + 1
7021 if (Buffer.TYPED_ARRAY_SUPPORT) {
7022 this[offset] = (value >>> 24)
7023 this[offset + 1] = (value >>> 16)
7024 this[offset + 2] = (value >>> 8)
7025 this[offset + 3] = (value & 0xff)
7026 } else {
7027 objectWriteUInt32(this, value, offset, false)
7028 }
7029 return offset + 4
7030}
7031
7032function checkIEEE754 (buf, value, offset, ext, max, min) {
7033 if (offset + ext > buf.length) throw new RangeError('Index out of range')
7034 if (offset < 0) throw new RangeError('Index out of range')
7035}
7036
7037function writeFloat (buf, value, offset, littleEndian, noAssert) {
7038 if (!noAssert) {
7039 checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
7040 }
7041 ieee754.write(buf, value, offset, littleEndian, 23, 4)
7042 return offset + 4
7043}
7044
7045Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
7046 return writeFloat(this, value, offset, true, noAssert)
7047}
7048
7049Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
7050 return writeFloat(this, value, offset, false, noAssert)
7051}
7052
7053function writeDouble (buf, value, offset, littleEndian, noAssert) {
7054 if (!noAssert) {
7055 checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
7056 }
7057 ieee754.write(buf, value, offset, littleEndian, 52, 8)
7058 return offset + 8
7059}
7060
7061Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
7062 return writeDouble(this, value, offset, true, noAssert)
7063}
7064
7065Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
7066 return writeDouble(this, value, offset, false, noAssert)
7067}
7068
7069// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
7070Buffer.prototype.copy = function copy (target, targetStart, start, end) {
7071 if (!start) start = 0
7072 if (!end && end !== 0) end = this.length
7073 if (targetStart >= target.length) targetStart = target.length
7074 if (!targetStart) targetStart = 0
7075 if (end > 0 && end < start) end = start
7076
7077 // Copy 0 bytes; we're done
7078 if (end === start) return 0
7079 if (target.length === 0 || this.length === 0) return 0
7080
7081 // Fatal error conditions
7082 if (targetStart < 0) {
7083 throw new RangeError('targetStart out of bounds')
7084 }
7085 if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
7086 if (end < 0) throw new RangeError('sourceEnd out of bounds')
7087
7088 // Are we oob?
7089 if (end > this.length) end = this.length
7090 if (target.length - targetStart < end - start) {
7091 end = target.length - targetStart + start
7092 }
7093
7094 var len = end - start
7095 var i
7096
7097 if (this === target && start < targetStart && targetStart < end) {
7098 // descending copy from end
7099 for (i = len - 1; i >= 0; --i) {
7100 target[i + targetStart] = this[i + start]
7101 }
7102 } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
7103 // ascending copy from start
7104 for (i = 0; i < len; ++i) {
7105 target[i + targetStart] = this[i + start]
7106 }
7107 } else {
7108 Uint8Array.prototype.set.call(
7109 target,
7110 this.subarray(start, start + len),
7111 targetStart
7112 )
7113 }
7114
7115 return len
7116}
7117
7118// Usage:
7119// buffer.fill(number[, offset[, end]])
7120// buffer.fill(buffer[, offset[, end]])
7121// buffer.fill(string[, offset[, end]][, encoding])
7122Buffer.prototype.fill = function fill (val, start, end, encoding) {
7123 // Handle string cases:
7124 if (typeof val === 'string') {
7125 if (typeof start === 'string') {
7126 encoding = start
7127 start = 0
7128 end = this.length
7129 } else if (typeof end === 'string') {
7130 encoding = end
7131 end = this.length
7132 }
7133 if (val.length === 1) {
7134 var code = val.charCodeAt(0)
7135 if (code < 256) {
7136 val = code
7137 }
7138 }
7139 if (encoding !== undefined && typeof encoding !== 'string') {
7140 throw new TypeError('encoding must be a string')
7141 }
7142 if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
7143 throw new TypeError('Unknown encoding: ' + encoding)
7144 }
7145 } else if (typeof val === 'number') {
7146 val = val & 255
7147 }
7148
7149 // Invalid ranges are not set to a default, so can range check early.
7150 if (start < 0 || this.length < start || this.length < end) {
7151 throw new RangeError('Out of range index')
7152 }
7153
7154 if (end <= start) {
7155 return this
7156 }
7157
7158 start = start >>> 0
7159 end = end === undefined ? this.length : end >>> 0
7160
7161 if (!val) val = 0
7162
7163 var i
7164 if (typeof val === 'number') {
7165 for (i = start; i < end; ++i) {
7166 this[i] = val
7167 }
7168 } else {
7169 var bytes = Buffer.isBuffer(val)
7170 ? val
7171 : utf8ToBytes(new Buffer(val, encoding).toString())
7172 var len = bytes.length
7173 for (i = 0; i < end - start; ++i) {
7174 this[i + start] = bytes[i % len]
7175 }
7176 }
7177
7178 return this
7179}
7180
7181// HELPER FUNCTIONS
7182// ================
7183
7184var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
7185
7186function base64clean (str) {
7187 // Node strips out invalid characters like \n and \t from the string, base64-js does not
7188 str = stringtrim(str).replace(INVALID_BASE64_RE, '')
7189 // Node converts strings with length < 2 to ''
7190 if (str.length < 2) return ''
7191 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
7192 while (str.length % 4 !== 0) {
7193 str = str + '='
7194 }
7195 return str
7196}
7197
7198function stringtrim (str) {
7199 if (str.trim) return str.trim()
7200 return str.replace(/^\s+|\s+$/g, '')
7201}
7202
7203function toHex (n) {
7204 if (n < 16) return '0' + n.toString(16)
7205 return n.toString(16)
7206}
7207
7208function utf8ToBytes (string, units) {
7209 units = units || Infinity
7210 var codePoint
7211 var length = string.length
7212 var leadSurrogate = null
7213 var bytes = []
7214
7215 for (var i = 0; i < length; ++i) {
7216 codePoint = string.charCodeAt(i)
7217
7218 // is surrogate component
7219 if (codePoint > 0xD7FF && codePoint < 0xE000) {
7220 // last char was a lead
7221 if (!leadSurrogate) {
7222 // no lead yet
7223 if (codePoint > 0xDBFF) {
7224 // unexpected trail
7225 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
7226 continue
7227 } else if (i + 1 === length) {
7228 // unpaired lead
7229 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
7230 continue
7231 }
7232
7233 // valid lead
7234 leadSurrogate = codePoint
7235
7236 continue
7237 }
7238
7239 // 2 leads in a row
7240 if (codePoint < 0xDC00) {
7241 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
7242 leadSurrogate = codePoint
7243 continue
7244 }
7245
7246 // valid surrogate pair
7247 codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
7248 } else if (leadSurrogate) {
7249 // valid bmp char, but last char was a lead
7250 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
7251 }
7252
7253 leadSurrogate = null
7254
7255 // encode utf8
7256 if (codePoint < 0x80) {
7257 if ((units -= 1) < 0) break
7258 bytes.push(codePoint)
7259 } else if (codePoint < 0x800) {
7260 if ((units -= 2) < 0) break
7261 bytes.push(
7262 codePoint >> 0x6 | 0xC0,
7263 codePoint & 0x3F | 0x80
7264 )
7265 } else if (codePoint < 0x10000) {
7266 if ((units -= 3) < 0) break
7267 bytes.push(
7268 codePoint >> 0xC | 0xE0,
7269 codePoint >> 0x6 & 0x3F | 0x80,
7270 codePoint & 0x3F | 0x80
7271 )
7272 } else if (codePoint < 0x110000) {
7273 if ((units -= 4) < 0) break
7274 bytes.push(
7275 codePoint >> 0x12 | 0xF0,
7276 codePoint >> 0xC & 0x3F | 0x80,
7277 codePoint >> 0x6 & 0x3F | 0x80,
7278 codePoint & 0x3F | 0x80
7279 )
7280 } else {
7281 throw new Error('Invalid code point')
7282 }
7283 }
7284
7285 return bytes
7286}
7287
7288function asciiToBytes (str) {
7289 var byteArray = []
7290 for (var i = 0; i < str.length; ++i) {
7291 // Node's code seems to be doing this and not & 0x7F..
7292 byteArray.push(str.charCodeAt(i) & 0xFF)
7293 }
7294 return byteArray
7295}
7296
7297function utf16leToBytes (str, units) {
7298 var c, hi, lo
7299 var byteArray = []
7300 for (var i = 0; i < str.length; ++i) {
7301 if ((units -= 2) < 0) break
7302
7303 c = str.charCodeAt(i)
7304 hi = c >> 8
7305 lo = c % 256
7306 byteArray.push(lo)
7307 byteArray.push(hi)
7308 }
7309
7310 return byteArray
7311}
7312
7313function base64ToBytes (str) {
7314 return base64.toByteArray(base64clean(str))
7315}
7316
7317function blitBuffer (src, dst, offset, length) {
7318 for (var i = 0; i < length; ++i) {
7319 if ((i + offset >= dst.length) || (i >= src.length)) break
7320 dst[i + offset] = src[i]
7321 }
7322 return i
7323}
7324
7325function isnan (val) {
7326 return val !== val // eslint-disable-line no-self-compare
7327}
7328
7329}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
7330},{"base64-js":66,"ieee754":225,"isarray":234}],71:[function(require,module,exports){
7331module.exports = {
7332 "100": "Continue",
7333 "101": "Switching Protocols",
7334 "102": "Processing",
7335 "200": "OK",
7336 "201": "Created",
7337 "202": "Accepted",
7338 "203": "Non-Authoritative Information",
7339 "204": "No Content",
7340 "205": "Reset Content",
7341 "206": "Partial Content",
7342 "207": "Multi-Status",
7343 "208": "Already Reported",
7344 "226": "IM Used",
7345 "300": "Multiple Choices",
7346 "301": "Moved Permanently",
7347 "302": "Found",
7348 "303": "See Other",
7349 "304": "Not Modified",
7350 "305": "Use Proxy",
7351 "307": "Temporary Redirect",
7352 "308": "Permanent Redirect",
7353 "400": "Bad Request",
7354 "401": "Unauthorized",
7355 "402": "Payment Required",
7356 "403": "Forbidden",
7357 "404": "Not Found",
7358 "405": "Method Not Allowed",
7359 "406": "Not Acceptable",
7360 "407": "Proxy Authentication Required",
7361 "408": "Request Timeout",
7362 "409": "Conflict",
7363 "410": "Gone",
7364 "411": "Length Required",
7365 "412": "Precondition Failed",
7366 "413": "Payload Too Large",
7367 "414": "URI Too Long",
7368 "415": "Unsupported Media Type",
7369 "416": "Range Not Satisfiable",
7370 "417": "Expectation Failed",
7371 "418": "I'm a teapot",
7372 "421": "Misdirected Request",
7373 "422": "Unprocessable Entity",
7374 "423": "Locked",
7375 "424": "Failed Dependency",
7376 "425": "Unordered Collection",
7377 "426": "Upgrade Required",
7378 "428": "Precondition Required",
7379 "429": "Too Many Requests",
7380 "431": "Request Header Fields Too Large",
7381 "451": "Unavailable For Legal Reasons",
7382 "500": "Internal Server Error",
7383 "501": "Not Implemented",
7384 "502": "Bad Gateway",
7385 "503": "Service Unavailable",
7386 "504": "Gateway Timeout",
7387 "505": "HTTP Version Not Supported",
7388 "506": "Variant Also Negotiates",
7389 "507": "Insufficient Storage",
7390 "508": "Loop Detected",
7391 "509": "Bandwidth Limit Exceeded",
7392 "510": "Not Extended",
7393 "511": "Network Authentication Required"
7394}
7395
7396},{}],72:[function(require,module,exports){
7397module.exports={
7398 "O_RDONLY": 0,
7399 "O_WRONLY": 1,
7400 "O_RDWR": 2,
7401 "S_IFMT": 61440,
7402 "S_IFREG": 32768,
7403 "S_IFDIR": 16384,
7404 "S_IFCHR": 8192,
7405 "S_IFBLK": 24576,
7406 "S_IFIFO": 4096,
7407 "S_IFLNK": 40960,
7408 "S_IFSOCK": 49152,
7409 "O_CREAT": 512,
7410 "O_EXCL": 2048,
7411 "O_NOCTTY": 131072,
7412 "O_TRUNC": 1024,
7413 "O_APPEND": 8,
7414 "O_DIRECTORY": 1048576,
7415 "O_NOFOLLOW": 256,
7416 "O_SYNC": 128,
7417 "O_SYMLINK": 2097152,
7418 "O_NONBLOCK": 4,
7419 "S_IRWXU": 448,
7420 "S_IRUSR": 256,
7421 "S_IWUSR": 128,
7422 "S_IXUSR": 64,
7423 "S_IRWXG": 56,
7424 "S_IRGRP": 32,
7425 "S_IWGRP": 16,
7426 "S_IXGRP": 8,
7427 "S_IRWXO": 7,
7428 "S_IROTH": 4,
7429 "S_IWOTH": 2,
7430 "S_IXOTH": 1,
7431 "E2BIG": 7,
7432 "EACCES": 13,
7433 "EADDRINUSE": 48,
7434 "EADDRNOTAVAIL": 49,
7435 "EAFNOSUPPORT": 47,
7436 "EAGAIN": 35,
7437 "EALREADY": 37,
7438 "EBADF": 9,
7439 "EBADMSG": 94,
7440 "EBUSY": 16,
7441 "ECANCELED": 89,
7442 "ECHILD": 10,
7443 "ECONNABORTED": 53,
7444 "ECONNREFUSED": 61,
7445 "ECONNRESET": 54,
7446 "EDEADLK": 11,
7447 "EDESTADDRREQ": 39,
7448 "EDOM": 33,
7449 "EDQUOT": 69,
7450 "EEXIST": 17,
7451 "EFAULT": 14,
7452 "EFBIG": 27,
7453 "EHOSTUNREACH": 65,
7454 "EIDRM": 90,
7455 "EILSEQ": 92,
7456 "EINPROGRESS": 36,
7457 "EINTR": 4,
7458 "EINVAL": 22,
7459 "EIO": 5,
7460 "EISCONN": 56,
7461 "EISDIR": 21,
7462 "ELOOP": 62,
7463 "EMFILE": 24,
7464 "EMLINK": 31,
7465 "EMSGSIZE": 40,
7466 "EMULTIHOP": 95,
7467 "ENAMETOOLONG": 63,
7468 "ENETDOWN": 50,
7469 "ENETRESET": 52,
7470 "ENETUNREACH": 51,
7471 "ENFILE": 23,
7472 "ENOBUFS": 55,
7473 "ENODATA": 96,
7474 "ENODEV": 19,
7475 "ENOENT": 2,
7476 "ENOEXEC": 8,
7477 "ENOLCK": 77,
7478 "ENOLINK": 97,
7479 "ENOMEM": 12,
7480 "ENOMSG": 91,
7481 "ENOPROTOOPT": 42,
7482 "ENOSPC": 28,
7483 "ENOSR": 98,
7484 "ENOSTR": 99,
7485 "ENOSYS": 78,
7486 "ENOTCONN": 57,
7487 "ENOTDIR": 20,
7488 "ENOTEMPTY": 66,
7489 "ENOTSOCK": 38,
7490 "ENOTSUP": 45,
7491 "ENOTTY": 25,
7492 "ENXIO": 6,
7493 "EOPNOTSUPP": 102,
7494 "EOVERFLOW": 84,
7495 "EPERM": 1,
7496 "EPIPE": 32,
7497 "EPROTO": 100,
7498 "EPROTONOSUPPORT": 43,
7499 "EPROTOTYPE": 41,
7500 "ERANGE": 34,
7501 "EROFS": 30,
7502 "ESPIPE": 29,
7503 "ESRCH": 3,
7504 "ESTALE": 70,
7505 "ETIME": 101,
7506 "ETIMEDOUT": 60,
7507 "ETXTBSY": 26,
7508 "EWOULDBLOCK": 35,
7509 "EXDEV": 18,
7510 "SIGHUP": 1,
7511 "SIGINT": 2,
7512 "SIGQUIT": 3,
7513 "SIGILL": 4,
7514 "SIGTRAP": 5,
7515 "SIGABRT": 6,
7516 "SIGIOT": 6,
7517 "SIGBUS": 10,
7518 "SIGFPE": 8,
7519 "SIGKILL": 9,
7520 "SIGUSR1": 30,
7521 "SIGSEGV": 11,
7522 "SIGUSR2": 31,
7523 "SIGPIPE": 13,
7524 "SIGALRM": 14,
7525 "SIGTERM": 15,
7526 "SIGCHLD": 20,
7527 "SIGCONT": 19,
7528 "SIGSTOP": 17,
7529 "SIGTSTP": 18,
7530 "SIGTTIN": 21,
7531 "SIGTTOU": 22,
7532 "SIGURG": 16,
7533 "SIGXCPU": 24,
7534 "SIGXFSZ": 25,
7535 "SIGVTALRM": 26,
7536 "SIGPROF": 27,
7537 "SIGWINCH": 28,
7538 "SIGIO": 23,
7539 "SIGSYS": 12,
7540 "SSL_OP_ALL": 2147486719,
7541 "SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION": 262144,
7542 "SSL_OP_CIPHER_SERVER_PREFERENCE": 4194304,
7543 "SSL_OP_CISCO_ANYCONNECT": 32768,
7544 "SSL_OP_COOKIE_EXCHANGE": 8192,
7545 "SSL_OP_CRYPTOPRO_TLSEXT_BUG": 2147483648,
7546 "SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS": 2048,
7547 "SSL_OP_EPHEMERAL_RSA": 0,
7548 "SSL_OP_LEGACY_SERVER_CONNECT": 4,
7549 "SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER": 32,
7550 "SSL_OP_MICROSOFT_SESS_ID_BUG": 1,
7551 "SSL_OP_MSIE_SSLV2_RSA_PADDING": 0,
7552 "SSL_OP_NETSCAPE_CA_DN_BUG": 536870912,
7553 "SSL_OP_NETSCAPE_CHALLENGE_BUG": 2,
7554 "SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG": 1073741824,
7555 "SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG": 8,
7556 "SSL_OP_NO_COMPRESSION": 131072,
7557 "SSL_OP_NO_QUERY_MTU": 4096,
7558 "SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION": 65536,
7559 "SSL_OP_NO_SSLv2": 16777216,
7560 "SSL_OP_NO_SSLv3": 33554432,
7561 "SSL_OP_NO_TICKET": 16384,
7562 "SSL_OP_NO_TLSv1": 67108864,
7563 "SSL_OP_NO_TLSv1_1": 268435456,
7564 "SSL_OP_NO_TLSv1_2": 134217728,
7565 "SSL_OP_PKCS1_CHECK_1": 0,
7566 "SSL_OP_PKCS1_CHECK_2": 0,
7567 "SSL_OP_SINGLE_DH_USE": 1048576,
7568 "SSL_OP_SINGLE_ECDH_USE": 524288,
7569 "SSL_OP_SSLEAY_080_CLIENT_DH_BUG": 128,
7570 "SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG": 0,
7571 "SSL_OP_TLS_BLOCK_PADDING_BUG": 512,
7572 "SSL_OP_TLS_D5_BUG": 256,
7573 "SSL_OP_TLS_ROLLBACK_BUG": 8388608,
7574 "ENGINE_METHOD_DSA": 2,
7575 "ENGINE_METHOD_DH": 4,
7576 "ENGINE_METHOD_RAND": 8,
7577 "ENGINE_METHOD_ECDH": 16,
7578 "ENGINE_METHOD_ECDSA": 32,
7579 "ENGINE_METHOD_CIPHERS": 64,
7580 "ENGINE_METHOD_DIGESTS": 128,
7581 "ENGINE_METHOD_STORE": 256,
7582 "ENGINE_METHOD_PKEY_METHS": 512,
7583 "ENGINE_METHOD_PKEY_ASN1_METHS": 1024,
7584 "ENGINE_METHOD_ALL": 65535,
7585 "ENGINE_METHOD_NONE": 0,
7586 "DH_CHECK_P_NOT_SAFE_PRIME": 2,
7587 "DH_CHECK_P_NOT_PRIME": 1,
7588 "DH_UNABLE_TO_CHECK_GENERATOR": 4,
7589 "DH_NOT_SUITABLE_GENERATOR": 8,
7590 "NPN_ENABLED": 1,
7591 "RSA_PKCS1_PADDING": 1,
7592 "RSA_SSLV23_PADDING": 2,
7593 "RSA_NO_PADDING": 3,
7594 "RSA_PKCS1_OAEP_PADDING": 4,
7595 "RSA_X931_PADDING": 5,
7596 "RSA_PKCS1_PSS_PADDING": 6,
7597 "POINT_CONVERSION_COMPRESSED": 2,
7598 "POINT_CONVERSION_UNCOMPRESSED": 4,
7599 "POINT_CONVERSION_HYBRID": 6,
7600 "F_OK": 0,
7601 "R_OK": 4,
7602 "W_OK": 2,
7603 "X_OK": 1,
7604 "UV_UDP_REUSEADDR": 4
7605}
7606
7607},{}],73:[function(require,module,exports){
7608/*!
7609 * copy-to - index.js
7610 * Copyright(c) 2014 dead_horse <dead_horse@qq.com>
7611 * MIT Licensed
7612 */
7613
7614'use strict';
7615
7616/**
7617 * slice() reference.
7618 */
7619
7620var slice = Array.prototype.slice;
7621
7622/**
7623 * Expose copy
7624 *
7625 * ```
7626 * copy({foo: 'nar', hello: 'copy'}).to({hello: 'world'});
7627 * copy({foo: 'nar', hello: 'copy'}).toCover({hello: 'world'});
7628 * ```
7629 *
7630 * @param {Object} src
7631 * @return {Copy}
7632 */
7633
7634module.exports = Copy;
7635
7636
7637/**
7638 * Copy
7639 * @param {Object} src
7640 * @param {Boolean} withAccess
7641 */
7642
7643function Copy(src, withAccess) {
7644 if (!(this instanceof Copy)) return new Copy(src, withAccess);
7645 this.src = src;
7646 this._withAccess = withAccess;
7647}
7648
7649/**
7650 * copy properties include getter and setter
7651 * @param {[type]} val [description]
7652 * @return {[type]} [description]
7653 */
7654
7655Copy.prototype.withAccess = function (w) {
7656 this._withAccess = w !== false;
7657 return this;
7658};
7659
7660/**
7661 * pick keys in src
7662 *
7663 * @api: public
7664 */
7665
7666Copy.prototype.pick = function(keys) {
7667 if (!Array.isArray(keys)) {
7668 keys = slice.call(arguments);
7669 }
7670 if (keys.length) {
7671 this.keys = keys;
7672 }
7673 return this;
7674};
7675
7676/**
7677 * copy src to target,
7678 * do not cover any property target has
7679 * @param {Object} to
7680 *
7681 * @api: public
7682 */
7683
7684Copy.prototype.to = function(to) {
7685 to = to || {};
7686
7687 if (!this.src) return to;
7688 var keys = this.keys || Object.keys(this.src);
7689
7690 if (!this._withAccess) {
7691 for (var i = 0; i < keys.length; i++) {
7692 key = keys[i];
7693 if (to[key] !== undefined) continue;
7694 to[key] = this.src[key];
7695 }
7696 return to;
7697 }
7698
7699 for (var i = 0; i < keys.length; i++) {
7700 var key = keys[i];
7701 if (!notDefined(to, key)) continue;
7702 var getter = this.src.__lookupGetter__(key);
7703 var setter = this.src.__lookupSetter__(key);
7704 if (getter) to.__defineGetter__(key, getter);
7705 if (setter) to.__defineSetter__(key, setter);
7706
7707 if (!getter && !setter) {
7708 to[key] = this.src[key];
7709 }
7710 }
7711 return to;
7712};
7713
7714/**
7715 * copy src to target,
7716 * override any property target has
7717 * @param {Object} to
7718 *
7719 * @api: public
7720 */
7721
7722Copy.prototype.toCover = function(to) {
7723 var keys = this.keys || Object.keys(this.src);
7724
7725 for (var i = 0; i < keys.length; i++) {
7726 var key = keys[i];
7727 delete to[key];
7728 var getter = this.src.__lookupGetter__(key);
7729 var setter = this.src.__lookupSetter__(key);
7730 if (getter) to.__defineGetter__(key, getter);
7731 if (setter) to.__defineSetter__(key, setter);
7732
7733 if (!getter && !setter) {
7734 to[key] = this.src[key];
7735 }
7736 }
7737};
7738
7739Copy.prototype.override = Copy.prototype.toCover;
7740
7741/**
7742 * append another object to src
7743 * @param {Obj} obj
7744 * @return {Copy}
7745 */
7746
7747Copy.prototype.and = function (obj) {
7748 var src = {};
7749 this.to(src);
7750 this.src = obj;
7751 this.to(src);
7752 this.src = src;
7753
7754 return this;
7755};
7756
7757/**
7758 * check obj[key] if not defiend
7759 * @param {Object} obj
7760 * @param {String} key
7761 * @return {Boolean}
7762 */
7763
7764function notDefined(obj, key) {
7765 return obj[key] === undefined
7766 && obj.__lookupGetter__(key) === undefined
7767 && obj.__lookupSetter__(key) === undefined;
7768}
7769
7770},{}],74:[function(require,module,exports){
7771require('../../modules/es6.string.iterator');
7772require('../../modules/es6.array.from');
7773module.exports = require('../../modules/_core').Array.from;
7774
7775},{"../../modules/_core":96,"../../modules/es6.array.from":165,"../../modules/es6.string.iterator":177}],75:[function(require,module,exports){
7776var core = require('../../modules/_core');
7777var $JSON = core.JSON || (core.JSON = { stringify: JSON.stringify });
7778module.exports = function stringify(it) { // eslint-disable-line no-unused-vars
7779 return $JSON.stringify.apply($JSON, arguments);
7780};
7781
7782},{"../../modules/_core":96}],76:[function(require,module,exports){
7783require('../../modules/es6.object.assign');
7784module.exports = require('../../modules/_core').Object.assign;
7785
7786},{"../../modules/_core":96,"../../modules/es6.object.assign":168}],77:[function(require,module,exports){
7787require('../../modules/es6.object.create');
7788var $Object = require('../../modules/_core').Object;
7789module.exports = function create(P, D) {
7790 return $Object.create(P, D);
7791};
7792
7793},{"../../modules/_core":96,"../../modules/es6.object.create":169}],78:[function(require,module,exports){
7794require('../../modules/es6.object.define-property');
7795var $Object = require('../../modules/_core').Object;
7796module.exports = function defineProperty(it, key, desc) {
7797 return $Object.defineProperty(it, key, desc);
7798};
7799
7800},{"../../modules/_core":96,"../../modules/es6.object.define-property":170}],79:[function(require,module,exports){
7801require('../../modules/es7.object.entries');
7802module.exports = require('../../modules/_core').Object.entries;
7803
7804},{"../../modules/_core":96,"../../modules/es7.object.entries":179}],80:[function(require,module,exports){
7805require('../../modules/es6.object.get-own-property-names');
7806var $Object = require('../../modules/_core').Object;
7807module.exports = function getOwnPropertyNames(it) {
7808 return $Object.getOwnPropertyNames(it);
7809};
7810
7811},{"../../modules/_core":96,"../../modules/es6.object.get-own-property-names":171}],81:[function(require,module,exports){
7812require('../../modules/es6.object.get-prototype-of');
7813module.exports = require('../../modules/_core').Object.getPrototypeOf;
7814
7815},{"../../modules/_core":96,"../../modules/es6.object.get-prototype-of":172}],82:[function(require,module,exports){
7816require('../../modules/es6.object.keys');
7817module.exports = require('../../modules/_core').Object.keys;
7818
7819},{"../../modules/_core":96,"../../modules/es6.object.keys":173}],83:[function(require,module,exports){
7820require('../modules/es6.object.to-string');
7821require('../modules/es6.string.iterator');
7822require('../modules/web.dom.iterable');
7823require('../modules/es6.promise');
7824require('../modules/es7.promise.finally');
7825require('../modules/es7.promise.try');
7826module.exports = require('../modules/_core').Promise;
7827
7828},{"../modules/_core":96,"../modules/es6.object.to-string":174,"../modules/es6.promise":175,"../modules/es6.string.iterator":177,"../modules/es7.promise.finally":180,"../modules/es7.promise.try":181,"../modules/web.dom.iterable":184}],84:[function(require,module,exports){
7829require('../modules/web.immediate');
7830module.exports = require('../modules/_core').setImmediate;
7831
7832},{"../modules/_core":96,"../modules/web.immediate":185}],85:[function(require,module,exports){
7833require('../../modules/es6.string.from-code-point');
7834module.exports = require('../../modules/_core').String.fromCodePoint;
7835
7836},{"../../modules/_core":96,"../../modules/es6.string.from-code-point":176}],86:[function(require,module,exports){
7837require('../../modules/es6.function.has-instance');
7838module.exports = require('../../modules/_wks-ext').f('hasInstance');
7839
7840},{"../../modules/_wks-ext":162,"../../modules/es6.function.has-instance":167}],87:[function(require,module,exports){
7841require('../../modules/es6.symbol');
7842require('../../modules/es6.object.to-string');
7843require('../../modules/es7.symbol.async-iterator');
7844require('../../modules/es7.symbol.observable');
7845module.exports = require('../../modules/_core').Symbol;
7846
7847},{"../../modules/_core":96,"../../modules/es6.object.to-string":174,"../../modules/es6.symbol":178,"../../modules/es7.symbol.async-iterator":182,"../../modules/es7.symbol.observable":183}],88:[function(require,module,exports){
7848require('../../modules/es6.string.iterator');
7849require('../../modules/web.dom.iterable');
7850module.exports = require('../../modules/_wks-ext').f('iterator');
7851
7852},{"../../modules/_wks-ext":162,"../../modules/es6.string.iterator":177,"../../modules/web.dom.iterable":184}],89:[function(require,module,exports){
7853module.exports = function (it) {
7854 if (typeof it != 'function') throw TypeError(it + ' is not a function!');
7855 return it;
7856};
7857
7858},{}],90:[function(require,module,exports){
7859module.exports = function () { /* empty */ };
7860
7861},{}],91:[function(require,module,exports){
7862module.exports = function (it, Constructor, name, forbiddenField) {
7863 if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) {
7864 throw TypeError(name + ': incorrect invocation!');
7865 } return it;
7866};
7867
7868},{}],92:[function(require,module,exports){
7869var isObject = require('./_is-object');
7870module.exports = function (it) {
7871 if (!isObject(it)) throw TypeError(it + ' is not an object!');
7872 return it;
7873};
7874
7875},{"./_is-object":116}],93:[function(require,module,exports){
7876// false -> Array#indexOf
7877// true -> Array#includes
7878var toIObject = require('./_to-iobject');
7879var toLength = require('./_to-length');
7880var toAbsoluteIndex = require('./_to-absolute-index');
7881module.exports = function (IS_INCLUDES) {
7882 return function ($this, el, fromIndex) {
7883 var O = toIObject($this);
7884 var length = toLength(O.length);
7885 var index = toAbsoluteIndex(fromIndex, length);
7886 var value;
7887 // Array#includes uses SameValueZero equality algorithm
7888 // eslint-disable-next-line no-self-compare
7889 if (IS_INCLUDES && el != el) while (length > index) {
7890 value = O[index++];
7891 // eslint-disable-next-line no-self-compare
7892 if (value != value) return true;
7893 // Array#indexOf ignores holes, Array#includes - not
7894 } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
7895 if (O[index] === el) return IS_INCLUDES || index || 0;
7896 } return !IS_INCLUDES && -1;
7897 };
7898};
7899
7900},{"./_to-absolute-index":153,"./_to-iobject":155,"./_to-length":156}],94:[function(require,module,exports){
7901// getting tag from 19.1.3.6 Object.prototype.toString()
7902var cof = require('./_cof');
7903var TAG = require('./_wks')('toStringTag');
7904// ES3 wrong here
7905var ARG = cof(function () { return arguments; }()) == 'Arguments';
7906
7907// fallback for IE11 Script Access Denied error
7908var tryGet = function (it, key) {
7909 try {
7910 return it[key];
7911 } catch (e) { /* empty */ }
7912};
7913
7914module.exports = function (it) {
7915 var O, T, B;
7916 return it === undefined ? 'Undefined' : it === null ? 'Null'
7917 // @@toStringTag case
7918 : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
7919 // builtinTag case
7920 : ARG ? cof(O)
7921 // ES3 arguments fallback
7922 : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
7923};
7924
7925},{"./_cof":95,"./_wks":163}],95:[function(require,module,exports){
7926var toString = {}.toString;
7927
7928module.exports = function (it) {
7929 return toString.call(it).slice(8, -1);
7930};
7931
7932},{}],96:[function(require,module,exports){
7933var core = module.exports = { version: '2.5.7' };
7934if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
7935
7936},{}],97:[function(require,module,exports){
7937'use strict';
7938var $defineProperty = require('./_object-dp');
7939var createDesc = require('./_property-desc');
7940
7941module.exports = function (object, index, value) {
7942 if (index in object) $defineProperty.f(object, index, createDesc(0, value));
7943 else object[index] = value;
7944};
7945
7946},{"./_object-dp":129,"./_property-desc":143}],98:[function(require,module,exports){
7947// optional / simple context binding
7948var aFunction = require('./_a-function');
7949module.exports = function (fn, that, length) {
7950 aFunction(fn);
7951 if (that === undefined) return fn;
7952 switch (length) {
7953 case 1: return function (a) {
7954 return fn.call(that, a);
7955 };
7956 case 2: return function (a, b) {
7957 return fn.call(that, a, b);
7958 };
7959 case 3: return function (a, b, c) {
7960 return fn.call(that, a, b, c);
7961 };
7962 }
7963 return function (/* ...args */) {
7964 return fn.apply(that, arguments);
7965 };
7966};
7967
7968},{"./_a-function":89}],99:[function(require,module,exports){
7969// 7.2.1 RequireObjectCoercible(argument)
7970module.exports = function (it) {
7971 if (it == undefined) throw TypeError("Can't call method on " + it);
7972 return it;
7973};
7974
7975},{}],100:[function(require,module,exports){
7976// Thank's IE8 for his funny defineProperty
7977module.exports = !require('./_fails')(function () {
7978 return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
7979});
7980
7981},{"./_fails":105}],101:[function(require,module,exports){
7982var isObject = require('./_is-object');
7983var document = require('./_global').document;
7984// typeof document.createElement is 'object' in old IE
7985var is = isObject(document) && isObject(document.createElement);
7986module.exports = function (it) {
7987 return is ? document.createElement(it) : {};
7988};
7989
7990},{"./_global":107,"./_is-object":116}],102:[function(require,module,exports){
7991// IE 8- don't enum bug keys
7992module.exports = (
7993 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
7994).split(',');
7995
7996},{}],103:[function(require,module,exports){
7997// all enumerable object keys, includes symbols
7998var getKeys = require('./_object-keys');
7999var gOPS = require('./_object-gops');
8000var pIE = require('./_object-pie');
8001module.exports = function (it) {
8002 var result = getKeys(it);
8003 var getSymbols = gOPS.f;
8004 if (getSymbols) {
8005 var symbols = getSymbols(it);
8006 var isEnum = pIE.f;
8007 var i = 0;
8008 var key;
8009 while (symbols.length > i) if (isEnum.call(it, key = symbols[i++])) result.push(key);
8010 } return result;
8011};
8012
8013},{"./_object-gops":134,"./_object-keys":137,"./_object-pie":138}],104:[function(require,module,exports){
8014var global = require('./_global');
8015var core = require('./_core');
8016var ctx = require('./_ctx');
8017var hide = require('./_hide');
8018var has = require('./_has');
8019var PROTOTYPE = 'prototype';
8020
8021var $export = function (type, name, source) {
8022 var IS_FORCED = type & $export.F;
8023 var IS_GLOBAL = type & $export.G;
8024 var IS_STATIC = type & $export.S;
8025 var IS_PROTO = type & $export.P;
8026 var IS_BIND = type & $export.B;
8027 var IS_WRAP = type & $export.W;
8028 var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});
8029 var expProto = exports[PROTOTYPE];
8030 var target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE];
8031 var key, own, out;
8032 if (IS_GLOBAL) source = name;
8033 for (key in source) {
8034 // contains in native
8035 own = !IS_FORCED && target && target[key] !== undefined;
8036 if (own && has(exports, key)) continue;
8037 // export native or passed
8038 out = own ? target[key] : source[key];
8039 // prevent global pollution for namespaces
8040 exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
8041 // bind timers to global for call from export context
8042 : IS_BIND && own ? ctx(out, global)
8043 // wrap global constructors for prevent change them in library
8044 : IS_WRAP && target[key] == out ? (function (C) {
8045 var F = function (a, b, c) {
8046 if (this instanceof C) {
8047 switch (arguments.length) {
8048 case 0: return new C();
8049 case 1: return new C(a);
8050 case 2: return new C(a, b);
8051 } return new C(a, b, c);
8052 } return C.apply(this, arguments);
8053 };
8054 F[PROTOTYPE] = C[PROTOTYPE];
8055 return F;
8056 // make static versions for prototype methods
8057 })(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
8058 // export proto methods to core.%CONSTRUCTOR%.methods.%NAME%
8059 if (IS_PROTO) {
8060 (exports.virtual || (exports.virtual = {}))[key] = out;
8061 // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%
8062 if (type & $export.R && expProto && !expProto[key]) hide(expProto, key, out);
8063 }
8064 }
8065};
8066// type bitmap
8067$export.F = 1; // forced
8068$export.G = 2; // global
8069$export.S = 4; // static
8070$export.P = 8; // proto
8071$export.B = 16; // bind
8072$export.W = 32; // wrap
8073$export.U = 64; // safe
8074$export.R = 128; // real proto method for `library`
8075module.exports = $export;
8076
8077},{"./_core":96,"./_ctx":98,"./_global":107,"./_has":108,"./_hide":109}],105:[function(require,module,exports){
8078module.exports = function (exec) {
8079 try {
8080 return !!exec();
8081 } catch (e) {
8082 return true;
8083 }
8084};
8085
8086},{}],106:[function(require,module,exports){
8087var ctx = require('./_ctx');
8088var call = require('./_iter-call');
8089var isArrayIter = require('./_is-array-iter');
8090var anObject = require('./_an-object');
8091var toLength = require('./_to-length');
8092var getIterFn = require('./core.get-iterator-method');
8093var BREAK = {};
8094var RETURN = {};
8095var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
8096 var iterFn = ITERATOR ? function () { return iterable; } : getIterFn(iterable);
8097 var f = ctx(fn, that, entries ? 2 : 1);
8098 var index = 0;
8099 var length, step, iterator, result;
8100 if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
8101 // fast case for arrays with default iterator
8102 if (isArrayIter(iterFn)) for (length = toLength(iterable.length); length > index; index++) {
8103 result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
8104 if (result === BREAK || result === RETURN) return result;
8105 } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
8106 result = call(iterator, f, step.value, entries);
8107 if (result === BREAK || result === RETURN) return result;
8108 }
8109};
8110exports.BREAK = BREAK;
8111exports.RETURN = RETURN;
8112
8113},{"./_an-object":92,"./_ctx":98,"./_is-array-iter":114,"./_iter-call":117,"./_to-length":156,"./core.get-iterator-method":164}],107:[function(require,module,exports){
8114// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
8115var global = module.exports = typeof window != 'undefined' && window.Math == Math
8116 ? window : typeof self != 'undefined' && self.Math == Math ? self
8117 // eslint-disable-next-line no-new-func
8118 : Function('return this')();
8119if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
8120
8121},{}],108:[function(require,module,exports){
8122var hasOwnProperty = {}.hasOwnProperty;
8123module.exports = function (it, key) {
8124 return hasOwnProperty.call(it, key);
8125};
8126
8127},{}],109:[function(require,module,exports){
8128var dP = require('./_object-dp');
8129var createDesc = require('./_property-desc');
8130module.exports = require('./_descriptors') ? function (object, key, value) {
8131 return dP.f(object, key, createDesc(1, value));
8132} : function (object, key, value) {
8133 object[key] = value;
8134 return object;
8135};
8136
8137},{"./_descriptors":100,"./_object-dp":129,"./_property-desc":143}],110:[function(require,module,exports){
8138var document = require('./_global').document;
8139module.exports = document && document.documentElement;
8140
8141},{"./_global":107}],111:[function(require,module,exports){
8142module.exports = !require('./_descriptors') && !require('./_fails')(function () {
8143 return Object.defineProperty(require('./_dom-create')('div'), 'a', { get: function () { return 7; } }).a != 7;
8144});
8145
8146},{"./_descriptors":100,"./_dom-create":101,"./_fails":105}],112:[function(require,module,exports){
8147// fast apply, http://jsperf.lnkit.com/fast-apply/5
8148module.exports = function (fn, args, that) {
8149 var un = that === undefined;
8150 switch (args.length) {
8151 case 0: return un ? fn()
8152 : fn.call(that);
8153 case 1: return un ? fn(args[0])
8154 : fn.call(that, args[0]);
8155 case 2: return un ? fn(args[0], args[1])
8156 : fn.call(that, args[0], args[1]);
8157 case 3: return un ? fn(args[0], args[1], args[2])
8158 : fn.call(that, args[0], args[1], args[2]);
8159 case 4: return un ? fn(args[0], args[1], args[2], args[3])
8160 : fn.call(that, args[0], args[1], args[2], args[3]);
8161 } return fn.apply(that, args);
8162};
8163
8164},{}],113:[function(require,module,exports){
8165// fallback for non-array-like ES3 and non-enumerable old V8 strings
8166var cof = require('./_cof');
8167// eslint-disable-next-line no-prototype-builtins
8168module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
8169 return cof(it) == 'String' ? it.split('') : Object(it);
8170};
8171
8172},{"./_cof":95}],114:[function(require,module,exports){
8173// check on default Array iterator
8174var Iterators = require('./_iterators');
8175var ITERATOR = require('./_wks')('iterator');
8176var ArrayProto = Array.prototype;
8177
8178module.exports = function (it) {
8179 return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
8180};
8181
8182},{"./_iterators":122,"./_wks":163}],115:[function(require,module,exports){
8183// 7.2.2 IsArray(argument)
8184var cof = require('./_cof');
8185module.exports = Array.isArray || function isArray(arg) {
8186 return cof(arg) == 'Array';
8187};
8188
8189},{"./_cof":95}],116:[function(require,module,exports){
8190module.exports = function (it) {
8191 return typeof it === 'object' ? it !== null : typeof it === 'function';
8192};
8193
8194},{}],117:[function(require,module,exports){
8195// call something on iterator step with safe closing on error
8196var anObject = require('./_an-object');
8197module.exports = function (iterator, fn, value, entries) {
8198 try {
8199 return entries ? fn(anObject(value)[0], value[1]) : fn(value);
8200 // 7.4.6 IteratorClose(iterator, completion)
8201 } catch (e) {
8202 var ret = iterator['return'];
8203 if (ret !== undefined) anObject(ret.call(iterator));
8204 throw e;
8205 }
8206};
8207
8208},{"./_an-object":92}],118:[function(require,module,exports){
8209'use strict';
8210var create = require('./_object-create');
8211var descriptor = require('./_property-desc');
8212var setToStringTag = require('./_set-to-string-tag');
8213var IteratorPrototype = {};
8214
8215// 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
8216require('./_hide')(IteratorPrototype, require('./_wks')('iterator'), function () { return this; });
8217
8218module.exports = function (Constructor, NAME, next) {
8219 Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) });
8220 setToStringTag(Constructor, NAME + ' Iterator');
8221};
8222
8223},{"./_hide":109,"./_object-create":128,"./_property-desc":143,"./_set-to-string-tag":147,"./_wks":163}],119:[function(require,module,exports){
8224'use strict';
8225var LIBRARY = require('./_library');
8226var $export = require('./_export');
8227var redefine = require('./_redefine');
8228var hide = require('./_hide');
8229var Iterators = require('./_iterators');
8230var $iterCreate = require('./_iter-create');
8231var setToStringTag = require('./_set-to-string-tag');
8232var getPrototypeOf = require('./_object-gpo');
8233var ITERATOR = require('./_wks')('iterator');
8234var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
8235var FF_ITERATOR = '@@iterator';
8236var KEYS = 'keys';
8237var VALUES = 'values';
8238
8239var returnThis = function () { return this; };
8240
8241module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
8242 $iterCreate(Constructor, NAME, next);
8243 var getMethod = function (kind) {
8244 if (!BUGGY && kind in proto) return proto[kind];
8245 switch (kind) {
8246 case KEYS: return function keys() { return new Constructor(this, kind); };
8247 case VALUES: return function values() { return new Constructor(this, kind); };
8248 } return function entries() { return new Constructor(this, kind); };
8249 };
8250 var TAG = NAME + ' Iterator';
8251 var DEF_VALUES = DEFAULT == VALUES;
8252 var VALUES_BUG = false;
8253 var proto = Base.prototype;
8254 var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
8255 var $default = $native || getMethod(DEFAULT);
8256 var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
8257 var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
8258 var methods, key, IteratorPrototype;
8259 // Fix native
8260 if ($anyNative) {
8261 IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));
8262 if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
8263 // Set @@toStringTag to native iterators
8264 setToStringTag(IteratorPrototype, TAG, true);
8265 // fix for some old engines
8266 if (!LIBRARY && typeof IteratorPrototype[ITERATOR] != 'function') hide(IteratorPrototype, ITERATOR, returnThis);
8267 }
8268 }
8269 // fix Array#{values, @@iterator}.name in V8 / FF
8270 if (DEF_VALUES && $native && $native.name !== VALUES) {
8271 VALUES_BUG = true;
8272 $default = function values() { return $native.call(this); };
8273 }
8274 // Define iterator
8275 if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
8276 hide(proto, ITERATOR, $default);
8277 }
8278 // Plug for library
8279 Iterators[NAME] = $default;
8280 Iterators[TAG] = returnThis;
8281 if (DEFAULT) {
8282 methods = {
8283 values: DEF_VALUES ? $default : getMethod(VALUES),
8284 keys: IS_SET ? $default : getMethod(KEYS),
8285 entries: $entries
8286 };
8287 if (FORCED) for (key in methods) {
8288 if (!(key in proto)) redefine(proto, key, methods[key]);
8289 } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
8290 }
8291 return methods;
8292};
8293
8294},{"./_export":104,"./_hide":109,"./_iter-create":118,"./_iterators":122,"./_library":123,"./_object-gpo":135,"./_redefine":145,"./_set-to-string-tag":147,"./_wks":163}],120:[function(require,module,exports){
8295var ITERATOR = require('./_wks')('iterator');
8296var SAFE_CLOSING = false;
8297
8298try {
8299 var riter = [7][ITERATOR]();
8300 riter['return'] = function () { SAFE_CLOSING = true; };
8301 // eslint-disable-next-line no-throw-literal
8302 Array.from(riter, function () { throw 2; });
8303} catch (e) { /* empty */ }
8304
8305module.exports = function (exec, skipClosing) {
8306 if (!skipClosing && !SAFE_CLOSING) return false;
8307 var safe = false;
8308 try {
8309 var arr = [7];
8310 var iter = arr[ITERATOR]();
8311 iter.next = function () { return { done: safe = true }; };
8312 arr[ITERATOR] = function () { return iter; };
8313 exec(arr);
8314 } catch (e) { /* empty */ }
8315 return safe;
8316};
8317
8318},{"./_wks":163}],121:[function(require,module,exports){
8319module.exports = function (done, value) {
8320 return { value: value, done: !!done };
8321};
8322
8323},{}],122:[function(require,module,exports){
8324module.exports = {};
8325
8326},{}],123:[function(require,module,exports){
8327module.exports = true;
8328
8329},{}],124:[function(require,module,exports){
8330var META = require('./_uid')('meta');
8331var isObject = require('./_is-object');
8332var has = require('./_has');
8333var setDesc = require('./_object-dp').f;
8334var id = 0;
8335var isExtensible = Object.isExtensible || function () {
8336 return true;
8337};
8338var FREEZE = !require('./_fails')(function () {
8339 return isExtensible(Object.preventExtensions({}));
8340});
8341var setMeta = function (it) {
8342 setDesc(it, META, { value: {
8343 i: 'O' + ++id, // object ID
8344 w: {} // weak collections IDs
8345 } });
8346};
8347var fastKey = function (it, create) {
8348 // return primitive with prefix
8349 if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
8350 if (!has(it, META)) {
8351 // can't set metadata to uncaught frozen object
8352 if (!isExtensible(it)) return 'F';
8353 // not necessary to add metadata
8354 if (!create) return 'E';
8355 // add missing metadata
8356 setMeta(it);
8357 // return object ID
8358 } return it[META].i;
8359};
8360var getWeak = function (it, create) {
8361 if (!has(it, META)) {
8362 // can't set metadata to uncaught frozen object
8363 if (!isExtensible(it)) return true;
8364 // not necessary to add metadata
8365 if (!create) return false;
8366 // add missing metadata
8367 setMeta(it);
8368 // return hash weak collections IDs
8369 } return it[META].w;
8370};
8371// add metadata on freeze-family methods calling
8372var onFreeze = function (it) {
8373 if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it);
8374 return it;
8375};
8376var meta = module.exports = {
8377 KEY: META,
8378 NEED: false,
8379 fastKey: fastKey,
8380 getWeak: getWeak,
8381 onFreeze: onFreeze
8382};
8383
8384},{"./_fails":105,"./_has":108,"./_is-object":116,"./_object-dp":129,"./_uid":159}],125:[function(require,module,exports){
8385var global = require('./_global');
8386var macrotask = require('./_task').set;
8387var Observer = global.MutationObserver || global.WebKitMutationObserver;
8388var process = global.process;
8389var Promise = global.Promise;
8390var isNode = require('./_cof')(process) == 'process';
8391
8392module.exports = function () {
8393 var head, last, notify;
8394
8395 var flush = function () {
8396 var parent, fn;
8397 if (isNode && (parent = process.domain)) parent.exit();
8398 while (head) {
8399 fn = head.fn;
8400 head = head.next;
8401 try {
8402 fn();
8403 } catch (e) {
8404 if (head) notify();
8405 else last = undefined;
8406 throw e;
8407 }
8408 } last = undefined;
8409 if (parent) parent.enter();
8410 };
8411
8412 // Node.js
8413 if (isNode) {
8414 notify = function () {
8415 process.nextTick(flush);
8416 };
8417 // browsers with MutationObserver, except iOS Safari - https://github.com/zloirock/core-js/issues/339
8418 } else if (Observer && !(global.navigator && global.navigator.standalone)) {
8419 var toggle = true;
8420 var node = document.createTextNode('');
8421 new Observer(flush).observe(node, { characterData: true }); // eslint-disable-line no-new
8422 notify = function () {
8423 node.data = toggle = !toggle;
8424 };
8425 // environments with maybe non-completely correct, but existent Promise
8426 } else if (Promise && Promise.resolve) {
8427 // Promise.resolve without an argument throws an error in LG WebOS 2
8428 var promise = Promise.resolve(undefined);
8429 notify = function () {
8430 promise.then(flush);
8431 };
8432 // for other environments - macrotask based on:
8433 // - setImmediate
8434 // - MessageChannel
8435 // - window.postMessag
8436 // - onreadystatechange
8437 // - setTimeout
8438 } else {
8439 notify = function () {
8440 // strange IE + webpack dev server bug - use .call(global)
8441 macrotask.call(global, flush);
8442 };
8443 }
8444
8445 return function (fn) {
8446 var task = { fn: fn, next: undefined };
8447 if (last) last.next = task;
8448 if (!head) {
8449 head = task;
8450 notify();
8451 } last = task;
8452 };
8453};
8454
8455},{"./_cof":95,"./_global":107,"./_task":152}],126:[function(require,module,exports){
8456'use strict';
8457// 25.4.1.5 NewPromiseCapability(C)
8458var aFunction = require('./_a-function');
8459
8460function PromiseCapability(C) {
8461 var resolve, reject;
8462 this.promise = new C(function ($$resolve, $$reject) {
8463 if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
8464 resolve = $$resolve;
8465 reject = $$reject;
8466 });
8467 this.resolve = aFunction(resolve);
8468 this.reject = aFunction(reject);
8469}
8470
8471module.exports.f = function (C) {
8472 return new PromiseCapability(C);
8473};
8474
8475},{"./_a-function":89}],127:[function(require,module,exports){
8476'use strict';
8477// 19.1.2.1 Object.assign(target, source, ...)
8478var getKeys = require('./_object-keys');
8479var gOPS = require('./_object-gops');
8480var pIE = require('./_object-pie');
8481var toObject = require('./_to-object');
8482var IObject = require('./_iobject');
8483var $assign = Object.assign;
8484
8485// should work with symbols and should have deterministic property order (V8 bug)
8486module.exports = !$assign || require('./_fails')(function () {
8487 var A = {};
8488 var B = {};
8489 // eslint-disable-next-line no-undef
8490 var S = Symbol();
8491 var K = 'abcdefghijklmnopqrst';
8492 A[S] = 7;
8493 K.split('').forEach(function (k) { B[k] = k; });
8494 return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
8495}) ? function assign(target, source) { // eslint-disable-line no-unused-vars
8496 var T = toObject(target);
8497 var aLen = arguments.length;
8498 var index = 1;
8499 var getSymbols = gOPS.f;
8500 var isEnum = pIE.f;
8501 while (aLen > index) {
8502 var S = IObject(arguments[index++]);
8503 var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S);
8504 var length = keys.length;
8505 var j = 0;
8506 var key;
8507 while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key];
8508 } return T;
8509} : $assign;
8510
8511},{"./_fails":105,"./_iobject":113,"./_object-gops":134,"./_object-keys":137,"./_object-pie":138,"./_to-object":157}],128:[function(require,module,exports){
8512// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
8513var anObject = require('./_an-object');
8514var dPs = require('./_object-dps');
8515var enumBugKeys = require('./_enum-bug-keys');
8516var IE_PROTO = require('./_shared-key')('IE_PROTO');
8517var Empty = function () { /* empty */ };
8518var PROTOTYPE = 'prototype';
8519
8520// Create object with fake `null` prototype: use iframe Object with cleared prototype
8521var createDict = function () {
8522 // Thrash, waste and sodomy: IE GC bug
8523 var iframe = require('./_dom-create')('iframe');
8524 var i = enumBugKeys.length;
8525 var lt = '<';
8526 var gt = '>';
8527 var iframeDocument;
8528 iframe.style.display = 'none';
8529 require('./_html').appendChild(iframe);
8530 iframe.src = 'javascript:'; // eslint-disable-line no-script-url
8531 // createDict = iframe.contentWindow.Object;
8532 // html.removeChild(iframe);
8533 iframeDocument = iframe.contentWindow.document;
8534 iframeDocument.open();
8535 iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
8536 iframeDocument.close();
8537 createDict = iframeDocument.F;
8538 while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]];
8539 return createDict();
8540};
8541
8542module.exports = Object.create || function create(O, Properties) {
8543 var result;
8544 if (O !== null) {
8545 Empty[PROTOTYPE] = anObject(O);
8546 result = new Empty();
8547 Empty[PROTOTYPE] = null;
8548 // add "__proto__" for Object.getPrototypeOf polyfill
8549 result[IE_PROTO] = O;
8550 } else result = createDict();
8551 return Properties === undefined ? result : dPs(result, Properties);
8552};
8553
8554},{"./_an-object":92,"./_dom-create":101,"./_enum-bug-keys":102,"./_html":110,"./_object-dps":130,"./_shared-key":148}],129:[function(require,module,exports){
8555var anObject = require('./_an-object');
8556var IE8_DOM_DEFINE = require('./_ie8-dom-define');
8557var toPrimitive = require('./_to-primitive');
8558var dP = Object.defineProperty;
8559
8560exports.f = require('./_descriptors') ? Object.defineProperty : function defineProperty(O, P, Attributes) {
8561 anObject(O);
8562 P = toPrimitive(P, true);
8563 anObject(Attributes);
8564 if (IE8_DOM_DEFINE) try {
8565 return dP(O, P, Attributes);
8566 } catch (e) { /* empty */ }
8567 if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
8568 if ('value' in Attributes) O[P] = Attributes.value;
8569 return O;
8570};
8571
8572},{"./_an-object":92,"./_descriptors":100,"./_ie8-dom-define":111,"./_to-primitive":158}],130:[function(require,module,exports){
8573var dP = require('./_object-dp');
8574var anObject = require('./_an-object');
8575var getKeys = require('./_object-keys');
8576
8577module.exports = require('./_descriptors') ? Object.defineProperties : function defineProperties(O, Properties) {
8578 anObject(O);
8579 var keys = getKeys(Properties);
8580 var length = keys.length;
8581 var i = 0;
8582 var P;
8583 while (length > i) dP.f(O, P = keys[i++], Properties[P]);
8584 return O;
8585};
8586
8587},{"./_an-object":92,"./_descriptors":100,"./_object-dp":129,"./_object-keys":137}],131:[function(require,module,exports){
8588var pIE = require('./_object-pie');
8589var createDesc = require('./_property-desc');
8590var toIObject = require('./_to-iobject');
8591var toPrimitive = require('./_to-primitive');
8592var has = require('./_has');
8593var IE8_DOM_DEFINE = require('./_ie8-dom-define');
8594var gOPD = Object.getOwnPropertyDescriptor;
8595
8596exports.f = require('./_descriptors') ? gOPD : function getOwnPropertyDescriptor(O, P) {
8597 O = toIObject(O);
8598 P = toPrimitive(P, true);
8599 if (IE8_DOM_DEFINE) try {
8600 return gOPD(O, P);
8601 } catch (e) { /* empty */ }
8602 if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]);
8603};
8604
8605},{"./_descriptors":100,"./_has":108,"./_ie8-dom-define":111,"./_object-pie":138,"./_property-desc":143,"./_to-iobject":155,"./_to-primitive":158}],132:[function(require,module,exports){
8606// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
8607var toIObject = require('./_to-iobject');
8608var gOPN = require('./_object-gopn').f;
8609var toString = {}.toString;
8610
8611var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
8612 ? Object.getOwnPropertyNames(window) : [];
8613
8614var getWindowNames = function (it) {
8615 try {
8616 return gOPN(it);
8617 } catch (e) {
8618 return windowNames.slice();
8619 }
8620};
8621
8622module.exports.f = function getOwnPropertyNames(it) {
8623 return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it));
8624};
8625
8626},{"./_object-gopn":133,"./_to-iobject":155}],133:[function(require,module,exports){
8627// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
8628var $keys = require('./_object-keys-internal');
8629var hiddenKeys = require('./_enum-bug-keys').concat('length', 'prototype');
8630
8631exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
8632 return $keys(O, hiddenKeys);
8633};
8634
8635},{"./_enum-bug-keys":102,"./_object-keys-internal":136}],134:[function(require,module,exports){
8636exports.f = Object.getOwnPropertySymbols;
8637
8638},{}],135:[function(require,module,exports){
8639// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
8640var has = require('./_has');
8641var toObject = require('./_to-object');
8642var IE_PROTO = require('./_shared-key')('IE_PROTO');
8643var ObjectProto = Object.prototype;
8644
8645module.exports = Object.getPrototypeOf || function (O) {
8646 O = toObject(O);
8647 if (has(O, IE_PROTO)) return O[IE_PROTO];
8648 if (typeof O.constructor == 'function' && O instanceof O.constructor) {
8649 return O.constructor.prototype;
8650 } return O instanceof Object ? ObjectProto : null;
8651};
8652
8653},{"./_has":108,"./_shared-key":148,"./_to-object":157}],136:[function(require,module,exports){
8654var has = require('./_has');
8655var toIObject = require('./_to-iobject');
8656var arrayIndexOf = require('./_array-includes')(false);
8657var IE_PROTO = require('./_shared-key')('IE_PROTO');
8658
8659module.exports = function (object, names) {
8660 var O = toIObject(object);
8661 var i = 0;
8662 var result = [];
8663 var key;
8664 for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key);
8665 // Don't enum bug & hidden keys
8666 while (names.length > i) if (has(O, key = names[i++])) {
8667 ~arrayIndexOf(result, key) || result.push(key);
8668 }
8669 return result;
8670};
8671
8672},{"./_array-includes":93,"./_has":108,"./_shared-key":148,"./_to-iobject":155}],137:[function(require,module,exports){
8673// 19.1.2.14 / 15.2.3.14 Object.keys(O)
8674var $keys = require('./_object-keys-internal');
8675var enumBugKeys = require('./_enum-bug-keys');
8676
8677module.exports = Object.keys || function keys(O) {
8678 return $keys(O, enumBugKeys);
8679};
8680
8681},{"./_enum-bug-keys":102,"./_object-keys-internal":136}],138:[function(require,module,exports){
8682exports.f = {}.propertyIsEnumerable;
8683
8684},{}],139:[function(require,module,exports){
8685// most Object methods by ES6 should accept primitives
8686var $export = require('./_export');
8687var core = require('./_core');
8688var fails = require('./_fails');
8689module.exports = function (KEY, exec) {
8690 var fn = (core.Object || {})[KEY] || Object[KEY];
8691 var exp = {};
8692 exp[KEY] = exec(fn);
8693 $export($export.S + $export.F * fails(function () { fn(1); }), 'Object', exp);
8694};
8695
8696},{"./_core":96,"./_export":104,"./_fails":105}],140:[function(require,module,exports){
8697var getKeys = require('./_object-keys');
8698var toIObject = require('./_to-iobject');
8699var isEnum = require('./_object-pie').f;
8700module.exports = function (isEntries) {
8701 return function (it) {
8702 var O = toIObject(it);
8703 var keys = getKeys(O);
8704 var length = keys.length;
8705 var i = 0;
8706 var result = [];
8707 var key;
8708 while (length > i) if (isEnum.call(O, key = keys[i++])) {
8709 result.push(isEntries ? [key, O[key]] : O[key]);
8710 } return result;
8711 };
8712};
8713
8714},{"./_object-keys":137,"./_object-pie":138,"./_to-iobject":155}],141:[function(require,module,exports){
8715module.exports = function (exec) {
8716 try {
8717 return { e: false, v: exec() };
8718 } catch (e) {
8719 return { e: true, v: e };
8720 }
8721};
8722
8723},{}],142:[function(require,module,exports){
8724var anObject = require('./_an-object');
8725var isObject = require('./_is-object');
8726var newPromiseCapability = require('./_new-promise-capability');
8727
8728module.exports = function (C, x) {
8729 anObject(C);
8730 if (isObject(x) && x.constructor === C) return x;
8731 var promiseCapability = newPromiseCapability.f(C);
8732 var resolve = promiseCapability.resolve;
8733 resolve(x);
8734 return promiseCapability.promise;
8735};
8736
8737},{"./_an-object":92,"./_is-object":116,"./_new-promise-capability":126}],143:[function(require,module,exports){
8738module.exports = function (bitmap, value) {
8739 return {
8740 enumerable: !(bitmap & 1),
8741 configurable: !(bitmap & 2),
8742 writable: !(bitmap & 4),
8743 value: value
8744 };
8745};
8746
8747},{}],144:[function(require,module,exports){
8748var hide = require('./_hide');
8749module.exports = function (target, src, safe) {
8750 for (var key in src) {
8751 if (safe && target[key]) target[key] = src[key];
8752 else hide(target, key, src[key]);
8753 } return target;
8754};
8755
8756},{"./_hide":109}],145:[function(require,module,exports){
8757module.exports = require('./_hide');
8758
8759},{"./_hide":109}],146:[function(require,module,exports){
8760'use strict';
8761var global = require('./_global');
8762var core = require('./_core');
8763var dP = require('./_object-dp');
8764var DESCRIPTORS = require('./_descriptors');
8765var SPECIES = require('./_wks')('species');
8766
8767module.exports = function (KEY) {
8768 var C = typeof core[KEY] == 'function' ? core[KEY] : global[KEY];
8769 if (DESCRIPTORS && C && !C[SPECIES]) dP.f(C, SPECIES, {
8770 configurable: true,
8771 get: function () { return this; }
8772 });
8773};
8774
8775},{"./_core":96,"./_descriptors":100,"./_global":107,"./_object-dp":129,"./_wks":163}],147:[function(require,module,exports){
8776var def = require('./_object-dp').f;
8777var has = require('./_has');
8778var TAG = require('./_wks')('toStringTag');
8779
8780module.exports = function (it, tag, stat) {
8781 if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });
8782};
8783
8784},{"./_has":108,"./_object-dp":129,"./_wks":163}],148:[function(require,module,exports){
8785var shared = require('./_shared')('keys');
8786var uid = require('./_uid');
8787module.exports = function (key) {
8788 return shared[key] || (shared[key] = uid(key));
8789};
8790
8791},{"./_shared":149,"./_uid":159}],149:[function(require,module,exports){
8792var core = require('./_core');
8793var global = require('./_global');
8794var SHARED = '__core-js_shared__';
8795var store = global[SHARED] || (global[SHARED] = {});
8796
8797(module.exports = function (key, value) {
8798 return store[key] || (store[key] = value !== undefined ? value : {});
8799})('versions', []).push({
8800 version: core.version,
8801 mode: require('./_library') ? 'pure' : 'global',
8802 copyright: '© 2018 Denis Pushkarev (zloirock.ru)'
8803});
8804
8805},{"./_core":96,"./_global":107,"./_library":123}],150:[function(require,module,exports){
8806// 7.3.20 SpeciesConstructor(O, defaultConstructor)
8807var anObject = require('./_an-object');
8808var aFunction = require('./_a-function');
8809var SPECIES = require('./_wks')('species');
8810module.exports = function (O, D) {
8811 var C = anObject(O).constructor;
8812 var S;
8813 return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);
8814};
8815
8816},{"./_a-function":89,"./_an-object":92,"./_wks":163}],151:[function(require,module,exports){
8817var toInteger = require('./_to-integer');
8818var defined = require('./_defined');
8819// true -> String#at
8820// false -> String#codePointAt
8821module.exports = function (TO_STRING) {
8822 return function (that, pos) {
8823 var s = String(defined(that));
8824 var i = toInteger(pos);
8825 var l = s.length;
8826 var a, b;
8827 if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
8828 a = s.charCodeAt(i);
8829 return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
8830 ? TO_STRING ? s.charAt(i) : a
8831 : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
8832 };
8833};
8834
8835},{"./_defined":99,"./_to-integer":154}],152:[function(require,module,exports){
8836var ctx = require('./_ctx');
8837var invoke = require('./_invoke');
8838var html = require('./_html');
8839var cel = require('./_dom-create');
8840var global = require('./_global');
8841var process = global.process;
8842var setTask = global.setImmediate;
8843var clearTask = global.clearImmediate;
8844var MessageChannel = global.MessageChannel;
8845var Dispatch = global.Dispatch;
8846var counter = 0;
8847var queue = {};
8848var ONREADYSTATECHANGE = 'onreadystatechange';
8849var defer, channel, port;
8850var run = function () {
8851 var id = +this;
8852 // eslint-disable-next-line no-prototype-builtins
8853 if (queue.hasOwnProperty(id)) {
8854 var fn = queue[id];
8855 delete queue[id];
8856 fn();
8857 }
8858};
8859var listener = function (event) {
8860 run.call(event.data);
8861};
8862// Node.js 0.9+ & IE10+ has setImmediate, otherwise:
8863if (!setTask || !clearTask) {
8864 setTask = function setImmediate(fn) {
8865 var args = [];
8866 var i = 1;
8867 while (arguments.length > i) args.push(arguments[i++]);
8868 queue[++counter] = function () {
8869 // eslint-disable-next-line no-new-func
8870 invoke(typeof fn == 'function' ? fn : Function(fn), args);
8871 };
8872 defer(counter);
8873 return counter;
8874 };
8875 clearTask = function clearImmediate(id) {
8876 delete queue[id];
8877 };
8878 // Node.js 0.8-
8879 if (require('./_cof')(process) == 'process') {
8880 defer = function (id) {
8881 process.nextTick(ctx(run, id, 1));
8882 };
8883 // Sphere (JS game engine) Dispatch API
8884 } else if (Dispatch && Dispatch.now) {
8885 defer = function (id) {
8886 Dispatch.now(ctx(run, id, 1));
8887 };
8888 // Browsers with MessageChannel, includes WebWorkers
8889 } else if (MessageChannel) {
8890 channel = new MessageChannel();
8891 port = channel.port2;
8892 channel.port1.onmessage = listener;
8893 defer = ctx(port.postMessage, port, 1);
8894 // Browsers with postMessage, skip WebWorkers
8895 // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
8896 } else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts) {
8897 defer = function (id) {
8898 global.postMessage(id + '', '*');
8899 };
8900 global.addEventListener('message', listener, false);
8901 // IE8-
8902 } else if (ONREADYSTATECHANGE in cel('script')) {
8903 defer = function (id) {
8904 html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function () {
8905 html.removeChild(this);
8906 run.call(id);
8907 };
8908 };
8909 // Rest old browsers
8910 } else {
8911 defer = function (id) {
8912 setTimeout(ctx(run, id, 1), 0);
8913 };
8914 }
8915}
8916module.exports = {
8917 set: setTask,
8918 clear: clearTask
8919};
8920
8921},{"./_cof":95,"./_ctx":98,"./_dom-create":101,"./_global":107,"./_html":110,"./_invoke":112}],153:[function(require,module,exports){
8922var toInteger = require('./_to-integer');
8923var max = Math.max;
8924var min = Math.min;
8925module.exports = function (index, length) {
8926 index = toInteger(index);
8927 return index < 0 ? max(index + length, 0) : min(index, length);
8928};
8929
8930},{"./_to-integer":154}],154:[function(require,module,exports){
8931// 7.1.4 ToInteger
8932var ceil = Math.ceil;
8933var floor = Math.floor;
8934module.exports = function (it) {
8935 return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
8936};
8937
8938},{}],155:[function(require,module,exports){
8939// to indexed object, toObject with fallback for non-array-like ES3 strings
8940var IObject = require('./_iobject');
8941var defined = require('./_defined');
8942module.exports = function (it) {
8943 return IObject(defined(it));
8944};
8945
8946},{"./_defined":99,"./_iobject":113}],156:[function(require,module,exports){
8947// 7.1.15 ToLength
8948var toInteger = require('./_to-integer');
8949var min = Math.min;
8950module.exports = function (it) {
8951 return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
8952};
8953
8954},{"./_to-integer":154}],157:[function(require,module,exports){
8955// 7.1.13 ToObject(argument)
8956var defined = require('./_defined');
8957module.exports = function (it) {
8958 return Object(defined(it));
8959};
8960
8961},{"./_defined":99}],158:[function(require,module,exports){
8962// 7.1.1 ToPrimitive(input [, PreferredType])
8963var isObject = require('./_is-object');
8964// instead of the ES6 spec version, we didn't implement @@toPrimitive case
8965// and the second argument - flag - preferred type is a string
8966module.exports = function (it, S) {
8967 if (!isObject(it)) return it;
8968 var fn, val;
8969 if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
8970 if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
8971 if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
8972 throw TypeError("Can't convert object to primitive value");
8973};
8974
8975},{"./_is-object":116}],159:[function(require,module,exports){
8976var id = 0;
8977var px = Math.random();
8978module.exports = function (key) {
8979 return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
8980};
8981
8982},{}],160:[function(require,module,exports){
8983var global = require('./_global');
8984var navigator = global.navigator;
8985
8986module.exports = navigator && navigator.userAgent || '';
8987
8988},{"./_global":107}],161:[function(require,module,exports){
8989var global = require('./_global');
8990var core = require('./_core');
8991var LIBRARY = require('./_library');
8992var wksExt = require('./_wks-ext');
8993var defineProperty = require('./_object-dp').f;
8994module.exports = function (name) {
8995 var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});
8996 if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: wksExt.f(name) });
8997};
8998
8999},{"./_core":96,"./_global":107,"./_library":123,"./_object-dp":129,"./_wks-ext":162}],162:[function(require,module,exports){
9000exports.f = require('./_wks');
9001
9002},{"./_wks":163}],163:[function(require,module,exports){
9003var store = require('./_shared')('wks');
9004var uid = require('./_uid');
9005var Symbol = require('./_global').Symbol;
9006var USE_SYMBOL = typeof Symbol == 'function';
9007
9008var $exports = module.exports = function (name) {
9009 return store[name] || (store[name] =
9010 USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
9011};
9012
9013$exports.store = store;
9014
9015},{"./_global":107,"./_shared":149,"./_uid":159}],164:[function(require,module,exports){
9016var classof = require('./_classof');
9017var ITERATOR = require('./_wks')('iterator');
9018var Iterators = require('./_iterators');
9019module.exports = require('./_core').getIteratorMethod = function (it) {
9020 if (it != undefined) return it[ITERATOR]
9021 || it['@@iterator']
9022 || Iterators[classof(it)];
9023};
9024
9025},{"./_classof":94,"./_core":96,"./_iterators":122,"./_wks":163}],165:[function(require,module,exports){
9026'use strict';
9027var ctx = require('./_ctx');
9028var $export = require('./_export');
9029var toObject = require('./_to-object');
9030var call = require('./_iter-call');
9031var isArrayIter = require('./_is-array-iter');
9032var toLength = require('./_to-length');
9033var createProperty = require('./_create-property');
9034var getIterFn = require('./core.get-iterator-method');
9035
9036$export($export.S + $export.F * !require('./_iter-detect')(function (iter) { Array.from(iter); }), 'Array', {
9037 // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
9038 from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
9039 var O = toObject(arrayLike);
9040 var C = typeof this == 'function' ? this : Array;
9041 var aLen = arguments.length;
9042 var mapfn = aLen > 1 ? arguments[1] : undefined;
9043 var mapping = mapfn !== undefined;
9044 var index = 0;
9045 var iterFn = getIterFn(O);
9046 var length, result, step, iterator;
9047 if (mapping) mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
9048 // if object isn't iterable or it's array with default iterator - use simple case
9049 if (iterFn != undefined && !(C == Array && isArrayIter(iterFn))) {
9050 for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) {
9051 createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value);
9052 }
9053 } else {
9054 length = toLength(O.length);
9055 for (result = new C(length); length > index; index++) {
9056 createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
9057 }
9058 }
9059 result.length = index;
9060 return result;
9061 }
9062});
9063
9064},{"./_create-property":97,"./_ctx":98,"./_export":104,"./_is-array-iter":114,"./_iter-call":117,"./_iter-detect":120,"./_to-length":156,"./_to-object":157,"./core.get-iterator-method":164}],166:[function(require,module,exports){
9065'use strict';
9066var addToUnscopables = require('./_add-to-unscopables');
9067var step = require('./_iter-step');
9068var Iterators = require('./_iterators');
9069var toIObject = require('./_to-iobject');
9070
9071// 22.1.3.4 Array.prototype.entries()
9072// 22.1.3.13 Array.prototype.keys()
9073// 22.1.3.29 Array.prototype.values()
9074// 22.1.3.30 Array.prototype[@@iterator]()
9075module.exports = require('./_iter-define')(Array, 'Array', function (iterated, kind) {
9076 this._t = toIObject(iterated); // target
9077 this._i = 0; // next index
9078 this._k = kind; // kind
9079// 22.1.5.2.1 %ArrayIteratorPrototype%.next()
9080}, function () {
9081 var O = this._t;
9082 var kind = this._k;
9083 var index = this._i++;
9084 if (!O || index >= O.length) {
9085 this._t = undefined;
9086 return step(1);
9087 }
9088 if (kind == 'keys') return step(0, index);
9089 if (kind == 'values') return step(0, O[index]);
9090 return step(0, [index, O[index]]);
9091}, 'values');
9092
9093// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
9094Iterators.Arguments = Iterators.Array;
9095
9096addToUnscopables('keys');
9097addToUnscopables('values');
9098addToUnscopables('entries');
9099
9100},{"./_add-to-unscopables":90,"./_iter-define":119,"./_iter-step":121,"./_iterators":122,"./_to-iobject":155}],167:[function(require,module,exports){
9101'use strict';
9102var isObject = require('./_is-object');
9103var getPrototypeOf = require('./_object-gpo');
9104var HAS_INSTANCE = require('./_wks')('hasInstance');
9105var FunctionProto = Function.prototype;
9106// 19.2.3.6 Function.prototype[@@hasInstance](V)
9107if (!(HAS_INSTANCE in FunctionProto)) require('./_object-dp').f(FunctionProto, HAS_INSTANCE, { value: function (O) {
9108 if (typeof this != 'function' || !isObject(O)) return false;
9109 if (!isObject(this.prototype)) return O instanceof this;
9110 // for environment w/o native `@@hasInstance` logic enough `instanceof`, but add this:
9111 while (O = getPrototypeOf(O)) if (this.prototype === O) return true;
9112 return false;
9113} });
9114
9115},{"./_is-object":116,"./_object-dp":129,"./_object-gpo":135,"./_wks":163}],168:[function(require,module,exports){
9116// 19.1.3.1 Object.assign(target, source)
9117var $export = require('./_export');
9118
9119$export($export.S + $export.F, 'Object', { assign: require('./_object-assign') });
9120
9121},{"./_export":104,"./_object-assign":127}],169:[function(require,module,exports){
9122var $export = require('./_export');
9123// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
9124$export($export.S, 'Object', { create: require('./_object-create') });
9125
9126},{"./_export":104,"./_object-create":128}],170:[function(require,module,exports){
9127var $export = require('./_export');
9128// 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
9129$export($export.S + $export.F * !require('./_descriptors'), 'Object', { defineProperty: require('./_object-dp').f });
9130
9131},{"./_descriptors":100,"./_export":104,"./_object-dp":129}],171:[function(require,module,exports){
9132// 19.1.2.7 Object.getOwnPropertyNames(O)
9133require('./_object-sap')('getOwnPropertyNames', function () {
9134 return require('./_object-gopn-ext').f;
9135});
9136
9137},{"./_object-gopn-ext":132,"./_object-sap":139}],172:[function(require,module,exports){
9138// 19.1.2.9 Object.getPrototypeOf(O)
9139var toObject = require('./_to-object');
9140var $getPrototypeOf = require('./_object-gpo');
9141
9142require('./_object-sap')('getPrototypeOf', function () {
9143 return function getPrototypeOf(it) {
9144 return $getPrototypeOf(toObject(it));
9145 };
9146});
9147
9148},{"./_object-gpo":135,"./_object-sap":139,"./_to-object":157}],173:[function(require,module,exports){
9149// 19.1.2.14 Object.keys(O)
9150var toObject = require('./_to-object');
9151var $keys = require('./_object-keys');
9152
9153require('./_object-sap')('keys', function () {
9154 return function keys(it) {
9155 return $keys(toObject(it));
9156 };
9157});
9158
9159},{"./_object-keys":137,"./_object-sap":139,"./_to-object":157}],174:[function(require,module,exports){
9160arguments[4][68][0].apply(exports,arguments)
9161},{"dup":68}],175:[function(require,module,exports){
9162'use strict';
9163var LIBRARY = require('./_library');
9164var global = require('./_global');
9165var ctx = require('./_ctx');
9166var classof = require('./_classof');
9167var $export = require('./_export');
9168var isObject = require('./_is-object');
9169var aFunction = require('./_a-function');
9170var anInstance = require('./_an-instance');
9171var forOf = require('./_for-of');
9172var speciesConstructor = require('./_species-constructor');
9173var task = require('./_task').set;
9174var microtask = require('./_microtask')();
9175var newPromiseCapabilityModule = require('./_new-promise-capability');
9176var perform = require('./_perform');
9177var userAgent = require('./_user-agent');
9178var promiseResolve = require('./_promise-resolve');
9179var PROMISE = 'Promise';
9180var TypeError = global.TypeError;
9181var process = global.process;
9182var versions = process && process.versions;
9183var v8 = versions && versions.v8 || '';
9184var $Promise = global[PROMISE];
9185var isNode = classof(process) == 'process';
9186var empty = function () { /* empty */ };
9187var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper;
9188var newPromiseCapability = newGenericPromiseCapability = newPromiseCapabilityModule.f;
9189
9190var USE_NATIVE = !!function () {
9191 try {
9192 // correct subclassing with @@species support
9193 var promise = $Promise.resolve(1);
9194 var FakePromise = (promise.constructor = {})[require('./_wks')('species')] = function (exec) {
9195 exec(empty, empty);
9196 };
9197 // unhandled rejections tracking support, NodeJS Promise without it fails @@species test
9198 return (isNode || typeof PromiseRejectionEvent == 'function')
9199 && promise.then(empty) instanceof FakePromise
9200 // v8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
9201 // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
9202 // we can't detect it synchronously, so just check versions
9203 && v8.indexOf('6.6') !== 0
9204 && userAgent.indexOf('Chrome/66') === -1;
9205 } catch (e) { /* empty */ }
9206}();
9207
9208// helpers
9209var isThenable = function (it) {
9210 var then;
9211 return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
9212};
9213var notify = function (promise, isReject) {
9214 if (promise._n) return;
9215 promise._n = true;
9216 var chain = promise._c;
9217 microtask(function () {
9218 var value = promise._v;
9219 var ok = promise._s == 1;
9220 var i = 0;
9221 var run = function (reaction) {
9222 var handler = ok ? reaction.ok : reaction.fail;
9223 var resolve = reaction.resolve;
9224 var reject = reaction.reject;
9225 var domain = reaction.domain;
9226 var result, then, exited;
9227 try {
9228 if (handler) {
9229 if (!ok) {
9230 if (promise._h == 2) onHandleUnhandled(promise);
9231 promise._h = 1;
9232 }
9233 if (handler === true) result = value;
9234 else {
9235 if (domain) domain.enter();
9236 result = handler(value); // may throw
9237 if (domain) {
9238 domain.exit();
9239 exited = true;
9240 }
9241 }
9242 if (result === reaction.promise) {
9243 reject(TypeError('Promise-chain cycle'));
9244 } else if (then = isThenable(result)) {
9245 then.call(result, resolve, reject);
9246 } else resolve(result);
9247 } else reject(value);
9248 } catch (e) {
9249 if (domain && !exited) domain.exit();
9250 reject(e);
9251 }
9252 };
9253 while (chain.length > i) run(chain[i++]); // variable length - can't use forEach
9254 promise._c = [];
9255 promise._n = false;
9256 if (isReject && !promise._h) onUnhandled(promise);
9257 });
9258};
9259var onUnhandled = function (promise) {
9260 task.call(global, function () {
9261 var value = promise._v;
9262 var unhandled = isUnhandled(promise);
9263 var result, handler, console;
9264 if (unhandled) {
9265 result = perform(function () {
9266 if (isNode) {
9267 process.emit('unhandledRejection', value, promise);
9268 } else if (handler = global.onunhandledrejection) {
9269 handler({ promise: promise, reason: value });
9270 } else if ((console = global.console) && console.error) {
9271 console.error('Unhandled promise rejection', value);
9272 }
9273 });
9274 // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
9275 promise._h = isNode || isUnhandled(promise) ? 2 : 1;
9276 } promise._a = undefined;
9277 if (unhandled && result.e) throw result.v;
9278 });
9279};
9280var isUnhandled = function (promise) {
9281 return promise._h !== 1 && (promise._a || promise._c).length === 0;
9282};
9283var onHandleUnhandled = function (promise) {
9284 task.call(global, function () {
9285 var handler;
9286 if (isNode) {
9287 process.emit('rejectionHandled', promise);
9288 } else if (handler = global.onrejectionhandled) {
9289 handler({ promise: promise, reason: promise._v });
9290 }
9291 });
9292};
9293var $reject = function (value) {
9294 var promise = this;
9295 if (promise._d) return;
9296 promise._d = true;
9297 promise = promise._w || promise; // unwrap
9298 promise._v = value;
9299 promise._s = 2;
9300 if (!promise._a) promise._a = promise._c.slice();
9301 notify(promise, true);
9302};
9303var $resolve = function (value) {
9304 var promise = this;
9305 var then;
9306 if (promise._d) return;
9307 promise._d = true;
9308 promise = promise._w || promise; // unwrap
9309 try {
9310 if (promise === value) throw TypeError("Promise can't be resolved itself");
9311 if (then = isThenable(value)) {
9312 microtask(function () {
9313 var wrapper = { _w: promise, _d: false }; // wrap
9314 try {
9315 then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
9316 } catch (e) {
9317 $reject.call(wrapper, e);
9318 }
9319 });
9320 } else {
9321 promise._v = value;
9322 promise._s = 1;
9323 notify(promise, false);
9324 }
9325 } catch (e) {
9326 $reject.call({ _w: promise, _d: false }, e); // wrap
9327 }
9328};
9329
9330// constructor polyfill
9331if (!USE_NATIVE) {
9332 // 25.4.3.1 Promise(executor)
9333 $Promise = function Promise(executor) {
9334 anInstance(this, $Promise, PROMISE, '_h');
9335 aFunction(executor);
9336 Internal.call(this);
9337 try {
9338 executor(ctx($resolve, this, 1), ctx($reject, this, 1));
9339 } catch (err) {
9340 $reject.call(this, err);
9341 }
9342 };
9343 // eslint-disable-next-line no-unused-vars
9344 Internal = function Promise(executor) {
9345 this._c = []; // <- awaiting reactions
9346 this._a = undefined; // <- checked in isUnhandled reactions
9347 this._s = 0; // <- state
9348 this._d = false; // <- done
9349 this._v = undefined; // <- value
9350 this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled
9351 this._n = false; // <- notify
9352 };
9353 Internal.prototype = require('./_redefine-all')($Promise.prototype, {
9354 // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
9355 then: function then(onFulfilled, onRejected) {
9356 var reaction = newPromiseCapability(speciesConstructor(this, $Promise));
9357 reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
9358 reaction.fail = typeof onRejected == 'function' && onRejected;
9359 reaction.domain = isNode ? process.domain : undefined;
9360 this._c.push(reaction);
9361 if (this._a) this._a.push(reaction);
9362 if (this._s) notify(this, false);
9363 return reaction.promise;
9364 },
9365 // 25.4.5.1 Promise.prototype.catch(onRejected)
9366 'catch': function (onRejected) {
9367 return this.then(undefined, onRejected);
9368 }
9369 });
9370 OwnPromiseCapability = function () {
9371 var promise = new Internal();
9372 this.promise = promise;
9373 this.resolve = ctx($resolve, promise, 1);
9374 this.reject = ctx($reject, promise, 1);
9375 };
9376 newPromiseCapabilityModule.f = newPromiseCapability = function (C) {
9377 return C === $Promise || C === Wrapper
9378 ? new OwnPromiseCapability(C)
9379 : newGenericPromiseCapability(C);
9380 };
9381}
9382
9383$export($export.G + $export.W + $export.F * !USE_NATIVE, { Promise: $Promise });
9384require('./_set-to-string-tag')($Promise, PROMISE);
9385require('./_set-species')(PROMISE);
9386Wrapper = require('./_core')[PROMISE];
9387
9388// statics
9389$export($export.S + $export.F * !USE_NATIVE, PROMISE, {
9390 // 25.4.4.5 Promise.reject(r)
9391 reject: function reject(r) {
9392 var capability = newPromiseCapability(this);
9393 var $$reject = capability.reject;
9394 $$reject(r);
9395 return capability.promise;
9396 }
9397});
9398$export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, {
9399 // 25.4.4.6 Promise.resolve(x)
9400 resolve: function resolve(x) {
9401 return promiseResolve(LIBRARY && this === Wrapper ? $Promise : this, x);
9402 }
9403});
9404$export($export.S + $export.F * !(USE_NATIVE && require('./_iter-detect')(function (iter) {
9405 $Promise.all(iter)['catch'](empty);
9406})), PROMISE, {
9407 // 25.4.4.1 Promise.all(iterable)
9408 all: function all(iterable) {
9409 var C = this;
9410 var capability = newPromiseCapability(C);
9411 var resolve = capability.resolve;
9412 var reject = capability.reject;
9413 var result = perform(function () {
9414 var values = [];
9415 var index = 0;
9416 var remaining = 1;
9417 forOf(iterable, false, function (promise) {
9418 var $index = index++;
9419 var alreadyCalled = false;
9420 values.push(undefined);
9421 remaining++;
9422 C.resolve(promise).then(function (value) {
9423 if (alreadyCalled) return;
9424 alreadyCalled = true;
9425 values[$index] = value;
9426 --remaining || resolve(values);
9427 }, reject);
9428 });
9429 --remaining || resolve(values);
9430 });
9431 if (result.e) reject(result.v);
9432 return capability.promise;
9433 },
9434 // 25.4.4.4 Promise.race(iterable)
9435 race: function race(iterable) {
9436 var C = this;
9437 var capability = newPromiseCapability(C);
9438 var reject = capability.reject;
9439 var result = perform(function () {
9440 forOf(iterable, false, function (promise) {
9441 C.resolve(promise).then(capability.resolve, reject);
9442 });
9443 });
9444 if (result.e) reject(result.v);
9445 return capability.promise;
9446 }
9447});
9448
9449},{"./_a-function":89,"./_an-instance":91,"./_classof":94,"./_core":96,"./_ctx":98,"./_export":104,"./_for-of":106,"./_global":107,"./_is-object":116,"./_iter-detect":120,"./_library":123,"./_microtask":125,"./_new-promise-capability":126,"./_perform":141,"./_promise-resolve":142,"./_redefine-all":144,"./_set-species":146,"./_set-to-string-tag":147,"./_species-constructor":150,"./_task":152,"./_user-agent":160,"./_wks":163}],176:[function(require,module,exports){
9450var $export = require('./_export');
9451var toAbsoluteIndex = require('./_to-absolute-index');
9452var fromCharCode = String.fromCharCode;
9453var $fromCodePoint = String.fromCodePoint;
9454
9455// length should be 1, old FF problem
9456$export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {
9457 // 21.1.2.2 String.fromCodePoint(...codePoints)
9458 fromCodePoint: function fromCodePoint(x) { // eslint-disable-line no-unused-vars
9459 var res = [];
9460 var aLen = arguments.length;
9461 var i = 0;
9462 var code;
9463 while (aLen > i) {
9464 code = +arguments[i++];
9465 if (toAbsoluteIndex(code, 0x10ffff) !== code) throw RangeError(code + ' is not a valid code point');
9466 res.push(code < 0x10000
9467 ? fromCharCode(code)
9468 : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)
9469 );
9470 } return res.join('');
9471 }
9472});
9473
9474},{"./_export":104,"./_to-absolute-index":153}],177:[function(require,module,exports){
9475'use strict';
9476var $at = require('./_string-at')(true);
9477
9478// 21.1.3.27 String.prototype[@@iterator]()
9479require('./_iter-define')(String, 'String', function (iterated) {
9480 this._t = String(iterated); // target
9481 this._i = 0; // next index
9482// 21.1.5.2.1 %StringIteratorPrototype%.next()
9483}, function () {
9484 var O = this._t;
9485 var index = this._i;
9486 var point;
9487 if (index >= O.length) return { value: undefined, done: true };
9488 point = $at(O, index);
9489 this._i += point.length;
9490 return { value: point, done: false };
9491});
9492
9493},{"./_iter-define":119,"./_string-at":151}],178:[function(require,module,exports){
9494'use strict';
9495// ECMAScript 6 symbols shim
9496var global = require('./_global');
9497var has = require('./_has');
9498var DESCRIPTORS = require('./_descriptors');
9499var $export = require('./_export');
9500var redefine = require('./_redefine');
9501var META = require('./_meta').KEY;
9502var $fails = require('./_fails');
9503var shared = require('./_shared');
9504var setToStringTag = require('./_set-to-string-tag');
9505var uid = require('./_uid');
9506var wks = require('./_wks');
9507var wksExt = require('./_wks-ext');
9508var wksDefine = require('./_wks-define');
9509var enumKeys = require('./_enum-keys');
9510var isArray = require('./_is-array');
9511var anObject = require('./_an-object');
9512var isObject = require('./_is-object');
9513var toIObject = require('./_to-iobject');
9514var toPrimitive = require('./_to-primitive');
9515var createDesc = require('./_property-desc');
9516var _create = require('./_object-create');
9517var gOPNExt = require('./_object-gopn-ext');
9518var $GOPD = require('./_object-gopd');
9519var $DP = require('./_object-dp');
9520var $keys = require('./_object-keys');
9521var gOPD = $GOPD.f;
9522var dP = $DP.f;
9523var gOPN = gOPNExt.f;
9524var $Symbol = global.Symbol;
9525var $JSON = global.JSON;
9526var _stringify = $JSON && $JSON.stringify;
9527var PROTOTYPE = 'prototype';
9528var HIDDEN = wks('_hidden');
9529var TO_PRIMITIVE = wks('toPrimitive');
9530var isEnum = {}.propertyIsEnumerable;
9531var SymbolRegistry = shared('symbol-registry');
9532var AllSymbols = shared('symbols');
9533var OPSymbols = shared('op-symbols');
9534var ObjectProto = Object[PROTOTYPE];
9535var USE_NATIVE = typeof $Symbol == 'function';
9536var QObject = global.QObject;
9537// Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
9538var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
9539
9540// fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
9541var setSymbolDesc = DESCRIPTORS && $fails(function () {
9542 return _create(dP({}, 'a', {
9543 get: function () { return dP(this, 'a', { value: 7 }).a; }
9544 })).a != 7;
9545}) ? function (it, key, D) {
9546 var protoDesc = gOPD(ObjectProto, key);
9547 if (protoDesc) delete ObjectProto[key];
9548 dP(it, key, D);
9549 if (protoDesc && it !== ObjectProto) dP(ObjectProto, key, protoDesc);
9550} : dP;
9551
9552var wrap = function (tag) {
9553 var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]);
9554 sym._k = tag;
9555 return sym;
9556};
9557
9558var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function (it) {
9559 return typeof it == 'symbol';
9560} : function (it) {
9561 return it instanceof $Symbol;
9562};
9563
9564var $defineProperty = function defineProperty(it, key, D) {
9565 if (it === ObjectProto) $defineProperty(OPSymbols, key, D);
9566 anObject(it);
9567 key = toPrimitive(key, true);
9568 anObject(D);
9569 if (has(AllSymbols, key)) {
9570 if (!D.enumerable) {
9571 if (!has(it, HIDDEN)) dP(it, HIDDEN, createDesc(1, {}));
9572 it[HIDDEN][key] = true;
9573 } else {
9574 if (has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false;
9575 D = _create(D, { enumerable: createDesc(0, false) });
9576 } return setSymbolDesc(it, key, D);
9577 } return dP(it, key, D);
9578};
9579var $defineProperties = function defineProperties(it, P) {
9580 anObject(it);
9581 var keys = enumKeys(P = toIObject(P));
9582 var i = 0;
9583 var l = keys.length;
9584 var key;
9585 while (l > i) $defineProperty(it, key = keys[i++], P[key]);
9586 return it;
9587};
9588var $create = function create(it, P) {
9589 return P === undefined ? _create(it) : $defineProperties(_create(it), P);
9590};
9591var $propertyIsEnumerable = function propertyIsEnumerable(key) {
9592 var E = isEnum.call(this, key = toPrimitive(key, true));
9593 if (this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return false;
9594 return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
9595};
9596var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) {
9597 it = toIObject(it);
9598 key = toPrimitive(key, true);
9599 if (it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return;
9600 var D = gOPD(it, key);
9601 if (D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true;
9602 return D;
9603};
9604var $getOwnPropertyNames = function getOwnPropertyNames(it) {
9605 var names = gOPN(toIObject(it));
9606 var result = [];
9607 var i = 0;
9608 var key;
9609 while (names.length > i) {
9610 if (!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key);
9611 } return result;
9612};
9613var $getOwnPropertySymbols = function getOwnPropertySymbols(it) {
9614 var IS_OP = it === ObjectProto;
9615 var names = gOPN(IS_OP ? OPSymbols : toIObject(it));
9616 var result = [];
9617 var i = 0;
9618 var key;
9619 while (names.length > i) {
9620 if (has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true)) result.push(AllSymbols[key]);
9621 } return result;
9622};
9623
9624// 19.4.1.1 Symbol([description])
9625if (!USE_NATIVE) {
9626 $Symbol = function Symbol() {
9627 if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!');
9628 var tag = uid(arguments.length > 0 ? arguments[0] : undefined);
9629 var $set = function (value) {
9630 if (this === ObjectProto) $set.call(OPSymbols, value);
9631 if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
9632 setSymbolDesc(this, tag, createDesc(1, value));
9633 };
9634 if (DESCRIPTORS && setter) setSymbolDesc(ObjectProto, tag, { configurable: true, set: $set });
9635 return wrap(tag);
9636 };
9637 redefine($Symbol[PROTOTYPE], 'toString', function toString() {
9638 return this._k;
9639 });
9640
9641 $GOPD.f = $getOwnPropertyDescriptor;
9642 $DP.f = $defineProperty;
9643 require('./_object-gopn').f = gOPNExt.f = $getOwnPropertyNames;
9644 require('./_object-pie').f = $propertyIsEnumerable;
9645 require('./_object-gops').f = $getOwnPropertySymbols;
9646
9647 if (DESCRIPTORS && !require('./_library')) {
9648 redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);
9649 }
9650
9651 wksExt.f = function (name) {
9652 return wrap(wks(name));
9653 };
9654}
9655
9656$export($export.G + $export.W + $export.F * !USE_NATIVE, { Symbol: $Symbol });
9657
9658for (var es6Symbols = (
9659 // 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14
9660 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'
9661).split(','), j = 0; es6Symbols.length > j;)wks(es6Symbols[j++]);
9662
9663for (var wellKnownSymbols = $keys(wks.store), k = 0; wellKnownSymbols.length > k;) wksDefine(wellKnownSymbols[k++]);
9664
9665$export($export.S + $export.F * !USE_NATIVE, 'Symbol', {
9666 // 19.4.2.1 Symbol.for(key)
9667 'for': function (key) {
9668 return has(SymbolRegistry, key += '')
9669 ? SymbolRegistry[key]
9670 : SymbolRegistry[key] = $Symbol(key);
9671 },
9672 // 19.4.2.5 Symbol.keyFor(sym)
9673 keyFor: function keyFor(sym) {
9674 if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!');
9675 for (var key in SymbolRegistry) if (SymbolRegistry[key] === sym) return key;
9676 },
9677 useSetter: function () { setter = true; },
9678 useSimple: function () { setter = false; }
9679});
9680
9681$export($export.S + $export.F * !USE_NATIVE, 'Object', {
9682 // 19.1.2.2 Object.create(O [, Properties])
9683 create: $create,
9684 // 19.1.2.4 Object.defineProperty(O, P, Attributes)
9685 defineProperty: $defineProperty,
9686 // 19.1.2.3 Object.defineProperties(O, Properties)
9687 defineProperties: $defineProperties,
9688 // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
9689 getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
9690 // 19.1.2.7 Object.getOwnPropertyNames(O)
9691 getOwnPropertyNames: $getOwnPropertyNames,
9692 // 19.1.2.8 Object.getOwnPropertySymbols(O)
9693 getOwnPropertySymbols: $getOwnPropertySymbols
9694});
9695
9696// 24.3.2 JSON.stringify(value [, replacer [, space]])
9697$JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function () {
9698 var S = $Symbol();
9699 // MS Edge converts symbol values to JSON as {}
9700 // WebKit converts symbol values to JSON as null
9701 // V8 throws on boxed symbols
9702 return _stringify([S]) != '[null]' || _stringify({ a: S }) != '{}' || _stringify(Object(S)) != '{}';
9703})), 'JSON', {
9704 stringify: function stringify(it) {
9705 var args = [it];
9706 var i = 1;
9707 var replacer, $replacer;
9708 while (arguments.length > i) args.push(arguments[i++]);
9709 $replacer = replacer = args[1];
9710 if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
9711 if (!isArray(replacer)) replacer = function (key, value) {
9712 if (typeof $replacer == 'function') value = $replacer.call(this, key, value);
9713 if (!isSymbol(value)) return value;
9714 };
9715 args[1] = replacer;
9716 return _stringify.apply($JSON, args);
9717 }
9718});
9719
9720// 19.4.3.4 Symbol.prototype[@@toPrimitive](hint)
9721$Symbol[PROTOTYPE][TO_PRIMITIVE] || require('./_hide')($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
9722// 19.4.3.5 Symbol.prototype[@@toStringTag]
9723setToStringTag($Symbol, 'Symbol');
9724// 20.2.1.9 Math[@@toStringTag]
9725setToStringTag(Math, 'Math', true);
9726// 24.3.3 JSON[@@toStringTag]
9727setToStringTag(global.JSON, 'JSON', true);
9728
9729},{"./_an-object":92,"./_descriptors":100,"./_enum-keys":103,"./_export":104,"./_fails":105,"./_global":107,"./_has":108,"./_hide":109,"./_is-array":115,"./_is-object":116,"./_library":123,"./_meta":124,"./_object-create":128,"./_object-dp":129,"./_object-gopd":131,"./_object-gopn":133,"./_object-gopn-ext":132,"./_object-gops":134,"./_object-keys":137,"./_object-pie":138,"./_property-desc":143,"./_redefine":145,"./_set-to-string-tag":147,"./_shared":149,"./_to-iobject":155,"./_to-primitive":158,"./_uid":159,"./_wks":163,"./_wks-define":161,"./_wks-ext":162}],179:[function(require,module,exports){
9730// https://github.com/tc39/proposal-object-values-entries
9731var $export = require('./_export');
9732var $entries = require('./_object-to-array')(true);
9733
9734$export($export.S, 'Object', {
9735 entries: function entries(it) {
9736 return $entries(it);
9737 }
9738});
9739
9740},{"./_export":104,"./_object-to-array":140}],180:[function(require,module,exports){
9741// https://github.com/tc39/proposal-promise-finally
9742'use strict';
9743var $export = require('./_export');
9744var core = require('./_core');
9745var global = require('./_global');
9746var speciesConstructor = require('./_species-constructor');
9747var promiseResolve = require('./_promise-resolve');
9748
9749$export($export.P + $export.R, 'Promise', { 'finally': function (onFinally) {
9750 var C = speciesConstructor(this, core.Promise || global.Promise);
9751 var isFunction = typeof onFinally == 'function';
9752 return this.then(
9753 isFunction ? function (x) {
9754 return promiseResolve(C, onFinally()).then(function () { return x; });
9755 } : onFinally,
9756 isFunction ? function (e) {
9757 return promiseResolve(C, onFinally()).then(function () { throw e; });
9758 } : onFinally
9759 );
9760} });
9761
9762},{"./_core":96,"./_export":104,"./_global":107,"./_promise-resolve":142,"./_species-constructor":150}],181:[function(require,module,exports){
9763'use strict';
9764// https://github.com/tc39/proposal-promise-try
9765var $export = require('./_export');
9766var newPromiseCapability = require('./_new-promise-capability');
9767var perform = require('./_perform');
9768
9769$export($export.S, 'Promise', { 'try': function (callbackfn) {
9770 var promiseCapability = newPromiseCapability.f(this);
9771 var result = perform(callbackfn);
9772 (result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v);
9773 return promiseCapability.promise;
9774} });
9775
9776},{"./_export":104,"./_new-promise-capability":126,"./_perform":141}],182:[function(require,module,exports){
9777require('./_wks-define')('asyncIterator');
9778
9779},{"./_wks-define":161}],183:[function(require,module,exports){
9780require('./_wks-define')('observable');
9781
9782},{"./_wks-define":161}],184:[function(require,module,exports){
9783require('./es6.array.iterator');
9784var global = require('./_global');
9785var hide = require('./_hide');
9786var Iterators = require('./_iterators');
9787var TO_STRING_TAG = require('./_wks')('toStringTag');
9788
9789var DOMIterables = ('CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,' +
9790 'DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,' +
9791 'MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,' +
9792 'SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,' +
9793 'TextTrackList,TouchList').split(',');
9794
9795for (var i = 0; i < DOMIterables.length; i++) {
9796 var NAME = DOMIterables[i];
9797 var Collection = global[NAME];
9798 var proto = Collection && Collection.prototype;
9799 if (proto && !proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME);
9800 Iterators[NAME] = Iterators.Array;
9801}
9802
9803},{"./_global":107,"./_hide":109,"./_iterators":122,"./_wks":163,"./es6.array.iterator":166}],185:[function(require,module,exports){
9804var $export = require('./_export');
9805var $task = require('./_task');
9806$export($export.G + $export.B, {
9807 setImmediate: $task.set,
9808 clearImmediate: $task.clear
9809});
9810
9811},{"./_export":104,"./_task":152}],186:[function(require,module,exports){
9812(function (Buffer){
9813'use strict';
9814
9815var _typeof2 = require('babel-runtime/helpers/typeof');
9816
9817var _typeof3 = _interopRequireDefault(_typeof2);
9818
9819function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9820
9821// Copyright Joyent, Inc. and other Node contributors.
9822//
9823// Permission is hereby granted, free of charge, to any person obtaining a
9824// copy of this software and associated documentation files (the
9825// "Software"), to deal in the Software without restriction, including
9826// without limitation the rights to use, copy, modify, merge, publish,
9827// distribute, sublicense, and/or sell copies of the Software, and to permit
9828// persons to whom the Software is furnished to do so, subject to the
9829// following conditions:
9830//
9831// The above copyright notice and this permission notice shall be included
9832// in all copies or substantial portions of the Software.
9833//
9834// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
9835// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
9836// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
9837// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
9838// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
9839// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
9840// USE OR OTHER DEALINGS IN THE SOFTWARE.
9841
9842// NOTE: These type checking functions intentionally don't use `instanceof`
9843// because it is fragile and can be easily faked with `Object.create()`.
9844
9845function isArray(arg) {
9846 if (Array.isArray) {
9847 return Array.isArray(arg);
9848 }
9849 return objectToString(arg) === '[object Array]';
9850}
9851exports.isArray = isArray;
9852
9853function isBoolean(arg) {
9854 return typeof arg === 'boolean';
9855}
9856exports.isBoolean = isBoolean;
9857
9858function isNull(arg) {
9859 return arg === null;
9860}
9861exports.isNull = isNull;
9862
9863function isNullOrUndefined(arg) {
9864 return arg == null;
9865}
9866exports.isNullOrUndefined = isNullOrUndefined;
9867
9868function isNumber(arg) {
9869 return typeof arg === 'number';
9870}
9871exports.isNumber = isNumber;
9872
9873function isString(arg) {
9874 return typeof arg === 'string';
9875}
9876exports.isString = isString;
9877
9878function isSymbol(arg) {
9879 return (typeof arg === 'undefined' ? 'undefined' : (0, _typeof3.default)(arg)) === 'symbol';
9880}
9881exports.isSymbol = isSymbol;
9882
9883function isUndefined(arg) {
9884 return arg === void 0;
9885}
9886exports.isUndefined = isUndefined;
9887
9888function isRegExp(re) {
9889 return objectToString(re) === '[object RegExp]';
9890}
9891exports.isRegExp = isRegExp;
9892
9893function isObject(arg) {
9894 return (typeof arg === 'undefined' ? 'undefined' : (0, _typeof3.default)(arg)) === 'object' && arg !== null;
9895}
9896exports.isObject = isObject;
9897
9898function isDate(d) {
9899 return objectToString(d) === '[object Date]';
9900}
9901exports.isDate = isDate;
9902
9903function isError(e) {
9904 return objectToString(e) === '[object Error]' || e instanceof Error;
9905}
9906exports.isError = isError;
9907
9908function isFunction(arg) {
9909 return typeof arg === 'function';
9910}
9911exports.isFunction = isFunction;
9912
9913function isPrimitive(arg) {
9914 return arg === null || typeof arg === 'boolean' || typeof arg === 'number' || typeof arg === 'string' || (typeof arg === 'undefined' ? 'undefined' : (0, _typeof3.default)(arg)) === 'symbol' || // ES6 symbol
9915 typeof arg === 'undefined';
9916}
9917exports.isPrimitive = isPrimitive;
9918
9919exports.isBuffer = Buffer.isBuffer;
9920
9921function objectToString(o) {
9922 return Object.prototype.toString.call(o);
9923}
9924
9925}).call(this,{"isBuffer":require("../../is-buffer/index.js")})
9926},{"../../is-buffer/index.js":227,"babel-runtime/helpers/typeof":64}],187:[function(require,module,exports){
9927'use strict';
9928
9929var _typeof2 = require('babel-runtime/helpers/typeof');
9930
9931var _typeof3 = _interopRequireDefault(_typeof2);
9932
9933function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9934
9935/*
9936 * Date Format 1.2.3
9937 * (c) 2007-2009 Steven Levithan <stevenlevithan.com>
9938 * MIT license
9939 *
9940 * Includes enhancements by Scott Trenda <scott.trenda.net>
9941 * and Kris Kowal <cixar.com/~kris.kowal/>
9942 *
9943 * Accepts a date, a mask, or a date and a mask.
9944 * Returns a formatted version of the given date.
9945 * The date defaults to the current date/time.
9946 * The mask defaults to dateFormat.masks.default.
9947 */
9948
9949(function (global) {
9950 'use strict';
9951
9952 var dateFormat = function () {
9953 var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZWN]|'[^']*'|'[^']*'/g;
9954 var timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g;
9955 var timezoneClip = /[^-+\dA-Z]/g;
9956
9957 // Regexes and supporting functions are cached through closure
9958 return function (date, mask, utc, gmt) {
9959
9960 // You can't provide utc if you skip other args (use the 'UTC:' mask prefix)
9961 if (arguments.length === 1 && kindOf(date) === 'string' && !/\d/.test(date)) {
9962 mask = date;
9963 date = undefined;
9964 }
9965
9966 date = date || new Date();
9967
9968 if (!(date instanceof Date)) {
9969 date = new Date(date);
9970 }
9971
9972 if (isNaN(date)) {
9973 throw TypeError('Invalid date');
9974 }
9975
9976 mask = String(dateFormat.masks[mask] || mask || dateFormat.masks['default']);
9977
9978 // Allow setting the utc/gmt argument via the mask
9979 var maskSlice = mask.slice(0, 4);
9980 if (maskSlice === 'UTC:' || maskSlice === 'GMT:') {
9981 mask = mask.slice(4);
9982 utc = true;
9983 if (maskSlice === 'GMT:') {
9984 gmt = true;
9985 }
9986 }
9987
9988 var _ = utc ? 'getUTC' : 'get';
9989 var d = date[_ + 'Date']();
9990 var D = date[_ + 'Day']();
9991 var m = date[_ + 'Month']();
9992 var y = date[_ + 'FullYear']();
9993 var H = date[_ + 'Hours']();
9994 var M = date[_ + 'Minutes']();
9995 var s = date[_ + 'Seconds']();
9996 var L = date[_ + 'Milliseconds']();
9997 var o = utc ? 0 : date.getTimezoneOffset();
9998 var W = getWeek(date);
9999 var N = getDayOfWeek(date);
10000 var flags = {
10001 d: d,
10002 dd: pad(d),
10003 ddd: dateFormat.i18n.dayNames[D],
10004 dddd: dateFormat.i18n.dayNames[D + 7],
10005 m: m + 1,
10006 mm: pad(m + 1),
10007 mmm: dateFormat.i18n.monthNames[m],
10008 mmmm: dateFormat.i18n.monthNames[m + 12],
10009 yy: String(y).slice(2),
10010 yyyy: y,
10011 h: H % 12 || 12,
10012 hh: pad(H % 12 || 12),
10013 H: H,
10014 HH: pad(H),
10015 M: M,
10016 MM: pad(M),
10017 s: s,
10018 ss: pad(s),
10019 l: pad(L, 3),
10020 L: pad(Math.round(L / 10)),
10021 t: H < 12 ? 'a' : 'p',
10022 tt: H < 12 ? 'am' : 'pm',
10023 T: H < 12 ? 'A' : 'P',
10024 TT: H < 12 ? 'AM' : 'PM',
10025 Z: gmt ? 'GMT' : utc ? 'UTC' : (String(date).match(timezone) || ['']).pop().replace(timezoneClip, ''),
10026 o: (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
10027 S: ['th', 'st', 'nd', 'rd'][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10],
10028 W: W,
10029 N: N
10030 };
10031
10032 return mask.replace(token, function (match) {
10033 if (match in flags) {
10034 return flags[match];
10035 }
10036 return match.slice(1, match.length - 1);
10037 });
10038 };
10039 }();
10040
10041 dateFormat.masks = {
10042 'default': 'ddd mmm dd yyyy HH:MM:ss',
10043 'shortDate': 'm/d/yy',
10044 'mediumDate': 'mmm d, yyyy',
10045 'longDate': 'mmmm d, yyyy',
10046 'fullDate': 'dddd, mmmm d, yyyy',
10047 'shortTime': 'h:MM TT',
10048 'mediumTime': 'h:MM:ss TT',
10049 'longTime': 'h:MM:ss TT Z',
10050 'isoDate': 'yyyy-mm-dd',
10051 'isoTime': 'HH:MM:ss',
10052 'isoDateTime': 'yyyy-mm-dd\'T\'HH:MM:sso',
10053 'isoUtcDateTime': 'UTC:yyyy-mm-dd\'T\'HH:MM:ss\'Z\'',
10054 'expiresHeaderFormat': 'ddd, dd mmm yyyy HH:MM:ss Z'
10055 };
10056
10057 // Internationalization strings
10058 dateFormat.i18n = {
10059 dayNames: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
10060 monthNames: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
10061 };
10062
10063 function pad(val, len) {
10064 val = String(val);
10065 len = len || 2;
10066 while (val.length < len) {
10067 val = '0' + val;
10068 }
10069 return val;
10070 }
10071
10072 /**
10073 * Get the ISO 8601 week number
10074 * Based on comments from
10075 * http://techblog.procurios.nl/k/n618/news/view/33796/14863/Calculate-ISO-8601-week-and-year-in-javascript.html
10076 *
10077 * @param {Object} `date`
10078 * @return {Number}
10079 */
10080 function getWeek(date) {
10081 // Remove time components of date
10082 var targetThursday = new Date(date.getFullYear(), date.getMonth(), date.getDate());
10083
10084 // Change date to Thursday same week
10085 targetThursday.setDate(targetThursday.getDate() - (targetThursday.getDay() + 6) % 7 + 3);
10086
10087 // Take January 4th as it is always in week 1 (see ISO 8601)
10088 var firstThursday = new Date(targetThursday.getFullYear(), 0, 4);
10089
10090 // Change date to Thursday same week
10091 firstThursday.setDate(firstThursday.getDate() - (firstThursday.getDay() + 6) % 7 + 3);
10092
10093 // Check if daylight-saving-time-switch occurred and correct for it
10094 var ds = targetThursday.getTimezoneOffset() - firstThursday.getTimezoneOffset();
10095 targetThursday.setHours(targetThursday.getHours() - ds);
10096
10097 // Number of weeks between target Thursday and first Thursday
10098 var weekDiff = (targetThursday - firstThursday) / (86400000 * 7);
10099 return 1 + Math.floor(weekDiff);
10100 }
10101
10102 /**
10103 * Get ISO-8601 numeric representation of the day of the week
10104 * 1 (for Monday) through 7 (for Sunday)
10105 *
10106 * @param {Object} `date`
10107 * @return {Number}
10108 */
10109 function getDayOfWeek(date) {
10110 var dow = date.getDay();
10111 if (dow === 0) {
10112 dow = 7;
10113 }
10114 return dow;
10115 }
10116
10117 /**
10118 * kind-of shortcut
10119 * @param {*} val
10120 * @return {String}
10121 */
10122 function kindOf(val) {
10123 if (val === null) {
10124 return 'null';
10125 }
10126
10127 if (val === undefined) {
10128 return 'undefined';
10129 }
10130
10131 if ((typeof val === 'undefined' ? 'undefined' : (0, _typeof3.default)(val)) !== 'object') {
10132 return typeof val === 'undefined' ? 'undefined' : (0, _typeof3.default)(val);
10133 }
10134
10135 if (Array.isArray(val)) {
10136 return 'array';
10137 }
10138
10139 return {}.toString.call(val).slice(8, -1).toLowerCase();
10140 };
10141
10142 if (typeof define === 'function' && define.amd) {
10143 define(function () {
10144 return dateFormat;
10145 });
10146 } else if ((typeof exports === 'undefined' ? 'undefined' : (0, _typeof3.default)(exports)) === 'object') {
10147 module.exports = dateFormat;
10148 } else {
10149 global.dateFormat = dateFormat;
10150 }
10151})(undefined);
10152
10153},{"babel-runtime/helpers/typeof":64}],188:[function(require,module,exports){
10154(function (process){
10155/**
10156 * This is the web browser implementation of `debug()`.
10157 *
10158 * Expose `debug()` as the module.
10159 */
10160
10161exports = module.exports = require('./debug');
10162exports.log = log;
10163exports.formatArgs = formatArgs;
10164exports.save = save;
10165exports.load = load;
10166exports.useColors = useColors;
10167exports.storage = 'undefined' != typeof chrome
10168 && 'undefined' != typeof chrome.storage
10169 ? chrome.storage.local
10170 : localstorage();
10171
10172/**
10173 * Colors.
10174 */
10175
10176exports.colors = [
10177 'lightseagreen',
10178 'forestgreen',
10179 'goldenrod',
10180 'dodgerblue',
10181 'darkorchid',
10182 'crimson'
10183];
10184
10185/**
10186 * Currently only WebKit-based Web Inspectors, Firefox >= v31,
10187 * and the Firebug extension (any Firefox version) are known
10188 * to support "%c" CSS customizations.
10189 *
10190 * TODO: add a `localStorage` variable to explicitly enable/disable colors
10191 */
10192
10193function useColors() {
10194 // NB: In an Electron preload script, document will be defined but not fully
10195 // initialized. Since we know we're in Chrome, we'll just detect this case
10196 // explicitly
10197 if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
10198 return true;
10199 }
10200
10201 // is webkit? http://stackoverflow.com/a/16459606/376773
10202 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
10203 return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
10204 // is firebug? http://stackoverflow.com/a/398120/376773
10205 (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
10206 // is firefox >= v31?
10207 // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
10208 (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
10209 // double check webkit in userAgent just in case we are in a worker
10210 (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
10211}
10212
10213/**
10214 * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
10215 */
10216
10217exports.formatters.j = function(v) {
10218 try {
10219 return JSON.stringify(v);
10220 } catch (err) {
10221 return '[UnexpectedJSONParseError]: ' + err.message;
10222 }
10223};
10224
10225
10226/**
10227 * Colorize log arguments if enabled.
10228 *
10229 * @api public
10230 */
10231
10232function formatArgs(args) {
10233 var useColors = this.useColors;
10234
10235 args[0] = (useColors ? '%c' : '')
10236 + this.namespace
10237 + (useColors ? ' %c' : ' ')
10238 + args[0]
10239 + (useColors ? '%c ' : ' ')
10240 + '+' + exports.humanize(this.diff);
10241
10242 if (!useColors) return;
10243
10244 var c = 'color: ' + this.color;
10245 args.splice(1, 0, c, 'color: inherit')
10246
10247 // the final "%c" is somewhat tricky, because there could be other
10248 // arguments passed either before or after the %c, so we need to
10249 // figure out the correct index to insert the CSS into
10250 var index = 0;
10251 var lastC = 0;
10252 args[0].replace(/%[a-zA-Z%]/g, function(match) {
10253 if ('%%' === match) return;
10254 index++;
10255 if ('%c' === match) {
10256 // we only are interested in the *last* %c
10257 // (the user may have provided their own)
10258 lastC = index;
10259 }
10260 });
10261
10262 args.splice(lastC, 0, c);
10263}
10264
10265/**
10266 * Invokes `console.log()` when available.
10267 * No-op when `console.log` is not a "function".
10268 *
10269 * @api public
10270 */
10271
10272function log() {
10273 // this hackery is required for IE8/9, where
10274 // the `console.log` function doesn't have 'apply'
10275 return 'object' === typeof console
10276 && console.log
10277 && Function.prototype.apply.call(console.log, console, arguments);
10278}
10279
10280/**
10281 * Save `namespaces`.
10282 *
10283 * @param {String} namespaces
10284 * @api private
10285 */
10286
10287function save(namespaces) {
10288 try {
10289 if (null == namespaces) {
10290 exports.storage.removeItem('debug');
10291 } else {
10292 exports.storage.debug = namespaces;
10293 }
10294 } catch(e) {}
10295}
10296
10297/**
10298 * Load `namespaces`.
10299 *
10300 * @return {String} returns the previously persisted debug modes
10301 * @api private
10302 */
10303
10304function load() {
10305 var r;
10306 try {
10307 r = exports.storage.debug;
10308 } catch(e) {}
10309
10310 // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
10311 if (!r && typeof process !== 'undefined' && 'env' in process) {
10312 r = process.env.DEBUG;
10313 }
10314
10315 return r;
10316}
10317
10318/**
10319 * Enable namespaces listed in `localStorage.debug` initially.
10320 */
10321
10322exports.enable(load());
10323
10324/**
10325 * Localstorage attempts to return the localstorage.
10326 *
10327 * This is necessary because safari throws
10328 * when a user disables cookies/localstorage
10329 * and you attempt to access it.
10330 *
10331 * @return {LocalStorage}
10332 * @api private
10333 */
10334
10335function localstorage() {
10336 try {
10337 return window.localStorage;
10338 } catch (e) {}
10339}
10340
10341}).call(this,require('_process'))
10342},{"./debug":189,"_process":249}],189:[function(require,module,exports){
10343
10344/**
10345 * This is the common logic for both the Node.js and web browser
10346 * implementations of `debug()`.
10347 *
10348 * Expose `debug()` as the module.
10349 */
10350
10351exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
10352exports.coerce = coerce;
10353exports.disable = disable;
10354exports.enable = enable;
10355exports.enabled = enabled;
10356exports.humanize = require('ms');
10357
10358/**
10359 * The currently active debug mode names, and names to skip.
10360 */
10361
10362exports.names = [];
10363exports.skips = [];
10364
10365/**
10366 * Map of special "%n" handling functions, for the debug "format" argument.
10367 *
10368 * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
10369 */
10370
10371exports.formatters = {};
10372
10373/**
10374 * Previous log timestamp.
10375 */
10376
10377var prevTime;
10378
10379/**
10380 * Select a color.
10381 * @param {String} namespace
10382 * @return {Number}
10383 * @api private
10384 */
10385
10386function selectColor(namespace) {
10387 var hash = 0, i;
10388
10389 for (i in namespace) {
10390 hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
10391 hash |= 0; // Convert to 32bit integer
10392 }
10393
10394 return exports.colors[Math.abs(hash) % exports.colors.length];
10395}
10396
10397/**
10398 * Create a debugger with the given `namespace`.
10399 *
10400 * @param {String} namespace
10401 * @return {Function}
10402 * @api public
10403 */
10404
10405function createDebug(namespace) {
10406
10407 function debug() {
10408 // disabled?
10409 if (!debug.enabled) return;
10410
10411 var self = debug;
10412
10413 // set `diff` timestamp
10414 var curr = +new Date();
10415 var ms = curr - (prevTime || curr);
10416 self.diff = ms;
10417 self.prev = prevTime;
10418 self.curr = curr;
10419 prevTime = curr;
10420
10421 // turn the `arguments` into a proper Array
10422 var args = new Array(arguments.length);
10423 for (var i = 0; i < args.length; i++) {
10424 args[i] = arguments[i];
10425 }
10426
10427 args[0] = exports.coerce(args[0]);
10428
10429 if ('string' !== typeof args[0]) {
10430 // anything else let's inspect with %O
10431 args.unshift('%O');
10432 }
10433
10434 // apply any `formatters` transformations
10435 var index = 0;
10436 args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
10437 // if we encounter an escaped % then don't increase the array index
10438 if (match === '%%') return match;
10439 index++;
10440 var formatter = exports.formatters[format];
10441 if ('function' === typeof formatter) {
10442 var val = args[index];
10443 match = formatter.call(self, val);
10444
10445 // now we need to remove `args[index]` since it's inlined in the `format`
10446 args.splice(index, 1);
10447 index--;
10448 }
10449 return match;
10450 });
10451
10452 // apply env-specific formatting (colors, etc.)
10453 exports.formatArgs.call(self, args);
10454
10455 var logFn = debug.log || exports.log || console.log.bind(console);
10456 logFn.apply(self, args);
10457 }
10458
10459 debug.namespace = namespace;
10460 debug.enabled = exports.enabled(namespace);
10461 debug.useColors = exports.useColors();
10462 debug.color = selectColor(namespace);
10463
10464 // env-specific initialization logic for debug instances
10465 if ('function' === typeof exports.init) {
10466 exports.init(debug);
10467 }
10468
10469 return debug;
10470}
10471
10472/**
10473 * Enables a debug mode by namespaces. This can include modes
10474 * separated by a colon and wildcards.
10475 *
10476 * @param {String} namespaces
10477 * @api public
10478 */
10479
10480function enable(namespaces) {
10481 exports.save(namespaces);
10482
10483 exports.names = [];
10484 exports.skips = [];
10485
10486 var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
10487 var len = split.length;
10488
10489 for (var i = 0; i < len; i++) {
10490 if (!split[i]) continue; // ignore empty strings
10491 namespaces = split[i].replace(/\*/g, '.*?');
10492 if (namespaces[0] === '-') {
10493 exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
10494 } else {
10495 exports.names.push(new RegExp('^' + namespaces + '$'));
10496 }
10497 }
10498}
10499
10500/**
10501 * Disable debug output.
10502 *
10503 * @api public
10504 */
10505
10506function disable() {
10507 exports.enable('');
10508}
10509
10510/**
10511 * Returns true if the given mode name is enabled, false otherwise.
10512 *
10513 * @param {String} name
10514 * @return {Boolean}
10515 * @api public
10516 */
10517
10518function enabled(name) {
10519 var i, len;
10520 for (i = 0, len = exports.skips.length; i < len; i++) {
10521 if (exports.skips[i].test(name)) {
10522 return false;
10523 }
10524 }
10525 for (i = 0, len = exports.names.length; i < len; i++) {
10526 if (exports.names[i].test(name)) {
10527 return true;
10528 }
10529 }
10530 return false;
10531}
10532
10533/**
10534 * Coerce `val`.
10535 *
10536 * @param {Mixed} val
10537 * @return {Mixed}
10538 * @api private
10539 */
10540
10541function coerce(val) {
10542 if (val instanceof Error) return val.stack || val.message;
10543 return val;
10544}
10545
10546},{"ms":238}],190:[function(require,module,exports){
10547'use strict';
10548
10549var keys = require('object-keys');
10550var foreach = require('foreach');
10551var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';
10552
10553var toStr = Object.prototype.toString;
10554
10555var isFunction = function (fn) {
10556 return typeof fn === 'function' && toStr.call(fn) === '[object Function]';
10557};
10558
10559var arePropertyDescriptorsSupported = function () {
10560 var obj = {};
10561 try {
10562 Object.defineProperty(obj, 'x', { enumerable: false, value: obj });
10563 /* eslint-disable no-unused-vars, no-restricted-syntax */
10564 for (var _ in obj) { return false; }
10565 /* eslint-enable no-unused-vars, no-restricted-syntax */
10566 return obj.x === obj;
10567 } catch (e) { /* this is IE 8. */
10568 return false;
10569 }
10570};
10571var supportsDescriptors = Object.defineProperty && arePropertyDescriptorsSupported();
10572
10573var defineProperty = function (object, name, value, predicate) {
10574 if (name in object && (!isFunction(predicate) || !predicate())) {
10575 return;
10576 }
10577 if (supportsDescriptors) {
10578 Object.defineProperty(object, name, {
10579 configurable: true,
10580 enumerable: false,
10581 value: value,
10582 writable: true
10583 });
10584 } else {
10585 object[name] = value;
10586 }
10587};
10588
10589var defineProperties = function (object, map) {
10590 var predicates = arguments.length > 2 ? arguments[2] : {};
10591 var props = keys(map);
10592 if (hasSymbols) {
10593 props = props.concat(Object.getOwnPropertySymbols(map));
10594 }
10595 foreach(props, function (name) {
10596 defineProperty(object, name, map[name], predicates[name]);
10597 });
10598};
10599
10600defineProperties.supportsDescriptors = !!supportsDescriptors;
10601
10602module.exports = defineProperties;
10603
10604},{"foreach":217,"object-keys":240}],191:[function(require,module,exports){
10605'use strict';
10606
10607/* globals
10608 Atomics,
10609 SharedArrayBuffer,
10610*/
10611
10612var undefined; // eslint-disable-line no-shadow-restricted-names
10613
10614var ThrowTypeError = Object.getOwnPropertyDescriptor
10615 ? (function () { return Object.getOwnPropertyDescriptor(arguments, 'callee').get; }())
10616 : function () { throw new TypeError(); };
10617
10618var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol';
10619
10620var getProto = Object.getPrototypeOf || function (x) { return x.__proto__; }; // eslint-disable-line no-proto
10621
10622var generator; // = function * () {};
10623var generatorFunction = generator ? getProto(generator) : undefined;
10624var asyncFn; // async function() {};
10625var asyncFunction = asyncFn ? asyncFn.constructor : undefined;
10626var asyncGen; // async function * () {};
10627var asyncGenFunction = asyncGen ? getProto(asyncGen) : undefined;
10628var asyncGenIterator = asyncGen ? asyncGen() : undefined;
10629
10630var TypedArray = typeof Uint8Array === 'undefined' ? undefined : getProto(Uint8Array);
10631
10632var INTRINSICS = {
10633 '$ %Array%': Array,
10634 '$ %ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer,
10635 '$ %ArrayBufferPrototype%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer.prototype,
10636 '$ %ArrayIteratorPrototype%': hasSymbols ? getProto([][Symbol.iterator]()) : undefined,
10637 '$ %ArrayPrototype%': Array.prototype,
10638 '$ %ArrayProto_entries%': Array.prototype.entries,
10639 '$ %ArrayProto_forEach%': Array.prototype.forEach,
10640 '$ %ArrayProto_keys%': Array.prototype.keys,
10641 '$ %ArrayProto_values%': Array.prototype.values,
10642 '$ %AsyncFromSyncIteratorPrototype%': undefined,
10643 '$ %AsyncFunction%': asyncFunction,
10644 '$ %AsyncFunctionPrototype%': asyncFunction ? asyncFunction.prototype : undefined,
10645 '$ %AsyncGenerator%': asyncGen ? getProto(asyncGenIterator) : undefined,
10646 '$ %AsyncGeneratorFunction%': asyncGenFunction,
10647 '$ %AsyncGeneratorPrototype%': asyncGenFunction ? asyncGenFunction.prototype : undefined,
10648 '$ %AsyncIteratorPrototype%': asyncGenIterator && hasSymbols && Symbol.asyncIterator ? asyncGenIterator[Symbol.asyncIterator]() : undefined,
10649 '$ %Atomics%': typeof Atomics === 'undefined' ? undefined : Atomics,
10650 '$ %Boolean%': Boolean,
10651 '$ %BooleanPrototype%': Boolean.prototype,
10652 '$ %DataView%': typeof DataView === 'undefined' ? undefined : DataView,
10653 '$ %DataViewPrototype%': typeof DataView === 'undefined' ? undefined : DataView.prototype,
10654 '$ %Date%': Date,
10655 '$ %DatePrototype%': Date.prototype,
10656 '$ %decodeURI%': decodeURI,
10657 '$ %decodeURIComponent%': decodeURIComponent,
10658 '$ %encodeURI%': encodeURI,
10659 '$ %encodeURIComponent%': encodeURIComponent,
10660 '$ %Error%': Error,
10661 '$ %ErrorPrototype%': Error.prototype,
10662 '$ %eval%': eval, // eslint-disable-line no-eval
10663 '$ %EvalError%': EvalError,
10664 '$ %EvalErrorPrototype%': EvalError.prototype,
10665 '$ %Float32Array%': typeof Float32Array === 'undefined' ? undefined : Float32Array,
10666 '$ %Float32ArrayPrototype%': typeof Float32Array === 'undefined' ? undefined : Float32Array.prototype,
10667 '$ %Float64Array%': typeof Float64Array === 'undefined' ? undefined : Float64Array,
10668 '$ %Float64ArrayPrototype%': typeof Float64Array === 'undefined' ? undefined : Float64Array.prototype,
10669 '$ %Function%': Function,
10670 '$ %FunctionPrototype%': Function.prototype,
10671 '$ %Generator%': generator ? getProto(generator()) : undefined,
10672 '$ %GeneratorFunction%': generatorFunction,
10673 '$ %GeneratorPrototype%': generatorFunction ? generatorFunction.prototype : undefined,
10674 '$ %Int8Array%': typeof Int8Array === 'undefined' ? undefined : Int8Array,
10675 '$ %Int8ArrayPrototype%': typeof Int8Array === 'undefined' ? undefined : Int8Array.prototype,
10676 '$ %Int16Array%': typeof Int16Array === 'undefined' ? undefined : Int16Array,
10677 '$ %Int16ArrayPrototype%': typeof Int16Array === 'undefined' ? undefined : Int8Array.prototype,
10678 '$ %Int32Array%': typeof Int32Array === 'undefined' ? undefined : Int32Array,
10679 '$ %Int32ArrayPrototype%': typeof Int32Array === 'undefined' ? undefined : Int32Array.prototype,
10680 '$ %isFinite%': isFinite,
10681 '$ %isNaN%': isNaN,
10682 '$ %IteratorPrototype%': hasSymbols ? getProto(getProto([][Symbol.iterator]())) : undefined,
10683 '$ %JSON%': JSON,
10684 '$ %JSONParse%': JSON.parse,
10685 '$ %Map%': typeof Map === 'undefined' ? undefined : Map,
10686 '$ %MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols ? undefined : getProto(new Map()[Symbol.iterator]()),
10687 '$ %MapPrototype%': typeof Map === 'undefined' ? undefined : Map.prototype,
10688 '$ %Math%': Math,
10689 '$ %Number%': Number,
10690 '$ %NumberPrototype%': Number.prototype,
10691 '$ %Object%': Object,
10692 '$ %ObjectPrototype%': Object.prototype,
10693 '$ %ObjProto_toString%': Object.prototype.toString,
10694 '$ %ObjProto_valueOf%': Object.prototype.valueOf,
10695 '$ %parseFloat%': parseFloat,
10696 '$ %parseInt%': parseInt,
10697 '$ %Promise%': typeof Promise === 'undefined' ? undefined : Promise,
10698 '$ %PromisePrototype%': typeof Promise === 'undefined' ? undefined : Promise.prototype,
10699 '$ %PromiseProto_then%': typeof Promise === 'undefined' ? undefined : Promise.prototype.then,
10700 '$ %Promise_all%': typeof Promise === 'undefined' ? undefined : Promise.all,
10701 '$ %Promise_reject%': typeof Promise === 'undefined' ? undefined : Promise.reject,
10702 '$ %Promise_resolve%': typeof Promise === 'undefined' ? undefined : Promise.resolve,
10703 '$ %Proxy%': typeof Proxy === 'undefined' ? undefined : Proxy,
10704 '$ %RangeError%': RangeError,
10705 '$ %RangeErrorPrototype%': RangeError.prototype,
10706 '$ %ReferenceError%': ReferenceError,
10707 '$ %ReferenceErrorPrototype%': ReferenceError.prototype,
10708 '$ %Reflect%': typeof Reflect === 'undefined' ? undefined : Reflect,
10709 '$ %RegExp%': RegExp,
10710 '$ %RegExpPrototype%': RegExp.prototype,
10711 '$ %Set%': typeof Set === 'undefined' ? undefined : Set,
10712 '$ %SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols ? undefined : getProto(new Set()[Symbol.iterator]()),
10713 '$ %SetPrototype%': typeof Set === 'undefined' ? undefined : Set.prototype,
10714 '$ %SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer,
10715 '$ %SharedArrayBufferPrototype%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer.prototype,
10716 '$ %String%': String,
10717 '$ %StringIteratorPrototype%': hasSymbols ? getProto(''[Symbol.iterator]()) : undefined,
10718 '$ %StringPrototype%': String.prototype,
10719 '$ %Symbol%': hasSymbols ? Symbol : undefined,
10720 '$ %SymbolPrototype%': hasSymbols ? Symbol.prototype : undefined,
10721 '$ %SyntaxError%': SyntaxError,
10722 '$ %SyntaxErrorPrototype%': SyntaxError.prototype,
10723 '$ %ThrowTypeError%': ThrowTypeError,
10724 '$ %TypedArray%': TypedArray,
10725 '$ %TypedArrayPrototype%': TypedArray ? TypedArray.prototype : undefined,
10726 '$ %TypeError%': TypeError,
10727 '$ %TypeErrorPrototype%': TypeError.prototype,
10728 '$ %Uint8Array%': typeof Uint8Array === 'undefined' ? undefined : Uint8Array,
10729 '$ %Uint8ArrayPrototype%': typeof Uint8Array === 'undefined' ? undefined : Uint8Array.prototype,
10730 '$ %Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined : Uint8ClampedArray,
10731 '$ %Uint8ClampedArrayPrototype%': typeof Uint8ClampedArray === 'undefined' ? undefined : Uint8ClampedArray.prototype,
10732 '$ %Uint16Array%': typeof Uint16Array === 'undefined' ? undefined : Uint16Array,
10733 '$ %Uint16ArrayPrototype%': typeof Uint16Array === 'undefined' ? undefined : Uint16Array.prototype,
10734 '$ %Uint32Array%': typeof Uint32Array === 'undefined' ? undefined : Uint32Array,
10735 '$ %Uint32ArrayPrototype%': typeof Uint32Array === 'undefined' ? undefined : Uint32Array.prototype,
10736 '$ %URIError%': URIError,
10737 '$ %URIErrorPrototype%': URIError.prototype,
10738 '$ %WeakMap%': typeof WeakMap === 'undefined' ? undefined : WeakMap,
10739 '$ %WeakMapPrototype%': typeof WeakMap === 'undefined' ? undefined : WeakMap.prototype,
10740 '$ %WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet,
10741 '$ %WeakSetPrototype%': typeof WeakSet === 'undefined' ? undefined : WeakSet.prototype
10742};
10743
10744module.exports = function GetIntrinsic(name, allowMissing) {
10745 if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
10746 throw new TypeError('"allowMissing" argument must be a boolean');
10747 }
10748
10749 var key = '$ ' + name;
10750 if (!(key in INTRINSICS)) {
10751 throw new SyntaxError('intrinsic ' + name + ' does not exist!');
10752 }
10753
10754 // istanbul ignore if // hopefully this is impossible to test :-)
10755 if (typeof INTRINSICS[key] === 'undefined' && !allowMissing) {
10756 throw new TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
10757 }
10758 return INTRINSICS[key];
10759};
10760
10761},{}],192:[function(require,module,exports){
10762'use strict';
10763
10764var has = require('has');
10765var toPrimitive = require('es-to-primitive/es6');
10766var keys = require('object-keys');
10767var inspect = require('object-inspect');
10768
10769var GetIntrinsic = require('./GetIntrinsic');
10770
10771var $TypeError = GetIntrinsic('%TypeError%');
10772var $RangeError = GetIntrinsic('%RangeError%');
10773var $SyntaxError = GetIntrinsic('%SyntaxError%');
10774var $Array = GetIntrinsic('%Array%');
10775var $ArrayPrototype = $Array.prototype;
10776var $String = GetIntrinsic('%String%');
10777var $Object = GetIntrinsic('%Object%');
10778var $Number = GetIntrinsic('%Number%');
10779var $Symbol = GetIntrinsic('%Symbol%', true);
10780var $RegExp = GetIntrinsic('%RegExp%');
10781var $Promise = GetIntrinsic('%Promise%', true);
10782var $preventExtensions = $Object.preventExtensions;
10783
10784var hasSymbols = require('has-symbols')();
10785
10786var assertRecord = require('./helpers/assertRecord');
10787var $isNaN = require('./helpers/isNaN');
10788var $isFinite = require('./helpers/isFinite');
10789var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1;
10790var MAX_SAFE_INTEGER = $Number.MAX_SAFE_INTEGER || Math.pow(2, 53) - 1;
10791
10792var assign = require('./helpers/assign');
10793var sign = require('./helpers/sign');
10794var mod = require('./helpers/mod');
10795var isPrimitive = require('./helpers/isPrimitive');
10796var forEach = require('./helpers/forEach');
10797var every = require('./helpers/every');
10798var isSamePropertyDescriptor = require('./helpers/isSamePropertyDescriptor');
10799var isPropertyDescriptor = require('./helpers/isPropertyDescriptor');
10800var parseInteger = parseInt;
10801var callBind = require('./helpers/callBind');
10802var $PromiseThen = $Promise ? callBind(GetIntrinsic('%PromiseProto_then%')) : null;
10803var arraySlice = callBind($Array.prototype.slice);
10804var strSlice = callBind($String.prototype.slice);
10805var isBinary = callBind($RegExp.prototype.test, /^0b[01]+$/i);
10806var isOctal = callBind($RegExp.prototype.test, /^0o[0-7]+$/i);
10807var isDigit = callBind($RegExp.prototype.test, /^[0-9]$/);
10808var regexExec = callBind($RegExp.prototype.exec);
10809var nonWS = ['\u0085', '\u200b', '\ufffe'].join('');
10810var nonWSregex = new $RegExp('[' + nonWS + ']', 'g');
10811var hasNonWS = callBind($RegExp.prototype.test, nonWSregex);
10812var invalidHexLiteral = /^[-+]0x[0-9a-f]+$/i;
10813var isInvalidHexLiteral = callBind($RegExp.prototype.test, invalidHexLiteral);
10814var $charCodeAt = callBind($String.prototype.charCodeAt);
10815var $isEnumerable = callBind($Object.prototype.propertyIsEnumerable);
10816
10817var toStr = callBind($Object.prototype.toString);
10818
10819var $NumberValueOf = callBind(GetIntrinsic('%NumberPrototype%').valueOf);
10820var $BooleanValueOf = callBind(GetIntrinsic('%BooleanPrototype%').valueOf);
10821var $StringValueOf = callBind(GetIntrinsic('%StringPrototype%').valueOf);
10822var $DateValueOf = callBind(GetIntrinsic('%DatePrototype%').valueOf);
10823var $SymbolToString = hasSymbols && callBind(GetIntrinsic('%SymbolPrototype%').toString);
10824
10825var $floor = Math.floor;
10826var $abs = Math.abs;
10827
10828var $ObjectCreate = $Object.create;
10829var $gOPD = $Object.getOwnPropertyDescriptor;
10830var $gOPN = $Object.getOwnPropertyNames;
10831var $gOPS = $Object.getOwnPropertySymbols;
10832var $isExtensible = $Object.isExtensible;
10833var $defineProperty = $Object.defineProperty;
10834var $setProto = Object.setPrototypeOf || (
10835 // eslint-disable-next-line no-proto, no-negated-condition
10836 [].__proto__ !== Array.prototype
10837 ? null
10838 : function (O, proto) {
10839 O.__proto__ = proto; // eslint-disable-line no-proto
10840 return O;
10841 }
10842);
10843
10844var DefineOwnProperty = function DefineOwnProperty(ES, O, P, desc) {
10845 if (!$defineProperty) {
10846 if (!ES.IsDataDescriptor(desc)) {
10847 // ES3 does not support getters/setters
10848 return false;
10849 }
10850 if (!desc['[[Configurable]]'] || !desc['[[Writable]]']) {
10851 return false;
10852 }
10853
10854 // fallback for ES3
10855 if (P in O && $isEnumerable(O, P) !== !!desc['[[Enumerable]]']) {
10856 // a non-enumerable existing property
10857 return false;
10858 }
10859
10860 // property does not exist at all, or exists but is enumerable
10861 var V = desc['[[Value]]'];
10862 O[P] = V; // will use [[Define]]
10863 return ES.SameValue(O[P], V);
10864 }
10865 $defineProperty(O, P, ES.FromPropertyDescriptor(desc));
10866 return true;
10867};
10868
10869// whitespace from: https://es5.github.io/#x15.5.4.20
10870// implementation from https://github.com/es-shims/es5-shim/blob/v3.4.0/es5-shim.js#L1304-L1324
10871var ws = [
10872 '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003',
10873 '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028',
10874 '\u2029\uFEFF'
10875].join('');
10876var trimRegex = new RegExp('(^[' + ws + ']+)|([' + ws + ']+$)', 'g');
10877var $replace = callBind($String.prototype.replace);
10878var trim = function (value) {
10879 return $replace(value, trimRegex, '');
10880};
10881
10882var ES5 = require('./es5');
10883
10884var hasRegExpMatcher = require('is-regex');
10885
10886// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-abstract-operations
10887var ES6 = assign(assign({}, ES5), {
10888
10889 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-call-f-v-args
10890 Call: function Call(F, V) {
10891 var args = arguments.length > 2 ? arguments[2] : [];
10892 if (!this.IsCallable(F)) {
10893 throw new $TypeError(inspect(F) + ' is not a function');
10894 }
10895 return F.apply(V, args);
10896 },
10897
10898 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toprimitive
10899 ToPrimitive: toPrimitive,
10900
10901 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toboolean
10902 // ToBoolean: ES5.ToBoolean,
10903
10904 // https://ecma-international.org/ecma-262/6.0/#sec-tonumber
10905 ToNumber: function ToNumber(argument) {
10906 var value = isPrimitive(argument) ? argument : toPrimitive(argument, $Number);
10907 if (typeof value === 'symbol') {
10908 throw new $TypeError('Cannot convert a Symbol value to a number');
10909 }
10910 if (typeof value === 'string') {
10911 if (isBinary(value)) {
10912 return this.ToNumber(parseInteger(strSlice(value, 2), 2));
10913 } else if (isOctal(value)) {
10914 return this.ToNumber(parseInteger(strSlice(value, 2), 8));
10915 } else if (hasNonWS(value) || isInvalidHexLiteral(value)) {
10916 return NaN;
10917 } else {
10918 var trimmed = trim(value);
10919 if (trimmed !== value) {
10920 return this.ToNumber(trimmed);
10921 }
10922 }
10923 }
10924 return $Number(value);
10925 },
10926
10927 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tointeger
10928 // ToInteger: ES5.ToNumber,
10929
10930 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toint32
10931 // ToInt32: ES5.ToInt32,
10932
10933 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint32
10934 // ToUint32: ES5.ToUint32,
10935
10936 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toint16
10937 ToInt16: function ToInt16(argument) {
10938 var int16bit = this.ToUint16(argument);
10939 return int16bit >= 0x8000 ? int16bit - 0x10000 : int16bit;
10940 },
10941
10942 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint16
10943 // ToUint16: ES5.ToUint16,
10944
10945 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toint8
10946 ToInt8: function ToInt8(argument) {
10947 var int8bit = this.ToUint8(argument);
10948 return int8bit >= 0x80 ? int8bit - 0x100 : int8bit;
10949 },
10950
10951 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint8
10952 ToUint8: function ToUint8(argument) {
10953 var number = this.ToNumber(argument);
10954 if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; }
10955 var posInt = sign(number) * $floor($abs(number));
10956 return mod(posInt, 0x100);
10957 },
10958
10959 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint8clamp
10960 ToUint8Clamp: function ToUint8Clamp(argument) {
10961 var number = this.ToNumber(argument);
10962 if ($isNaN(number) || number <= 0) { return 0; }
10963 if (number >= 0xFF) { return 0xFF; }
10964 var f = $floor(argument);
10965 if (f + 0.5 < number) { return f + 1; }
10966 if (number < f + 0.5) { return f; }
10967 if (f % 2 !== 0) { return f + 1; }
10968 return f;
10969 },
10970
10971 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tostring
10972 ToString: function ToString(argument) {
10973 if (typeof argument === 'symbol') {
10974 throw new $TypeError('Cannot convert a Symbol value to a string');
10975 }
10976 return $String(argument);
10977 },
10978
10979 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toobject
10980 ToObject: function ToObject(value) {
10981 this.RequireObjectCoercible(value);
10982 return $Object(value);
10983 },
10984
10985 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-topropertykey
10986 ToPropertyKey: function ToPropertyKey(argument) {
10987 var key = this.ToPrimitive(argument, $String);
10988 return typeof key === 'symbol' ? key : this.ToString(key);
10989 },
10990
10991 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength
10992 ToLength: function ToLength(argument) {
10993 var len = this.ToInteger(argument);
10994 if (len <= 0) { return 0; } // includes converting -0 to +0
10995 if (len > MAX_SAFE_INTEGER) { return MAX_SAFE_INTEGER; }
10996 return len;
10997 },
10998
10999 // https://ecma-international.org/ecma-262/6.0/#sec-canonicalnumericindexstring
11000 CanonicalNumericIndexString: function CanonicalNumericIndexString(argument) {
11001 if (toStr(argument) !== '[object String]') {
11002 throw new $TypeError('must be a string');
11003 }
11004 if (argument === '-0') { return -0; }
11005 var n = this.ToNumber(argument);
11006 if (this.SameValue(this.ToString(n), argument)) { return n; }
11007 return void 0;
11008 },
11009
11010 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-requireobjectcoercible
11011 RequireObjectCoercible: ES5.CheckObjectCoercible,
11012
11013 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isarray
11014 IsArray: $Array.isArray || function IsArray(argument) {
11015 return toStr(argument) === '[object Array]';
11016 },
11017
11018 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-iscallable
11019 // IsCallable: ES5.IsCallable,
11020
11021 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isconstructor
11022 IsConstructor: function IsConstructor(argument) {
11023 return typeof argument === 'function' && !!argument.prototype; // unfortunately there's no way to truly check this without try/catch `new argument`
11024 },
11025
11026 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isextensible-o
11027 IsExtensible: $preventExtensions
11028 ? function IsExtensible(obj) {
11029 if (isPrimitive(obj)) {
11030 return false;
11031 }
11032 return $isExtensible(obj);
11033 }
11034 : function isExtensible(obj) { return true; }, // eslint-disable-line no-unused-vars
11035
11036 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isinteger
11037 IsInteger: function IsInteger(argument) {
11038 if (typeof argument !== 'number' || $isNaN(argument) || !$isFinite(argument)) {
11039 return false;
11040 }
11041 var abs = $abs(argument);
11042 return $floor(abs) === abs;
11043 },
11044
11045 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ispropertykey
11046 IsPropertyKey: function IsPropertyKey(argument) {
11047 return typeof argument === 'string' || typeof argument === 'symbol';
11048 },
11049
11050 // https://ecma-international.org/ecma-262/6.0/#sec-isregexp
11051 IsRegExp: function IsRegExp(argument) {
11052 if (!argument || typeof argument !== 'object') {
11053 return false;
11054 }
11055 if (hasSymbols) {
11056 var isRegExp = argument[$Symbol.match];
11057 if (typeof isRegExp !== 'undefined') {
11058 return ES5.ToBoolean(isRegExp);
11059 }
11060 }
11061 return hasRegExpMatcher(argument);
11062 },
11063
11064 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevalue
11065 // SameValue: ES5.SameValue,
11066
11067 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero
11068 SameValueZero: function SameValueZero(x, y) {
11069 return (x === y) || ($isNaN(x) && $isNaN(y));
11070 },
11071
11072 /**
11073 * 7.3.2 GetV (V, P)
11074 * 1. Assert: IsPropertyKey(P) is true.
11075 * 2. Let O be ToObject(V).
11076 * 3. ReturnIfAbrupt(O).
11077 * 4. Return O.[[Get]](P, V).
11078 */
11079 GetV: function GetV(V, P) {
11080 // 7.3.2.1
11081 if (!this.IsPropertyKey(P)) {
11082 throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
11083 }
11084
11085 // 7.3.2.2-3
11086 var O = this.ToObject(V);
11087
11088 // 7.3.2.4
11089 return O[P];
11090 },
11091
11092 /**
11093 * 7.3.9 - https://ecma-international.org/ecma-262/6.0/#sec-getmethod
11094 * 1. Assert: IsPropertyKey(P) is true.
11095 * 2. Let func be GetV(O, P).
11096 * 3. ReturnIfAbrupt(func).
11097 * 4. If func is either undefined or null, return undefined.
11098 * 5. If IsCallable(func) is false, throw a TypeError exception.
11099 * 6. Return func.
11100 */
11101 GetMethod: function GetMethod(O, P) {
11102 // 7.3.9.1
11103 if (!this.IsPropertyKey(P)) {
11104 throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
11105 }
11106
11107 // 7.3.9.2
11108 var func = this.GetV(O, P);
11109
11110 // 7.3.9.4
11111 if (func == null) {
11112 return void 0;
11113 }
11114
11115 // 7.3.9.5
11116 if (!this.IsCallable(func)) {
11117 throw new $TypeError(P + 'is not a function');
11118 }
11119
11120 // 7.3.9.6
11121 return func;
11122 },
11123
11124 /**
11125 * 7.3.1 Get (O, P) - https://ecma-international.org/ecma-262/6.0/#sec-get-o-p
11126 * 1. Assert: Type(O) is Object.
11127 * 2. Assert: IsPropertyKey(P) is true.
11128 * 3. Return O.[[Get]](P, O).
11129 */
11130 Get: function Get(O, P) {
11131 // 7.3.1.1
11132 if (this.Type(O) !== 'Object') {
11133 throw new $TypeError('Assertion failed: Type(O) is not Object');
11134 }
11135 // 7.3.1.2
11136 if (!this.IsPropertyKey(P)) {
11137 throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true, got ' + inspect(P));
11138 }
11139 // 7.3.1.3
11140 return O[P];
11141 },
11142
11143 Type: function Type(x) {
11144 if (typeof x === 'symbol') {
11145 return 'Symbol';
11146 }
11147 return ES5.Type(x);
11148 },
11149
11150 // https://ecma-international.org/ecma-262/6.0/#sec-speciesconstructor
11151 SpeciesConstructor: function SpeciesConstructor(O, defaultConstructor) {
11152 if (this.Type(O) !== 'Object') {
11153 throw new $TypeError('Assertion failed: Type(O) is not Object');
11154 }
11155 var C = O.constructor;
11156 if (typeof C === 'undefined') {
11157 return defaultConstructor;
11158 }
11159 if (this.Type(C) !== 'Object') {
11160 throw new $TypeError('O.constructor is not an Object');
11161 }
11162 var S = hasSymbols && $Symbol.species ? C[$Symbol.species] : void 0;
11163 if (S == null) {
11164 return defaultConstructor;
11165 }
11166 if (this.IsConstructor(S)) {
11167 return S;
11168 }
11169 throw new $TypeError('no constructor found');
11170 },
11171
11172 // https://www.ecma-international.org/ecma-262/6.0/#sec-frompropertydescriptor
11173 FromPropertyDescriptor: function FromPropertyDescriptor(Desc) {
11174 if (typeof Desc === 'undefined') {
11175 return Desc;
11176 }
11177
11178 assertRecord(this, 'Property Descriptor', 'Desc', Desc);
11179
11180 var obj = {};
11181 if ('[[Value]]' in Desc) {
11182 obj.value = Desc['[[Value]]'];
11183 }
11184 if ('[[Writable]]' in Desc) {
11185 obj.writable = Desc['[[Writable]]'];
11186 }
11187 if ('[[Get]]' in Desc) {
11188 obj.get = Desc['[[Get]]'];
11189 }
11190 if ('[[Set]]' in Desc) {
11191 obj.set = Desc['[[Set]]'];
11192 }
11193 if ('[[Enumerable]]' in Desc) {
11194 obj.enumerable = Desc['[[Enumerable]]'];
11195 }
11196 if ('[[Configurable]]' in Desc) {
11197 obj.configurable = Desc['[[Configurable]]'];
11198 }
11199 return obj;
11200 },
11201
11202 // https://ecma-international.org/ecma-262/6.0/#sec-completepropertydescriptor
11203 CompletePropertyDescriptor: function CompletePropertyDescriptor(Desc) {
11204 assertRecord(this, 'Property Descriptor', 'Desc', Desc);
11205
11206 if (this.IsGenericDescriptor(Desc) || this.IsDataDescriptor(Desc)) {
11207 if (!has(Desc, '[[Value]]')) {
11208 Desc['[[Value]]'] = void 0;
11209 }
11210 if (!has(Desc, '[[Writable]]')) {
11211 Desc['[[Writable]]'] = false;
11212 }
11213 } else {
11214 if (!has(Desc, '[[Get]]')) {
11215 Desc['[[Get]]'] = void 0;
11216 }
11217 if (!has(Desc, '[[Set]]')) {
11218 Desc['[[Set]]'] = void 0;
11219 }
11220 }
11221 if (!has(Desc, '[[Enumerable]]')) {
11222 Desc['[[Enumerable]]'] = false;
11223 }
11224 if (!has(Desc, '[[Configurable]]')) {
11225 Desc['[[Configurable]]'] = false;
11226 }
11227 return Desc;
11228 },
11229
11230 // https://ecma-international.org/ecma-262/6.0/#sec-set-o-p-v-throw
11231 Set: function Set(O, P, V, Throw) {
11232 if (this.Type(O) !== 'Object') {
11233 throw new $TypeError('O must be an Object');
11234 }
11235 if (!this.IsPropertyKey(P)) {
11236 throw new $TypeError('P must be a Property Key');
11237 }
11238 if (this.Type(Throw) !== 'Boolean') {
11239 throw new $TypeError('Throw must be a Boolean');
11240 }
11241 if (Throw) {
11242 O[P] = V;
11243 return true;
11244 } else {
11245 try {
11246 O[P] = V;
11247 } catch (e) {
11248 return false;
11249 }
11250 }
11251 },
11252
11253 // https://ecma-international.org/ecma-262/6.0/#sec-hasownproperty
11254 HasOwnProperty: function HasOwnProperty(O, P) {
11255 if (this.Type(O) !== 'Object') {
11256 throw new $TypeError('O must be an Object');
11257 }
11258 if (!this.IsPropertyKey(P)) {
11259 throw new $TypeError('P must be a Property Key');
11260 }
11261 return has(O, P);
11262 },
11263
11264 // https://ecma-international.org/ecma-262/6.0/#sec-hasproperty
11265 HasProperty: function HasProperty(O, P) {
11266 if (this.Type(O) !== 'Object') {
11267 throw new $TypeError('O must be an Object');
11268 }
11269 if (!this.IsPropertyKey(P)) {
11270 throw new $TypeError('P must be a Property Key');
11271 }
11272 return P in O;
11273 },
11274
11275 // https://ecma-international.org/ecma-262/6.0/#sec-isconcatspreadable
11276 IsConcatSpreadable: function IsConcatSpreadable(O) {
11277 if (this.Type(O) !== 'Object') {
11278 return false;
11279 }
11280 if (hasSymbols && typeof $Symbol.isConcatSpreadable === 'symbol') {
11281 var spreadable = this.Get(O, Symbol.isConcatSpreadable);
11282 if (typeof spreadable !== 'undefined') {
11283 return this.ToBoolean(spreadable);
11284 }
11285 }
11286 return this.IsArray(O);
11287 },
11288
11289 // https://ecma-international.org/ecma-262/6.0/#sec-invoke
11290 Invoke: function Invoke(O, P) {
11291 if (!this.IsPropertyKey(P)) {
11292 throw new $TypeError('P must be a Property Key');
11293 }
11294 var argumentsList = arraySlice(arguments, 2);
11295 var func = this.GetV(O, P);
11296 return this.Call(func, O, argumentsList);
11297 },
11298
11299 // https://ecma-international.org/ecma-262/6.0/#sec-getiterator
11300 GetIterator: function GetIterator(obj, method) {
11301 var actualMethod = method;
11302 if (arguments.length < 2) {
11303 if (!hasSymbols) {
11304 throw new SyntaxError('GetIterator depends on native Symbol support when `method` is not passed');
11305 }
11306 actualMethod = this.GetMethod(obj, $Symbol.iterator);
11307 }
11308 var iterator = this.Call(actualMethod, obj);
11309 if (this.Type(iterator) !== 'Object') {
11310 throw new $TypeError('iterator must return an object');
11311 }
11312
11313 return iterator;
11314 },
11315
11316 // https://ecma-international.org/ecma-262/6.0/#sec-iteratornext
11317 IteratorNext: function IteratorNext(iterator, value) {
11318 var result = this.Invoke(iterator, 'next', arguments.length < 2 ? [] : [value]);
11319 if (this.Type(result) !== 'Object') {
11320 throw new $TypeError('iterator next must return an object');
11321 }
11322 return result;
11323 },
11324
11325 // https://ecma-international.org/ecma-262/6.0/#sec-iteratorcomplete
11326 IteratorComplete: function IteratorComplete(iterResult) {
11327 if (this.Type(iterResult) !== 'Object') {
11328 throw new $TypeError('Assertion failed: Type(iterResult) is not Object');
11329 }
11330 return this.ToBoolean(this.Get(iterResult, 'done'));
11331 },
11332
11333 // https://ecma-international.org/ecma-262/6.0/#sec-iteratorvalue
11334 IteratorValue: function IteratorValue(iterResult) {
11335 if (this.Type(iterResult) !== 'Object') {
11336 throw new $TypeError('Assertion failed: Type(iterResult) is not Object');
11337 }
11338 return this.Get(iterResult, 'value');
11339 },
11340
11341 // https://ecma-international.org/ecma-262/6.0/#sec-iteratorstep
11342 IteratorStep: function IteratorStep(iterator) {
11343 var result = this.IteratorNext(iterator);
11344 var done = this.IteratorComplete(result);
11345 return done === true ? false : result;
11346 },
11347
11348 // https://ecma-international.org/ecma-262/6.0/#sec-iteratorclose
11349 IteratorClose: function IteratorClose(iterator, completion) {
11350 if (this.Type(iterator) !== 'Object') {
11351 throw new $TypeError('Assertion failed: Type(iterator) is not Object');
11352 }
11353 if (!this.IsCallable(completion)) {
11354 throw new $TypeError('Assertion failed: completion is not a thunk for a Completion Record');
11355 }
11356 var completionThunk = completion;
11357
11358 var iteratorReturn = this.GetMethod(iterator, 'return');
11359
11360 if (typeof iteratorReturn === 'undefined') {
11361 return completionThunk();
11362 }
11363
11364 var completionRecord;
11365 try {
11366 var innerResult = this.Call(iteratorReturn, iterator, []);
11367 } catch (e) {
11368 // if we hit here, then "e" is the innerResult completion that needs re-throwing
11369
11370 // if the completion is of type "throw", this will throw.
11371 completionRecord = completionThunk();
11372 completionThunk = null; // ensure it's not called twice.
11373
11374 // if not, then return the innerResult completion
11375 throw e;
11376 }
11377 completionRecord = completionThunk(); // if innerResult worked, then throw if the completion does
11378 completionThunk = null; // ensure it's not called twice.
11379
11380 if (this.Type(innerResult) !== 'Object') {
11381 throw new $TypeError('iterator .return must return an object');
11382 }
11383
11384 return completionRecord;
11385 },
11386
11387 // https://ecma-international.org/ecma-262/6.0/#sec-createiterresultobject
11388 CreateIterResultObject: function CreateIterResultObject(value, done) {
11389 if (this.Type(done) !== 'Boolean') {
11390 throw new $TypeError('Assertion failed: Type(done) is not Boolean');
11391 }
11392 return {
11393 value: value,
11394 done: done
11395 };
11396 },
11397
11398 // https://ecma-international.org/ecma-262/6.0/#sec-regexpexec
11399 RegExpExec: function RegExpExec(R, S) {
11400 if (this.Type(R) !== 'Object') {
11401 throw new $TypeError('R must be an Object');
11402 }
11403 if (this.Type(S) !== 'String') {
11404 throw new $TypeError('S must be a String');
11405 }
11406 var exec = this.Get(R, 'exec');
11407 if (this.IsCallable(exec)) {
11408 var result = this.Call(exec, R, [S]);
11409 if (result === null || this.Type(result) === 'Object') {
11410 return result;
11411 }
11412 throw new $TypeError('"exec" method must return `null` or an Object');
11413 }
11414 return regexExec(R, S);
11415 },
11416
11417 // https://ecma-international.org/ecma-262/6.0/#sec-arrayspeciescreate
11418 ArraySpeciesCreate: function ArraySpeciesCreate(originalArray, length) {
11419 if (!this.IsInteger(length) || length < 0) {
11420 throw new $TypeError('Assertion failed: length must be an integer >= 0');
11421 }
11422 var len = length === 0 ? 0 : length;
11423 var C;
11424 var isArray = this.IsArray(originalArray);
11425 if (isArray) {
11426 C = this.Get(originalArray, 'constructor');
11427 // TODO: figure out how to make a cross-realm normal Array, a same-realm Array
11428 // if (this.IsConstructor(C)) {
11429 // if C is another realm's Array, C = undefined
11430 // Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(Array))) === null ?
11431 // }
11432 if (this.Type(C) === 'Object' && hasSymbols && $Symbol.species) {
11433 C = this.Get(C, $Symbol.species);
11434 if (C === null) {
11435 C = void 0;
11436 }
11437 }
11438 }
11439 if (typeof C === 'undefined') {
11440 return $Array(len);
11441 }
11442 if (!this.IsConstructor(C)) {
11443 throw new $TypeError('C must be a constructor');
11444 }
11445 return new C(len); // this.Construct(C, len);
11446 },
11447
11448 CreateDataProperty: function CreateDataProperty(O, P, V) {
11449 if (this.Type(O) !== 'Object') {
11450 throw new $TypeError('Assertion failed: Type(O) is not Object');
11451 }
11452 if (!this.IsPropertyKey(P)) {
11453 throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
11454 }
11455 var oldDesc = $gOPD(O, P);
11456 var extensible = oldDesc || this.IsExtensible(O);
11457 var immutable = oldDesc && (!oldDesc.writable || !oldDesc.configurable);
11458 if (immutable || !extensible) {
11459 return false;
11460 }
11461 return DefineOwnProperty(this, O, P, {
11462 '[[Configurable]]': true,
11463 '[[Enumerable]]': true,
11464 '[[Value]]': V,
11465 '[[Writable]]': true
11466 });
11467 },
11468
11469 // https://ecma-international.org/ecma-262/6.0/#sec-createdatapropertyorthrow
11470 CreateDataPropertyOrThrow: function CreateDataPropertyOrThrow(O, P, V) {
11471 if (this.Type(O) !== 'Object') {
11472 throw new $TypeError('Assertion failed: Type(O) is not Object');
11473 }
11474 if (!this.IsPropertyKey(P)) {
11475 throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
11476 }
11477 var success = this.CreateDataProperty(O, P, V);
11478 if (!success) {
11479 throw new $TypeError('unable to create data property');
11480 }
11481 return success;
11482 },
11483
11484 // https://www.ecma-international.org/ecma-262/6.0/#sec-objectcreate
11485 ObjectCreate: function ObjectCreate(proto, internalSlotsList) {
11486 if (proto !== null && this.Type(proto) !== 'Object') {
11487 throw new $TypeError('Assertion failed: proto must be null or an object');
11488 }
11489 var slots = arguments.length < 2 ? [] : internalSlotsList;
11490 if (slots.length > 0) {
11491 throw new $SyntaxError('es-abstract does not yet support internal slots');
11492 }
11493
11494 if (proto === null && !$ObjectCreate) {
11495 throw new $SyntaxError('native Object.create support is required to create null objects');
11496 }
11497
11498 return $ObjectCreate(proto);
11499 },
11500
11501 // https://ecma-international.org/ecma-262/6.0/#sec-advancestringindex
11502 AdvanceStringIndex: function AdvanceStringIndex(S, index, unicode) {
11503 if (this.Type(S) !== 'String') {
11504 throw new $TypeError('S must be a String');
11505 }
11506 if (!this.IsInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) {
11507 throw new $TypeError('Assertion failed: length must be an integer >= 0 and <= 2**53');
11508 }
11509 if (this.Type(unicode) !== 'Boolean') {
11510 throw new $TypeError('Assertion failed: unicode must be a Boolean');
11511 }
11512 if (!unicode) {
11513 return index + 1;
11514 }
11515 var length = S.length;
11516 if ((index + 1) >= length) {
11517 return index + 1;
11518 }
11519
11520 var first = $charCodeAt(S, index);
11521 if (first < 0xD800 || first > 0xDBFF) {
11522 return index + 1;
11523 }
11524
11525 var second = $charCodeAt(S, index + 1);
11526 if (second < 0xDC00 || second > 0xDFFF) {
11527 return index + 1;
11528 }
11529
11530 return index + 2;
11531 },
11532
11533 // https://www.ecma-international.org/ecma-262/6.0/#sec-createmethodproperty
11534 CreateMethodProperty: function CreateMethodProperty(O, P, V) {
11535 if (this.Type(O) !== 'Object') {
11536 throw new $TypeError('Assertion failed: Type(O) is not Object');
11537 }
11538
11539 if (!this.IsPropertyKey(P)) {
11540 throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
11541 }
11542
11543 var newDesc = {
11544 '[[Configurable]]': true,
11545 '[[Enumerable]]': false,
11546 '[[Value]]': V,
11547 '[[Writable]]': true
11548 };
11549 return DefineOwnProperty(this, O, P, newDesc);
11550 },
11551
11552 // https://www.ecma-international.org/ecma-262/6.0/#sec-definepropertyorthrow
11553 DefinePropertyOrThrow: function DefinePropertyOrThrow(O, P, desc) {
11554 if (this.Type(O) !== 'Object') {
11555 throw new $TypeError('Assertion failed: Type(O) is not Object');
11556 }
11557
11558 if (!this.IsPropertyKey(P)) {
11559 throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
11560 }
11561
11562 var Desc = isPropertyDescriptor(this, desc) ? desc : this.ToPropertyDescriptor(desc);
11563 if (!isPropertyDescriptor(this, Desc)) {
11564 throw new $TypeError('Assertion failed: Desc is not a valid Property Descriptor');
11565 }
11566
11567 return DefineOwnProperty(this, O, P, Desc);
11568 },
11569
11570 // https://www.ecma-international.org/ecma-262/6.0/#sec-deletepropertyorthrow
11571 DeletePropertyOrThrow: function DeletePropertyOrThrow(O, P) {
11572 if (this.Type(O) !== 'Object') {
11573 throw new $TypeError('Assertion failed: Type(O) is not Object');
11574 }
11575
11576 if (!this.IsPropertyKey(P)) {
11577 throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
11578 }
11579
11580 var success = delete O[P];
11581 if (!success) {
11582 throw new TypeError('Attempt to delete property failed.');
11583 }
11584 return success;
11585 },
11586
11587 // https://www.ecma-international.org/ecma-262/6.0/#sec-enumerableownnames
11588 EnumerableOwnNames: function EnumerableOwnNames(O) {
11589 if (this.Type(O) !== 'Object') {
11590 throw new $TypeError('Assertion failed: Type(O) is not Object');
11591 }
11592
11593 return keys(O);
11594 },
11595
11596 // https://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-number-prototype-object
11597 thisNumberValue: function thisNumberValue(value) {
11598 if (this.Type(value) === 'Number') {
11599 return value;
11600 }
11601
11602 return $NumberValueOf(value);
11603 },
11604
11605 // https://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-boolean-prototype-object
11606 thisBooleanValue: function thisBooleanValue(value) {
11607 if (this.Type(value) === 'Boolean') {
11608 return value;
11609 }
11610
11611 return $BooleanValueOf(value);
11612 },
11613
11614 // https://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-string-prototype-object
11615 thisStringValue: function thisStringValue(value) {
11616 if (this.Type(value) === 'String') {
11617 return value;
11618 }
11619
11620 return $StringValueOf(value);
11621 },
11622
11623 // https://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-date-prototype-object
11624 thisTimeValue: function thisTimeValue(value) {
11625 return $DateValueOf(value);
11626 },
11627
11628 // https://www.ecma-international.org/ecma-262/6.0/#sec-setintegritylevel
11629 SetIntegrityLevel: function SetIntegrityLevel(O, level) {
11630 if (this.Type(O) !== 'Object') {
11631 throw new $TypeError('Assertion failed: Type(O) is not Object');
11632 }
11633 if (level !== 'sealed' && level !== 'frozen') {
11634 throw new $TypeError('Assertion failed: `level` must be `"sealed"` or `"frozen"`');
11635 }
11636 if (!$preventExtensions) {
11637 throw new $SyntaxError('SetIntegrityLevel requires native `Object.preventExtensions` support');
11638 }
11639 var status = $preventExtensions(O);
11640 if (!status) {
11641 return false;
11642 }
11643 if (!$gOPN) {
11644 throw new $SyntaxError('SetIntegrityLevel requires native `Object.getOwnPropertyNames` support');
11645 }
11646 var theKeys = $gOPN(O);
11647 var ES = this;
11648 if (level === 'sealed') {
11649 forEach(theKeys, function (k) {
11650 ES.DefinePropertyOrThrow(O, k, { configurable: false });
11651 });
11652 } else if (level === 'frozen') {
11653 forEach(theKeys, function (k) {
11654 var currentDesc = $gOPD(O, k);
11655 if (typeof currentDesc !== 'undefined') {
11656 var desc;
11657 if (ES.IsAccessorDescriptor(ES.ToPropertyDescriptor(currentDesc))) {
11658 desc = { configurable: false };
11659 } else {
11660 desc = { configurable: false, writable: false };
11661 }
11662 ES.DefinePropertyOrThrow(O, k, desc);
11663 }
11664 });
11665 }
11666 return true;
11667 },
11668
11669 // https://www.ecma-international.org/ecma-262/6.0/#sec-testintegritylevel
11670 TestIntegrityLevel: function TestIntegrityLevel(O, level) {
11671 if (this.Type(O) !== 'Object') {
11672 throw new $TypeError('Assertion failed: Type(O) is not Object');
11673 }
11674 if (level !== 'sealed' && level !== 'frozen') {
11675 throw new $TypeError('Assertion failed: `level` must be `"sealed"` or `"frozen"`');
11676 }
11677 var status = this.IsExtensible(O);
11678 if (status) {
11679 return false;
11680 }
11681 var theKeys = $gOPN(O);
11682 var ES = this;
11683 return theKeys.length === 0 || every(theKeys, function (k) {
11684 var currentDesc = $gOPD(O, k);
11685 if (typeof currentDesc !== 'undefined') {
11686 if (currentDesc.configurable) {
11687 return false;
11688 }
11689 if (level === 'frozen' && ES.IsDataDescriptor(ES.ToPropertyDescriptor(currentDesc)) && currentDesc.writable) {
11690 return false;
11691 }
11692 }
11693 return true;
11694 });
11695 },
11696
11697 // https://www.ecma-international.org/ecma-262/6.0/#sec-ordinaryhasinstance
11698 OrdinaryHasInstance: function OrdinaryHasInstance(C, O) {
11699 if (this.IsCallable(C) === false) {
11700 return false;
11701 }
11702 if (this.Type(O) !== 'Object') {
11703 return false;
11704 }
11705 var P = this.Get(C, 'prototype');
11706 if (this.Type(P) !== 'Object') {
11707 throw new $TypeError('OrdinaryHasInstance called on an object with an invalid prototype property.');
11708 }
11709 return O instanceof C;
11710 },
11711
11712 // https://www.ecma-international.org/ecma-262/6.0/#sec-ordinaryhasproperty
11713 OrdinaryHasProperty: function OrdinaryHasProperty(O, P) {
11714 if (this.Type(O) !== 'Object') {
11715 throw new $TypeError('Assertion failed: Type(O) is not Object');
11716 }
11717 if (!this.IsPropertyKey(P)) {
11718 throw new $TypeError('Assertion failed: P must be a Property Key');
11719 }
11720 return P in O;
11721 },
11722
11723 // https://www.ecma-international.org/ecma-262/6.0/#sec-instanceofoperator
11724 InstanceofOperator: function InstanceofOperator(O, C) {
11725 if (this.Type(O) !== 'Object') {
11726 throw new $TypeError('Assertion failed: Type(O) is not Object');
11727 }
11728 var instOfHandler = hasSymbols && $Symbol.hasInstance ? this.GetMethod(C, $Symbol.hasInstance) : void 0;
11729 if (typeof instOfHandler !== 'undefined') {
11730 return this.ToBoolean(this.Call(instOfHandler, C, [O]));
11731 }
11732 if (!this.IsCallable(C)) {
11733 throw new $TypeError('`C` is not Callable');
11734 }
11735 return this.OrdinaryHasInstance(C, O);
11736 },
11737
11738 // https://www.ecma-international.org/ecma-262/6.0/#sec-ispromise
11739 IsPromise: function IsPromise(x) {
11740 if (this.Type(x) !== 'Object') {
11741 return false;
11742 }
11743 if (!$Promise) { // Promises are not supported
11744 return false;
11745 }
11746 try {
11747 $PromiseThen(x); // throws if not a promise
11748 } catch (e) {
11749 return false;
11750 }
11751 return true;
11752 },
11753
11754 // https://www.ecma-international.org/ecma-262/6.0/#sec-abstract-equality-comparison
11755 'Abstract Equality Comparison': function AbstractEqualityComparison(x, y) {
11756 var xType = this.Type(x);
11757 var yType = this.Type(y);
11758 if (xType === yType) {
11759 return x === y; // ES6+ specified this shortcut anyways.
11760 }
11761 if (x == null && y == null) {
11762 return true;
11763 }
11764 if (xType === 'Number' && yType === 'String') {
11765 return this['Abstract Equality Comparison'](x, this.ToNumber(y));
11766 }
11767 if (xType === 'String' && yType === 'Number') {
11768 return this['Abstract Equality Comparison'](this.ToNumber(x), y);
11769 }
11770 if (xType === 'Boolean') {
11771 return this['Abstract Equality Comparison'](this.ToNumber(x), y);
11772 }
11773 if (yType === 'Boolean') {
11774 return this['Abstract Equality Comparison'](x, this.ToNumber(y));
11775 }
11776 if ((xType === 'String' || xType === 'Number' || xType === 'Symbol') && yType === 'Object') {
11777 return this['Abstract Equality Comparison'](x, this.ToPrimitive(y));
11778 }
11779 if (xType === 'Object' && (yType === 'String' || yType === 'Number' || yType === 'Symbol')) {
11780 return this['Abstract Equality Comparison'](this.ToPrimitive(x), y);
11781 }
11782 return false;
11783 },
11784
11785 // eslint-disable-next-line max-lines-per-function, max-statements, id-length, max-params
11786 ValidateAndApplyPropertyDescriptor: function ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current) {
11787 // this uses the ES2017+ logic, since it fixes a number of bugs in the ES2015 logic.
11788 var oType = this.Type(O);
11789 if (oType !== 'Undefined' && oType !== 'Object') {
11790 throw new $TypeError('Assertion failed: O must be undefined or an Object');
11791 }
11792 if (this.Type(extensible) !== 'Boolean') {
11793 throw new $TypeError('Assertion failed: extensible must be a Boolean');
11794 }
11795 if (!isPropertyDescriptor(this, Desc)) {
11796 throw new $TypeError('Assertion failed: Desc must be a Property Descriptor');
11797 }
11798 if (this.Type(current) !== 'Undefined' && !isPropertyDescriptor(this, current)) {
11799 throw new $TypeError('Assertion failed: current must be a Property Descriptor, or undefined');
11800 }
11801 if (oType !== 'Undefined' && !this.IsPropertyKey(P)) {
11802 throw new $TypeError('Assertion failed: if O is not undefined, P must be a Property Key');
11803 }
11804 if (this.Type(current) === 'Undefined') {
11805 if (!extensible) {
11806 return false;
11807 }
11808 if (this.IsGenericDescriptor(Desc) || this.IsDataDescriptor(Desc)) {
11809 if (oType !== 'Undefined') {
11810 DefineOwnProperty(this, O, P, {
11811 '[[Configurable]]': Desc['[[Configurable]]'],
11812 '[[Enumerable]]': Desc['[[Enumerable]]'],
11813 '[[Value]]': Desc['[[Value]]'],
11814 '[[Writable]]': Desc['[[Writable]]']
11815 });
11816 }
11817 } else {
11818 if (!this.IsAccessorDescriptor(Desc)) {
11819 throw new $TypeError('Assertion failed: Desc is not an accessor descriptor');
11820 }
11821 if (oType !== 'Undefined') {
11822 return DefineOwnProperty(this, O, P, Desc);
11823 }
11824 }
11825 return true;
11826 }
11827 if (this.IsGenericDescriptor(Desc) && !('[[Configurable]]' in Desc) && !('[[Enumerable]]' in Desc)) {
11828 return true;
11829 }
11830 if (isSamePropertyDescriptor(this, Desc, current)) {
11831 return true; // removed by ES2017, but should still be correct
11832 }
11833 // "if every field in Desc is absent, return true" can't really match the assertion that it's a Property Descriptor
11834 if (!current['[[Configurable]]']) {
11835 if (Desc['[[Configurable]]']) {
11836 return false;
11837 }
11838 if ('[[Enumerable]]' in Desc && !Desc['[[Enumerable]]'] === !!current['[[Enumerable]]']) {
11839 return false;
11840 }
11841 }
11842 if (this.IsGenericDescriptor(Desc)) {
11843 // no further validation is required.
11844 } else if (this.IsDataDescriptor(current) !== this.IsDataDescriptor(Desc)) {
11845 if (!current['[[Configurable]]']) {
11846 return false;
11847 }
11848 if (this.IsDataDescriptor(current)) {
11849 if (oType !== 'Undefined') {
11850 DefineOwnProperty(this, O, P, {
11851 '[[Configurable]]': current['[[Configurable]]'],
11852 '[[Enumerable]]': current['[[Enumerable]]'],
11853 '[[Get]]': undefined
11854 });
11855 }
11856 } else if (oType !== 'Undefined') {
11857 DefineOwnProperty(this, O, P, {
11858 '[[Configurable]]': current['[[Configurable]]'],
11859 '[[Enumerable]]': current['[[Enumerable]]'],
11860 '[[Value]]': undefined
11861 });
11862 }
11863 } else if (this.IsDataDescriptor(current) && this.IsDataDescriptor(Desc)) {
11864 if (!current['[[Configurable]]'] && !current['[[Writable]]']) {
11865 if ('[[Writable]]' in Desc && Desc['[[Writable]]']) {
11866 return false;
11867 }
11868 if ('[[Value]]' in Desc && !this.SameValue(Desc['[[Value]]'], current['[[Value]]'])) {
11869 return false;
11870 }
11871 return true;
11872 }
11873 } else if (this.IsAccessorDescriptor(current) && this.IsAccessorDescriptor(Desc)) {
11874 if (!current['[[Configurable]]']) {
11875 if ('[[Set]]' in Desc && !this.SameValue(Desc['[[Set]]'], current['[[Set]]'])) {
11876 return false;
11877 }
11878 if ('[[Get]]' in Desc && !this.SameValue(Desc['[[Get]]'], current['[[Get]]'])) {
11879 return false;
11880 }
11881 return true;
11882 }
11883 } else {
11884 throw new $TypeError('Assertion failed: current and Desc are not both data, both accessors, or one accessor and one data.');
11885 }
11886 if (oType !== 'Undefined') {
11887 return DefineOwnProperty(this, O, P, Desc);
11888 }
11889 return true;
11890 },
11891
11892 // https://www.ecma-international.org/ecma-262/6.0/#sec-ordinarydefineownproperty
11893 OrdinaryDefineOwnProperty: function OrdinaryDefineOwnProperty(O, P, Desc) {
11894 if (this.Type(O) !== 'Object') {
11895 throw new $TypeError('Assertion failed: O must be an Object');
11896 }
11897 if (!this.IsPropertyKey(P)) {
11898 throw new $TypeError('Assertion failed: P must be a Property Key');
11899 }
11900 if (!isPropertyDescriptor(this, Desc)) {
11901 throw new $TypeError('Assertion failed: Desc must be a Property Descriptor');
11902 }
11903 var desc = $gOPD(O, P);
11904 var current = desc && this.ToPropertyDescriptor(desc);
11905 var extensible = this.IsExtensible(O);
11906 return this.ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current);
11907 },
11908
11909 // https://www.ecma-international.org/ecma-262/6.0/#sec-ordinarygetownproperty
11910 OrdinaryGetOwnProperty: function OrdinaryGetOwnProperty(O, P) {
11911 if (this.Type(O) !== 'Object') {
11912 throw new $TypeError('Assertion failed: O must be an Object');
11913 }
11914 if (!this.IsPropertyKey(P)) {
11915 throw new $TypeError('Assertion failed: P must be a Property Key');
11916 }
11917 if (!has(O, P)) {
11918 return void 0;
11919 }
11920 if (!$gOPD) {
11921 // ES3 fallback
11922 var arrayLength = this.IsArray(O) && P === 'length';
11923 var regexLastIndex = this.IsRegExp(O) && P === 'lastIndex';
11924 return {
11925 '[[Configurable]]': !(arrayLength || regexLastIndex),
11926 '[[Enumerable]]': $isEnumerable(O, P),
11927 '[[Value]]': O[P],
11928 '[[Writable]]': true
11929 };
11930 }
11931 return this.ToPropertyDescriptor($gOPD(O, P));
11932 },
11933
11934 // https://www.ecma-international.org/ecma-262/6.0/#sec-arraycreate
11935 ArrayCreate: function ArrayCreate(length) {
11936 if (!this.IsInteger(length) || length < 0) {
11937 throw new $TypeError('Assertion failed: `length` must be an integer Number >= 0');
11938 }
11939 if (length > MAX_ARRAY_LENGTH) {
11940 throw new $RangeError('length is greater than (2**32 - 1)');
11941 }
11942 var proto = arguments.length > 1 ? arguments[1] : $ArrayPrototype;
11943 var A = []; // steps 5 - 7, and 9
11944 if (proto !== $ArrayPrototype) { // step 8
11945 if (!$setProto) {
11946 throw new $SyntaxError('ArrayCreate: a `proto` argument that is not `Array.prototype` is not supported in an environment that does not support setting the [[Prototype]]');
11947 }
11948 $setProto(A, proto);
11949 }
11950 if (length !== 0) { // bypasses the need for step 2
11951 A.length = length;
11952 }
11953 /* step 10, the above as a shortcut for the below
11954 this.OrdinaryDefineOwnProperty(A, 'length', {
11955 '[[Configurable]]': false,
11956 '[[Enumerable]]': false,
11957 '[[Value]]': length,
11958 '[[Writable]]': true
11959 });
11960 */
11961 return A;
11962 },
11963
11964 // eslint-disable-next-line max-statements, max-lines-per-function
11965 ArraySetLength: function ArraySetLength(A, Desc) {
11966 if (!this.IsArray(A)) {
11967 throw new $TypeError('Assertion failed: A must be an Array');
11968 }
11969 if (!isPropertyDescriptor(this, Desc)) {
11970 throw new $TypeError('Assertion failed: Desc must be a Property Descriptor');
11971 }
11972 if (!('[[Value]]' in Desc)) {
11973 return this.OrdinaryDefineOwnProperty(A, 'length', Desc);
11974 }
11975 var newLenDesc = assign({}, Desc);
11976 var newLen = this.ToUint32(Desc['[[Value]]']);
11977 var numberLen = this.ToNumber(Desc['[[Value]]']);
11978 if (newLen !== numberLen) {
11979 throw new $RangeError('Invalid array length');
11980 }
11981 newLenDesc['[[Value]]'] = newLen;
11982 var oldLenDesc = this.OrdinaryGetOwnProperty(A, 'length');
11983 if (!this.IsDataDescriptor(oldLenDesc)) {
11984 throw new $TypeError('Assertion failed: an array had a non-data descriptor on `length`');
11985 }
11986 var oldLen = oldLenDesc['[[Value]]'];
11987 if (newLen >= oldLen) {
11988 return this.OrdinaryDefineOwnProperty(A, 'length', newLenDesc);
11989 }
11990 if (!oldLenDesc['[[Writable]]']) {
11991 return false;
11992 }
11993 var newWritable;
11994 if (!('[[Writable]]' in newLenDesc) || newLenDesc['[[Writable]]']) {
11995 newWritable = true;
11996 } else {
11997 newWritable = false;
11998 newLenDesc['[[Writable]]'] = true;
11999 }
12000 var succeeded = this.OrdinaryDefineOwnProperty(A, 'length', newLenDesc);
12001 if (!succeeded) {
12002 return false;
12003 }
12004 while (newLen < oldLen) {
12005 oldLen -= 1;
12006 var deleteSucceeded = delete A[this.ToString(oldLen)];
12007 if (!deleteSucceeded) {
12008 newLenDesc['[[Value]]'] = oldLen + 1;
12009 if (!newWritable) {
12010 newLenDesc['[[Writable]]'] = false;
12011 this.OrdinaryDefineOwnProperty(A, 'length', newLenDesc);
12012 return false;
12013 }
12014 }
12015 }
12016 if (!newWritable) {
12017 return this.OrdinaryDefineOwnProperty(A, 'length', { '[[Writable]]': false });
12018 }
12019 return true;
12020 },
12021
12022 // https://www.ecma-international.org/ecma-262/6.0/#sec-createhtml
12023 CreateHTML: function CreateHTML(string, tag, attribute, value) {
12024 if (this.Type(tag) !== 'String' || this.Type(attribute) !== 'String') {
12025 throw new $TypeError('Assertion failed: `tag` and `attribute` must be strings');
12026 }
12027 var str = this.RequireObjectCoercible(string);
12028 var S = this.ToString(str);
12029 var p1 = '<' + tag;
12030 if (attribute !== '') {
12031 var V = this.ToString(value);
12032 var escapedV = $replace(V, /\x22/g, '&quot;');
12033 p1 += '\x20' + attribute + '\x3D\x22' + escapedV + '\x22';
12034 }
12035 return p1 + '>' + S + '</' + tag + '>';
12036 },
12037
12038 // https://www.ecma-international.org/ecma-262/6.0/#sec-getownpropertykeys
12039 GetOwnPropertyKeys: function GetOwnPropertyKeys(O, Type) {
12040 if (this.Type(O) !== 'Object') {
12041 throw new $TypeError('Assertion failed: Type(O) is not Object');
12042 }
12043 if (Type === 'Symbol') {
12044 return hasSymbols && $gOPS ? $gOPS(O) : [];
12045 }
12046 if (Type === 'String') {
12047 if (!$gOPN) {
12048 return keys(O);
12049 }
12050 return $gOPN(O);
12051 }
12052 throw new $TypeError('Assertion failed: `Type` must be `"String"` or `"Symbol"`');
12053 },
12054
12055 // https://www.ecma-international.org/ecma-262/6.0/#sec-symboldescriptivestring
12056 SymbolDescriptiveString: function SymbolDescriptiveString(sym) {
12057 if (this.Type(sym) !== 'Symbol') {
12058 throw new $TypeError('Assertion failed: `sym` must be a Symbol');
12059 }
12060 return $SymbolToString(sym);
12061 },
12062
12063 // https://www.ecma-international.org/ecma-262/6.0/#sec-getsubstitution
12064 // eslint-disable-next-line max-statements, max-params, max-lines-per-function
12065 GetSubstitution: function GetSubstitution(matched, str, position, captures, replacement) {
12066 if (this.Type(matched) !== 'String') {
12067 throw new $TypeError('Assertion failed: `matched` must be a String');
12068 }
12069 var matchLength = matched.length;
12070
12071 if (this.Type(str) !== 'String') {
12072 throw new $TypeError('Assertion failed: `str` must be a String');
12073 }
12074 var stringLength = str.length;
12075
12076 if (!this.IsInteger(position) || position < 0 || position > stringLength) {
12077 throw new $TypeError('Assertion failed: `position` must be a nonnegative integer, and less than or equal to the length of `string`, got ' + inspect(position));
12078 }
12079
12080 var ES = this;
12081 var isStringOrHole = function (capture, index, arr) { return ES.Type(capture) === 'String' || !(index in arr); };
12082 if (!this.IsArray(captures) || !every(captures, isStringOrHole)) {
12083 throw new $TypeError('Assertion failed: `captures` must be a List of Strings, got ' + inspect(captures));
12084 }
12085
12086 if (this.Type(replacement) !== 'String') {
12087 throw new $TypeError('Assertion failed: `replacement` must be a String');
12088 }
12089
12090 var tailPos = position + matchLength;
12091 var m = captures.length;
12092
12093 var result = '';
12094 for (var i = 0; i < replacement.length; i += 1) {
12095 // if this is a $, and it's not the end of the replacement
12096 var current = replacement[i];
12097 var isLast = (i + 1) >= replacement.length;
12098 var nextIsLast = (i + 2) >= replacement.length;
12099 if (current === '$' && !isLast) {
12100 var next = replacement[i + 1];
12101 if (next === '$') {
12102 result += '$';
12103 i += 1;
12104 } else if (next === '&') {
12105 result += matched;
12106 i += 1;
12107 } else if (next === '`') {
12108 result += position === 0 ? '' : strSlice(str, 0, position - 1);
12109 i += 1;
12110 } else if (next === "'") {
12111 result += tailPos >= stringLength ? '' : strSlice(str, tailPos);
12112 i += 1;
12113 } else {
12114 var nextNext = nextIsLast ? null : replacement[i + 2];
12115 if (isDigit(next) && next !== '0' && (nextIsLast || !isDigit(nextNext))) {
12116 // $1 through $9, and not followed by a digit
12117 var n = parseInteger(next, 10);
12118 // if (n > m, impl-defined)
12119 result += (n <= m && this.Type(captures[n - 1]) === 'Undefined') ? '' : captures[n - 1];
12120 i += 1;
12121 } else if (isDigit(next) && (nextIsLast || isDigit(nextNext))) {
12122 // $00 through $99
12123 var nn = next + nextNext;
12124 var nnI = parseInteger(nn, 10) - 1;
12125 // if nn === '00' or nn > m, impl-defined
12126 result += (nn <= m && this.Type(captures[nnI]) === 'Undefined') ? '' : captures[nnI];
12127 i += 2;
12128 } else {
12129 result += '$';
12130 }
12131 }
12132 } else {
12133 // the final $, or else not a $
12134 result += replacement[i];
12135 }
12136 }
12137 return result;
12138 }
12139});
12140
12141delete ES6.CheckObjectCoercible; // renamed in ES6 to RequireObjectCoercible
12142
12143module.exports = ES6;
12144
12145},{"./GetIntrinsic":191,"./es5":194,"./helpers/assertRecord":196,"./helpers/assign":197,"./helpers/callBind":198,"./helpers/every":199,"./helpers/forEach":200,"./helpers/isFinite":201,"./helpers/isNaN":202,"./helpers/isPrimitive":203,"./helpers/isPropertyDescriptor":204,"./helpers/isSamePropertyDescriptor":205,"./helpers/mod":206,"./helpers/sign":207,"es-to-primitive/es6":213,"has":222,"has-symbols":220,"is-regex":231,"object-inspect":239,"object-keys":209}],193:[function(require,module,exports){
12146'use strict';
12147
12148var GetIntrinsic = require('./GetIntrinsic');
12149
12150var $Array = GetIntrinsic('%Array%');
12151
12152var hasSymbols = require('has-symbols')();
12153
12154var ES2015 = require('./es2015');
12155var assign = require('./helpers/assign');
12156var callBind = require('./helpers/callBind');
12157
12158var $arrayPush = callBind($Array.prototype.push);
12159var $arraySlice = callBind($Array.prototype.slice);
12160var $arrayJoin = callBind($Array.prototype.join);
12161
12162var ES2016 = assign(assign({}, ES2015), {
12163 // https://www.ecma-international.org/ecma-262/7.0/#sec-samevaluenonnumber
12164 SameValueNonNumber: function SameValueNonNumber(x, y) {
12165 if (typeof x === 'number' || typeof x !== typeof y) {
12166 throw new TypeError('SameValueNonNumber requires two non-number values of the same type.');
12167 }
12168 return this.SameValue(x, y);
12169 },
12170
12171 // https://www.ecma-international.org/ecma-262/7.0/#sec-iterabletoarraylike
12172 IterableToArrayLike: function IterableToArrayLike(items) {
12173 var usingIterator;
12174 if (hasSymbols) {
12175 usingIterator = this.GetMethod(items, Symbol.iterator);
12176 } else if (this.IsArray(items)) {
12177 usingIterator = function () {
12178 var i = -1;
12179 var arr = this; // eslint-disable-line no-invalid-this
12180 return {
12181 next: function () {
12182 i += 1;
12183 return {
12184 done: i >= arr.length,
12185 value: arr[i]
12186 };
12187 }
12188 };
12189 };
12190 } else if (this.Type(items) === 'String') {
12191 var ES = this;
12192 usingIterator = function () {
12193 var i = 0;
12194 return {
12195 next: function () {
12196 var nextIndex = ES.AdvanceStringIndex(items, i, true);
12197 var value = $arrayJoin($arraySlice(items, i, nextIndex), '');
12198 i = nextIndex;
12199 return {
12200 done: nextIndex > items.length,
12201 value: value
12202 };
12203 }
12204 };
12205 };
12206 }
12207 if (typeof usingIterator !== 'undefined') {
12208 var iterator = this.GetIterator(items, usingIterator);
12209 var values = [];
12210 var next = true;
12211 while (next) {
12212 next = this.IteratorStep(iterator);
12213 if (next) {
12214 var nextValue = this.IteratorValue(next);
12215 $arrayPush(values, nextValue);
12216 }
12217 }
12218 return values;
12219 }
12220
12221 return this.ToObject(items);
12222 }
12223});
12224
12225module.exports = ES2016;
12226
12227},{"./GetIntrinsic":191,"./es2015":192,"./helpers/assign":197,"./helpers/callBind":198,"has-symbols":220}],194:[function(require,module,exports){
12228'use strict';
12229
12230var GetIntrinsic = require('./GetIntrinsic');
12231
12232var $Object = GetIntrinsic('%Object%');
12233var $TypeError = GetIntrinsic('%TypeError%');
12234var $String = GetIntrinsic('%String%');
12235var $Number = GetIntrinsic('%Number%');
12236
12237var assertRecord = require('./helpers/assertRecord');
12238var isPropertyDescriptor = require('./helpers/isPropertyDescriptor');
12239var $isNaN = require('./helpers/isNaN');
12240var $isFinite = require('./helpers/isFinite');
12241
12242var sign = require('./helpers/sign');
12243var mod = require('./helpers/mod');
12244
12245var IsCallable = require('is-callable');
12246var toPrimitive = require('es-to-primitive/es5');
12247
12248var has = require('has');
12249
12250var callBind = require('./helpers/callBind');
12251var strSlice = callBind($String.prototype.slice);
12252
12253var isPrefixOf = function isPrefixOf(prefix, string) {
12254 if (prefix === string) {
12255 return true;
12256 }
12257 if (prefix.length > string.length) {
12258 return false;
12259 }
12260 return strSlice(string, 0, prefix.length) === prefix;
12261};
12262
12263// https://es5.github.io/#x9
12264var ES5 = {
12265 ToPrimitive: toPrimitive,
12266
12267 ToBoolean: function ToBoolean(value) {
12268 return !!value;
12269 },
12270 ToNumber: function ToNumber(value) {
12271 return +value; // eslint-disable-line no-implicit-coercion
12272 },
12273 ToInteger: function ToInteger(value) {
12274 var number = this.ToNumber(value);
12275 if ($isNaN(number)) { return 0; }
12276 if (number === 0 || !$isFinite(number)) { return number; }
12277 return sign(number) * Math.floor(Math.abs(number));
12278 },
12279 ToInt32: function ToInt32(x) {
12280 return this.ToNumber(x) >> 0;
12281 },
12282 ToUint32: function ToUint32(x) {
12283 return this.ToNumber(x) >>> 0;
12284 },
12285 ToUint16: function ToUint16(value) {
12286 var number = this.ToNumber(value);
12287 if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; }
12288 var posInt = sign(number) * Math.floor(Math.abs(number));
12289 return mod(posInt, 0x10000);
12290 },
12291 ToString: function ToString(value) {
12292 return $String(value);
12293 },
12294 ToObject: function ToObject(value) {
12295 this.CheckObjectCoercible(value);
12296 return $Object(value);
12297 },
12298 CheckObjectCoercible: function CheckObjectCoercible(value, optMessage) {
12299 /* jshint eqnull:true */
12300 if (value == null) {
12301 throw new $TypeError(optMessage || 'Cannot call method on ' + value);
12302 }
12303 return value;
12304 },
12305 IsCallable: IsCallable,
12306 SameValue: function SameValue(x, y) {
12307 if (x === y) { // 0 === -0, but they are not identical.
12308 if (x === 0) { return 1 / x === 1 / y; }
12309 return true;
12310 }
12311 return $isNaN(x) && $isNaN(y);
12312 },
12313
12314 // https://www.ecma-international.org/ecma-262/5.1/#sec-8
12315 Type: function Type(x) {
12316 if (x === null) {
12317 return 'Null';
12318 }
12319 if (typeof x === 'undefined') {
12320 return 'Undefined';
12321 }
12322 if (typeof x === 'function' || typeof x === 'object') {
12323 return 'Object';
12324 }
12325 if (typeof x === 'number') {
12326 return 'Number';
12327 }
12328 if (typeof x === 'boolean') {
12329 return 'Boolean';
12330 }
12331 if (typeof x === 'string') {
12332 return 'String';
12333 }
12334 },
12335
12336 // https://ecma-international.org/ecma-262/6.0/#sec-property-descriptor-specification-type
12337 IsPropertyDescriptor: function IsPropertyDescriptor(Desc) {
12338 return isPropertyDescriptor(this, Desc);
12339 },
12340
12341 // https://ecma-international.org/ecma-262/5.1/#sec-8.10.1
12342 IsAccessorDescriptor: function IsAccessorDescriptor(Desc) {
12343 if (typeof Desc === 'undefined') {
12344 return false;
12345 }
12346
12347 assertRecord(this, 'Property Descriptor', 'Desc', Desc);
12348
12349 if (!has(Desc, '[[Get]]') && !has(Desc, '[[Set]]')) {
12350 return false;
12351 }
12352
12353 return true;
12354 },
12355
12356 // https://ecma-international.org/ecma-262/5.1/#sec-8.10.2
12357 IsDataDescriptor: function IsDataDescriptor(Desc) {
12358 if (typeof Desc === 'undefined') {
12359 return false;
12360 }
12361
12362 assertRecord(this, 'Property Descriptor', 'Desc', Desc);
12363
12364 if (!has(Desc, '[[Value]]') && !has(Desc, '[[Writable]]')) {
12365 return false;
12366 }
12367
12368 return true;
12369 },
12370
12371 // https://ecma-international.org/ecma-262/5.1/#sec-8.10.3
12372 IsGenericDescriptor: function IsGenericDescriptor(Desc) {
12373 if (typeof Desc === 'undefined') {
12374 return false;
12375 }
12376
12377 assertRecord(this, 'Property Descriptor', 'Desc', Desc);
12378
12379 if (!this.IsAccessorDescriptor(Desc) && !this.IsDataDescriptor(Desc)) {
12380 return true;
12381 }
12382
12383 return false;
12384 },
12385
12386 // https://ecma-international.org/ecma-262/5.1/#sec-8.10.4
12387 FromPropertyDescriptor: function FromPropertyDescriptor(Desc) {
12388 if (typeof Desc === 'undefined') {
12389 return Desc;
12390 }
12391
12392 assertRecord(this, 'Property Descriptor', 'Desc', Desc);
12393
12394 if (this.IsDataDescriptor(Desc)) {
12395 return {
12396 value: Desc['[[Value]]'],
12397 writable: !!Desc['[[Writable]]'],
12398 enumerable: !!Desc['[[Enumerable]]'],
12399 configurable: !!Desc['[[Configurable]]']
12400 };
12401 } else if (this.IsAccessorDescriptor(Desc)) {
12402 return {
12403 get: Desc['[[Get]]'],
12404 set: Desc['[[Set]]'],
12405 enumerable: !!Desc['[[Enumerable]]'],
12406 configurable: !!Desc['[[Configurable]]']
12407 };
12408 } else {
12409 throw new $TypeError('FromPropertyDescriptor must be called with a fully populated Property Descriptor');
12410 }
12411 },
12412
12413 // https://ecma-international.org/ecma-262/5.1/#sec-8.10.5
12414 ToPropertyDescriptor: function ToPropertyDescriptor(Obj) {
12415 if (this.Type(Obj) !== 'Object') {
12416 throw new $TypeError('ToPropertyDescriptor requires an object');
12417 }
12418
12419 var desc = {};
12420 if (has(Obj, 'enumerable')) {
12421 desc['[[Enumerable]]'] = this.ToBoolean(Obj.enumerable);
12422 }
12423 if (has(Obj, 'configurable')) {
12424 desc['[[Configurable]]'] = this.ToBoolean(Obj.configurable);
12425 }
12426 if (has(Obj, 'value')) {
12427 desc['[[Value]]'] = Obj.value;
12428 }
12429 if (has(Obj, 'writable')) {
12430 desc['[[Writable]]'] = this.ToBoolean(Obj.writable);
12431 }
12432 if (has(Obj, 'get')) {
12433 var getter = Obj.get;
12434 if (typeof getter !== 'undefined' && !this.IsCallable(getter)) {
12435 throw new TypeError('getter must be a function');
12436 }
12437 desc['[[Get]]'] = getter;
12438 }
12439 if (has(Obj, 'set')) {
12440 var setter = Obj.set;
12441 if (typeof setter !== 'undefined' && !this.IsCallable(setter)) {
12442 throw new $TypeError('setter must be a function');
12443 }
12444 desc['[[Set]]'] = setter;
12445 }
12446
12447 if ((has(desc, '[[Get]]') || has(desc, '[[Set]]')) && (has(desc, '[[Value]]') || has(desc, '[[Writable]]'))) {
12448 throw new $TypeError('Invalid property descriptor. Cannot both specify accessors and a value or writable attribute');
12449 }
12450 return desc;
12451 },
12452
12453 // https://www.ecma-international.org/ecma-262/5.1/#sec-11.9.3
12454 'Abstract Equality Comparison': function AbstractEqualityComparison(x, y) {
12455 var xType = this.Type(x);
12456 var yType = this.Type(y);
12457 if (xType === yType) {
12458 return x === y; // ES6+ specified this shortcut anyways.
12459 }
12460 if (x == null && y == null) {
12461 return true;
12462 }
12463 if (xType === 'Number' && yType === 'String') {
12464 return this['Abstract Equality Comparison'](x, this.ToNumber(y));
12465 }
12466 if (xType === 'String' && yType === 'Number') {
12467 return this['Abstract Equality Comparison'](this.ToNumber(x), y);
12468 }
12469 if (xType === 'Boolean') {
12470 return this['Abstract Equality Comparison'](this.ToNumber(x), y);
12471 }
12472 if (yType === 'Boolean') {
12473 return this['Abstract Equality Comparison'](x, this.ToNumber(y));
12474 }
12475 if ((xType === 'String' || xType === 'Number') && yType === 'Object') {
12476 return this['Abstract Equality Comparison'](x, this.ToPrimitive(y));
12477 }
12478 if (xType === 'Object' && (yType === 'String' || yType === 'Number')) {
12479 return this['Abstract Equality Comparison'](this.ToPrimitive(x), y);
12480 }
12481 return false;
12482 },
12483
12484 // https://www.ecma-international.org/ecma-262/5.1/#sec-11.9.6
12485 'Strict Equality Comparison': function StrictEqualityComparison(x, y) {
12486 var xType = this.Type(x);
12487 var yType = this.Type(y);
12488 if (xType !== yType) {
12489 return false;
12490 }
12491 if (xType === 'Undefined' || xType === 'Null') {
12492 return true;
12493 }
12494 return x === y; // shortcut for steps 4-7
12495 },
12496
12497 // https://www.ecma-international.org/ecma-262/5.1/#sec-11.8.5
12498 // eslint-disable-next-line max-statements
12499 'Abstract Relational Comparison': function AbstractRelationalComparison(x, y, LeftFirst) {
12500 if (this.Type(LeftFirst) !== 'Boolean') {
12501 throw new $TypeError('Assertion failed: LeftFirst argument must be a Boolean');
12502 }
12503 var px;
12504 var py;
12505 if (LeftFirst) {
12506 px = this.ToPrimitive(x, $Number);
12507 py = this.ToPrimitive(y, $Number);
12508 } else {
12509 py = this.ToPrimitive(y, $Number);
12510 px = this.ToPrimitive(x, $Number);
12511 }
12512 var bothStrings = this.Type(px) === 'String' && this.Type(py) === 'String';
12513 if (!bothStrings) {
12514 var nx = this.ToNumber(px);
12515 var ny = this.ToNumber(py);
12516 if ($isNaN(nx) || $isNaN(ny)) {
12517 return undefined;
12518 }
12519 if ($isFinite(nx) && $isFinite(ny) && nx === ny) {
12520 return false;
12521 }
12522 if (nx === 0 && ny === 0) {
12523 return false;
12524 }
12525 if (nx === Infinity) {
12526 return false;
12527 }
12528 if (ny === Infinity) {
12529 return true;
12530 }
12531 if (ny === -Infinity) {
12532 return false;
12533 }
12534 if (nx === -Infinity) {
12535 return true;
12536 }
12537 return nx < ny; // by now, these are both nonzero, finite, and not equal
12538 }
12539 if (isPrefixOf(py, px)) {
12540 return false;
12541 }
12542 if (isPrefixOf(px, py)) {
12543 return true;
12544 }
12545 return px < py; // both strings, neither a prefix of the other. shortcut for steps c-f
12546 }
12547};
12548
12549module.exports = ES5;
12550
12551},{"./GetIntrinsic":191,"./helpers/assertRecord":196,"./helpers/callBind":198,"./helpers/isFinite":201,"./helpers/isNaN":202,"./helpers/isPropertyDescriptor":204,"./helpers/mod":206,"./helpers/sign":207,"es-to-primitive/es5":212,"has":222,"is-callable":228}],195:[function(require,module,exports){
12552'use strict';
12553
12554module.exports = require('./es2016');
12555
12556},{"./es2016":193}],196:[function(require,module,exports){
12557'use strict';
12558
12559var GetIntrinsic = require('../GetIntrinsic');
12560
12561var $TypeError = GetIntrinsic('%TypeError%');
12562var $SyntaxError = GetIntrinsic('%SyntaxError%');
12563
12564var has = require('has');
12565
12566var predicates = {
12567 // https://ecma-international.org/ecma-262/6.0/#sec-property-descriptor-specification-type
12568 'Property Descriptor': function isPropertyDescriptor(ES, Desc) {
12569 if (ES.Type(Desc) !== 'Object') {
12570 return false;
12571 }
12572 var allowed = {
12573 '[[Configurable]]': true,
12574 '[[Enumerable]]': true,
12575 '[[Get]]': true,
12576 '[[Set]]': true,
12577 '[[Value]]': true,
12578 '[[Writable]]': true
12579 };
12580
12581 for (var key in Desc) { // eslint-disable-line
12582 if (has(Desc, key) && !allowed[key]) {
12583 return false;
12584 }
12585 }
12586
12587 var isData = has(Desc, '[[Value]]');
12588 var IsAccessor = has(Desc, '[[Get]]') || has(Desc, '[[Set]]');
12589 if (isData && IsAccessor) {
12590 throw new $TypeError('Property Descriptors may not be both accessor and data descriptors');
12591 }
12592 return true;
12593 }
12594};
12595
12596module.exports = function assertRecord(ES, recordType, argumentName, value) {
12597 var predicate = predicates[recordType];
12598 if (typeof predicate !== 'function') {
12599 throw new $SyntaxError('unknown record type: ' + recordType);
12600 }
12601 if (!predicate(ES, value)) {
12602 throw new $TypeError(argumentName + ' must be a ' + recordType);
12603 }
12604};
12605
12606},{"../GetIntrinsic":191,"has":222}],197:[function(require,module,exports){
12607'use strict';
12608
12609var GetIntrinsic = require('../GetIntrinsic');
12610
12611var has = require('has');
12612
12613var $assign = GetIntrinsic('%Object%').assign;
12614
12615module.exports = function assign(target, source) {
12616 if ($assign) {
12617 return $assign(target, source);
12618 }
12619
12620 // eslint-disable-next-line no-restricted-syntax
12621 for (var key in source) {
12622 if (has(source, key)) {
12623 target[key] = source[key];
12624 }
12625 }
12626 return target;
12627};
12628
12629},{"../GetIntrinsic":191,"has":222}],198:[function(require,module,exports){
12630'use strict';
12631
12632var bind = require('function-bind');
12633
12634var GetIntrinsic = require('../GetIntrinsic');
12635
12636var $Function = GetIntrinsic('%Function%');
12637var $apply = $Function.apply;
12638var $call = $Function.call;
12639
12640module.exports = function callBind() {
12641 return bind.apply($call, arguments);
12642};
12643
12644module.exports.apply = function applyBind() {
12645 return bind.apply($apply, arguments);
12646};
12647
12648},{"../GetIntrinsic":191,"function-bind":219}],199:[function(require,module,exports){
12649'use strict';
12650
12651module.exports = function every(array, predicate) {
12652 for (var i = 0; i < array.length; i += 1) {
12653 if (!predicate(array[i], i, array)) {
12654 return false;
12655 }
12656 }
12657 return true;
12658};
12659
12660},{}],200:[function(require,module,exports){
12661'use strict';
12662
12663module.exports = function forEach(array, callback) {
12664 for (var i = 0; i < array.length; i += 1) {
12665 callback(array[i], i, array); // eslint-disable-line callback-return
12666 }
12667};
12668
12669},{}],201:[function(require,module,exports){
12670'use strict';
12671
12672var $isNaN = Number.isNaN || function (a) { return a !== a; };
12673
12674module.exports = Number.isFinite || function (x) { return typeof x === 'number' && !$isNaN(x) && x !== Infinity && x !== -Infinity; };
12675
12676},{}],202:[function(require,module,exports){
12677'use strict';
12678
12679module.exports = Number.isNaN || function isNaN(a) {
12680 return a !== a;
12681};
12682
12683},{}],203:[function(require,module,exports){
12684'use strict';
12685
12686module.exports = function isPrimitive(value) {
12687 return value === null || (typeof value !== 'function' && typeof value !== 'object');
12688};
12689
12690},{}],204:[function(require,module,exports){
12691'use strict';
12692
12693var GetIntrinsic = require('../GetIntrinsic');
12694
12695var has = require('has');
12696var $TypeError = GetIntrinsic('%TypeError%');
12697
12698module.exports = function IsPropertyDescriptor(ES, Desc) {
12699 if (ES.Type(Desc) !== 'Object') {
12700 return false;
12701 }
12702 var allowed = {
12703 '[[Configurable]]': true,
12704 '[[Enumerable]]': true,
12705 '[[Get]]': true,
12706 '[[Set]]': true,
12707 '[[Value]]': true,
12708 '[[Writable]]': true
12709 };
12710
12711 for (var key in Desc) { // eslint-disable-line
12712 if (has(Desc, key) && !allowed[key]) {
12713 return false;
12714 }
12715 }
12716
12717 if (ES.IsDataDescriptor(Desc) && ES.IsAccessorDescriptor(Desc)) {
12718 throw new $TypeError('Property Descriptors may not be both accessor and data descriptors');
12719 }
12720 return true;
12721};
12722
12723},{"../GetIntrinsic":191,"has":222}],205:[function(require,module,exports){
12724'use strict';
12725
12726var every = require('./every');
12727
12728module.exports = function isSamePropertyDescriptor(ES, D1, D2) {
12729 var fields = [
12730 '[[Configurable]]',
12731 '[[Enumerable]]',
12732 '[[Get]]',
12733 '[[Set]]',
12734 '[[Value]]',
12735 '[[Writable]]'
12736 ];
12737 return every(fields, function (field) {
12738 if ((field in D1) !== (field in D2)) {
12739 return false;
12740 }
12741 return ES.SameValue(D1[field], D2[field]);
12742 });
12743};
12744
12745},{"./every":199}],206:[function(require,module,exports){
12746'use strict';
12747
12748module.exports = function mod(number, modulo) {
12749 var remain = number % modulo;
12750 return Math.floor(remain >= 0 ? remain : remain + modulo);
12751};
12752
12753},{}],207:[function(require,module,exports){
12754'use strict';
12755
12756module.exports = function sign(number) {
12757 return number >= 0 ? 1 : -1;
12758};
12759
12760},{}],208:[function(require,module,exports){
12761'use strict';
12762
12763var keysShim;
12764if (!Object.keys) {
12765 // modified from https://github.com/es-shims/es5-shim
12766 var has = Object.prototype.hasOwnProperty;
12767 var toStr = Object.prototype.toString;
12768 var isArgs = require('./isArguments'); // eslint-disable-line global-require
12769 var isEnumerable = Object.prototype.propertyIsEnumerable;
12770 var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
12771 var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
12772 var dontEnums = [
12773 'toString',
12774 'toLocaleString',
12775 'valueOf',
12776 'hasOwnProperty',
12777 'isPrototypeOf',
12778 'propertyIsEnumerable',
12779 'constructor'
12780 ];
12781 var equalsConstructorPrototype = function (o) {
12782 var ctor = o.constructor;
12783 return ctor && ctor.prototype === o;
12784 };
12785 var excludedKeys = {
12786 $applicationCache: true,
12787 $console: true,
12788 $external: true,
12789 $frame: true,
12790 $frameElement: true,
12791 $frames: true,
12792 $innerHeight: true,
12793 $innerWidth: true,
12794 $onmozfullscreenchange: true,
12795 $onmozfullscreenerror: true,
12796 $outerHeight: true,
12797 $outerWidth: true,
12798 $pageXOffset: true,
12799 $pageYOffset: true,
12800 $parent: true,
12801 $scrollLeft: true,
12802 $scrollTop: true,
12803 $scrollX: true,
12804 $scrollY: true,
12805 $self: true,
12806 $webkitIndexedDB: true,
12807 $webkitStorageInfo: true,
12808 $window: true
12809 };
12810 var hasAutomationEqualityBug = (function () {
12811 /* global window */
12812 if (typeof window === 'undefined') { return false; }
12813 for (var k in window) {
12814 try {
12815 if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
12816 try {
12817 equalsConstructorPrototype(window[k]);
12818 } catch (e) {
12819 return true;
12820 }
12821 }
12822 } catch (e) {
12823 return true;
12824 }
12825 }
12826 return false;
12827 }());
12828 var equalsConstructorPrototypeIfNotBuggy = function (o) {
12829 /* global window */
12830 if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
12831 return equalsConstructorPrototype(o);
12832 }
12833 try {
12834 return equalsConstructorPrototype(o);
12835 } catch (e) {
12836 return false;
12837 }
12838 };
12839
12840 keysShim = function keys(object) {
12841 var isObject = object !== null && typeof object === 'object';
12842 var isFunction = toStr.call(object) === '[object Function]';
12843 var isArguments = isArgs(object);
12844 var isString = isObject && toStr.call(object) === '[object String]';
12845 var theKeys = [];
12846
12847 if (!isObject && !isFunction && !isArguments) {
12848 throw new TypeError('Object.keys called on a non-object');
12849 }
12850
12851 var skipProto = hasProtoEnumBug && isFunction;
12852 if (isString && object.length > 0 && !has.call(object, 0)) {
12853 for (var i = 0; i < object.length; ++i) {
12854 theKeys.push(String(i));
12855 }
12856 }
12857
12858 if (isArguments && object.length > 0) {
12859 for (var j = 0; j < object.length; ++j) {
12860 theKeys.push(String(j));
12861 }
12862 } else {
12863 for (var name in object) {
12864 if (!(skipProto && name === 'prototype') && has.call(object, name)) {
12865 theKeys.push(String(name));
12866 }
12867 }
12868 }
12869
12870 if (hasDontEnumBug) {
12871 var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
12872
12873 for (var k = 0; k < dontEnums.length; ++k) {
12874 if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
12875 theKeys.push(dontEnums[k]);
12876 }
12877 }
12878 }
12879 return theKeys;
12880 };
12881}
12882module.exports = keysShim;
12883
12884},{"./isArguments":210}],209:[function(require,module,exports){
12885'use strict';
12886
12887var slice = Array.prototype.slice;
12888var isArgs = require('./isArguments');
12889
12890var origKeys = Object.keys;
12891var keysShim = origKeys ? function keys(o) { return origKeys(o); } : require('./implementation');
12892
12893var originalKeys = Object.keys;
12894
12895keysShim.shim = function shimObjectKeys() {
12896 if (Object.keys) {
12897 var keysWorksWithArguments = (function () {
12898 // Safari 5.0 bug
12899 var args = Object.keys(arguments);
12900 return args && args.length === arguments.length;
12901 }(1, 2));
12902 if (!keysWorksWithArguments) {
12903 Object.keys = function keys(object) { // eslint-disable-line func-name-matching
12904 if (isArgs(object)) {
12905 return originalKeys(slice.call(object));
12906 }
12907 return originalKeys(object);
12908 };
12909 }
12910 } else {
12911 Object.keys = keysShim;
12912 }
12913 return Object.keys || keysShim;
12914};
12915
12916module.exports = keysShim;
12917
12918},{"./implementation":208,"./isArguments":210}],210:[function(require,module,exports){
12919'use strict';
12920
12921var toStr = Object.prototype.toString;
12922
12923module.exports = function isArguments(value) {
12924 var str = toStr.call(value);
12925 var isArgs = str === '[object Arguments]';
12926 if (!isArgs) {
12927 isArgs = str !== '[object Array]' &&
12928 value !== null &&
12929 typeof value === 'object' &&
12930 typeof value.length === 'number' &&
12931 value.length >= 0 &&
12932 toStr.call(value.callee) === '[object Function]';
12933 }
12934 return isArgs;
12935};
12936
12937},{}],211:[function(require,module,exports){
12938'use strict';
12939
12940var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol';
12941
12942var isPrimitive = require('./helpers/isPrimitive');
12943var isCallable = require('is-callable');
12944var isDate = require('is-date-object');
12945var isSymbol = require('is-symbol');
12946
12947var ordinaryToPrimitive = function OrdinaryToPrimitive(O, hint) {
12948 if (typeof O === 'undefined' || O === null) {
12949 throw new TypeError('Cannot call method on ' + O);
12950 }
12951 if (typeof hint !== 'string' || (hint !== 'number' && hint !== 'string')) {
12952 throw new TypeError('hint must be "string" or "number"');
12953 }
12954 var methodNames = hint === 'string' ? ['toString', 'valueOf'] : ['valueOf', 'toString'];
12955 var method, result, i;
12956 for (i = 0; i < methodNames.length; ++i) {
12957 method = O[methodNames[i]];
12958 if (isCallable(method)) {
12959 result = method.call(O);
12960 if (isPrimitive(result)) {
12961 return result;
12962 }
12963 }
12964 }
12965 throw new TypeError('No default value');
12966};
12967
12968var GetMethod = function GetMethod(O, P) {
12969 var func = O[P];
12970 if (func !== null && typeof func !== 'undefined') {
12971 if (!isCallable(func)) {
12972 throw new TypeError(func + ' returned for property ' + P + ' of object ' + O + ' is not a function');
12973 }
12974 return func;
12975 }
12976 return void 0;
12977};
12978
12979// http://www.ecma-international.org/ecma-262/6.0/#sec-toprimitive
12980module.exports = function ToPrimitive(input) {
12981 if (isPrimitive(input)) {
12982 return input;
12983 }
12984 var hint = 'default';
12985 if (arguments.length > 1) {
12986 if (arguments[1] === String) {
12987 hint = 'string';
12988 } else if (arguments[1] === Number) {
12989 hint = 'number';
12990 }
12991 }
12992
12993 var exoticToPrim;
12994 if (hasSymbols) {
12995 if (Symbol.toPrimitive) {
12996 exoticToPrim = GetMethod(input, Symbol.toPrimitive);
12997 } else if (isSymbol(input)) {
12998 exoticToPrim = Symbol.prototype.valueOf;
12999 }
13000 }
13001 if (typeof exoticToPrim !== 'undefined') {
13002 var result = exoticToPrim.call(input, hint);
13003 if (isPrimitive(result)) {
13004 return result;
13005 }
13006 throw new TypeError('unable to convert exotic object to primitive');
13007 }
13008 if (hint === 'default' && (isDate(input) || isSymbol(input))) {
13009 hint = 'string';
13010 }
13011 return ordinaryToPrimitive(input, hint === 'default' ? 'number' : hint);
13012};
13013
13014},{"./helpers/isPrimitive":214,"is-callable":228,"is-date-object":230,"is-symbol":232}],212:[function(require,module,exports){
13015'use strict';
13016
13017var toStr = Object.prototype.toString;
13018
13019var isPrimitive = require('./helpers/isPrimitive');
13020
13021var isCallable = require('is-callable');
13022
13023// http://ecma-international.org/ecma-262/5.1/#sec-8.12.8
13024var ES5internalSlots = {
13025 '[[DefaultValue]]': function (O) {
13026 var actualHint;
13027 if (arguments.length > 1) {
13028 actualHint = arguments[1];
13029 } else {
13030 actualHint = toStr.call(O) === '[object Date]' ? String : Number;
13031 }
13032
13033 if (actualHint === String || actualHint === Number) {
13034 var methods = actualHint === String ? ['toString', 'valueOf'] : ['valueOf', 'toString'];
13035 var value, i;
13036 for (i = 0; i < methods.length; ++i) {
13037 if (isCallable(O[methods[i]])) {
13038 value = O[methods[i]]();
13039 if (isPrimitive(value)) {
13040 return value;
13041 }
13042 }
13043 }
13044 throw new TypeError('No default value');
13045 }
13046 throw new TypeError('invalid [[DefaultValue]] hint supplied');
13047 }
13048};
13049
13050// http://ecma-international.org/ecma-262/5.1/#sec-9.1
13051module.exports = function ToPrimitive(input) {
13052 if (isPrimitive(input)) {
13053 return input;
13054 }
13055 if (arguments.length > 1) {
13056 return ES5internalSlots['[[DefaultValue]]'](input, arguments[1]);
13057 }
13058 return ES5internalSlots['[[DefaultValue]]'](input);
13059};
13060
13061},{"./helpers/isPrimitive":214,"is-callable":228}],213:[function(require,module,exports){
13062'use strict';
13063
13064module.exports = require('./es2015');
13065
13066},{"./es2015":211}],214:[function(require,module,exports){
13067module.exports = function isPrimitive(value) {
13068 return value === null || (typeof value !== 'function' && typeof value !== 'object');
13069};
13070
13071},{}],215:[function(require,module,exports){
13072/*!
13073 * escape-html
13074 * Copyright(c) 2012-2013 TJ Holowaychuk
13075 * Copyright(c) 2015 Andreas Lubbe
13076 * Copyright(c) 2015 Tiancheng "Timothy" Gu
13077 * MIT Licensed
13078 */
13079
13080'use strict';
13081
13082/**
13083 * Module variables.
13084 * @private
13085 */
13086
13087var matchHtmlRegExp = /["'&<>]/;
13088
13089/**
13090 * Module exports.
13091 * @public
13092 */
13093
13094module.exports = escapeHtml;
13095
13096/**
13097 * Escape special characters in the given string of html.
13098 *
13099 * @param {string} string The string to escape for inserting into HTML
13100 * @return {string}
13101 * @public
13102 */
13103
13104function escapeHtml(string) {
13105 var str = '' + string;
13106 var match = matchHtmlRegExp.exec(str);
13107
13108 if (!match) {
13109 return str;
13110 }
13111
13112 var escape;
13113 var html = '';
13114 var index = 0;
13115 var lastIndex = 0;
13116
13117 for (index = match.index; index < str.length; index++) {
13118 switch (str.charCodeAt(index)) {
13119 case 34: // "
13120 escape = '&quot;';
13121 break;
13122 case 38: // &
13123 escape = '&amp;';
13124 break;
13125 case 39: // '
13126 escape = '&#39;';
13127 break;
13128 case 60: // <
13129 escape = '&lt;';
13130 break;
13131 case 62: // >
13132 escape = '&gt;';
13133 break;
13134 default:
13135 continue;
13136 }
13137
13138 if (lastIndex !== index) {
13139 html += str.substring(lastIndex, index);
13140 }
13141
13142 lastIndex = index + 1;
13143 html += escape;
13144 }
13145
13146 return lastIndex !== index
13147 ? html + str.substring(lastIndex, index)
13148 : html;
13149}
13150
13151},{}],216:[function(require,module,exports){
13152// Copyright Joyent, Inc. and other Node contributors.
13153//
13154// Permission is hereby granted, free of charge, to any person obtaining a
13155// copy of this software and associated documentation files (the
13156// "Software"), to deal in the Software without restriction, including
13157// without limitation the rights to use, copy, modify, merge, publish,
13158// distribute, sublicense, and/or sell copies of the Software, and to permit
13159// persons to whom the Software is furnished to do so, subject to the
13160// following conditions:
13161//
13162// The above copyright notice and this permission notice shall be included
13163// in all copies or substantial portions of the Software.
13164//
13165// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
13166// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
13167// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
13168// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
13169// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
13170// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
13171// USE OR OTHER DEALINGS IN THE SOFTWARE.
13172
13173function EventEmitter() {
13174 this._events = this._events || {};
13175 this._maxListeners = this._maxListeners || undefined;
13176}
13177module.exports = EventEmitter;
13178
13179// Backwards-compat with node 0.10.x
13180EventEmitter.EventEmitter = EventEmitter;
13181
13182EventEmitter.prototype._events = undefined;
13183EventEmitter.prototype._maxListeners = undefined;
13184
13185// By default EventEmitters will print a warning if more than 10 listeners are
13186// added to it. This is a useful default which helps finding memory leaks.
13187EventEmitter.defaultMaxListeners = 10;
13188
13189// Obviously not all Emitters should be limited to 10. This function allows
13190// that to be increased. Set to zero for unlimited.
13191EventEmitter.prototype.setMaxListeners = function(n) {
13192 if (!isNumber(n) || n < 0 || isNaN(n))
13193 throw TypeError('n must be a positive number');
13194 this._maxListeners = n;
13195 return this;
13196};
13197
13198EventEmitter.prototype.emit = function(type) {
13199 var er, handler, len, args, i, listeners;
13200
13201 if (!this._events)
13202 this._events = {};
13203
13204 // If there is no 'error' event listener then throw.
13205 if (type === 'error') {
13206 if (!this._events.error ||
13207 (isObject(this._events.error) && !this._events.error.length)) {
13208 er = arguments[1];
13209 if (er instanceof Error) {
13210 throw er; // Unhandled 'error' event
13211 } else {
13212 // At least give some kind of context to the user
13213 var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
13214 err.context = er;
13215 throw err;
13216 }
13217 }
13218 }
13219
13220 handler = this._events[type];
13221
13222 if (isUndefined(handler))
13223 return false;
13224
13225 if (isFunction(handler)) {
13226 switch (arguments.length) {
13227 // fast cases
13228 case 1:
13229 handler.call(this);
13230 break;
13231 case 2:
13232 handler.call(this, arguments[1]);
13233 break;
13234 case 3:
13235 handler.call(this, arguments[1], arguments[2]);
13236 break;
13237 // slower
13238 default:
13239 args = Array.prototype.slice.call(arguments, 1);
13240 handler.apply(this, args);
13241 }
13242 } else if (isObject(handler)) {
13243 args = Array.prototype.slice.call(arguments, 1);
13244 listeners = handler.slice();
13245 len = listeners.length;
13246 for (i = 0; i < len; i++)
13247 listeners[i].apply(this, args);
13248 }
13249
13250 return true;
13251};
13252
13253EventEmitter.prototype.addListener = function(type, listener) {
13254 var m;
13255
13256 if (!isFunction(listener))
13257 throw TypeError('listener must be a function');
13258
13259 if (!this._events)
13260 this._events = {};
13261
13262 // To avoid recursion in the case that type === "newListener"! Before
13263 // adding it to the listeners, first emit "newListener".
13264 if (this._events.newListener)
13265 this.emit('newListener', type,
13266 isFunction(listener.listener) ?
13267 listener.listener : listener);
13268
13269 if (!this._events[type])
13270 // Optimize the case of one listener. Don't need the extra array object.
13271 this._events[type] = listener;
13272 else if (isObject(this._events[type]))
13273 // If we've already got an array, just append.
13274 this._events[type].push(listener);
13275 else
13276 // Adding the second element, need to change to array.
13277 this._events[type] = [this._events[type], listener];
13278
13279 // Check for listener leak
13280 if (isObject(this._events[type]) && !this._events[type].warned) {
13281 if (!isUndefined(this._maxListeners)) {
13282 m = this._maxListeners;
13283 } else {
13284 m = EventEmitter.defaultMaxListeners;
13285 }
13286
13287 if (m && m > 0 && this._events[type].length > m) {
13288 this._events[type].warned = true;
13289 console.error('(node) warning: possible EventEmitter memory ' +
13290 'leak detected. %d listeners added. ' +
13291 'Use emitter.setMaxListeners() to increase limit.',
13292 this._events[type].length);
13293 if (typeof console.trace === 'function') {
13294 // not supported in IE 10
13295 console.trace();
13296 }
13297 }
13298 }
13299
13300 return this;
13301};
13302
13303EventEmitter.prototype.on = EventEmitter.prototype.addListener;
13304
13305EventEmitter.prototype.once = function(type, listener) {
13306 if (!isFunction(listener))
13307 throw TypeError('listener must be a function');
13308
13309 var fired = false;
13310
13311 function g() {
13312 this.removeListener(type, g);
13313
13314 if (!fired) {
13315 fired = true;
13316 listener.apply(this, arguments);
13317 }
13318 }
13319
13320 g.listener = listener;
13321 this.on(type, g);
13322
13323 return this;
13324};
13325
13326// emits a 'removeListener' event iff the listener was removed
13327EventEmitter.prototype.removeListener = function(type, listener) {
13328 var list, position, length, i;
13329
13330 if (!isFunction(listener))
13331 throw TypeError('listener must be a function');
13332
13333 if (!this._events || !this._events[type])
13334 return this;
13335
13336 list = this._events[type];
13337 length = list.length;
13338 position = -1;
13339
13340 if (list === listener ||
13341 (isFunction(list.listener) && list.listener === listener)) {
13342 delete this._events[type];
13343 if (this._events.removeListener)
13344 this.emit('removeListener', type, listener);
13345
13346 } else if (isObject(list)) {
13347 for (i = length; i-- > 0;) {
13348 if (list[i] === listener ||
13349 (list[i].listener && list[i].listener === listener)) {
13350 position = i;
13351 break;
13352 }
13353 }
13354
13355 if (position < 0)
13356 return this;
13357
13358 if (list.length === 1) {
13359 list.length = 0;
13360 delete this._events[type];
13361 } else {
13362 list.splice(position, 1);
13363 }
13364
13365 if (this._events.removeListener)
13366 this.emit('removeListener', type, listener);
13367 }
13368
13369 return this;
13370};
13371
13372EventEmitter.prototype.removeAllListeners = function(type) {
13373 var key, listeners;
13374
13375 if (!this._events)
13376 return this;
13377
13378 // not listening for removeListener, no need to emit
13379 if (!this._events.removeListener) {
13380 if (arguments.length === 0)
13381 this._events = {};
13382 else if (this._events[type])
13383 delete this._events[type];
13384 return this;
13385 }
13386
13387 // emit removeListener for all listeners on all events
13388 if (arguments.length === 0) {
13389 for (key in this._events) {
13390 if (key === 'removeListener') continue;
13391 this.removeAllListeners(key);
13392 }
13393 this.removeAllListeners('removeListener');
13394 this._events = {};
13395 return this;
13396 }
13397
13398 listeners = this._events[type];
13399
13400 if (isFunction(listeners)) {
13401 this.removeListener(type, listeners);
13402 } else if (listeners) {
13403 // LIFO order
13404 while (listeners.length)
13405 this.removeListener(type, listeners[listeners.length - 1]);
13406 }
13407 delete this._events[type];
13408
13409 return this;
13410};
13411
13412EventEmitter.prototype.listeners = function(type) {
13413 var ret;
13414 if (!this._events || !this._events[type])
13415 ret = [];
13416 else if (isFunction(this._events[type]))
13417 ret = [this._events[type]];
13418 else
13419 ret = this._events[type].slice();
13420 return ret;
13421};
13422
13423EventEmitter.prototype.listenerCount = function(type) {
13424 if (this._events) {
13425 var evlistener = this._events[type];
13426
13427 if (isFunction(evlistener))
13428 return 1;
13429 else if (evlistener)
13430 return evlistener.length;
13431 }
13432 return 0;
13433};
13434
13435EventEmitter.listenerCount = function(emitter, type) {
13436 return emitter.listenerCount(type);
13437};
13438
13439function isFunction(arg) {
13440 return typeof arg === 'function';
13441}
13442
13443function isNumber(arg) {
13444 return typeof arg === 'number';
13445}
13446
13447function isObject(arg) {
13448 return typeof arg === 'object' && arg !== null;
13449}
13450
13451function isUndefined(arg) {
13452 return arg === void 0;
13453}
13454
13455},{}],217:[function(require,module,exports){
13456
13457var hasOwn = Object.prototype.hasOwnProperty;
13458var toString = Object.prototype.toString;
13459
13460module.exports = function forEach (obj, fn, ctx) {
13461 if (toString.call(fn) !== '[object Function]') {
13462 throw new TypeError('iterator must be a function');
13463 }
13464 var l = obj.length;
13465 if (l === +l) {
13466 for (var i = 0; i < l; i++) {
13467 fn.call(ctx, obj[i], i, obj);
13468 }
13469 } else {
13470 for (var k in obj) {
13471 if (hasOwn.call(obj, k)) {
13472 fn.call(ctx, obj[k], k, obj);
13473 }
13474 }
13475 }
13476};
13477
13478
13479},{}],218:[function(require,module,exports){
13480'use strict';
13481
13482/* eslint no-invalid-this: 1 */
13483
13484var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
13485var slice = Array.prototype.slice;
13486var toStr = Object.prototype.toString;
13487var funcType = '[object Function]';
13488
13489module.exports = function bind(that) {
13490 var target = this;
13491 if (typeof target !== 'function' || toStr.call(target) !== funcType) {
13492 throw new TypeError(ERROR_MESSAGE + target);
13493 }
13494 var args = slice.call(arguments, 1);
13495
13496 var bound;
13497 var binder = function () {
13498 if (this instanceof bound) {
13499 var result = target.apply(
13500 this,
13501 args.concat(slice.call(arguments))
13502 );
13503 if (Object(result) === result) {
13504 return result;
13505 }
13506 return this;
13507 } else {
13508 return target.apply(
13509 that,
13510 args.concat(slice.call(arguments))
13511 );
13512 }
13513 };
13514
13515 var boundLength = Math.max(0, target.length - args.length);
13516 var boundArgs = [];
13517 for (var i = 0; i < boundLength; i++) {
13518 boundArgs.push('$' + i);
13519 }
13520
13521 bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
13522
13523 if (target.prototype) {
13524 var Empty = function Empty() {};
13525 Empty.prototype = target.prototype;
13526 bound.prototype = new Empty();
13527 Empty.prototype = null;
13528 }
13529
13530 return bound;
13531};
13532
13533},{}],219:[function(require,module,exports){
13534'use strict';
13535
13536var implementation = require('./implementation');
13537
13538module.exports = Function.prototype.bind || implementation;
13539
13540},{"./implementation":218}],220:[function(require,module,exports){
13541(function (global){
13542'use strict';
13543
13544var origSymbol = global.Symbol;
13545var hasSymbolSham = require('./shams');
13546
13547module.exports = function hasNativeSymbols() {
13548 if (typeof origSymbol !== 'function') { return false; }
13549 if (typeof Symbol !== 'function') { return false; }
13550 if (typeof origSymbol('foo') !== 'symbol') { return false; }
13551 if (typeof Symbol('bar') !== 'symbol') { return false; }
13552
13553 return hasSymbolSham();
13554};
13555
13556}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
13557},{"./shams":221}],221:[function(require,module,exports){
13558'use strict';
13559
13560/* eslint complexity: [2, 17], max-statements: [2, 33] */
13561module.exports = function hasSymbols() {
13562 if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
13563 if (typeof Symbol.iterator === 'symbol') { return true; }
13564
13565 var obj = {};
13566 var sym = Symbol('test');
13567 var symObj = Object(sym);
13568 if (typeof sym === 'string') { return false; }
13569
13570 if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
13571 if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
13572
13573 // temp disabled per https://github.com/ljharb/object.assign/issues/17
13574 // if (sym instanceof Symbol) { return false; }
13575 // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
13576 // if (!(symObj instanceof Symbol)) { return false; }
13577
13578 // if (typeof Symbol.prototype.toString !== 'function') { return false; }
13579 // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
13580
13581 var symVal = 42;
13582 obj[sym] = symVal;
13583 for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax
13584 if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
13585
13586 if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
13587
13588 var syms = Object.getOwnPropertySymbols(obj);
13589 if (syms.length !== 1 || syms[0] !== sym) { return false; }
13590
13591 if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
13592
13593 if (typeof Object.getOwnPropertyDescriptor === 'function') {
13594 var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
13595 if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
13596 }
13597
13598 return true;
13599};
13600
13601},{}],222:[function(require,module,exports){
13602'use strict';
13603
13604var bind = require('function-bind');
13605
13606module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty);
13607
13608},{"function-bind":219}],223:[function(require,module,exports){
13609var http = require('http');
13610
13611var https = module.exports;
13612
13613for (var key in http) {
13614 if (http.hasOwnProperty(key)) https[key] = http[key];
13615};
13616
13617https.request = function (params, cb) {
13618 if (!params) params = {};
13619 params.scheme = 'https';
13620 params.protocol = 'https:';
13621 return http.request.call(this, params, cb);
13622}
13623
13624},{"http":272}],224:[function(require,module,exports){
13625/*!
13626 * humanize-ms - index.js
13627 * Copyright(c) 2014 dead_horse <dead_horse@qq.com>
13628 * MIT Licensed
13629 */
13630
13631'use strict';
13632
13633/**
13634 * Module dependencies.
13635 */
13636
13637var util = require('util');
13638var ms = require('ms');
13639
13640module.exports = function (t) {
13641 if (typeof t === 'number') return t;
13642 var r = ms(t);
13643 if (r === undefined) {
13644 var err = new Error(util.format('humanize-ms(%j) result undefined', t));
13645 console.warn(err.stack);
13646 }
13647 return r;
13648};
13649
13650},{"ms":238,"util":287}],225:[function(require,module,exports){
13651exports.read = function (buffer, offset, isLE, mLen, nBytes) {
13652 var e, m
13653 var eLen = (nBytes * 8) - mLen - 1
13654 var eMax = (1 << eLen) - 1
13655 var eBias = eMax >> 1
13656 var nBits = -7
13657 var i = isLE ? (nBytes - 1) : 0
13658 var d = isLE ? -1 : 1
13659 var s = buffer[offset + i]
13660
13661 i += d
13662
13663 e = s & ((1 << (-nBits)) - 1)
13664 s >>= (-nBits)
13665 nBits += eLen
13666 for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
13667
13668 m = e & ((1 << (-nBits)) - 1)
13669 e >>= (-nBits)
13670 nBits += mLen
13671 for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
13672
13673 if (e === 0) {
13674 e = 1 - eBias
13675 } else if (e === eMax) {
13676 return m ? NaN : ((s ? -1 : 1) * Infinity)
13677 } else {
13678 m = m + Math.pow(2, mLen)
13679 e = e - eBias
13680 }
13681 return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
13682}
13683
13684exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
13685 var e, m, c
13686 var eLen = (nBytes * 8) - mLen - 1
13687 var eMax = (1 << eLen) - 1
13688 var eBias = eMax >> 1
13689 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
13690 var i = isLE ? 0 : (nBytes - 1)
13691 var d = isLE ? 1 : -1
13692 var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
13693
13694 value = Math.abs(value)
13695
13696 if (isNaN(value) || value === Infinity) {
13697 m = isNaN(value) ? 1 : 0
13698 e = eMax
13699 } else {
13700 e = Math.floor(Math.log(value) / Math.LN2)
13701 if (value * (c = Math.pow(2, -e)) < 1) {
13702 e--
13703 c *= 2
13704 }
13705 if (e + eBias >= 1) {
13706 value += rt / c
13707 } else {
13708 value += rt * Math.pow(2, 1 - eBias)
13709 }
13710 if (value * c >= 2) {
13711 e++
13712 c /= 2
13713 }
13714
13715 if (e + eBias >= eMax) {
13716 m = 0
13717 e = eMax
13718 } else if (e + eBias >= 1) {
13719 m = ((value * c) - 1) * Math.pow(2, mLen)
13720 e = e + eBias
13721 } else {
13722 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
13723 e = 0
13724 }
13725 }
13726
13727 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
13728
13729 e = (e << mLen) | m
13730 eLen += mLen
13731 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
13732
13733 buffer[offset + i - d] |= s * 128
13734}
13735
13736},{}],226:[function(require,module,exports){
13737if (typeof Object.create === 'function') {
13738 // implementation from standard node.js 'util' module
13739 module.exports = function inherits(ctor, superCtor) {
13740 ctor.super_ = superCtor
13741 ctor.prototype = Object.create(superCtor.prototype, {
13742 constructor: {
13743 value: ctor,
13744 enumerable: false,
13745 writable: true,
13746 configurable: true
13747 }
13748 });
13749 };
13750} else {
13751 // old school shim for old browsers
13752 module.exports = function inherits(ctor, superCtor) {
13753 ctor.super_ = superCtor
13754 var TempCtor = function () {}
13755 TempCtor.prototype = superCtor.prototype
13756 ctor.prototype = new TempCtor()
13757 ctor.prototype.constructor = ctor
13758 }
13759}
13760
13761},{}],227:[function(require,module,exports){
13762/*!
13763 * Determine if an object is a Buffer
13764 *
13765 * @author Feross Aboukhadijeh <https://feross.org>
13766 * @license MIT
13767 */
13768
13769// The _isBuffer check is for Safari 5-7 support, because it's missing
13770// Object.prototype.constructor. Remove this eventually
13771module.exports = function (obj) {
13772 return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
13773}
13774
13775function isBuffer (obj) {
13776 return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
13777}
13778
13779// For Node v0.10 support. Remove this eventually.
13780function isSlowBuffer (obj) {
13781 return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
13782}
13783
13784},{}],228:[function(require,module,exports){
13785'use strict';
13786
13787var fnToStr = Function.prototype.toString;
13788
13789var constructorRegex = /^\s*class\b/;
13790var isES6ClassFn = function isES6ClassFunction(value) {
13791 try {
13792 var fnStr = fnToStr.call(value);
13793 return constructorRegex.test(fnStr);
13794 } catch (e) {
13795 return false; // not a function
13796 }
13797};
13798
13799var tryFunctionObject = function tryFunctionToStr(value) {
13800 try {
13801 if (isES6ClassFn(value)) { return false; }
13802 fnToStr.call(value);
13803 return true;
13804 } catch (e) {
13805 return false;
13806 }
13807};
13808var toStr = Object.prototype.toString;
13809var fnClass = '[object Function]';
13810var genClass = '[object GeneratorFunction]';
13811var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
13812
13813module.exports = function isCallable(value) {
13814 if (!value) { return false; }
13815 if (typeof value !== 'function' && typeof value !== 'object') { return false; }
13816 if (typeof value === 'function' && !value.prototype) { return true; }
13817 if (hasToStringTag) { return tryFunctionObject(value); }
13818 if (isES6ClassFn(value)) { return false; }
13819 var strClass = toStr.call(value);
13820 return strClass === fnClass || strClass === genClass;
13821};
13822
13823},{}],229:[function(require,module,exports){
13824(function(root) {
13825 var toString = Function.prototype.toString;
13826
13827 function fnBody(fn) {
13828 return toString.call(fn).replace(/^[^{]*{\s*/,'').replace(/\s*}[^}]*$/,'');
13829 }
13830
13831 function isClass(fn) {
13832 return (typeof fn === 'function' &&
13833 (/^class(?:\s|{)/.test(toString.call(fn)) ||
13834 (/^.*classCallCheck\(/.test(fnBody(fn)))) // babel.js
13835 );
13836 }
13837
13838 if (typeof exports !== 'undefined') {
13839 if (typeof module !== 'undefined' && module.exports) {
13840 exports = module.exports = isClass;
13841 }
13842 exports.isClass = isClass;
13843 } else if (typeof define === 'function' && define.amd) {
13844 define([], function() {
13845 return isClass;
13846 });
13847 } else {
13848 root.isClass = isClass;
13849 }
13850
13851})(this);
13852
13853},{}],230:[function(require,module,exports){
13854'use strict';
13855
13856var getDay = Date.prototype.getDay;
13857var tryDateObject = function tryDateObject(value) {
13858 try {
13859 getDay.call(value);
13860 return true;
13861 } catch (e) {
13862 return false;
13863 }
13864};
13865
13866var toStr = Object.prototype.toString;
13867var dateClass = '[object Date]';
13868var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
13869
13870module.exports = function isDateObject(value) {
13871 if (typeof value !== 'object' || value === null) { return false; }
13872 return hasToStringTag ? tryDateObject(value) : toStr.call(value) === dateClass;
13873};
13874
13875},{}],231:[function(require,module,exports){
13876'use strict';
13877
13878var has = require('has');
13879var regexExec = RegExp.prototype.exec;
13880var gOPD = Object.getOwnPropertyDescriptor;
13881
13882var tryRegexExecCall = function tryRegexExec(value) {
13883 try {
13884 var lastIndex = value.lastIndex;
13885 value.lastIndex = 0;
13886
13887 regexExec.call(value);
13888 return true;
13889 } catch (e) {
13890 return false;
13891 } finally {
13892 value.lastIndex = lastIndex;
13893 }
13894};
13895var toStr = Object.prototype.toString;
13896var regexClass = '[object RegExp]';
13897var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
13898
13899module.exports = function isRegex(value) {
13900 if (!value || typeof value !== 'object') {
13901 return false;
13902 }
13903 if (!hasToStringTag) {
13904 return toStr.call(value) === regexClass;
13905 }
13906
13907 var descriptor = gOPD(value, 'lastIndex');
13908 var hasLastIndexDataProperty = descriptor && has(descriptor, 'value');
13909 if (!hasLastIndexDataProperty) {
13910 return false;
13911 }
13912
13913 return tryRegexExecCall(value);
13914};
13915
13916},{"has":222}],232:[function(require,module,exports){
13917'use strict';
13918
13919var toStr = Object.prototype.toString;
13920var hasSymbols = require('has-symbols')();
13921
13922if (hasSymbols) {
13923 var symToStr = Symbol.prototype.toString;
13924 var symStringRegex = /^Symbol\(.*\)$/;
13925 var isSymbolObject = function isRealSymbolObject(value) {
13926 if (typeof value.valueOf() !== 'symbol') {
13927 return false;
13928 }
13929 return symStringRegex.test(symToStr.call(value));
13930 };
13931
13932 module.exports = function isSymbol(value) {
13933 if (typeof value === 'symbol') {
13934 return true;
13935 }
13936 if (toStr.call(value) !== '[object Symbol]') {
13937 return false;
13938 }
13939 try {
13940 return isSymbolObject(value);
13941 } catch (e) {
13942 return false;
13943 }
13944 };
13945} else {
13946
13947 module.exports = function isSymbol(value) {
13948 // this environment does not support Symbols.
13949 return false && value;
13950 };
13951}
13952
13953},{"has-symbols":220}],233:[function(require,module,exports){
13954'use strict';
13955
13956var utils = require('core-util-is');
13957var isStearm = require('isstream');
13958// wait for https://github.com/miguelmota/is-class/pull/6 merge
13959var isClass = require('is-class-hotfix');
13960
13961/**
13962 * Expose all methods in core-util-is
13963 */
13964
13965Object.keys(utils).map(function (name) {
13966 exports[transform(name)] = utils[name];
13967});
13968
13969/**
13970 * Stream detected by isstream
13971 */
13972
13973exports.stream = isStearm;
13974exports.readableStream = isStearm.isReadable;
13975exports.writableStream = isStearm.isWritable;
13976exports.duplexStream = isStearm.isDuplex;
13977
13978/**
13979 * Class detected by is-class
13980 */
13981 exports.class = isClass;
13982
13983/**
13984 * Extend method
13985 */
13986
13987exports.finite = Number.isFinite;
13988
13989exports.NaN = Number.isNaN
13990
13991exports.generator = function (obj) {
13992 return obj
13993 && 'function' === typeof obj.next
13994 && 'function' === typeof obj.throw;
13995};
13996
13997exports.generatorFunction = function (obj) {
13998 return obj
13999 && obj.constructor
14000 && 'GeneratorFunction' === obj.constructor.name;
14001};
14002
14003exports.asyncFunction = function (obj) {
14004 return obj
14005 && obj.constructor
14006 && 'AsyncFunction' === obj.constructor.name;
14007};
14008
14009exports.promise = function (obj) {
14010 return obj
14011 && 'function' === typeof obj.then;
14012};
14013
14014var MAX_INT_31 = Math.pow(2, 31);
14015
14016exports.int = function (obj) {
14017 return utils.isNumber(obj)
14018 && obj % 1 === 0;
14019};
14020
14021exports.int32 = function (obj) {
14022 return exports.int(obj)
14023 && obj < MAX_INT_31
14024 && obj >= -MAX_INT_31;
14025};
14026
14027exports.long = function (obj) {
14028 return exports.int(obj)
14029 && (obj >= MAX_INT_31 || obj < -MAX_INT_31);
14030};
14031
14032exports.Long = function (obj) {
14033 return exports.object(obj)
14034 && exports.number(obj.high)
14035 && exports.number(obj.low);
14036};
14037
14038exports.double = function (obj) {
14039 return utils.isNumber(obj)
14040 && !isNaN(obj)
14041 && obj % 1 !== 0;
14042};
14043
14044/**
14045 * override core-util-is
14046 */
14047
14048exports.date = function isDate(obj) {
14049 return obj instanceof Date;
14050};
14051
14052exports.regExp = function isRegExp(obj) {
14053 return obj instanceof RegExp;
14054};
14055exports.regexp = exports.regExp;
14056
14057exports.error = function isError(obj) {
14058 return obj instanceof Error;
14059};
14060
14061exports.array = Array.isArray;
14062
14063/**
14064 * transform isNull type to null
14065 * @param {[type]} m [description]
14066 * @return {[type]} [description]
14067 */
14068
14069function transform(m) {
14070 var name = m.slice(2);
14071 name = name[0].toLowerCase() + name.slice(1);
14072 return name;
14073}
14074
14075},{"core-util-is":186,"is-class-hotfix":229,"isstream":235}],234:[function(require,module,exports){
14076var toString = {}.toString;
14077
14078module.exports = Array.isArray || function (arr) {
14079 return toString.call(arr) == '[object Array]';
14080};
14081
14082},{}],235:[function(require,module,exports){
14083var stream = require('stream')
14084
14085
14086function isStream (obj) {
14087 return obj instanceof stream.Stream
14088}
14089
14090
14091function isReadable (obj) {
14092 return isStream(obj) && typeof obj._read == 'function' && typeof obj._readableState == 'object'
14093}
14094
14095
14096function isWritable (obj) {
14097 return isStream(obj) && typeof obj._write == 'function' && typeof obj._writableState == 'object'
14098}
14099
14100
14101function isDuplex (obj) {
14102 return isReadable(obj) && isWritable(obj)
14103}
14104
14105
14106module.exports = isStream
14107module.exports.isReadable = isReadable
14108module.exports.isWritable = isWritable
14109module.exports.isDuplex = isDuplex
14110
14111},{"stream":271}],236:[function(require,module,exports){
14112(function (global){
14113/*
14114 * base64.js
14115 *
14116 * Licensed under the BSD 3-Clause License.
14117 * http://opensource.org/licenses/BSD-3-Clause
14118 *
14119 * References:
14120 * http://en.wikipedia.org/wiki/Base64
14121 */
14122;(function (global, factory) {
14123 typeof exports === 'object' && typeof module !== 'undefined'
14124 ? module.exports = factory(global)
14125 : typeof define === 'function' && define.amd
14126 ? define(factory) : factory(global)
14127}((
14128 typeof self !== 'undefined' ? self
14129 : typeof window !== 'undefined' ? window
14130 : typeof global !== 'undefined' ? global
14131: this
14132), function(global) {
14133 'use strict';
14134 // existing version for noConflict()
14135 global = global || {};
14136 var _Base64 = global.Base64;
14137 var version = "2.5.2";
14138 // if node.js and NOT React Native, we use Buffer
14139 var buffer;
14140 if (typeof module !== 'undefined' && module.exports) {
14141 try {
14142 buffer = eval("require('buffer').Buffer");
14143 } catch (err) {
14144 buffer = undefined;
14145 }
14146 }
14147 // constants
14148 var b64chars
14149 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
14150 var b64tab = function(bin) {
14151 var t = {};
14152 for (var i = 0, l = bin.length; i < l; i++) t[bin.charAt(i)] = i;
14153 return t;
14154 }(b64chars);
14155 var fromCharCode = String.fromCharCode;
14156 // encoder stuff
14157 var cb_utob = function(c) {
14158 if (c.length < 2) {
14159 var cc = c.charCodeAt(0);
14160 return cc < 0x80 ? c
14161 : cc < 0x800 ? (fromCharCode(0xc0 | (cc >>> 6))
14162 + fromCharCode(0x80 | (cc & 0x3f)))
14163 : (fromCharCode(0xe0 | ((cc >>> 12) & 0x0f))
14164 + fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
14165 + fromCharCode(0x80 | ( cc & 0x3f)));
14166 } else {
14167 var cc = 0x10000
14168 + (c.charCodeAt(0) - 0xD800) * 0x400
14169 + (c.charCodeAt(1) - 0xDC00);
14170 return (fromCharCode(0xf0 | ((cc >>> 18) & 0x07))
14171 + fromCharCode(0x80 | ((cc >>> 12) & 0x3f))
14172 + fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
14173 + fromCharCode(0x80 | ( cc & 0x3f)));
14174 }
14175 };
14176 var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
14177 var utob = function(u) {
14178 return u.replace(re_utob, cb_utob);
14179 };
14180 var cb_encode = function(ccc) {
14181 var padlen = [0, 2, 1][ccc.length % 3],
14182 ord = ccc.charCodeAt(0) << 16
14183 | ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8)
14184 | ((ccc.length > 2 ? ccc.charCodeAt(2) : 0)),
14185 chars = [
14186 b64chars.charAt( ord >>> 18),
14187 b64chars.charAt((ord >>> 12) & 63),
14188 padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
14189 padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
14190 ];
14191 return chars.join('');
14192 };
14193 var btoa = global.btoa ? function(b) {
14194 return global.btoa(b);
14195 } : function(b) {
14196 return b.replace(/[\s\S]{1,3}/g, cb_encode);
14197 };
14198 var _encode = function(u) {
14199 var isUint8Array = Object.prototype.toString.call(u) === '[object Uint8Array]';
14200 return isUint8Array ? u.toString('base64')
14201 : btoa(utob(String(u)));
14202 }
14203 var encode = function(u, urisafe) {
14204 return !urisafe
14205 ? _encode(u)
14206 : _encode(String(u)).replace(/[+\/]/g, function(m0) {
14207 return m0 == '+' ? '-' : '_';
14208 }).replace(/=/g, '');
14209 };
14210 var encodeURI = function(u) { return encode(u, true) };
14211 // decoder stuff
14212 var re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g;
14213 var cb_btou = function(cccc) {
14214 switch(cccc.length) {
14215 case 4:
14216 var cp = ((0x07 & cccc.charCodeAt(0)) << 18)
14217 | ((0x3f & cccc.charCodeAt(1)) << 12)
14218 | ((0x3f & cccc.charCodeAt(2)) << 6)
14219 | (0x3f & cccc.charCodeAt(3)),
14220 offset = cp - 0x10000;
14221 return (fromCharCode((offset >>> 10) + 0xD800)
14222 + fromCharCode((offset & 0x3FF) + 0xDC00));
14223 case 3:
14224 return fromCharCode(
14225 ((0x0f & cccc.charCodeAt(0)) << 12)
14226 | ((0x3f & cccc.charCodeAt(1)) << 6)
14227 | (0x3f & cccc.charCodeAt(2))
14228 );
14229 default:
14230 return fromCharCode(
14231 ((0x1f & cccc.charCodeAt(0)) << 6)
14232 | (0x3f & cccc.charCodeAt(1))
14233 );
14234 }
14235 };
14236 var btou = function(b) {
14237 return b.replace(re_btou, cb_btou);
14238 };
14239 var cb_decode = function(cccc) {
14240 var len = cccc.length,
14241 padlen = len % 4,
14242 n = (len > 0 ? b64tab[cccc.charAt(0)] << 18 : 0)
14243 | (len > 1 ? b64tab[cccc.charAt(1)] << 12 : 0)
14244 | (len > 2 ? b64tab[cccc.charAt(2)] << 6 : 0)
14245 | (len > 3 ? b64tab[cccc.charAt(3)] : 0),
14246 chars = [
14247 fromCharCode( n >>> 16),
14248 fromCharCode((n >>> 8) & 0xff),
14249 fromCharCode( n & 0xff)
14250 ];
14251 chars.length -= [0, 0, 2, 1][padlen];
14252 return chars.join('');
14253 };
14254 var _atob = global.atob ? function(a) {
14255 return global.atob(a);
14256 } : function(a){
14257 return a.replace(/\S{1,4}/g, cb_decode);
14258 };
14259 var atob = function(a) {
14260 return _atob(String(a).replace(/[^A-Za-z0-9\+\/]/g, ''));
14261 };
14262 var _decode = buffer ?
14263 buffer.from && Uint8Array && buffer.from !== Uint8Array.from
14264 ? function(a) {
14265 return (a.constructor === buffer.constructor
14266 ? a : buffer.from(a, 'base64')).toString();
14267 }
14268 : function(a) {
14269 return (a.constructor === buffer.constructor
14270 ? a : new buffer(a, 'base64')).toString();
14271 }
14272 : function(a) { return btou(_atob(a)) };
14273 var decode = function(a){
14274 return _decode(
14275 String(a).replace(/[-_]/g, function(m0) { return m0 == '-' ? '+' : '/' })
14276 .replace(/[^A-Za-z0-9\+\/]/g, '')
14277 );
14278 };
14279 var noConflict = function() {
14280 var Base64 = global.Base64;
14281 global.Base64 = _Base64;
14282 return Base64;
14283 };
14284 // export Base64
14285 global.Base64 = {
14286 VERSION: version,
14287 atob: atob,
14288 btoa: btoa,
14289 fromBase64: decode,
14290 toBase64: encode,
14291 utob: utob,
14292 encode: encode,
14293 encodeURI: encodeURI,
14294 btou: btou,
14295 decode: decode,
14296 noConflict: noConflict,
14297 __buffer__: buffer
14298 };
14299 // if ES5 is available, make Base64.extendString() available
14300 if (typeof Object.defineProperty === 'function') {
14301 var noEnum = function(v){
14302 return {value:v,enumerable:false,writable:true,configurable:true};
14303 };
14304 global.Base64.extendString = function () {
14305 Object.defineProperty(
14306 String.prototype, 'fromBase64', noEnum(function () {
14307 return decode(this)
14308 }));
14309 Object.defineProperty(
14310 String.prototype, 'toBase64', noEnum(function (urisafe) {
14311 return encode(this, urisafe)
14312 }));
14313 Object.defineProperty(
14314 String.prototype, 'toBase64URI', noEnum(function () {
14315 return encode(this, true)
14316 }));
14317 };
14318 }
14319 //
14320 // export Base64 to the namespace
14321 //
14322 if (global['Meteor']) { // Meteor.js
14323 Base64 = global.Base64;
14324 }
14325 // module.exports and AMD are mutually exclusive.
14326 // module.exports has precedence.
14327 if (typeof module !== 'undefined' && module.exports) {
14328 module.exports.Base64 = global.Base64;
14329 }
14330 else if (typeof define === 'function' && define.amd) {
14331 // AMD. Register as an anonymous module.
14332 define([], function(){ return global.Base64 });
14333 }
14334 // that's it!
14335 return {Base64: global.Base64}
14336}));
14337
14338
14339}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
14340},{}],237:[function(require,module,exports){
14341/*!
14342 * merge-descriptors
14343 * Copyright(c) 2014 Jonathan Ong
14344 * Copyright(c) 2015 Douglas Christopher Wilson
14345 * MIT Licensed
14346 */
14347
14348'use strict'
14349
14350/**
14351 * Module exports.
14352 * @public
14353 */
14354
14355module.exports = merge
14356
14357/**
14358 * Module variables.
14359 * @private
14360 */
14361
14362var hasOwnProperty = Object.prototype.hasOwnProperty
14363
14364/**
14365 * Merge the property descriptors of `src` into `dest`
14366 *
14367 * @param {object} dest Object to add descriptors to
14368 * @param {object} src Object to clone descriptors from
14369 * @param {boolean} [redefine=true] Redefine `dest` properties with `src` properties
14370 * @returns {object} Reference to dest
14371 * @public
14372 */
14373
14374function merge(dest, src, redefine) {
14375 if (!dest) {
14376 throw new TypeError('argument dest is required')
14377 }
14378
14379 if (!src) {
14380 throw new TypeError('argument src is required')
14381 }
14382
14383 if (redefine === undefined) {
14384 // Default to true
14385 redefine = true
14386 }
14387
14388 Object.getOwnPropertyNames(src).forEach(function forEachOwnPropertyName(name) {
14389 if (!redefine && hasOwnProperty.call(dest, name)) {
14390 // Skip desriptor
14391 return
14392 }
14393
14394 // Copy descriptor
14395 var descriptor = Object.getOwnPropertyDescriptor(src, name)
14396 Object.defineProperty(dest, name, descriptor)
14397 })
14398
14399 return dest
14400}
14401
14402},{}],238:[function(require,module,exports){
14403/**
14404 * Helpers.
14405 */
14406
14407var s = 1000;
14408var m = s * 60;
14409var h = m * 60;
14410var d = h * 24;
14411var y = d * 365.25;
14412
14413/**
14414 * Parse or format the given `val`.
14415 *
14416 * Options:
14417 *
14418 * - `long` verbose formatting [false]
14419 *
14420 * @param {String|Number} val
14421 * @param {Object} [options]
14422 * @throws {Error} throw an error if val is not a non-empty string or a number
14423 * @return {String|Number}
14424 * @api public
14425 */
14426
14427module.exports = function(val, options) {
14428 options = options || {};
14429 var type = typeof val;
14430 if (type === 'string' && val.length > 0) {
14431 return parse(val);
14432 } else if (type === 'number' && isNaN(val) === false) {
14433 return options.long ? fmtLong(val) : fmtShort(val);
14434 }
14435 throw new Error(
14436 'val is not a non-empty string or a valid number. val=' +
14437 JSON.stringify(val)
14438 );
14439};
14440
14441/**
14442 * Parse the given `str` and return milliseconds.
14443 *
14444 * @param {String} str
14445 * @return {Number}
14446 * @api private
14447 */
14448
14449function parse(str) {
14450 str = String(str);
14451 if (str.length > 100) {
14452 return;
14453 }
14454 var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
14455 str
14456 );
14457 if (!match) {
14458 return;
14459 }
14460 var n = parseFloat(match[1]);
14461 var type = (match[2] || 'ms').toLowerCase();
14462 switch (type) {
14463 case 'years':
14464 case 'year':
14465 case 'yrs':
14466 case 'yr':
14467 case 'y':
14468 return n * y;
14469 case 'days':
14470 case 'day':
14471 case 'd':
14472 return n * d;
14473 case 'hours':
14474 case 'hour':
14475 case 'hrs':
14476 case 'hr':
14477 case 'h':
14478 return n * h;
14479 case 'minutes':
14480 case 'minute':
14481 case 'mins':
14482 case 'min':
14483 case 'm':
14484 return n * m;
14485 case 'seconds':
14486 case 'second':
14487 case 'secs':
14488 case 'sec':
14489 case 's':
14490 return n * s;
14491 case 'milliseconds':
14492 case 'millisecond':
14493 case 'msecs':
14494 case 'msec':
14495 case 'ms':
14496 return n;
14497 default:
14498 return undefined;
14499 }
14500}
14501
14502/**
14503 * Short format for `ms`.
14504 *
14505 * @param {Number} ms
14506 * @return {String}
14507 * @api private
14508 */
14509
14510function fmtShort(ms) {
14511 if (ms >= d) {
14512 return Math.round(ms / d) + 'd';
14513 }
14514 if (ms >= h) {
14515 return Math.round(ms / h) + 'h';
14516 }
14517 if (ms >= m) {
14518 return Math.round(ms / m) + 'm';
14519 }
14520 if (ms >= s) {
14521 return Math.round(ms / s) + 's';
14522 }
14523 return ms + 'ms';
14524}
14525
14526/**
14527 * Long format for `ms`.
14528 *
14529 * @param {Number} ms
14530 * @return {String}
14531 * @api private
14532 */
14533
14534function fmtLong(ms) {
14535 return plural(ms, d, 'day') ||
14536 plural(ms, h, 'hour') ||
14537 plural(ms, m, 'minute') ||
14538 plural(ms, s, 'second') ||
14539 ms + ' ms';
14540}
14541
14542/**
14543 * Pluralization helper.
14544 */
14545
14546function plural(ms, n, name) {
14547 if (ms < n) {
14548 return;
14549 }
14550 if (ms < n * 1.5) {
14551 return Math.floor(ms / n) + ' ' + name;
14552 }
14553 return Math.ceil(ms / n) + ' ' + name + 's';
14554}
14555
14556},{}],239:[function(require,module,exports){
14557var hasMap = typeof Map === 'function' && Map.prototype;
14558var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null;
14559var mapSize = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === 'function' ? mapSizeDescriptor.get : null;
14560var mapForEach = hasMap && Map.prototype.forEach;
14561var hasSet = typeof Set === 'function' && Set.prototype;
14562var setSizeDescriptor = Object.getOwnPropertyDescriptor && hasSet ? Object.getOwnPropertyDescriptor(Set.prototype, 'size') : null;
14563var setSize = hasSet && setSizeDescriptor && typeof setSizeDescriptor.get === 'function' ? setSizeDescriptor.get : null;
14564var setForEach = hasSet && Set.prototype.forEach;
14565var booleanValueOf = Boolean.prototype.valueOf;
14566var objectToString = Object.prototype.toString;
14567var bigIntValueOf = typeof BigInt === 'function' ? BigInt.prototype.valueOf : null;
14568
14569var inspectCustom = require('./util.inspect').custom;
14570var inspectSymbol = (inspectCustom && isSymbol(inspectCustom)) ? inspectCustom : null;
14571
14572module.exports = function inspect_ (obj, opts, depth, seen) {
14573 if (!opts) opts = {};
14574
14575 if (has(opts, 'quoteStyle') && (opts.quoteStyle !== 'single' && opts.quoteStyle !== 'double')) {
14576 throw new TypeError('option "quoteStyle" must be "single" or "double"');
14577 }
14578
14579 if (typeof obj === 'undefined') {
14580 return 'undefined';
14581 }
14582 if (obj === null) {
14583 return 'null';
14584 }
14585 if (typeof obj === 'boolean') {
14586 return obj ? 'true' : 'false';
14587 }
14588
14589 if (typeof obj === 'string') {
14590 return inspectString(obj, opts);
14591 }
14592 if (typeof obj === 'number') {
14593 if (obj === 0) {
14594 return Infinity / obj > 0 ? '0' : '-0';
14595 }
14596 return String(obj);
14597 }
14598 if (typeof obj === 'bigint') {
14599 return String(obj) + 'n';
14600 }
14601
14602 var maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth;
14603 if (typeof depth === 'undefined') depth = 0;
14604 if (depth >= maxDepth && maxDepth > 0 && typeof obj === 'object') {
14605 return '[Object]';
14606 }
14607
14608 if (typeof seen === 'undefined') seen = [];
14609 else if (indexOf(seen, obj) >= 0) {
14610 return '[Circular]';
14611 }
14612
14613 function inspect (value, from) {
14614 if (from) {
14615 seen = seen.slice();
14616 seen.push(from);
14617 }
14618 return inspect_(value, opts, depth + 1, seen);
14619 }
14620
14621 if (typeof obj === 'function') {
14622 var name = nameOf(obj);
14623 return '[Function' + (name ? ': ' + name : '') + ']';
14624 }
14625 if (isSymbol(obj)) {
14626 var symString = Symbol.prototype.toString.call(obj);
14627 return typeof obj === 'object' ? markBoxed(symString) : symString;
14628 }
14629 if (isElement(obj)) {
14630 var s = '<' + String(obj.nodeName).toLowerCase();
14631 var attrs = obj.attributes || [];
14632 for (var i = 0; i < attrs.length; i++) {
14633 s += ' ' + attrs[i].name + '=' + wrapQuotes(quote(attrs[i].value), 'double', opts);
14634 }
14635 s += '>';
14636 if (obj.childNodes && obj.childNodes.length) s += '...';
14637 s += '</' + String(obj.nodeName).toLowerCase() + '>';
14638 return s;
14639 }
14640 if (isArray(obj)) {
14641 if (obj.length === 0) return '[]';
14642 return '[ ' + arrObjKeys(obj, inspect).join(', ') + ' ]';
14643 }
14644 if (isError(obj)) {
14645 var parts = arrObjKeys(obj, inspect);
14646 if (parts.length === 0) return '[' + String(obj) + ']';
14647 return '{ [' + String(obj) + '] ' + parts.join(', ') + ' }';
14648 }
14649 if (typeof obj === 'object') {
14650 if (inspectSymbol && typeof obj[inspectSymbol] === 'function') {
14651 return obj[inspectSymbol]();
14652 } else if (typeof obj.inspect === 'function') {
14653 return obj.inspect();
14654 }
14655 }
14656 if (isMap(obj)) {
14657 var parts = [];
14658 mapForEach.call(obj, function (value, key) {
14659 parts.push(inspect(key, obj) + ' => ' + inspect(value, obj));
14660 });
14661 return collectionOf('Map', mapSize.call(obj), parts);
14662 }
14663 if (isSet(obj)) {
14664 var parts = [];
14665 setForEach.call(obj, function (value ) {
14666 parts.push(inspect(value, obj));
14667 });
14668 return collectionOf('Set', setSize.call(obj), parts);
14669 }
14670 if (isNumber(obj)) {
14671 return markBoxed(inspect(Number(obj)));
14672 }
14673 if (isBigInt(obj)) {
14674 return markBoxed(inspect(bigIntValueOf.call(obj)));
14675 }
14676 if (isBoolean(obj)) {
14677 return markBoxed(booleanValueOf.call(obj));
14678 }
14679 if (isString(obj)) {
14680 return markBoxed(inspect(String(obj)));
14681 }
14682 if (!isDate(obj) && !isRegExp(obj)) {
14683 var xs = arrObjKeys(obj, inspect);
14684 if (xs.length === 0) return '{}';
14685 return '{ ' + xs.join(', ') + ' }';
14686 }
14687 return String(obj);
14688};
14689
14690function wrapQuotes (s, defaultStyle, opts) {
14691 var quoteChar = (opts.quoteStyle || defaultStyle) === 'double' ? '"' : "'";
14692 return quoteChar + s + quoteChar;
14693}
14694
14695function quote (s) {
14696 return String(s).replace(/"/g, '&quot;');
14697}
14698
14699function isArray (obj) { return toStr(obj) === '[object Array]'; }
14700function isDate (obj) { return toStr(obj) === '[object Date]'; }
14701function isRegExp (obj) { return toStr(obj) === '[object RegExp]'; }
14702function isError (obj) { return toStr(obj) === '[object Error]'; }
14703function isSymbol (obj) { return toStr(obj) === '[object Symbol]'; }
14704function isString (obj) { return toStr(obj) === '[object String]'; }
14705function isNumber (obj) { return toStr(obj) === '[object Number]'; }
14706function isBigInt (obj) { return toStr(obj) === '[object BigInt]'; }
14707function isBoolean (obj) { return toStr(obj) === '[object Boolean]'; }
14708
14709var hasOwn = Object.prototype.hasOwnProperty || function (key) { return key in this; };
14710function has (obj, key) {
14711 return hasOwn.call(obj, key);
14712}
14713
14714function toStr (obj) {
14715 return objectToString.call(obj);
14716}
14717
14718function nameOf (f) {
14719 if (f.name) return f.name;
14720 var m = String(f).match(/^function\s*([\w$]+)/);
14721 if (m) return m[1];
14722}
14723
14724function indexOf (xs, x) {
14725 if (xs.indexOf) return xs.indexOf(x);
14726 for (var i = 0, l = xs.length; i < l; i++) {
14727 if (xs[i] === x) return i;
14728 }
14729 return -1;
14730}
14731
14732function isMap (x) {
14733 if (!mapSize) {
14734 return false;
14735 }
14736 try {
14737 mapSize.call(x);
14738 try {
14739 setSize.call(x);
14740 } catch (s) {
14741 return true;
14742 }
14743 return x instanceof Map; // core-js workaround, pre-v2.5.0
14744 } catch (e) {}
14745 return false;
14746}
14747
14748function isSet (x) {
14749 if (!setSize) {
14750 return false;
14751 }
14752 try {
14753 setSize.call(x);
14754 try {
14755 mapSize.call(x);
14756 } catch (m) {
14757 return true;
14758 }
14759 return x instanceof Set; // core-js workaround, pre-v2.5.0
14760 } catch (e) {}
14761 return false;
14762}
14763
14764function isElement (x) {
14765 if (!x || typeof x !== 'object') return false;
14766 if (typeof HTMLElement !== 'undefined' && x instanceof HTMLElement) {
14767 return true;
14768 }
14769 return typeof x.nodeName === 'string'
14770 && typeof x.getAttribute === 'function'
14771 ;
14772}
14773
14774function inspectString (str, opts) {
14775 var s = str.replace(/(['\\])/g, '\\$1').replace(/[\x00-\x1f]/g, lowbyte);
14776 return wrapQuotes(s, 'single', opts);
14777}
14778
14779function lowbyte (c) {
14780 var n = c.charCodeAt(0);
14781 var x = { 8: 'b', 9: 't', 10: 'n', 12: 'f', 13: 'r' }[n];
14782 if (x) return '\\' + x;
14783 return '\\x' + (n < 0x10 ? '0' : '') + n.toString(16);
14784}
14785
14786function markBoxed (str) {
14787 return 'Object(' + str + ')';
14788}
14789
14790function collectionOf (type, size, entries) {
14791 return type + ' (' + size + ') {' + entries.join(', ') + '}';
14792}
14793
14794function arrObjKeys (obj, inspect) {
14795 var isArr = isArray(obj);
14796 var xs = [];
14797 if (isArr) {
14798 xs.length = obj.length;
14799 for (var i = 0; i < obj.length; i++) {
14800 xs[i] = has(obj, i) ? inspect(obj[i], obj) : '';
14801 }
14802 }
14803 for (var key in obj) {
14804 if (!has(obj, key)) continue;
14805 if (isArr && String(Number(key)) === key && key < obj.length) continue;
14806 if (/[^\w$]/.test(key)) {
14807 xs.push(inspect(key, obj) + ': ' + inspect(obj[key], obj));
14808 } else {
14809 xs.push(key + ': ' + inspect(obj[key], obj));
14810 }
14811 }
14812 return xs;
14813}
14814
14815},{"./util.inspect":68}],240:[function(require,module,exports){
14816'use strict';
14817
14818// modified from https://github.com/es-shims/es5-shim
14819var has = Object.prototype.hasOwnProperty;
14820var toStr = Object.prototype.toString;
14821var slice = Array.prototype.slice;
14822var isArgs = require('./isArguments');
14823var isEnumerable = Object.prototype.propertyIsEnumerable;
14824var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
14825var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
14826var dontEnums = [
14827 'toString',
14828 'toLocaleString',
14829 'valueOf',
14830 'hasOwnProperty',
14831 'isPrototypeOf',
14832 'propertyIsEnumerable',
14833 'constructor'
14834];
14835var equalsConstructorPrototype = function (o) {
14836 var ctor = o.constructor;
14837 return ctor && ctor.prototype === o;
14838};
14839var excludedKeys = {
14840 $applicationCache: true,
14841 $console: true,
14842 $external: true,
14843 $frame: true,
14844 $frameElement: true,
14845 $frames: true,
14846 $innerHeight: true,
14847 $innerWidth: true,
14848 $outerHeight: true,
14849 $outerWidth: true,
14850 $pageXOffset: true,
14851 $pageYOffset: true,
14852 $parent: true,
14853 $scrollLeft: true,
14854 $scrollTop: true,
14855 $scrollX: true,
14856 $scrollY: true,
14857 $self: true,
14858 $webkitIndexedDB: true,
14859 $webkitStorageInfo: true,
14860 $window: true
14861};
14862var hasAutomationEqualityBug = (function () {
14863 /* global window */
14864 if (typeof window === 'undefined') { return false; }
14865 for (var k in window) {
14866 try {
14867 if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
14868 try {
14869 equalsConstructorPrototype(window[k]);
14870 } catch (e) {
14871 return true;
14872 }
14873 }
14874 } catch (e) {
14875 return true;
14876 }
14877 }
14878 return false;
14879}());
14880var equalsConstructorPrototypeIfNotBuggy = function (o) {
14881 /* global window */
14882 if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
14883 return equalsConstructorPrototype(o);
14884 }
14885 try {
14886 return equalsConstructorPrototype(o);
14887 } catch (e) {
14888 return false;
14889 }
14890};
14891
14892var keysShim = function keys(object) {
14893 var isObject = object !== null && typeof object === 'object';
14894 var isFunction = toStr.call(object) === '[object Function]';
14895 var isArguments = isArgs(object);
14896 var isString = isObject && toStr.call(object) === '[object String]';
14897 var theKeys = [];
14898
14899 if (!isObject && !isFunction && !isArguments) {
14900 throw new TypeError('Object.keys called on a non-object');
14901 }
14902
14903 var skipProto = hasProtoEnumBug && isFunction;
14904 if (isString && object.length > 0 && !has.call(object, 0)) {
14905 for (var i = 0; i < object.length; ++i) {
14906 theKeys.push(String(i));
14907 }
14908 }
14909
14910 if (isArguments && object.length > 0) {
14911 for (var j = 0; j < object.length; ++j) {
14912 theKeys.push(String(j));
14913 }
14914 } else {
14915 for (var name in object) {
14916 if (!(skipProto && name === 'prototype') && has.call(object, name)) {
14917 theKeys.push(String(name));
14918 }
14919 }
14920 }
14921
14922 if (hasDontEnumBug) {
14923 var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
14924
14925 for (var k = 0; k < dontEnums.length; ++k) {
14926 if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
14927 theKeys.push(dontEnums[k]);
14928 }
14929 }
14930 }
14931 return theKeys;
14932};
14933
14934keysShim.shim = function shimObjectKeys() {
14935 if (Object.keys) {
14936 var keysWorksWithArguments = (function () {
14937 // Safari 5.0 bug
14938 return (Object.keys(arguments) || '').length === 2;
14939 }(1, 2));
14940 if (!keysWorksWithArguments) {
14941 var originalKeys = Object.keys;
14942 Object.keys = function keys(object) { // eslint-disable-line func-name-matching
14943 if (isArgs(object)) {
14944 return originalKeys(slice.call(object));
14945 } else {
14946 return originalKeys(object);
14947 }
14948 };
14949 }
14950 } else {
14951 Object.keys = keysShim;
14952 }
14953 return Object.keys || keysShim;
14954};
14955
14956module.exports = keysShim;
14957
14958},{"./isArguments":241}],241:[function(require,module,exports){
14959arguments[4][210][0].apply(exports,arguments)
14960},{"dup":210}],242:[function(require,module,exports){
14961'use strict';
14962
14963var ES = require('es-abstract/es7');
14964
14965var defineProperty = Object.defineProperty;
14966var getDescriptor = Object.getOwnPropertyDescriptor;
14967var getOwnNames = Object.getOwnPropertyNames;
14968var getSymbols = Object.getOwnPropertySymbols;
14969var concat = Function.call.bind(Array.prototype.concat);
14970var reduce = Function.call.bind(Array.prototype.reduce);
14971var getAll = getSymbols ? function (obj) {
14972 return concat(getOwnNames(obj), getSymbols(obj));
14973} : getOwnNames;
14974
14975var isES5 = ES.IsCallable(getDescriptor) && ES.IsCallable(getOwnNames);
14976
14977var safePut = function put(obj, prop, val) { // eslint-disable-line max-params
14978 if (defineProperty && prop in obj) {
14979 defineProperty(obj, prop, {
14980 configurable: true,
14981 enumerable: true,
14982 value: val,
14983 writable: true
14984 });
14985 } else {
14986 obj[prop] = val;
14987 }
14988};
14989
14990module.exports = function getOwnPropertyDescriptors(value) {
14991 ES.RequireObjectCoercible(value);
14992 if (!isES5) {
14993 throw new TypeError('getOwnPropertyDescriptors requires Object.getOwnPropertyDescriptor');
14994 }
14995
14996 var O = ES.ToObject(value);
14997 return reduce(getAll(O), function (acc, key) {
14998 var descriptor = getDescriptor(O, key);
14999 if (typeof descriptor !== 'undefined') {
15000 safePut(acc, key, descriptor);
15001 }
15002 return acc;
15003 }, {});
15004};
15005
15006},{"es-abstract/es7":195}],243:[function(require,module,exports){
15007'use strict';
15008
15009var define = require('define-properties');
15010
15011var implementation = require('./implementation');
15012var getPolyfill = require('./polyfill');
15013var shim = require('./shim');
15014
15015define(implementation, {
15016 getPolyfill: getPolyfill,
15017 implementation: implementation,
15018 shim: shim
15019});
15020
15021module.exports = implementation;
15022
15023},{"./implementation":242,"./polyfill":244,"./shim":245,"define-properties":190}],244:[function(require,module,exports){
15024'use strict';
15025
15026var implementation = require('./implementation');
15027
15028module.exports = function getPolyfill() {
15029 return typeof Object.getOwnPropertyDescriptors === 'function' ? Object.getOwnPropertyDescriptors : implementation;
15030};
15031
15032},{"./implementation":242}],245:[function(require,module,exports){
15033'use strict';
15034
15035var getPolyfill = require('./polyfill');
15036var define = require('define-properties');
15037
15038module.exports = function shimGetOwnPropertyDescriptors() {
15039 var polyfill = getPolyfill();
15040 define(
15041 Object,
15042 { getOwnPropertyDescriptors: polyfill },
15043 { getOwnPropertyDescriptors: function () { return Object.getOwnPropertyDescriptors !== polyfill; } }
15044 );
15045 return polyfill;
15046};
15047
15048},{"./polyfill":244,"define-properties":190}],246:[function(require,module,exports){
15049(function (process){
15050// .dirname, .basename, and .extname methods are extracted from Node.js v8.11.1,
15051// backported and transplited with Babel, with backwards-compat fixes
15052
15053// Copyright Joyent, Inc. and other Node contributors.
15054//
15055// Permission is hereby granted, free of charge, to any person obtaining a
15056// copy of this software and associated documentation files (the
15057// "Software"), to deal in the Software without restriction, including
15058// without limitation the rights to use, copy, modify, merge, publish,
15059// distribute, sublicense, and/or sell copies of the Software, and to permit
15060// persons to whom the Software is furnished to do so, subject to the
15061// following conditions:
15062//
15063// The above copyright notice and this permission notice shall be included
15064// in all copies or substantial portions of the Software.
15065//
15066// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15067// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15068// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
15069// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15070// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15071// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
15072// USE OR OTHER DEALINGS IN THE SOFTWARE.
15073
15074// resolves . and .. elements in a path array with directory names there
15075// must be no slashes, empty elements, or device names (c:\) in the array
15076// (so also no leading and trailing slashes - it does not distinguish
15077// relative and absolute paths)
15078function normalizeArray(parts, allowAboveRoot) {
15079 // if the path tries to go above the root, `up` ends up > 0
15080 var up = 0;
15081 for (var i = parts.length - 1; i >= 0; i--) {
15082 var last = parts[i];
15083 if (last === '.') {
15084 parts.splice(i, 1);
15085 } else if (last === '..') {
15086 parts.splice(i, 1);
15087 up++;
15088 } else if (up) {
15089 parts.splice(i, 1);
15090 up--;
15091 }
15092 }
15093
15094 // if the path is allowed to go above the root, restore leading ..s
15095 if (allowAboveRoot) {
15096 for (; up--; up) {
15097 parts.unshift('..');
15098 }
15099 }
15100
15101 return parts;
15102}
15103
15104// path.resolve([from ...], to)
15105// posix version
15106exports.resolve = function() {
15107 var resolvedPath = '',
15108 resolvedAbsolute = false;
15109
15110 for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
15111 var path = (i >= 0) ? arguments[i] : process.cwd();
15112
15113 // Skip empty and invalid entries
15114 if (typeof path !== 'string') {
15115 throw new TypeError('Arguments to path.resolve must be strings');
15116 } else if (!path) {
15117 continue;
15118 }
15119
15120 resolvedPath = path + '/' + resolvedPath;
15121 resolvedAbsolute = path.charAt(0) === '/';
15122 }
15123
15124 // At this point the path should be resolved to a full absolute path, but
15125 // handle relative paths to be safe (might happen when process.cwd() fails)
15126
15127 // Normalize the path
15128 resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
15129 return !!p;
15130 }), !resolvedAbsolute).join('/');
15131
15132 return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
15133};
15134
15135// path.normalize(path)
15136// posix version
15137exports.normalize = function(path) {
15138 var isAbsolute = exports.isAbsolute(path),
15139 trailingSlash = substr(path, -1) === '/';
15140
15141 // Normalize the path
15142 path = normalizeArray(filter(path.split('/'), function(p) {
15143 return !!p;
15144 }), !isAbsolute).join('/');
15145
15146 if (!path && !isAbsolute) {
15147 path = '.';
15148 }
15149 if (path && trailingSlash) {
15150 path += '/';
15151 }
15152
15153 return (isAbsolute ? '/' : '') + path;
15154};
15155
15156// posix version
15157exports.isAbsolute = function(path) {
15158 return path.charAt(0) === '/';
15159};
15160
15161// posix version
15162exports.join = function() {
15163 var paths = Array.prototype.slice.call(arguments, 0);
15164 return exports.normalize(filter(paths, function(p, index) {
15165 if (typeof p !== 'string') {
15166 throw new TypeError('Arguments to path.join must be strings');
15167 }
15168 return p;
15169 }).join('/'));
15170};
15171
15172
15173// path.relative(from, to)
15174// posix version
15175exports.relative = function(from, to) {
15176 from = exports.resolve(from).substr(1);
15177 to = exports.resolve(to).substr(1);
15178
15179 function trim(arr) {
15180 var start = 0;
15181 for (; start < arr.length; start++) {
15182 if (arr[start] !== '') break;
15183 }
15184
15185 var end = arr.length - 1;
15186 for (; end >= 0; end--) {
15187 if (arr[end] !== '') break;
15188 }
15189
15190 if (start > end) return [];
15191 return arr.slice(start, end - start + 1);
15192 }
15193
15194 var fromParts = trim(from.split('/'));
15195 var toParts = trim(to.split('/'));
15196
15197 var length = Math.min(fromParts.length, toParts.length);
15198 var samePartsLength = length;
15199 for (var i = 0; i < length; i++) {
15200 if (fromParts[i] !== toParts[i]) {
15201 samePartsLength = i;
15202 break;
15203 }
15204 }
15205
15206 var outputParts = [];
15207 for (var i = samePartsLength; i < fromParts.length; i++) {
15208 outputParts.push('..');
15209 }
15210
15211 outputParts = outputParts.concat(toParts.slice(samePartsLength));
15212
15213 return outputParts.join('/');
15214};
15215
15216exports.sep = '/';
15217exports.delimiter = ':';
15218
15219exports.dirname = function (path) {
15220 if (typeof path !== 'string') path = path + '';
15221 if (path.length === 0) return '.';
15222 var code = path.charCodeAt(0);
15223 var hasRoot = code === 47 /*/*/;
15224 var end = -1;
15225 var matchedSlash = true;
15226 for (var i = path.length - 1; i >= 1; --i) {
15227 code = path.charCodeAt(i);
15228 if (code === 47 /*/*/) {
15229 if (!matchedSlash) {
15230 end = i;
15231 break;
15232 }
15233 } else {
15234 // We saw the first non-path separator
15235 matchedSlash = false;
15236 }
15237 }
15238
15239 if (end === -1) return hasRoot ? '/' : '.';
15240 if (hasRoot && end === 1) {
15241 // return '//';
15242 // Backwards-compat fix:
15243 return '/';
15244 }
15245 return path.slice(0, end);
15246};
15247
15248function basename(path) {
15249 if (typeof path !== 'string') path = path + '';
15250
15251 var start = 0;
15252 var end = -1;
15253 var matchedSlash = true;
15254 var i;
15255
15256 for (i = path.length - 1; i >= 0; --i) {
15257 if (path.charCodeAt(i) === 47 /*/*/) {
15258 // If we reached a path separator that was not part of a set of path
15259 // separators at the end of the string, stop now
15260 if (!matchedSlash) {
15261 start = i + 1;
15262 break;
15263 }
15264 } else if (end === -1) {
15265 // We saw the first non-path separator, mark this as the end of our
15266 // path component
15267 matchedSlash = false;
15268 end = i + 1;
15269 }
15270 }
15271
15272 if (end === -1) return '';
15273 return path.slice(start, end);
15274}
15275
15276// Uses a mixed approach for backwards-compatibility, as ext behavior changed
15277// in new Node.js versions, so only basename() above is backported here
15278exports.basename = function (path, ext) {
15279 var f = basename(path);
15280 if (ext && f.substr(-1 * ext.length) === ext) {
15281 f = f.substr(0, f.length - ext.length);
15282 }
15283 return f;
15284};
15285
15286exports.extname = function (path) {
15287 if (typeof path !== 'string') path = path + '';
15288 var startDot = -1;
15289 var startPart = 0;
15290 var end = -1;
15291 var matchedSlash = true;
15292 // Track the state of characters (if any) we see before our first dot and
15293 // after any path separator we find
15294 var preDotState = 0;
15295 for (var i = path.length - 1; i >= 0; --i) {
15296 var code = path.charCodeAt(i);
15297 if (code === 47 /*/*/) {
15298 // If we reached a path separator that was not part of a set of path
15299 // separators at the end of the string, stop now
15300 if (!matchedSlash) {
15301 startPart = i + 1;
15302 break;
15303 }
15304 continue;
15305 }
15306 if (end === -1) {
15307 // We saw the first non-path separator, mark this as the end of our
15308 // extension
15309 matchedSlash = false;
15310 end = i + 1;
15311 }
15312 if (code === 46 /*.*/) {
15313 // If this is our first dot, mark it as the start of our extension
15314 if (startDot === -1)
15315 startDot = i;
15316 else if (preDotState !== 1)
15317 preDotState = 1;
15318 } else if (startDot !== -1) {
15319 // We saw a non-dot and non-path separator before our dot, so we should
15320 // have a good chance at having a non-empty extension
15321 preDotState = -1;
15322 }
15323 }
15324
15325 if (startDot === -1 || end === -1 ||
15326 // We saw a non-dot character immediately before the dot
15327 preDotState === 0 ||
15328 // The (right-most) trimmed path component is exactly '..'
15329 preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
15330 return '';
15331 }
15332 return path.slice(startDot, end);
15333};
15334
15335function filter (xs, f) {
15336 if (xs.filter) return xs.filter(f);
15337 var res = [];
15338 for (var i = 0; i < xs.length; i++) {
15339 if (f(xs[i], i, xs)) res.push(xs[i]);
15340 }
15341 return res;
15342}
15343
15344// String.prototype.substr - negative index don't work in IE8
15345var substr = 'ab'.substr(-1) === 'b'
15346 ? function (str, start, len) { return str.substr(start, len) }
15347 : function (str, start, len) {
15348 if (start < 0) start = str.length + start;
15349 return str.substr(start, len);
15350 }
15351;
15352
15353}).call(this,require('_process'))
15354},{"_process":249}],247:[function(require,module,exports){
15355(function (global){
15356/*!
15357 * Platform.js <https://mths.be/platform>
15358 * Copyright 2014-2018 Benjamin Tan <https://bnjmnt4n.now.sh/>
15359 * Copyright 2011-2013 John-David Dalton <http://allyoucanleet.com/>
15360 * Available under MIT license <https://mths.be/mit>
15361 */
15362;(function() {
15363 'use strict';
15364
15365 /** Used to determine if values are of the language type `Object`. */
15366 var objectTypes = {
15367 'function': true,
15368 'object': true
15369 };
15370
15371 /** Used as a reference to the global object. */
15372 var root = (objectTypes[typeof window] && window) || this;
15373
15374 /** Backup possible global object. */
15375 var oldRoot = root;
15376
15377 /** Detect free variable `exports`. */
15378 var freeExports = objectTypes[typeof exports] && exports;
15379
15380 /** Detect free variable `module`. */
15381 var freeModule = objectTypes[typeof module] && module && !module.nodeType && module;
15382
15383 /** Detect free variable `global` from Node.js or Browserified code and use it as `root`. */
15384 var freeGlobal = freeExports && freeModule && typeof global == 'object' && global;
15385 if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal)) {
15386 root = freeGlobal;
15387 }
15388
15389 /**
15390 * Used as the maximum length of an array-like object.
15391 * See the [ES6 spec](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength)
15392 * for more details.
15393 */
15394 var maxSafeInteger = Math.pow(2, 53) - 1;
15395
15396 /** Regular expression to detect Opera. */
15397 var reOpera = /\bOpera/;
15398
15399 /** Possible global object. */
15400 var thisBinding = this;
15401
15402 /** Used for native method references. */
15403 var objectProto = Object.prototype;
15404
15405 /** Used to check for own properties of an object. */
15406 var hasOwnProperty = objectProto.hasOwnProperty;
15407
15408 /** Used to resolve the internal `[[Class]]` of values. */
15409 var toString = objectProto.toString;
15410
15411 /*--------------------------------------------------------------------------*/
15412
15413 /**
15414 * Capitalizes a string value.
15415 *
15416 * @private
15417 * @param {string} string The string to capitalize.
15418 * @returns {string} The capitalized string.
15419 */
15420 function capitalize(string) {
15421 string = String(string);
15422 return string.charAt(0).toUpperCase() + string.slice(1);
15423 }
15424
15425 /**
15426 * A utility function to clean up the OS name.
15427 *
15428 * @private
15429 * @param {string} os The OS name to clean up.
15430 * @param {string} [pattern] A `RegExp` pattern matching the OS name.
15431 * @param {string} [label] A label for the OS.
15432 */
15433 function cleanupOS(os, pattern, label) {
15434 // Platform tokens are defined at:
15435 // http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx
15436 // http://web.archive.org/web/20081122053950/http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx
15437 var data = {
15438 '10.0': '10',
15439 '6.4': '10 Technical Preview',
15440 '6.3': '8.1',
15441 '6.2': '8',
15442 '6.1': 'Server 2008 R2 / 7',
15443 '6.0': 'Server 2008 / Vista',
15444 '5.2': 'Server 2003 / XP 64-bit',
15445 '5.1': 'XP',
15446 '5.01': '2000 SP1',
15447 '5.0': '2000',
15448 '4.0': 'NT',
15449 '4.90': 'ME'
15450 };
15451 // Detect Windows version from platform tokens.
15452 if (pattern && label && /^Win/i.test(os) && !/^Windows Phone /i.test(os) &&
15453 (data = data[/[\d.]+$/.exec(os)])) {
15454 os = 'Windows ' + data;
15455 }
15456 // Correct character case and cleanup string.
15457 os = String(os);
15458
15459 if (pattern && label) {
15460 os = os.replace(RegExp(pattern, 'i'), label);
15461 }
15462
15463 os = format(
15464 os.replace(/ ce$/i, ' CE')
15465 .replace(/\bhpw/i, 'web')
15466 .replace(/\bMacintosh\b/, 'Mac OS')
15467 .replace(/_PowerPC\b/i, ' OS')
15468 .replace(/\b(OS X) [^ \d]+/i, '$1')
15469 .replace(/\bMac (OS X)\b/, '$1')
15470 .replace(/\/(\d)/, ' $1')
15471 .replace(/_/g, '.')
15472 .replace(/(?: BePC|[ .]*fc[ \d.]+)$/i, '')
15473 .replace(/\bx86\.64\b/gi, 'x86_64')
15474 .replace(/\b(Windows Phone) OS\b/, '$1')
15475 .replace(/\b(Chrome OS \w+) [\d.]+\b/, '$1')
15476 .split(' on ')[0]
15477 );
15478
15479 return os;
15480 }
15481
15482 /**
15483 * An iteration utility for arrays and objects.
15484 *
15485 * @private
15486 * @param {Array|Object} object The object to iterate over.
15487 * @param {Function} callback The function called per iteration.
15488 */
15489 function each(object, callback) {
15490 var index = -1,
15491 length = object ? object.length : 0;
15492
15493 if (typeof length == 'number' && length > -1 && length <= maxSafeInteger) {
15494 while (++index < length) {
15495 callback(object[index], index, object);
15496 }
15497 } else {
15498 forOwn(object, callback);
15499 }
15500 }
15501
15502 /**
15503 * Trim and conditionally capitalize string values.
15504 *
15505 * @private
15506 * @param {string} string The string to format.
15507 * @returns {string} The formatted string.
15508 */
15509 function format(string) {
15510 string = trim(string);
15511 return /^(?:webOS|i(?:OS|P))/.test(string)
15512 ? string
15513 : capitalize(string);
15514 }
15515
15516 /**
15517 * Iterates over an object's own properties, executing the `callback` for each.
15518 *
15519 * @private
15520 * @param {Object} object The object to iterate over.
15521 * @param {Function} callback The function executed per own property.
15522 */
15523 function forOwn(object, callback) {
15524 for (var key in object) {
15525 if (hasOwnProperty.call(object, key)) {
15526 callback(object[key], key, object);
15527 }
15528 }
15529 }
15530
15531 /**
15532 * Gets the internal `[[Class]]` of a value.
15533 *
15534 * @private
15535 * @param {*} value The value.
15536 * @returns {string} The `[[Class]]`.
15537 */
15538 function getClassOf(value) {
15539 return value == null
15540 ? capitalize(value)
15541 : toString.call(value).slice(8, -1);
15542 }
15543
15544 /**
15545 * Host objects can return type values that are different from their actual
15546 * data type. The objects we are concerned with usually return non-primitive
15547 * types of "object", "function", or "unknown".
15548 *
15549 * @private
15550 * @param {*} object The owner of the property.
15551 * @param {string} property The property to check.
15552 * @returns {boolean} Returns `true` if the property value is a non-primitive, else `false`.
15553 */
15554 function isHostType(object, property) {
15555 var type = object != null ? typeof object[property] : 'number';
15556 return !/^(?:boolean|number|string|undefined)$/.test(type) &&
15557 (type == 'object' ? !!object[property] : true);
15558 }
15559
15560 /**
15561 * Prepares a string for use in a `RegExp` by making hyphens and spaces optional.
15562 *
15563 * @private
15564 * @param {string} string The string to qualify.
15565 * @returns {string} The qualified string.
15566 */
15567 function qualify(string) {
15568 return String(string).replace(/([ -])(?!$)/g, '$1?');
15569 }
15570
15571 /**
15572 * A bare-bones `Array#reduce` like utility function.
15573 *
15574 * @private
15575 * @param {Array} array The array to iterate over.
15576 * @param {Function} callback The function called per iteration.
15577 * @returns {*} The accumulated result.
15578 */
15579 function reduce(array, callback) {
15580 var accumulator = null;
15581 each(array, function(value, index) {
15582 accumulator = callback(accumulator, value, index, array);
15583 });
15584 return accumulator;
15585 }
15586
15587 /**
15588 * Removes leading and trailing whitespace from a string.
15589 *
15590 * @private
15591 * @param {string} string The string to trim.
15592 * @returns {string} The trimmed string.
15593 */
15594 function trim(string) {
15595 return String(string).replace(/^ +| +$/g, '');
15596 }
15597
15598 /*--------------------------------------------------------------------------*/
15599
15600 /**
15601 * Creates a new platform object.
15602 *
15603 * @memberOf platform
15604 * @param {Object|string} [ua=navigator.userAgent] The user agent string or
15605 * context object.
15606 * @returns {Object} A platform object.
15607 */
15608 function parse(ua) {
15609
15610 /** The environment context object. */
15611 var context = root;
15612
15613 /** Used to flag when a custom context is provided. */
15614 var isCustomContext = ua && typeof ua == 'object' && getClassOf(ua) != 'String';
15615
15616 // Juggle arguments.
15617 if (isCustomContext) {
15618 context = ua;
15619 ua = null;
15620 }
15621
15622 /** Browser navigator object. */
15623 var nav = context.navigator || {};
15624
15625 /** Browser user agent string. */
15626 var userAgent = nav.userAgent || '';
15627
15628 ua || (ua = userAgent);
15629
15630 /** Used to flag when `thisBinding` is the [ModuleScope]. */
15631 var isModuleScope = isCustomContext || thisBinding == oldRoot;
15632
15633 /** Used to detect if browser is like Chrome. */
15634 var likeChrome = isCustomContext
15635 ? !!nav.likeChrome
15636 : /\bChrome\b/.test(ua) && !/internal|\n/i.test(toString.toString());
15637
15638 /** Internal `[[Class]]` value shortcuts. */
15639 var objectClass = 'Object',
15640 airRuntimeClass = isCustomContext ? objectClass : 'ScriptBridgingProxyObject',
15641 enviroClass = isCustomContext ? objectClass : 'Environment',
15642 javaClass = (isCustomContext && context.java) ? 'JavaPackage' : getClassOf(context.java),
15643 phantomClass = isCustomContext ? objectClass : 'RuntimeObject';
15644
15645 /** Detect Java environments. */
15646 var java = /\bJava/.test(javaClass) && context.java;
15647
15648 /** Detect Rhino. */
15649 var rhino = java && getClassOf(context.environment) == enviroClass;
15650
15651 /** A character to represent alpha. */
15652 var alpha = java ? 'a' : '\u03b1';
15653
15654 /** A character to represent beta. */
15655 var beta = java ? 'b' : '\u03b2';
15656
15657 /** Browser document object. */
15658 var doc = context.document || {};
15659
15660 /**
15661 * Detect Opera browser (Presto-based).
15662 * http://www.howtocreate.co.uk/operaStuff/operaObject.html
15663 * http://dev.opera.com/articles/view/opera-mini-web-content-authoring-guidelines/#operamini
15664 */
15665 var opera = context.operamini || context.opera;
15666
15667 /** Opera `[[Class]]`. */
15668 var operaClass = reOpera.test(operaClass = (isCustomContext && opera) ? opera['[[Class]]'] : getClassOf(opera))
15669 ? operaClass
15670 : (opera = null);
15671
15672 /*------------------------------------------------------------------------*/
15673
15674 /** Temporary variable used over the script's lifetime. */
15675 var data;
15676
15677 /** The CPU architecture. */
15678 var arch = ua;
15679
15680 /** Platform description array. */
15681 var description = [];
15682
15683 /** Platform alpha/beta indicator. */
15684 var prerelease = null;
15685
15686 /** A flag to indicate that environment features should be used to resolve the platform. */
15687 var useFeatures = ua == userAgent;
15688
15689 /** The browser/environment version. */
15690 var version = useFeatures && opera && typeof opera.version == 'function' && opera.version();
15691
15692 /** A flag to indicate if the OS ends with "/ Version" */
15693 var isSpecialCasedOS;
15694
15695 /* Detectable layout engines (order is important). */
15696 var layout = getLayout([
15697 { 'label': 'EdgeHTML', 'pattern': 'Edge' },
15698 'Trident',
15699 { 'label': 'WebKit', 'pattern': 'AppleWebKit' },
15700 'iCab',
15701 'Presto',
15702 'NetFront',
15703 'Tasman',
15704 'KHTML',
15705 'Gecko'
15706 ]);
15707
15708 /* Detectable browser names (order is important). */
15709 var name = getName([
15710 'Adobe AIR',
15711 'Arora',
15712 'Avant Browser',
15713 'Breach',
15714 'Camino',
15715 'Electron',
15716 'Epiphany',
15717 'Fennec',
15718 'Flock',
15719 'Galeon',
15720 'GreenBrowser',
15721 'iCab',
15722 'Iceweasel',
15723 'K-Meleon',
15724 'Konqueror',
15725 'Lunascape',
15726 'Maxthon',
15727 { 'label': 'Microsoft Edge', 'pattern': 'Edge' },
15728 'Midori',
15729 'Nook Browser',
15730 'PaleMoon',
15731 'PhantomJS',
15732 'Raven',
15733 'Rekonq',
15734 'RockMelt',
15735 { 'label': 'Samsung Internet', 'pattern': 'SamsungBrowser' },
15736 'SeaMonkey',
15737 { 'label': 'Silk', 'pattern': '(?:Cloud9|Silk-Accelerated)' },
15738 'Sleipnir',
15739 'SlimBrowser',
15740 { 'label': 'SRWare Iron', 'pattern': 'Iron' },
15741 'Sunrise',
15742 'Swiftfox',
15743 'Waterfox',
15744 'WebPositive',
15745 'Opera Mini',
15746 { 'label': 'Opera Mini', 'pattern': 'OPiOS' },
15747 'Opera',
15748 { 'label': 'Opera', 'pattern': 'OPR' },
15749 'Chrome',
15750 { 'label': 'Chrome Mobile', 'pattern': '(?:CriOS|CrMo)' },
15751 { 'label': 'Firefox', 'pattern': '(?:Firefox|Minefield)' },
15752 { 'label': 'Firefox for iOS', 'pattern': 'FxiOS' },
15753 { 'label': 'IE', 'pattern': 'IEMobile' },
15754 { 'label': 'IE', 'pattern': 'MSIE' },
15755 'Safari'
15756 ]);
15757
15758 /* Detectable products (order is important). */
15759 var product = getProduct([
15760 { 'label': 'BlackBerry', 'pattern': 'BB10' },
15761 'BlackBerry',
15762 { 'label': 'Galaxy S', 'pattern': 'GT-I9000' },
15763 { 'label': 'Galaxy S2', 'pattern': 'GT-I9100' },
15764 { 'label': 'Galaxy S3', 'pattern': 'GT-I9300' },
15765 { 'label': 'Galaxy S4', 'pattern': 'GT-I9500' },
15766 { 'label': 'Galaxy S5', 'pattern': 'SM-G900' },
15767 { 'label': 'Galaxy S6', 'pattern': 'SM-G920' },
15768 { 'label': 'Galaxy S6 Edge', 'pattern': 'SM-G925' },
15769 { 'label': 'Galaxy S7', 'pattern': 'SM-G930' },
15770 { 'label': 'Galaxy S7 Edge', 'pattern': 'SM-G935' },
15771 'Google TV',
15772 'Lumia',
15773 'iPad',
15774 'iPod',
15775 'iPhone',
15776 'Kindle',
15777 { 'label': 'Kindle Fire', 'pattern': '(?:Cloud9|Silk-Accelerated)' },
15778 'Nexus',
15779 'Nook',
15780 'PlayBook',
15781 'PlayStation Vita',
15782 'PlayStation',
15783 'TouchPad',
15784 'Transformer',
15785 { 'label': 'Wii U', 'pattern': 'WiiU' },
15786 'Wii',
15787 'Xbox One',
15788 { 'label': 'Xbox 360', 'pattern': 'Xbox' },
15789 'Xoom'
15790 ]);
15791
15792 /* Detectable manufacturers. */
15793 var manufacturer = getManufacturer({
15794 'Apple': { 'iPad': 1, 'iPhone': 1, 'iPod': 1 },
15795 'Archos': {},
15796 'Amazon': { 'Kindle': 1, 'Kindle Fire': 1 },
15797 'Asus': { 'Transformer': 1 },
15798 'Barnes & Noble': { 'Nook': 1 },
15799 'BlackBerry': { 'PlayBook': 1 },
15800 'Google': { 'Google TV': 1, 'Nexus': 1 },
15801 'HP': { 'TouchPad': 1 },
15802 'HTC': {},
15803 'LG': {},
15804 'Microsoft': { 'Xbox': 1, 'Xbox One': 1 },
15805 'Motorola': { 'Xoom': 1 },
15806 'Nintendo': { 'Wii U': 1, 'Wii': 1 },
15807 'Nokia': { 'Lumia': 1 },
15808 'Samsung': { 'Galaxy S': 1, 'Galaxy S2': 1, 'Galaxy S3': 1, 'Galaxy S4': 1 },
15809 'Sony': { 'PlayStation': 1, 'PlayStation Vita': 1 }
15810 });
15811
15812 /* Detectable operating systems (order is important). */
15813 var os = getOS([
15814 'Windows Phone',
15815 'Android',
15816 'CentOS',
15817 { 'label': 'Chrome OS', 'pattern': 'CrOS' },
15818 'Debian',
15819 'Fedora',
15820 'FreeBSD',
15821 'Gentoo',
15822 'Haiku',
15823 'Kubuntu',
15824 'Linux Mint',
15825 'OpenBSD',
15826 'Red Hat',
15827 'SuSE',
15828 'Ubuntu',
15829 'Xubuntu',
15830 'Cygwin',
15831 'Symbian OS',
15832 'hpwOS',
15833 'webOS ',
15834 'webOS',
15835 'Tablet OS',
15836 'Tizen',
15837 'Linux',
15838 'Mac OS X',
15839 'Macintosh',
15840 'Mac',
15841 'Windows 98;',
15842 'Windows '
15843 ]);
15844
15845 /*------------------------------------------------------------------------*/
15846
15847 /**
15848 * Picks the layout engine from an array of guesses.
15849 *
15850 * @private
15851 * @param {Array} guesses An array of guesses.
15852 * @returns {null|string} The detected layout engine.
15853 */
15854 function getLayout(guesses) {
15855 return reduce(guesses, function(result, guess) {
15856 return result || RegExp('\\b' + (
15857 guess.pattern || qualify(guess)
15858 ) + '\\b', 'i').exec(ua) && (guess.label || guess);
15859 });
15860 }
15861
15862 /**
15863 * Picks the manufacturer from an array of guesses.
15864 *
15865 * @private
15866 * @param {Array} guesses An object of guesses.
15867 * @returns {null|string} The detected manufacturer.
15868 */
15869 function getManufacturer(guesses) {
15870 return reduce(guesses, function(result, value, key) {
15871 // Lookup the manufacturer by product or scan the UA for the manufacturer.
15872 return result || (
15873 value[product] ||
15874 value[/^[a-z]+(?: +[a-z]+\b)*/i.exec(product)] ||
15875 RegExp('\\b' + qualify(key) + '(?:\\b|\\w*\\d)', 'i').exec(ua)
15876 ) && key;
15877 });
15878 }
15879
15880 /**
15881 * Picks the browser name from an array of guesses.
15882 *
15883 * @private
15884 * @param {Array} guesses An array of guesses.
15885 * @returns {null|string} The detected browser name.
15886 */
15887 function getName(guesses) {
15888 return reduce(guesses, function(result, guess) {
15889 return result || RegExp('\\b' + (
15890 guess.pattern || qualify(guess)
15891 ) + '\\b', 'i').exec(ua) && (guess.label || guess);
15892 });
15893 }
15894
15895 /**
15896 * Picks the OS name from an array of guesses.
15897 *
15898 * @private
15899 * @param {Array} guesses An array of guesses.
15900 * @returns {null|string} The detected OS name.
15901 */
15902 function getOS(guesses) {
15903 return reduce(guesses, function(result, guess) {
15904 var pattern = guess.pattern || qualify(guess);
15905 if (!result && (result =
15906 RegExp('\\b' + pattern + '(?:/[\\d.]+|[ \\w.]*)', 'i').exec(ua)
15907 )) {
15908 result = cleanupOS(result, pattern, guess.label || guess);
15909 }
15910 return result;
15911 });
15912 }
15913
15914 /**
15915 * Picks the product name from an array of guesses.
15916 *
15917 * @private
15918 * @param {Array} guesses An array of guesses.
15919 * @returns {null|string} The detected product name.
15920 */
15921 function getProduct(guesses) {
15922 return reduce(guesses, function(result, guess) {
15923 var pattern = guess.pattern || qualify(guess);
15924 if (!result && (result =
15925 RegExp('\\b' + pattern + ' *\\d+[.\\w_]*', 'i').exec(ua) ||
15926 RegExp('\\b' + pattern + ' *\\w+-[\\w]*', 'i').exec(ua) ||
15927 RegExp('\\b' + pattern + '(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)', 'i').exec(ua)
15928 )) {
15929 // Split by forward slash and append product version if needed.
15930 if ((result = String((guess.label && !RegExp(pattern, 'i').test(guess.label)) ? guess.label : result).split('/'))[1] && !/[\d.]+/.test(result[0])) {
15931 result[0] += ' ' + result[1];
15932 }
15933 // Correct character case and cleanup string.
15934 guess = guess.label || guess;
15935 result = format(result[0]
15936 .replace(RegExp(pattern, 'i'), guess)
15937 .replace(RegExp('; *(?:' + guess + '[_-])?', 'i'), ' ')
15938 .replace(RegExp('(' + guess + ')[-_.]?(\\w)', 'i'), '$1 $2'));
15939 }
15940 return result;
15941 });
15942 }
15943
15944 /**
15945 * Resolves the version using an array of UA patterns.
15946 *
15947 * @private
15948 * @param {Array} patterns An array of UA patterns.
15949 * @returns {null|string} The detected version.
15950 */
15951 function getVersion(patterns) {
15952 return reduce(patterns, function(result, pattern) {
15953 return result || (RegExp(pattern +
15954 '(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)', 'i').exec(ua) || 0)[1] || null;
15955 });
15956 }
15957
15958 /**
15959 * Returns `platform.description` when the platform object is coerced to a string.
15960 *
15961 * @name toString
15962 * @memberOf platform
15963 * @returns {string} Returns `platform.description` if available, else an empty string.
15964 */
15965 function toStringPlatform() {
15966 return this.description || '';
15967 }
15968
15969 /*------------------------------------------------------------------------*/
15970
15971 // Convert layout to an array so we can add extra details.
15972 layout && (layout = [layout]);
15973
15974 // Detect product names that contain their manufacturer's name.
15975 if (manufacturer && !product) {
15976 product = getProduct([manufacturer]);
15977 }
15978 // Clean up Google TV.
15979 if ((data = /\bGoogle TV\b/.exec(product))) {
15980 product = data[0];
15981 }
15982 // Detect simulators.
15983 if (/\bSimulator\b/i.test(ua)) {
15984 product = (product ? product + ' ' : '') + 'Simulator';
15985 }
15986 // Detect Opera Mini 8+ running in Turbo/Uncompressed mode on iOS.
15987 if (name == 'Opera Mini' && /\bOPiOS\b/.test(ua)) {
15988 description.push('running in Turbo/Uncompressed mode');
15989 }
15990 // Detect IE Mobile 11.
15991 if (name == 'IE' && /\blike iPhone OS\b/.test(ua)) {
15992 data = parse(ua.replace(/like iPhone OS/, ''));
15993 manufacturer = data.manufacturer;
15994 product = data.product;
15995 }
15996 // Detect iOS.
15997 else if (/^iP/.test(product)) {
15998 name || (name = 'Safari');
15999 os = 'iOS' + ((data = / OS ([\d_]+)/i.exec(ua))
16000 ? ' ' + data[1].replace(/_/g, '.')
16001 : '');
16002 }
16003 // Detect Kubuntu.
16004 else if (name == 'Konqueror' && !/buntu/i.test(os)) {
16005 os = 'Kubuntu';
16006 }
16007 // Detect Android browsers.
16008 else if ((manufacturer && manufacturer != 'Google' &&
16009 ((/Chrome/.test(name) && !/\bMobile Safari\b/i.test(ua)) || /\bVita\b/.test(product))) ||
16010 (/\bAndroid\b/.test(os) && /^Chrome/.test(name) && /\bVersion\//i.test(ua))) {
16011 name = 'Android Browser';
16012 os = /\bAndroid\b/.test(os) ? os : 'Android';
16013 }
16014 // Detect Silk desktop/accelerated modes.
16015 else if (name == 'Silk') {
16016 if (!/\bMobi/i.test(ua)) {
16017 os = 'Android';
16018 description.unshift('desktop mode');
16019 }
16020 if (/Accelerated *= *true/i.test(ua)) {
16021 description.unshift('accelerated');
16022 }
16023 }
16024 // Detect PaleMoon identifying as Firefox.
16025 else if (name == 'PaleMoon' && (data = /\bFirefox\/([\d.]+)\b/.exec(ua))) {
16026 description.push('identifying as Firefox ' + data[1]);
16027 }
16028 // Detect Firefox OS and products running Firefox.
16029 else if (name == 'Firefox' && (data = /\b(Mobile|Tablet|TV)\b/i.exec(ua))) {
16030 os || (os = 'Firefox OS');
16031 product || (product = data[1]);
16032 }
16033 // Detect false positives for Firefox/Safari.
16034 else if (!name || (data = !/\bMinefield\b/i.test(ua) && /\b(?:Firefox|Safari)\b/.exec(name))) {
16035 // Escape the `/` for Firefox 1.
16036 if (name && !product && /[\/,]|^[^(]+?\)/.test(ua.slice(ua.indexOf(data + '/') + 8))) {
16037 // Clear name of false positives.
16038 name = null;
16039 }
16040 // Reassign a generic name.
16041 if ((data = product || manufacturer || os) &&
16042 (product || manufacturer || /\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(os))) {
16043 name = /[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(os) ? os : data) + ' Browser';
16044 }
16045 }
16046 // Add Chrome version to description for Electron.
16047 else if (name == 'Electron' && (data = (/\bChrome\/([\d.]+)\b/.exec(ua) || 0)[1])) {
16048 description.push('Chromium ' + data);
16049 }
16050 // Detect non-Opera (Presto-based) versions (order is important).
16051 if (!version) {
16052 version = getVersion([
16053 '(?:Cloud9|CriOS|CrMo|Edge|FxiOS|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$))',
16054 'Version',
16055 qualify(name),
16056 '(?:Firefox|Minefield|NetFront)'
16057 ]);
16058 }
16059 // Detect stubborn layout engines.
16060 if ((data =
16061 layout == 'iCab' && parseFloat(version) > 3 && 'WebKit' ||
16062 /\bOpera\b/.test(name) && (/\bOPR\b/.test(ua) ? 'Blink' : 'Presto') ||
16063 /\b(?:Midori|Nook|Safari)\b/i.test(ua) && !/^(?:Trident|EdgeHTML)$/.test(layout) && 'WebKit' ||
16064 !layout && /\bMSIE\b/i.test(ua) && (os == 'Mac OS' ? 'Tasman' : 'Trident') ||
16065 layout == 'WebKit' && /\bPlayStation\b(?! Vita\b)/i.test(name) && 'NetFront'
16066 )) {
16067 layout = [data];
16068 }
16069 // Detect Windows Phone 7 desktop mode.
16070 if (name == 'IE' && (data = (/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(ua) || 0)[1])) {
16071 name += ' Mobile';
16072 os = 'Windows Phone ' + (/\+$/.test(data) ? data : data + '.x');
16073 description.unshift('desktop mode');
16074 }
16075 // Detect Windows Phone 8.x desktop mode.
16076 else if (/\bWPDesktop\b/i.test(ua)) {
16077 name = 'IE Mobile';
16078 os = 'Windows Phone 8.x';
16079 description.unshift('desktop mode');
16080 version || (version = (/\brv:([\d.]+)/.exec(ua) || 0)[1]);
16081 }
16082 // Detect IE 11 identifying as other browsers.
16083 else if (name != 'IE' && layout == 'Trident' && (data = /\brv:([\d.]+)/.exec(ua))) {
16084 if (name) {
16085 description.push('identifying as ' + name + (version ? ' ' + version : ''));
16086 }
16087 name = 'IE';
16088 version = data[1];
16089 }
16090 // Leverage environment features.
16091 if (useFeatures) {
16092 // Detect server-side environments.
16093 // Rhino has a global function while others have a global object.
16094 if (isHostType(context, 'global')) {
16095 if (java) {
16096 data = java.lang.System;
16097 arch = data.getProperty('os.arch');
16098 os = os || data.getProperty('os.name') + ' ' + data.getProperty('os.version');
16099 }
16100 if (rhino) {
16101 try {
16102 version = context.require('ringo/engine').version.join('.');
16103 name = 'RingoJS';
16104 } catch(e) {
16105 if ((data = context.system) && data.global.system == context.system) {
16106 name = 'Narwhal';
16107 os || (os = data[0].os || null);
16108 }
16109 }
16110 if (!name) {
16111 name = 'Rhino';
16112 }
16113 }
16114 else if (
16115 typeof context.process == 'object' && !context.process.browser &&
16116 (data = context.process)
16117 ) {
16118 if (typeof data.versions == 'object') {
16119 if (typeof data.versions.electron == 'string') {
16120 description.push('Node ' + data.versions.node);
16121 name = 'Electron';
16122 version = data.versions.electron;
16123 } else if (typeof data.versions.nw == 'string') {
16124 description.push('Chromium ' + version, 'Node ' + data.versions.node);
16125 name = 'NW.js';
16126 version = data.versions.nw;
16127 }
16128 }
16129 if (!name) {
16130 name = 'Node.js';
16131 arch = data.arch;
16132 os = data.platform;
16133 version = /[\d.]+/.exec(data.version);
16134 version = version ? version[0] : null;
16135 }
16136 }
16137 }
16138 // Detect Adobe AIR.
16139 else if (getClassOf((data = context.runtime)) == airRuntimeClass) {
16140 name = 'Adobe AIR';
16141 os = data.flash.system.Capabilities.os;
16142 }
16143 // Detect PhantomJS.
16144 else if (getClassOf((data = context.phantom)) == phantomClass) {
16145 name = 'PhantomJS';
16146 version = (data = data.version || null) && (data.major + '.' + data.minor + '.' + data.patch);
16147 }
16148 // Detect IE compatibility modes.
16149 else if (typeof doc.documentMode == 'number' && (data = /\bTrident\/(\d+)/i.exec(ua))) {
16150 // We're in compatibility mode when the Trident version + 4 doesn't
16151 // equal the document mode.
16152 version = [version, doc.documentMode];
16153 if ((data = +data[1] + 4) != version[1]) {
16154 description.push('IE ' + version[1] + ' mode');
16155 layout && (layout[1] = '');
16156 version[1] = data;
16157 }
16158 version = name == 'IE' ? String(version[1].toFixed(1)) : version[0];
16159 }
16160 // Detect IE 11 masking as other browsers.
16161 else if (typeof doc.documentMode == 'number' && /^(?:Chrome|Firefox)\b/.test(name)) {
16162 description.push('masking as ' + name + ' ' + version);
16163 name = 'IE';
16164 version = '11.0';
16165 layout = ['Trident'];
16166 os = 'Windows';
16167 }
16168 os = os && format(os);
16169 }
16170 // Detect prerelease phases.
16171 if (version && (data =
16172 /(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(version) ||
16173 /(?:alpha|beta)(?: ?\d)?/i.exec(ua + ';' + (useFeatures && nav.appMinorVersion)) ||
16174 /\bMinefield\b/i.test(ua) && 'a'
16175 )) {
16176 prerelease = /b/i.test(data) ? 'beta' : 'alpha';
16177 version = version.replace(RegExp(data + '\\+?$'), '') +
16178 (prerelease == 'beta' ? beta : alpha) + (/\d+\+?/.exec(data) || '');
16179 }
16180 // Detect Firefox Mobile.
16181 if (name == 'Fennec' || name == 'Firefox' && /\b(?:Android|Firefox OS)\b/.test(os)) {
16182 name = 'Firefox Mobile';
16183 }
16184 // Obscure Maxthon's unreliable version.
16185 else if (name == 'Maxthon' && version) {
16186 version = version.replace(/\.[\d.]+/, '.x');
16187 }
16188 // Detect Xbox 360 and Xbox One.
16189 else if (/\bXbox\b/i.test(product)) {
16190 if (product == 'Xbox 360') {
16191 os = null;
16192 }
16193 if (product == 'Xbox 360' && /\bIEMobile\b/.test(ua)) {
16194 description.unshift('mobile mode');
16195 }
16196 }
16197 // Add mobile postfix.
16198 else if ((/^(?:Chrome|IE|Opera)$/.test(name) || name && !product && !/Browser|Mobi/.test(name)) &&
16199 (os == 'Windows CE' || /Mobi/i.test(ua))) {
16200 name += ' Mobile';
16201 }
16202 // Detect IE platform preview.
16203 else if (name == 'IE' && useFeatures) {
16204 try {
16205 if (context.external === null) {
16206 description.unshift('platform preview');
16207 }
16208 } catch(e) {
16209 description.unshift('embedded');
16210 }
16211 }
16212 // Detect BlackBerry OS version.
16213 // http://docs.blackberry.com/en/developers/deliverables/18169/HTTP_headers_sent_by_BB_Browser_1234911_11.jsp
16214 else if ((/\bBlackBerry\b/.test(product) || /\bBB10\b/.test(ua)) && (data =
16215 (RegExp(product.replace(/ +/g, ' *') + '/([.\\d]+)', 'i').exec(ua) || 0)[1] ||
16216 version
16217 )) {
16218 data = [data, /BB10/.test(ua)];
16219 os = (data[1] ? (product = null, manufacturer = 'BlackBerry') : 'Device Software') + ' ' + data[0];
16220 version = null;
16221 }
16222 // Detect Opera identifying/masking itself as another browser.
16223 // http://www.opera.com/support/kb/view/843/
16224 else if (this != forOwn && product != 'Wii' && (
16225 (useFeatures && opera) ||
16226 (/Opera/.test(name) && /\b(?:MSIE|Firefox)\b/i.test(ua)) ||
16227 (name == 'Firefox' && /\bOS X (?:\d+\.){2,}/.test(os)) ||
16228 (name == 'IE' && (
16229 (os && !/^Win/.test(os) && version > 5.5) ||
16230 /\bWindows XP\b/.test(os) && version > 8 ||
16231 version == 8 && !/\bTrident\b/.test(ua)
16232 ))
16233 ) && !reOpera.test((data = parse.call(forOwn, ua.replace(reOpera, '') + ';'))) && data.name) {
16234 // When "identifying", the UA contains both Opera and the other browser's name.
16235 data = 'ing as ' + data.name + ((data = data.version) ? ' ' + data : '');
16236 if (reOpera.test(name)) {
16237 if (/\bIE\b/.test(data) && os == 'Mac OS') {
16238 os = null;
16239 }
16240 data = 'identify' + data;
16241 }
16242 // When "masking", the UA contains only the other browser's name.
16243 else {
16244 data = 'mask' + data;
16245 if (operaClass) {
16246 name = format(operaClass.replace(/([a-z])([A-Z])/g, '$1 $2'));
16247 } else {
16248 name = 'Opera';
16249 }
16250 if (/\bIE\b/.test(data)) {
16251 os = null;
16252 }
16253 if (!useFeatures) {
16254 version = null;
16255 }
16256 }
16257 layout = ['Presto'];
16258 description.push(data);
16259 }
16260 // Detect WebKit Nightly and approximate Chrome/Safari versions.
16261 if ((data = (/\bAppleWebKit\/([\d.]+\+?)/i.exec(ua) || 0)[1])) {
16262 // Correct build number for numeric comparison.
16263 // (e.g. "532.5" becomes "532.05")
16264 data = [parseFloat(data.replace(/\.(\d)$/, '.0$1')), data];
16265 // Nightly builds are postfixed with a "+".
16266 if (name == 'Safari' && data[1].slice(-1) == '+') {
16267 name = 'WebKit Nightly';
16268 prerelease = 'alpha';
16269 version = data[1].slice(0, -1);
16270 }
16271 // Clear incorrect browser versions.
16272 else if (version == data[1] ||
16273 version == (data[2] = (/\bSafari\/([\d.]+\+?)/i.exec(ua) || 0)[1])) {
16274 version = null;
16275 }
16276 // Use the full Chrome version when available.
16277 data[1] = (/\bChrome\/([\d.]+)/i.exec(ua) || 0)[1];
16278 // Detect Blink layout engine.
16279 if (data[0] == 537.36 && data[2] == 537.36 && parseFloat(data[1]) >= 28 && layout == 'WebKit') {
16280 layout = ['Blink'];
16281 }
16282 // Detect JavaScriptCore.
16283 // http://stackoverflow.com/questions/6768474/how-can-i-detect-which-javascript-engine-v8-or-jsc-is-used-at-runtime-in-androi
16284 if (!useFeatures || (!likeChrome && !data[1])) {
16285 layout && (layout[1] = 'like Safari');
16286 data = (data = data[0], data < 400 ? 1 : data < 500 ? 2 : data < 526 ? 3 : data < 533 ? 4 : data < 534 ? '4+' : data < 535 ? 5 : data < 537 ? 6 : data < 538 ? 7 : data < 601 ? 8 : '8');
16287 } else {
16288 layout && (layout[1] = 'like Chrome');
16289 data = data[1] || (data = data[0], data < 530 ? 1 : data < 532 ? 2 : data < 532.05 ? 3 : data < 533 ? 4 : data < 534.03 ? 5 : data < 534.07 ? 6 : data < 534.10 ? 7 : data < 534.13 ? 8 : data < 534.16 ? 9 : data < 534.24 ? 10 : data < 534.30 ? 11 : data < 535.01 ? 12 : data < 535.02 ? '13+' : data < 535.07 ? 15 : data < 535.11 ? 16 : data < 535.19 ? 17 : data < 536.05 ? 18 : data < 536.10 ? 19 : data < 537.01 ? 20 : data < 537.11 ? '21+' : data < 537.13 ? 23 : data < 537.18 ? 24 : data < 537.24 ? 25 : data < 537.36 ? 26 : layout != 'Blink' ? '27' : '28');
16290 }
16291 // Add the postfix of ".x" or "+" for approximate versions.
16292 layout && (layout[1] += ' ' + (data += typeof data == 'number' ? '.x' : /[.+]/.test(data) ? '' : '+'));
16293 // Obscure version for some Safari 1-2 releases.
16294 if (name == 'Safari' && (!version || parseInt(version) > 45)) {
16295 version = data;
16296 }
16297 }
16298 // Detect Opera desktop modes.
16299 if (name == 'Opera' && (data = /\bzbov|zvav$/.exec(os))) {
16300 name += ' ';
16301 description.unshift('desktop mode');
16302 if (data == 'zvav') {
16303 name += 'Mini';
16304 version = null;
16305 } else {
16306 name += 'Mobile';
16307 }
16308 os = os.replace(RegExp(' *' + data + '$'), '');
16309 }
16310 // Detect Chrome desktop mode.
16311 else if (name == 'Safari' && /\bChrome\b/.exec(layout && layout[1])) {
16312 description.unshift('desktop mode');
16313 name = 'Chrome Mobile';
16314 version = null;
16315
16316 if (/\bOS X\b/.test(os)) {
16317 manufacturer = 'Apple';
16318 os = 'iOS 4.3+';
16319 } else {
16320 os = null;
16321 }
16322 }
16323 // Strip incorrect OS versions.
16324 if (version && version.indexOf((data = /[\d.]+$/.exec(os))) == 0 &&
16325 ua.indexOf('/' + data + '-') > -1) {
16326 os = trim(os.replace(data, ''));
16327 }
16328 // Add layout engine.
16329 if (layout && !/\b(?:Avant|Nook)\b/.test(name) && (
16330 /Browser|Lunascape|Maxthon/.test(name) ||
16331 name != 'Safari' && /^iOS/.test(os) && /\bSafari\b/.test(layout[1]) ||
16332 /^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|Web)/.test(name) && layout[1])) {
16333 // Don't add layout details to description if they are falsey.
16334 (data = layout[layout.length - 1]) && description.push(data);
16335 }
16336 // Combine contextual information.
16337 if (description.length) {
16338 description = ['(' + description.join('; ') + ')'];
16339 }
16340 // Append manufacturer to description.
16341 if (manufacturer && product && product.indexOf(manufacturer) < 0) {
16342 description.push('on ' + manufacturer);
16343 }
16344 // Append product to description.
16345 if (product) {
16346 description.push((/^on /.test(description[description.length - 1]) ? '' : 'on ') + product);
16347 }
16348 // Parse the OS into an object.
16349 if (os) {
16350 data = / ([\d.+]+)$/.exec(os);
16351 isSpecialCasedOS = data && os.charAt(os.length - data[0].length - 1) == '/';
16352 os = {
16353 'architecture': 32,
16354 'family': (data && !isSpecialCasedOS) ? os.replace(data[0], '') : os,
16355 'version': data ? data[1] : null,
16356 'toString': function() {
16357 var version = this.version;
16358 return this.family + ((version && !isSpecialCasedOS) ? ' ' + version : '') + (this.architecture == 64 ? ' 64-bit' : '');
16359 }
16360 };
16361 }
16362 // Add browser/OS architecture.
16363 if ((data = /\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(arch)) && !/\bi686\b/i.test(arch)) {
16364 if (os) {
16365 os.architecture = 64;
16366 os.family = os.family.replace(RegExp(' *' + data), '');
16367 }
16368 if (
16369 name && (/\bWOW64\b/i.test(ua) ||
16370 (useFeatures && /\w(?:86|32)$/.test(nav.cpuClass || nav.platform) && !/\bWin64; x64\b/i.test(ua)))
16371 ) {
16372 description.unshift('32-bit');
16373 }
16374 }
16375 // Chrome 39 and above on OS X is always 64-bit.
16376 else if (
16377 os && /^OS X/.test(os.family) &&
16378 name == 'Chrome' && parseFloat(version) >= 39
16379 ) {
16380 os.architecture = 64;
16381 }
16382
16383 ua || (ua = null);
16384
16385 /*------------------------------------------------------------------------*/
16386
16387 /**
16388 * The platform object.
16389 *
16390 * @name platform
16391 * @type Object
16392 */
16393 var platform = {};
16394
16395 /**
16396 * The platform description.
16397 *
16398 * @memberOf platform
16399 * @type string|null
16400 */
16401 platform.description = ua;
16402
16403 /**
16404 * The name of the browser's layout engine.
16405 *
16406 * The list of common layout engines include:
16407 * "Blink", "EdgeHTML", "Gecko", "Trident" and "WebKit"
16408 *
16409 * @memberOf platform
16410 * @type string|null
16411 */
16412 platform.layout = layout && layout[0];
16413
16414 /**
16415 * The name of the product's manufacturer.
16416 *
16417 * The list of manufacturers include:
16418 * "Apple", "Archos", "Amazon", "Asus", "Barnes & Noble", "BlackBerry",
16419 * "Google", "HP", "HTC", "LG", "Microsoft", "Motorola", "Nintendo",
16420 * "Nokia", "Samsung" and "Sony"
16421 *
16422 * @memberOf platform
16423 * @type string|null
16424 */
16425 platform.manufacturer = manufacturer;
16426
16427 /**
16428 * The name of the browser/environment.
16429 *
16430 * The list of common browser names include:
16431 * "Chrome", "Electron", "Firefox", "Firefox for iOS", "IE",
16432 * "Microsoft Edge", "PhantomJS", "Safari", "SeaMonkey", "Silk",
16433 * "Opera Mini" and "Opera"
16434 *
16435 * Mobile versions of some browsers have "Mobile" appended to their name:
16436 * eg. "Chrome Mobile", "Firefox Mobile", "IE Mobile" and "Opera Mobile"
16437 *
16438 * @memberOf platform
16439 * @type string|null
16440 */
16441 platform.name = name;
16442
16443 /**
16444 * The alpha/beta release indicator.
16445 *
16446 * @memberOf platform
16447 * @type string|null
16448 */
16449 platform.prerelease = prerelease;
16450
16451 /**
16452 * The name of the product hosting the browser.
16453 *
16454 * The list of common products include:
16455 *
16456 * "BlackBerry", "Galaxy S4", "Lumia", "iPad", "iPod", "iPhone", "Kindle",
16457 * "Kindle Fire", "Nexus", "Nook", "PlayBook", "TouchPad" and "Transformer"
16458 *
16459 * @memberOf platform
16460 * @type string|null
16461 */
16462 platform.product = product;
16463
16464 /**
16465 * The browser's user agent string.
16466 *
16467 * @memberOf platform
16468 * @type string|null
16469 */
16470 platform.ua = ua;
16471
16472 /**
16473 * The browser/environment version.
16474 *
16475 * @memberOf platform
16476 * @type string|null
16477 */
16478 platform.version = name && version;
16479
16480 /**
16481 * The name of the operating system.
16482 *
16483 * @memberOf platform
16484 * @type Object
16485 */
16486 platform.os = os || {
16487
16488 /**
16489 * The CPU architecture the OS is built for.
16490 *
16491 * @memberOf platform.os
16492 * @type number|null
16493 */
16494 'architecture': null,
16495
16496 /**
16497 * The family of the OS.
16498 *
16499 * Common values include:
16500 * "Windows", "Windows Server 2008 R2 / 7", "Windows Server 2008 / Vista",
16501 * "Windows XP", "OS X", "Ubuntu", "Debian", "Fedora", "Red Hat", "SuSE",
16502 * "Android", "iOS" and "Windows Phone"
16503 *
16504 * @memberOf platform.os
16505 * @type string|null
16506 */
16507 'family': null,
16508
16509 /**
16510 * The version of the OS.
16511 *
16512 * @memberOf platform.os
16513 * @type string|null
16514 */
16515 'version': null,
16516
16517 /**
16518 * Returns the OS string.
16519 *
16520 * @memberOf platform.os
16521 * @returns {string} The OS string.
16522 */
16523 'toString': function() { return 'null'; }
16524 };
16525
16526 platform.parse = parse;
16527 platform.toString = toStringPlatform;
16528
16529 if (platform.version) {
16530 description.unshift(version);
16531 }
16532 if (platform.name) {
16533 description.unshift(name);
16534 }
16535 if (os && name && !(os == String(os).split(' ')[0] && (os == name.split(' ')[0] || product))) {
16536 description.push(product ? '(' + os + ')' : 'on ' + os);
16537 }
16538 if (description.length) {
16539 platform.description = description.join(' ');
16540 }
16541 return platform;
16542 }
16543
16544 /*--------------------------------------------------------------------------*/
16545
16546 // Export platform.
16547 var platform = parse();
16548
16549 // Some AMD build optimizers, like r.js, check for condition patterns like the following:
16550 if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
16551 // Expose platform on the global object to prevent errors when platform is
16552 // loaded by a script tag in the presence of an AMD loader.
16553 // See http://requirejs.org/docs/errors.html#mismatch for more details.
16554 root.platform = platform;
16555
16556 // Define as an anonymous module so platform can be aliased through path mapping.
16557 define(function() {
16558 return platform;
16559 });
16560 }
16561 // Check for `exports` after `define` in case a build optimizer adds an `exports` object.
16562 else if (freeExports && freeModule) {
16563 // Export for CommonJS support.
16564 forOwn(platform, function(value, key) {
16565 freeExports[key] = value;
16566 });
16567 }
16568 else {
16569 // Export to the global object.
16570 root.platform = platform;
16571 }
16572}.call(this));
16573
16574}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
16575},{}],248:[function(require,module,exports){
16576(function (process){
16577'use strict';
16578
16579if (!process.version ||
16580 process.version.indexOf('v0.') === 0 ||
16581 process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
16582 module.exports = { nextTick: nextTick };
16583} else {
16584 module.exports = process
16585}
16586
16587function nextTick(fn, arg1, arg2, arg3) {
16588 if (typeof fn !== 'function') {
16589 throw new TypeError('"callback" argument must be a function');
16590 }
16591 var len = arguments.length;
16592 var args, i;
16593 switch (len) {
16594 case 0:
16595 case 1:
16596 return process.nextTick(fn);
16597 case 2:
16598 return process.nextTick(function afterTickOne() {
16599 fn.call(null, arg1);
16600 });
16601 case 3:
16602 return process.nextTick(function afterTickTwo() {
16603 fn.call(null, arg1, arg2);
16604 });
16605 case 4:
16606 return process.nextTick(function afterTickThree() {
16607 fn.call(null, arg1, arg2, arg3);
16608 });
16609 default:
16610 args = new Array(len - 1);
16611 i = 0;
16612 while (i < args.length) {
16613 args[i++] = arguments[i];
16614 }
16615 return process.nextTick(function afterTick() {
16616 fn.apply(null, args);
16617 });
16618 }
16619}
16620
16621
16622}).call(this,require('_process'))
16623},{"_process":249}],249:[function(require,module,exports){
16624// shim for using process in browser
16625var process = module.exports = {};
16626
16627// cached from whatever global is present so that test runners that stub it
16628// don't break things. But we need to wrap it in a try catch in case it is
16629// wrapped in strict mode code which doesn't define any globals. It's inside a
16630// function because try/catches deoptimize in certain engines.
16631
16632var cachedSetTimeout;
16633var cachedClearTimeout;
16634
16635function defaultSetTimout() {
16636 throw new Error('setTimeout has not been defined');
16637}
16638function defaultClearTimeout () {
16639 throw new Error('clearTimeout has not been defined');
16640}
16641(function () {
16642 try {
16643 if (typeof setTimeout === 'function') {
16644 cachedSetTimeout = setTimeout;
16645 } else {
16646 cachedSetTimeout = defaultSetTimout;
16647 }
16648 } catch (e) {
16649 cachedSetTimeout = defaultSetTimout;
16650 }
16651 try {
16652 if (typeof clearTimeout === 'function') {
16653 cachedClearTimeout = clearTimeout;
16654 } else {
16655 cachedClearTimeout = defaultClearTimeout;
16656 }
16657 } catch (e) {
16658 cachedClearTimeout = defaultClearTimeout;
16659 }
16660} ())
16661function runTimeout(fun) {
16662 if (cachedSetTimeout === setTimeout) {
16663 //normal enviroments in sane situations
16664 return setTimeout(fun, 0);
16665 }
16666 // if setTimeout wasn't available but was latter defined
16667 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
16668 cachedSetTimeout = setTimeout;
16669 return setTimeout(fun, 0);
16670 }
16671 try {
16672 // when when somebody has screwed with setTimeout but no I.E. maddness
16673 return cachedSetTimeout(fun, 0);
16674 } catch(e){
16675 try {
16676 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
16677 return cachedSetTimeout.call(null, fun, 0);
16678 } catch(e){
16679 // 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
16680 return cachedSetTimeout.call(this, fun, 0);
16681 }
16682 }
16683
16684
16685}
16686function runClearTimeout(marker) {
16687 if (cachedClearTimeout === clearTimeout) {
16688 //normal enviroments in sane situations
16689 return clearTimeout(marker);
16690 }
16691 // if clearTimeout wasn't available but was latter defined
16692 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
16693 cachedClearTimeout = clearTimeout;
16694 return clearTimeout(marker);
16695 }
16696 try {
16697 // when when somebody has screwed with setTimeout but no I.E. maddness
16698 return cachedClearTimeout(marker);
16699 } catch (e){
16700 try {
16701 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
16702 return cachedClearTimeout.call(null, marker);
16703 } catch (e){
16704 // 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.
16705 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
16706 return cachedClearTimeout.call(this, marker);
16707 }
16708 }
16709
16710
16711
16712}
16713var queue = [];
16714var draining = false;
16715var currentQueue;
16716var queueIndex = -1;
16717
16718function cleanUpNextTick() {
16719 if (!draining || !currentQueue) {
16720 return;
16721 }
16722 draining = false;
16723 if (currentQueue.length) {
16724 queue = currentQueue.concat(queue);
16725 } else {
16726 queueIndex = -1;
16727 }
16728 if (queue.length) {
16729 drainQueue();
16730 }
16731}
16732
16733function drainQueue() {
16734 if (draining) {
16735 return;
16736 }
16737 var timeout = runTimeout(cleanUpNextTick);
16738 draining = true;
16739
16740 var len = queue.length;
16741 while(len) {
16742 currentQueue = queue;
16743 queue = [];
16744 while (++queueIndex < len) {
16745 if (currentQueue) {
16746 currentQueue[queueIndex].run();
16747 }
16748 }
16749 queueIndex = -1;
16750 len = queue.length;
16751 }
16752 currentQueue = null;
16753 draining = false;
16754 runClearTimeout(timeout);
16755}
16756
16757process.nextTick = function (fun) {
16758 var args = new Array(arguments.length - 1);
16759 if (arguments.length > 1) {
16760 for (var i = 1; i < arguments.length; i++) {
16761 args[i - 1] = arguments[i];
16762 }
16763 }
16764 queue.push(new Item(fun, args));
16765 if (queue.length === 1 && !draining) {
16766 runTimeout(drainQueue);
16767 }
16768};
16769
16770// v8 likes predictible objects
16771function Item(fun, array) {
16772 this.fun = fun;
16773 this.array = array;
16774}
16775Item.prototype.run = function () {
16776 this.fun.apply(null, this.array);
16777};
16778process.title = 'browser';
16779process.browser = true;
16780process.env = {};
16781process.argv = [];
16782process.version = ''; // empty string to avoid regexp issues
16783process.versions = {};
16784
16785function noop() {}
16786
16787process.on = noop;
16788process.addListener = noop;
16789process.once = noop;
16790process.off = noop;
16791process.removeListener = noop;
16792process.removeAllListeners = noop;
16793process.emit = noop;
16794process.prependListener = noop;
16795process.prependOnceListener = noop;
16796
16797process.listeners = function (name) { return [] }
16798
16799process.binding = function (name) {
16800 throw new Error('process.binding is not supported');
16801};
16802
16803process.cwd = function () { return '/' };
16804process.chdir = function (dir) {
16805 throw new Error('process.chdir is not supported');
16806};
16807process.umask = function() { return 0; };
16808
16809},{}],250:[function(require,module,exports){
16810(function (global){
16811/*! https://mths.be/punycode v1.4.1 by @mathias */
16812;(function(root) {
16813
16814 /** Detect free variables */
16815 var freeExports = typeof exports == 'object' && exports &&
16816 !exports.nodeType && exports;
16817 var freeModule = typeof module == 'object' && module &&
16818 !module.nodeType && module;
16819 var freeGlobal = typeof global == 'object' && global;
16820 if (
16821 freeGlobal.global === freeGlobal ||
16822 freeGlobal.window === freeGlobal ||
16823 freeGlobal.self === freeGlobal
16824 ) {
16825 root = freeGlobal;
16826 }
16827
16828 /**
16829 * The `punycode` object.
16830 * @name punycode
16831 * @type Object
16832 */
16833 var punycode,
16834
16835 /** Highest positive signed 32-bit float value */
16836 maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
16837
16838 /** Bootstring parameters */
16839 base = 36,
16840 tMin = 1,
16841 tMax = 26,
16842 skew = 38,
16843 damp = 700,
16844 initialBias = 72,
16845 initialN = 128, // 0x80
16846 delimiter = '-', // '\x2D'
16847
16848 /** Regular expressions */
16849 regexPunycode = /^xn--/,
16850 regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
16851 regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
16852
16853 /** Error messages */
16854 errors = {
16855 'overflow': 'Overflow: input needs wider integers to process',
16856 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
16857 'invalid-input': 'Invalid input'
16858 },
16859
16860 /** Convenience shortcuts */
16861 baseMinusTMin = base - tMin,
16862 floor = Math.floor,
16863 stringFromCharCode = String.fromCharCode,
16864
16865 /** Temporary variable */
16866 key;
16867
16868 /*--------------------------------------------------------------------------*/
16869
16870 /**
16871 * A generic error utility function.
16872 * @private
16873 * @param {String} type The error type.
16874 * @returns {Error} Throws a `RangeError` with the applicable error message.
16875 */
16876 function error(type) {
16877 throw new RangeError(errors[type]);
16878 }
16879
16880 /**
16881 * A generic `Array#map` utility function.
16882 * @private
16883 * @param {Array} array The array to iterate over.
16884 * @param {Function} callback The function that gets called for every array
16885 * item.
16886 * @returns {Array} A new array of values returned by the callback function.
16887 */
16888 function map(array, fn) {
16889 var length = array.length;
16890 var result = [];
16891 while (length--) {
16892 result[length] = fn(array[length]);
16893 }
16894 return result;
16895 }
16896
16897 /**
16898 * A simple `Array#map`-like wrapper to work with domain name strings or email
16899 * addresses.
16900 * @private
16901 * @param {String} domain The domain name or email address.
16902 * @param {Function} callback The function that gets called for every
16903 * character.
16904 * @returns {Array} A new string of characters returned by the callback
16905 * function.
16906 */
16907 function mapDomain(string, fn) {
16908 var parts = string.split('@');
16909 var result = '';
16910 if (parts.length > 1) {
16911 // In email addresses, only the domain name should be punycoded. Leave
16912 // the local part (i.e. everything up to `@`) intact.
16913 result = parts[0] + '@';
16914 string = parts[1];
16915 }
16916 // Avoid `split(regex)` for IE8 compatibility. See #17.
16917 string = string.replace(regexSeparators, '\x2E');
16918 var labels = string.split('.');
16919 var encoded = map(labels, fn).join('.');
16920 return result + encoded;
16921 }
16922
16923 /**
16924 * Creates an array containing the numeric code points of each Unicode
16925 * character in the string. While JavaScript uses UCS-2 internally,
16926 * this function will convert a pair of surrogate halves (each of which
16927 * UCS-2 exposes as separate characters) into a single code point,
16928 * matching UTF-16.
16929 * @see `punycode.ucs2.encode`
16930 * @see <https://mathiasbynens.be/notes/javascript-encoding>
16931 * @memberOf punycode.ucs2
16932 * @name decode
16933 * @param {String} string The Unicode input string (UCS-2).
16934 * @returns {Array} The new array of code points.
16935 */
16936 function ucs2decode(string) {
16937 var output = [],
16938 counter = 0,
16939 length = string.length,
16940 value,
16941 extra;
16942 while (counter < length) {
16943 value = string.charCodeAt(counter++);
16944 if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
16945 // high surrogate, and there is a next character
16946 extra = string.charCodeAt(counter++);
16947 if ((extra & 0xFC00) == 0xDC00) { // low surrogate
16948 output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
16949 } else {
16950 // unmatched surrogate; only append this code unit, in case the next
16951 // code unit is the high surrogate of a surrogate pair
16952 output.push(value);
16953 counter--;
16954 }
16955 } else {
16956 output.push(value);
16957 }
16958 }
16959 return output;
16960 }
16961
16962 /**
16963 * Creates a string based on an array of numeric code points.
16964 * @see `punycode.ucs2.decode`
16965 * @memberOf punycode.ucs2
16966 * @name encode
16967 * @param {Array} codePoints The array of numeric code points.
16968 * @returns {String} The new Unicode string (UCS-2).
16969 */
16970 function ucs2encode(array) {
16971 return map(array, function(value) {
16972 var output = '';
16973 if (value > 0xFFFF) {
16974 value -= 0x10000;
16975 output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
16976 value = 0xDC00 | value & 0x3FF;
16977 }
16978 output += stringFromCharCode(value);
16979 return output;
16980 }).join('');
16981 }
16982
16983 /**
16984 * Converts a basic code point into a digit/integer.
16985 * @see `digitToBasic()`
16986 * @private
16987 * @param {Number} codePoint The basic numeric code point value.
16988 * @returns {Number} The numeric value of a basic code point (for use in
16989 * representing integers) in the range `0` to `base - 1`, or `base` if
16990 * the code point does not represent a value.
16991 */
16992 function basicToDigit(codePoint) {
16993 if (codePoint - 48 < 10) {
16994 return codePoint - 22;
16995 }
16996 if (codePoint - 65 < 26) {
16997 return codePoint - 65;
16998 }
16999 if (codePoint - 97 < 26) {
17000 return codePoint - 97;
17001 }
17002 return base;
17003 }
17004
17005 /**
17006 * Converts a digit/integer into a basic code point.
17007 * @see `basicToDigit()`
17008 * @private
17009 * @param {Number} digit The numeric value of a basic code point.
17010 * @returns {Number} The basic code point whose value (when used for
17011 * representing integers) is `digit`, which needs to be in the range
17012 * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
17013 * used; else, the lowercase form is used. The behavior is undefined
17014 * if `flag` is non-zero and `digit` has no uppercase form.
17015 */
17016 function digitToBasic(digit, flag) {
17017 // 0..25 map to ASCII a..z or A..Z
17018 // 26..35 map to ASCII 0..9
17019 return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
17020 }
17021
17022 /**
17023 * Bias adaptation function as per section 3.4 of RFC 3492.
17024 * https://tools.ietf.org/html/rfc3492#section-3.4
17025 * @private
17026 */
17027 function adapt(delta, numPoints, firstTime) {
17028 var k = 0;
17029 delta = firstTime ? floor(delta / damp) : delta >> 1;
17030 delta += floor(delta / numPoints);
17031 for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
17032 delta = floor(delta / baseMinusTMin);
17033 }
17034 return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
17035 }
17036
17037 /**
17038 * Converts a Punycode string of ASCII-only symbols to a string of Unicode
17039 * symbols.
17040 * @memberOf punycode
17041 * @param {String} input The Punycode string of ASCII-only symbols.
17042 * @returns {String} The resulting string of Unicode symbols.
17043 */
17044 function decode(input) {
17045 // Don't use UCS-2
17046 var output = [],
17047 inputLength = input.length,
17048 out,
17049 i = 0,
17050 n = initialN,
17051 bias = initialBias,
17052 basic,
17053 j,
17054 index,
17055 oldi,
17056 w,
17057 k,
17058 digit,
17059 t,
17060 /** Cached calculation results */
17061 baseMinusT;
17062
17063 // Handle the basic code points: let `basic` be the number of input code
17064 // points before the last delimiter, or `0` if there is none, then copy
17065 // the first basic code points to the output.
17066
17067 basic = input.lastIndexOf(delimiter);
17068 if (basic < 0) {
17069 basic = 0;
17070 }
17071
17072 for (j = 0; j < basic; ++j) {
17073 // if it's not a basic code point
17074 if (input.charCodeAt(j) >= 0x80) {
17075 error('not-basic');
17076 }
17077 output.push(input.charCodeAt(j));
17078 }
17079
17080 // Main decoding loop: start just after the last delimiter if any basic code
17081 // points were copied; start at the beginning otherwise.
17082
17083 for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
17084
17085 // `index` is the index of the next character to be consumed.
17086 // Decode a generalized variable-length integer into `delta`,
17087 // which gets added to `i`. The overflow checking is easier
17088 // if we increase `i` as we go, then subtract off its starting
17089 // value at the end to obtain `delta`.
17090 for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
17091
17092 if (index >= inputLength) {
17093 error('invalid-input');
17094 }
17095
17096 digit = basicToDigit(input.charCodeAt(index++));
17097
17098 if (digit >= base || digit > floor((maxInt - i) / w)) {
17099 error('overflow');
17100 }
17101
17102 i += digit * w;
17103 t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
17104
17105 if (digit < t) {
17106 break;
17107 }
17108
17109 baseMinusT = base - t;
17110 if (w > floor(maxInt / baseMinusT)) {
17111 error('overflow');
17112 }
17113
17114 w *= baseMinusT;
17115
17116 }
17117
17118 out = output.length + 1;
17119 bias = adapt(i - oldi, out, oldi == 0);
17120
17121 // `i` was supposed to wrap around from `out` to `0`,
17122 // incrementing `n` each time, so we'll fix that now:
17123 if (floor(i / out) > maxInt - n) {
17124 error('overflow');
17125 }
17126
17127 n += floor(i / out);
17128 i %= out;
17129
17130 // Insert `n` at position `i` of the output
17131 output.splice(i++, 0, n);
17132
17133 }
17134
17135 return ucs2encode(output);
17136 }
17137
17138 /**
17139 * Converts a string of Unicode symbols (e.g. a domain name label) to a
17140 * Punycode string of ASCII-only symbols.
17141 * @memberOf punycode
17142 * @param {String} input The string of Unicode symbols.
17143 * @returns {String} The resulting Punycode string of ASCII-only symbols.
17144 */
17145 function encode(input) {
17146 var n,
17147 delta,
17148 handledCPCount,
17149 basicLength,
17150 bias,
17151 j,
17152 m,
17153 q,
17154 k,
17155 t,
17156 currentValue,
17157 output = [],
17158 /** `inputLength` will hold the number of code points in `input`. */
17159 inputLength,
17160 /** Cached calculation results */
17161 handledCPCountPlusOne,
17162 baseMinusT,
17163 qMinusT;
17164
17165 // Convert the input in UCS-2 to Unicode
17166 input = ucs2decode(input);
17167
17168 // Cache the length
17169 inputLength = input.length;
17170
17171 // Initialize the state
17172 n = initialN;
17173 delta = 0;
17174 bias = initialBias;
17175
17176 // Handle the basic code points
17177 for (j = 0; j < inputLength; ++j) {
17178 currentValue = input[j];
17179 if (currentValue < 0x80) {
17180 output.push(stringFromCharCode(currentValue));
17181 }
17182 }
17183
17184 handledCPCount = basicLength = output.length;
17185
17186 // `handledCPCount` is the number of code points that have been handled;
17187 // `basicLength` is the number of basic code points.
17188
17189 // Finish the basic string - if it is not empty - with a delimiter
17190 if (basicLength) {
17191 output.push(delimiter);
17192 }
17193
17194 // Main encoding loop:
17195 while (handledCPCount < inputLength) {
17196
17197 // All non-basic code points < n have been handled already. Find the next
17198 // larger one:
17199 for (m = maxInt, j = 0; j < inputLength; ++j) {
17200 currentValue = input[j];
17201 if (currentValue >= n && currentValue < m) {
17202 m = currentValue;
17203 }
17204 }
17205
17206 // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
17207 // but guard against overflow
17208 handledCPCountPlusOne = handledCPCount + 1;
17209 if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
17210 error('overflow');
17211 }
17212
17213 delta += (m - n) * handledCPCountPlusOne;
17214 n = m;
17215
17216 for (j = 0; j < inputLength; ++j) {
17217 currentValue = input[j];
17218
17219 if (currentValue < n && ++delta > maxInt) {
17220 error('overflow');
17221 }
17222
17223 if (currentValue == n) {
17224 // Represent delta as a generalized variable-length integer
17225 for (q = delta, k = base; /* no condition */; k += base) {
17226 t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
17227 if (q < t) {
17228 break;
17229 }
17230 qMinusT = q - t;
17231 baseMinusT = base - t;
17232 output.push(
17233 stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
17234 );
17235 q = floor(qMinusT / baseMinusT);
17236 }
17237
17238 output.push(stringFromCharCode(digitToBasic(q, 0)));
17239 bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
17240 delta = 0;
17241 ++handledCPCount;
17242 }
17243 }
17244
17245 ++delta;
17246 ++n;
17247
17248 }
17249 return output.join('');
17250 }
17251
17252 /**
17253 * Converts a Punycode string representing a domain name or an email address
17254 * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
17255 * it doesn't matter if you call it on a string that has already been
17256 * converted to Unicode.
17257 * @memberOf punycode
17258 * @param {String} input The Punycoded domain name or email address to
17259 * convert to Unicode.
17260 * @returns {String} The Unicode representation of the given Punycode
17261 * string.
17262 */
17263 function toUnicode(input) {
17264 return mapDomain(input, function(string) {
17265 return regexPunycode.test(string)
17266 ? decode(string.slice(4).toLowerCase())
17267 : string;
17268 });
17269 }
17270
17271 /**
17272 * Converts a Unicode string representing a domain name or an email address to
17273 * Punycode. Only the non-ASCII parts of the domain name will be converted,
17274 * i.e. it doesn't matter if you call it with a domain that's already in
17275 * ASCII.
17276 * @memberOf punycode
17277 * @param {String} input The domain name or email address to convert, as a
17278 * Unicode string.
17279 * @returns {String} The Punycode representation of the given domain name or
17280 * email address.
17281 */
17282 function toASCII(input) {
17283 return mapDomain(input, function(string) {
17284 return regexNonASCII.test(string)
17285 ? 'xn--' + encode(string)
17286 : string;
17287 });
17288 }
17289
17290 /*--------------------------------------------------------------------------*/
17291
17292 /** Define the public API */
17293 punycode = {
17294 /**
17295 * A string representing the current Punycode.js version number.
17296 * @memberOf punycode
17297 * @type String
17298 */
17299 'version': '1.4.1',
17300 /**
17301 * An object of methods to convert from JavaScript's internal character
17302 * representation (UCS-2) to Unicode code points, and back.
17303 * @see <https://mathiasbynens.be/notes/javascript-encoding>
17304 * @memberOf punycode
17305 * @type Object
17306 */
17307 'ucs2': {
17308 'decode': ucs2decode,
17309 'encode': ucs2encode
17310 },
17311 'decode': decode,
17312 'encode': encode,
17313 'toASCII': toASCII,
17314 'toUnicode': toUnicode
17315 };
17316
17317 /** Expose `punycode` */
17318 // Some AMD build optimizers, like r.js, check for specific condition patterns
17319 // like the following:
17320 if (
17321 typeof define == 'function' &&
17322 typeof define.amd == 'object' &&
17323 define.amd
17324 ) {
17325 define('punycode', function() {
17326 return punycode;
17327 });
17328 } else if (freeExports && freeModule) {
17329 if (module.exports == freeExports) {
17330 // in Node.js, io.js, or RingoJS v0.8.0+
17331 freeModule.exports = punycode;
17332 } else {
17333 // in Narwhal or RingoJS v0.7.0-
17334 for (key in punycode) {
17335 punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
17336 }
17337 }
17338 } else {
17339 // in Rhino or a web browser
17340 root.punycode = punycode;
17341 }
17342
17343}(this));
17344
17345}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
17346},{}],251:[function(require,module,exports){
17347// Copyright Joyent, Inc. and other Node contributors.
17348//
17349// Permission is hereby granted, free of charge, to any person obtaining a
17350// copy of this software and associated documentation files (the
17351// "Software"), to deal in the Software without restriction, including
17352// without limitation the rights to use, copy, modify, merge, publish,
17353// distribute, sublicense, and/or sell copies of the Software, and to permit
17354// persons to whom the Software is furnished to do so, subject to the
17355// following conditions:
17356//
17357// The above copyright notice and this permission notice shall be included
17358// in all copies or substantial portions of the Software.
17359//
17360// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17361// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17362// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17363// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17364// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17365// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
17366// USE OR OTHER DEALINGS IN THE SOFTWARE.
17367
17368'use strict';
17369
17370// If obj.hasOwnProperty has been overridden, then calling
17371// obj.hasOwnProperty(prop) will break.
17372// See: https://github.com/joyent/node/issues/1707
17373function hasOwnProperty(obj, prop) {
17374 return Object.prototype.hasOwnProperty.call(obj, prop);
17375}
17376
17377module.exports = function(qs, sep, eq, options) {
17378 sep = sep || '&';
17379 eq = eq || '=';
17380 var obj = {};
17381
17382 if (typeof qs !== 'string' || qs.length === 0) {
17383 return obj;
17384 }
17385
17386 var regexp = /\+/g;
17387 qs = qs.split(sep);
17388
17389 var maxKeys = 1000;
17390 if (options && typeof options.maxKeys === 'number') {
17391 maxKeys = options.maxKeys;
17392 }
17393
17394 var len = qs.length;
17395 // maxKeys <= 0 means that we should not limit keys count
17396 if (maxKeys > 0 && len > maxKeys) {
17397 len = maxKeys;
17398 }
17399
17400 for (var i = 0; i < len; ++i) {
17401 var x = qs[i].replace(regexp, '%20'),
17402 idx = x.indexOf(eq),
17403 kstr, vstr, k, v;
17404
17405 if (idx >= 0) {
17406 kstr = x.substr(0, idx);
17407 vstr = x.substr(idx + 1);
17408 } else {
17409 kstr = x;
17410 vstr = '';
17411 }
17412
17413 k = decodeURIComponent(kstr);
17414 v = decodeURIComponent(vstr);
17415
17416 if (!hasOwnProperty(obj, k)) {
17417 obj[k] = v;
17418 } else if (isArray(obj[k])) {
17419 obj[k].push(v);
17420 } else {
17421 obj[k] = [obj[k], v];
17422 }
17423 }
17424
17425 return obj;
17426};
17427
17428var isArray = Array.isArray || function (xs) {
17429 return Object.prototype.toString.call(xs) === '[object Array]';
17430};
17431
17432},{}],252:[function(require,module,exports){
17433// Copyright Joyent, Inc. and other Node contributors.
17434//
17435// Permission is hereby granted, free of charge, to any person obtaining a
17436// copy of this software and associated documentation files (the
17437// "Software"), to deal in the Software without restriction, including
17438// without limitation the rights to use, copy, modify, merge, publish,
17439// distribute, sublicense, and/or sell copies of the Software, and to permit
17440// persons to whom the Software is furnished to do so, subject to the
17441// following conditions:
17442//
17443// The above copyright notice and this permission notice shall be included
17444// in all copies or substantial portions of the Software.
17445//
17446// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17447// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17448// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17449// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17450// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17451// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
17452// USE OR OTHER DEALINGS IN THE SOFTWARE.
17453
17454'use strict';
17455
17456var stringifyPrimitive = function(v) {
17457 switch (typeof v) {
17458 case 'string':
17459 return v;
17460
17461 case 'boolean':
17462 return v ? 'true' : 'false';
17463
17464 case 'number':
17465 return isFinite(v) ? v : '';
17466
17467 default:
17468 return '';
17469 }
17470};
17471
17472module.exports = function(obj, sep, eq, name) {
17473 sep = sep || '&';
17474 eq = eq || '=';
17475 if (obj === null) {
17476 obj = undefined;
17477 }
17478
17479 if (typeof obj === 'object') {
17480 return map(objectKeys(obj), function(k) {
17481 var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
17482 if (isArray(obj[k])) {
17483 return map(obj[k], function(v) {
17484 return ks + encodeURIComponent(stringifyPrimitive(v));
17485 }).join(sep);
17486 } else {
17487 return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
17488 }
17489 }).join(sep);
17490
17491 }
17492
17493 if (!name) return '';
17494 return encodeURIComponent(stringifyPrimitive(name)) + eq +
17495 encodeURIComponent(stringifyPrimitive(obj));
17496};
17497
17498var isArray = Array.isArray || function (xs) {
17499 return Object.prototype.toString.call(xs) === '[object Array]';
17500};
17501
17502function map (xs, f) {
17503 if (xs.map) return xs.map(f);
17504 var res = [];
17505 for (var i = 0; i < xs.length; i++) {
17506 res.push(f(xs[i], i));
17507 }
17508 return res;
17509}
17510
17511var objectKeys = Object.keys || function (obj) {
17512 var res = [];
17513 for (var key in obj) {
17514 if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
17515 }
17516 return res;
17517};
17518
17519},{}],253:[function(require,module,exports){
17520'use strict';
17521
17522exports.decode = exports.parse = require('./decode');
17523exports.encode = exports.stringify = require('./encode');
17524
17525},{"./decode":251,"./encode":252}],254:[function(require,module,exports){
17526module.exports = require('./lib/_stream_duplex.js');
17527
17528},{"./lib/_stream_duplex.js":255}],255:[function(require,module,exports){
17529// Copyright Joyent, Inc. and other Node contributors.
17530//
17531// Permission is hereby granted, free of charge, to any person obtaining a
17532// copy of this software and associated documentation files (the
17533// "Software"), to deal in the Software without restriction, including
17534// without limitation the rights to use, copy, modify, merge, publish,
17535// distribute, sublicense, and/or sell copies of the Software, and to permit
17536// persons to whom the Software is furnished to do so, subject to the
17537// following conditions:
17538//
17539// The above copyright notice and this permission notice shall be included
17540// in all copies or substantial portions of the Software.
17541//
17542// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17543// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17544// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17545// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17546// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17547// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
17548// USE OR OTHER DEALINGS IN THE SOFTWARE.
17549
17550// a duplex stream is just a stream that is both readable and writable.
17551// Since JS doesn't have multiple prototypal inheritance, this class
17552// prototypally inherits from Readable, and then parasitically from
17553// Writable.
17554
17555'use strict';
17556
17557/*<replacement>*/
17558
17559var _keys = require('babel-runtime/core-js/object/keys');
17560
17561var _keys2 = _interopRequireDefault(_keys);
17562
17563function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17564
17565var pna = require('process-nextick-args');
17566/*</replacement>*/
17567
17568/*<replacement>*/
17569var objectKeys = _keys2.default || function (obj) {
17570 var keys = [];
17571 for (var key in obj) {
17572 keys.push(key);
17573 }return keys;
17574};
17575/*</replacement>*/
17576
17577module.exports = Duplex;
17578
17579/*<replacement>*/
17580var util = require('core-util-is');
17581util.inherits = require('inherits');
17582/*</replacement>*/
17583
17584var Readable = require('./_stream_readable');
17585var Writable = require('./_stream_writable');
17586
17587util.inherits(Duplex, Readable);
17588
17589{
17590 // avoid scope creep, the keys array can then be collected
17591 var keys = objectKeys(Writable.prototype);
17592 for (var v = 0; v < keys.length; v++) {
17593 var method = keys[v];
17594 if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
17595 }
17596}
17597
17598function Duplex(options) {
17599 if (!(this instanceof Duplex)) return new Duplex(options);
17600
17601 Readable.call(this, options);
17602 Writable.call(this, options);
17603
17604 if (options && options.readable === false) this.readable = false;
17605
17606 if (options && options.writable === false) this.writable = false;
17607
17608 this.allowHalfOpen = true;
17609 if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
17610
17611 this.once('end', onend);
17612}
17613
17614Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
17615 // making it explicit this property is not enumerable
17616 // because otherwise some prototype manipulation in
17617 // userland will fail
17618 enumerable: false,
17619 get: function get() {
17620 return this._writableState.highWaterMark;
17621 }
17622});
17623
17624// the no-half-open enforcer
17625function onend() {
17626 // if we allow half-open state, or if the writable side ended,
17627 // then we're ok.
17628 if (this.allowHalfOpen || this._writableState.ended) return;
17629
17630 // no more data can be written.
17631 // But allow more writes to happen in this tick.
17632 pna.nextTick(onEndNT, this);
17633}
17634
17635function onEndNT(self) {
17636 self.end();
17637}
17638
17639Object.defineProperty(Duplex.prototype, 'destroyed', {
17640 get: function get() {
17641 if (this._readableState === undefined || this._writableState === undefined) {
17642 return false;
17643 }
17644 return this._readableState.destroyed && this._writableState.destroyed;
17645 },
17646 set: function set(value) {
17647 // we ignore the value if the stream
17648 // has not been initialized yet
17649 if (this._readableState === undefined || this._writableState === undefined) {
17650 return;
17651 }
17652
17653 // backward compatibility, the user is explicitly
17654 // managing destroyed
17655 this._readableState.destroyed = value;
17656 this._writableState.destroyed = value;
17657 }
17658});
17659
17660Duplex.prototype._destroy = function (err, cb) {
17661 this.push(null);
17662 this.end();
17663
17664 pna.nextTick(cb, err);
17665};
17666
17667},{"./_stream_readable":257,"./_stream_writable":259,"babel-runtime/core-js/object/keys":55,"core-util-is":186,"inherits":226,"process-nextick-args":248}],256:[function(require,module,exports){
17668// Copyright Joyent, Inc. and other Node contributors.
17669//
17670// Permission is hereby granted, free of charge, to any person obtaining a
17671// copy of this software and associated documentation files (the
17672// "Software"), to deal in the Software without restriction, including
17673// without limitation the rights to use, copy, modify, merge, publish,
17674// distribute, sublicense, and/or sell copies of the Software, and to permit
17675// persons to whom the Software is furnished to do so, subject to the
17676// following conditions:
17677//
17678// The above copyright notice and this permission notice shall be included
17679// in all copies or substantial portions of the Software.
17680//
17681// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17682// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17683// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17684// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17685// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17686// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
17687// USE OR OTHER DEALINGS IN THE SOFTWARE.
17688
17689// a passthrough stream.
17690// basically just the most minimal sort of Transform stream.
17691// Every written chunk gets output as-is.
17692
17693'use strict';
17694
17695module.exports = PassThrough;
17696
17697var Transform = require('./_stream_transform');
17698
17699/*<replacement>*/
17700var util = require('core-util-is');
17701util.inherits = require('inherits');
17702/*</replacement>*/
17703
17704util.inherits(PassThrough, Transform);
17705
17706function PassThrough(options) {
17707 if (!(this instanceof PassThrough)) return new PassThrough(options);
17708
17709 Transform.call(this, options);
17710}
17711
17712PassThrough.prototype._transform = function (chunk, encoding, cb) {
17713 cb(null, chunk);
17714};
17715
17716},{"./_stream_transform":258,"core-util-is":186,"inherits":226}],257:[function(require,module,exports){
17717(function (process,global){
17718// Copyright Joyent, Inc. and other Node contributors.
17719//
17720// Permission is hereby granted, free of charge, to any person obtaining a
17721// copy of this software and associated documentation files (the
17722// "Software"), to deal in the Software without restriction, including
17723// without limitation the rights to use, copy, modify, merge, publish,
17724// distribute, sublicense, and/or sell copies of the Software, and to permit
17725// persons to whom the Software is furnished to do so, subject to the
17726// following conditions:
17727//
17728// The above copyright notice and this permission notice shall be included
17729// in all copies or substantial portions of the Software.
17730//
17731// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17732// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17733// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17734// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17735// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17736// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
17737// USE OR OTHER DEALINGS IN THE SOFTWARE.
17738
17739'use strict';
17740
17741/*<replacement>*/
17742
17743var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
17744
17745var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
17746
17747function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17748
17749var pna = require('process-nextick-args');
17750/*</replacement>*/
17751
17752module.exports = Readable;
17753
17754/*<replacement>*/
17755var isArray = require('isarray');
17756/*</replacement>*/
17757
17758/*<replacement>*/
17759var Duplex;
17760/*</replacement>*/
17761
17762Readable.ReadableState = ReadableState;
17763
17764/*<replacement>*/
17765var EE = require('events').EventEmitter;
17766
17767var EElistenerCount = function EElistenerCount(emitter, type) {
17768 return emitter.listeners(type).length;
17769};
17770/*</replacement>*/
17771
17772/*<replacement>*/
17773var Stream = require('./internal/streams/stream');
17774/*</replacement>*/
17775
17776/*<replacement>*/
17777
17778var Buffer = require('safe-buffer').Buffer;
17779var OurUint8Array = global.Uint8Array || function () {};
17780function _uint8ArrayToBuffer(chunk) {
17781 return Buffer.from(chunk);
17782}
17783function _isUint8Array(obj) {
17784 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
17785}
17786
17787/*</replacement>*/
17788
17789/*<replacement>*/
17790var util = require('core-util-is');
17791util.inherits = require('inherits');
17792/*</replacement>*/
17793
17794/*<replacement>*/
17795var debugUtil = require('util');
17796var debug = void 0;
17797if (debugUtil && debugUtil.debuglog) {
17798 debug = debugUtil.debuglog('stream');
17799} else {
17800 debug = function debug() {};
17801}
17802/*</replacement>*/
17803
17804var BufferList = require('./internal/streams/BufferList');
17805var destroyImpl = require('./internal/streams/destroy');
17806var StringDecoder;
17807
17808util.inherits(Readable, Stream);
17809
17810var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
17811
17812function prependListener(emitter, event, fn) {
17813 // Sadly this is not cacheable as some libraries bundle their own
17814 // event emitter implementation with them.
17815 if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
17816
17817 // This is a hack to make sure that our error handler is attached before any
17818 // userland ones. NEVER DO THIS. This is here only because this code needs
17819 // to continue to work with older versions of Node.js that do not include
17820 // the prependListener() method. The goal is to eventually remove this hack.
17821 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]];
17822}
17823
17824function ReadableState(options, stream) {
17825 Duplex = Duplex || require('./_stream_duplex');
17826
17827 options = options || {};
17828
17829 // Duplex streams are both readable and writable, but share
17830 // the same options object.
17831 // However, some cases require setting options to different
17832 // values for the readable and the writable sides of the duplex stream.
17833 // These options can be provided separately as readableXXX and writableXXX.
17834 var isDuplex = stream instanceof Duplex;
17835
17836 // object stream flag. Used to make read(n) ignore n and to
17837 // make all the buffer merging and length checks go away
17838 this.objectMode = !!options.objectMode;
17839
17840 if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
17841
17842 // the point at which it stops calling _read() to fill the buffer
17843 // Note: 0 is a valid value, means "don't call _read preemptively ever"
17844 var hwm = options.highWaterMark;
17845 var readableHwm = options.readableHighWaterMark;
17846 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
17847
17848 if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
17849
17850 // cast to ints.
17851 this.highWaterMark = Math.floor(this.highWaterMark);
17852
17853 // A linked list is used to store data chunks instead of an array because the
17854 // linked list can remove elements from the beginning faster than
17855 // array.shift()
17856 this.buffer = new BufferList();
17857 this.length = 0;
17858 this.pipes = null;
17859 this.pipesCount = 0;
17860 this.flowing = null;
17861 this.ended = false;
17862 this.endEmitted = false;
17863 this.reading = false;
17864
17865 // a flag to be able to tell if the event 'readable'/'data' is emitted
17866 // immediately, or on a later tick. We set this to true at first, because
17867 // any actions that shouldn't happen until "later" should generally also
17868 // not happen before the first read call.
17869 this.sync = true;
17870
17871 // whenever we return null, then we set a flag to say
17872 // that we're awaiting a 'readable' event emission.
17873 this.needReadable = false;
17874 this.emittedReadable = false;
17875 this.readableListening = false;
17876 this.resumeScheduled = false;
17877
17878 // has it been destroyed
17879 this.destroyed = false;
17880
17881 // Crypto is kind of old and crusty. Historically, its default string
17882 // encoding is 'binary' so we have to make this configurable.
17883 // Everything else in the universe uses 'utf8', though.
17884 this.defaultEncoding = options.defaultEncoding || 'utf8';
17885
17886 // the number of writers that are awaiting a drain event in .pipe()s
17887 this.awaitDrain = 0;
17888
17889 // if true, a maybeReadMore has been scheduled
17890 this.readingMore = false;
17891
17892 this.decoder = null;
17893 this.encoding = null;
17894 if (options.encoding) {
17895 if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
17896 this.decoder = new StringDecoder(options.encoding);
17897 this.encoding = options.encoding;
17898 }
17899}
17900
17901function Readable(options) {
17902 Duplex = Duplex || require('./_stream_duplex');
17903
17904 if (!(this instanceof Readable)) return new Readable(options);
17905
17906 this._readableState = new ReadableState(options, this);
17907
17908 // legacy
17909 this.readable = true;
17910
17911 if (options) {
17912 if (typeof options.read === 'function') this._read = options.read;
17913
17914 if (typeof options.destroy === 'function') this._destroy = options.destroy;
17915 }
17916
17917 Stream.call(this);
17918}
17919
17920Object.defineProperty(Readable.prototype, 'destroyed', {
17921 get: function get() {
17922 if (this._readableState === undefined) {
17923 return false;
17924 }
17925 return this._readableState.destroyed;
17926 },
17927 set: function set(value) {
17928 // we ignore the value if the stream
17929 // has not been initialized yet
17930 if (!this._readableState) {
17931 return;
17932 }
17933
17934 // backward compatibility, the user is explicitly
17935 // managing destroyed
17936 this._readableState.destroyed = value;
17937 }
17938});
17939
17940Readable.prototype.destroy = destroyImpl.destroy;
17941Readable.prototype._undestroy = destroyImpl.undestroy;
17942Readable.prototype._destroy = function (err, cb) {
17943 this.push(null);
17944 cb(err);
17945};
17946
17947// Manually shove something into the read() buffer.
17948// This returns true if the highWaterMark has not been hit yet,
17949// similar to how Writable.write() returns true if you should
17950// write() some more.
17951Readable.prototype.push = function (chunk, encoding) {
17952 var state = this._readableState;
17953 var skipChunkCheck;
17954
17955 if (!state.objectMode) {
17956 if (typeof chunk === 'string') {
17957 encoding = encoding || state.defaultEncoding;
17958 if (encoding !== state.encoding) {
17959 chunk = Buffer.from(chunk, encoding);
17960 encoding = '';
17961 }
17962 skipChunkCheck = true;
17963 }
17964 } else {
17965 skipChunkCheck = true;
17966 }
17967
17968 return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
17969};
17970
17971// Unshift should *always* be something directly out of read()
17972Readable.prototype.unshift = function (chunk) {
17973 return readableAddChunk(this, chunk, null, true, false);
17974};
17975
17976function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
17977 var state = stream._readableState;
17978 if (chunk === null) {
17979 state.reading = false;
17980 onEofChunk(stream, state);
17981 } else {
17982 var er;
17983 if (!skipChunkCheck) er = chunkInvalid(state, chunk);
17984 if (er) {
17985 stream.emit('error', er);
17986 } else if (state.objectMode || chunk && chunk.length > 0) {
17987 if (typeof chunk !== 'string' && !state.objectMode && (0, _getPrototypeOf2.default)(chunk) !== Buffer.prototype) {
17988 chunk = _uint8ArrayToBuffer(chunk);
17989 }
17990
17991 if (addToFront) {
17992 if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
17993 } else if (state.ended) {
17994 stream.emit('error', new Error('stream.push() after EOF'));
17995 } else {
17996 state.reading = false;
17997 if (state.decoder && !encoding) {
17998 chunk = state.decoder.write(chunk);
17999 if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
18000 } else {
18001 addChunk(stream, state, chunk, false);
18002 }
18003 }
18004 } else if (!addToFront) {
18005 state.reading = false;
18006 }
18007 }
18008
18009 return needMoreData(state);
18010}
18011
18012function addChunk(stream, state, chunk, addToFront) {
18013 if (state.flowing && state.length === 0 && !state.sync) {
18014 stream.emit('data', chunk);
18015 stream.read(0);
18016 } else {
18017 // update the buffer info.
18018 state.length += state.objectMode ? 1 : chunk.length;
18019 if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
18020
18021 if (state.needReadable) emitReadable(stream);
18022 }
18023 maybeReadMore(stream, state);
18024}
18025
18026function chunkInvalid(state, chunk) {
18027 var er;
18028 if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
18029 er = new TypeError('Invalid non-string/buffer chunk');
18030 }
18031 return er;
18032}
18033
18034// if it's past the high water mark, we can push in some more.
18035// Also, if we have no data yet, we can stand some
18036// more bytes. This is to work around cases where hwm=0,
18037// such as the repl. Also, if the push() triggered a
18038// readable event, and the user called read(largeNumber) such that
18039// needReadable was set, then we ought to push more, so that another
18040// 'readable' event will be triggered.
18041function needMoreData(state) {
18042 return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
18043}
18044
18045Readable.prototype.isPaused = function () {
18046 return this._readableState.flowing === false;
18047};
18048
18049// backwards compatibility.
18050Readable.prototype.setEncoding = function (enc) {
18051 if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
18052 this._readableState.decoder = new StringDecoder(enc);
18053 this._readableState.encoding = enc;
18054 return this;
18055};
18056
18057// Don't raise the hwm > 8MB
18058var MAX_HWM = 0x800000;
18059function computeNewHighWaterMark(n) {
18060 if (n >= MAX_HWM) {
18061 n = MAX_HWM;
18062 } else {
18063 // Get the next highest power of 2 to prevent increasing hwm excessively in
18064 // tiny amounts
18065 n--;
18066 n |= n >>> 1;
18067 n |= n >>> 2;
18068 n |= n >>> 4;
18069 n |= n >>> 8;
18070 n |= n >>> 16;
18071 n++;
18072 }
18073 return n;
18074}
18075
18076// This function is designed to be inlinable, so please take care when making
18077// changes to the function body.
18078function howMuchToRead(n, state) {
18079 if (n <= 0 || state.length === 0 && state.ended) return 0;
18080 if (state.objectMode) return 1;
18081 if (n !== n) {
18082 // Only flow one buffer at a time
18083 if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
18084 }
18085 // If we're asking for more than the current hwm, then raise the hwm.
18086 if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
18087 if (n <= state.length) return n;
18088 // Don't have enough
18089 if (!state.ended) {
18090 state.needReadable = true;
18091 return 0;
18092 }
18093 return state.length;
18094}
18095
18096// you can override either this method, or the async _read(n) below.
18097Readable.prototype.read = function (n) {
18098 debug('read', n);
18099 n = parseInt(n, 10);
18100 var state = this._readableState;
18101 var nOrig = n;
18102
18103 if (n !== 0) state.emittedReadable = false;
18104
18105 // if we're doing read(0) to trigger a readable event, but we
18106 // already have a bunch of data in the buffer, then just trigger
18107 // the 'readable' event and move on.
18108 if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
18109 debug('read: emitReadable', state.length, state.ended);
18110 if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
18111 return null;
18112 }
18113
18114 n = howMuchToRead(n, state);
18115
18116 // if we've ended, and we're now clear, then finish it up.
18117 if (n === 0 && state.ended) {
18118 if (state.length === 0) endReadable(this);
18119 return null;
18120 }
18121
18122 // All the actual chunk generation logic needs to be
18123 // *below* the call to _read. The reason is that in certain
18124 // synthetic stream cases, such as passthrough streams, _read
18125 // may be a completely synchronous operation which may change
18126 // the state of the read buffer, providing enough data when
18127 // before there was *not* enough.
18128 //
18129 // So, the steps are:
18130 // 1. Figure out what the state of things will be after we do
18131 // a read from the buffer.
18132 //
18133 // 2. If that resulting state will trigger a _read, then call _read.
18134 // Note that this may be asynchronous, or synchronous. Yes, it is
18135 // deeply ugly to write APIs this way, but that still doesn't mean
18136 // that the Readable class should behave improperly, as streams are
18137 // designed to be sync/async agnostic.
18138 // Take note if the _read call is sync or async (ie, if the read call
18139 // has returned yet), so that we know whether or not it's safe to emit
18140 // 'readable' etc.
18141 //
18142 // 3. Actually pull the requested chunks out of the buffer and return.
18143
18144 // if we need a readable event, then we need to do some reading.
18145 var doRead = state.needReadable;
18146 debug('need readable', doRead);
18147
18148 // if we currently have less than the highWaterMark, then also read some
18149 if (state.length === 0 || state.length - n < state.highWaterMark) {
18150 doRead = true;
18151 debug('length less than watermark', doRead);
18152 }
18153
18154 // however, if we've ended, then there's no point, and if we're already
18155 // reading, then it's unnecessary.
18156 if (state.ended || state.reading) {
18157 doRead = false;
18158 debug('reading or ended', doRead);
18159 } else if (doRead) {
18160 debug('do read');
18161 state.reading = true;
18162 state.sync = true;
18163 // if the length is currently zero, then we *need* a readable event.
18164 if (state.length === 0) state.needReadable = true;
18165 // call internal read method
18166 this._read(state.highWaterMark);
18167 state.sync = false;
18168 // If _read pushed data synchronously, then `reading` will be false,
18169 // and we need to re-evaluate how much data we can return to the user.
18170 if (!state.reading) n = howMuchToRead(nOrig, state);
18171 }
18172
18173 var ret;
18174 if (n > 0) ret = fromList(n, state);else ret = null;
18175
18176 if (ret === null) {
18177 state.needReadable = true;
18178 n = 0;
18179 } else {
18180 state.length -= n;
18181 }
18182
18183 if (state.length === 0) {
18184 // If we have nothing in the buffer, then we want to know
18185 // as soon as we *do* get something into the buffer.
18186 if (!state.ended) state.needReadable = true;
18187
18188 // If we tried to read() past the EOF, then emit end on the next tick.
18189 if (nOrig !== n && state.ended) endReadable(this);
18190 }
18191
18192 if (ret !== null) this.emit('data', ret);
18193
18194 return ret;
18195};
18196
18197function onEofChunk(stream, state) {
18198 if (state.ended) return;
18199 if (state.decoder) {
18200 var chunk = state.decoder.end();
18201 if (chunk && chunk.length) {
18202 state.buffer.push(chunk);
18203 state.length += state.objectMode ? 1 : chunk.length;
18204 }
18205 }
18206 state.ended = true;
18207
18208 // emit 'readable' now to make sure it gets picked up.
18209 emitReadable(stream);
18210}
18211
18212// Don't emit readable right away in sync mode, because this can trigger
18213// another read() call => stack overflow. This way, it might trigger
18214// a nextTick recursion warning, but that's not so bad.
18215function emitReadable(stream) {
18216 var state = stream._readableState;
18217 state.needReadable = false;
18218 if (!state.emittedReadable) {
18219 debug('emitReadable', state.flowing);
18220 state.emittedReadable = true;
18221 if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
18222 }
18223}
18224
18225function emitReadable_(stream) {
18226 debug('emit readable');
18227 stream.emit('readable');
18228 flow(stream);
18229}
18230
18231// at this point, the user has presumably seen the 'readable' event,
18232// and called read() to consume some data. that may have triggered
18233// in turn another _read(n) call, in which case reading = true if
18234// it's in progress.
18235// However, if we're not ended, or reading, and the length < hwm,
18236// then go ahead and try to read some more preemptively.
18237function maybeReadMore(stream, state) {
18238 if (!state.readingMore) {
18239 state.readingMore = true;
18240 pna.nextTick(maybeReadMore_, stream, state);
18241 }
18242}
18243
18244function maybeReadMore_(stream, state) {
18245 var len = state.length;
18246 while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
18247 debug('maybeReadMore read 0');
18248 stream.read(0);
18249 if (len === state.length)
18250 // didn't get any data, stop spinning.
18251 break;else len = state.length;
18252 }
18253 state.readingMore = false;
18254}
18255
18256// abstract method. to be overridden in specific implementation classes.
18257// call cb(er, data) where data is <= n in length.
18258// for virtual (non-string, non-buffer) streams, "length" is somewhat
18259// arbitrary, and perhaps not very meaningful.
18260Readable.prototype._read = function (n) {
18261 this.emit('error', new Error('_read() is not implemented'));
18262};
18263
18264Readable.prototype.pipe = function (dest, pipeOpts) {
18265 var src = this;
18266 var state = this._readableState;
18267
18268 switch (state.pipesCount) {
18269 case 0:
18270 state.pipes = dest;
18271 break;
18272 case 1:
18273 state.pipes = [state.pipes, dest];
18274 break;
18275 default:
18276 state.pipes.push(dest);
18277 break;
18278 }
18279 state.pipesCount += 1;
18280 debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
18281
18282 var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
18283
18284 var endFn = doEnd ? onend : unpipe;
18285 if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
18286
18287 dest.on('unpipe', onunpipe);
18288 function onunpipe(readable, unpipeInfo) {
18289 debug('onunpipe');
18290 if (readable === src) {
18291 if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
18292 unpipeInfo.hasUnpiped = true;
18293 cleanup();
18294 }
18295 }
18296 }
18297
18298 function onend() {
18299 debug('onend');
18300 dest.end();
18301 }
18302
18303 // when the dest drains, it reduces the awaitDrain counter
18304 // on the source. This would be more elegant with a .once()
18305 // handler in flow(), but adding and removing repeatedly is
18306 // too slow.
18307 var ondrain = pipeOnDrain(src);
18308 dest.on('drain', ondrain);
18309
18310 var cleanedUp = false;
18311 function cleanup() {
18312 debug('cleanup');
18313 // cleanup event handlers once the pipe is broken
18314 dest.removeListener('close', onclose);
18315 dest.removeListener('finish', onfinish);
18316 dest.removeListener('drain', ondrain);
18317 dest.removeListener('error', onerror);
18318 dest.removeListener('unpipe', onunpipe);
18319 src.removeListener('end', onend);
18320 src.removeListener('end', unpipe);
18321 src.removeListener('data', ondata);
18322
18323 cleanedUp = true;
18324
18325 // if the reader is waiting for a drain event from this
18326 // specific writer, then it would cause it to never start
18327 // flowing again.
18328 // So, if this is awaiting a drain, then we just call it now.
18329 // If we don't know, then assume that we are waiting for one.
18330 if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
18331 }
18332
18333 // If the user pushes more data while we're writing to dest then we'll end up
18334 // in ondata again. However, we only want to increase awaitDrain once because
18335 // dest will only emit one 'drain' event for the multiple writes.
18336 // => Introduce a guard on increasing awaitDrain.
18337 var increasedAwaitDrain = false;
18338 src.on('data', ondata);
18339 function ondata(chunk) {
18340 debug('ondata');
18341 increasedAwaitDrain = false;
18342 var ret = dest.write(chunk);
18343 if (false === ret && !increasedAwaitDrain) {
18344 // If the user unpiped during `dest.write()`, it is possible
18345 // to get stuck in a permanently paused state if that write
18346 // also returned false.
18347 // => Check whether `dest` is still a piping destination.
18348 if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
18349 debug('false write response, pause', src._readableState.awaitDrain);
18350 src._readableState.awaitDrain++;
18351 increasedAwaitDrain = true;
18352 }
18353 src.pause();
18354 }
18355 }
18356
18357 // if the dest has an error, then stop piping into it.
18358 // however, don't suppress the throwing behavior for this.
18359 function onerror(er) {
18360 debug('onerror', er);
18361 unpipe();
18362 dest.removeListener('error', onerror);
18363 if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
18364 }
18365
18366 // Make sure our error handler is attached before userland ones.
18367 prependListener(dest, 'error', onerror);
18368
18369 // Both close and finish should trigger unpipe, but only once.
18370 function onclose() {
18371 dest.removeListener('finish', onfinish);
18372 unpipe();
18373 }
18374 dest.once('close', onclose);
18375 function onfinish() {
18376 debug('onfinish');
18377 dest.removeListener('close', onclose);
18378 unpipe();
18379 }
18380 dest.once('finish', onfinish);
18381
18382 function unpipe() {
18383 debug('unpipe');
18384 src.unpipe(dest);
18385 }
18386
18387 // tell the dest that it's being piped to
18388 dest.emit('pipe', src);
18389
18390 // start the flow if it hasn't been started already.
18391 if (!state.flowing) {
18392 debug('pipe resume');
18393 src.resume();
18394 }
18395
18396 return dest;
18397};
18398
18399function pipeOnDrain(src) {
18400 return function () {
18401 var state = src._readableState;
18402 debug('pipeOnDrain', state.awaitDrain);
18403 if (state.awaitDrain) state.awaitDrain--;
18404 if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
18405 state.flowing = true;
18406 flow(src);
18407 }
18408 };
18409}
18410
18411Readable.prototype.unpipe = function (dest) {
18412 var state = this._readableState;
18413 var unpipeInfo = { hasUnpiped: false };
18414
18415 // if we're not piping anywhere, then do nothing.
18416 if (state.pipesCount === 0) return this;
18417
18418 // just one destination. most common case.
18419 if (state.pipesCount === 1) {
18420 // passed in one, but it's not the right one.
18421 if (dest && dest !== state.pipes) return this;
18422
18423 if (!dest) dest = state.pipes;
18424
18425 // got a match.
18426 state.pipes = null;
18427 state.pipesCount = 0;
18428 state.flowing = false;
18429 if (dest) dest.emit('unpipe', this, unpipeInfo);
18430 return this;
18431 }
18432
18433 // slow case. multiple pipe destinations.
18434
18435 if (!dest) {
18436 // remove all.
18437 var dests = state.pipes;
18438 var len = state.pipesCount;
18439 state.pipes = null;
18440 state.pipesCount = 0;
18441 state.flowing = false;
18442
18443 for (var i = 0; i < len; i++) {
18444 dests[i].emit('unpipe', this, unpipeInfo);
18445 }return this;
18446 }
18447
18448 // try to find the right one.
18449 var index = indexOf(state.pipes, dest);
18450 if (index === -1) return this;
18451
18452 state.pipes.splice(index, 1);
18453 state.pipesCount -= 1;
18454 if (state.pipesCount === 1) state.pipes = state.pipes[0];
18455
18456 dest.emit('unpipe', this, unpipeInfo);
18457
18458 return this;
18459};
18460
18461// set up data events if they are asked for
18462// Ensure readable listeners eventually get something
18463Readable.prototype.on = function (ev, fn) {
18464 var res = Stream.prototype.on.call(this, ev, fn);
18465
18466 if (ev === 'data') {
18467 // Start flowing on next tick if stream isn't explicitly paused
18468 if (this._readableState.flowing !== false) this.resume();
18469 } else if (ev === 'readable') {
18470 var state = this._readableState;
18471 if (!state.endEmitted && !state.readableListening) {
18472 state.readableListening = state.needReadable = true;
18473 state.emittedReadable = false;
18474 if (!state.reading) {
18475 pna.nextTick(nReadingNextTick, this);
18476 } else if (state.length) {
18477 emitReadable(this);
18478 }
18479 }
18480 }
18481
18482 return res;
18483};
18484Readable.prototype.addListener = Readable.prototype.on;
18485
18486function nReadingNextTick(self) {
18487 debug('readable nexttick read 0');
18488 self.read(0);
18489}
18490
18491// pause() and resume() are remnants of the legacy readable stream API
18492// If the user uses them, then switch into old mode.
18493Readable.prototype.resume = function () {
18494 var state = this._readableState;
18495 if (!state.flowing) {
18496 debug('resume');
18497 state.flowing = true;
18498 resume(this, state);
18499 }
18500 return this;
18501};
18502
18503function resume(stream, state) {
18504 if (!state.resumeScheduled) {
18505 state.resumeScheduled = true;
18506 pna.nextTick(resume_, stream, state);
18507 }
18508}
18509
18510function resume_(stream, state) {
18511 if (!state.reading) {
18512 debug('resume read 0');
18513 stream.read(0);
18514 }
18515
18516 state.resumeScheduled = false;
18517 state.awaitDrain = 0;
18518 stream.emit('resume');
18519 flow(stream);
18520 if (state.flowing && !state.reading) stream.read(0);
18521}
18522
18523Readable.prototype.pause = function () {
18524 debug('call pause flowing=%j', this._readableState.flowing);
18525 if (false !== this._readableState.flowing) {
18526 debug('pause');
18527 this._readableState.flowing = false;
18528 this.emit('pause');
18529 }
18530 return this;
18531};
18532
18533function flow(stream) {
18534 var state = stream._readableState;
18535 debug('flow', state.flowing);
18536 while (state.flowing && stream.read() !== null) {}
18537}
18538
18539// wrap an old-style stream as the async data source.
18540// This is *not* part of the readable stream interface.
18541// It is an ugly unfortunate mess of history.
18542Readable.prototype.wrap = function (stream) {
18543 var _this = this;
18544
18545 var state = this._readableState;
18546 var paused = false;
18547
18548 stream.on('end', function () {
18549 debug('wrapped end');
18550 if (state.decoder && !state.ended) {
18551 var chunk = state.decoder.end();
18552 if (chunk && chunk.length) _this.push(chunk);
18553 }
18554
18555 _this.push(null);
18556 });
18557
18558 stream.on('data', function (chunk) {
18559 debug('wrapped data');
18560 if (state.decoder) chunk = state.decoder.write(chunk);
18561
18562 // don't skip over falsy values in objectMode
18563 if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
18564
18565 var ret = _this.push(chunk);
18566 if (!ret) {
18567 paused = true;
18568 stream.pause();
18569 }
18570 });
18571
18572 // proxy all the other methods.
18573 // important when wrapping filters and duplexes.
18574 for (var i in stream) {
18575 if (this[i] === undefined && typeof stream[i] === 'function') {
18576 this[i] = function (method) {
18577 return function () {
18578 return stream[method].apply(stream, arguments);
18579 };
18580 }(i);
18581 }
18582 }
18583
18584 // proxy certain important events.
18585 for (var n = 0; n < kProxyEvents.length; n++) {
18586 stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
18587 }
18588
18589 // when we try to consume some more bytes, simply unpause the
18590 // underlying stream.
18591 this._read = function (n) {
18592 debug('wrapped _read', n);
18593 if (paused) {
18594 paused = false;
18595 stream.resume();
18596 }
18597 };
18598
18599 return this;
18600};
18601
18602Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
18603 // making it explicit this property is not enumerable
18604 // because otherwise some prototype manipulation in
18605 // userland will fail
18606 enumerable: false,
18607 get: function get() {
18608 return this._readableState.highWaterMark;
18609 }
18610});
18611
18612// exposed for testing purposes only.
18613Readable._fromList = fromList;
18614
18615// Pluck off n bytes from an array of buffers.
18616// Length is the combined lengths of all the buffers in the list.
18617// This function is designed to be inlinable, so please take care when making
18618// changes to the function body.
18619function fromList(n, state) {
18620 // nothing buffered
18621 if (state.length === 0) return null;
18622
18623 var ret;
18624 if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
18625 // read it all, truncate the list
18626 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);
18627 state.buffer.clear();
18628 } else {
18629 // read part of list
18630 ret = fromListPartial(n, state.buffer, state.decoder);
18631 }
18632
18633 return ret;
18634}
18635
18636// Extracts only enough buffered data to satisfy the amount requested.
18637// This function is designed to be inlinable, so please take care when making
18638// changes to the function body.
18639function fromListPartial(n, list, hasStrings) {
18640 var ret;
18641 if (n < list.head.data.length) {
18642 // slice is the same for buffers and strings
18643 ret = list.head.data.slice(0, n);
18644 list.head.data = list.head.data.slice(n);
18645 } else if (n === list.head.data.length) {
18646 // first chunk is a perfect match
18647 ret = list.shift();
18648 } else {
18649 // result spans more than one buffer
18650 ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
18651 }
18652 return ret;
18653}
18654
18655// Copies a specified amount of characters from the list of buffered data
18656// chunks.
18657// This function is designed to be inlinable, so please take care when making
18658// changes to the function body.
18659function copyFromBufferString(n, list) {
18660 var p = list.head;
18661 var c = 1;
18662 var ret = p.data;
18663 n -= ret.length;
18664 while (p = p.next) {
18665 var str = p.data;
18666 var nb = n > str.length ? str.length : n;
18667 if (nb === str.length) ret += str;else ret += str.slice(0, n);
18668 n -= nb;
18669 if (n === 0) {
18670 if (nb === str.length) {
18671 ++c;
18672 if (p.next) list.head = p.next;else list.head = list.tail = null;
18673 } else {
18674 list.head = p;
18675 p.data = str.slice(nb);
18676 }
18677 break;
18678 }
18679 ++c;
18680 }
18681 list.length -= c;
18682 return ret;
18683}
18684
18685// Copies a specified amount of bytes from the list of buffered data chunks.
18686// This function is designed to be inlinable, so please take care when making
18687// changes to the function body.
18688function copyFromBuffer(n, list) {
18689 var ret = Buffer.allocUnsafe(n);
18690 var p = list.head;
18691 var c = 1;
18692 p.data.copy(ret);
18693 n -= p.data.length;
18694 while (p = p.next) {
18695 var buf = p.data;
18696 var nb = n > buf.length ? buf.length : n;
18697 buf.copy(ret, ret.length - n, 0, nb);
18698 n -= nb;
18699 if (n === 0) {
18700 if (nb === buf.length) {
18701 ++c;
18702 if (p.next) list.head = p.next;else list.head = list.tail = null;
18703 } else {
18704 list.head = p;
18705 p.data = buf.slice(nb);
18706 }
18707 break;
18708 }
18709 ++c;
18710 }
18711 list.length -= c;
18712 return ret;
18713}
18714
18715function endReadable(stream) {
18716 var state = stream._readableState;
18717
18718 // If we get here before consuming all the bytes, then that is a
18719 // bug in node. Should never happen.
18720 if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
18721
18722 if (!state.endEmitted) {
18723 state.ended = true;
18724 pna.nextTick(endReadableNT, state, stream);
18725 }
18726}
18727
18728function endReadableNT(state, stream) {
18729 // Check that we didn't get one last unshift.
18730 if (!state.endEmitted && state.length === 0) {
18731 state.endEmitted = true;
18732 stream.readable = false;
18733 stream.emit('end');
18734 }
18735}
18736
18737function indexOf(xs, x) {
18738 for (var i = 0, l = xs.length; i < l; i++) {
18739 if (xs[i] === x) return i;
18740 }
18741 return -1;
18742}
18743
18744}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
18745},{"./_stream_duplex":255,"./internal/streams/BufferList":260,"./internal/streams/destroy":261,"./internal/streams/stream":262,"_process":249,"babel-runtime/core-js/object/get-prototype-of":54,"core-util-is":186,"events":216,"inherits":226,"isarray":234,"process-nextick-args":248,"safe-buffer":269,"string_decoder/":276,"util":68}],258:[function(require,module,exports){
18746// Copyright Joyent, Inc. and other Node contributors.
18747//
18748// Permission is hereby granted, free of charge, to any person obtaining a
18749// copy of this software and associated documentation files (the
18750// "Software"), to deal in the Software without restriction, including
18751// without limitation the rights to use, copy, modify, merge, publish,
18752// distribute, sublicense, and/or sell copies of the Software, and to permit
18753// persons to whom the Software is furnished to do so, subject to the
18754// following conditions:
18755//
18756// The above copyright notice and this permission notice shall be included
18757// in all copies or substantial portions of the Software.
18758//
18759// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18760// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18761// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
18762// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18763// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18764// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
18765// USE OR OTHER DEALINGS IN THE SOFTWARE.
18766
18767// a transform stream is a readable/writable stream where you do
18768// something with the data. Sometimes it's called a "filter",
18769// but that's not a great name for it, since that implies a thing where
18770// some bits pass through, and others are simply ignored. (That would
18771// be a valid example of a transform, of course.)
18772//
18773// While the output is causally related to the input, it's not a
18774// necessarily symmetric or synchronous transformation. For example,
18775// a zlib stream might take multiple plain-text writes(), and then
18776// emit a single compressed chunk some time in the future.
18777//
18778// Here's how this works:
18779//
18780// The Transform stream has all the aspects of the readable and writable
18781// stream classes. When you write(chunk), that calls _write(chunk,cb)
18782// internally, and returns false if there's a lot of pending writes
18783// buffered up. When you call read(), that calls _read(n) until
18784// there's enough pending readable data buffered up.
18785//
18786// In a transform stream, the written data is placed in a buffer. When
18787// _read(n) is called, it transforms the queued up data, calling the
18788// buffered _write cb's as it consumes chunks. If consuming a single
18789// written chunk would result in multiple output chunks, then the first
18790// outputted bit calls the readcb, and subsequent chunks just go into
18791// the read buffer, and will cause it to emit 'readable' if necessary.
18792//
18793// This way, back-pressure is actually determined by the reading side,
18794// since _read has to be called to start processing a new chunk. However,
18795// a pathological inflate type of transform can cause excessive buffering
18796// here. For example, imagine a stream where every byte of input is
18797// interpreted as an integer from 0-255, and then results in that many
18798// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
18799// 1kb of data being output. In this case, you could write a very small
18800// amount of input, and end up with a very large amount of output. In
18801// such a pathological inflating mechanism, there'd be no way to tell
18802// the system to stop doing the transform. A single 4MB write could
18803// cause the system to run out of memory.
18804//
18805// However, even in such a pathological case, only a single written chunk
18806// would be consumed, and then the rest would wait (un-transformed) until
18807// the results of the previous transformed chunk were consumed.
18808
18809'use strict';
18810
18811module.exports = Transform;
18812
18813var Duplex = require('./_stream_duplex');
18814
18815/*<replacement>*/
18816var util = require('core-util-is');
18817util.inherits = require('inherits');
18818/*</replacement>*/
18819
18820util.inherits(Transform, Duplex);
18821
18822function afterTransform(er, data) {
18823 var ts = this._transformState;
18824 ts.transforming = false;
18825
18826 var cb = ts.writecb;
18827
18828 if (!cb) {
18829 return this.emit('error', new Error('write callback called multiple times'));
18830 }
18831
18832 ts.writechunk = null;
18833 ts.writecb = null;
18834
18835 if (data != null) // single equals check for both `null` and `undefined`
18836 this.push(data);
18837
18838 cb(er);
18839
18840 var rs = this._readableState;
18841 rs.reading = false;
18842 if (rs.needReadable || rs.length < rs.highWaterMark) {
18843 this._read(rs.highWaterMark);
18844 }
18845}
18846
18847function Transform(options) {
18848 if (!(this instanceof Transform)) return new Transform(options);
18849
18850 Duplex.call(this, options);
18851
18852 this._transformState = {
18853 afterTransform: afterTransform.bind(this),
18854 needTransform: false,
18855 transforming: false,
18856 writecb: null,
18857 writechunk: null,
18858 writeencoding: null
18859 };
18860
18861 // start out asking for a readable event once data is transformed.
18862 this._readableState.needReadable = true;
18863
18864 // we have implemented the _read method, and done the other things
18865 // that Readable wants before the first _read call, so unset the
18866 // sync guard flag.
18867 this._readableState.sync = false;
18868
18869 if (options) {
18870 if (typeof options.transform === 'function') this._transform = options.transform;
18871
18872 if (typeof options.flush === 'function') this._flush = options.flush;
18873 }
18874
18875 // When the writable side finishes, then flush out anything remaining.
18876 this.on('prefinish', prefinish);
18877}
18878
18879function prefinish() {
18880 var _this = this;
18881
18882 if (typeof this._flush === 'function') {
18883 this._flush(function (er, data) {
18884 done(_this, er, data);
18885 });
18886 } else {
18887 done(this, null, null);
18888 }
18889}
18890
18891Transform.prototype.push = function (chunk, encoding) {
18892 this._transformState.needTransform = false;
18893 return Duplex.prototype.push.call(this, chunk, encoding);
18894};
18895
18896// This is the part where you do stuff!
18897// override this function in implementation classes.
18898// 'chunk' is an input chunk.
18899//
18900// Call `push(newChunk)` to pass along transformed output
18901// to the readable side. You may call 'push' zero or more times.
18902//
18903// Call `cb(err)` when you are done with this chunk. If you pass
18904// an error, then that'll put the hurt on the whole operation. If you
18905// never call cb(), then you'll never get another chunk.
18906Transform.prototype._transform = function (chunk, encoding, cb) {
18907 throw new Error('_transform() is not implemented');
18908};
18909
18910Transform.prototype._write = function (chunk, encoding, cb) {
18911 var ts = this._transformState;
18912 ts.writecb = cb;
18913 ts.writechunk = chunk;
18914 ts.writeencoding = encoding;
18915 if (!ts.transforming) {
18916 var rs = this._readableState;
18917 if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
18918 }
18919};
18920
18921// Doesn't matter what the args are here.
18922// _transform does all the work.
18923// That we got here means that the readable side wants more data.
18924Transform.prototype._read = function (n) {
18925 var ts = this._transformState;
18926
18927 if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
18928 ts.transforming = true;
18929 this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
18930 } else {
18931 // mark that we need a transform, so that any data that comes in
18932 // will get processed, now that we've asked for it.
18933 ts.needTransform = true;
18934 }
18935};
18936
18937Transform.prototype._destroy = function (err, cb) {
18938 var _this2 = this;
18939
18940 Duplex.prototype._destroy.call(this, err, function (err2) {
18941 cb(err2);
18942 _this2.emit('close');
18943 });
18944};
18945
18946function done(stream, er, data) {
18947 if (er) return stream.emit('error', er);
18948
18949 if (data != null) // single equals check for both `null` and `undefined`
18950 stream.push(data);
18951
18952 // if there's nothing in the write buffer, then that means
18953 // that nothing more will ever be provided
18954 if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
18955
18956 if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
18957
18958 return stream.push(null);
18959}
18960
18961},{"./_stream_duplex":255,"core-util-is":186,"inherits":226}],259:[function(require,module,exports){
18962(function (process,global){
18963// Copyright Joyent, Inc. and other Node contributors.
18964//
18965// Permission is hereby granted, free of charge, to any person obtaining a
18966// copy of this software and associated documentation files (the
18967// "Software"), to deal in the Software without restriction, including
18968// without limitation the rights to use, copy, modify, merge, publish,
18969// distribute, sublicense, and/or sell copies of the Software, and to permit
18970// persons to whom the Software is furnished to do so, subject to the
18971// following conditions:
18972//
18973// The above copyright notice and this permission notice shall be included
18974// in all copies or substantial portions of the Software.
18975//
18976// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18977// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18978// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
18979// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18980// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18981// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
18982// USE OR OTHER DEALINGS IN THE SOFTWARE.
18983
18984// A bit simpler than readable streams.
18985// Implement an async ._write(chunk, encoding, cb), and it'll handle all
18986// the drain event emission and buffering.
18987
18988'use strict';
18989
18990/*<replacement>*/
18991
18992var _defineProperty = require('babel-runtime/core-js/object/define-property');
18993
18994var _defineProperty2 = _interopRequireDefault(_defineProperty);
18995
18996var _hasInstance = require('babel-runtime/core-js/symbol/has-instance');
18997
18998var _hasInstance2 = _interopRequireDefault(_hasInstance);
18999
19000var _symbol = require('babel-runtime/core-js/symbol');
19001
19002var _symbol2 = _interopRequireDefault(_symbol);
19003
19004var _setImmediate2 = require('babel-runtime/core-js/set-immediate');
19005
19006var _setImmediate3 = _interopRequireDefault(_setImmediate2);
19007
19008function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19009
19010var pna = require('process-nextick-args');
19011/*</replacement>*/
19012
19013module.exports = Writable;
19014
19015/* <replacement> */
19016function WriteReq(chunk, encoding, cb) {
19017 this.chunk = chunk;
19018 this.encoding = encoding;
19019 this.callback = cb;
19020 this.next = null;
19021}
19022
19023// It seems a linked list but it is not
19024// there will be only 2 of these for each stream
19025function CorkedRequest(state) {
19026 var _this = this;
19027
19028 this.next = null;
19029 this.entry = null;
19030 this.finish = function () {
19031 onCorkedFinish(_this, state);
19032 };
19033}
19034/* </replacement> */
19035
19036/*<replacement>*/
19037var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? _setImmediate3.default : pna.nextTick;
19038/*</replacement>*/
19039
19040/*<replacement>*/
19041var Duplex;
19042/*</replacement>*/
19043
19044Writable.WritableState = WritableState;
19045
19046/*<replacement>*/
19047var util = require('core-util-is');
19048util.inherits = require('inherits');
19049/*</replacement>*/
19050
19051/*<replacement>*/
19052var internalUtil = {
19053 deprecate: require('util-deprecate')
19054};
19055/*</replacement>*/
19056
19057/*<replacement>*/
19058var Stream = require('./internal/streams/stream');
19059/*</replacement>*/
19060
19061/*<replacement>*/
19062
19063var Buffer = require('safe-buffer').Buffer;
19064var OurUint8Array = global.Uint8Array || function () {};
19065function _uint8ArrayToBuffer(chunk) {
19066 return Buffer.from(chunk);
19067}
19068function _isUint8Array(obj) {
19069 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
19070}
19071
19072/*</replacement>*/
19073
19074var destroyImpl = require('./internal/streams/destroy');
19075
19076util.inherits(Writable, Stream);
19077
19078function nop() {}
19079
19080function WritableState(options, stream) {
19081 Duplex = Duplex || require('./_stream_duplex');
19082
19083 options = options || {};
19084
19085 // Duplex streams are both readable and writable, but share
19086 // the same options object.
19087 // However, some cases require setting options to different
19088 // values for the readable and the writable sides of the duplex stream.
19089 // These options can be provided separately as readableXXX and writableXXX.
19090 var isDuplex = stream instanceof Duplex;
19091
19092 // object stream flag to indicate whether or not this stream
19093 // contains buffers or objects.
19094 this.objectMode = !!options.objectMode;
19095
19096 if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
19097
19098 // the point at which write() starts returning false
19099 // Note: 0 is a valid value, means that we always return false if
19100 // the entire buffer is not flushed immediately on write()
19101 var hwm = options.highWaterMark;
19102 var writableHwm = options.writableHighWaterMark;
19103 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
19104
19105 if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
19106
19107 // cast to ints.
19108 this.highWaterMark = Math.floor(this.highWaterMark);
19109
19110 // if _final has been called
19111 this.finalCalled = false;
19112
19113 // drain event flag.
19114 this.needDrain = false;
19115 // at the start of calling end()
19116 this.ending = false;
19117 // when end() has been called, and returned
19118 this.ended = false;
19119 // when 'finish' is emitted
19120 this.finished = false;
19121
19122 // has it been destroyed
19123 this.destroyed = false;
19124
19125 // should we decode strings into buffers before passing to _write?
19126 // this is here so that some node-core streams can optimize string
19127 // handling at a lower level.
19128 var noDecode = options.decodeStrings === false;
19129 this.decodeStrings = !noDecode;
19130
19131 // Crypto is kind of old and crusty. Historically, its default string
19132 // encoding is 'binary' so we have to make this configurable.
19133 // Everything else in the universe uses 'utf8', though.
19134 this.defaultEncoding = options.defaultEncoding || 'utf8';
19135
19136 // not an actual buffer we keep track of, but a measurement
19137 // of how much we're waiting to get pushed to some underlying
19138 // socket or file.
19139 this.length = 0;
19140
19141 // a flag to see when we're in the middle of a write.
19142 this.writing = false;
19143
19144 // when true all writes will be buffered until .uncork() call
19145 this.corked = 0;
19146
19147 // a flag to be able to tell if the onwrite cb is called immediately,
19148 // or on a later tick. We set this to true at first, because any
19149 // actions that shouldn't happen until "later" should generally also
19150 // not happen before the first write call.
19151 this.sync = true;
19152
19153 // a flag to know if we're processing previously buffered items, which
19154 // may call the _write() callback in the same tick, so that we don't
19155 // end up in an overlapped onwrite situation.
19156 this.bufferProcessing = false;
19157
19158 // the callback that's passed to _write(chunk,cb)
19159 this.onwrite = function (er) {
19160 onwrite(stream, er);
19161 };
19162
19163 // the callback that the user supplies to write(chunk,encoding,cb)
19164 this.writecb = null;
19165
19166 // the amount that is being written when _write is called.
19167 this.writelen = 0;
19168
19169 this.bufferedRequest = null;
19170 this.lastBufferedRequest = null;
19171
19172 // number of pending user-supplied write callbacks
19173 // this must be 0 before 'finish' can be emitted
19174 this.pendingcb = 0;
19175
19176 // emit prefinish if the only thing we're waiting for is _write cbs
19177 // This is relevant for synchronous Transform streams
19178 this.prefinished = false;
19179
19180 // True if the error was already emitted and should not be thrown again
19181 this.errorEmitted = false;
19182
19183 // count buffered requests
19184 this.bufferedRequestCount = 0;
19185
19186 // allocate the first CorkedRequest, there is always
19187 // one allocated and free to use, and we maintain at most two
19188 this.corkedRequestsFree = new CorkedRequest(this);
19189}
19190
19191WritableState.prototype.getBuffer = function getBuffer() {
19192 var current = this.bufferedRequest;
19193 var out = [];
19194 while (current) {
19195 out.push(current);
19196 current = current.next;
19197 }
19198 return out;
19199};
19200
19201(function () {
19202 try {
19203 Object.defineProperty(WritableState.prototype, 'buffer', {
19204 get: internalUtil.deprecate(function () {
19205 return this.getBuffer();
19206 }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
19207 });
19208 } catch (_) {}
19209})();
19210
19211// Test _writableState for inheritance to account for Duplex streams,
19212// whose prototype chain only points to Readable.
19213var realHasInstance;
19214if (typeof _symbol2.default === 'function' && _hasInstance2.default && typeof Function.prototype[_hasInstance2.default] === 'function') {
19215 realHasInstance = Function.prototype[_hasInstance2.default];
19216 (0, _defineProperty2.default)(Writable, _hasInstance2.default, {
19217 value: function value(object) {
19218 if (realHasInstance.call(this, object)) return true;
19219 if (this !== Writable) return false;
19220
19221 return object && object._writableState instanceof WritableState;
19222 }
19223 });
19224} else {
19225 realHasInstance = function realHasInstance(object) {
19226 return object instanceof this;
19227 };
19228}
19229
19230function Writable(options) {
19231 Duplex = Duplex || require('./_stream_duplex');
19232
19233 // Writable ctor is applied to Duplexes, too.
19234 // `realHasInstance` is necessary because using plain `instanceof`
19235 // would return false, as no `_writableState` property is attached.
19236
19237 // Trying to use the custom `instanceof` for Writable here will also break the
19238 // Node.js LazyTransform implementation, which has a non-trivial getter for
19239 // `_writableState` that would lead to infinite recursion.
19240 if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
19241 return new Writable(options);
19242 }
19243
19244 this._writableState = new WritableState(options, this);
19245
19246 // legacy.
19247 this.writable = true;
19248
19249 if (options) {
19250 if (typeof options.write === 'function') this._write = options.write;
19251
19252 if (typeof options.writev === 'function') this._writev = options.writev;
19253
19254 if (typeof options.destroy === 'function') this._destroy = options.destroy;
19255
19256 if (typeof options.final === 'function') this._final = options.final;
19257 }
19258
19259 Stream.call(this);
19260}
19261
19262// Otherwise people can pipe Writable streams, which is just wrong.
19263Writable.prototype.pipe = function () {
19264 this.emit('error', new Error('Cannot pipe, not readable'));
19265};
19266
19267function writeAfterEnd(stream, cb) {
19268 var er = new Error('write after end');
19269 // TODO: defer error events consistently everywhere, not just the cb
19270 stream.emit('error', er);
19271 pna.nextTick(cb, er);
19272}
19273
19274// Checks that a user-supplied chunk is valid, especially for the particular
19275// mode the stream is in. Currently this means that `null` is never accepted
19276// and undefined/non-string values are only allowed in object mode.
19277function validChunk(stream, state, chunk, cb) {
19278 var valid = true;
19279 var er = false;
19280
19281 if (chunk === null) {
19282 er = new TypeError('May not write null values to stream');
19283 } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
19284 er = new TypeError('Invalid non-string/buffer chunk');
19285 }
19286 if (er) {
19287 stream.emit('error', er);
19288 pna.nextTick(cb, er);
19289 valid = false;
19290 }
19291 return valid;
19292}
19293
19294Writable.prototype.write = function (chunk, encoding, cb) {
19295 var state = this._writableState;
19296 var ret = false;
19297 var isBuf = !state.objectMode && _isUint8Array(chunk);
19298
19299 if (isBuf && !Buffer.isBuffer(chunk)) {
19300 chunk = _uint8ArrayToBuffer(chunk);
19301 }
19302
19303 if (typeof encoding === 'function') {
19304 cb = encoding;
19305 encoding = null;
19306 }
19307
19308 if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
19309
19310 if (typeof cb !== 'function') cb = nop;
19311
19312 if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
19313 state.pendingcb++;
19314 ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
19315 }
19316
19317 return ret;
19318};
19319
19320Writable.prototype.cork = function () {
19321 var state = this._writableState;
19322
19323 state.corked++;
19324};
19325
19326Writable.prototype.uncork = function () {
19327 var state = this._writableState;
19328
19329 if (state.corked) {
19330 state.corked--;
19331
19332 if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
19333 }
19334};
19335
19336Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
19337 // node::ParseEncoding() requires lower case.
19338 if (typeof encoding === 'string') encoding = encoding.toLowerCase();
19339 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);
19340 this._writableState.defaultEncoding = encoding;
19341 return this;
19342};
19343
19344function decodeChunk(state, chunk, encoding) {
19345 if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
19346 chunk = Buffer.from(chunk, encoding);
19347 }
19348 return chunk;
19349}
19350
19351Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
19352 // making it explicit this property is not enumerable
19353 // because otherwise some prototype manipulation in
19354 // userland will fail
19355 enumerable: false,
19356 get: function get() {
19357 return this._writableState.highWaterMark;
19358 }
19359});
19360
19361// if we're already writing something, then just put this
19362// in the queue, and wait our turn. Otherwise, call _write
19363// If we return false, then we need a drain event, so set that flag.
19364function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
19365 if (!isBuf) {
19366 var newChunk = decodeChunk(state, chunk, encoding);
19367 if (chunk !== newChunk) {
19368 isBuf = true;
19369 encoding = 'buffer';
19370 chunk = newChunk;
19371 }
19372 }
19373 var len = state.objectMode ? 1 : chunk.length;
19374
19375 state.length += len;
19376
19377 var ret = state.length < state.highWaterMark;
19378 // we must ensure that previous needDrain will not be reset to false.
19379 if (!ret) state.needDrain = true;
19380
19381 if (state.writing || state.corked) {
19382 var last = state.lastBufferedRequest;
19383 state.lastBufferedRequest = {
19384 chunk: chunk,
19385 encoding: encoding,
19386 isBuf: isBuf,
19387 callback: cb,
19388 next: null
19389 };
19390 if (last) {
19391 last.next = state.lastBufferedRequest;
19392 } else {
19393 state.bufferedRequest = state.lastBufferedRequest;
19394 }
19395 state.bufferedRequestCount += 1;
19396 } else {
19397 doWrite(stream, state, false, len, chunk, encoding, cb);
19398 }
19399
19400 return ret;
19401}
19402
19403function doWrite(stream, state, writev, len, chunk, encoding, cb) {
19404 state.writelen = len;
19405 state.writecb = cb;
19406 state.writing = true;
19407 state.sync = true;
19408 if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
19409 state.sync = false;
19410}
19411
19412function onwriteError(stream, state, sync, er, cb) {
19413 --state.pendingcb;
19414
19415 if (sync) {
19416 // defer the callback if we are being called synchronously
19417 // to avoid piling up things on the stack
19418 pna.nextTick(cb, er);
19419 // this can emit finish, and it will always happen
19420 // after error
19421 pna.nextTick(finishMaybe, stream, state);
19422 stream._writableState.errorEmitted = true;
19423 stream.emit('error', er);
19424 } else {
19425 // the caller expect this to happen before if
19426 // it is async
19427 cb(er);
19428 stream._writableState.errorEmitted = true;
19429 stream.emit('error', er);
19430 // this can emit finish, but finish must
19431 // always follow error
19432 finishMaybe(stream, state);
19433 }
19434}
19435
19436function onwriteStateUpdate(state) {
19437 state.writing = false;
19438 state.writecb = null;
19439 state.length -= state.writelen;
19440 state.writelen = 0;
19441}
19442
19443function onwrite(stream, er) {
19444 var state = stream._writableState;
19445 var sync = state.sync;
19446 var cb = state.writecb;
19447
19448 onwriteStateUpdate(state);
19449
19450 if (er) onwriteError(stream, state, sync, er, cb);else {
19451 // Check if we're actually ready to finish, but don't emit yet
19452 var finished = needFinish(state);
19453
19454 if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
19455 clearBuffer(stream, state);
19456 }
19457
19458 if (sync) {
19459 /*<replacement>*/
19460 asyncWrite(afterWrite, stream, state, finished, cb);
19461 /*</replacement>*/
19462 } else {
19463 afterWrite(stream, state, finished, cb);
19464 }
19465 }
19466}
19467
19468function afterWrite(stream, state, finished, cb) {
19469 if (!finished) onwriteDrain(stream, state);
19470 state.pendingcb--;
19471 cb();
19472 finishMaybe(stream, state);
19473}
19474
19475// Must force callback to be called on nextTick, so that we don't
19476// emit 'drain' before the write() consumer gets the 'false' return
19477// value, and has a chance to attach a 'drain' listener.
19478function onwriteDrain(stream, state) {
19479 if (state.length === 0 && state.needDrain) {
19480 state.needDrain = false;
19481 stream.emit('drain');
19482 }
19483}
19484
19485// if there's something in the buffer waiting, then process it
19486function clearBuffer(stream, state) {
19487 state.bufferProcessing = true;
19488 var entry = state.bufferedRequest;
19489
19490 if (stream._writev && entry && entry.next) {
19491 // Fast case, write everything using _writev()
19492 var l = state.bufferedRequestCount;
19493 var buffer = new Array(l);
19494 var holder = state.corkedRequestsFree;
19495 holder.entry = entry;
19496
19497 var count = 0;
19498 var allBuffers = true;
19499 while (entry) {
19500 buffer[count] = entry;
19501 if (!entry.isBuf) allBuffers = false;
19502 entry = entry.next;
19503 count += 1;
19504 }
19505 buffer.allBuffers = allBuffers;
19506
19507 doWrite(stream, state, true, state.length, buffer, '', holder.finish);
19508
19509 // doWrite is almost always async, defer these to save a bit of time
19510 // as the hot path ends with doWrite
19511 state.pendingcb++;
19512 state.lastBufferedRequest = null;
19513 if (holder.next) {
19514 state.corkedRequestsFree = holder.next;
19515 holder.next = null;
19516 } else {
19517 state.corkedRequestsFree = new CorkedRequest(state);
19518 }
19519 state.bufferedRequestCount = 0;
19520 } else {
19521 // Slow case, write chunks one-by-one
19522 while (entry) {
19523 var chunk = entry.chunk;
19524 var encoding = entry.encoding;
19525 var cb = entry.callback;
19526 var len = state.objectMode ? 1 : chunk.length;
19527
19528 doWrite(stream, state, false, len, chunk, encoding, cb);
19529 entry = entry.next;
19530 state.bufferedRequestCount--;
19531 // if we didn't call the onwrite immediately, then
19532 // it means that we need to wait until it does.
19533 // also, that means that the chunk and cb are currently
19534 // being processed, so move the buffer counter past them.
19535 if (state.writing) {
19536 break;
19537 }
19538 }
19539
19540 if (entry === null) state.lastBufferedRequest = null;
19541 }
19542
19543 state.bufferedRequest = entry;
19544 state.bufferProcessing = false;
19545}
19546
19547Writable.prototype._write = function (chunk, encoding, cb) {
19548 cb(new Error('_write() is not implemented'));
19549};
19550
19551Writable.prototype._writev = null;
19552
19553Writable.prototype.end = function (chunk, encoding, cb) {
19554 var state = this._writableState;
19555
19556 if (typeof chunk === 'function') {
19557 cb = chunk;
19558 chunk = null;
19559 encoding = null;
19560 } else if (typeof encoding === 'function') {
19561 cb = encoding;
19562 encoding = null;
19563 }
19564
19565 if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
19566
19567 // .end() fully uncorks
19568 if (state.corked) {
19569 state.corked = 1;
19570 this.uncork();
19571 }
19572
19573 // ignore unnecessary end() calls.
19574 if (!state.ending && !state.finished) endWritable(this, state, cb);
19575};
19576
19577function needFinish(state) {
19578 return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
19579}
19580function callFinal(stream, state) {
19581 stream._final(function (err) {
19582 state.pendingcb--;
19583 if (err) {
19584 stream.emit('error', err);
19585 }
19586 state.prefinished = true;
19587 stream.emit('prefinish');
19588 finishMaybe(stream, state);
19589 });
19590}
19591function prefinish(stream, state) {
19592 if (!state.prefinished && !state.finalCalled) {
19593 if (typeof stream._final === 'function') {
19594 state.pendingcb++;
19595 state.finalCalled = true;
19596 pna.nextTick(callFinal, stream, state);
19597 } else {
19598 state.prefinished = true;
19599 stream.emit('prefinish');
19600 }
19601 }
19602}
19603
19604function finishMaybe(stream, state) {
19605 var need = needFinish(state);
19606 if (need) {
19607 prefinish(stream, state);
19608 if (state.pendingcb === 0) {
19609 state.finished = true;
19610 stream.emit('finish');
19611 }
19612 }
19613 return need;
19614}
19615
19616function endWritable(stream, state, cb) {
19617 state.ending = true;
19618 finishMaybe(stream, state);
19619 if (cb) {
19620 if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
19621 }
19622 state.ended = true;
19623 stream.writable = false;
19624}
19625
19626function onCorkedFinish(corkReq, state, err) {
19627 var entry = corkReq.entry;
19628 corkReq.entry = null;
19629 while (entry) {
19630 var cb = entry.callback;
19631 state.pendingcb--;
19632 cb(err);
19633 entry = entry.next;
19634 }
19635 if (state.corkedRequestsFree) {
19636 state.corkedRequestsFree.next = corkReq;
19637 } else {
19638 state.corkedRequestsFree = corkReq;
19639 }
19640}
19641
19642Object.defineProperty(Writable.prototype, 'destroyed', {
19643 get: function get() {
19644 if (this._writableState === undefined) {
19645 return false;
19646 }
19647 return this._writableState.destroyed;
19648 },
19649 set: function set(value) {
19650 // we ignore the value if the stream
19651 // has not been initialized yet
19652 if (!this._writableState) {
19653 return;
19654 }
19655
19656 // backward compatibility, the user is explicitly
19657 // managing destroyed
19658 this._writableState.destroyed = value;
19659 }
19660});
19661
19662Writable.prototype.destroy = destroyImpl.destroy;
19663Writable.prototype._undestroy = destroyImpl.undestroy;
19664Writable.prototype._destroy = function (err, cb) {
19665 this.end();
19666 cb(err);
19667};
19668
19669}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
19670},{"./_stream_duplex":255,"./internal/streams/destroy":261,"./internal/streams/stream":262,"_process":249,"babel-runtime/core-js/object/define-property":51,"babel-runtime/core-js/set-immediate":57,"babel-runtime/core-js/symbol":59,"babel-runtime/core-js/symbol/has-instance":60,"core-util-is":186,"inherits":226,"process-nextick-args":248,"safe-buffer":269,"util-deprecate":281}],260:[function(require,module,exports){
19671'use strict';
19672
19673function _classCallCheck(instance, Constructor) {
19674 if (!(instance instanceof Constructor)) {
19675 throw new TypeError("Cannot call a class as a function");
19676 }
19677}
19678
19679var Buffer = require('safe-buffer').Buffer;
19680var util = require('util');
19681
19682function copyBuffer(src, target, offset) {
19683 src.copy(target, offset);
19684}
19685
19686module.exports = function () {
19687 function BufferList() {
19688 _classCallCheck(this, BufferList);
19689
19690 this.head = null;
19691 this.tail = null;
19692 this.length = 0;
19693 }
19694
19695 BufferList.prototype.push = function push(v) {
19696 var entry = { data: v, next: null };
19697 if (this.length > 0) this.tail.next = entry;else this.head = entry;
19698 this.tail = entry;
19699 ++this.length;
19700 };
19701
19702 BufferList.prototype.unshift = function unshift(v) {
19703 var entry = { data: v, next: this.head };
19704 if (this.length === 0) this.tail = entry;
19705 this.head = entry;
19706 ++this.length;
19707 };
19708
19709 BufferList.prototype.shift = function shift() {
19710 if (this.length === 0) return;
19711 var ret = this.head.data;
19712 if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
19713 --this.length;
19714 return ret;
19715 };
19716
19717 BufferList.prototype.clear = function clear() {
19718 this.head = this.tail = null;
19719 this.length = 0;
19720 };
19721
19722 BufferList.prototype.join = function join(s) {
19723 if (this.length === 0) return '';
19724 var p = this.head;
19725 var ret = '' + p.data;
19726 while (p = p.next) {
19727 ret += s + p.data;
19728 }return ret;
19729 };
19730
19731 BufferList.prototype.concat = function concat(n) {
19732 if (this.length === 0) return Buffer.alloc(0);
19733 if (this.length === 1) return this.head.data;
19734 var ret = Buffer.allocUnsafe(n >>> 0);
19735 var p = this.head;
19736 var i = 0;
19737 while (p) {
19738 copyBuffer(p.data, ret, i);
19739 i += p.data.length;
19740 p = p.next;
19741 }
19742 return ret;
19743 };
19744
19745 return BufferList;
19746}();
19747
19748if (util && util.inspect && util.inspect.custom) {
19749 module.exports.prototype[util.inspect.custom] = function () {
19750 var obj = util.inspect({ length: this.length });
19751 return this.constructor.name + ' ' + obj;
19752 };
19753}
19754
19755},{"safe-buffer":269,"util":68}],261:[function(require,module,exports){
19756'use strict';
19757
19758/*<replacement>*/
19759
19760var pna = require('process-nextick-args');
19761/*</replacement>*/
19762
19763// undocumented cb() API, needed for core, not for public API
19764function destroy(err, cb) {
19765 var _this = this;
19766
19767 var readableDestroyed = this._readableState && this._readableState.destroyed;
19768 var writableDestroyed = this._writableState && this._writableState.destroyed;
19769
19770 if (readableDestroyed || writableDestroyed) {
19771 if (cb) {
19772 cb(err);
19773 } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
19774 pna.nextTick(emitErrorNT, this, err);
19775 }
19776 return this;
19777 }
19778
19779 // we set destroyed to true before firing error callbacks in order
19780 // to make it re-entrance safe in case destroy() is called within callbacks
19781
19782 if (this._readableState) {
19783 this._readableState.destroyed = true;
19784 }
19785
19786 // if this is a duplex stream mark the writable part as destroyed as well
19787 if (this._writableState) {
19788 this._writableState.destroyed = true;
19789 }
19790
19791 this._destroy(err || null, function (err) {
19792 if (!cb && err) {
19793 pna.nextTick(emitErrorNT, _this, err);
19794 if (_this._writableState) {
19795 _this._writableState.errorEmitted = true;
19796 }
19797 } else if (cb) {
19798 cb(err);
19799 }
19800 });
19801
19802 return this;
19803}
19804
19805function undestroy() {
19806 if (this._readableState) {
19807 this._readableState.destroyed = false;
19808 this._readableState.reading = false;
19809 this._readableState.ended = false;
19810 this._readableState.endEmitted = false;
19811 }
19812
19813 if (this._writableState) {
19814 this._writableState.destroyed = false;
19815 this._writableState.ended = false;
19816 this._writableState.ending = false;
19817 this._writableState.finished = false;
19818 this._writableState.errorEmitted = false;
19819 }
19820}
19821
19822function emitErrorNT(self, err) {
19823 self.emit('error', err);
19824}
19825
19826module.exports = {
19827 destroy: destroy,
19828 undestroy: undestroy
19829};
19830
19831},{"process-nextick-args":248}],262:[function(require,module,exports){
19832'use strict';
19833
19834module.exports = require('events').EventEmitter;
19835
19836},{"events":216}],263:[function(require,module,exports){
19837module.exports = require('./readable').PassThrough
19838
19839},{"./readable":264}],264:[function(require,module,exports){
19840exports = module.exports = require('./lib/_stream_readable.js');
19841exports.Stream = exports;
19842exports.Readable = exports;
19843exports.Writable = require('./lib/_stream_writable.js');
19844exports.Duplex = require('./lib/_stream_duplex.js');
19845exports.Transform = require('./lib/_stream_transform.js');
19846exports.PassThrough = require('./lib/_stream_passthrough.js');
19847
19848},{"./lib/_stream_duplex.js":255,"./lib/_stream_passthrough.js":256,"./lib/_stream_readable.js":257,"./lib/_stream_transform.js":258,"./lib/_stream_writable.js":259}],265:[function(require,module,exports){
19849module.exports = require('./readable').Transform
19850
19851},{"./readable":264}],266:[function(require,module,exports){
19852module.exports = require('./lib/_stream_writable.js');
19853
19854},{"./lib/_stream_writable.js":259}],267:[function(require,module,exports){
19855/**
19856 * Copyright (c) 2014-present, Facebook, Inc.
19857 *
19858 * This source code is licensed under the MIT license found in the
19859 * LICENSE file in the root directory of this source tree.
19860 */
19861
19862// This method of obtaining a reference to the global object needs to be
19863// kept identical to the way it is obtained in runtime.js
19864var g = (function() { return this })() || Function("return this")();
19865
19866// Use `getOwnPropertyNames` because not all browsers support calling
19867// `hasOwnProperty` on the global `self` object in a worker. See #183.
19868var hadRuntime = g.regeneratorRuntime &&
19869 Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0;
19870
19871// Save the old regeneratorRuntime in case it needs to be restored later.
19872var oldRuntime = hadRuntime && g.regeneratorRuntime;
19873
19874// Force reevalutation of runtime.js.
19875g.regeneratorRuntime = undefined;
19876
19877module.exports = require("./runtime");
19878
19879if (hadRuntime) {
19880 // Restore the original runtime.
19881 g.regeneratorRuntime = oldRuntime;
19882} else {
19883 // Remove the global property added by runtime.js.
19884 try {
19885 delete g.regeneratorRuntime;
19886 } catch(e) {
19887 g.regeneratorRuntime = undefined;
19888 }
19889}
19890
19891},{"./runtime":268}],268:[function(require,module,exports){
19892/**
19893 * Copyright (c) 2014-present, Facebook, Inc.
19894 *
19895 * This source code is licensed under the MIT license found in the
19896 * LICENSE file in the root directory of this source tree.
19897 */
19898
19899!(function(global) {
19900 "use strict";
19901
19902 var Op = Object.prototype;
19903 var hasOwn = Op.hasOwnProperty;
19904 var undefined; // More compressible than void 0.
19905 var $Symbol = typeof Symbol === "function" ? Symbol : {};
19906 var iteratorSymbol = $Symbol.iterator || "@@iterator";
19907 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
19908 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
19909
19910 var inModule = typeof module === "object";
19911 var runtime = global.regeneratorRuntime;
19912 if (runtime) {
19913 if (inModule) {
19914 // If regeneratorRuntime is defined globally and we're in a module,
19915 // make the exports object identical to regeneratorRuntime.
19916 module.exports = runtime;
19917 }
19918 // Don't bother evaluating the rest of this file if the runtime was
19919 // already defined globally.
19920 return;
19921 }
19922
19923 // Define the runtime globally (as expected by generated code) as either
19924 // module.exports (if we're in a module) or a new, empty object.
19925 runtime = global.regeneratorRuntime = inModule ? module.exports : {};
19926
19927 function wrap(innerFn, outerFn, self, tryLocsList) {
19928 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
19929 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
19930 var generator = Object.create(protoGenerator.prototype);
19931 var context = new Context(tryLocsList || []);
19932
19933 // The ._invoke method unifies the implementations of the .next,
19934 // .throw, and .return methods.
19935 generator._invoke = makeInvokeMethod(innerFn, self, context);
19936
19937 return generator;
19938 }
19939 runtime.wrap = wrap;
19940
19941 // Try/catch helper to minimize deoptimizations. Returns a completion
19942 // record like context.tryEntries[i].completion. This interface could
19943 // have been (and was previously) designed to take a closure to be
19944 // invoked without arguments, but in all the cases we care about we
19945 // already have an existing method we want to call, so there's no need
19946 // to create a new function object. We can even get away with assuming
19947 // the method takes exactly one argument, since that happens to be true
19948 // in every case, so we don't have to touch the arguments object. The
19949 // only additional allocation required is the completion record, which
19950 // has a stable shape and so hopefully should be cheap to allocate.
19951 function tryCatch(fn, obj, arg) {
19952 try {
19953 return { type: "normal", arg: fn.call(obj, arg) };
19954 } catch (err) {
19955 return { type: "throw", arg: err };
19956 }
19957 }
19958
19959 var GenStateSuspendedStart = "suspendedStart";
19960 var GenStateSuspendedYield = "suspendedYield";
19961 var GenStateExecuting = "executing";
19962 var GenStateCompleted = "completed";
19963
19964 // Returning this object from the innerFn has the same effect as
19965 // breaking out of the dispatch switch statement.
19966 var ContinueSentinel = {};
19967
19968 // Dummy constructor functions that we use as the .constructor and
19969 // .constructor.prototype properties for functions that return Generator
19970 // objects. For full spec compliance, you may wish to configure your
19971 // minifier not to mangle the names of these two functions.
19972 function Generator() {}
19973 function GeneratorFunction() {}
19974 function GeneratorFunctionPrototype() {}
19975
19976 // This is a polyfill for %IteratorPrototype% for environments that
19977 // don't natively support it.
19978 var IteratorPrototype = {};
19979 IteratorPrototype[iteratorSymbol] = function () {
19980 return this;
19981 };
19982
19983 var getProto = Object.getPrototypeOf;
19984 var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
19985 if (NativeIteratorPrototype &&
19986 NativeIteratorPrototype !== Op &&
19987 hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
19988 // This environment has a native %IteratorPrototype%; use it instead
19989 // of the polyfill.
19990 IteratorPrototype = NativeIteratorPrototype;
19991 }
19992
19993 var Gp = GeneratorFunctionPrototype.prototype =
19994 Generator.prototype = Object.create(IteratorPrototype);
19995 GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
19996 GeneratorFunctionPrototype.constructor = GeneratorFunction;
19997 GeneratorFunctionPrototype[toStringTagSymbol] =
19998 GeneratorFunction.displayName = "GeneratorFunction";
19999
20000 // Helper for defining the .next, .throw, and .return methods of the
20001 // Iterator interface in terms of a single ._invoke method.
20002 function defineIteratorMethods(prototype) {
20003 ["next", "throw", "return"].forEach(function(method) {
20004 prototype[method] = function(arg) {
20005 return this._invoke(method, arg);
20006 };
20007 });
20008 }
20009
20010 runtime.isGeneratorFunction = function(genFun) {
20011 var ctor = typeof genFun === "function" && genFun.constructor;
20012 return ctor
20013 ? ctor === GeneratorFunction ||
20014 // For the native GeneratorFunction constructor, the best we can
20015 // do is to check its .name property.
20016 (ctor.displayName || ctor.name) === "GeneratorFunction"
20017 : false;
20018 };
20019
20020 runtime.mark = function(genFun) {
20021 if (Object.setPrototypeOf) {
20022 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
20023 } else {
20024 genFun.__proto__ = GeneratorFunctionPrototype;
20025 if (!(toStringTagSymbol in genFun)) {
20026 genFun[toStringTagSymbol] = "GeneratorFunction";
20027 }
20028 }
20029 genFun.prototype = Object.create(Gp);
20030 return genFun;
20031 };
20032
20033 // Within the body of any async function, `await x` is transformed to
20034 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
20035 // `hasOwn.call(value, "__await")` to determine if the yielded value is
20036 // meant to be awaited.
20037 runtime.awrap = function(arg) {
20038 return { __await: arg };
20039 };
20040
20041 function AsyncIterator(generator) {
20042 function invoke(method, arg, resolve, reject) {
20043 var record = tryCatch(generator[method], generator, arg);
20044 if (record.type === "throw") {
20045 reject(record.arg);
20046 } else {
20047 var result = record.arg;
20048 var value = result.value;
20049 if (value &&
20050 typeof value === "object" &&
20051 hasOwn.call(value, "__await")) {
20052 return Promise.resolve(value.__await).then(function(value) {
20053 invoke("next", value, resolve, reject);
20054 }, function(err) {
20055 invoke("throw", err, resolve, reject);
20056 });
20057 }
20058
20059 return Promise.resolve(value).then(function(unwrapped) {
20060 // When a yielded Promise is resolved, its final value becomes
20061 // the .value of the Promise<{value,done}> result for the
20062 // current iteration. If the Promise is rejected, however, the
20063 // result for this iteration will be rejected with the same
20064 // reason. Note that rejections of yielded Promises are not
20065 // thrown back into the generator function, as is the case
20066 // when an awaited Promise is rejected. This difference in
20067 // behavior between yield and await is important, because it
20068 // allows the consumer to decide what to do with the yielded
20069 // rejection (swallow it and continue, manually .throw it back
20070 // into the generator, abandon iteration, whatever). With
20071 // await, by contrast, there is no opportunity to examine the
20072 // rejection reason outside the generator function, so the
20073 // only option is to throw it from the await expression, and
20074 // let the generator function handle the exception.
20075 result.value = unwrapped;
20076 resolve(result);
20077 }, reject);
20078 }
20079 }
20080
20081 var previousPromise;
20082
20083 function enqueue(method, arg) {
20084 function callInvokeWithMethodAndArg() {
20085 return new Promise(function(resolve, reject) {
20086 invoke(method, arg, resolve, reject);
20087 });
20088 }
20089
20090 return previousPromise =
20091 // If enqueue has been called before, then we want to wait until
20092 // all previous Promises have been resolved before calling invoke,
20093 // so that results are always delivered in the correct order. If
20094 // enqueue has not been called before, then it is important to
20095 // call invoke immediately, without waiting on a callback to fire,
20096 // so that the async generator function has the opportunity to do
20097 // any necessary setup in a predictable way. This predictability
20098 // is why the Promise constructor synchronously invokes its
20099 // executor callback, and why async functions synchronously
20100 // execute code before the first await. Since we implement simple
20101 // async functions in terms of async generators, it is especially
20102 // important to get this right, even though it requires care.
20103 previousPromise ? previousPromise.then(
20104 callInvokeWithMethodAndArg,
20105 // Avoid propagating failures to Promises returned by later
20106 // invocations of the iterator.
20107 callInvokeWithMethodAndArg
20108 ) : callInvokeWithMethodAndArg();
20109 }
20110
20111 // Define the unified helper method that is used to implement .next,
20112 // .throw, and .return (see defineIteratorMethods).
20113 this._invoke = enqueue;
20114 }
20115
20116 defineIteratorMethods(AsyncIterator.prototype);
20117 AsyncIterator.prototype[asyncIteratorSymbol] = function () {
20118 return this;
20119 };
20120 runtime.AsyncIterator = AsyncIterator;
20121
20122 // Note that simple async functions are implemented on top of
20123 // AsyncIterator objects; they just return a Promise for the value of
20124 // the final result produced by the iterator.
20125 runtime.async = function(innerFn, outerFn, self, tryLocsList) {
20126 var iter = new AsyncIterator(
20127 wrap(innerFn, outerFn, self, tryLocsList)
20128 );
20129
20130 return runtime.isGeneratorFunction(outerFn)
20131 ? iter // If outerFn is a generator, return the full iterator.
20132 : iter.next().then(function(result) {
20133 return result.done ? result.value : iter.next();
20134 });
20135 };
20136
20137 function makeInvokeMethod(innerFn, self, context) {
20138 var state = GenStateSuspendedStart;
20139
20140 return function invoke(method, arg) {
20141 if (state === GenStateExecuting) {
20142 throw new Error("Generator is already running");
20143 }
20144
20145 if (state === GenStateCompleted) {
20146 if (method === "throw") {
20147 throw arg;
20148 }
20149
20150 // Be forgiving, per 25.3.3.3.3 of the spec:
20151 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
20152 return doneResult();
20153 }
20154
20155 context.method = method;
20156 context.arg = arg;
20157
20158 while (true) {
20159 var delegate = context.delegate;
20160 if (delegate) {
20161 var delegateResult = maybeInvokeDelegate(delegate, context);
20162 if (delegateResult) {
20163 if (delegateResult === ContinueSentinel) continue;
20164 return delegateResult;
20165 }
20166 }
20167
20168 if (context.method === "next") {
20169 // Setting context._sent for legacy support of Babel's
20170 // function.sent implementation.
20171 context.sent = context._sent = context.arg;
20172
20173 } else if (context.method === "throw") {
20174 if (state === GenStateSuspendedStart) {
20175 state = GenStateCompleted;
20176 throw context.arg;
20177 }
20178
20179 context.dispatchException(context.arg);
20180
20181 } else if (context.method === "return") {
20182 context.abrupt("return", context.arg);
20183 }
20184
20185 state = GenStateExecuting;
20186
20187 var record = tryCatch(innerFn, self, context);
20188 if (record.type === "normal") {
20189 // If an exception is thrown from innerFn, we leave state ===
20190 // GenStateExecuting and loop back for another invocation.
20191 state = context.done
20192 ? GenStateCompleted
20193 : GenStateSuspendedYield;
20194
20195 if (record.arg === ContinueSentinel) {
20196 continue;
20197 }
20198
20199 return {
20200 value: record.arg,
20201 done: context.done
20202 };
20203
20204 } else if (record.type === "throw") {
20205 state = GenStateCompleted;
20206 // Dispatch the exception by looping back around to the
20207 // context.dispatchException(context.arg) call above.
20208 context.method = "throw";
20209 context.arg = record.arg;
20210 }
20211 }
20212 };
20213 }
20214
20215 // Call delegate.iterator[context.method](context.arg) and handle the
20216 // result, either by returning a { value, done } result from the
20217 // delegate iterator, or by modifying context.method and context.arg,
20218 // setting context.delegate to null, and returning the ContinueSentinel.
20219 function maybeInvokeDelegate(delegate, context) {
20220 var method = delegate.iterator[context.method];
20221 if (method === undefined) {
20222 // A .throw or .return when the delegate iterator has no .throw
20223 // method always terminates the yield* loop.
20224 context.delegate = null;
20225
20226 if (context.method === "throw") {
20227 if (delegate.iterator.return) {
20228 // If the delegate iterator has a return method, give it a
20229 // chance to clean up.
20230 context.method = "return";
20231 context.arg = undefined;
20232 maybeInvokeDelegate(delegate, context);
20233
20234 if (context.method === "throw") {
20235 // If maybeInvokeDelegate(context) changed context.method from
20236 // "return" to "throw", let that override the TypeError below.
20237 return ContinueSentinel;
20238 }
20239 }
20240
20241 context.method = "throw";
20242 context.arg = new TypeError(
20243 "The iterator does not provide a 'throw' method");
20244 }
20245
20246 return ContinueSentinel;
20247 }
20248
20249 var record = tryCatch(method, delegate.iterator, context.arg);
20250
20251 if (record.type === "throw") {
20252 context.method = "throw";
20253 context.arg = record.arg;
20254 context.delegate = null;
20255 return ContinueSentinel;
20256 }
20257
20258 var info = record.arg;
20259
20260 if (! info) {
20261 context.method = "throw";
20262 context.arg = new TypeError("iterator result is not an object");
20263 context.delegate = null;
20264 return ContinueSentinel;
20265 }
20266
20267 if (info.done) {
20268 // Assign the result of the finished delegate to the temporary
20269 // variable specified by delegate.resultName (see delegateYield).
20270 context[delegate.resultName] = info.value;
20271
20272 // Resume execution at the desired location (see delegateYield).
20273 context.next = delegate.nextLoc;
20274
20275 // If context.method was "throw" but the delegate handled the
20276 // exception, let the outer generator proceed normally. If
20277 // context.method was "next", forget context.arg since it has been
20278 // "consumed" by the delegate iterator. If context.method was
20279 // "return", allow the original .return call to continue in the
20280 // outer generator.
20281 if (context.method !== "return") {
20282 context.method = "next";
20283 context.arg = undefined;
20284 }
20285
20286 } else {
20287 // Re-yield the result returned by the delegate method.
20288 return info;
20289 }
20290
20291 // The delegate iterator is finished, so forget it and continue with
20292 // the outer generator.
20293 context.delegate = null;
20294 return ContinueSentinel;
20295 }
20296
20297 // Define Generator.prototype.{next,throw,return} in terms of the
20298 // unified ._invoke helper method.
20299 defineIteratorMethods(Gp);
20300
20301 Gp[toStringTagSymbol] = "Generator";
20302
20303 // A Generator should always return itself as the iterator object when the
20304 // @@iterator function is called on it. Some browsers' implementations of the
20305 // iterator prototype chain incorrectly implement this, causing the Generator
20306 // object to not be returned from this call. This ensures that doesn't happen.
20307 // See https://github.com/facebook/regenerator/issues/274 for more details.
20308 Gp[iteratorSymbol] = function() {
20309 return this;
20310 };
20311
20312 Gp.toString = function() {
20313 return "[object Generator]";
20314 };
20315
20316 function pushTryEntry(locs) {
20317 var entry = { tryLoc: locs[0] };
20318
20319 if (1 in locs) {
20320 entry.catchLoc = locs[1];
20321 }
20322
20323 if (2 in locs) {
20324 entry.finallyLoc = locs[2];
20325 entry.afterLoc = locs[3];
20326 }
20327
20328 this.tryEntries.push(entry);
20329 }
20330
20331 function resetTryEntry(entry) {
20332 var record = entry.completion || {};
20333 record.type = "normal";
20334 delete record.arg;
20335 entry.completion = record;
20336 }
20337
20338 function Context(tryLocsList) {
20339 // The root entry object (effectively a try statement without a catch
20340 // or a finally block) gives us a place to store values thrown from
20341 // locations where there is no enclosing try statement.
20342 this.tryEntries = [{ tryLoc: "root" }];
20343 tryLocsList.forEach(pushTryEntry, this);
20344 this.reset(true);
20345 }
20346
20347 runtime.keys = function(object) {
20348 var keys = [];
20349 for (var key in object) {
20350 keys.push(key);
20351 }
20352 keys.reverse();
20353
20354 // Rather than returning an object with a next method, we keep
20355 // things simple and return the next function itself.
20356 return function next() {
20357 while (keys.length) {
20358 var key = keys.pop();
20359 if (key in object) {
20360 next.value = key;
20361 next.done = false;
20362 return next;
20363 }
20364 }
20365
20366 // To avoid creating an additional object, we just hang the .value
20367 // and .done properties off the next function object itself. This
20368 // also ensures that the minifier will not anonymize the function.
20369 next.done = true;
20370 return next;
20371 };
20372 };
20373
20374 function values(iterable) {
20375 if (iterable) {
20376 var iteratorMethod = iterable[iteratorSymbol];
20377 if (iteratorMethod) {
20378 return iteratorMethod.call(iterable);
20379 }
20380
20381 if (typeof iterable.next === "function") {
20382 return iterable;
20383 }
20384
20385 if (!isNaN(iterable.length)) {
20386 var i = -1, next = function next() {
20387 while (++i < iterable.length) {
20388 if (hasOwn.call(iterable, i)) {
20389 next.value = iterable[i];
20390 next.done = false;
20391 return next;
20392 }
20393 }
20394
20395 next.value = undefined;
20396 next.done = true;
20397
20398 return next;
20399 };
20400
20401 return next.next = next;
20402 }
20403 }
20404
20405 // Return an iterator with no values.
20406 return { next: doneResult };
20407 }
20408 runtime.values = values;
20409
20410 function doneResult() {
20411 return { value: undefined, done: true };
20412 }
20413
20414 Context.prototype = {
20415 constructor: Context,
20416
20417 reset: function(skipTempReset) {
20418 this.prev = 0;
20419 this.next = 0;
20420 // Resetting context._sent for legacy support of Babel's
20421 // function.sent implementation.
20422 this.sent = this._sent = undefined;
20423 this.done = false;
20424 this.delegate = null;
20425
20426 this.method = "next";
20427 this.arg = undefined;
20428
20429 this.tryEntries.forEach(resetTryEntry);
20430
20431 if (!skipTempReset) {
20432 for (var name in this) {
20433 // Not sure about the optimal order of these conditions:
20434 if (name.charAt(0) === "t" &&
20435 hasOwn.call(this, name) &&
20436 !isNaN(+name.slice(1))) {
20437 this[name] = undefined;
20438 }
20439 }
20440 }
20441 },
20442
20443 stop: function() {
20444 this.done = true;
20445
20446 var rootEntry = this.tryEntries[0];
20447 var rootRecord = rootEntry.completion;
20448 if (rootRecord.type === "throw") {
20449 throw rootRecord.arg;
20450 }
20451
20452 return this.rval;
20453 },
20454
20455 dispatchException: function(exception) {
20456 if (this.done) {
20457 throw exception;
20458 }
20459
20460 var context = this;
20461 function handle(loc, caught) {
20462 record.type = "throw";
20463 record.arg = exception;
20464 context.next = loc;
20465
20466 if (caught) {
20467 // If the dispatched exception was caught by a catch block,
20468 // then let that catch block handle the exception normally.
20469 context.method = "next";
20470 context.arg = undefined;
20471 }
20472
20473 return !! caught;
20474 }
20475
20476 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
20477 var entry = this.tryEntries[i];
20478 var record = entry.completion;
20479
20480 if (entry.tryLoc === "root") {
20481 // Exception thrown outside of any try block that could handle
20482 // it, so set the completion value of the entire function to
20483 // throw the exception.
20484 return handle("end");
20485 }
20486
20487 if (entry.tryLoc <= this.prev) {
20488 var hasCatch = hasOwn.call(entry, "catchLoc");
20489 var hasFinally = hasOwn.call(entry, "finallyLoc");
20490
20491 if (hasCatch && hasFinally) {
20492 if (this.prev < entry.catchLoc) {
20493 return handle(entry.catchLoc, true);
20494 } else if (this.prev < entry.finallyLoc) {
20495 return handle(entry.finallyLoc);
20496 }
20497
20498 } else if (hasCatch) {
20499 if (this.prev < entry.catchLoc) {
20500 return handle(entry.catchLoc, true);
20501 }
20502
20503 } else if (hasFinally) {
20504 if (this.prev < entry.finallyLoc) {
20505 return handle(entry.finallyLoc);
20506 }
20507
20508 } else {
20509 throw new Error("try statement without catch or finally");
20510 }
20511 }
20512 }
20513 },
20514
20515 abrupt: function(type, arg) {
20516 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
20517 var entry = this.tryEntries[i];
20518 if (entry.tryLoc <= this.prev &&
20519 hasOwn.call(entry, "finallyLoc") &&
20520 this.prev < entry.finallyLoc) {
20521 var finallyEntry = entry;
20522 break;
20523 }
20524 }
20525
20526 if (finallyEntry &&
20527 (type === "break" ||
20528 type === "continue") &&
20529 finallyEntry.tryLoc <= arg &&
20530 arg <= finallyEntry.finallyLoc) {
20531 // Ignore the finally entry if control is not jumping to a
20532 // location outside the try/catch block.
20533 finallyEntry = null;
20534 }
20535
20536 var record = finallyEntry ? finallyEntry.completion : {};
20537 record.type = type;
20538 record.arg = arg;
20539
20540 if (finallyEntry) {
20541 this.method = "next";
20542 this.next = finallyEntry.finallyLoc;
20543 return ContinueSentinel;
20544 }
20545
20546 return this.complete(record);
20547 },
20548
20549 complete: function(record, afterLoc) {
20550 if (record.type === "throw") {
20551 throw record.arg;
20552 }
20553
20554 if (record.type === "break" ||
20555 record.type === "continue") {
20556 this.next = record.arg;
20557 } else if (record.type === "return") {
20558 this.rval = this.arg = record.arg;
20559 this.method = "return";
20560 this.next = "end";
20561 } else if (record.type === "normal" && afterLoc) {
20562 this.next = afterLoc;
20563 }
20564
20565 return ContinueSentinel;
20566 },
20567
20568 finish: function(finallyLoc) {
20569 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
20570 var entry = this.tryEntries[i];
20571 if (entry.finallyLoc === finallyLoc) {
20572 this.complete(entry.completion, entry.afterLoc);
20573 resetTryEntry(entry);
20574 return ContinueSentinel;
20575 }
20576 }
20577 },
20578
20579 "catch": function(tryLoc) {
20580 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
20581 var entry = this.tryEntries[i];
20582 if (entry.tryLoc === tryLoc) {
20583 var record = entry.completion;
20584 if (record.type === "throw") {
20585 var thrown = record.arg;
20586 resetTryEntry(entry);
20587 }
20588 return thrown;
20589 }
20590 }
20591
20592 // The context.catch method must only be called with a location
20593 // argument that corresponds to a known catch block.
20594 throw new Error("illegal catch attempt");
20595 },
20596
20597 delegateYield: function(iterable, resultName, nextLoc) {
20598 this.delegate = {
20599 iterator: values(iterable),
20600 resultName: resultName,
20601 nextLoc: nextLoc
20602 };
20603
20604 if (this.method === "next") {
20605 // Deliberately forget the last sent value so that we don't
20606 // accidentally pass it on to the delegate.
20607 this.arg = undefined;
20608 }
20609
20610 return ContinueSentinel;
20611 }
20612 };
20613})(
20614 // In sloppy mode, unbound `this` refers to the global object, fallback to
20615 // Function constructor if we're in global strict mode. That is sadly a form
20616 // of indirect eval which violates Content Security Policy.
20617 (function() { return this })() || Function("return this")()
20618);
20619
20620},{}],269:[function(require,module,exports){
20621/* eslint-disable node/no-deprecated-api */
20622var buffer = require('buffer')
20623var Buffer = buffer.Buffer
20624
20625// alternative to using Object.keys for old browsers
20626function copyProps (src, dst) {
20627 for (var key in src) {
20628 dst[key] = src[key]
20629 }
20630}
20631if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
20632 module.exports = buffer
20633} else {
20634 // Copy properties from require('buffer')
20635 copyProps(buffer, exports)
20636 exports.Buffer = SafeBuffer
20637}
20638
20639function SafeBuffer (arg, encodingOrOffset, length) {
20640 return Buffer(arg, encodingOrOffset, length)
20641}
20642
20643// Copy static methods from Buffer
20644copyProps(Buffer, SafeBuffer)
20645
20646SafeBuffer.from = function (arg, encodingOrOffset, length) {
20647 if (typeof arg === 'number') {
20648 throw new TypeError('Argument must not be a number')
20649 }
20650 return Buffer(arg, encodingOrOffset, length)
20651}
20652
20653SafeBuffer.alloc = function (size, fill, encoding) {
20654 if (typeof size !== 'number') {
20655 throw new TypeError('Argument must be a number')
20656 }
20657 var buf = Buffer(size)
20658 if (fill !== undefined) {
20659 if (typeof encoding === 'string') {
20660 buf.fill(fill, encoding)
20661 } else {
20662 buf.fill(fill)
20663 }
20664 } else {
20665 buf.fill(0)
20666 }
20667 return buf
20668}
20669
20670SafeBuffer.allocUnsafe = function (size) {
20671 if (typeof size !== 'number') {
20672 throw new TypeError('Argument must be a number')
20673 }
20674 return Buffer(size)
20675}
20676
20677SafeBuffer.allocUnsafeSlow = function (size) {
20678 if (typeof size !== 'number') {
20679 throw new TypeError('Argument must be a number')
20680 }
20681 return buffer.SlowBuffer(size)
20682}
20683
20684},{"buffer":70}],270:[function(require,module,exports){
20685(function (Buffer){
20686'use strict';
20687
20688var _fromCodePoint = require('babel-runtime/core-js/string/from-code-point');
20689
20690var _fromCodePoint2 = _interopRequireDefault(_fromCodePoint);
20691
20692var _stringify = require('babel-runtime/core-js/json/stringify');
20693
20694var _stringify2 = _interopRequireDefault(_stringify);
20695
20696var _typeof2 = require('babel-runtime/helpers/typeof');
20697
20698var _typeof3 = _interopRequireDefault(_typeof2);
20699
20700var _defineProperty = require('babel-runtime/core-js/object/define-property');
20701
20702var _defineProperty2 = _interopRequireDefault(_defineProperty);
20703
20704var _keys = require('babel-runtime/core-js/object/keys');
20705
20706var _keys2 = _interopRequireDefault(_keys);
20707
20708var _create = require('babel-runtime/core-js/object/create');
20709
20710var _create2 = _interopRequireDefault(_create);
20711
20712function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20713
20714;(function (sax) {
20715 // wrapper for non-node envs
20716 sax.parser = function (strict, opt) {
20717 return new SAXParser(strict, opt);
20718 };
20719 sax.SAXParser = SAXParser;
20720 sax.SAXStream = SAXStream;
20721 sax.createStream = createStream;
20722
20723 // When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns.
20724 // When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)),
20725 // since that's the earliest that a buffer overrun could occur. This way, checks are
20726 // as rare as required, but as often as necessary to ensure never crossing this bound.
20727 // Furthermore, buffers are only tested at most once per write(), so passing a very
20728 // large string into write() might have undesirable effects, but this is manageable by
20729 // the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme
20730 // edge case, result in creating at most one complete copy of the string passed in.
20731 // Set to Infinity to have unlimited buffers.
20732 sax.MAX_BUFFER_LENGTH = 64 * 1024;
20733
20734 var buffers = ['comment', 'sgmlDecl', 'textNode', 'tagName', 'doctype', 'procInstName', 'procInstBody', 'entity', 'attribName', 'attribValue', 'cdata', 'script'];
20735
20736 sax.EVENTS = ['text', 'processinginstruction', 'sgmldeclaration', 'doctype', 'comment', 'opentagstart', 'attribute', 'opentag', 'closetag', 'opencdata', 'cdata', 'closecdata', 'error', 'end', 'ready', 'script', 'opennamespace', 'closenamespace'];
20737
20738 function SAXParser(strict, opt) {
20739 if (!(this instanceof SAXParser)) {
20740 return new SAXParser(strict, opt);
20741 }
20742
20743 var parser = this;
20744 clearBuffers(parser);
20745 parser.q = parser.c = '';
20746 parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH;
20747 parser.opt = opt || {};
20748 parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags;
20749 parser.looseCase = parser.opt.lowercase ? 'toLowerCase' : 'toUpperCase';
20750 parser.tags = [];
20751 parser.closed = parser.closedRoot = parser.sawRoot = false;
20752 parser.tag = parser.error = null;
20753 parser.strict = !!strict;
20754 parser.noscript = !!(strict || parser.opt.noscript);
20755 parser.state = S.BEGIN;
20756 parser.strictEntities = parser.opt.strictEntities;
20757 parser.ENTITIES = parser.strictEntities ? (0, _create2.default)(sax.XML_ENTITIES) : (0, _create2.default)(sax.ENTITIES);
20758 parser.attribList = [];
20759
20760 // namespaces form a prototype chain.
20761 // it always points at the current tag,
20762 // which protos to its parent tag.
20763 if (parser.opt.xmlns) {
20764 parser.ns = (0, _create2.default)(rootNS);
20765 }
20766
20767 // mostly just for error reporting
20768 parser.trackPosition = parser.opt.position !== false;
20769 if (parser.trackPosition) {
20770 parser.position = parser.line = parser.column = 0;
20771 }
20772 emit(parser, 'onready');
20773 }
20774
20775 if (!_create2.default) {
20776 Object.create = function (o) {
20777 function F() {}
20778 F.prototype = o;
20779 var newf = new F();
20780 return newf;
20781 };
20782 }
20783
20784 if (!_keys2.default) {
20785 Object.keys = function (o) {
20786 var a = [];
20787 for (var i in o) {
20788 if (o.hasOwnProperty(i)) a.push(i);
20789 }return a;
20790 };
20791 }
20792
20793 function checkBufferLength(parser) {
20794 var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10);
20795 var maxActual = 0;
20796 for (var i = 0, l = buffers.length; i < l; i++) {
20797 var len = parser[buffers[i]].length;
20798 if (len > maxAllowed) {
20799 // Text/cdata nodes can get big, and since they're buffered,
20800 // we can get here under normal conditions.
20801 // Avoid issues by emitting the text node now,
20802 // so at least it won't get any bigger.
20803 switch (buffers[i]) {
20804 case 'textNode':
20805 closeText(parser);
20806 break;
20807
20808 case 'cdata':
20809 emitNode(parser, 'oncdata', parser.cdata);
20810 parser.cdata = '';
20811 break;
20812
20813 case 'script':
20814 emitNode(parser, 'onscript', parser.script);
20815 parser.script = '';
20816 break;
20817
20818 default:
20819 error(parser, 'Max buffer length exceeded: ' + buffers[i]);
20820 }
20821 }
20822 maxActual = Math.max(maxActual, len);
20823 }
20824 // schedule the next check for the earliest possible buffer overrun.
20825 var m = sax.MAX_BUFFER_LENGTH - maxActual;
20826 parser.bufferCheckPosition = m + parser.position;
20827 }
20828
20829 function clearBuffers(parser) {
20830 for (var i = 0, l = buffers.length; i < l; i++) {
20831 parser[buffers[i]] = '';
20832 }
20833 }
20834
20835 function flushBuffers(parser) {
20836 closeText(parser);
20837 if (parser.cdata !== '') {
20838 emitNode(parser, 'oncdata', parser.cdata);
20839 parser.cdata = '';
20840 }
20841 if (parser.script !== '') {
20842 emitNode(parser, 'onscript', parser.script);
20843 parser.script = '';
20844 }
20845 }
20846
20847 SAXParser.prototype = {
20848 end: function end() {
20849 _end(this);
20850 },
20851 write: write,
20852 resume: function resume() {
20853 this.error = null;return this;
20854 },
20855 close: function close() {
20856 return this.write(null);
20857 },
20858 flush: function flush() {
20859 flushBuffers(this);
20860 }
20861 };
20862
20863 var Stream;
20864 try {
20865 Stream = require('stream').Stream;
20866 } catch (ex) {
20867 Stream = function Stream() {};
20868 }
20869
20870 var streamWraps = sax.EVENTS.filter(function (ev) {
20871 return ev !== 'error' && ev !== 'end';
20872 });
20873
20874 function createStream(strict, opt) {
20875 return new SAXStream(strict, opt);
20876 }
20877
20878 function SAXStream(strict, opt) {
20879 if (!(this instanceof SAXStream)) {
20880 return new SAXStream(strict, opt);
20881 }
20882
20883 Stream.apply(this);
20884
20885 this._parser = new SAXParser(strict, opt);
20886 this.writable = true;
20887 this.readable = true;
20888
20889 var me = this;
20890
20891 this._parser.onend = function () {
20892 me.emit('end');
20893 };
20894
20895 this._parser.onerror = function (er) {
20896 me.emit('error', er);
20897
20898 // if didn't throw, then means error was handled.
20899 // go ahead and clear error, so we can write again.
20900 me._parser.error = null;
20901 };
20902
20903 this._decoder = null;
20904
20905 streamWraps.forEach(function (ev) {
20906 (0, _defineProperty2.default)(me, 'on' + ev, {
20907 get: function get() {
20908 return me._parser['on' + ev];
20909 },
20910 set: function set(h) {
20911 if (!h) {
20912 me.removeAllListeners(ev);
20913 me._parser['on' + ev] = h;
20914 return h;
20915 }
20916 me.on(ev, h);
20917 },
20918 enumerable: true,
20919 configurable: false
20920 });
20921 });
20922 }
20923
20924 SAXStream.prototype = (0, _create2.default)(Stream.prototype, {
20925 constructor: {
20926 value: SAXStream
20927 }
20928 });
20929
20930 SAXStream.prototype.write = function (data) {
20931 if (typeof Buffer === 'function' && typeof Buffer.isBuffer === 'function' && Buffer.isBuffer(data)) {
20932 if (!this._decoder) {
20933 var SD = require('string_decoder').StringDecoder;
20934 this._decoder = new SD('utf8');
20935 }
20936 data = this._decoder.write(data);
20937 }
20938
20939 this._parser.write(data.toString());
20940 this.emit('data', data);
20941 return true;
20942 };
20943
20944 SAXStream.prototype.end = function (chunk) {
20945 if (chunk && chunk.length) {
20946 this.write(chunk);
20947 }
20948 this._parser.end();
20949 return true;
20950 };
20951
20952 SAXStream.prototype.on = function (ev, handler) {
20953 var me = this;
20954 if (!me._parser['on' + ev] && streamWraps.indexOf(ev) !== -1) {
20955 me._parser['on' + ev] = function () {
20956 var args = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments);
20957 args.splice(0, 0, ev);
20958 me.emit.apply(me, args);
20959 };
20960 }
20961
20962 return Stream.prototype.on.call(me, ev, handler);
20963 };
20964
20965 // this really needs to be replaced with character classes.
20966 // XML allows all manner of ridiculous numbers and digits.
20967 var CDATA = '[CDATA[';
20968 var DOCTYPE = 'DOCTYPE';
20969 var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
20970 var XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/';
20971 var rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE
20972
20973 // http://www.w3.org/TR/REC-xml/#NT-NameStartChar
20974 // This implementation works on strings, a single character at a time
20975 // as such, it cannot ever support astral-plane characters (10000-EFFFF)
20976 // without a significant breaking change to either this parser, or the
20977 // JavaScript language. Implementation of an emoji-capable xml parser
20978 // is left as an exercise for the reader.
20979 };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]/;
20980
20981 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-]/;
20982
20983 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]/;
20984 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-]/;
20985
20986 function isWhitespace(c) {
20987 return c === ' ' || c === '\n' || c === '\r' || c === '\t';
20988 }
20989
20990 function isQuote(c) {
20991 return c === '"' || c === '\'';
20992 }
20993
20994 function isAttribEnd(c) {
20995 return c === '>' || isWhitespace(c);
20996 }
20997
20998 function isMatch(regex, c) {
20999 return regex.test(c);
21000 }
21001
21002 function notMatch(regex, c) {
21003 return !isMatch(regex, c);
21004 }
21005
21006 var S = 0;
21007 sax.STATE = {
21008 BEGIN: S++, // leading byte order mark or whitespace
21009 BEGIN_WHITESPACE: S++, // leading whitespace
21010 TEXT: S++, // general stuff
21011 TEXT_ENTITY: S++, // &amp and such.
21012 OPEN_WAKA: S++, // <
21013 SGML_DECL: S++, // <!BLARG
21014 SGML_DECL_QUOTED: S++, // <!BLARG foo "bar
21015 DOCTYPE: S++, // <!DOCTYPE
21016 DOCTYPE_QUOTED: S++, // <!DOCTYPE "//blah
21017 DOCTYPE_DTD: S++, // <!DOCTYPE "//blah" [ ...
21018 DOCTYPE_DTD_QUOTED: S++, // <!DOCTYPE "//blah" [ "foo
21019 COMMENT_STARTING: S++, // <!-
21020 COMMENT: S++, // <!--
21021 COMMENT_ENDING: S++, // <!-- blah -
21022 COMMENT_ENDED: S++, // <!-- blah --
21023 CDATA: S++, // <![CDATA[ something
21024 CDATA_ENDING: S++, // ]
21025 CDATA_ENDING_2: S++, // ]]
21026 PROC_INST: S++, // <?hi
21027 PROC_INST_BODY: S++, // <?hi there
21028 PROC_INST_ENDING: S++, // <?hi "there" ?
21029 OPEN_TAG: S++, // <strong
21030 OPEN_TAG_SLASH: S++, // <strong /
21031 ATTRIB: S++, // <a
21032 ATTRIB_NAME: S++, // <a foo
21033 ATTRIB_NAME_SAW_WHITE: S++, // <a foo _
21034 ATTRIB_VALUE: S++, // <a foo=
21035 ATTRIB_VALUE_QUOTED: S++, // <a foo="bar
21036 ATTRIB_VALUE_CLOSED: S++, // <a foo="bar"
21037 ATTRIB_VALUE_UNQUOTED: S++, // <a foo=bar
21038 ATTRIB_VALUE_ENTITY_Q: S++, // <foo bar="&quot;"
21039 ATTRIB_VALUE_ENTITY_U: S++, // <foo bar=&quot
21040 CLOSE_TAG: S++, // </a
21041 CLOSE_TAG_SAW_WHITE: S++, // </a >
21042 SCRIPT: S++, // <script> ...
21043 SCRIPT_ENDING: S++ // <script> ... <
21044 };
21045
21046 sax.XML_ENTITIES = {
21047 'amp': '&',
21048 'gt': '>',
21049 'lt': '<',
21050 'quot': '"',
21051 'apos': "'"
21052 };
21053
21054 sax.ENTITIES = {
21055 'amp': '&',
21056 'gt': '>',
21057 'lt': '<',
21058 'quot': '"',
21059 'apos': "'",
21060 'AElig': 198,
21061 'Aacute': 193,
21062 'Acirc': 194,
21063 'Agrave': 192,
21064 'Aring': 197,
21065 'Atilde': 195,
21066 'Auml': 196,
21067 'Ccedil': 199,
21068 'ETH': 208,
21069 'Eacute': 201,
21070 'Ecirc': 202,
21071 'Egrave': 200,
21072 'Euml': 203,
21073 'Iacute': 205,
21074 'Icirc': 206,
21075 'Igrave': 204,
21076 'Iuml': 207,
21077 'Ntilde': 209,
21078 'Oacute': 211,
21079 'Ocirc': 212,
21080 'Ograve': 210,
21081 'Oslash': 216,
21082 'Otilde': 213,
21083 'Ouml': 214,
21084 'THORN': 222,
21085 'Uacute': 218,
21086 'Ucirc': 219,
21087 'Ugrave': 217,
21088 'Uuml': 220,
21089 'Yacute': 221,
21090 'aacute': 225,
21091 'acirc': 226,
21092 'aelig': 230,
21093 'agrave': 224,
21094 'aring': 229,
21095 'atilde': 227,
21096 'auml': 228,
21097 'ccedil': 231,
21098 'eacute': 233,
21099 'ecirc': 234,
21100 'egrave': 232,
21101 'eth': 240,
21102 'euml': 235,
21103 'iacute': 237,
21104 'icirc': 238,
21105 'igrave': 236,
21106 'iuml': 239,
21107 'ntilde': 241,
21108 'oacute': 243,
21109 'ocirc': 244,
21110 'ograve': 242,
21111 'oslash': 248,
21112 'otilde': 245,
21113 'ouml': 246,
21114 'szlig': 223,
21115 'thorn': 254,
21116 'uacute': 250,
21117 'ucirc': 251,
21118 'ugrave': 249,
21119 'uuml': 252,
21120 'yacute': 253,
21121 'yuml': 255,
21122 'copy': 169,
21123 'reg': 174,
21124 'nbsp': 160,
21125 'iexcl': 161,
21126 'cent': 162,
21127 'pound': 163,
21128 'curren': 164,
21129 'yen': 165,
21130 'brvbar': 166,
21131 'sect': 167,
21132 'uml': 168,
21133 'ordf': 170,
21134 'laquo': 171,
21135 'not': 172,
21136 'shy': 173,
21137 'macr': 175,
21138 'deg': 176,
21139 'plusmn': 177,
21140 'sup1': 185,
21141 'sup2': 178,
21142 'sup3': 179,
21143 'acute': 180,
21144 'micro': 181,
21145 'para': 182,
21146 'middot': 183,
21147 'cedil': 184,
21148 'ordm': 186,
21149 'raquo': 187,
21150 'frac14': 188,
21151 'frac12': 189,
21152 'frac34': 190,
21153 'iquest': 191,
21154 'times': 215,
21155 'divide': 247,
21156 'OElig': 338,
21157 'oelig': 339,
21158 'Scaron': 352,
21159 'scaron': 353,
21160 'Yuml': 376,
21161 'fnof': 402,
21162 'circ': 710,
21163 'tilde': 732,
21164 'Alpha': 913,
21165 'Beta': 914,
21166 'Gamma': 915,
21167 'Delta': 916,
21168 'Epsilon': 917,
21169 'Zeta': 918,
21170 'Eta': 919,
21171 'Theta': 920,
21172 'Iota': 921,
21173 'Kappa': 922,
21174 'Lambda': 923,
21175 'Mu': 924,
21176 'Nu': 925,
21177 'Xi': 926,
21178 'Omicron': 927,
21179 'Pi': 928,
21180 'Rho': 929,
21181 'Sigma': 931,
21182 'Tau': 932,
21183 'Upsilon': 933,
21184 'Phi': 934,
21185 'Chi': 935,
21186 'Psi': 936,
21187 'Omega': 937,
21188 'alpha': 945,
21189 'beta': 946,
21190 'gamma': 947,
21191 'delta': 948,
21192 'epsilon': 949,
21193 'zeta': 950,
21194 'eta': 951,
21195 'theta': 952,
21196 'iota': 953,
21197 'kappa': 954,
21198 'lambda': 955,
21199 'mu': 956,
21200 'nu': 957,
21201 'xi': 958,
21202 'omicron': 959,
21203 'pi': 960,
21204 'rho': 961,
21205 'sigmaf': 962,
21206 'sigma': 963,
21207 'tau': 964,
21208 'upsilon': 965,
21209 'phi': 966,
21210 'chi': 967,
21211 'psi': 968,
21212 'omega': 969,
21213 'thetasym': 977,
21214 'upsih': 978,
21215 'piv': 982,
21216 'ensp': 8194,
21217 'emsp': 8195,
21218 'thinsp': 8201,
21219 'zwnj': 8204,
21220 'zwj': 8205,
21221 'lrm': 8206,
21222 'rlm': 8207,
21223 'ndash': 8211,
21224 'mdash': 8212,
21225 'lsquo': 8216,
21226 'rsquo': 8217,
21227 'sbquo': 8218,
21228 'ldquo': 8220,
21229 'rdquo': 8221,
21230 'bdquo': 8222,
21231 'dagger': 8224,
21232 'Dagger': 8225,
21233 'bull': 8226,
21234 'hellip': 8230,
21235 'permil': 8240,
21236 'prime': 8242,
21237 'Prime': 8243,
21238 'lsaquo': 8249,
21239 'rsaquo': 8250,
21240 'oline': 8254,
21241 'frasl': 8260,
21242 'euro': 8364,
21243 'image': 8465,
21244 'weierp': 8472,
21245 'real': 8476,
21246 'trade': 8482,
21247 'alefsym': 8501,
21248 'larr': 8592,
21249 'uarr': 8593,
21250 'rarr': 8594,
21251 'darr': 8595,
21252 'harr': 8596,
21253 'crarr': 8629,
21254 'lArr': 8656,
21255 'uArr': 8657,
21256 'rArr': 8658,
21257 'dArr': 8659,
21258 'hArr': 8660,
21259 'forall': 8704,
21260 'part': 8706,
21261 'exist': 8707,
21262 'empty': 8709,
21263 'nabla': 8711,
21264 'isin': 8712,
21265 'notin': 8713,
21266 'ni': 8715,
21267 'prod': 8719,
21268 'sum': 8721,
21269 'minus': 8722,
21270 'lowast': 8727,
21271 'radic': 8730,
21272 'prop': 8733,
21273 'infin': 8734,
21274 'ang': 8736,
21275 'and': 8743,
21276 'or': 8744,
21277 'cap': 8745,
21278 'cup': 8746,
21279 'int': 8747,
21280 'there4': 8756,
21281 'sim': 8764,
21282 'cong': 8773,
21283 'asymp': 8776,
21284 'ne': 8800,
21285 'equiv': 8801,
21286 'le': 8804,
21287 'ge': 8805,
21288 'sub': 8834,
21289 'sup': 8835,
21290 'nsub': 8836,
21291 'sube': 8838,
21292 'supe': 8839,
21293 'oplus': 8853,
21294 'otimes': 8855,
21295 'perp': 8869,
21296 'sdot': 8901,
21297 'lceil': 8968,
21298 'rceil': 8969,
21299 'lfloor': 8970,
21300 'rfloor': 8971,
21301 'lang': 9001,
21302 'rang': 9002,
21303 'loz': 9674,
21304 'spades': 9824,
21305 'clubs': 9827,
21306 'hearts': 9829,
21307 'diams': 9830
21308 };
21309
21310 (0, _keys2.default)(sax.ENTITIES).forEach(function (key) {
21311 var e = sax.ENTITIES[key];
21312 var s = typeof e === 'number' ? String.fromCharCode(e) : e;
21313 sax.ENTITIES[key] = s;
21314 });
21315
21316 for (var s in sax.STATE) {
21317 sax.STATE[sax.STATE[s]] = s;
21318 }
21319
21320 // shorthand
21321 S = sax.STATE;
21322
21323 function emit(parser, event, data) {
21324 parser[event] && parser[event](data);
21325 }
21326
21327 function emitNode(parser, nodeType, data) {
21328 if (parser.textNode) closeText(parser);
21329 emit(parser, nodeType, data);
21330 }
21331
21332 function closeText(parser) {
21333 parser.textNode = textopts(parser.opt, parser.textNode);
21334 if (parser.textNode) emit(parser, 'ontext', parser.textNode);
21335 parser.textNode = '';
21336 }
21337
21338 function textopts(opt, text) {
21339 if (opt.trim) text = text.trim();
21340 if (opt.normalize) text = text.replace(/\s+/g, ' ');
21341 return text;
21342 }
21343
21344 function error(parser, er) {
21345 closeText(parser);
21346 if (parser.trackPosition) {
21347 er += '\nLine: ' + parser.line + '\nColumn: ' + parser.column + '\nChar: ' + parser.c;
21348 }
21349 er = new Error(er);
21350 parser.error = er;
21351 emit(parser, 'onerror', er);
21352 return parser;
21353 }
21354
21355 function _end(parser) {
21356 if (parser.sawRoot && !parser.closedRoot) strictFail(parser, 'Unclosed root tag');
21357 if (parser.state !== S.BEGIN && parser.state !== S.BEGIN_WHITESPACE && parser.state !== S.TEXT) {
21358 error(parser, 'Unexpected end');
21359 }
21360 closeText(parser);
21361 parser.c = '';
21362 parser.closed = true;
21363 emit(parser, 'onend');
21364 SAXParser.call(parser, parser.strict, parser.opt);
21365 return parser;
21366 }
21367
21368 function strictFail(parser, message) {
21369 if ((typeof parser === 'undefined' ? 'undefined' : (0, _typeof3.default)(parser)) !== 'object' || !(parser instanceof SAXParser)) {
21370 throw new Error('bad call to strictFail');
21371 }
21372 if (parser.strict) {
21373 error(parser, message);
21374 }
21375 }
21376
21377 function newTag(parser) {
21378 if (!parser.strict) parser.tagName = parser.tagName[parser.looseCase]();
21379 var parent = parser.tags[parser.tags.length - 1] || parser;
21380 var tag = parser.tag = { name: parser.tagName, attributes: {}
21381
21382 // will be overridden if tag contails an xmlns="foo" or xmlns:foo="bar"
21383 };if (parser.opt.xmlns) {
21384 tag.ns = parent.ns;
21385 }
21386 parser.attribList.length = 0;
21387 emitNode(parser, 'onopentagstart', tag);
21388 }
21389
21390 function qname(name, attribute) {
21391 var i = name.indexOf(':');
21392 var qualName = i < 0 ? ['', name] : name.split(':');
21393 var prefix = qualName[0];
21394 var local = qualName[1];
21395
21396 // <x "xmlns"="http://foo">
21397 if (attribute && name === 'xmlns') {
21398 prefix = 'xmlns';
21399 local = '';
21400 }
21401
21402 return { prefix: prefix, local: local };
21403 }
21404
21405 function attrib(parser) {
21406 if (!parser.strict) {
21407 parser.attribName = parser.attribName[parser.looseCase]();
21408 }
21409
21410 if (parser.attribList.indexOf(parser.attribName) !== -1 || parser.tag.attributes.hasOwnProperty(parser.attribName)) {
21411 parser.attribName = parser.attribValue = '';
21412 return;
21413 }
21414
21415 if (parser.opt.xmlns) {
21416 var qn = qname(parser.attribName, true);
21417 var prefix = qn.prefix;
21418 var local = qn.local;
21419
21420 if (prefix === 'xmlns') {
21421 // namespace binding attribute. push the binding into scope
21422 if (local === 'xml' && parser.attribValue !== XML_NAMESPACE) {
21423 strictFail(parser, 'xml: prefix must be bound to ' + XML_NAMESPACE + '\n' + 'Actual: ' + parser.attribValue);
21424 } else if (local === 'xmlns' && parser.attribValue !== XMLNS_NAMESPACE) {
21425 strictFail(parser, 'xmlns: prefix must be bound to ' + XMLNS_NAMESPACE + '\n' + 'Actual: ' + parser.attribValue);
21426 } else {
21427 var tag = parser.tag;
21428 var parent = parser.tags[parser.tags.length - 1] || parser;
21429 if (tag.ns === parent.ns) {
21430 tag.ns = (0, _create2.default)(parent.ns);
21431 }
21432 tag.ns[local] = parser.attribValue;
21433 }
21434 }
21435
21436 // defer onattribute events until all attributes have been seen
21437 // so any new bindings can take effect. preserve attribute order
21438 // so deferred events can be emitted in document order
21439 parser.attribList.push([parser.attribName, parser.attribValue]);
21440 } else {
21441 // in non-xmlns mode, we can emit the event right away
21442 parser.tag.attributes[parser.attribName] = parser.attribValue;
21443 emitNode(parser, 'onattribute', {
21444 name: parser.attribName,
21445 value: parser.attribValue
21446 });
21447 }
21448
21449 parser.attribName = parser.attribValue = '';
21450 }
21451
21452 function openTag(parser, selfClosing) {
21453 if (parser.opt.xmlns) {
21454 // emit namespace binding events
21455 var tag = parser.tag;
21456
21457 // add namespace info to tag
21458 var qn = qname(parser.tagName);
21459 tag.prefix = qn.prefix;
21460 tag.local = qn.local;
21461 tag.uri = tag.ns[qn.prefix] || '';
21462
21463 if (tag.prefix && !tag.uri) {
21464 strictFail(parser, 'Unbound namespace prefix: ' + (0, _stringify2.default)(parser.tagName));
21465 tag.uri = qn.prefix;
21466 }
21467
21468 var parent = parser.tags[parser.tags.length - 1] || parser;
21469 if (tag.ns && parent.ns !== tag.ns) {
21470 (0, _keys2.default)(tag.ns).forEach(function (p) {
21471 emitNode(parser, 'onopennamespace', {
21472 prefix: p,
21473 uri: tag.ns[p]
21474 });
21475 });
21476 }
21477
21478 // handle deferred onattribute events
21479 // Note: do not apply default ns to attributes:
21480 // http://www.w3.org/TR/REC-xml-names/#defaulting
21481 for (var i = 0, l = parser.attribList.length; i < l; i++) {
21482 var nv = parser.attribList[i];
21483 var name = nv[0];
21484 var value = nv[1];
21485 var qualName = qname(name, true);
21486 var prefix = qualName.prefix;
21487 var local = qualName.local;
21488 var uri = prefix === '' ? '' : tag.ns[prefix] || '';
21489 var a = {
21490 name: name,
21491 value: value,
21492 prefix: prefix,
21493 local: local,
21494 uri: uri
21495
21496 // if there's any attributes with an undefined namespace,
21497 // then fail on them now.
21498 };if (prefix && prefix !== 'xmlns' && !uri) {
21499 strictFail(parser, 'Unbound namespace prefix: ' + (0, _stringify2.default)(prefix));
21500 a.uri = prefix;
21501 }
21502 parser.tag.attributes[name] = a;
21503 emitNode(parser, 'onattribute', a);
21504 }
21505 parser.attribList.length = 0;
21506 }
21507
21508 parser.tag.isSelfClosing = !!selfClosing;
21509
21510 // process the tag
21511 parser.sawRoot = true;
21512 parser.tags.push(parser.tag);
21513 emitNode(parser, 'onopentag', parser.tag);
21514 if (!selfClosing) {
21515 // special case for <script> in non-strict mode.
21516 if (!parser.noscript && parser.tagName.toLowerCase() === 'script') {
21517 parser.state = S.SCRIPT;
21518 } else {
21519 parser.state = S.TEXT;
21520 }
21521 parser.tag = null;
21522 parser.tagName = '';
21523 }
21524 parser.attribName = parser.attribValue = '';
21525 parser.attribList.length = 0;
21526 }
21527
21528 function closeTag(parser) {
21529 if (!parser.tagName) {
21530 strictFail(parser, 'Weird empty close tag.');
21531 parser.textNode += '</>';
21532 parser.state = S.TEXT;
21533 return;
21534 }
21535
21536 if (parser.script) {
21537 if (parser.tagName !== 'script') {
21538 parser.script += '</' + parser.tagName + '>';
21539 parser.tagName = '';
21540 parser.state = S.SCRIPT;
21541 return;
21542 }
21543 emitNode(parser, 'onscript', parser.script);
21544 parser.script = '';
21545 }
21546
21547 // first make sure that the closing tag actually exists.
21548 // <a><b></c></b></a> will close everything, otherwise.
21549 var t = parser.tags.length;
21550 var tagName = parser.tagName;
21551 if (!parser.strict) {
21552 tagName = tagName[parser.looseCase]();
21553 }
21554 var closeTo = tagName;
21555 while (t--) {
21556 var close = parser.tags[t];
21557 if (close.name !== closeTo) {
21558 // fail the first time in strict mode
21559 strictFail(parser, 'Unexpected close tag');
21560 } else {
21561 break;
21562 }
21563 }
21564
21565 // didn't find it. we already failed for strict, so just abort.
21566 if (t < 0) {
21567 strictFail(parser, 'Unmatched closing tag: ' + parser.tagName);
21568 parser.textNode += '</' + parser.tagName + '>';
21569 parser.state = S.TEXT;
21570 return;
21571 }
21572 parser.tagName = tagName;
21573 var s = parser.tags.length;
21574 while (s-- > t) {
21575 var tag = parser.tag = parser.tags.pop();
21576 parser.tagName = parser.tag.name;
21577 emitNode(parser, 'onclosetag', parser.tagName);
21578
21579 var x = {};
21580 for (var i in tag.ns) {
21581 x[i] = tag.ns[i];
21582 }
21583
21584 var parent = parser.tags[parser.tags.length - 1] || parser;
21585 if (parser.opt.xmlns && tag.ns !== parent.ns) {
21586 // remove namespace bindings introduced by tag
21587 (0, _keys2.default)(tag.ns).forEach(function (p) {
21588 var n = tag.ns[p];
21589 emitNode(parser, 'onclosenamespace', { prefix: p, uri: n });
21590 });
21591 }
21592 }
21593 if (t === 0) parser.closedRoot = true;
21594 parser.tagName = parser.attribValue = parser.attribName = '';
21595 parser.attribList.length = 0;
21596 parser.state = S.TEXT;
21597 }
21598
21599 function parseEntity(parser) {
21600 var entity = parser.entity;
21601 var entityLC = entity.toLowerCase();
21602 var num;
21603 var numStr = '';
21604
21605 if (parser.ENTITIES[entity]) {
21606 return parser.ENTITIES[entity];
21607 }
21608 if (parser.ENTITIES[entityLC]) {
21609 return parser.ENTITIES[entityLC];
21610 }
21611 entity = entityLC;
21612 if (entity.charAt(0) === '#') {
21613 if (entity.charAt(1) === 'x') {
21614 entity = entity.slice(2);
21615 num = parseInt(entity, 16);
21616 numStr = num.toString(16);
21617 } else {
21618 entity = entity.slice(1);
21619 num = parseInt(entity, 10);
21620 numStr = num.toString(10);
21621 }
21622 }
21623 entity = entity.replace(/^0+/, '');
21624 if (isNaN(num) || numStr.toLowerCase() !== entity) {
21625 strictFail(parser, 'Invalid character entity');
21626 return '&' + parser.entity + ';';
21627 }
21628
21629 return (0, _fromCodePoint2.default)(num);
21630 }
21631
21632 function beginWhiteSpace(parser, c) {
21633 if (c === '<') {
21634 parser.state = S.OPEN_WAKA;
21635 parser.startTagPosition = parser.position;
21636 } else if (!isWhitespace(c)) {
21637 // have to process this as a text node.
21638 // weird, but happens.
21639 strictFail(parser, 'Non-whitespace before first tag.');
21640 parser.textNode = c;
21641 parser.state = S.TEXT;
21642 }
21643 }
21644
21645 function charAt(chunk, i) {
21646 var result = '';
21647 if (i < chunk.length) {
21648 result = chunk.charAt(i);
21649 }
21650 return result;
21651 }
21652
21653 function write(chunk) {
21654 var parser = this;
21655 if (this.error) {
21656 throw this.error;
21657 }
21658 if (parser.closed) {
21659 return error(parser, 'Cannot write after close. Assign an onready handler.');
21660 }
21661 if (chunk === null) {
21662 return _end(parser);
21663 }
21664 if ((typeof chunk === 'undefined' ? 'undefined' : (0, _typeof3.default)(chunk)) === 'object') {
21665 chunk = chunk.toString();
21666 }
21667 var i = 0;
21668 var c = '';
21669 while (true) {
21670 c = charAt(chunk, i++);
21671 parser.c = c;
21672
21673 if (!c) {
21674 break;
21675 }
21676
21677 if (parser.trackPosition) {
21678 parser.position++;
21679 if (c === '\n') {
21680 parser.line++;
21681 parser.column = 0;
21682 } else {
21683 parser.column++;
21684 }
21685 }
21686
21687 switch (parser.state) {
21688 case S.BEGIN:
21689 parser.state = S.BEGIN_WHITESPACE;
21690 if (c === '\uFEFF') {
21691 continue;
21692 }
21693 beginWhiteSpace(parser, c);
21694 continue;
21695
21696 case S.BEGIN_WHITESPACE:
21697 beginWhiteSpace(parser, c);
21698 continue;
21699
21700 case S.TEXT:
21701 if (parser.sawRoot && !parser.closedRoot) {
21702 var starti = i - 1;
21703 while (c && c !== '<' && c !== '&') {
21704 c = charAt(chunk, i++);
21705 if (c && parser.trackPosition) {
21706 parser.position++;
21707 if (c === '\n') {
21708 parser.line++;
21709 parser.column = 0;
21710 } else {
21711 parser.column++;
21712 }
21713 }
21714 }
21715 parser.textNode += chunk.substring(starti, i - 1);
21716 }
21717 if (c === '<' && !(parser.sawRoot && parser.closedRoot && !parser.strict)) {
21718 parser.state = S.OPEN_WAKA;
21719 parser.startTagPosition = parser.position;
21720 } else {
21721 if (!isWhitespace(c) && (!parser.sawRoot || parser.closedRoot)) {
21722 strictFail(parser, 'Text data outside of root node.');
21723 }
21724 if (c === '&') {
21725 parser.state = S.TEXT_ENTITY;
21726 } else {
21727 parser.textNode += c;
21728 }
21729 }
21730 continue;
21731
21732 case S.SCRIPT:
21733 // only non-strict
21734 if (c === '<') {
21735 parser.state = S.SCRIPT_ENDING;
21736 } else {
21737 parser.script += c;
21738 }
21739 continue;
21740
21741 case S.SCRIPT_ENDING:
21742 if (c === '/') {
21743 parser.state = S.CLOSE_TAG;
21744 } else {
21745 parser.script += '<' + c;
21746 parser.state = S.SCRIPT;
21747 }
21748 continue;
21749
21750 case S.OPEN_WAKA:
21751 // either a /, ?, !, or text is coming next.
21752 if (c === '!') {
21753 parser.state = S.SGML_DECL;
21754 parser.sgmlDecl = '';
21755 } else if (isWhitespace(c)) {
21756 // wait for it...
21757 } else if (isMatch(nameStart, c)) {
21758 parser.state = S.OPEN_TAG;
21759 parser.tagName = c;
21760 } else if (c === '/') {
21761 parser.state = S.CLOSE_TAG;
21762 parser.tagName = '';
21763 } else if (c === '?') {
21764 parser.state = S.PROC_INST;
21765 parser.procInstName = parser.procInstBody = '';
21766 } else {
21767 strictFail(parser, 'Unencoded <');
21768 // if there was some whitespace, then add that in.
21769 if (parser.startTagPosition + 1 < parser.position) {
21770 var pad = parser.position - parser.startTagPosition;
21771 c = new Array(pad).join(' ') + c;
21772 }
21773 parser.textNode += '<' + c;
21774 parser.state = S.TEXT;
21775 }
21776 continue;
21777
21778 case S.SGML_DECL:
21779 if ((parser.sgmlDecl + c).toUpperCase() === CDATA) {
21780 emitNode(parser, 'onopencdata');
21781 parser.state = S.CDATA;
21782 parser.sgmlDecl = '';
21783 parser.cdata = '';
21784 } else if (parser.sgmlDecl + c === '--') {
21785 parser.state = S.COMMENT;
21786 parser.comment = '';
21787 parser.sgmlDecl = '';
21788 } else if ((parser.sgmlDecl + c).toUpperCase() === DOCTYPE) {
21789 parser.state = S.DOCTYPE;
21790 if (parser.doctype || parser.sawRoot) {
21791 strictFail(parser, 'Inappropriately located doctype declaration');
21792 }
21793 parser.doctype = '';
21794 parser.sgmlDecl = '';
21795 } else if (c === '>') {
21796 emitNode(parser, 'onsgmldeclaration', parser.sgmlDecl);
21797 parser.sgmlDecl = '';
21798 parser.state = S.TEXT;
21799 } else if (isQuote(c)) {
21800 parser.state = S.SGML_DECL_QUOTED;
21801 parser.sgmlDecl += c;
21802 } else {
21803 parser.sgmlDecl += c;
21804 }
21805 continue;
21806
21807 case S.SGML_DECL_QUOTED:
21808 if (c === parser.q) {
21809 parser.state = S.SGML_DECL;
21810 parser.q = '';
21811 }
21812 parser.sgmlDecl += c;
21813 continue;
21814
21815 case S.DOCTYPE:
21816 if (c === '>') {
21817 parser.state = S.TEXT;
21818 emitNode(parser, 'ondoctype', parser.doctype);
21819 parser.doctype = true; // just remember that we saw it.
21820 } else {
21821 parser.doctype += c;
21822 if (c === '[') {
21823 parser.state = S.DOCTYPE_DTD;
21824 } else if (isQuote(c)) {
21825 parser.state = S.DOCTYPE_QUOTED;
21826 parser.q = c;
21827 }
21828 }
21829 continue;
21830
21831 case S.DOCTYPE_QUOTED:
21832 parser.doctype += c;
21833 if (c === parser.q) {
21834 parser.q = '';
21835 parser.state = S.DOCTYPE;
21836 }
21837 continue;
21838
21839 case S.DOCTYPE_DTD:
21840 parser.doctype += c;
21841 if (c === ']') {
21842 parser.state = S.DOCTYPE;
21843 } else if (isQuote(c)) {
21844 parser.state = S.DOCTYPE_DTD_QUOTED;
21845 parser.q = c;
21846 }
21847 continue;
21848
21849 case S.DOCTYPE_DTD_QUOTED:
21850 parser.doctype += c;
21851 if (c === parser.q) {
21852 parser.state = S.DOCTYPE_DTD;
21853 parser.q = '';
21854 }
21855 continue;
21856
21857 case S.COMMENT:
21858 if (c === '-') {
21859 parser.state = S.COMMENT_ENDING;
21860 } else {
21861 parser.comment += c;
21862 }
21863 continue;
21864
21865 case S.COMMENT_ENDING:
21866 if (c === '-') {
21867 parser.state = S.COMMENT_ENDED;
21868 parser.comment = textopts(parser.opt, parser.comment);
21869 if (parser.comment) {
21870 emitNode(parser, 'oncomment', parser.comment);
21871 }
21872 parser.comment = '';
21873 } else {
21874 parser.comment += '-' + c;
21875 parser.state = S.COMMENT;
21876 }
21877 continue;
21878
21879 case S.COMMENT_ENDED:
21880 if (c !== '>') {
21881 strictFail(parser, 'Malformed comment');
21882 // allow <!-- blah -- bloo --> in non-strict mode,
21883 // which is a comment of " blah -- bloo "
21884 parser.comment += '--' + c;
21885 parser.state = S.COMMENT;
21886 } else {
21887 parser.state = S.TEXT;
21888 }
21889 continue;
21890
21891 case S.CDATA:
21892 if (c === ']') {
21893 parser.state = S.CDATA_ENDING;
21894 } else {
21895 parser.cdata += c;
21896 }
21897 continue;
21898
21899 case S.CDATA_ENDING:
21900 if (c === ']') {
21901 parser.state = S.CDATA_ENDING_2;
21902 } else {
21903 parser.cdata += ']' + c;
21904 parser.state = S.CDATA;
21905 }
21906 continue;
21907
21908 case S.CDATA_ENDING_2:
21909 if (c === '>') {
21910 if (parser.cdata) {
21911 emitNode(parser, 'oncdata', parser.cdata);
21912 }
21913 emitNode(parser, 'onclosecdata');
21914 parser.cdata = '';
21915 parser.state = S.TEXT;
21916 } else if (c === ']') {
21917 parser.cdata += ']';
21918 } else {
21919 parser.cdata += ']]' + c;
21920 parser.state = S.CDATA;
21921 }
21922 continue;
21923
21924 case S.PROC_INST:
21925 if (c === '?') {
21926 parser.state = S.PROC_INST_ENDING;
21927 } else if (isWhitespace(c)) {
21928 parser.state = S.PROC_INST_BODY;
21929 } else {
21930 parser.procInstName += c;
21931 }
21932 continue;
21933
21934 case S.PROC_INST_BODY:
21935 if (!parser.procInstBody && isWhitespace(c)) {
21936 continue;
21937 } else if (c === '?') {
21938 parser.state = S.PROC_INST_ENDING;
21939 } else {
21940 parser.procInstBody += c;
21941 }
21942 continue;
21943
21944 case S.PROC_INST_ENDING:
21945 if (c === '>') {
21946 emitNode(parser, 'onprocessinginstruction', {
21947 name: parser.procInstName,
21948 body: parser.procInstBody
21949 });
21950 parser.procInstName = parser.procInstBody = '';
21951 parser.state = S.TEXT;
21952 } else {
21953 parser.procInstBody += '?' + c;
21954 parser.state = S.PROC_INST_BODY;
21955 }
21956 continue;
21957
21958 case S.OPEN_TAG:
21959 if (isMatch(nameBody, c)) {
21960 parser.tagName += c;
21961 } else {
21962 newTag(parser);
21963 if (c === '>') {
21964 openTag(parser);
21965 } else if (c === '/') {
21966 parser.state = S.OPEN_TAG_SLASH;
21967 } else {
21968 if (!isWhitespace(c)) {
21969 strictFail(parser, 'Invalid character in tag name');
21970 }
21971 parser.state = S.ATTRIB;
21972 }
21973 }
21974 continue;
21975
21976 case S.OPEN_TAG_SLASH:
21977 if (c === '>') {
21978 openTag(parser, true);
21979 closeTag(parser);
21980 } else {
21981 strictFail(parser, 'Forward-slash in opening tag not followed by >');
21982 parser.state = S.ATTRIB;
21983 }
21984 continue;
21985
21986 case S.ATTRIB:
21987 // haven't read the attribute name yet.
21988 if (isWhitespace(c)) {
21989 continue;
21990 } else if (c === '>') {
21991 openTag(parser);
21992 } else if (c === '/') {
21993 parser.state = S.OPEN_TAG_SLASH;
21994 } else if (isMatch(nameStart, c)) {
21995 parser.attribName = c;
21996 parser.attribValue = '';
21997 parser.state = S.ATTRIB_NAME;
21998 } else {
21999 strictFail(parser, 'Invalid attribute name');
22000 }
22001 continue;
22002
22003 case S.ATTRIB_NAME:
22004 if (c === '=') {
22005 parser.state = S.ATTRIB_VALUE;
22006 } else if (c === '>') {
22007 strictFail(parser, 'Attribute without value');
22008 parser.attribValue = parser.attribName;
22009 attrib(parser);
22010 openTag(parser);
22011 } else if (isWhitespace(c)) {
22012 parser.state = S.ATTRIB_NAME_SAW_WHITE;
22013 } else if (isMatch(nameBody, c)) {
22014 parser.attribName += c;
22015 } else {
22016 strictFail(parser, 'Invalid attribute name');
22017 }
22018 continue;
22019
22020 case S.ATTRIB_NAME_SAW_WHITE:
22021 if (c === '=') {
22022 parser.state = S.ATTRIB_VALUE;
22023 } else if (isWhitespace(c)) {
22024 continue;
22025 } else {
22026 strictFail(parser, 'Attribute without value');
22027 parser.tag.attributes[parser.attribName] = '';
22028 parser.attribValue = '';
22029 emitNode(parser, 'onattribute', {
22030 name: parser.attribName,
22031 value: ''
22032 });
22033 parser.attribName = '';
22034 if (c === '>') {
22035 openTag(parser);
22036 } else if (isMatch(nameStart, c)) {
22037 parser.attribName = c;
22038 parser.state = S.ATTRIB_NAME;
22039 } else {
22040 strictFail(parser, 'Invalid attribute name');
22041 parser.state = S.ATTRIB;
22042 }
22043 }
22044 continue;
22045
22046 case S.ATTRIB_VALUE:
22047 if (isWhitespace(c)) {
22048 continue;
22049 } else if (isQuote(c)) {
22050 parser.q = c;
22051 parser.state = S.ATTRIB_VALUE_QUOTED;
22052 } else {
22053 strictFail(parser, 'Unquoted attribute value');
22054 parser.state = S.ATTRIB_VALUE_UNQUOTED;
22055 parser.attribValue = c;
22056 }
22057 continue;
22058
22059 case S.ATTRIB_VALUE_QUOTED:
22060 if (c !== parser.q) {
22061 if (c === '&') {
22062 parser.state = S.ATTRIB_VALUE_ENTITY_Q;
22063 } else {
22064 parser.attribValue += c;
22065 }
22066 continue;
22067 }
22068 attrib(parser);
22069 parser.q = '';
22070 parser.state = S.ATTRIB_VALUE_CLOSED;
22071 continue;
22072
22073 case S.ATTRIB_VALUE_CLOSED:
22074 if (isWhitespace(c)) {
22075 parser.state = S.ATTRIB;
22076 } else if (c === '>') {
22077 openTag(parser);
22078 } else if (c === '/') {
22079 parser.state = S.OPEN_TAG_SLASH;
22080 } else if (isMatch(nameStart, c)) {
22081 strictFail(parser, 'No whitespace between attributes');
22082 parser.attribName = c;
22083 parser.attribValue = '';
22084 parser.state = S.ATTRIB_NAME;
22085 } else {
22086 strictFail(parser, 'Invalid attribute name');
22087 }
22088 continue;
22089
22090 case S.ATTRIB_VALUE_UNQUOTED:
22091 if (!isAttribEnd(c)) {
22092 if (c === '&') {
22093 parser.state = S.ATTRIB_VALUE_ENTITY_U;
22094 } else {
22095 parser.attribValue += c;
22096 }
22097 continue;
22098 }
22099 attrib(parser);
22100 if (c === '>') {
22101 openTag(parser);
22102 } else {
22103 parser.state = S.ATTRIB;
22104 }
22105 continue;
22106
22107 case S.CLOSE_TAG:
22108 if (!parser.tagName) {
22109 if (isWhitespace(c)) {
22110 continue;
22111 } else if (notMatch(nameStart, c)) {
22112 if (parser.script) {
22113 parser.script += '</' + c;
22114 parser.state = S.SCRIPT;
22115 } else {
22116 strictFail(parser, 'Invalid tagname in closing tag.');
22117 }
22118 } else {
22119 parser.tagName = c;
22120 }
22121 } else if (c === '>') {
22122 closeTag(parser);
22123 } else if (isMatch(nameBody, c)) {
22124 parser.tagName += c;
22125 } else if (parser.script) {
22126 parser.script += '</' + parser.tagName;
22127 parser.tagName = '';
22128 parser.state = S.SCRIPT;
22129 } else {
22130 if (!isWhitespace(c)) {
22131 strictFail(parser, 'Invalid tagname in closing tag');
22132 }
22133 parser.state = S.CLOSE_TAG_SAW_WHITE;
22134 }
22135 continue;
22136
22137 case S.CLOSE_TAG_SAW_WHITE:
22138 if (isWhitespace(c)) {
22139 continue;
22140 }
22141 if (c === '>') {
22142 closeTag(parser);
22143 } else {
22144 strictFail(parser, 'Invalid characters in closing tag');
22145 }
22146 continue;
22147
22148 case S.TEXT_ENTITY:
22149 case S.ATTRIB_VALUE_ENTITY_Q:
22150 case S.ATTRIB_VALUE_ENTITY_U:
22151 var returnState;
22152 var buffer;
22153 switch (parser.state) {
22154 case S.TEXT_ENTITY:
22155 returnState = S.TEXT;
22156 buffer = 'textNode';
22157 break;
22158
22159 case S.ATTRIB_VALUE_ENTITY_Q:
22160 returnState = S.ATTRIB_VALUE_QUOTED;
22161 buffer = 'attribValue';
22162 break;
22163
22164 case S.ATTRIB_VALUE_ENTITY_U:
22165 returnState = S.ATTRIB_VALUE_UNQUOTED;
22166 buffer = 'attribValue';
22167 break;
22168 }
22169
22170 if (c === ';') {
22171 parser[buffer] += parseEntity(parser);
22172 parser.entity = '';
22173 parser.state = returnState;
22174 } else if (isMatch(parser.entity.length ? entityBody : entityStart, c)) {
22175 parser.entity += c;
22176 } else {
22177 strictFail(parser, 'Invalid character in entity name');
22178 parser[buffer] += '&' + parser.entity + c;
22179 parser.entity = '';
22180 parser.state = returnState;
22181 }
22182
22183 continue;
22184
22185 default:
22186 throw new Error(parser, 'Unknown state: ' + parser.state);
22187 }
22188 } // while
22189
22190 if (parser.position >= parser.bufferCheckPosition) {
22191 checkBufferLength(parser);
22192 }
22193 return parser;
22194 }
22195
22196 /*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
22197 /* istanbul ignore next */
22198 if (!_fromCodePoint2.default) {
22199 (function () {
22200 var stringFromCharCode = String.fromCharCode;
22201 var floor = Math.floor;
22202 var fromCodePoint = function fromCodePoint() {
22203 var MAX_SIZE = 0x4000;
22204 var codeUnits = [];
22205 var highSurrogate;
22206 var lowSurrogate;
22207 var index = -1;
22208 var length = arguments.length;
22209 if (!length) {
22210 return '';
22211 }
22212 var result = '';
22213 while (++index < length) {
22214 var codePoint = Number(arguments[index]);
22215 if (!isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
22216 codePoint < 0 || // not a valid Unicode code point
22217 codePoint > 0x10FFFF || // not a valid Unicode code point
22218 floor(codePoint) !== codePoint // not an integer
22219 ) {
22220 throw RangeError('Invalid code point: ' + codePoint);
22221 }
22222 if (codePoint <= 0xFFFF) {
22223 // BMP code point
22224 codeUnits.push(codePoint);
22225 } else {
22226 // Astral code point; split in surrogate halves
22227 // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
22228 codePoint -= 0x10000;
22229 highSurrogate = (codePoint >> 10) + 0xD800;
22230 lowSurrogate = codePoint % 0x400 + 0xDC00;
22231 codeUnits.push(highSurrogate, lowSurrogate);
22232 }
22233 if (index + 1 === length || codeUnits.length > MAX_SIZE) {
22234 result += stringFromCharCode.apply(null, codeUnits);
22235 codeUnits.length = 0;
22236 }
22237 }
22238 return result;
22239 };
22240 /* istanbul ignore next */
22241 if (_defineProperty2.default) {
22242 Object.defineProperty(String, 'fromCodePoint', {
22243 value: fromCodePoint,
22244 configurable: true,
22245 writable: true
22246 });
22247 } else {
22248 String.fromCodePoint = fromCodePoint;
22249 }
22250 })();
22251 }
22252})(typeof exports === 'undefined' ? undefined.sax = {} : exports);
22253
22254}).call(this,require("buffer").Buffer)
22255},{"babel-runtime/core-js/json/stringify":48,"babel-runtime/core-js/object/create":50,"babel-runtime/core-js/object/define-property":51,"babel-runtime/core-js/object/keys":55,"babel-runtime/core-js/string/from-code-point":58,"babel-runtime/helpers/typeof":64,"buffer":70,"stream":271,"string_decoder":69}],271:[function(require,module,exports){
22256// Copyright Joyent, Inc. and other Node contributors.
22257//
22258// Permission is hereby granted, free of charge, to any person obtaining a
22259// copy of this software and associated documentation files (the
22260// "Software"), to deal in the Software without restriction, including
22261// without limitation the rights to use, copy, modify, merge, publish,
22262// distribute, sublicense, and/or sell copies of the Software, and to permit
22263// persons to whom the Software is furnished to do so, subject to the
22264// following conditions:
22265//
22266// The above copyright notice and this permission notice shall be included
22267// in all copies or substantial portions of the Software.
22268//
22269// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22270// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22271// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
22272// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22273// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22274// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22275// USE OR OTHER DEALINGS IN THE SOFTWARE.
22276
22277module.exports = Stream;
22278
22279var EE = require('events').EventEmitter;
22280var inherits = require('inherits');
22281
22282inherits(Stream, EE);
22283Stream.Readable = require('readable-stream/readable.js');
22284Stream.Writable = require('readable-stream/writable.js');
22285Stream.Duplex = require('readable-stream/duplex.js');
22286Stream.Transform = require('readable-stream/transform.js');
22287Stream.PassThrough = require('readable-stream/passthrough.js');
22288
22289// Backwards-compat with node 0.4.x
22290Stream.Stream = Stream;
22291
22292
22293
22294// old-style streams. Note that the pipe method (the only relevant
22295// part of this class) is overridden in the Readable class.
22296
22297function Stream() {
22298 EE.call(this);
22299}
22300
22301Stream.prototype.pipe = function(dest, options) {
22302 var source = this;
22303
22304 function ondata(chunk) {
22305 if (dest.writable) {
22306 if (false === dest.write(chunk) && source.pause) {
22307 source.pause();
22308 }
22309 }
22310 }
22311
22312 source.on('data', ondata);
22313
22314 function ondrain() {
22315 if (source.readable && source.resume) {
22316 source.resume();
22317 }
22318 }
22319
22320 dest.on('drain', ondrain);
22321
22322 // If the 'end' option is not supplied, dest.end() will be called when
22323 // source gets the 'end' or 'close' events. Only dest.end() once.
22324 if (!dest._isStdio && (!options || options.end !== false)) {
22325 source.on('end', onend);
22326 source.on('close', onclose);
22327 }
22328
22329 var didOnEnd = false;
22330 function onend() {
22331 if (didOnEnd) return;
22332 didOnEnd = true;
22333
22334 dest.end();
22335 }
22336
22337
22338 function onclose() {
22339 if (didOnEnd) return;
22340 didOnEnd = true;
22341
22342 if (typeof dest.destroy === 'function') dest.destroy();
22343 }
22344
22345 // don't leave dangling pipes when there are errors.
22346 function onerror(er) {
22347 cleanup();
22348 if (EE.listenerCount(this, 'error') === 0) {
22349 throw er; // Unhandled stream error in pipe.
22350 }
22351 }
22352
22353 source.on('error', onerror);
22354 dest.on('error', onerror);
22355
22356 // remove all the event listeners that were added.
22357 function cleanup() {
22358 source.removeListener('data', ondata);
22359 dest.removeListener('drain', ondrain);
22360
22361 source.removeListener('end', onend);
22362 source.removeListener('close', onclose);
22363
22364 source.removeListener('error', onerror);
22365 dest.removeListener('error', onerror);
22366
22367 source.removeListener('end', cleanup);
22368 source.removeListener('close', cleanup);
22369
22370 dest.removeListener('close', cleanup);
22371 }
22372
22373 source.on('end', cleanup);
22374 source.on('close', cleanup);
22375
22376 dest.on('close', cleanup);
22377
22378 dest.emit('pipe', source);
22379
22380 // Allow for unix-like usage: A.pipe(B).pipe(C)
22381 return dest;
22382};
22383
22384},{"events":216,"inherits":226,"readable-stream/duplex.js":254,"readable-stream/passthrough.js":263,"readable-stream/readable.js":264,"readable-stream/transform.js":265,"readable-stream/writable.js":266}],272:[function(require,module,exports){
22385(function (global){
22386var ClientRequest = require('./lib/request')
22387var response = require('./lib/response')
22388var extend = require('xtend')
22389var statusCodes = require('builtin-status-codes')
22390var url = require('url')
22391
22392var http = exports
22393
22394http.request = function (opts, cb) {
22395 if (typeof opts === 'string')
22396 opts = url.parse(opts)
22397 else
22398 opts = extend(opts)
22399
22400 // Normally, the page is loaded from http or https, so not specifying a protocol
22401 // will result in a (valid) protocol-relative url. However, this won't work if
22402 // the protocol is something else, like 'file:'
22403 var defaultProtocol = global.location.protocol.search(/^https?:$/) === -1 ? 'http:' : ''
22404
22405 var protocol = opts.protocol || defaultProtocol
22406 var host = opts.hostname || opts.host
22407 var port = opts.port
22408 var path = opts.path || '/'
22409
22410 // Necessary for IPv6 addresses
22411 if (host && host.indexOf(':') !== -1)
22412 host = '[' + host + ']'
22413
22414 // This may be a relative url. The browser should always be able to interpret it correctly.
22415 opts.url = (host ? (protocol + '//' + host) : '') + (port ? ':' + port : '') + path
22416 opts.method = (opts.method || 'GET').toUpperCase()
22417 opts.headers = opts.headers || {}
22418
22419 // Also valid opts.auth, opts.mode
22420
22421 var req = new ClientRequest(opts)
22422 if (cb)
22423 req.on('response', cb)
22424 return req
22425}
22426
22427http.get = function get (opts, cb) {
22428 var req = http.request(opts, cb)
22429 req.end()
22430 return req
22431}
22432
22433http.ClientRequest = ClientRequest
22434http.IncomingMessage = response.IncomingMessage
22435
22436http.Agent = function () {}
22437http.Agent.defaultMaxSockets = 4
22438
22439http.globalAgent = new http.Agent()
22440
22441http.STATUS_CODES = statusCodes
22442
22443http.METHODS = [
22444 'CHECKOUT',
22445 'CONNECT',
22446 'COPY',
22447 'DELETE',
22448 'GET',
22449 'HEAD',
22450 'LOCK',
22451 'M-SEARCH',
22452 'MERGE',
22453 'MKACTIVITY',
22454 'MKCOL',
22455 'MOVE',
22456 'NOTIFY',
22457 'OPTIONS',
22458 'PATCH',
22459 'POST',
22460 'PROPFIND',
22461 'PROPPATCH',
22462 'PURGE',
22463 'PUT',
22464 'REPORT',
22465 'SEARCH',
22466 'SUBSCRIBE',
22467 'TRACE',
22468 'UNLOCK',
22469 'UNSUBSCRIBE'
22470]
22471}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
22472},{"./lib/request":274,"./lib/response":275,"builtin-status-codes":71,"url":279,"xtend":327}],273:[function(require,module,exports){
22473(function (global){
22474'use strict';
22475
22476exports.fetch = isFunction(global.fetch) && isFunction(global.ReadableStream);
22477
22478exports.writableStream = isFunction(global.WritableStream);
22479
22480exports.abortController = isFunction(global.AbortController);
22481
22482exports.blobConstructor = false;
22483try {
22484 new Blob([new ArrayBuffer(1)]);
22485 exports.blobConstructor = true;
22486} catch (e) {}
22487
22488// The xhr request to example.com may violate some restrictive CSP configurations,
22489// so if we're running in a browser that supports `fetch`, avoid calling getXHR()
22490// and assume support for certain features below.
22491var xhr;
22492function getXHR() {
22493 // Cache the xhr value
22494 if (xhr !== undefined) return xhr;
22495
22496 if (global.XMLHttpRequest) {
22497 xhr = new global.XMLHttpRequest();
22498 // If XDomainRequest is available (ie only, where xhr might not work
22499 // cross domain), use the page location. Otherwise use example.com
22500 // Note: this doesn't actually make an http request.
22501 try {
22502 xhr.open('GET', global.XDomainRequest ? '/' : 'https://example.com');
22503 } catch (e) {
22504 xhr = null;
22505 }
22506 } else {
22507 // Service workers don't have XHR
22508 xhr = null;
22509 }
22510 return xhr;
22511}
22512
22513function checkTypeSupport(type) {
22514 var xhr = getXHR();
22515 if (!xhr) return false;
22516 try {
22517 xhr.responseType = type;
22518 return xhr.responseType === type;
22519 } catch (e) {}
22520 return false;
22521}
22522
22523// For some strange reason, Safari 7.0 reports typeof global.ArrayBuffer === 'object'.
22524// Safari 7.1 appears to have fixed this bug.
22525var haveArrayBuffer = typeof global.ArrayBuffer !== 'undefined';
22526var haveSlice = haveArrayBuffer && isFunction(global.ArrayBuffer.prototype.slice);
22527
22528// If fetch is supported, then arraybuffer will be supported too. Skip calling
22529// checkTypeSupport(), since that calls getXHR().
22530exports.arraybuffer = exports.fetch || haveArrayBuffer && checkTypeSupport('arraybuffer');
22531
22532// These next two tests unavoidably show warnings in Chrome. Since fetch will always
22533// be used if it's available, just return false for these to avoid the warnings.
22534exports.msstream = !exports.fetch && haveSlice && checkTypeSupport('ms-stream');
22535exports.mozchunkedarraybuffer = !exports.fetch && haveArrayBuffer && checkTypeSupport('moz-chunked-arraybuffer');
22536
22537// If fetch is supported, then overrideMimeType will be supported too. Skip calling
22538// getXHR().
22539exports.overrideMimeType = exports.fetch || (getXHR() ? isFunction(getXHR().overrideMimeType) : false);
22540
22541exports.vbArray = isFunction(global.VBArray);
22542
22543function isFunction(value) {
22544 return typeof value === 'function';
22545}
22546
22547xhr = null; // Help gc
22548
22549}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
22550},{}],274:[function(require,module,exports){
22551(function (process,global,Buffer){
22552'use strict';
22553
22554var _keys = require('babel-runtime/core-js/object/keys');
22555
22556var _keys2 = _interopRequireDefault(_keys);
22557
22558function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22559
22560var capability = require('./capability');
22561var inherits = require('inherits');
22562var response = require('./response');
22563var stream = require('readable-stream');
22564var toArrayBuffer = require('to-arraybuffer');
22565
22566var IncomingMessage = response.IncomingMessage;
22567var rStates = response.readyStates;
22568
22569function decideMode(preferBinary, useFetch) {
22570 if (capability.fetch && useFetch) {
22571 return 'fetch';
22572 } else if (capability.mozchunkedarraybuffer) {
22573 return 'moz-chunked-arraybuffer';
22574 } else if (capability.msstream) {
22575 return 'ms-stream';
22576 } else if (capability.arraybuffer && preferBinary) {
22577 return 'arraybuffer';
22578 } else if (capability.vbArray && preferBinary) {
22579 return 'text:vbarray';
22580 } else {
22581 return 'text';
22582 }
22583}
22584
22585var ClientRequest = module.exports = function (opts) {
22586 var self = this;
22587 stream.Writable.call(self);
22588
22589 self._opts = opts;
22590 self._body = [];
22591 self._headers = {};
22592 if (opts.auth) self.setHeader('Authorization', 'Basic ' + new Buffer(opts.auth).toString('base64'));
22593 (0, _keys2.default)(opts.headers).forEach(function (name) {
22594 self.setHeader(name, opts.headers[name]);
22595 });
22596
22597 var preferBinary;
22598 var useFetch = true;
22599 if (opts.mode === 'disable-fetch' || 'requestTimeout' in opts && !capability.abortController) {
22600 // If the use of XHR should be preferred. Not typically needed.
22601 useFetch = false;
22602 preferBinary = true;
22603 } else if (opts.mode === 'prefer-streaming') {
22604 // If streaming is a high priority but binary compatibility and
22605 // the accuracy of the 'content-type' header aren't
22606 preferBinary = false;
22607 } else if (opts.mode === 'allow-wrong-content-type') {
22608 // If streaming is more important than preserving the 'content-type' header
22609 preferBinary = !capability.overrideMimeType;
22610 } else if (!opts.mode || opts.mode === 'default' || opts.mode === 'prefer-fast') {
22611 // Use binary if text streaming may corrupt data or the content-type header, or for speed
22612 preferBinary = true;
22613 } else {
22614 throw new Error('Invalid value for opts.mode');
22615 }
22616 self._mode = decideMode(preferBinary, useFetch);
22617 self._fetchTimer = null;
22618
22619 self.on('finish', function () {
22620 self._onFinish();
22621 });
22622};
22623
22624inherits(ClientRequest, stream.Writable);
22625
22626ClientRequest.prototype.setHeader = function (name, value) {
22627 var self = this;
22628 var lowerName = name.toLowerCase();
22629 // This check is not necessary, but it prevents warnings from browsers about setting unsafe
22630 // headers. To be honest I'm not entirely sure hiding these warnings is a good thing, but
22631 // http-browserify did it, so I will too.
22632 if (unsafeHeaders.indexOf(lowerName) !== -1) return;
22633
22634 self._headers[lowerName] = {
22635 name: name,
22636 value: value
22637 };
22638};
22639
22640ClientRequest.prototype.getHeader = function (name) {
22641 var header = this._headers[name.toLowerCase()];
22642 if (header) return header.value;
22643 return null;
22644};
22645
22646ClientRequest.prototype.removeHeader = function (name) {
22647 var self = this;
22648 delete self._headers[name.toLowerCase()];
22649};
22650
22651ClientRequest.prototype._onFinish = function () {
22652 var self = this;
22653
22654 if (self._destroyed) return;
22655 var opts = self._opts;
22656
22657 var headersObj = self._headers;
22658 var body = null;
22659 if (opts.method !== 'GET' && opts.method !== 'HEAD') {
22660 if (capability.arraybuffer) {
22661 body = toArrayBuffer(Buffer.concat(self._body));
22662 } else if (capability.blobConstructor) {
22663 body = new global.Blob(self._body.map(function (buffer) {
22664 return toArrayBuffer(buffer);
22665 }), {
22666 type: (headersObj['content-type'] || {}).value || ''
22667 });
22668 } else {
22669 // get utf8 string
22670 body = Buffer.concat(self._body).toString();
22671 }
22672 }
22673
22674 // create flattened list of headers
22675 var headersList = [];
22676 (0, _keys2.default)(headersObj).forEach(function (keyName) {
22677 var name = headersObj[keyName].name;
22678 var value = headersObj[keyName].value;
22679 if (Array.isArray(value)) {
22680 value.forEach(function (v) {
22681 headersList.push([name, v]);
22682 });
22683 } else {
22684 headersList.push([name, value]);
22685 }
22686 });
22687
22688 if (self._mode === 'fetch') {
22689 var signal = null;
22690 var fetchTimer = null;
22691 if (capability.abortController) {
22692 var controller = new AbortController();
22693 signal = controller.signal;
22694 self._fetchAbortController = controller;
22695
22696 if ('requestTimeout' in opts && opts.requestTimeout !== 0) {
22697 self._fetchTimer = global.setTimeout(function () {
22698 self.emit('requestTimeout');
22699 if (self._fetchAbortController) self._fetchAbortController.abort();
22700 }, opts.requestTimeout);
22701 }
22702 }
22703
22704 global.fetch(self._opts.url, {
22705 method: self._opts.method,
22706 headers: headersList,
22707 body: body || undefined,
22708 mode: 'cors',
22709 credentials: opts.withCredentials ? 'include' : 'same-origin',
22710 signal: signal
22711 }).then(function (response) {
22712 self._fetchResponse = response;
22713 self._connect();
22714 }, function (reason) {
22715 global.clearTimeout(self._fetchTimer);
22716 if (!self._destroyed) self.emit('error', reason);
22717 });
22718 } else {
22719 var xhr = self._xhr = new global.XMLHttpRequest();
22720 try {
22721 xhr.open(self._opts.method, self._opts.url, true);
22722 } catch (err) {
22723 process.nextTick(function () {
22724 self.emit('error', err);
22725 });
22726 return;
22727 }
22728
22729 // Can't set responseType on really old browsers
22730 if ('responseType' in xhr) xhr.responseType = self._mode.split(':')[0];
22731
22732 if ('withCredentials' in xhr) xhr.withCredentials = !!opts.withCredentials;
22733
22734 if (self._mode === 'text' && 'overrideMimeType' in xhr) xhr.overrideMimeType('text/plain; charset=x-user-defined');
22735
22736 if ('requestTimeout' in opts) {
22737 xhr.timeout = opts.requestTimeout;
22738 xhr.ontimeout = function () {
22739 self.emit('requestTimeout');
22740 };
22741 }
22742
22743 headersList.forEach(function (header) {
22744 xhr.setRequestHeader(header[0], header[1]);
22745 });
22746
22747 self._response = null;
22748 xhr.onreadystatechange = function () {
22749 switch (xhr.readyState) {
22750 case rStates.LOADING:
22751 case rStates.DONE:
22752 self._onXHRProgress();
22753 break;
22754 }
22755 };
22756 // Necessary for streaming in Firefox, since xhr.response is ONLY defined
22757 // in onprogress, not in onreadystatechange with xhr.readyState = 3
22758 if (self._mode === 'moz-chunked-arraybuffer') {
22759 xhr.onprogress = function () {
22760 self._onXHRProgress();
22761 };
22762 }
22763
22764 xhr.onerror = function () {
22765 if (self._destroyed) return;
22766 self.emit('error', new Error('XHR error'));
22767 };
22768
22769 try {
22770 xhr.send(body);
22771 } catch (err) {
22772 process.nextTick(function () {
22773 self.emit('error', err);
22774 });
22775 return;
22776 }
22777 }
22778};
22779
22780/**
22781 * Checks if xhr.status is readable and non-zero, indicating no error.
22782 * Even though the spec says it should be available in readyState 3,
22783 * accessing it throws an exception in IE8
22784 */
22785function statusValid(xhr) {
22786 try {
22787 var status = xhr.status;
22788 return status !== null && status !== 0;
22789 } catch (e) {
22790 return false;
22791 }
22792}
22793
22794ClientRequest.prototype._onXHRProgress = function () {
22795 var self = this;
22796
22797 if (!statusValid(self._xhr) || self._destroyed) return;
22798
22799 if (!self._response) self._connect();
22800
22801 self._response._onXHRProgress();
22802};
22803
22804ClientRequest.prototype._connect = function () {
22805 var self = this;
22806
22807 if (self._destroyed) return;
22808
22809 self._response = new IncomingMessage(self._xhr, self._fetchResponse, self._mode, self._fetchTimer);
22810 self._response.on('error', function (err) {
22811 self.emit('error', err);
22812 });
22813
22814 self.emit('response', self._response);
22815};
22816
22817ClientRequest.prototype._write = function (chunk, encoding, cb) {
22818 var self = this;
22819
22820 self._body.push(chunk);
22821 cb();
22822};
22823
22824ClientRequest.prototype.abort = ClientRequest.prototype.destroy = function () {
22825 var self = this;
22826 self._destroyed = true;
22827 global.clearTimeout(self._fetchTimer);
22828 if (self._response) self._response._destroyed = true;
22829 if (self._xhr) self._xhr.abort();else if (self._fetchAbortController) self._fetchAbortController.abort();
22830};
22831
22832ClientRequest.prototype.end = function (data, encoding, cb) {
22833 var self = this;
22834 if (typeof data === 'function') {
22835 cb = data;
22836 data = undefined;
22837 }
22838
22839 stream.Writable.prototype.end.call(self, data, encoding, cb);
22840};
22841
22842ClientRequest.prototype.flushHeaders = function () {};
22843ClientRequest.prototype.setTimeout = function () {};
22844ClientRequest.prototype.setNoDelay = function () {};
22845ClientRequest.prototype.setSocketKeepAlive = function () {};
22846
22847// Taken from http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader%28%29-method
22848var unsafeHeaders = ['accept-charset', 'accept-encoding', 'access-control-request-headers', 'access-control-request-method', 'connection', 'content-length', 'cookie', 'cookie2', 'date', 'dnt', 'expect', 'host', 'keep-alive', 'origin', 'referer', 'te', 'trailer', 'transfer-encoding', 'upgrade', 'user-agent', 'via'];
22849
22850}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer)
22851},{"./capability":273,"./response":275,"_process":249,"babel-runtime/core-js/object/keys":55,"buffer":70,"inherits":226,"readable-stream":264,"to-arraybuffer":278}],275:[function(require,module,exports){
22852(function (process,global,Buffer){
22853'use strict';
22854
22855var _promise = require('babel-runtime/core-js/promise');
22856
22857var _promise2 = _interopRequireDefault(_promise);
22858
22859function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22860
22861var capability = require('./capability');
22862var inherits = require('inherits');
22863var stream = require('readable-stream');
22864
22865var rStates = exports.readyStates = {
22866 UNSENT: 0,
22867 OPENED: 1,
22868 HEADERS_RECEIVED: 2,
22869 LOADING: 3,
22870 DONE: 4
22871};
22872
22873var IncomingMessage = exports.IncomingMessage = function (xhr, response, mode, fetchTimer) {
22874 var self = this;
22875 stream.Readable.call(self);
22876
22877 self._mode = mode;
22878 self.headers = {};
22879 self.rawHeaders = [];
22880 self.trailers = {};
22881 self.rawTrailers = [];
22882
22883 // Fake the 'close' event, but only once 'end' fires
22884 self.on('end', function () {
22885 // The nextTick is necessary to prevent the 'request' module from causing an infinite loop
22886 process.nextTick(function () {
22887 self.emit('close');
22888 });
22889 });
22890
22891 if (mode === 'fetch') {
22892 var read = function read() {
22893 reader.read().then(function (result) {
22894 if (self._destroyed) return;
22895 if (result.done) {
22896 global.clearTimeout(fetchTimer);
22897 self.push(null);
22898 return;
22899 }
22900 self.push(new Buffer(result.value));
22901 read();
22902 }).catch(function (err) {
22903 global.clearTimeout(fetchTimer);
22904 if (!self._destroyed) self.emit('error', err);
22905 });
22906 };
22907
22908 self._fetchResponse = response;
22909
22910 self.url = response.url;
22911 self.statusCode = response.status;
22912 self.statusMessage = response.statusText;
22913
22914 response.headers.forEach(function (header, key) {
22915 self.headers[key.toLowerCase()] = header;
22916 self.rawHeaders.push(key, header);
22917 });
22918
22919 if (capability.writableStream) {
22920 var writable = new WritableStream({
22921 write: function write(chunk) {
22922 return new _promise2.default(function (resolve, reject) {
22923 if (self._destroyed) {
22924 reject();
22925 } else if (self.push(new Buffer(chunk))) {
22926 resolve();
22927 } else {
22928 self._resumeFetch = resolve;
22929 }
22930 });
22931 },
22932 close: function close() {
22933 global.clearTimeout(fetchTimer);
22934 if (!self._destroyed) self.push(null);
22935 },
22936 abort: function abort(err) {
22937 if (!self._destroyed) self.emit('error', err);
22938 }
22939 });
22940
22941 try {
22942 response.body.pipeTo(writable).catch(function (err) {
22943 global.clearTimeout(fetchTimer);
22944 if (!self._destroyed) self.emit('error', err);
22945 });
22946 return;
22947 } catch (e) {} // pipeTo method isn't defined. Can't find a better way to feature test this
22948 }
22949 // fallback for when writableStream or pipeTo aren't available
22950 var reader = response.body.getReader();
22951
22952 read();
22953 } else {
22954 self._xhr = xhr;
22955 self._pos = 0;
22956
22957 self.url = xhr.responseURL;
22958 self.statusCode = xhr.status;
22959 self.statusMessage = xhr.statusText;
22960 var headers = xhr.getAllResponseHeaders().split(/\r?\n/);
22961 headers.forEach(function (header) {
22962 var matches = header.match(/^([^:]+):\s*(.*)/);
22963 if (matches) {
22964 var key = matches[1].toLowerCase();
22965 if (key === 'set-cookie') {
22966 if (self.headers[key] === undefined) {
22967 self.headers[key] = [];
22968 }
22969 self.headers[key].push(matches[2]);
22970 } else if (self.headers[key] !== undefined) {
22971 self.headers[key] += ', ' + matches[2];
22972 } else {
22973 self.headers[key] = matches[2];
22974 }
22975 self.rawHeaders.push(matches[1], matches[2]);
22976 }
22977 });
22978
22979 self._charset = 'x-user-defined';
22980 if (!capability.overrideMimeType) {
22981 var mimeType = self.rawHeaders['mime-type'];
22982 if (mimeType) {
22983 var charsetMatch = mimeType.match(/;\s*charset=([^;])(;|$)/);
22984 if (charsetMatch) {
22985 self._charset = charsetMatch[1].toLowerCase();
22986 }
22987 }
22988 if (!self._charset) self._charset = 'utf-8'; // best guess
22989 }
22990 }
22991};
22992
22993inherits(IncomingMessage, stream.Readable);
22994
22995IncomingMessage.prototype._read = function () {
22996 var self = this;
22997
22998 var resolve = self._resumeFetch;
22999 if (resolve) {
23000 self._resumeFetch = null;
23001 resolve();
23002 }
23003};
23004
23005IncomingMessage.prototype._onXHRProgress = function () {
23006 var self = this;
23007
23008 var xhr = self._xhr;
23009
23010 var response = null;
23011 switch (self._mode) {
23012 case 'text:vbarray':
23013 // For IE9
23014 if (xhr.readyState !== rStates.DONE) break;
23015 try {
23016 // This fails in IE8
23017 response = new global.VBArray(xhr.responseBody).toArray();
23018 } catch (e) {}
23019 if (response !== null) {
23020 self.push(new Buffer(response));
23021 break;
23022 }
23023 // Falls through in IE8
23024 case 'text':
23025 try {
23026 // This will fail when readyState = 3 in IE9. Switch mode and wait for readyState = 4
23027 response = xhr.responseText;
23028 } catch (e) {
23029 self._mode = 'text:vbarray';
23030 break;
23031 }
23032 if (response.length > self._pos) {
23033 var newData = response.substr(self._pos);
23034 if (self._charset === 'x-user-defined') {
23035 var buffer = new Buffer(newData.length);
23036 for (var i = 0; i < newData.length; i++) {
23037 buffer[i] = newData.charCodeAt(i) & 0xff;
23038 }self.push(buffer);
23039 } else {
23040 self.push(newData, self._charset);
23041 }
23042 self._pos = response.length;
23043 }
23044 break;
23045 case 'arraybuffer':
23046 if (xhr.readyState !== rStates.DONE || !xhr.response) break;
23047 response = xhr.response;
23048 self.push(new Buffer(new Uint8Array(response)));
23049 break;
23050 case 'moz-chunked-arraybuffer':
23051 // take whole
23052 response = xhr.response;
23053 if (xhr.readyState !== rStates.LOADING || !response) break;
23054 self.push(new Buffer(new Uint8Array(response)));
23055 break;
23056 case 'ms-stream':
23057 response = xhr.response;
23058 if (xhr.readyState !== rStates.LOADING) break;
23059 var reader = new global.MSStreamReader();
23060 reader.onprogress = function () {
23061 if (reader.result.byteLength > self._pos) {
23062 self.push(new Buffer(new Uint8Array(reader.result.slice(self._pos))));
23063 self._pos = reader.result.byteLength;
23064 }
23065 };
23066 reader.onload = function () {
23067 self.push(null);
23068 };
23069 // reader.onerror = ??? // TODO: this
23070 reader.readAsArrayBuffer(response);
23071 break;
23072 }
23073
23074 // The ms-stream case handles end separately in reader.onload()
23075 if (self._xhr.readyState === rStates.DONE && self._mode !== 'ms-stream') {
23076 self.push(null);
23077 }
23078};
23079
23080}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer)
23081},{"./capability":273,"_process":249,"babel-runtime/core-js/promise":56,"buffer":70,"inherits":226,"readable-stream":264}],276:[function(require,module,exports){
23082// Copyright Joyent, Inc. and other Node contributors.
23083//
23084// Permission is hereby granted, free of charge, to any person obtaining a
23085// copy of this software and associated documentation files (the
23086// "Software"), to deal in the Software without restriction, including
23087// without limitation the rights to use, copy, modify, merge, publish,
23088// distribute, sublicense, and/or sell copies of the Software, and to permit
23089// persons to whom the Software is furnished to do so, subject to the
23090// following conditions:
23091//
23092// The above copyright notice and this permission notice shall be included
23093// in all copies or substantial portions of the Software.
23094//
23095// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23096// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23097// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
23098// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
23099// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23100// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
23101// USE OR OTHER DEALINGS IN THE SOFTWARE.
23102
23103'use strict';
23104
23105/*<replacement>*/
23106
23107var Buffer = require('safe-buffer').Buffer;
23108/*</replacement>*/
23109
23110var isEncoding = Buffer.isEncoding || function (encoding) {
23111 encoding = '' + encoding;
23112 switch (encoding && encoding.toLowerCase()) {
23113 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':
23114 return true;
23115 default:
23116 return false;
23117 }
23118};
23119
23120function _normalizeEncoding(enc) {
23121 if (!enc) return 'utf8';
23122 var retried;
23123 while (true) {
23124 switch (enc) {
23125 case 'utf8':
23126 case 'utf-8':
23127 return 'utf8';
23128 case 'ucs2':
23129 case 'ucs-2':
23130 case 'utf16le':
23131 case 'utf-16le':
23132 return 'utf16le';
23133 case 'latin1':
23134 case 'binary':
23135 return 'latin1';
23136 case 'base64':
23137 case 'ascii':
23138 case 'hex':
23139 return enc;
23140 default:
23141 if (retried) return; // undefined
23142 enc = ('' + enc).toLowerCase();
23143 retried = true;
23144 }
23145 }
23146};
23147
23148// Do not cache `Buffer.isEncoding` when checking encoding names as some
23149// modules monkey-patch it to support additional encodings
23150function normalizeEncoding(enc) {
23151 var nenc = _normalizeEncoding(enc);
23152 if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
23153 return nenc || enc;
23154}
23155
23156// StringDecoder provides an interface for efficiently splitting a series of
23157// buffers into a series of JS strings without breaking apart multi-byte
23158// characters.
23159exports.StringDecoder = StringDecoder;
23160function StringDecoder(encoding) {
23161 this.encoding = normalizeEncoding(encoding);
23162 var nb;
23163 switch (this.encoding) {
23164 case 'utf16le':
23165 this.text = utf16Text;
23166 this.end = utf16End;
23167 nb = 4;
23168 break;
23169 case 'utf8':
23170 this.fillLast = utf8FillLast;
23171 nb = 4;
23172 break;
23173 case 'base64':
23174 this.text = base64Text;
23175 this.end = base64End;
23176 nb = 3;
23177 break;
23178 default:
23179 this.write = simpleWrite;
23180 this.end = simpleEnd;
23181 return;
23182 }
23183 this.lastNeed = 0;
23184 this.lastTotal = 0;
23185 this.lastChar = Buffer.allocUnsafe(nb);
23186}
23187
23188StringDecoder.prototype.write = function (buf) {
23189 if (buf.length === 0) return '';
23190 var r;
23191 var i;
23192 if (this.lastNeed) {
23193 r = this.fillLast(buf);
23194 if (r === undefined) return '';
23195 i = this.lastNeed;
23196 this.lastNeed = 0;
23197 } else {
23198 i = 0;
23199 }
23200 if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
23201 return r || '';
23202};
23203
23204StringDecoder.prototype.end = utf8End;
23205
23206// Returns only complete characters in a Buffer
23207StringDecoder.prototype.text = utf8Text;
23208
23209// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
23210StringDecoder.prototype.fillLast = function (buf) {
23211 if (this.lastNeed <= buf.length) {
23212 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
23213 return this.lastChar.toString(this.encoding, 0, this.lastTotal);
23214 }
23215 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
23216 this.lastNeed -= buf.length;
23217};
23218
23219// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
23220// continuation byte. If an invalid byte is detected, -2 is returned.
23221function utf8CheckByte(byte) {
23222 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;
23223 return byte >> 6 === 0x02 ? -1 : -2;
23224}
23225
23226// Checks at most 3 bytes at the end of a Buffer in order to detect an
23227// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
23228// needed to complete the UTF-8 character (if applicable) are returned.
23229function utf8CheckIncomplete(self, buf, i) {
23230 var j = buf.length - 1;
23231 if (j < i) return 0;
23232 var nb = utf8CheckByte(buf[j]);
23233 if (nb >= 0) {
23234 if (nb > 0) self.lastNeed = nb - 1;
23235 return nb;
23236 }
23237 if (--j < i || nb === -2) return 0;
23238 nb = utf8CheckByte(buf[j]);
23239 if (nb >= 0) {
23240 if (nb > 0) self.lastNeed = nb - 2;
23241 return nb;
23242 }
23243 if (--j < i || nb === -2) return 0;
23244 nb = utf8CheckByte(buf[j]);
23245 if (nb >= 0) {
23246 if (nb > 0) {
23247 if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
23248 }
23249 return nb;
23250 }
23251 return 0;
23252}
23253
23254// Validates as many continuation bytes for a multi-byte UTF-8 character as
23255// needed or are available. If we see a non-continuation byte where we expect
23256// one, we "replace" the validated continuation bytes we've seen so far with
23257// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
23258// behavior. The continuation byte check is included three times in the case
23259// where all of the continuation bytes for a character exist in the same buffer.
23260// It is also done this way as a slight performance increase instead of using a
23261// loop.
23262function utf8CheckExtraBytes(self, buf, p) {
23263 if ((buf[0] & 0xC0) !== 0x80) {
23264 self.lastNeed = 0;
23265 return '\uFFFD';
23266 }
23267 if (self.lastNeed > 1 && buf.length > 1) {
23268 if ((buf[1] & 0xC0) !== 0x80) {
23269 self.lastNeed = 1;
23270 return '\uFFFD';
23271 }
23272 if (self.lastNeed > 2 && buf.length > 2) {
23273 if ((buf[2] & 0xC0) !== 0x80) {
23274 self.lastNeed = 2;
23275 return '\uFFFD';
23276 }
23277 }
23278 }
23279}
23280
23281// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
23282function utf8FillLast(buf) {
23283 var p = this.lastTotal - this.lastNeed;
23284 var r = utf8CheckExtraBytes(this, buf, p);
23285 if (r !== undefined) return r;
23286 if (this.lastNeed <= buf.length) {
23287 buf.copy(this.lastChar, p, 0, this.lastNeed);
23288 return this.lastChar.toString(this.encoding, 0, this.lastTotal);
23289 }
23290 buf.copy(this.lastChar, p, 0, buf.length);
23291 this.lastNeed -= buf.length;
23292}
23293
23294// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
23295// partial character, the character's bytes are buffered until the required
23296// number of bytes are available.
23297function utf8Text(buf, i) {
23298 var total = utf8CheckIncomplete(this, buf, i);
23299 if (!this.lastNeed) return buf.toString('utf8', i);
23300 this.lastTotal = total;
23301 var end = buf.length - (total - this.lastNeed);
23302 buf.copy(this.lastChar, 0, end);
23303 return buf.toString('utf8', i, end);
23304}
23305
23306// For UTF-8, a replacement character is added when ending on a partial
23307// character.
23308function utf8End(buf) {
23309 var r = buf && buf.length ? this.write(buf) : '';
23310 if (this.lastNeed) return r + '\uFFFD';
23311 return r;
23312}
23313
23314// UTF-16LE typically needs two bytes per character, but even if we have an even
23315// number of bytes available, we need to check if we end on a leading/high
23316// surrogate. In that case, we need to wait for the next two bytes in order to
23317// decode the last character properly.
23318function utf16Text(buf, i) {
23319 if ((buf.length - i) % 2 === 0) {
23320 var r = buf.toString('utf16le', i);
23321 if (r) {
23322 var c = r.charCodeAt(r.length - 1);
23323 if (c >= 0xD800 && c <= 0xDBFF) {
23324 this.lastNeed = 2;
23325 this.lastTotal = 4;
23326 this.lastChar[0] = buf[buf.length - 2];
23327 this.lastChar[1] = buf[buf.length - 1];
23328 return r.slice(0, -1);
23329 }
23330 }
23331 return r;
23332 }
23333 this.lastNeed = 1;
23334 this.lastTotal = 2;
23335 this.lastChar[0] = buf[buf.length - 1];
23336 return buf.toString('utf16le', i, buf.length - 1);
23337}
23338
23339// For UTF-16LE we do not explicitly append special replacement characters if we
23340// end on a partial character, we simply let v8 handle that.
23341function utf16End(buf) {
23342 var r = buf && buf.length ? this.write(buf) : '';
23343 if (this.lastNeed) {
23344 var end = this.lastTotal - this.lastNeed;
23345 return r + this.lastChar.toString('utf16le', 0, end);
23346 }
23347 return r;
23348}
23349
23350function base64Text(buf, i) {
23351 var n = (buf.length - i) % 3;
23352 if (n === 0) return buf.toString('base64', i);
23353 this.lastNeed = 3 - n;
23354 this.lastTotal = 3;
23355 if (n === 1) {
23356 this.lastChar[0] = buf[buf.length - 1];
23357 } else {
23358 this.lastChar[0] = buf[buf.length - 2];
23359 this.lastChar[1] = buf[buf.length - 1];
23360 }
23361 return buf.toString('base64', i, buf.length - n);
23362}
23363
23364function base64End(buf) {
23365 var r = buf && buf.length ? this.write(buf) : '';
23366 if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
23367 return r;
23368}
23369
23370// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
23371function simpleWrite(buf) {
23372 return buf.toString(this.encoding);
23373}
23374
23375function simpleEnd(buf) {
23376 return buf && buf.length ? this.write(buf) : '';
23377}
23378
23379},{"safe-buffer":269}],277:[function(require,module,exports){
23380(function (setImmediate,clearImmediate){
23381var nextTick = require('process/browser.js').nextTick;
23382var apply = Function.prototype.apply;
23383var slice = Array.prototype.slice;
23384var immediateIds = {};
23385var nextImmediateId = 0;
23386
23387// DOM APIs, for completeness
23388
23389exports.setTimeout = function() {
23390 return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
23391};
23392exports.setInterval = function() {
23393 return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
23394};
23395exports.clearTimeout =
23396exports.clearInterval = function(timeout) { timeout.close(); };
23397
23398function Timeout(id, clearFn) {
23399 this._id = id;
23400 this._clearFn = clearFn;
23401}
23402Timeout.prototype.unref = Timeout.prototype.ref = function() {};
23403Timeout.prototype.close = function() {
23404 this._clearFn.call(window, this._id);
23405};
23406
23407// Does not start the time, just sets up the members needed.
23408exports.enroll = function(item, msecs) {
23409 clearTimeout(item._idleTimeoutId);
23410 item._idleTimeout = msecs;
23411};
23412
23413exports.unenroll = function(item) {
23414 clearTimeout(item._idleTimeoutId);
23415 item._idleTimeout = -1;
23416};
23417
23418exports._unrefActive = exports.active = function(item) {
23419 clearTimeout(item._idleTimeoutId);
23420
23421 var msecs = item._idleTimeout;
23422 if (msecs >= 0) {
23423 item._idleTimeoutId = setTimeout(function onTimeout() {
23424 if (item._onTimeout)
23425 item._onTimeout();
23426 }, msecs);
23427 }
23428};
23429
23430// That's not how node.js implements it but the exposed api is the same.
23431exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
23432 var id = nextImmediateId++;
23433 var args = arguments.length < 2 ? false : slice.call(arguments, 1);
23434
23435 immediateIds[id] = true;
23436
23437 nextTick(function onNextTick() {
23438 if (immediateIds[id]) {
23439 // fn.call() is faster so we optimize for the common use-case
23440 // @see http://jsperf.com/call-apply-segu
23441 if (args) {
23442 fn.apply(null, args);
23443 } else {
23444 fn.call(null);
23445 }
23446 // Prevent ids from leaking
23447 exports.clearImmediate(id);
23448 }
23449 });
23450
23451 return id;
23452};
23453
23454exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
23455 delete immediateIds[id];
23456};
23457}).call(this,require("timers").setImmediate,require("timers").clearImmediate)
23458},{"process/browser.js":249,"timers":277}],278:[function(require,module,exports){
23459var Buffer = require('buffer').Buffer
23460
23461module.exports = function (buf) {
23462 // If the buffer is backed by a Uint8Array, a faster version will work
23463 if (buf instanceof Uint8Array) {
23464 // If the buffer isn't a subarray, return the underlying ArrayBuffer
23465 if (buf.byteOffset === 0 && buf.byteLength === buf.buffer.byteLength) {
23466 return buf.buffer
23467 } else if (typeof buf.buffer.slice === 'function') {
23468 // Otherwise we need to get a proper copy
23469 return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength)
23470 }
23471 }
23472
23473 if (Buffer.isBuffer(buf)) {
23474 // This is the slow version that will work with any Buffer
23475 // implementation (even in old browsers)
23476 var arrayCopy = new Uint8Array(buf.length)
23477 var len = buf.length
23478 for (var i = 0; i < len; i++) {
23479 arrayCopy[i] = buf[i]
23480 }
23481 return arrayCopy.buffer
23482 } else {
23483 throw new Error('Argument must be a Buffer')
23484 }
23485}
23486
23487},{"buffer":70}],279:[function(require,module,exports){
23488// Copyright Joyent, Inc. and other Node contributors.
23489//
23490// Permission is hereby granted, free of charge, to any person obtaining a
23491// copy of this software and associated documentation files (the
23492// "Software"), to deal in the Software without restriction, including
23493// without limitation the rights to use, copy, modify, merge, publish,
23494// distribute, sublicense, and/or sell copies of the Software, and to permit
23495// persons to whom the Software is furnished to do so, subject to the
23496// following conditions:
23497//
23498// The above copyright notice and this permission notice shall be included
23499// in all copies or substantial portions of the Software.
23500//
23501// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23502// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23503// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
23504// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
23505// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23506// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
23507// USE OR OTHER DEALINGS IN THE SOFTWARE.
23508
23509'use strict';
23510
23511var punycode = require('punycode');
23512var util = require('./util');
23513
23514exports.parse = urlParse;
23515exports.resolve = urlResolve;
23516exports.resolveObject = urlResolveObject;
23517exports.format = urlFormat;
23518
23519exports.Url = Url;
23520
23521function Url() {
23522 this.protocol = null;
23523 this.slashes = null;
23524 this.auth = null;
23525 this.host = null;
23526 this.port = null;
23527 this.hostname = null;
23528 this.hash = null;
23529 this.search = null;
23530 this.query = null;
23531 this.pathname = null;
23532 this.path = null;
23533 this.href = null;
23534}
23535
23536// Reference: RFC 3986, RFC 1808, RFC 2396
23537
23538// define these here so at least they only have to be
23539// compiled once on the first module load.
23540var protocolPattern = /^([a-z0-9.+-]+:)/i,
23541 portPattern = /:[0-9]*$/,
23542
23543 // Special case for a simple path URL
23544 simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
23545
23546 // RFC 2396: characters reserved for delimiting URLs.
23547 // We actually just auto-escape these.
23548 delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
23549
23550 // RFC 2396: characters not allowed for various reasons.
23551 unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
23552
23553 // Allowed by RFCs, but cause of XSS attacks. Always escape these.
23554 autoEscape = ['\''].concat(unwise),
23555 // Characters that are never ever allowed in a hostname.
23556 // Note that any invalid chars are also handled, but these
23557 // are the ones that are *expected* to be seen, so we fast-path
23558 // them.
23559 nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
23560 hostEndingChars = ['/', '?', '#'],
23561 hostnameMaxLen = 255,
23562 hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
23563 hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
23564 // protocols that can allow "unsafe" and "unwise" chars.
23565 unsafeProtocol = {
23566 'javascript': true,
23567 'javascript:': true
23568 },
23569 // protocols that never have a hostname.
23570 hostlessProtocol = {
23571 'javascript': true,
23572 'javascript:': true
23573 },
23574 // protocols that always contain a // bit.
23575 slashedProtocol = {
23576 'http': true,
23577 'https': true,
23578 'ftp': true,
23579 'gopher': true,
23580 'file': true,
23581 'http:': true,
23582 'https:': true,
23583 'ftp:': true,
23584 'gopher:': true,
23585 'file:': true
23586 },
23587 querystring = require('querystring');
23588
23589function urlParse(url, parseQueryString, slashesDenoteHost) {
23590 if (url && util.isObject(url) && url instanceof Url) return url;
23591
23592 var u = new Url;
23593 u.parse(url, parseQueryString, slashesDenoteHost);
23594 return u;
23595}
23596
23597Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
23598 if (!util.isString(url)) {
23599 throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
23600 }
23601
23602 // Copy chrome, IE, opera backslash-handling behavior.
23603 // Back slashes before the query string get converted to forward slashes
23604 // See: https://code.google.com/p/chromium/issues/detail?id=25916
23605 var queryIndex = url.indexOf('?'),
23606 splitter =
23607 (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',
23608 uSplit = url.split(splitter),
23609 slashRegex = /\\/g;
23610 uSplit[0] = uSplit[0].replace(slashRegex, '/');
23611 url = uSplit.join(splitter);
23612
23613 var rest = url;
23614
23615 // trim before proceeding.
23616 // This is to support parse stuff like " http://foo.com \n"
23617 rest = rest.trim();
23618
23619 if (!slashesDenoteHost && url.split('#').length === 1) {
23620 // Try fast path regexp
23621 var simplePath = simplePathPattern.exec(rest);
23622 if (simplePath) {
23623 this.path = rest;
23624 this.href = rest;
23625 this.pathname = simplePath[1];
23626 if (simplePath[2]) {
23627 this.search = simplePath[2];
23628 if (parseQueryString) {
23629 this.query = querystring.parse(this.search.substr(1));
23630 } else {
23631 this.query = this.search.substr(1);
23632 }
23633 } else if (parseQueryString) {
23634 this.search = '';
23635 this.query = {};
23636 }
23637 return this;
23638 }
23639 }
23640
23641 var proto = protocolPattern.exec(rest);
23642 if (proto) {
23643 proto = proto[0];
23644 var lowerProto = proto.toLowerCase();
23645 this.protocol = lowerProto;
23646 rest = rest.substr(proto.length);
23647 }
23648
23649 // figure out if it's got a host
23650 // user@server is *always* interpreted as a hostname, and url
23651 // resolution will treat //foo/bar as host=foo,path=bar because that's
23652 // how the browser resolves relative URLs.
23653 if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
23654 var slashes = rest.substr(0, 2) === '//';
23655 if (slashes && !(proto && hostlessProtocol[proto])) {
23656 rest = rest.substr(2);
23657 this.slashes = true;
23658 }
23659 }
23660
23661 if (!hostlessProtocol[proto] &&
23662 (slashes || (proto && !slashedProtocol[proto]))) {
23663
23664 // there's a hostname.
23665 // the first instance of /, ?, ;, or # ends the host.
23666 //
23667 // If there is an @ in the hostname, then non-host chars *are* allowed
23668 // to the left of the last @ sign, unless some host-ending character
23669 // comes *before* the @-sign.
23670 // URLs are obnoxious.
23671 //
23672 // ex:
23673 // http://a@b@c/ => user:a@b host:c
23674 // http://a@b?@c => user:a host:c path:/?@c
23675
23676 // v0.12 TODO(isaacs): This is not quite how Chrome does things.
23677 // Review our test case against browsers more comprehensively.
23678
23679 // find the first instance of any hostEndingChars
23680 var hostEnd = -1;
23681 for (var i = 0; i < hostEndingChars.length; i++) {
23682 var hec = rest.indexOf(hostEndingChars[i]);
23683 if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
23684 hostEnd = hec;
23685 }
23686
23687 // at this point, either we have an explicit point where the
23688 // auth portion cannot go past, or the last @ char is the decider.
23689 var auth, atSign;
23690 if (hostEnd === -1) {
23691 // atSign can be anywhere.
23692 atSign = rest.lastIndexOf('@');
23693 } else {
23694 // atSign must be in auth portion.
23695 // http://a@b/c@d => host:b auth:a path:/c@d
23696 atSign = rest.lastIndexOf('@', hostEnd);
23697 }
23698
23699 // Now we have a portion which is definitely the auth.
23700 // Pull that off.
23701 if (atSign !== -1) {
23702 auth = rest.slice(0, atSign);
23703 rest = rest.slice(atSign + 1);
23704 this.auth = decodeURIComponent(auth);
23705 }
23706
23707 // the host is the remaining to the left of the first non-host char
23708 hostEnd = -1;
23709 for (var i = 0; i < nonHostChars.length; i++) {
23710 var hec = rest.indexOf(nonHostChars[i]);
23711 if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
23712 hostEnd = hec;
23713 }
23714 // if we still have not hit it, then the entire thing is a host.
23715 if (hostEnd === -1)
23716 hostEnd = rest.length;
23717
23718 this.host = rest.slice(0, hostEnd);
23719 rest = rest.slice(hostEnd);
23720
23721 // pull out port.
23722 this.parseHost();
23723
23724 // we've indicated that there is a hostname,
23725 // so even if it's empty, it has to be present.
23726 this.hostname = this.hostname || '';
23727
23728 // if hostname begins with [ and ends with ]
23729 // assume that it's an IPv6 address.
23730 var ipv6Hostname = this.hostname[0] === '[' &&
23731 this.hostname[this.hostname.length - 1] === ']';
23732
23733 // validate a little.
23734 if (!ipv6Hostname) {
23735 var hostparts = this.hostname.split(/\./);
23736 for (var i = 0, l = hostparts.length; i < l; i++) {
23737 var part = hostparts[i];
23738 if (!part) continue;
23739 if (!part.match(hostnamePartPattern)) {
23740 var newpart = '';
23741 for (var j = 0, k = part.length; j < k; j++) {
23742 if (part.charCodeAt(j) > 127) {
23743 // we replace non-ASCII char with a temporary placeholder
23744 // we need this to make sure size of hostname is not
23745 // broken by replacing non-ASCII by nothing
23746 newpart += 'x';
23747 } else {
23748 newpart += part[j];
23749 }
23750 }
23751 // we test again with ASCII char only
23752 if (!newpart.match(hostnamePartPattern)) {
23753 var validParts = hostparts.slice(0, i);
23754 var notHost = hostparts.slice(i + 1);
23755 var bit = part.match(hostnamePartStart);
23756 if (bit) {
23757 validParts.push(bit[1]);
23758 notHost.unshift(bit[2]);
23759 }
23760 if (notHost.length) {
23761 rest = '/' + notHost.join('.') + rest;
23762 }
23763 this.hostname = validParts.join('.');
23764 break;
23765 }
23766 }
23767 }
23768 }
23769
23770 if (this.hostname.length > hostnameMaxLen) {
23771 this.hostname = '';
23772 } else {
23773 // hostnames are always lower case.
23774 this.hostname = this.hostname.toLowerCase();
23775 }
23776
23777 if (!ipv6Hostname) {
23778 // IDNA Support: Returns a punycoded representation of "domain".
23779 // It only converts parts of the domain name that
23780 // have non-ASCII characters, i.e. it doesn't matter if
23781 // you call it with a domain that already is ASCII-only.
23782 this.hostname = punycode.toASCII(this.hostname);
23783 }
23784
23785 var p = this.port ? ':' + this.port : '';
23786 var h = this.hostname || '';
23787 this.host = h + p;
23788 this.href += this.host;
23789
23790 // strip [ and ] from the hostname
23791 // the host field still retains them, though
23792 if (ipv6Hostname) {
23793 this.hostname = this.hostname.substr(1, this.hostname.length - 2);
23794 if (rest[0] !== '/') {
23795 rest = '/' + rest;
23796 }
23797 }
23798 }
23799
23800 // now rest is set to the post-host stuff.
23801 // chop off any delim chars.
23802 if (!unsafeProtocol[lowerProto]) {
23803
23804 // First, make 100% sure that any "autoEscape" chars get
23805 // escaped, even if encodeURIComponent doesn't think they
23806 // need to be.
23807 for (var i = 0, l = autoEscape.length; i < l; i++) {
23808 var ae = autoEscape[i];
23809 if (rest.indexOf(ae) === -1)
23810 continue;
23811 var esc = encodeURIComponent(ae);
23812 if (esc === ae) {
23813 esc = escape(ae);
23814 }
23815 rest = rest.split(ae).join(esc);
23816 }
23817 }
23818
23819
23820 // chop off from the tail first.
23821 var hash = rest.indexOf('#');
23822 if (hash !== -1) {
23823 // got a fragment string.
23824 this.hash = rest.substr(hash);
23825 rest = rest.slice(0, hash);
23826 }
23827 var qm = rest.indexOf('?');
23828 if (qm !== -1) {
23829 this.search = rest.substr(qm);
23830 this.query = rest.substr(qm + 1);
23831 if (parseQueryString) {
23832 this.query = querystring.parse(this.query);
23833 }
23834 rest = rest.slice(0, qm);
23835 } else if (parseQueryString) {
23836 // no query string, but parseQueryString still requested
23837 this.search = '';
23838 this.query = {};
23839 }
23840 if (rest) this.pathname = rest;
23841 if (slashedProtocol[lowerProto] &&
23842 this.hostname && !this.pathname) {
23843 this.pathname = '/';
23844 }
23845
23846 //to support http.request
23847 if (this.pathname || this.search) {
23848 var p = this.pathname || '';
23849 var s = this.search || '';
23850 this.path = p + s;
23851 }
23852
23853 // finally, reconstruct the href based on what has been validated.
23854 this.href = this.format();
23855 return this;
23856};
23857
23858// format a parsed object into a url string
23859function urlFormat(obj) {
23860 // ensure it's an object, and not a string url.
23861 // If it's an obj, this is a no-op.
23862 // this way, you can call url_format() on strings
23863 // to clean up potentially wonky urls.
23864 if (util.isString(obj)) obj = urlParse(obj);
23865 if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
23866 return obj.format();
23867}
23868
23869Url.prototype.format = function() {
23870 var auth = this.auth || '';
23871 if (auth) {
23872 auth = encodeURIComponent(auth);
23873 auth = auth.replace(/%3A/i, ':');
23874 auth += '@';
23875 }
23876
23877 var protocol = this.protocol || '',
23878 pathname = this.pathname || '',
23879 hash = this.hash || '',
23880 host = false,
23881 query = '';
23882
23883 if (this.host) {
23884 host = auth + this.host;
23885 } else if (this.hostname) {
23886 host = auth + (this.hostname.indexOf(':') === -1 ?
23887 this.hostname :
23888 '[' + this.hostname + ']');
23889 if (this.port) {
23890 host += ':' + this.port;
23891 }
23892 }
23893
23894 if (this.query &&
23895 util.isObject(this.query) &&
23896 Object.keys(this.query).length) {
23897 query = querystring.stringify(this.query);
23898 }
23899
23900 var search = this.search || (query && ('?' + query)) || '';
23901
23902 if (protocol && protocol.substr(-1) !== ':') protocol += ':';
23903
23904 // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
23905 // unless they had them to begin with.
23906 if (this.slashes ||
23907 (!protocol || slashedProtocol[protocol]) && host !== false) {
23908 host = '//' + (host || '');
23909 if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
23910 } else if (!host) {
23911 host = '';
23912 }
23913
23914 if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
23915 if (search && search.charAt(0) !== '?') search = '?' + search;
23916
23917 pathname = pathname.replace(/[?#]/g, function(match) {
23918 return encodeURIComponent(match);
23919 });
23920 search = search.replace('#', '%23');
23921
23922 return protocol + host + pathname + search + hash;
23923};
23924
23925function urlResolve(source, relative) {
23926 return urlParse(source, false, true).resolve(relative);
23927}
23928
23929Url.prototype.resolve = function(relative) {
23930 return this.resolveObject(urlParse(relative, false, true)).format();
23931};
23932
23933function urlResolveObject(source, relative) {
23934 if (!source) return relative;
23935 return urlParse(source, false, true).resolveObject(relative);
23936}
23937
23938Url.prototype.resolveObject = function(relative) {
23939 if (util.isString(relative)) {
23940 var rel = new Url();
23941 rel.parse(relative, false, true);
23942 relative = rel;
23943 }
23944
23945 var result = new Url();
23946 var tkeys = Object.keys(this);
23947 for (var tk = 0; tk < tkeys.length; tk++) {
23948 var tkey = tkeys[tk];
23949 result[tkey] = this[tkey];
23950 }
23951
23952 // hash is always overridden, no matter what.
23953 // even href="" will remove it.
23954 result.hash = relative.hash;
23955
23956 // if the relative url is empty, then there's nothing left to do here.
23957 if (relative.href === '') {
23958 result.href = result.format();
23959 return result;
23960 }
23961
23962 // hrefs like //foo/bar always cut to the protocol.
23963 if (relative.slashes && !relative.protocol) {
23964 // take everything except the protocol from relative
23965 var rkeys = Object.keys(relative);
23966 for (var rk = 0; rk < rkeys.length; rk++) {
23967 var rkey = rkeys[rk];
23968 if (rkey !== 'protocol')
23969 result[rkey] = relative[rkey];
23970 }
23971
23972 //urlParse appends trailing / to urls like http://www.example.com
23973 if (slashedProtocol[result.protocol] &&
23974 result.hostname && !result.pathname) {
23975 result.path = result.pathname = '/';
23976 }
23977
23978 result.href = result.format();
23979 return result;
23980 }
23981
23982 if (relative.protocol && relative.protocol !== result.protocol) {
23983 // if it's a known url protocol, then changing
23984 // the protocol does weird things
23985 // first, if it's not file:, then we MUST have a host,
23986 // and if there was a path
23987 // to begin with, then we MUST have a path.
23988 // if it is file:, then the host is dropped,
23989 // because that's known to be hostless.
23990 // anything else is assumed to be absolute.
23991 if (!slashedProtocol[relative.protocol]) {
23992 var keys = Object.keys(relative);
23993 for (var v = 0; v < keys.length; v++) {
23994 var k = keys[v];
23995 result[k] = relative[k];
23996 }
23997 result.href = result.format();
23998 return result;
23999 }
24000
24001 result.protocol = relative.protocol;
24002 if (!relative.host && !hostlessProtocol[relative.protocol]) {
24003 var relPath = (relative.pathname || '').split('/');
24004 while (relPath.length && !(relative.host = relPath.shift()));
24005 if (!relative.host) relative.host = '';
24006 if (!relative.hostname) relative.hostname = '';
24007 if (relPath[0] !== '') relPath.unshift('');
24008 if (relPath.length < 2) relPath.unshift('');
24009 result.pathname = relPath.join('/');
24010 } else {
24011 result.pathname = relative.pathname;
24012 }
24013 result.search = relative.search;
24014 result.query = relative.query;
24015 result.host = relative.host || '';
24016 result.auth = relative.auth;
24017 result.hostname = relative.hostname || relative.host;
24018 result.port = relative.port;
24019 // to support http.request
24020 if (result.pathname || result.search) {
24021 var p = result.pathname || '';
24022 var s = result.search || '';
24023 result.path = p + s;
24024 }
24025 result.slashes = result.slashes || relative.slashes;
24026 result.href = result.format();
24027 return result;
24028 }
24029
24030 var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
24031 isRelAbs = (
24032 relative.host ||
24033 relative.pathname && relative.pathname.charAt(0) === '/'
24034 ),
24035 mustEndAbs = (isRelAbs || isSourceAbs ||
24036 (result.host && relative.pathname)),
24037 removeAllDots = mustEndAbs,
24038 srcPath = result.pathname && result.pathname.split('/') || [],
24039 relPath = relative.pathname && relative.pathname.split('/') || [],
24040 psychotic = result.protocol && !slashedProtocol[result.protocol];
24041
24042 // if the url is a non-slashed url, then relative
24043 // links like ../.. should be able
24044 // to crawl up to the hostname, as well. This is strange.
24045 // result.protocol has already been set by now.
24046 // Later on, put the first path part into the host field.
24047 if (psychotic) {
24048 result.hostname = '';
24049 result.port = null;
24050 if (result.host) {
24051 if (srcPath[0] === '') srcPath[0] = result.host;
24052 else srcPath.unshift(result.host);
24053 }
24054 result.host = '';
24055 if (relative.protocol) {
24056 relative.hostname = null;
24057 relative.port = null;
24058 if (relative.host) {
24059 if (relPath[0] === '') relPath[0] = relative.host;
24060 else relPath.unshift(relative.host);
24061 }
24062 relative.host = null;
24063 }
24064 mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
24065 }
24066
24067 if (isRelAbs) {
24068 // it's absolute.
24069 result.host = (relative.host || relative.host === '') ?
24070 relative.host : result.host;
24071 result.hostname = (relative.hostname || relative.hostname === '') ?
24072 relative.hostname : result.hostname;
24073 result.search = relative.search;
24074 result.query = relative.query;
24075 srcPath = relPath;
24076 // fall through to the dot-handling below.
24077 } else if (relPath.length) {
24078 // it's relative
24079 // throw away the existing file, and take the new path instead.
24080 if (!srcPath) srcPath = [];
24081 srcPath.pop();
24082 srcPath = srcPath.concat(relPath);
24083 result.search = relative.search;
24084 result.query = relative.query;
24085 } else if (!util.isNullOrUndefined(relative.search)) {
24086 // just pull out the search.
24087 // like href='?foo'.
24088 // Put this after the other two cases because it simplifies the booleans
24089 if (psychotic) {
24090 result.hostname = result.host = srcPath.shift();
24091 //occationaly the auth can get stuck only in host
24092 //this especially happens in cases like
24093 //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
24094 var authInHost = result.host && result.host.indexOf('@') > 0 ?
24095 result.host.split('@') : false;
24096 if (authInHost) {
24097 result.auth = authInHost.shift();
24098 result.host = result.hostname = authInHost.shift();
24099 }
24100 }
24101 result.search = relative.search;
24102 result.query = relative.query;
24103 //to support http.request
24104 if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
24105 result.path = (result.pathname ? result.pathname : '') +
24106 (result.search ? result.search : '');
24107 }
24108 result.href = result.format();
24109 return result;
24110 }
24111
24112 if (!srcPath.length) {
24113 // no path at all. easy.
24114 // we've already handled the other stuff above.
24115 result.pathname = null;
24116 //to support http.request
24117 if (result.search) {
24118 result.path = '/' + result.search;
24119 } else {
24120 result.path = null;
24121 }
24122 result.href = result.format();
24123 return result;
24124 }
24125
24126 // if a url ENDs in . or .., then it must get a trailing slash.
24127 // however, if it ends in anything else non-slashy,
24128 // then it must NOT get a trailing slash.
24129 var last = srcPath.slice(-1)[0];
24130 var hasTrailingSlash = (
24131 (result.host || relative.host || srcPath.length > 1) &&
24132 (last === '.' || last === '..') || last === '');
24133
24134 // strip single dots, resolve double dots to parent dir
24135 // if the path tries to go above the root, `up` ends up > 0
24136 var up = 0;
24137 for (var i = srcPath.length; i >= 0; i--) {
24138 last = srcPath[i];
24139 if (last === '.') {
24140 srcPath.splice(i, 1);
24141 } else if (last === '..') {
24142 srcPath.splice(i, 1);
24143 up++;
24144 } else if (up) {
24145 srcPath.splice(i, 1);
24146 up--;
24147 }
24148 }
24149
24150 // if the path is allowed to go above the root, restore leading ..s
24151 if (!mustEndAbs && !removeAllDots) {
24152 for (; up--; up) {
24153 srcPath.unshift('..');
24154 }
24155 }
24156
24157 if (mustEndAbs && srcPath[0] !== '' &&
24158 (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
24159 srcPath.unshift('');
24160 }
24161
24162 if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
24163 srcPath.push('');
24164 }
24165
24166 var isAbsolute = srcPath[0] === '' ||
24167 (srcPath[0] && srcPath[0].charAt(0) === '/');
24168
24169 // put the host back
24170 if (psychotic) {
24171 result.hostname = result.host = isAbsolute ? '' :
24172 srcPath.length ? srcPath.shift() : '';
24173 //occationaly the auth can get stuck only in host
24174 //this especially happens in cases like
24175 //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
24176 var authInHost = result.host && result.host.indexOf('@') > 0 ?
24177 result.host.split('@') : false;
24178 if (authInHost) {
24179 result.auth = authInHost.shift();
24180 result.host = result.hostname = authInHost.shift();
24181 }
24182 }
24183
24184 mustEndAbs = mustEndAbs || (result.host && srcPath.length);
24185
24186 if (mustEndAbs && !isAbsolute) {
24187 srcPath.unshift('');
24188 }
24189
24190 if (!srcPath.length) {
24191 result.pathname = null;
24192 result.path = null;
24193 } else {
24194 result.pathname = srcPath.join('/');
24195 }
24196
24197 //to support request.http
24198 if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
24199 result.path = (result.pathname ? result.pathname : '') +
24200 (result.search ? result.search : '');
24201 }
24202 result.auth = relative.auth || result.auth;
24203 result.slashes = result.slashes || relative.slashes;
24204 result.href = result.format();
24205 return result;
24206};
24207
24208Url.prototype.parseHost = function() {
24209 var host = this.host;
24210 var port = portPattern.exec(host);
24211 if (port) {
24212 port = port[0];
24213 if (port !== ':') {
24214 this.port = port.substr(1);
24215 }
24216 host = host.substr(0, host.length - port.length);
24217 }
24218 if (host) this.hostname = host;
24219};
24220
24221},{"./util":280,"punycode":250,"querystring":253}],280:[function(require,module,exports){
24222'use strict';
24223
24224module.exports = {
24225 isString: function(arg) {
24226 return typeof(arg) === 'string';
24227 },
24228 isObject: function(arg) {
24229 return typeof(arg) === 'object' && arg !== null;
24230 },
24231 isNull: function(arg) {
24232 return arg === null;
24233 },
24234 isNullOrUndefined: function(arg) {
24235 return arg == null;
24236 }
24237};
24238
24239},{}],281:[function(require,module,exports){
24240(function (global){
24241
24242/**
24243 * Module exports.
24244 */
24245
24246module.exports = deprecate;
24247
24248/**
24249 * Mark that a method should not be used.
24250 * Returns a modified function which warns once by default.
24251 *
24252 * If `localStorage.noDeprecation = true` is set, then it is a no-op.
24253 *
24254 * If `localStorage.throwDeprecation = true` is set, then deprecated functions
24255 * will throw an Error when invoked.
24256 *
24257 * If `localStorage.traceDeprecation = true` is set, then deprecated functions
24258 * will invoke `console.trace()` instead of `console.error()`.
24259 *
24260 * @param {Function} fn - the function to deprecate
24261 * @param {String} msg - the string to print to the console when `fn` is invoked
24262 * @returns {Function} a new "deprecated" version of `fn`
24263 * @api public
24264 */
24265
24266function deprecate (fn, msg) {
24267 if (config('noDeprecation')) {
24268 return fn;
24269 }
24270
24271 var warned = false;
24272 function deprecated() {
24273 if (!warned) {
24274 if (config('throwDeprecation')) {
24275 throw new Error(msg);
24276 } else if (config('traceDeprecation')) {
24277 console.trace(msg);
24278 } else {
24279 console.warn(msg);
24280 }
24281 warned = true;
24282 }
24283 return fn.apply(this, arguments);
24284 }
24285
24286 return deprecated;
24287}
24288
24289/**
24290 * Checks `localStorage` for boolean values for the given `name`.
24291 *
24292 * @param {String} name
24293 * @returns {Boolean}
24294 * @api private
24295 */
24296
24297function config (name) {
24298 // accessing global.localStorage can trigger a DOMException in sandboxed iframes
24299 try {
24300 if (!global.localStorage) return false;
24301 } catch (_) {
24302 return false;
24303 }
24304 var val = global.localStorage[name];
24305 if (null == val) return false;
24306 return String(val).toLowerCase() === 'true';
24307}
24308
24309}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
24310},{}],282:[function(require,module,exports){
24311'use strict';
24312
24313var isES5 = typeof Object.defineProperty === 'function'
24314 && typeof Object.defineProperties === 'function'
24315 && typeof Object.getPrototypeOf === 'function'
24316 && typeof Object.setPrototypeOf === 'function';
24317
24318if (!isES5) {
24319 throw new TypeError('util.promisify requires a true ES5 environment');
24320}
24321
24322var getOwnPropertyDescriptors = require('object.getownpropertydescriptors');
24323
24324if (typeof Promise !== 'function') {
24325 throw new TypeError('`Promise` must be globally available for util.promisify to work.');
24326}
24327
24328var slice = Function.call.bind(Array.prototype.slice);
24329var concat = Function.call.bind(Array.prototype.concat);
24330var forEach = Function.call.bind(Array.prototype.forEach);
24331
24332var hasSymbols = typeof Symbol === 'function' && typeof Symbol('') === 'symbol';
24333
24334var kCustomPromisifiedSymbol = hasSymbols ? Symbol('util.promisify.custom') : null;
24335var kCustomPromisifyArgsSymbol = hasSymbols ? Symbol('customPromisifyArgs') : null;
24336
24337module.exports = function promisify(orig) {
24338 if (typeof orig !== 'function') {
24339 var error = new TypeError('The "original" argument must be of type function');
24340 error.name = 'TypeError [ERR_INVALID_ARG_TYPE]';
24341 error.code = 'ERR_INVALID_ARG_TYPE';
24342 throw error;
24343 }
24344
24345 if (hasSymbols && orig[kCustomPromisifiedSymbol]) {
24346 var customFunction = orig[kCustomPromisifiedSymbol];
24347 if (typeof customFunction !== 'function') {
24348 throw new TypeError('The [util.promisify.custom] property must be a function');
24349 }
24350 Object.defineProperty(customFunction, kCustomPromisifiedSymbol, {
24351 configurable: true,
24352 enumerable: false,
24353 value: customFunction,
24354 writable: false
24355 });
24356 return customFunction;
24357 }
24358
24359 // Names to create an object from in case the callback receives multiple
24360 // arguments, e.g. ['stdout', 'stderr'] for child_process.exec.
24361 var argumentNames = orig[kCustomPromisifyArgsSymbol];
24362
24363 var promisified = function fn() {
24364 var args = slice(arguments);
24365 var self = this; // eslint-disable-line no-invalid-this
24366 return new Promise(function (resolve, reject) {
24367 orig.apply(self, concat(args, function (err) {
24368 var values = arguments.length > 1 ? slice(arguments, 1) : [];
24369 if (err) {
24370 reject(err);
24371 } else if (typeof argumentNames !== 'undefined' && values.length > 1) {
24372 var obj = {};
24373 forEach(argumentNames, function (name, index) {
24374 obj[name] = values[index];
24375 });
24376 resolve(obj);
24377 } else {
24378 resolve(values[0]);
24379 }
24380 }));
24381 });
24382 };
24383
24384 Object.setPrototypeOf(promisified, Object.getPrototypeOf(orig));
24385
24386 Object.defineProperty(promisified, kCustomPromisifiedSymbol, {
24387 configurable: true,
24388 enumerable: false,
24389 value: promisified,
24390 writable: false
24391 });
24392 return Object.defineProperties(promisified, getOwnPropertyDescriptors(orig));
24393};
24394
24395module.exports.custom = kCustomPromisifiedSymbol;
24396module.exports.customPromisifyArgs = kCustomPromisifyArgsSymbol;
24397
24398},{"object.getownpropertydescriptors":243}],283:[function(require,module,exports){
24399'use strict';
24400
24401var define = require('define-properties');
24402var util = require('util');
24403
24404var implementation = require('./implementation');
24405var getPolyfill = require('./polyfill');
24406var polyfill = getPolyfill();
24407var shim = require('./shim');
24408
24409/* eslint-disable no-unused-vars */
24410var boundPromisify = function promisify(orig) {
24411/* eslint-enable no-unused-vars */
24412 return polyfill.apply(util, arguments);
24413};
24414define(boundPromisify, {
24415 custom: polyfill.custom,
24416 customPromisifyArgs: polyfill.customPromisifyArgs,
24417 getPolyfill: getPolyfill,
24418 implementation: implementation,
24419 shim: shim
24420});
24421
24422module.exports = boundPromisify;
24423
24424},{"./implementation":282,"./polyfill":284,"./shim":285,"define-properties":190,"util":287}],284:[function(require,module,exports){
24425'use strict';
24426
24427var util = require('util');
24428var implementation = require('./implementation');
24429
24430module.exports = function getPolyfill() {
24431 if (typeof util.promisify === 'function') {
24432 return util.promisify;
24433 }
24434 return implementation;
24435};
24436
24437},{"./implementation":282,"util":287}],285:[function(require,module,exports){
24438'use strict';
24439
24440var util = require('util');
24441var getPolyfill = require('./polyfill');
24442
24443module.exports = function shimUtilPromisify() {
24444 var polyfill = getPolyfill();
24445 if (polyfill !== util.promisify) {
24446 util.promisify = polyfill;
24447 Object.defineProperty(util, 'promisify', { value: polyfill });
24448 }
24449 return polyfill;
24450};
24451
24452},{"./polyfill":284,"util":287}],286:[function(require,module,exports){
24453module.exports = function isBuffer(arg) {
24454 return arg && typeof arg === 'object'
24455 && typeof arg.copy === 'function'
24456 && typeof arg.fill === 'function'
24457 && typeof arg.readUInt8 === 'function';
24458}
24459},{}],287:[function(require,module,exports){
24460(function (process,global){
24461// Copyright Joyent, Inc. and other Node contributors.
24462//
24463// Permission is hereby granted, free of charge, to any person obtaining a
24464// copy of this software and associated documentation files (the
24465// "Software"), to deal in the Software without restriction, including
24466// without limitation the rights to use, copy, modify, merge, publish,
24467// distribute, sublicense, and/or sell copies of the Software, and to permit
24468// persons to whom the Software is furnished to do so, subject to the
24469// following conditions:
24470//
24471// The above copyright notice and this permission notice shall be included
24472// in all copies or substantial portions of the Software.
24473//
24474// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24475// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24476// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
24477// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
24478// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24479// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24480// USE OR OTHER DEALINGS IN THE SOFTWARE.
24481
24482var formatRegExp = /%[sdj%]/g;
24483exports.format = function(f) {
24484 if (!isString(f)) {
24485 var objects = [];
24486 for (var i = 0; i < arguments.length; i++) {
24487 objects.push(inspect(arguments[i]));
24488 }
24489 return objects.join(' ');
24490 }
24491
24492 var i = 1;
24493 var args = arguments;
24494 var len = args.length;
24495 var str = String(f).replace(formatRegExp, function(x) {
24496 if (x === '%%') return '%';
24497 if (i >= len) return x;
24498 switch (x) {
24499 case '%s': return String(args[i++]);
24500 case '%d': return Number(args[i++]);
24501 case '%j':
24502 try {
24503 return JSON.stringify(args[i++]);
24504 } catch (_) {
24505 return '[Circular]';
24506 }
24507 default:
24508 return x;
24509 }
24510 });
24511 for (var x = args[i]; i < len; x = args[++i]) {
24512 if (isNull(x) || !isObject(x)) {
24513 str += ' ' + x;
24514 } else {
24515 str += ' ' + inspect(x);
24516 }
24517 }
24518 return str;
24519};
24520
24521
24522// Mark that a method should not be used.
24523// Returns a modified function which warns once by default.
24524// If --no-deprecation is set, then it is a no-op.
24525exports.deprecate = function(fn, msg) {
24526 // Allow for deprecating things in the process of starting up.
24527 if (isUndefined(global.process)) {
24528 return function() {
24529 return exports.deprecate(fn, msg).apply(this, arguments);
24530 };
24531 }
24532
24533 if (process.noDeprecation === true) {
24534 return fn;
24535 }
24536
24537 var warned = false;
24538 function deprecated() {
24539 if (!warned) {
24540 if (process.throwDeprecation) {
24541 throw new Error(msg);
24542 } else if (process.traceDeprecation) {
24543 console.trace(msg);
24544 } else {
24545 console.error(msg);
24546 }
24547 warned = true;
24548 }
24549 return fn.apply(this, arguments);
24550 }
24551
24552 return deprecated;
24553};
24554
24555
24556var debugs = {};
24557var debugEnviron;
24558exports.debuglog = function(set) {
24559 if (isUndefined(debugEnviron))
24560 debugEnviron = process.env.NODE_DEBUG || '';
24561 set = set.toUpperCase();
24562 if (!debugs[set]) {
24563 if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
24564 var pid = process.pid;
24565 debugs[set] = function() {
24566 var msg = exports.format.apply(exports, arguments);
24567 console.error('%s %d: %s', set, pid, msg);
24568 };
24569 } else {
24570 debugs[set] = function() {};
24571 }
24572 }
24573 return debugs[set];
24574};
24575
24576
24577/**
24578 * Echos the value of a value. Trys to print the value out
24579 * in the best way possible given the different types.
24580 *
24581 * @param {Object} obj The object to print out.
24582 * @param {Object} opts Optional options object that alters the output.
24583 */
24584/* legacy: obj, showHidden, depth, colors*/
24585function inspect(obj, opts) {
24586 // default options
24587 var ctx = {
24588 seen: [],
24589 stylize: stylizeNoColor
24590 };
24591 // legacy...
24592 if (arguments.length >= 3) ctx.depth = arguments[2];
24593 if (arguments.length >= 4) ctx.colors = arguments[3];
24594 if (isBoolean(opts)) {
24595 // legacy...
24596 ctx.showHidden = opts;
24597 } else if (opts) {
24598 // got an "options" object
24599 exports._extend(ctx, opts);
24600 }
24601 // set default options
24602 if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
24603 if (isUndefined(ctx.depth)) ctx.depth = 2;
24604 if (isUndefined(ctx.colors)) ctx.colors = false;
24605 if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
24606 if (ctx.colors) ctx.stylize = stylizeWithColor;
24607 return formatValue(ctx, obj, ctx.depth);
24608}
24609exports.inspect = inspect;
24610
24611
24612// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
24613inspect.colors = {
24614 'bold' : [1, 22],
24615 'italic' : [3, 23],
24616 'underline' : [4, 24],
24617 'inverse' : [7, 27],
24618 'white' : [37, 39],
24619 'grey' : [90, 39],
24620 'black' : [30, 39],
24621 'blue' : [34, 39],
24622 'cyan' : [36, 39],
24623 'green' : [32, 39],
24624 'magenta' : [35, 39],
24625 'red' : [31, 39],
24626 'yellow' : [33, 39]
24627};
24628
24629// Don't use 'blue' not visible on cmd.exe
24630inspect.styles = {
24631 'special': 'cyan',
24632 'number': 'yellow',
24633 'boolean': 'yellow',
24634 'undefined': 'grey',
24635 'null': 'bold',
24636 'string': 'green',
24637 'date': 'magenta',
24638 // "name": intentionally not styling
24639 'regexp': 'red'
24640};
24641
24642
24643function stylizeWithColor(str, styleType) {
24644 var style = inspect.styles[styleType];
24645
24646 if (style) {
24647 return '\u001b[' + inspect.colors[style][0] + 'm' + str +
24648 '\u001b[' + inspect.colors[style][1] + 'm';
24649 } else {
24650 return str;
24651 }
24652}
24653
24654
24655function stylizeNoColor(str, styleType) {
24656 return str;
24657}
24658
24659
24660function arrayToHash(array) {
24661 var hash = {};
24662
24663 array.forEach(function(val, idx) {
24664 hash[val] = true;
24665 });
24666
24667 return hash;
24668}
24669
24670
24671function formatValue(ctx, value, recurseTimes) {
24672 // Provide a hook for user-specified inspect functions.
24673 // Check that value is an object with an inspect function on it
24674 if (ctx.customInspect &&
24675 value &&
24676 isFunction(value.inspect) &&
24677 // Filter out the util module, it's inspect function is special
24678 value.inspect !== exports.inspect &&
24679 // Also filter out any prototype objects using the circular check.
24680 !(value.constructor && value.constructor.prototype === value)) {
24681 var ret = value.inspect(recurseTimes, ctx);
24682 if (!isString(ret)) {
24683 ret = formatValue(ctx, ret, recurseTimes);
24684 }
24685 return ret;
24686 }
24687
24688 // Primitive types cannot have properties
24689 var primitive = formatPrimitive(ctx, value);
24690 if (primitive) {
24691 return primitive;
24692 }
24693
24694 // Look up the keys of the object.
24695 var keys = Object.keys(value);
24696 var visibleKeys = arrayToHash(keys);
24697
24698 if (ctx.showHidden) {
24699 keys = Object.getOwnPropertyNames(value);
24700 }
24701
24702 // IE doesn't make error fields non-enumerable
24703 // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
24704 if (isError(value)
24705 && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
24706 return formatError(value);
24707 }
24708
24709 // Some type of object without properties can be shortcutted.
24710 if (keys.length === 0) {
24711 if (isFunction(value)) {
24712 var name = value.name ? ': ' + value.name : '';
24713 return ctx.stylize('[Function' + name + ']', 'special');
24714 }
24715 if (isRegExp(value)) {
24716 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
24717 }
24718 if (isDate(value)) {
24719 return ctx.stylize(Date.prototype.toString.call(value), 'date');
24720 }
24721 if (isError(value)) {
24722 return formatError(value);
24723 }
24724 }
24725
24726 var base = '', array = false, braces = ['{', '}'];
24727
24728 // Make Array say that they are Array
24729 if (isArray(value)) {
24730 array = true;
24731 braces = ['[', ']'];
24732 }
24733
24734 // Make functions say that they are functions
24735 if (isFunction(value)) {
24736 var n = value.name ? ': ' + value.name : '';
24737 base = ' [Function' + n + ']';
24738 }
24739
24740 // Make RegExps say that they are RegExps
24741 if (isRegExp(value)) {
24742 base = ' ' + RegExp.prototype.toString.call(value);
24743 }
24744
24745 // Make dates with properties first say the date
24746 if (isDate(value)) {
24747 base = ' ' + Date.prototype.toUTCString.call(value);
24748 }
24749
24750 // Make error with message first say the error
24751 if (isError(value)) {
24752 base = ' ' + formatError(value);
24753 }
24754
24755 if (keys.length === 0 && (!array || value.length == 0)) {
24756 return braces[0] + base + braces[1];
24757 }
24758
24759 if (recurseTimes < 0) {
24760 if (isRegExp(value)) {
24761 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
24762 } else {
24763 return ctx.stylize('[Object]', 'special');
24764 }
24765 }
24766
24767 ctx.seen.push(value);
24768
24769 var output;
24770 if (array) {
24771 output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
24772 } else {
24773 output = keys.map(function(key) {
24774 return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
24775 });
24776 }
24777
24778 ctx.seen.pop();
24779
24780 return reduceToSingleString(output, base, braces);
24781}
24782
24783
24784function formatPrimitive(ctx, value) {
24785 if (isUndefined(value))
24786 return ctx.stylize('undefined', 'undefined');
24787 if (isString(value)) {
24788 var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
24789 .replace(/'/g, "\\'")
24790 .replace(/\\"/g, '"') + '\'';
24791 return ctx.stylize(simple, 'string');
24792 }
24793 if (isNumber(value))
24794 return ctx.stylize('' + value, 'number');
24795 if (isBoolean(value))
24796 return ctx.stylize('' + value, 'boolean');
24797 // For some reason typeof null is "object", so special case here.
24798 if (isNull(value))
24799 return ctx.stylize('null', 'null');
24800}
24801
24802
24803function formatError(value) {
24804 return '[' + Error.prototype.toString.call(value) + ']';
24805}
24806
24807
24808function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
24809 var output = [];
24810 for (var i = 0, l = value.length; i < l; ++i) {
24811 if (hasOwnProperty(value, String(i))) {
24812 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
24813 String(i), true));
24814 } else {
24815 output.push('');
24816 }
24817 }
24818 keys.forEach(function(key) {
24819 if (!key.match(/^\d+$/)) {
24820 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
24821 key, true));
24822 }
24823 });
24824 return output;
24825}
24826
24827
24828function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
24829 var name, str, desc;
24830 desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
24831 if (desc.get) {
24832 if (desc.set) {
24833 str = ctx.stylize('[Getter/Setter]', 'special');
24834 } else {
24835 str = ctx.stylize('[Getter]', 'special');
24836 }
24837 } else {
24838 if (desc.set) {
24839 str = ctx.stylize('[Setter]', 'special');
24840 }
24841 }
24842 if (!hasOwnProperty(visibleKeys, key)) {
24843 name = '[' + key + ']';
24844 }
24845 if (!str) {
24846 if (ctx.seen.indexOf(desc.value) < 0) {
24847 if (isNull(recurseTimes)) {
24848 str = formatValue(ctx, desc.value, null);
24849 } else {
24850 str = formatValue(ctx, desc.value, recurseTimes - 1);
24851 }
24852 if (str.indexOf('\n') > -1) {
24853 if (array) {
24854 str = str.split('\n').map(function(line) {
24855 return ' ' + line;
24856 }).join('\n').substr(2);
24857 } else {
24858 str = '\n' + str.split('\n').map(function(line) {
24859 return ' ' + line;
24860 }).join('\n');
24861 }
24862 }
24863 } else {
24864 str = ctx.stylize('[Circular]', 'special');
24865 }
24866 }
24867 if (isUndefined(name)) {
24868 if (array && key.match(/^\d+$/)) {
24869 return str;
24870 }
24871 name = JSON.stringify('' + key);
24872 if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
24873 name = name.substr(1, name.length - 2);
24874 name = ctx.stylize(name, 'name');
24875 } else {
24876 name = name.replace(/'/g, "\\'")
24877 .replace(/\\"/g, '"')
24878 .replace(/(^"|"$)/g, "'");
24879 name = ctx.stylize(name, 'string');
24880 }
24881 }
24882
24883 return name + ': ' + str;
24884}
24885
24886
24887function reduceToSingleString(output, base, braces) {
24888 var numLinesEst = 0;
24889 var length = output.reduce(function(prev, cur) {
24890 numLinesEst++;
24891 if (cur.indexOf('\n') >= 0) numLinesEst++;
24892 return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
24893 }, 0);
24894
24895 if (length > 60) {
24896 return braces[0] +
24897 (base === '' ? '' : base + '\n ') +
24898 ' ' +
24899 output.join(',\n ') +
24900 ' ' +
24901 braces[1];
24902 }
24903
24904 return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
24905}
24906
24907
24908// NOTE: These type checking functions intentionally don't use `instanceof`
24909// because it is fragile and can be easily faked with `Object.create()`.
24910function isArray(ar) {
24911 return Array.isArray(ar);
24912}
24913exports.isArray = isArray;
24914
24915function isBoolean(arg) {
24916 return typeof arg === 'boolean';
24917}
24918exports.isBoolean = isBoolean;
24919
24920function isNull(arg) {
24921 return arg === null;
24922}
24923exports.isNull = isNull;
24924
24925function isNullOrUndefined(arg) {
24926 return arg == null;
24927}
24928exports.isNullOrUndefined = isNullOrUndefined;
24929
24930function isNumber(arg) {
24931 return typeof arg === 'number';
24932}
24933exports.isNumber = isNumber;
24934
24935function isString(arg) {
24936 return typeof arg === 'string';
24937}
24938exports.isString = isString;
24939
24940function isSymbol(arg) {
24941 return typeof arg === 'symbol';
24942}
24943exports.isSymbol = isSymbol;
24944
24945function isUndefined(arg) {
24946 return arg === void 0;
24947}
24948exports.isUndefined = isUndefined;
24949
24950function isRegExp(re) {
24951 return isObject(re) && objectToString(re) === '[object RegExp]';
24952}
24953exports.isRegExp = isRegExp;
24954
24955function isObject(arg) {
24956 return typeof arg === 'object' && arg !== null;
24957}
24958exports.isObject = isObject;
24959
24960function isDate(d) {
24961 return isObject(d) && objectToString(d) === '[object Date]';
24962}
24963exports.isDate = isDate;
24964
24965function isError(e) {
24966 return isObject(e) &&
24967 (objectToString(e) === '[object Error]' || e instanceof Error);
24968}
24969exports.isError = isError;
24970
24971function isFunction(arg) {
24972 return typeof arg === 'function';
24973}
24974exports.isFunction = isFunction;
24975
24976function isPrimitive(arg) {
24977 return arg === null ||
24978 typeof arg === 'boolean' ||
24979 typeof arg === 'number' ||
24980 typeof arg === 'string' ||
24981 typeof arg === 'symbol' || // ES6 symbol
24982 typeof arg === 'undefined';
24983}
24984exports.isPrimitive = isPrimitive;
24985
24986exports.isBuffer = require('./support/isBuffer');
24987
24988function objectToString(o) {
24989 return Object.prototype.toString.call(o);
24990}
24991
24992
24993function pad(n) {
24994 return n < 10 ? '0' + n.toString(10) : n.toString(10);
24995}
24996
24997
24998var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
24999 'Oct', 'Nov', 'Dec'];
25000
25001// 26 Feb 16:19:34
25002function timestamp() {
25003 var d = new Date();
25004 var time = [pad(d.getHours()),
25005 pad(d.getMinutes()),
25006 pad(d.getSeconds())].join(':');
25007 return [d.getDate(), months[d.getMonth()], time].join(' ');
25008}
25009
25010
25011// log is just a thin wrapper to console.log that prepends a timestamp
25012exports.log = function() {
25013 console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
25014};
25015
25016
25017/**
25018 * Inherit the prototype methods from one constructor into another.
25019 *
25020 * The Function.prototype.inherits from lang.js rewritten as a standalone
25021 * function (not on Function.prototype). NOTE: If this file is to be loaded
25022 * during bootstrapping this function needs to be rewritten using some native
25023 * functions as prototype setup using normal JavaScript does not work as
25024 * expected during bootstrapping (see mirror.js in r114903).
25025 *
25026 * @param {function} ctor Constructor function which needs to inherit the
25027 * prototype.
25028 * @param {function} superCtor Constructor function to inherit prototype from.
25029 */
25030exports.inherits = require('inherits');
25031
25032exports._extend = function(origin, add) {
25033 // Don't do anything if add isn't an object
25034 if (!add || !isObject(add)) return origin;
25035
25036 var keys = Object.keys(add);
25037 var i = keys.length;
25038 while (i--) {
25039 origin[keys[i]] = add[keys[i]];
25040 }
25041 return origin;
25042};
25043
25044function hasOwnProperty(obj, prop) {
25045 return Object.prototype.hasOwnProperty.call(obj, prop);
25046}
25047
25048}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
25049},{"./support/isBuffer":286,"_process":249,"inherits":226}],288:[function(require,module,exports){
25050"use strict";
25051
25052// Generated by CoffeeScript 1.12.7
25053(function () {
25054 "use strict";
25055
25056 exports.stripBOM = function (str) {
25057 if (str[0] === "\uFEFF") {
25058 return str.substring(1);
25059 } else {
25060 return str;
25061 }
25062 };
25063}).call(undefined);
25064
25065},{}],289:[function(require,module,exports){
25066'use strict';
25067
25068var _typeof2 = require('babel-runtime/helpers/typeof');
25069
25070var _typeof3 = _interopRequireDefault(_typeof2);
25071
25072var _keys = require('babel-runtime/core-js/object/keys');
25073
25074var _keys2 = _interopRequireDefault(_keys);
25075
25076function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25077
25078// Generated by CoffeeScript 1.12.7
25079(function () {
25080 "use strict";
25081
25082 var builder,
25083 defaults,
25084 escapeCDATA,
25085 requiresCDATA,
25086 wrapCDATA,
25087 hasProp = {}.hasOwnProperty;
25088
25089 builder = require('xmlbuilder');
25090
25091 defaults = require('./defaults').defaults;
25092
25093 requiresCDATA = function requiresCDATA(entry) {
25094 return typeof entry === "string" && (entry.indexOf('&') >= 0 || entry.indexOf('>') >= 0 || entry.indexOf('<') >= 0);
25095 };
25096
25097 wrapCDATA = function wrapCDATA(entry) {
25098 return "<![CDATA[" + escapeCDATA(entry) + "]]>";
25099 };
25100
25101 escapeCDATA = function escapeCDATA(entry) {
25102 return entry.replace(']]>', ']]]]><![CDATA[>');
25103 };
25104
25105 exports.Builder = function () {
25106 function Builder(opts) {
25107 var key, ref, value;
25108 this.options = {};
25109 ref = defaults["0.2"];
25110 for (key in ref) {
25111 if (!hasProp.call(ref, key)) continue;
25112 value = ref[key];
25113 this.options[key] = value;
25114 }
25115 for (key in opts) {
25116 if (!hasProp.call(opts, key)) continue;
25117 value = opts[key];
25118 this.options[key] = value;
25119 }
25120 }
25121
25122 Builder.prototype.buildObject = function (rootObj) {
25123 var attrkey, charkey, render, rootElement, rootName;
25124 attrkey = this.options.attrkey;
25125 charkey = this.options.charkey;
25126 if ((0, _keys2.default)(rootObj).length === 1 && this.options.rootName === defaults['0.2'].rootName) {
25127 rootName = (0, _keys2.default)(rootObj)[0];
25128 rootObj = rootObj[rootName];
25129 } else {
25130 rootName = this.options.rootName;
25131 }
25132 render = function (_this) {
25133 return function (element, obj) {
25134 var attr, child, entry, index, key, value;
25135 if ((typeof obj === 'undefined' ? 'undefined' : (0, _typeof3.default)(obj)) !== 'object') {
25136 if (_this.options.cdata && requiresCDATA(obj)) {
25137 element.raw(wrapCDATA(obj));
25138 } else {
25139 element.txt(obj);
25140 }
25141 } else if (Array.isArray(obj)) {
25142 for (index in obj) {
25143 if (!hasProp.call(obj, index)) continue;
25144 child = obj[index];
25145 for (key in child) {
25146 entry = child[key];
25147 element = render(element.ele(key), entry).up();
25148 }
25149 }
25150 } else {
25151 for (key in obj) {
25152 if (!hasProp.call(obj, key)) continue;
25153 child = obj[key];
25154 if (key === attrkey) {
25155 if ((typeof child === 'undefined' ? 'undefined' : (0, _typeof3.default)(child)) === "object") {
25156 for (attr in child) {
25157 value = child[attr];
25158 element = element.att(attr, value);
25159 }
25160 }
25161 } else if (key === charkey) {
25162 if (_this.options.cdata && requiresCDATA(child)) {
25163 element = element.raw(wrapCDATA(child));
25164 } else {
25165 element = element.txt(child);
25166 }
25167 } else if (Array.isArray(child)) {
25168 for (index in child) {
25169 if (!hasProp.call(child, index)) continue;
25170 entry = child[index];
25171 if (typeof entry === 'string') {
25172 if (_this.options.cdata && requiresCDATA(entry)) {
25173 element = element.ele(key).raw(wrapCDATA(entry)).up();
25174 } else {
25175 element = element.ele(key, entry).up();
25176 }
25177 } else {
25178 element = render(element.ele(key), entry).up();
25179 }
25180 }
25181 } else if ((typeof child === 'undefined' ? 'undefined' : (0, _typeof3.default)(child)) === "object") {
25182 element = render(element.ele(key), child).up();
25183 } else {
25184 if (typeof child === 'string' && _this.options.cdata && requiresCDATA(child)) {
25185 element = element.ele(key).raw(wrapCDATA(child)).up();
25186 } else {
25187 if (child == null) {
25188 child = '';
25189 }
25190 element = element.ele(key, child.toString()).up();
25191 }
25192 }
25193 }
25194 }
25195 return element;
25196 };
25197 }(this);
25198 rootElement = builder.create(rootName, this.options.xmldec, this.options.doctype, {
25199 headless: this.options.headless,
25200 allowSurrogateChars: this.options.allowSurrogateChars
25201 });
25202 return render(rootElement, rootObj).end(this.options.renderOpts);
25203 };
25204
25205 return Builder;
25206 }();
25207}).call(undefined);
25208
25209},{"./defaults":290,"babel-runtime/core-js/object/keys":55,"babel-runtime/helpers/typeof":64,"xmlbuilder":326}],290:[function(require,module,exports){
25210"use strict";
25211
25212// Generated by CoffeeScript 1.12.7
25213(function () {
25214 exports.defaults = {
25215 "0.1": {
25216 explicitCharkey: false,
25217 trim: true,
25218 normalize: true,
25219 normalizeTags: false,
25220 attrkey: "@",
25221 charkey: "#",
25222 explicitArray: false,
25223 ignoreAttrs: false,
25224 mergeAttrs: false,
25225 explicitRoot: false,
25226 validator: null,
25227 xmlns: false,
25228 explicitChildren: false,
25229 childkey: '@@',
25230 charsAsChildren: false,
25231 includeWhiteChars: false,
25232 async: false,
25233 strict: true,
25234 attrNameProcessors: null,
25235 attrValueProcessors: null,
25236 tagNameProcessors: null,
25237 valueProcessors: null,
25238 emptyTag: ''
25239 },
25240 "0.2": {
25241 explicitCharkey: false,
25242 trim: false,
25243 normalize: false,
25244 normalizeTags: false,
25245 attrkey: "$",
25246 charkey: "_",
25247 explicitArray: true,
25248 ignoreAttrs: false,
25249 mergeAttrs: false,
25250 explicitRoot: true,
25251 validator: null,
25252 xmlns: false,
25253 explicitChildren: false,
25254 preserveChildrenOrder: false,
25255 childkey: '$$',
25256 charsAsChildren: false,
25257 includeWhiteChars: false,
25258 async: false,
25259 strict: true,
25260 attrNameProcessors: null,
25261 attrValueProcessors: null,
25262 tagNameProcessors: null,
25263 valueProcessors: null,
25264 rootName: 'root',
25265 xmldec: {
25266 'version': '1.0',
25267 'encoding': 'UTF-8',
25268 'standalone': true
25269 },
25270 doctype: null,
25271 renderOpts: {
25272 'pretty': true,
25273 'indent': ' ',
25274 'newline': '\n'
25275 },
25276 headless: false,
25277 chunkSize: 10000,
25278 emptyTag: '',
25279 cdata: false
25280 }
25281 };
25282}).call(undefined);
25283
25284},{}],291:[function(require,module,exports){
25285'use strict';
25286
25287var _getOwnPropertyNames = require('babel-runtime/core-js/object/get-own-property-names');
25288
25289var _getOwnPropertyNames2 = _interopRequireDefault(_getOwnPropertyNames);
25290
25291var _keys = require('babel-runtime/core-js/object/keys');
25292
25293var _keys2 = _interopRequireDefault(_keys);
25294
25295var _typeof2 = require('babel-runtime/helpers/typeof');
25296
25297var _typeof3 = _interopRequireDefault(_typeof2);
25298
25299function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25300
25301// Generated by CoffeeScript 1.12.7
25302(function () {
25303 "use strict";
25304
25305 var bom,
25306 defaults,
25307 events,
25308 isEmpty,
25309 processItem,
25310 processors,
25311 promisify,
25312 sax,
25313 setImmediate,
25314 bind = function bind(fn, me) {
25315 return function () {
25316 return fn.apply(me, arguments);
25317 };
25318 },
25319 extend = function extend(child, parent) {
25320 for (var key in parent) {
25321 if (hasProp.call(parent, key)) child[key] = parent[key];
25322 }function ctor() {
25323 this.constructor = child;
25324 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
25325 },
25326 hasProp = {}.hasOwnProperty;
25327
25328 sax = require('sax');
25329
25330 events = require('events');
25331
25332 bom = require('./bom');
25333
25334 processors = require('./processors');
25335
25336 setImmediate = require('timers').setImmediate;
25337
25338 defaults = require('./defaults').defaults;
25339
25340 promisify = require('util.promisify');
25341
25342 isEmpty = function isEmpty(thing) {
25343 return (typeof thing === 'undefined' ? 'undefined' : (0, _typeof3.default)(thing)) === "object" && thing != null && (0, _keys2.default)(thing).length === 0;
25344 };
25345
25346 processItem = function processItem(processors, item, key) {
25347 var i, len, process;
25348 for (i = 0, len = processors.length; i < len; i++) {
25349 process = processors[i];
25350 item = process(item, key);
25351 }
25352 return item;
25353 };
25354
25355 exports.Parser = function (superClass) {
25356 extend(Parser, superClass);
25357
25358 function Parser(opts) {
25359 this.parseStringPromise = bind(this.parseStringPromise, this);
25360 this.parseString = bind(this.parseString, this);
25361 this.reset = bind(this.reset, this);
25362 this.assignOrPush = bind(this.assignOrPush, this);
25363 this.processAsync = bind(this.processAsync, this);
25364 var key, ref, value;
25365 if (!(this instanceof exports.Parser)) {
25366 return new exports.Parser(opts);
25367 }
25368 this.options = {};
25369 ref = defaults["0.2"];
25370 for (key in ref) {
25371 if (!hasProp.call(ref, key)) continue;
25372 value = ref[key];
25373 this.options[key] = value;
25374 }
25375 for (key in opts) {
25376 if (!hasProp.call(opts, key)) continue;
25377 value = opts[key];
25378 this.options[key] = value;
25379 }
25380 if (this.options.xmlns) {
25381 this.options.xmlnskey = this.options.attrkey + "ns";
25382 }
25383 if (this.options.normalizeTags) {
25384 if (!this.options.tagNameProcessors) {
25385 this.options.tagNameProcessors = [];
25386 }
25387 this.options.tagNameProcessors.unshift(processors.normalize);
25388 }
25389 this.reset();
25390 }
25391
25392 Parser.prototype.processAsync = function () {
25393 var chunk, err;
25394 try {
25395 if (this.remaining.length <= this.options.chunkSize) {
25396 chunk = this.remaining;
25397 this.remaining = '';
25398 this.saxParser = this.saxParser.write(chunk);
25399 return this.saxParser.close();
25400 } else {
25401 chunk = this.remaining.substr(0, this.options.chunkSize);
25402 this.remaining = this.remaining.substr(this.options.chunkSize, this.remaining.length);
25403 this.saxParser = this.saxParser.write(chunk);
25404 return setImmediate(this.processAsync);
25405 }
25406 } catch (error1) {
25407 err = error1;
25408 if (!this.saxParser.errThrown) {
25409 this.saxParser.errThrown = true;
25410 return this.emit(err);
25411 }
25412 }
25413 };
25414
25415 Parser.prototype.assignOrPush = function (obj, key, newValue) {
25416 if (!(key in obj)) {
25417 if (!this.options.explicitArray) {
25418 return obj[key] = newValue;
25419 } else {
25420 return obj[key] = [newValue];
25421 }
25422 } else {
25423 if (!(obj[key] instanceof Array)) {
25424 obj[key] = [obj[key]];
25425 }
25426 return obj[key].push(newValue);
25427 }
25428 };
25429
25430 Parser.prototype.reset = function () {
25431 var attrkey, charkey, ontext, stack;
25432 this.removeAllListeners();
25433 this.saxParser = sax.parser(this.options.strict, {
25434 trim: false,
25435 normalize: false,
25436 xmlns: this.options.xmlns
25437 });
25438 this.saxParser.errThrown = false;
25439 this.saxParser.onerror = function (_this) {
25440 return function (error) {
25441 _this.saxParser.resume();
25442 if (!_this.saxParser.errThrown) {
25443 _this.saxParser.errThrown = true;
25444 return _this.emit("error", error);
25445 }
25446 };
25447 }(this);
25448 this.saxParser.onend = function (_this) {
25449 return function () {
25450 if (!_this.saxParser.ended) {
25451 _this.saxParser.ended = true;
25452 return _this.emit("end", _this.resultObject);
25453 }
25454 };
25455 }(this);
25456 this.saxParser.ended = false;
25457 this.EXPLICIT_CHARKEY = this.options.explicitCharkey;
25458 this.resultObject = null;
25459 stack = [];
25460 attrkey = this.options.attrkey;
25461 charkey = this.options.charkey;
25462 this.saxParser.onopentag = function (_this) {
25463 return function (node) {
25464 var key, newValue, obj, processedKey, ref;
25465 obj = {};
25466 obj[charkey] = "";
25467 if (!_this.options.ignoreAttrs) {
25468 ref = node.attributes;
25469 for (key in ref) {
25470 if (!hasProp.call(ref, key)) continue;
25471 if (!(attrkey in obj) && !_this.options.mergeAttrs) {
25472 obj[attrkey] = {};
25473 }
25474 newValue = _this.options.attrValueProcessors ? processItem(_this.options.attrValueProcessors, node.attributes[key], key) : node.attributes[key];
25475 processedKey = _this.options.attrNameProcessors ? processItem(_this.options.attrNameProcessors, key) : key;
25476 if (_this.options.mergeAttrs) {
25477 _this.assignOrPush(obj, processedKey, newValue);
25478 } else {
25479 obj[attrkey][processedKey] = newValue;
25480 }
25481 }
25482 }
25483 obj["#name"] = _this.options.tagNameProcessors ? processItem(_this.options.tagNameProcessors, node.name) : node.name;
25484 if (_this.options.xmlns) {
25485 obj[_this.options.xmlnskey] = {
25486 uri: node.uri,
25487 local: node.local
25488 };
25489 }
25490 return stack.push(obj);
25491 };
25492 }(this);
25493 this.saxParser.onclosetag = function (_this) {
25494 return function () {
25495 var cdata, emptyStr, key, node, nodeName, obj, objClone, old, s, xpath;
25496 obj = stack.pop();
25497 nodeName = obj["#name"];
25498 if (!_this.options.explicitChildren || !_this.options.preserveChildrenOrder) {
25499 delete obj["#name"];
25500 }
25501 if (obj.cdata === true) {
25502 cdata = obj.cdata;
25503 delete obj.cdata;
25504 }
25505 s = stack[stack.length - 1];
25506 if (obj[charkey].match(/^\s*$/) && !cdata) {
25507 emptyStr = obj[charkey];
25508 delete obj[charkey];
25509 } else {
25510 if (_this.options.trim) {
25511 obj[charkey] = obj[charkey].trim();
25512 }
25513 if (_this.options.normalize) {
25514 obj[charkey] = obj[charkey].replace(/\s{2,}/g, " ").trim();
25515 }
25516 obj[charkey] = _this.options.valueProcessors ? processItem(_this.options.valueProcessors, obj[charkey], nodeName) : obj[charkey];
25517 if ((0, _keys2.default)(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY) {
25518 obj = obj[charkey];
25519 }
25520 }
25521 if (isEmpty(obj)) {
25522 obj = _this.options.emptyTag !== '' ? _this.options.emptyTag : emptyStr;
25523 }
25524 if (_this.options.validator != null) {
25525 xpath = "/" + function () {
25526 var i, len, results;
25527 results = [];
25528 for (i = 0, len = stack.length; i < len; i++) {
25529 node = stack[i];
25530 results.push(node["#name"]);
25531 }
25532 return results;
25533 }().concat(nodeName).join("/");
25534 (function () {
25535 var err;
25536 try {
25537 return obj = _this.options.validator(xpath, s && s[nodeName], obj);
25538 } catch (error1) {
25539 err = error1;
25540 return _this.emit("error", err);
25541 }
25542 })();
25543 }
25544 if (_this.options.explicitChildren && !_this.options.mergeAttrs && (typeof obj === 'undefined' ? 'undefined' : (0, _typeof3.default)(obj)) === 'object') {
25545 if (!_this.options.preserveChildrenOrder) {
25546 node = {};
25547 if (_this.options.attrkey in obj) {
25548 node[_this.options.attrkey] = obj[_this.options.attrkey];
25549 delete obj[_this.options.attrkey];
25550 }
25551 if (!_this.options.charsAsChildren && _this.options.charkey in obj) {
25552 node[_this.options.charkey] = obj[_this.options.charkey];
25553 delete obj[_this.options.charkey];
25554 }
25555 if ((0, _getOwnPropertyNames2.default)(obj).length > 0) {
25556 node[_this.options.childkey] = obj;
25557 }
25558 obj = node;
25559 } else if (s) {
25560 s[_this.options.childkey] = s[_this.options.childkey] || [];
25561 objClone = {};
25562 for (key in obj) {
25563 if (!hasProp.call(obj, key)) continue;
25564 objClone[key] = obj[key];
25565 }
25566 s[_this.options.childkey].push(objClone);
25567 delete obj["#name"];
25568 if ((0, _keys2.default)(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY) {
25569 obj = obj[charkey];
25570 }
25571 }
25572 }
25573 if (stack.length > 0) {
25574 return _this.assignOrPush(s, nodeName, obj);
25575 } else {
25576 if (_this.options.explicitRoot) {
25577 old = obj;
25578 obj = {};
25579 obj[nodeName] = old;
25580 }
25581 _this.resultObject = obj;
25582 _this.saxParser.ended = true;
25583 return _this.emit("end", _this.resultObject);
25584 }
25585 };
25586 }(this);
25587 ontext = function (_this) {
25588 return function (text) {
25589 var charChild, s;
25590 s = stack[stack.length - 1];
25591 if (s) {
25592 s[charkey] += text;
25593 if (_this.options.explicitChildren && _this.options.preserveChildrenOrder && _this.options.charsAsChildren && (_this.options.includeWhiteChars || text.replace(/\\n/g, '').trim() !== '')) {
25594 s[_this.options.childkey] = s[_this.options.childkey] || [];
25595 charChild = {
25596 '#name': '__text__'
25597 };
25598 charChild[charkey] = text;
25599 if (_this.options.normalize) {
25600 charChild[charkey] = charChild[charkey].replace(/\s{2,}/g, " ").trim();
25601 }
25602 s[_this.options.childkey].push(charChild);
25603 }
25604 return s;
25605 }
25606 };
25607 }(this);
25608 this.saxParser.ontext = ontext;
25609 return this.saxParser.oncdata = function (_this) {
25610 return function (text) {
25611 var s;
25612 s = ontext(text);
25613 if (s) {
25614 return s.cdata = true;
25615 }
25616 };
25617 }(this);
25618 };
25619
25620 Parser.prototype.parseString = function (str, cb) {
25621 var err;
25622 if (cb != null && typeof cb === "function") {
25623 this.on("end", function (result) {
25624 this.reset();
25625 return cb(null, result);
25626 });
25627 this.on("error", function (err) {
25628 this.reset();
25629 return cb(err);
25630 });
25631 }
25632 try {
25633 str = str.toString();
25634 if (str.trim() === '') {
25635 this.emit("end", null);
25636 return true;
25637 }
25638 str = bom.stripBOM(str);
25639 if (this.options.async) {
25640 this.remaining = str;
25641 setImmediate(this.processAsync);
25642 return this.saxParser;
25643 }
25644 return this.saxParser.write(str).close();
25645 } catch (error1) {
25646 err = error1;
25647 if (!(this.saxParser.errThrown || this.saxParser.ended)) {
25648 this.emit('error', err);
25649 return this.saxParser.errThrown = true;
25650 } else if (this.saxParser.ended) {
25651 throw err;
25652 }
25653 }
25654 };
25655
25656 Parser.prototype.parseStringPromise = function (str) {
25657 return promisify(this.parseString)(str);
25658 };
25659
25660 return Parser;
25661 }(events);
25662
25663 exports.parseString = function (str, a, b) {
25664 var cb, options, parser;
25665 if (b != null) {
25666 if (typeof b === 'function') {
25667 cb = b;
25668 }
25669 if ((typeof a === 'undefined' ? 'undefined' : (0, _typeof3.default)(a)) === 'object') {
25670 options = a;
25671 }
25672 } else {
25673 if (typeof a === 'function') {
25674 cb = a;
25675 }
25676 options = {};
25677 }
25678 parser = new exports.Parser(options);
25679 return parser.parseString(str, cb);
25680 };
25681
25682 exports.parseStringPromise = function (str, a) {
25683 var options, parser;
25684 if ((typeof a === 'undefined' ? 'undefined' : (0, _typeof3.default)(a)) === 'object') {
25685 options = a;
25686 }
25687 parser = new exports.Parser(options);
25688 return parser.parseStringPromise(str);
25689 };
25690}).call(undefined);
25691
25692},{"./bom":288,"./defaults":290,"./processors":292,"babel-runtime/core-js/object/get-own-property-names":53,"babel-runtime/core-js/object/keys":55,"babel-runtime/helpers/typeof":64,"events":216,"sax":270,"timers":277,"util.promisify":283}],292:[function(require,module,exports){
25693'use strict';
25694
25695// Generated by CoffeeScript 1.12.7
25696(function () {
25697 "use strict";
25698
25699 var prefixMatch;
25700
25701 prefixMatch = new RegExp(/(?!xmlns)^.*:/);
25702
25703 exports.normalize = function (str) {
25704 return str.toLowerCase();
25705 };
25706
25707 exports.firstCharLowerCase = function (str) {
25708 return str.charAt(0).toLowerCase() + str.slice(1);
25709 };
25710
25711 exports.stripPrefix = function (str) {
25712 return str.replace(prefixMatch, '');
25713 };
25714
25715 exports.parseNumbers = function (str) {
25716 if (!isNaN(str)) {
25717 str = str % 1 === 0 ? parseInt(str, 10) : parseFloat(str);
25718 }
25719 return str;
25720 };
25721
25722 exports.parseBooleans = function (str) {
25723 if (/^(?:true|false)$/i.test(str)) {
25724 str = str.toLowerCase() === 'true';
25725 }
25726 return str;
25727 };
25728}).call(undefined);
25729
25730},{}],293:[function(require,module,exports){
25731'use strict';
25732
25733// Generated by CoffeeScript 1.12.7
25734(function () {
25735 "use strict";
25736
25737 var builder,
25738 defaults,
25739 parser,
25740 processors,
25741 extend = function extend(child, parent) {
25742 for (var key in parent) {
25743 if (hasProp.call(parent, key)) child[key] = parent[key];
25744 }function ctor() {
25745 this.constructor = child;
25746 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
25747 },
25748 hasProp = {}.hasOwnProperty;
25749
25750 defaults = require('./defaults');
25751
25752 builder = require('./builder');
25753
25754 parser = require('./parser');
25755
25756 processors = require('./processors');
25757
25758 exports.defaults = defaults.defaults;
25759
25760 exports.processors = processors;
25761
25762 exports.ValidationError = function (superClass) {
25763 extend(ValidationError, superClass);
25764
25765 function ValidationError(message) {
25766 this.message = message;
25767 }
25768
25769 return ValidationError;
25770 }(Error);
25771
25772 exports.Builder = builder.Builder;
25773
25774 exports.Parser = parser.Parser;
25775
25776 exports.parseString = parser.parseString;
25777
25778 exports.parseStringPromise = parser.parseStringPromise;
25779}).call(undefined);
25780
25781},{"./builder":289,"./defaults":290,"./parser":291,"./processors":292}],294:[function(require,module,exports){
25782"use strict";
25783
25784// Generated by CoffeeScript 1.12.7
25785(function () {
25786 module.exports = {
25787 Disconnected: 1,
25788 Preceding: 2,
25789 Following: 4,
25790 Contains: 8,
25791 ContainedBy: 16,
25792 ImplementationSpecific: 32
25793 };
25794}).call(undefined);
25795
25796},{}],295:[function(require,module,exports){
25797"use strict";
25798
25799// Generated by CoffeeScript 1.12.7
25800(function () {
25801 module.exports = {
25802 Element: 1,
25803 Attribute: 2,
25804 Text: 3,
25805 CData: 4,
25806 EntityReference: 5,
25807 EntityDeclaration: 6,
25808 ProcessingInstruction: 7,
25809 Comment: 8,
25810 Document: 9,
25811 DocType: 10,
25812 DocumentFragment: 11,
25813 NotationDeclaration: 12,
25814 Declaration: 201,
25815 Raw: 202,
25816 AttributeDeclaration: 203,
25817 ElementDeclaration: 204,
25818 Dummy: 205
25819 };
25820}).call(undefined);
25821
25822},{}],296:[function(require,module,exports){
25823'use strict';
25824
25825var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
25826
25827var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
25828
25829var _typeof2 = require('babel-runtime/helpers/typeof');
25830
25831var _typeof3 = _interopRequireDefault(_typeof2);
25832
25833var _assign = require('babel-runtime/core-js/object/assign');
25834
25835var _assign2 = _interopRequireDefault(_assign);
25836
25837function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25838
25839// Generated by CoffeeScript 1.12.7
25840(function () {
25841 var assign,
25842 getValue,
25843 isArray,
25844 isEmpty,
25845 isFunction,
25846 isObject,
25847 isPlainObject,
25848 slice = [].slice,
25849 hasProp = {}.hasOwnProperty;
25850
25851 assign = function assign() {
25852 var i, key, len, source, sources, target;
25853 target = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : [];
25854 if (isFunction(_assign2.default)) {
25855 _assign2.default.apply(null, arguments);
25856 } else {
25857 for (i = 0, len = sources.length; i < len; i++) {
25858 source = sources[i];
25859 if (source != null) {
25860 for (key in source) {
25861 if (!hasProp.call(source, key)) continue;
25862 target[key] = source[key];
25863 }
25864 }
25865 }
25866 }
25867 return target;
25868 };
25869
25870 isFunction = function isFunction(val) {
25871 return !!val && Object.prototype.toString.call(val) === '[object Function]';
25872 };
25873
25874 isObject = function isObject(val) {
25875 var ref;
25876 return !!val && ((ref = typeof val === 'undefined' ? 'undefined' : (0, _typeof3.default)(val)) === 'function' || ref === 'object');
25877 };
25878
25879 isArray = function isArray(val) {
25880 if (isFunction(Array.isArray)) {
25881 return Array.isArray(val);
25882 } else {
25883 return Object.prototype.toString.call(val) === '[object Array]';
25884 }
25885 };
25886
25887 isEmpty = function isEmpty(val) {
25888 var key;
25889 if (isArray(val)) {
25890 return !val.length;
25891 } else {
25892 for (key in val) {
25893 if (!hasProp.call(val, key)) continue;
25894 return false;
25895 }
25896 return true;
25897 }
25898 };
25899
25900 isPlainObject = function isPlainObject(val) {
25901 var ctor, proto;
25902 return isObject(val) && (proto = (0, _getPrototypeOf2.default)(val)) && (ctor = proto.constructor) && typeof ctor === 'function' && ctor instanceof ctor && Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object);
25903 };
25904
25905 getValue = function getValue(obj) {
25906 if (isFunction(obj.valueOf)) {
25907 return obj.valueOf();
25908 } else {
25909 return obj;
25910 }
25911 };
25912
25913 module.exports.assign = assign;
25914
25915 module.exports.isFunction = isFunction;
25916
25917 module.exports.isObject = isObject;
25918
25919 module.exports.isArray = isArray;
25920
25921 module.exports.isEmpty = isEmpty;
25922
25923 module.exports.isPlainObject = isPlainObject;
25924
25925 module.exports.getValue = getValue;
25926}).call(undefined);
25927
25928},{"babel-runtime/core-js/object/assign":49,"babel-runtime/core-js/object/get-prototype-of":54,"babel-runtime/helpers/typeof":64}],297:[function(require,module,exports){
25929"use strict";
25930
25931// Generated by CoffeeScript 1.12.7
25932(function () {
25933 module.exports = {
25934 None: 0,
25935 OpenTag: 1,
25936 InsideTag: 2,
25937 CloseTag: 3
25938 };
25939}).call(undefined);
25940
25941},{}],298:[function(require,module,exports){
25942'use strict';
25943
25944var _create = require('babel-runtime/core-js/object/create');
25945
25946var _create2 = _interopRequireDefault(_create);
25947
25948function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25949
25950// Generated by CoffeeScript 1.12.7
25951(function () {
25952 var NodeType, XMLAttribute, XMLNode;
25953
25954 NodeType = require('./NodeType');
25955
25956 XMLNode = require('./XMLNode');
25957
25958 module.exports = XMLAttribute = function () {
25959 function XMLAttribute(parent, name, value) {
25960 this.parent = parent;
25961 if (this.parent) {
25962 this.options = this.parent.options;
25963 this.stringify = this.parent.stringify;
25964 }
25965 if (name == null) {
25966 throw new Error("Missing attribute name. " + this.debugInfo(name));
25967 }
25968 this.name = this.stringify.name(name);
25969 this.value = this.stringify.attValue(value);
25970 this.type = NodeType.Attribute;
25971 this.isId = false;
25972 this.schemaTypeInfo = null;
25973 }
25974
25975 Object.defineProperty(XMLAttribute.prototype, 'nodeType', {
25976 get: function get() {
25977 return this.type;
25978 }
25979 });
25980
25981 Object.defineProperty(XMLAttribute.prototype, 'ownerElement', {
25982 get: function get() {
25983 return this.parent;
25984 }
25985 });
25986
25987 Object.defineProperty(XMLAttribute.prototype, 'textContent', {
25988 get: function get() {
25989 return this.value;
25990 },
25991 set: function set(value) {
25992 return this.value = value || '';
25993 }
25994 });
25995
25996 Object.defineProperty(XMLAttribute.prototype, 'namespaceURI', {
25997 get: function get() {
25998 return '';
25999 }
26000 });
26001
26002 Object.defineProperty(XMLAttribute.prototype, 'prefix', {
26003 get: function get() {
26004 return '';
26005 }
26006 });
26007
26008 Object.defineProperty(XMLAttribute.prototype, 'localName', {
26009 get: function get() {
26010 return this.name;
26011 }
26012 });
26013
26014 Object.defineProperty(XMLAttribute.prototype, 'specified', {
26015 get: function get() {
26016 return true;
26017 }
26018 });
26019
26020 XMLAttribute.prototype.clone = function () {
26021 return (0, _create2.default)(this);
26022 };
26023
26024 XMLAttribute.prototype.toString = function (options) {
26025 return this.options.writer.attribute(this, this.options.writer.filterOptions(options));
26026 };
26027
26028 XMLAttribute.prototype.debugInfo = function (name) {
26029 name = name || this.name;
26030 if (name == null) {
26031 return "parent: <" + this.parent.name + ">";
26032 } else {
26033 return "attribute: {" + name + "}, parent: <" + this.parent.name + ">";
26034 }
26035 };
26036
26037 XMLAttribute.prototype.isEqualNode = function (node) {
26038 if (node.namespaceURI !== this.namespaceURI) {
26039 return false;
26040 }
26041 if (node.prefix !== this.prefix) {
26042 return false;
26043 }
26044 if (node.localName !== this.localName) {
26045 return false;
26046 }
26047 if (node.value !== this.value) {
26048 return false;
26049 }
26050 return true;
26051 };
26052
26053 return XMLAttribute;
26054 }();
26055}).call(undefined);
26056
26057},{"./NodeType":295,"./XMLNode":317,"babel-runtime/core-js/object/create":50}],299:[function(require,module,exports){
26058'use strict';
26059
26060var _create = require('babel-runtime/core-js/object/create');
26061
26062var _create2 = _interopRequireDefault(_create);
26063
26064function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26065
26066// Generated by CoffeeScript 1.12.7
26067(function () {
26068 var NodeType,
26069 XMLCData,
26070 XMLCharacterData,
26071 extend = function extend(child, parent) {
26072 for (var key in parent) {
26073 if (hasProp.call(parent, key)) child[key] = parent[key];
26074 }function ctor() {
26075 this.constructor = child;
26076 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
26077 },
26078 hasProp = {}.hasOwnProperty;
26079
26080 NodeType = require('./NodeType');
26081
26082 XMLCharacterData = require('./XMLCharacterData');
26083
26084 module.exports = XMLCData = function (superClass) {
26085 extend(XMLCData, superClass);
26086
26087 function XMLCData(parent, text) {
26088 XMLCData.__super__.constructor.call(this, parent);
26089 if (text == null) {
26090 throw new Error("Missing CDATA text. " + this.debugInfo());
26091 }
26092 this.name = "#cdata-section";
26093 this.type = NodeType.CData;
26094 this.value = this.stringify.cdata(text);
26095 }
26096
26097 XMLCData.prototype.clone = function () {
26098 return (0, _create2.default)(this);
26099 };
26100
26101 XMLCData.prototype.toString = function (options) {
26102 return this.options.writer.cdata(this, this.options.writer.filterOptions(options));
26103 };
26104
26105 return XMLCData;
26106 }(XMLCharacterData);
26107}).call(undefined);
26108
26109},{"./NodeType":295,"./XMLCharacterData":300,"babel-runtime/core-js/object/create":50}],300:[function(require,module,exports){
26110'use strict';
26111
26112var _create = require('babel-runtime/core-js/object/create');
26113
26114var _create2 = _interopRequireDefault(_create);
26115
26116function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26117
26118// Generated by CoffeeScript 1.12.7
26119(function () {
26120 var XMLCharacterData,
26121 XMLNode,
26122 extend = function extend(child, parent) {
26123 for (var key in parent) {
26124 if (hasProp.call(parent, key)) child[key] = parent[key];
26125 }function ctor() {
26126 this.constructor = child;
26127 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
26128 },
26129 hasProp = {}.hasOwnProperty;
26130
26131 XMLNode = require('./XMLNode');
26132
26133 module.exports = XMLCharacterData = function (superClass) {
26134 extend(XMLCharacterData, superClass);
26135
26136 function XMLCharacterData(parent) {
26137 XMLCharacterData.__super__.constructor.call(this, parent);
26138 this.value = '';
26139 }
26140
26141 Object.defineProperty(XMLCharacterData.prototype, 'data', {
26142 get: function get() {
26143 return this.value;
26144 },
26145 set: function set(value) {
26146 return this.value = value || '';
26147 }
26148 });
26149
26150 Object.defineProperty(XMLCharacterData.prototype, 'length', {
26151 get: function get() {
26152 return this.value.length;
26153 }
26154 });
26155
26156 Object.defineProperty(XMLCharacterData.prototype, 'textContent', {
26157 get: function get() {
26158 return this.value;
26159 },
26160 set: function set(value) {
26161 return this.value = value || '';
26162 }
26163 });
26164
26165 XMLCharacterData.prototype.clone = function () {
26166 return (0, _create2.default)(this);
26167 };
26168
26169 XMLCharacterData.prototype.substringData = function (offset, count) {
26170 throw new Error("This DOM method is not implemented." + this.debugInfo());
26171 };
26172
26173 XMLCharacterData.prototype.appendData = function (arg) {
26174 throw new Error("This DOM method is not implemented." + this.debugInfo());
26175 };
26176
26177 XMLCharacterData.prototype.insertData = function (offset, arg) {
26178 throw new Error("This DOM method is not implemented." + this.debugInfo());
26179 };
26180
26181 XMLCharacterData.prototype.deleteData = function (offset, count) {
26182 throw new Error("This DOM method is not implemented." + this.debugInfo());
26183 };
26184
26185 XMLCharacterData.prototype.replaceData = function (offset, count, arg) {
26186 throw new Error("This DOM method is not implemented." + this.debugInfo());
26187 };
26188
26189 XMLCharacterData.prototype.isEqualNode = function (node) {
26190 if (!XMLCharacterData.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
26191 return false;
26192 }
26193 if (node.data !== this.data) {
26194 return false;
26195 }
26196 return true;
26197 };
26198
26199 return XMLCharacterData;
26200 }(XMLNode);
26201}).call(undefined);
26202
26203},{"./XMLNode":317,"babel-runtime/core-js/object/create":50}],301:[function(require,module,exports){
26204'use strict';
26205
26206var _create = require('babel-runtime/core-js/object/create');
26207
26208var _create2 = _interopRequireDefault(_create);
26209
26210function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26211
26212// Generated by CoffeeScript 1.12.7
26213(function () {
26214 var NodeType,
26215 XMLCharacterData,
26216 XMLComment,
26217 extend = function extend(child, parent) {
26218 for (var key in parent) {
26219 if (hasProp.call(parent, key)) child[key] = parent[key];
26220 }function ctor() {
26221 this.constructor = child;
26222 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
26223 },
26224 hasProp = {}.hasOwnProperty;
26225
26226 NodeType = require('./NodeType');
26227
26228 XMLCharacterData = require('./XMLCharacterData');
26229
26230 module.exports = XMLComment = function (superClass) {
26231 extend(XMLComment, superClass);
26232
26233 function XMLComment(parent, text) {
26234 XMLComment.__super__.constructor.call(this, parent);
26235 if (text == null) {
26236 throw new Error("Missing comment text. " + this.debugInfo());
26237 }
26238 this.name = "#comment";
26239 this.type = NodeType.Comment;
26240 this.value = this.stringify.comment(text);
26241 }
26242
26243 XMLComment.prototype.clone = function () {
26244 return (0, _create2.default)(this);
26245 };
26246
26247 XMLComment.prototype.toString = function (options) {
26248 return this.options.writer.comment(this, this.options.writer.filterOptions(options));
26249 };
26250
26251 return XMLComment;
26252 }(XMLCharacterData);
26253}).call(undefined);
26254
26255},{"./NodeType":295,"./XMLCharacterData":300,"babel-runtime/core-js/object/create":50}],302:[function(require,module,exports){
26256'use strict';
26257
26258var _keys = require('babel-runtime/core-js/object/keys');
26259
26260var _keys2 = _interopRequireDefault(_keys);
26261
26262var _create = require('babel-runtime/core-js/object/create');
26263
26264var _create2 = _interopRequireDefault(_create);
26265
26266function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26267
26268// Generated by CoffeeScript 1.12.7
26269(function () {
26270 var XMLDOMConfiguration, XMLDOMErrorHandler, XMLDOMStringList;
26271
26272 XMLDOMErrorHandler = require('./XMLDOMErrorHandler');
26273
26274 XMLDOMStringList = require('./XMLDOMStringList');
26275
26276 module.exports = XMLDOMConfiguration = function () {
26277 function XMLDOMConfiguration() {
26278 var clonedSelf;
26279 this.defaultParams = {
26280 "canonical-form": false,
26281 "cdata-sections": false,
26282 "comments": false,
26283 "datatype-normalization": false,
26284 "element-content-whitespace": true,
26285 "entities": true,
26286 "error-handler": new XMLDOMErrorHandler(),
26287 "infoset": true,
26288 "validate-if-schema": false,
26289 "namespaces": true,
26290 "namespace-declarations": true,
26291 "normalize-characters": false,
26292 "schema-location": '',
26293 "schema-type": '',
26294 "split-cdata-sections": true,
26295 "validate": false,
26296 "well-formed": true
26297 };
26298 this.params = clonedSelf = (0, _create2.default)(this.defaultParams);
26299 }
26300
26301 Object.defineProperty(XMLDOMConfiguration.prototype, 'parameterNames', {
26302 get: function get() {
26303 return new XMLDOMStringList((0, _keys2.default)(this.defaultParams));
26304 }
26305 });
26306
26307 XMLDOMConfiguration.prototype.getParameter = function (name) {
26308 if (this.params.hasOwnProperty(name)) {
26309 return this.params[name];
26310 } else {
26311 return null;
26312 }
26313 };
26314
26315 XMLDOMConfiguration.prototype.canSetParameter = function (name, value) {
26316 return true;
26317 };
26318
26319 XMLDOMConfiguration.prototype.setParameter = function (name, value) {
26320 if (value != null) {
26321 return this.params[name] = value;
26322 } else {
26323 return delete this.params[name];
26324 }
26325 };
26326
26327 return XMLDOMConfiguration;
26328 }();
26329}).call(undefined);
26330
26331},{"./XMLDOMErrorHandler":303,"./XMLDOMStringList":305,"babel-runtime/core-js/object/create":50,"babel-runtime/core-js/object/keys":55}],303:[function(require,module,exports){
26332"use strict";
26333
26334// Generated by CoffeeScript 1.12.7
26335(function () {
26336 var XMLDOMErrorHandler;
26337
26338 module.exports = XMLDOMErrorHandler = function () {
26339 function XMLDOMErrorHandler() {}
26340
26341 XMLDOMErrorHandler.prototype.handleError = function (error) {
26342 throw new Error(error);
26343 };
26344
26345 return XMLDOMErrorHandler;
26346 }();
26347}).call(undefined);
26348
26349},{}],304:[function(require,module,exports){
26350"use strict";
26351
26352// Generated by CoffeeScript 1.12.7
26353(function () {
26354 var XMLDOMImplementation;
26355
26356 module.exports = XMLDOMImplementation = function () {
26357 function XMLDOMImplementation() {}
26358
26359 XMLDOMImplementation.prototype.hasFeature = function (feature, version) {
26360 return true;
26361 };
26362
26363 XMLDOMImplementation.prototype.createDocumentType = function (qualifiedName, publicId, systemId) {
26364 throw new Error("This DOM method is not implemented.");
26365 };
26366
26367 XMLDOMImplementation.prototype.createDocument = function (namespaceURI, qualifiedName, doctype) {
26368 throw new Error("This DOM method is not implemented.");
26369 };
26370
26371 XMLDOMImplementation.prototype.createHTMLDocument = function (title) {
26372 throw new Error("This DOM method is not implemented.");
26373 };
26374
26375 XMLDOMImplementation.prototype.getFeature = function (feature, version) {
26376 throw new Error("This DOM method is not implemented.");
26377 };
26378
26379 return XMLDOMImplementation;
26380 }();
26381}).call(undefined);
26382
26383},{}],305:[function(require,module,exports){
26384'use strict';
26385
26386// Generated by CoffeeScript 1.12.7
26387(function () {
26388 var XMLDOMStringList;
26389
26390 module.exports = XMLDOMStringList = function () {
26391 function XMLDOMStringList(arr) {
26392 this.arr = arr || [];
26393 }
26394
26395 Object.defineProperty(XMLDOMStringList.prototype, 'length', {
26396 get: function get() {
26397 return this.arr.length;
26398 }
26399 });
26400
26401 XMLDOMStringList.prototype.item = function (index) {
26402 return this.arr[index] || null;
26403 };
26404
26405 XMLDOMStringList.prototype.contains = function (str) {
26406 return this.arr.indexOf(str) !== -1;
26407 };
26408
26409 return XMLDOMStringList;
26410 }();
26411}).call(undefined);
26412
26413},{}],306:[function(require,module,exports){
26414'use strict';
26415
26416// Generated by CoffeeScript 1.12.7
26417(function () {
26418 var NodeType,
26419 XMLDTDAttList,
26420 XMLNode,
26421 extend = function extend(child, parent) {
26422 for (var key in parent) {
26423 if (hasProp.call(parent, key)) child[key] = parent[key];
26424 }function ctor() {
26425 this.constructor = child;
26426 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
26427 },
26428 hasProp = {}.hasOwnProperty;
26429
26430 XMLNode = require('./XMLNode');
26431
26432 NodeType = require('./NodeType');
26433
26434 module.exports = XMLDTDAttList = function (superClass) {
26435 extend(XMLDTDAttList, superClass);
26436
26437 function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) {
26438 XMLDTDAttList.__super__.constructor.call(this, parent);
26439 if (elementName == null) {
26440 throw new Error("Missing DTD element name. " + this.debugInfo());
26441 }
26442 if (attributeName == null) {
26443 throw new Error("Missing DTD attribute name. " + this.debugInfo(elementName));
26444 }
26445 if (!attributeType) {
26446 throw new Error("Missing DTD attribute type. " + this.debugInfo(elementName));
26447 }
26448 if (!defaultValueType) {
26449 throw new Error("Missing DTD attribute default. " + this.debugInfo(elementName));
26450 }
26451 if (defaultValueType.indexOf('#') !== 0) {
26452 defaultValueType = '#' + defaultValueType;
26453 }
26454 if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) {
26455 throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. " + this.debugInfo(elementName));
26456 }
26457 if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) {
26458 throw new Error("Default value only applies to #FIXED or #DEFAULT. " + this.debugInfo(elementName));
26459 }
26460 this.elementName = this.stringify.name(elementName);
26461 this.type = NodeType.AttributeDeclaration;
26462 this.attributeName = this.stringify.name(attributeName);
26463 this.attributeType = this.stringify.dtdAttType(attributeType);
26464 if (defaultValue) {
26465 this.defaultValue = this.stringify.dtdAttDefault(defaultValue);
26466 }
26467 this.defaultValueType = defaultValueType;
26468 }
26469
26470 XMLDTDAttList.prototype.toString = function (options) {
26471 return this.options.writer.dtdAttList(this, this.options.writer.filterOptions(options));
26472 };
26473
26474 return XMLDTDAttList;
26475 }(XMLNode);
26476}).call(undefined);
26477
26478},{"./NodeType":295,"./XMLNode":317}],307:[function(require,module,exports){
26479'use strict';
26480
26481// Generated by CoffeeScript 1.12.7
26482(function () {
26483 var NodeType,
26484 XMLDTDElement,
26485 XMLNode,
26486 extend = function extend(child, parent) {
26487 for (var key in parent) {
26488 if (hasProp.call(parent, key)) child[key] = parent[key];
26489 }function ctor() {
26490 this.constructor = child;
26491 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
26492 },
26493 hasProp = {}.hasOwnProperty;
26494
26495 XMLNode = require('./XMLNode');
26496
26497 NodeType = require('./NodeType');
26498
26499 module.exports = XMLDTDElement = function (superClass) {
26500 extend(XMLDTDElement, superClass);
26501
26502 function XMLDTDElement(parent, name, value) {
26503 XMLDTDElement.__super__.constructor.call(this, parent);
26504 if (name == null) {
26505 throw new Error("Missing DTD element name. " + this.debugInfo());
26506 }
26507 if (!value) {
26508 value = '(#PCDATA)';
26509 }
26510 if (Array.isArray(value)) {
26511 value = '(' + value.join(',') + ')';
26512 }
26513 this.name = this.stringify.name(name);
26514 this.type = NodeType.ElementDeclaration;
26515 this.value = this.stringify.dtdElementValue(value);
26516 }
26517
26518 XMLDTDElement.prototype.toString = function (options) {
26519 return this.options.writer.dtdElement(this, this.options.writer.filterOptions(options));
26520 };
26521
26522 return XMLDTDElement;
26523 }(XMLNode);
26524}).call(undefined);
26525
26526},{"./NodeType":295,"./XMLNode":317}],308:[function(require,module,exports){
26527'use strict';
26528
26529// Generated by CoffeeScript 1.12.7
26530(function () {
26531 var NodeType,
26532 XMLDTDEntity,
26533 XMLNode,
26534 isObject,
26535 extend = function extend(child, parent) {
26536 for (var key in parent) {
26537 if (hasProp.call(parent, key)) child[key] = parent[key];
26538 }function ctor() {
26539 this.constructor = child;
26540 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
26541 },
26542 hasProp = {}.hasOwnProperty;
26543
26544 isObject = require('./Utility').isObject;
26545
26546 XMLNode = require('./XMLNode');
26547
26548 NodeType = require('./NodeType');
26549
26550 module.exports = XMLDTDEntity = function (superClass) {
26551 extend(XMLDTDEntity, superClass);
26552
26553 function XMLDTDEntity(parent, pe, name, value) {
26554 XMLDTDEntity.__super__.constructor.call(this, parent);
26555 if (name == null) {
26556 throw new Error("Missing DTD entity name. " + this.debugInfo(name));
26557 }
26558 if (value == null) {
26559 throw new Error("Missing DTD entity value. " + this.debugInfo(name));
26560 }
26561 this.pe = !!pe;
26562 this.name = this.stringify.name(name);
26563 this.type = NodeType.EntityDeclaration;
26564 if (!isObject(value)) {
26565 this.value = this.stringify.dtdEntityValue(value);
26566 this.internal = true;
26567 } else {
26568 if (!value.pubID && !value.sysID) {
26569 throw new Error("Public and/or system identifiers are required for an external entity. " + this.debugInfo(name));
26570 }
26571 if (value.pubID && !value.sysID) {
26572 throw new Error("System identifier is required for a public external entity. " + this.debugInfo(name));
26573 }
26574 this.internal = false;
26575 if (value.pubID != null) {
26576 this.pubID = this.stringify.dtdPubID(value.pubID);
26577 }
26578 if (value.sysID != null) {
26579 this.sysID = this.stringify.dtdSysID(value.sysID);
26580 }
26581 if (value.nData != null) {
26582 this.nData = this.stringify.dtdNData(value.nData);
26583 }
26584 if (this.pe && this.nData) {
26585 throw new Error("Notation declaration is not allowed in a parameter entity. " + this.debugInfo(name));
26586 }
26587 }
26588 }
26589
26590 Object.defineProperty(XMLDTDEntity.prototype, 'publicId', {
26591 get: function get() {
26592 return this.pubID;
26593 }
26594 });
26595
26596 Object.defineProperty(XMLDTDEntity.prototype, 'systemId', {
26597 get: function get() {
26598 return this.sysID;
26599 }
26600 });
26601
26602 Object.defineProperty(XMLDTDEntity.prototype, 'notationName', {
26603 get: function get() {
26604 return this.nData || null;
26605 }
26606 });
26607
26608 Object.defineProperty(XMLDTDEntity.prototype, 'inputEncoding', {
26609 get: function get() {
26610 return null;
26611 }
26612 });
26613
26614 Object.defineProperty(XMLDTDEntity.prototype, 'xmlEncoding', {
26615 get: function get() {
26616 return null;
26617 }
26618 });
26619
26620 Object.defineProperty(XMLDTDEntity.prototype, 'xmlVersion', {
26621 get: function get() {
26622 return null;
26623 }
26624 });
26625
26626 XMLDTDEntity.prototype.toString = function (options) {
26627 return this.options.writer.dtdEntity(this, this.options.writer.filterOptions(options));
26628 };
26629
26630 return XMLDTDEntity;
26631 }(XMLNode);
26632}).call(undefined);
26633
26634},{"./NodeType":295,"./Utility":296,"./XMLNode":317}],309:[function(require,module,exports){
26635'use strict';
26636
26637// Generated by CoffeeScript 1.12.7
26638(function () {
26639 var NodeType,
26640 XMLDTDNotation,
26641 XMLNode,
26642 extend = function extend(child, parent) {
26643 for (var key in parent) {
26644 if (hasProp.call(parent, key)) child[key] = parent[key];
26645 }function ctor() {
26646 this.constructor = child;
26647 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
26648 },
26649 hasProp = {}.hasOwnProperty;
26650
26651 XMLNode = require('./XMLNode');
26652
26653 NodeType = require('./NodeType');
26654
26655 module.exports = XMLDTDNotation = function (superClass) {
26656 extend(XMLDTDNotation, superClass);
26657
26658 function XMLDTDNotation(parent, name, value) {
26659 XMLDTDNotation.__super__.constructor.call(this, parent);
26660 if (name == null) {
26661 throw new Error("Missing DTD notation name. " + this.debugInfo(name));
26662 }
26663 if (!value.pubID && !value.sysID) {
26664 throw new Error("Public or system identifiers are required for an external entity. " + this.debugInfo(name));
26665 }
26666 this.name = this.stringify.name(name);
26667 this.type = NodeType.NotationDeclaration;
26668 if (value.pubID != null) {
26669 this.pubID = this.stringify.dtdPubID(value.pubID);
26670 }
26671 if (value.sysID != null) {
26672 this.sysID = this.stringify.dtdSysID(value.sysID);
26673 }
26674 }
26675
26676 Object.defineProperty(XMLDTDNotation.prototype, 'publicId', {
26677 get: function get() {
26678 return this.pubID;
26679 }
26680 });
26681
26682 Object.defineProperty(XMLDTDNotation.prototype, 'systemId', {
26683 get: function get() {
26684 return this.sysID;
26685 }
26686 });
26687
26688 XMLDTDNotation.prototype.toString = function (options) {
26689 return this.options.writer.dtdNotation(this, this.options.writer.filterOptions(options));
26690 };
26691
26692 return XMLDTDNotation;
26693 }(XMLNode);
26694}).call(undefined);
26695
26696},{"./NodeType":295,"./XMLNode":317}],310:[function(require,module,exports){
26697'use strict';
26698
26699// Generated by CoffeeScript 1.12.7
26700(function () {
26701 var NodeType,
26702 XMLDeclaration,
26703 XMLNode,
26704 isObject,
26705 extend = function extend(child, parent) {
26706 for (var key in parent) {
26707 if (hasProp.call(parent, key)) child[key] = parent[key];
26708 }function ctor() {
26709 this.constructor = child;
26710 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
26711 },
26712 hasProp = {}.hasOwnProperty;
26713
26714 isObject = require('./Utility').isObject;
26715
26716 XMLNode = require('./XMLNode');
26717
26718 NodeType = require('./NodeType');
26719
26720 module.exports = XMLDeclaration = function (superClass) {
26721 extend(XMLDeclaration, superClass);
26722
26723 function XMLDeclaration(parent, version, encoding, standalone) {
26724 var ref;
26725 XMLDeclaration.__super__.constructor.call(this, parent);
26726 if (isObject(version)) {
26727 ref = version, version = ref.version, encoding = ref.encoding, standalone = ref.standalone;
26728 }
26729 if (!version) {
26730 version = '1.0';
26731 }
26732 this.type = NodeType.Declaration;
26733 this.version = this.stringify.xmlVersion(version);
26734 if (encoding != null) {
26735 this.encoding = this.stringify.xmlEncoding(encoding);
26736 }
26737 if (standalone != null) {
26738 this.standalone = this.stringify.xmlStandalone(standalone);
26739 }
26740 }
26741
26742 XMLDeclaration.prototype.toString = function (options) {
26743 return this.options.writer.declaration(this, this.options.writer.filterOptions(options));
26744 };
26745
26746 return XMLDeclaration;
26747 }(XMLNode);
26748}).call(undefined);
26749
26750},{"./NodeType":295,"./Utility":296,"./XMLNode":317}],311:[function(require,module,exports){
26751'use strict';
26752
26753// Generated by CoffeeScript 1.12.7
26754(function () {
26755 var NodeType,
26756 XMLDTDAttList,
26757 XMLDTDElement,
26758 XMLDTDEntity,
26759 XMLDTDNotation,
26760 XMLDocType,
26761 XMLNamedNodeMap,
26762 XMLNode,
26763 isObject,
26764 extend = function extend(child, parent) {
26765 for (var key in parent) {
26766 if (hasProp.call(parent, key)) child[key] = parent[key];
26767 }function ctor() {
26768 this.constructor = child;
26769 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
26770 },
26771 hasProp = {}.hasOwnProperty;
26772
26773 isObject = require('./Utility').isObject;
26774
26775 XMLNode = require('./XMLNode');
26776
26777 NodeType = require('./NodeType');
26778
26779 XMLDTDAttList = require('./XMLDTDAttList');
26780
26781 XMLDTDEntity = require('./XMLDTDEntity');
26782
26783 XMLDTDElement = require('./XMLDTDElement');
26784
26785 XMLDTDNotation = require('./XMLDTDNotation');
26786
26787 XMLNamedNodeMap = require('./XMLNamedNodeMap');
26788
26789 module.exports = XMLDocType = function (superClass) {
26790 extend(XMLDocType, superClass);
26791
26792 function XMLDocType(parent, pubID, sysID) {
26793 var child, i, len, ref, ref1, ref2;
26794 XMLDocType.__super__.constructor.call(this, parent);
26795 this.type = NodeType.DocType;
26796 if (parent.children) {
26797 ref = parent.children;
26798 for (i = 0, len = ref.length; i < len; i++) {
26799 child = ref[i];
26800 if (child.type === NodeType.Element) {
26801 this.name = child.name;
26802 break;
26803 }
26804 }
26805 }
26806 this.documentObject = parent;
26807 if (isObject(pubID)) {
26808 ref1 = pubID, pubID = ref1.pubID, sysID = ref1.sysID;
26809 }
26810 if (sysID == null) {
26811 ref2 = [pubID, sysID], sysID = ref2[0], pubID = ref2[1];
26812 }
26813 if (pubID != null) {
26814 this.pubID = this.stringify.dtdPubID(pubID);
26815 }
26816 if (sysID != null) {
26817 this.sysID = this.stringify.dtdSysID(sysID);
26818 }
26819 }
26820
26821 Object.defineProperty(XMLDocType.prototype, 'entities', {
26822 get: function get() {
26823 var child, i, len, nodes, ref;
26824 nodes = {};
26825 ref = this.children;
26826 for (i = 0, len = ref.length; i < len; i++) {
26827 child = ref[i];
26828 if (child.type === NodeType.EntityDeclaration && !child.pe) {
26829 nodes[child.name] = child;
26830 }
26831 }
26832 return new XMLNamedNodeMap(nodes);
26833 }
26834 });
26835
26836 Object.defineProperty(XMLDocType.prototype, 'notations', {
26837 get: function get() {
26838 var child, i, len, nodes, ref;
26839 nodes = {};
26840 ref = this.children;
26841 for (i = 0, len = ref.length; i < len; i++) {
26842 child = ref[i];
26843 if (child.type === NodeType.NotationDeclaration) {
26844 nodes[child.name] = child;
26845 }
26846 }
26847 return new XMLNamedNodeMap(nodes);
26848 }
26849 });
26850
26851 Object.defineProperty(XMLDocType.prototype, 'publicId', {
26852 get: function get() {
26853 return this.pubID;
26854 }
26855 });
26856
26857 Object.defineProperty(XMLDocType.prototype, 'systemId', {
26858 get: function get() {
26859 return this.sysID;
26860 }
26861 });
26862
26863 Object.defineProperty(XMLDocType.prototype, 'internalSubset', {
26864 get: function get() {
26865 throw new Error("This DOM method is not implemented." + this.debugInfo());
26866 }
26867 });
26868
26869 XMLDocType.prototype.element = function (name, value) {
26870 var child;
26871 child = new XMLDTDElement(this, name, value);
26872 this.children.push(child);
26873 return this;
26874 };
26875
26876 XMLDocType.prototype.attList = function (elementName, attributeName, attributeType, defaultValueType, defaultValue) {
26877 var child;
26878 child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
26879 this.children.push(child);
26880 return this;
26881 };
26882
26883 XMLDocType.prototype.entity = function (name, value) {
26884 var child;
26885 child = new XMLDTDEntity(this, false, name, value);
26886 this.children.push(child);
26887 return this;
26888 };
26889
26890 XMLDocType.prototype.pEntity = function (name, value) {
26891 var child;
26892 child = new XMLDTDEntity(this, true, name, value);
26893 this.children.push(child);
26894 return this;
26895 };
26896
26897 XMLDocType.prototype.notation = function (name, value) {
26898 var child;
26899 child = new XMLDTDNotation(this, name, value);
26900 this.children.push(child);
26901 return this;
26902 };
26903
26904 XMLDocType.prototype.toString = function (options) {
26905 return this.options.writer.docType(this, this.options.writer.filterOptions(options));
26906 };
26907
26908 XMLDocType.prototype.ele = function (name, value) {
26909 return this.element(name, value);
26910 };
26911
26912 XMLDocType.prototype.att = function (elementName, attributeName, attributeType, defaultValueType, defaultValue) {
26913 return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue);
26914 };
26915
26916 XMLDocType.prototype.ent = function (name, value) {
26917 return this.entity(name, value);
26918 };
26919
26920 XMLDocType.prototype.pent = function (name, value) {
26921 return this.pEntity(name, value);
26922 };
26923
26924 XMLDocType.prototype.not = function (name, value) {
26925 return this.notation(name, value);
26926 };
26927
26928 XMLDocType.prototype.up = function () {
26929 return this.root() || this.documentObject;
26930 };
26931
26932 XMLDocType.prototype.isEqualNode = function (node) {
26933 if (!XMLDocType.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
26934 return false;
26935 }
26936 if (node.name !== this.name) {
26937 return false;
26938 }
26939 if (node.publicId !== this.publicId) {
26940 return false;
26941 }
26942 if (node.systemId !== this.systemId) {
26943 return false;
26944 }
26945 return true;
26946 };
26947
26948 return XMLDocType;
26949 }(XMLNode);
26950}).call(undefined);
26951
26952},{"./NodeType":295,"./Utility":296,"./XMLDTDAttList":306,"./XMLDTDElement":307,"./XMLDTDEntity":308,"./XMLDTDNotation":309,"./XMLNamedNodeMap":316,"./XMLNode":317}],312:[function(require,module,exports){
26953'use strict';
26954
26955// Generated by CoffeeScript 1.12.7
26956(function () {
26957 var NodeType,
26958 XMLDOMConfiguration,
26959 XMLDOMImplementation,
26960 XMLDocument,
26961 XMLNode,
26962 XMLStringWriter,
26963 XMLStringifier,
26964 isPlainObject,
26965 extend = function extend(child, parent) {
26966 for (var key in parent) {
26967 if (hasProp.call(parent, key)) child[key] = parent[key];
26968 }function ctor() {
26969 this.constructor = child;
26970 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
26971 },
26972 hasProp = {}.hasOwnProperty;
26973
26974 isPlainObject = require('./Utility').isPlainObject;
26975
26976 XMLDOMImplementation = require('./XMLDOMImplementation');
26977
26978 XMLDOMConfiguration = require('./XMLDOMConfiguration');
26979
26980 XMLNode = require('./XMLNode');
26981
26982 NodeType = require('./NodeType');
26983
26984 XMLStringifier = require('./XMLStringifier');
26985
26986 XMLStringWriter = require('./XMLStringWriter');
26987
26988 module.exports = XMLDocument = function (superClass) {
26989 extend(XMLDocument, superClass);
26990
26991 function XMLDocument(options) {
26992 XMLDocument.__super__.constructor.call(this, null);
26993 this.name = "#document";
26994 this.type = NodeType.Document;
26995 this.documentURI = null;
26996 this.domConfig = new XMLDOMConfiguration();
26997 options || (options = {});
26998 if (!options.writer) {
26999 options.writer = new XMLStringWriter();
27000 }
27001 this.options = options;
27002 this.stringify = new XMLStringifier(options);
27003 }
27004
27005 Object.defineProperty(XMLDocument.prototype, 'implementation', {
27006 value: new XMLDOMImplementation()
27007 });
27008
27009 Object.defineProperty(XMLDocument.prototype, 'doctype', {
27010 get: function get() {
27011 var child, i, len, ref;
27012 ref = this.children;
27013 for (i = 0, len = ref.length; i < len; i++) {
27014 child = ref[i];
27015 if (child.type === NodeType.DocType) {
27016 return child;
27017 }
27018 }
27019 return null;
27020 }
27021 });
27022
27023 Object.defineProperty(XMLDocument.prototype, 'documentElement', {
27024 get: function get() {
27025 return this.rootObject || null;
27026 }
27027 });
27028
27029 Object.defineProperty(XMLDocument.prototype, 'inputEncoding', {
27030 get: function get() {
27031 return null;
27032 }
27033 });
27034
27035 Object.defineProperty(XMLDocument.prototype, 'strictErrorChecking', {
27036 get: function get() {
27037 return false;
27038 }
27039 });
27040
27041 Object.defineProperty(XMLDocument.prototype, 'xmlEncoding', {
27042 get: function get() {
27043 if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
27044 return this.children[0].encoding;
27045 } else {
27046 return null;
27047 }
27048 }
27049 });
27050
27051 Object.defineProperty(XMLDocument.prototype, 'xmlStandalone', {
27052 get: function get() {
27053 if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
27054 return this.children[0].standalone === 'yes';
27055 } else {
27056 return false;
27057 }
27058 }
27059 });
27060
27061 Object.defineProperty(XMLDocument.prototype, 'xmlVersion', {
27062 get: function get() {
27063 if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
27064 return this.children[0].version;
27065 } else {
27066 return "1.0";
27067 }
27068 }
27069 });
27070
27071 Object.defineProperty(XMLDocument.prototype, 'URL', {
27072 get: function get() {
27073 return this.documentURI;
27074 }
27075 });
27076
27077 Object.defineProperty(XMLDocument.prototype, 'origin', {
27078 get: function get() {
27079 return null;
27080 }
27081 });
27082
27083 Object.defineProperty(XMLDocument.prototype, 'compatMode', {
27084 get: function get() {
27085 return null;
27086 }
27087 });
27088
27089 Object.defineProperty(XMLDocument.prototype, 'characterSet', {
27090 get: function get() {
27091 return null;
27092 }
27093 });
27094
27095 Object.defineProperty(XMLDocument.prototype, 'contentType', {
27096 get: function get() {
27097 return null;
27098 }
27099 });
27100
27101 XMLDocument.prototype.end = function (writer) {
27102 var writerOptions;
27103 writerOptions = {};
27104 if (!writer) {
27105 writer = this.options.writer;
27106 } else if (isPlainObject(writer)) {
27107 writerOptions = writer;
27108 writer = this.options.writer;
27109 }
27110 return writer.document(this, writer.filterOptions(writerOptions));
27111 };
27112
27113 XMLDocument.prototype.toString = function (options) {
27114 return this.options.writer.document(this, this.options.writer.filterOptions(options));
27115 };
27116
27117 XMLDocument.prototype.createElement = function (tagName) {
27118 throw new Error("This DOM method is not implemented." + this.debugInfo());
27119 };
27120
27121 XMLDocument.prototype.createDocumentFragment = function () {
27122 throw new Error("This DOM method is not implemented." + this.debugInfo());
27123 };
27124
27125 XMLDocument.prototype.createTextNode = function (data) {
27126 throw new Error("This DOM method is not implemented." + this.debugInfo());
27127 };
27128
27129 XMLDocument.prototype.createComment = function (data) {
27130 throw new Error("This DOM method is not implemented." + this.debugInfo());
27131 };
27132
27133 XMLDocument.prototype.createCDATASection = function (data) {
27134 throw new Error("This DOM method is not implemented." + this.debugInfo());
27135 };
27136
27137 XMLDocument.prototype.createProcessingInstruction = function (target, data) {
27138 throw new Error("This DOM method is not implemented." + this.debugInfo());
27139 };
27140
27141 XMLDocument.prototype.createAttribute = function (name) {
27142 throw new Error("This DOM method is not implemented." + this.debugInfo());
27143 };
27144
27145 XMLDocument.prototype.createEntityReference = function (name) {
27146 throw new Error("This DOM method is not implemented." + this.debugInfo());
27147 };
27148
27149 XMLDocument.prototype.getElementsByTagName = function (tagname) {
27150 throw new Error("This DOM method is not implemented." + this.debugInfo());
27151 };
27152
27153 XMLDocument.prototype.importNode = function (importedNode, deep) {
27154 throw new Error("This DOM method is not implemented." + this.debugInfo());
27155 };
27156
27157 XMLDocument.prototype.createElementNS = function (namespaceURI, qualifiedName) {
27158 throw new Error("This DOM method is not implemented." + this.debugInfo());
27159 };
27160
27161 XMLDocument.prototype.createAttributeNS = function (namespaceURI, qualifiedName) {
27162 throw new Error("This DOM method is not implemented." + this.debugInfo());
27163 };
27164
27165 XMLDocument.prototype.getElementsByTagNameNS = function (namespaceURI, localName) {
27166 throw new Error("This DOM method is not implemented." + this.debugInfo());
27167 };
27168
27169 XMLDocument.prototype.getElementById = function (elementId) {
27170 throw new Error("This DOM method is not implemented." + this.debugInfo());
27171 };
27172
27173 XMLDocument.prototype.adoptNode = function (source) {
27174 throw new Error("This DOM method is not implemented." + this.debugInfo());
27175 };
27176
27177 XMLDocument.prototype.normalizeDocument = function () {
27178 throw new Error("This DOM method is not implemented." + this.debugInfo());
27179 };
27180
27181 XMLDocument.prototype.renameNode = function (node, namespaceURI, qualifiedName) {
27182 throw new Error("This DOM method is not implemented." + this.debugInfo());
27183 };
27184
27185 XMLDocument.prototype.getElementsByClassName = function (classNames) {
27186 throw new Error("This DOM method is not implemented." + this.debugInfo());
27187 };
27188
27189 XMLDocument.prototype.createEvent = function (eventInterface) {
27190 throw new Error("This DOM method is not implemented." + this.debugInfo());
27191 };
27192
27193 XMLDocument.prototype.createRange = function () {
27194 throw new Error("This DOM method is not implemented." + this.debugInfo());
27195 };
27196
27197 XMLDocument.prototype.createNodeIterator = function (root, whatToShow, filter) {
27198 throw new Error("This DOM method is not implemented." + this.debugInfo());
27199 };
27200
27201 XMLDocument.prototype.createTreeWalker = function (root, whatToShow, filter) {
27202 throw new Error("This DOM method is not implemented." + this.debugInfo());
27203 };
27204
27205 return XMLDocument;
27206 }(XMLNode);
27207}).call(undefined);
27208
27209},{"./NodeType":295,"./Utility":296,"./XMLDOMConfiguration":302,"./XMLDOMImplementation":304,"./XMLNode":317,"./XMLStringWriter":322,"./XMLStringifier":323}],313:[function(require,module,exports){
27210'use strict';
27211
27212// Generated by CoffeeScript 1.12.7
27213(function () {
27214 var NodeType,
27215 WriterState,
27216 XMLAttribute,
27217 XMLCData,
27218 XMLComment,
27219 XMLDTDAttList,
27220 XMLDTDElement,
27221 XMLDTDEntity,
27222 XMLDTDNotation,
27223 XMLDeclaration,
27224 XMLDocType,
27225 XMLDocument,
27226 XMLDocumentCB,
27227 XMLElement,
27228 XMLProcessingInstruction,
27229 XMLRaw,
27230 XMLStringWriter,
27231 XMLStringifier,
27232 XMLText,
27233 getValue,
27234 isFunction,
27235 isObject,
27236 isPlainObject,
27237 ref,
27238 hasProp = {}.hasOwnProperty;
27239
27240 ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isPlainObject = ref.isPlainObject, getValue = ref.getValue;
27241
27242 NodeType = require('./NodeType');
27243
27244 XMLDocument = require('./XMLDocument');
27245
27246 XMLElement = require('./XMLElement');
27247
27248 XMLCData = require('./XMLCData');
27249
27250 XMLComment = require('./XMLComment');
27251
27252 XMLRaw = require('./XMLRaw');
27253
27254 XMLText = require('./XMLText');
27255
27256 XMLProcessingInstruction = require('./XMLProcessingInstruction');
27257
27258 XMLDeclaration = require('./XMLDeclaration');
27259
27260 XMLDocType = require('./XMLDocType');
27261
27262 XMLDTDAttList = require('./XMLDTDAttList');
27263
27264 XMLDTDEntity = require('./XMLDTDEntity');
27265
27266 XMLDTDElement = require('./XMLDTDElement');
27267
27268 XMLDTDNotation = require('./XMLDTDNotation');
27269
27270 XMLAttribute = require('./XMLAttribute');
27271
27272 XMLStringifier = require('./XMLStringifier');
27273
27274 XMLStringWriter = require('./XMLStringWriter');
27275
27276 WriterState = require('./WriterState');
27277
27278 module.exports = XMLDocumentCB = function () {
27279 function XMLDocumentCB(options, onData, onEnd) {
27280 var writerOptions;
27281 this.name = "?xml";
27282 this.type = NodeType.Document;
27283 options || (options = {});
27284 writerOptions = {};
27285 if (!options.writer) {
27286 options.writer = new XMLStringWriter();
27287 } else if (isPlainObject(options.writer)) {
27288 writerOptions = options.writer;
27289 options.writer = new XMLStringWriter();
27290 }
27291 this.options = options;
27292 this.writer = options.writer;
27293 this.writerOptions = this.writer.filterOptions(writerOptions);
27294 this.stringify = new XMLStringifier(options);
27295 this.onDataCallback = onData || function () {};
27296 this.onEndCallback = onEnd || function () {};
27297 this.currentNode = null;
27298 this.currentLevel = -1;
27299 this.openTags = {};
27300 this.documentStarted = false;
27301 this.documentCompleted = false;
27302 this.root = null;
27303 }
27304
27305 XMLDocumentCB.prototype.createChildNode = function (node) {
27306 var att, attName, attributes, child, i, len, ref1, ref2;
27307 switch (node.type) {
27308 case NodeType.CData:
27309 this.cdata(node.value);
27310 break;
27311 case NodeType.Comment:
27312 this.comment(node.value);
27313 break;
27314 case NodeType.Element:
27315 attributes = {};
27316 ref1 = node.attribs;
27317 for (attName in ref1) {
27318 if (!hasProp.call(ref1, attName)) continue;
27319 att = ref1[attName];
27320 attributes[attName] = att.value;
27321 }
27322 this.node(node.name, attributes);
27323 break;
27324 case NodeType.Dummy:
27325 this.dummy();
27326 break;
27327 case NodeType.Raw:
27328 this.raw(node.value);
27329 break;
27330 case NodeType.Text:
27331 this.text(node.value);
27332 break;
27333 case NodeType.ProcessingInstruction:
27334 this.instruction(node.target, node.value);
27335 break;
27336 default:
27337 throw new Error("This XML node type is not supported in a JS object: " + node.constructor.name);
27338 }
27339 ref2 = node.children;
27340 for (i = 0, len = ref2.length; i < len; i++) {
27341 child = ref2[i];
27342 this.createChildNode(child);
27343 if (child.type === NodeType.Element) {
27344 this.up();
27345 }
27346 }
27347 return this;
27348 };
27349
27350 XMLDocumentCB.prototype.dummy = function () {
27351 return this;
27352 };
27353
27354 XMLDocumentCB.prototype.node = function (name, attributes, text) {
27355 var ref1;
27356 if (name == null) {
27357 throw new Error("Missing node name.");
27358 }
27359 if (this.root && this.currentLevel === -1) {
27360 throw new Error("Document can only have one root node. " + this.debugInfo(name));
27361 }
27362 this.openCurrent();
27363 name = getValue(name);
27364 if (attributes == null) {
27365 attributes = {};
27366 }
27367 attributes = getValue(attributes);
27368 if (!isObject(attributes)) {
27369 ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
27370 }
27371 this.currentNode = new XMLElement(this, name, attributes);
27372 this.currentNode.children = false;
27373 this.currentLevel++;
27374 this.openTags[this.currentLevel] = this.currentNode;
27375 if (text != null) {
27376 this.text(text);
27377 }
27378 return this;
27379 };
27380
27381 XMLDocumentCB.prototype.element = function (name, attributes, text) {
27382 var child, i, len, oldValidationFlag, ref1, root;
27383 if (this.currentNode && this.currentNode.type === NodeType.DocType) {
27384 this.dtdElement.apply(this, arguments);
27385 } else {
27386 if (Array.isArray(name) || isObject(name) || isFunction(name)) {
27387 oldValidationFlag = this.options.noValidation;
27388 this.options.noValidation = true;
27389 root = new XMLDocument(this.options).element('TEMP_ROOT');
27390 root.element(name);
27391 this.options.noValidation = oldValidationFlag;
27392 ref1 = root.children;
27393 for (i = 0, len = ref1.length; i < len; i++) {
27394 child = ref1[i];
27395 this.createChildNode(child);
27396 if (child.type === NodeType.Element) {
27397 this.up();
27398 }
27399 }
27400 } else {
27401 this.node(name, attributes, text);
27402 }
27403 }
27404 return this;
27405 };
27406
27407 XMLDocumentCB.prototype.attribute = function (name, value) {
27408 var attName, attValue;
27409 if (!this.currentNode || this.currentNode.children) {
27410 throw new Error("att() can only be used immediately after an ele() call in callback mode. " + this.debugInfo(name));
27411 }
27412 if (name != null) {
27413 name = getValue(name);
27414 }
27415 if (isObject(name)) {
27416 for (attName in name) {
27417 if (!hasProp.call(name, attName)) continue;
27418 attValue = name[attName];
27419 this.attribute(attName, attValue);
27420 }
27421 } else {
27422 if (isFunction(value)) {
27423 value = value.apply();
27424 }
27425 if (this.options.keepNullAttributes && value == null) {
27426 this.currentNode.attribs[name] = new XMLAttribute(this, name, "");
27427 } else if (value != null) {
27428 this.currentNode.attribs[name] = new XMLAttribute(this, name, value);
27429 }
27430 }
27431 return this;
27432 };
27433
27434 XMLDocumentCB.prototype.text = function (value) {
27435 var node;
27436 this.openCurrent();
27437 node = new XMLText(this, value);
27438 this.onData(this.writer.text(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
27439 return this;
27440 };
27441
27442 XMLDocumentCB.prototype.cdata = function (value) {
27443 var node;
27444 this.openCurrent();
27445 node = new XMLCData(this, value);
27446 this.onData(this.writer.cdata(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
27447 return this;
27448 };
27449
27450 XMLDocumentCB.prototype.comment = function (value) {
27451 var node;
27452 this.openCurrent();
27453 node = new XMLComment(this, value);
27454 this.onData(this.writer.comment(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
27455 return this;
27456 };
27457
27458 XMLDocumentCB.prototype.raw = function (value) {
27459 var node;
27460 this.openCurrent();
27461 node = new XMLRaw(this, value);
27462 this.onData(this.writer.raw(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
27463 return this;
27464 };
27465
27466 XMLDocumentCB.prototype.instruction = function (target, value) {
27467 var i, insTarget, insValue, len, node;
27468 this.openCurrent();
27469 if (target != null) {
27470 target = getValue(target);
27471 }
27472 if (value != null) {
27473 value = getValue(value);
27474 }
27475 if (Array.isArray(target)) {
27476 for (i = 0, len = target.length; i < len; i++) {
27477 insTarget = target[i];
27478 this.instruction(insTarget);
27479 }
27480 } else if (isObject(target)) {
27481 for (insTarget in target) {
27482 if (!hasProp.call(target, insTarget)) continue;
27483 insValue = target[insTarget];
27484 this.instruction(insTarget, insValue);
27485 }
27486 } else {
27487 if (isFunction(value)) {
27488 value = value.apply();
27489 }
27490 node = new XMLProcessingInstruction(this, target, value);
27491 this.onData(this.writer.processingInstruction(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
27492 }
27493 return this;
27494 };
27495
27496 XMLDocumentCB.prototype.declaration = function (version, encoding, standalone) {
27497 var node;
27498 this.openCurrent();
27499 if (this.documentStarted) {
27500 throw new Error("declaration() must be the first node.");
27501 }
27502 node = new XMLDeclaration(this, version, encoding, standalone);
27503 this.onData(this.writer.declaration(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
27504 return this;
27505 };
27506
27507 XMLDocumentCB.prototype.doctype = function (root, pubID, sysID) {
27508 this.openCurrent();
27509 if (root == null) {
27510 throw new Error("Missing root node name.");
27511 }
27512 if (this.root) {
27513 throw new Error("dtd() must come before the root node.");
27514 }
27515 this.currentNode = new XMLDocType(this, pubID, sysID);
27516 this.currentNode.rootNodeName = root;
27517 this.currentNode.children = false;
27518 this.currentLevel++;
27519 this.openTags[this.currentLevel] = this.currentNode;
27520 return this;
27521 };
27522
27523 XMLDocumentCB.prototype.dtdElement = function (name, value) {
27524 var node;
27525 this.openCurrent();
27526 node = new XMLDTDElement(this, name, value);
27527 this.onData(this.writer.dtdElement(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
27528 return this;
27529 };
27530
27531 XMLDocumentCB.prototype.attList = function (elementName, attributeName, attributeType, defaultValueType, defaultValue) {
27532 var node;
27533 this.openCurrent();
27534 node = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
27535 this.onData(this.writer.dtdAttList(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
27536 return this;
27537 };
27538
27539 XMLDocumentCB.prototype.entity = function (name, value) {
27540 var node;
27541 this.openCurrent();
27542 node = new XMLDTDEntity(this, false, name, value);
27543 this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
27544 return this;
27545 };
27546
27547 XMLDocumentCB.prototype.pEntity = function (name, value) {
27548 var node;
27549 this.openCurrent();
27550 node = new XMLDTDEntity(this, true, name, value);
27551 this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
27552 return this;
27553 };
27554
27555 XMLDocumentCB.prototype.notation = function (name, value) {
27556 var node;
27557 this.openCurrent();
27558 node = new XMLDTDNotation(this, name, value);
27559 this.onData(this.writer.dtdNotation(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
27560 return this;
27561 };
27562
27563 XMLDocumentCB.prototype.up = function () {
27564 if (this.currentLevel < 0) {
27565 throw new Error("The document node has no parent.");
27566 }
27567 if (this.currentNode) {
27568 if (this.currentNode.children) {
27569 this.closeNode(this.currentNode);
27570 } else {
27571 this.openNode(this.currentNode);
27572 }
27573 this.currentNode = null;
27574 } else {
27575 this.closeNode(this.openTags[this.currentLevel]);
27576 }
27577 delete this.openTags[this.currentLevel];
27578 this.currentLevel--;
27579 return this;
27580 };
27581
27582 XMLDocumentCB.prototype.end = function () {
27583 while (this.currentLevel >= 0) {
27584 this.up();
27585 }
27586 return this.onEnd();
27587 };
27588
27589 XMLDocumentCB.prototype.openCurrent = function () {
27590 if (this.currentNode) {
27591 this.currentNode.children = true;
27592 return this.openNode(this.currentNode);
27593 }
27594 };
27595
27596 XMLDocumentCB.prototype.openNode = function (node) {
27597 var att, chunk, name, ref1;
27598 if (!node.isOpen) {
27599 if (!this.root && this.currentLevel === 0 && node.type === NodeType.Element) {
27600 this.root = node;
27601 }
27602 chunk = '';
27603 if (node.type === NodeType.Element) {
27604 this.writerOptions.state = WriterState.OpenTag;
27605 chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '<' + node.name;
27606 ref1 = node.attribs;
27607 for (name in ref1) {
27608 if (!hasProp.call(ref1, name)) continue;
27609 att = ref1[name];
27610 chunk += this.writer.attribute(att, this.writerOptions, this.currentLevel);
27611 }
27612 chunk += (node.children ? '>' : '/>') + this.writer.endline(node, this.writerOptions, this.currentLevel);
27613 this.writerOptions.state = WriterState.InsideTag;
27614 } else {
27615 this.writerOptions.state = WriterState.OpenTag;
27616 chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '<!DOCTYPE ' + node.rootNodeName;
27617 if (node.pubID && node.sysID) {
27618 chunk += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
27619 } else if (node.sysID) {
27620 chunk += ' SYSTEM "' + node.sysID + '"';
27621 }
27622 if (node.children) {
27623 chunk += ' [';
27624 this.writerOptions.state = WriterState.InsideTag;
27625 } else {
27626 this.writerOptions.state = WriterState.CloseTag;
27627 chunk += '>';
27628 }
27629 chunk += this.writer.endline(node, this.writerOptions, this.currentLevel);
27630 }
27631 this.onData(chunk, this.currentLevel);
27632 return node.isOpen = true;
27633 }
27634 };
27635
27636 XMLDocumentCB.prototype.closeNode = function (node) {
27637 var chunk;
27638 if (!node.isClosed) {
27639 chunk = '';
27640 this.writerOptions.state = WriterState.CloseTag;
27641 if (node.type === NodeType.Element) {
27642 chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '</' + node.name + '>' + this.writer.endline(node, this.writerOptions, this.currentLevel);
27643 } else {
27644 chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + ']>' + this.writer.endline(node, this.writerOptions, this.currentLevel);
27645 }
27646 this.writerOptions.state = WriterState.None;
27647 this.onData(chunk, this.currentLevel);
27648 return node.isClosed = true;
27649 }
27650 };
27651
27652 XMLDocumentCB.prototype.onData = function (chunk, level) {
27653 this.documentStarted = true;
27654 return this.onDataCallback(chunk, level + 1);
27655 };
27656
27657 XMLDocumentCB.prototype.onEnd = function () {
27658 this.documentCompleted = true;
27659 return this.onEndCallback();
27660 };
27661
27662 XMLDocumentCB.prototype.debugInfo = function (name) {
27663 if (name == null) {
27664 return "";
27665 } else {
27666 return "node: <" + name + ">";
27667 }
27668 };
27669
27670 XMLDocumentCB.prototype.ele = function () {
27671 return this.element.apply(this, arguments);
27672 };
27673
27674 XMLDocumentCB.prototype.nod = function (name, attributes, text) {
27675 return this.node(name, attributes, text);
27676 };
27677
27678 XMLDocumentCB.prototype.txt = function (value) {
27679 return this.text(value);
27680 };
27681
27682 XMLDocumentCB.prototype.dat = function (value) {
27683 return this.cdata(value);
27684 };
27685
27686 XMLDocumentCB.prototype.com = function (value) {
27687 return this.comment(value);
27688 };
27689
27690 XMLDocumentCB.prototype.ins = function (target, value) {
27691 return this.instruction(target, value);
27692 };
27693
27694 XMLDocumentCB.prototype.dec = function (version, encoding, standalone) {
27695 return this.declaration(version, encoding, standalone);
27696 };
27697
27698 XMLDocumentCB.prototype.dtd = function (root, pubID, sysID) {
27699 return this.doctype(root, pubID, sysID);
27700 };
27701
27702 XMLDocumentCB.prototype.e = function (name, attributes, text) {
27703 return this.element(name, attributes, text);
27704 };
27705
27706 XMLDocumentCB.prototype.n = function (name, attributes, text) {
27707 return this.node(name, attributes, text);
27708 };
27709
27710 XMLDocumentCB.prototype.t = function (value) {
27711 return this.text(value);
27712 };
27713
27714 XMLDocumentCB.prototype.d = function (value) {
27715 return this.cdata(value);
27716 };
27717
27718 XMLDocumentCB.prototype.c = function (value) {
27719 return this.comment(value);
27720 };
27721
27722 XMLDocumentCB.prototype.r = function (value) {
27723 return this.raw(value);
27724 };
27725
27726 XMLDocumentCB.prototype.i = function (target, value) {
27727 return this.instruction(target, value);
27728 };
27729
27730 XMLDocumentCB.prototype.att = function () {
27731 if (this.currentNode && this.currentNode.type === NodeType.DocType) {
27732 return this.attList.apply(this, arguments);
27733 } else {
27734 return this.attribute.apply(this, arguments);
27735 }
27736 };
27737
27738 XMLDocumentCB.prototype.a = function () {
27739 if (this.currentNode && this.currentNode.type === NodeType.DocType) {
27740 return this.attList.apply(this, arguments);
27741 } else {
27742 return this.attribute.apply(this, arguments);
27743 }
27744 };
27745
27746 XMLDocumentCB.prototype.ent = function (name, value) {
27747 return this.entity(name, value);
27748 };
27749
27750 XMLDocumentCB.prototype.pent = function (name, value) {
27751 return this.pEntity(name, value);
27752 };
27753
27754 XMLDocumentCB.prototype.not = function (name, value) {
27755 return this.notation(name, value);
27756 };
27757
27758 return XMLDocumentCB;
27759 }();
27760}).call(undefined);
27761
27762},{"./NodeType":295,"./Utility":296,"./WriterState":297,"./XMLAttribute":298,"./XMLCData":299,"./XMLComment":301,"./XMLDTDAttList":306,"./XMLDTDElement":307,"./XMLDTDEntity":308,"./XMLDTDNotation":309,"./XMLDeclaration":310,"./XMLDocType":311,"./XMLDocument":312,"./XMLElement":315,"./XMLProcessingInstruction":319,"./XMLRaw":320,"./XMLStringWriter":322,"./XMLStringifier":323,"./XMLText":324}],314:[function(require,module,exports){
27763'use strict';
27764
27765var _create = require('babel-runtime/core-js/object/create');
27766
27767var _create2 = _interopRequireDefault(_create);
27768
27769function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27770
27771// Generated by CoffeeScript 1.12.7
27772(function () {
27773 var NodeType,
27774 XMLDummy,
27775 XMLNode,
27776 extend = function extend(child, parent) {
27777 for (var key in parent) {
27778 if (hasProp.call(parent, key)) child[key] = parent[key];
27779 }function ctor() {
27780 this.constructor = child;
27781 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
27782 },
27783 hasProp = {}.hasOwnProperty;
27784
27785 XMLNode = require('./XMLNode');
27786
27787 NodeType = require('./NodeType');
27788
27789 module.exports = XMLDummy = function (superClass) {
27790 extend(XMLDummy, superClass);
27791
27792 function XMLDummy(parent) {
27793 XMLDummy.__super__.constructor.call(this, parent);
27794 this.type = NodeType.Dummy;
27795 }
27796
27797 XMLDummy.prototype.clone = function () {
27798 return (0, _create2.default)(this);
27799 };
27800
27801 XMLDummy.prototype.toString = function (options) {
27802 return '';
27803 };
27804
27805 return XMLDummy;
27806 }(XMLNode);
27807}).call(undefined);
27808
27809},{"./NodeType":295,"./XMLNode":317,"babel-runtime/core-js/object/create":50}],315:[function(require,module,exports){
27810'use strict';
27811
27812var _create = require('babel-runtime/core-js/object/create');
27813
27814var _create2 = _interopRequireDefault(_create);
27815
27816function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27817
27818// Generated by CoffeeScript 1.12.7
27819(function () {
27820 var NodeType,
27821 XMLAttribute,
27822 XMLElement,
27823 XMLNamedNodeMap,
27824 XMLNode,
27825 getValue,
27826 isFunction,
27827 isObject,
27828 ref,
27829 extend = function extend(child, parent) {
27830 for (var key in parent) {
27831 if (hasProp.call(parent, key)) child[key] = parent[key];
27832 }function ctor() {
27833 this.constructor = child;
27834 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
27835 },
27836 hasProp = {}.hasOwnProperty;
27837
27838 ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, getValue = ref.getValue;
27839
27840 XMLNode = require('./XMLNode');
27841
27842 NodeType = require('./NodeType');
27843
27844 XMLAttribute = require('./XMLAttribute');
27845
27846 XMLNamedNodeMap = require('./XMLNamedNodeMap');
27847
27848 module.exports = XMLElement = function (superClass) {
27849 extend(XMLElement, superClass);
27850
27851 function XMLElement(parent, name, attributes) {
27852 var child, j, len, ref1;
27853 XMLElement.__super__.constructor.call(this, parent);
27854 if (name == null) {
27855 throw new Error("Missing element name. " + this.debugInfo());
27856 }
27857 this.name = this.stringify.name(name);
27858 this.type = NodeType.Element;
27859 this.attribs = {};
27860 this.schemaTypeInfo = null;
27861 if (attributes != null) {
27862 this.attribute(attributes);
27863 }
27864 if (parent.type === NodeType.Document) {
27865 this.isRoot = true;
27866 this.documentObject = parent;
27867 parent.rootObject = this;
27868 if (parent.children) {
27869 ref1 = parent.children;
27870 for (j = 0, len = ref1.length; j < len; j++) {
27871 child = ref1[j];
27872 if (child.type === NodeType.DocType) {
27873 child.name = this.name;
27874 break;
27875 }
27876 }
27877 }
27878 }
27879 }
27880
27881 Object.defineProperty(XMLElement.prototype, 'tagName', {
27882 get: function get() {
27883 return this.name;
27884 }
27885 });
27886
27887 Object.defineProperty(XMLElement.prototype, 'namespaceURI', {
27888 get: function get() {
27889 return '';
27890 }
27891 });
27892
27893 Object.defineProperty(XMLElement.prototype, 'prefix', {
27894 get: function get() {
27895 return '';
27896 }
27897 });
27898
27899 Object.defineProperty(XMLElement.prototype, 'localName', {
27900 get: function get() {
27901 return this.name;
27902 }
27903 });
27904
27905 Object.defineProperty(XMLElement.prototype, 'id', {
27906 get: function get() {
27907 throw new Error("This DOM method is not implemented." + this.debugInfo());
27908 }
27909 });
27910
27911 Object.defineProperty(XMLElement.prototype, 'className', {
27912 get: function get() {
27913 throw new Error("This DOM method is not implemented." + this.debugInfo());
27914 }
27915 });
27916
27917 Object.defineProperty(XMLElement.prototype, 'classList', {
27918 get: function get() {
27919 throw new Error("This DOM method is not implemented." + this.debugInfo());
27920 }
27921 });
27922
27923 Object.defineProperty(XMLElement.prototype, 'attributes', {
27924 get: function get() {
27925 if (!this.attributeMap || !this.attributeMap.nodes) {
27926 this.attributeMap = new XMLNamedNodeMap(this.attribs);
27927 }
27928 return this.attributeMap;
27929 }
27930 });
27931
27932 XMLElement.prototype.clone = function () {
27933 var att, attName, clonedSelf, ref1;
27934 clonedSelf = (0, _create2.default)(this);
27935 if (clonedSelf.isRoot) {
27936 clonedSelf.documentObject = null;
27937 }
27938 clonedSelf.attribs = {};
27939 ref1 = this.attribs;
27940 for (attName in ref1) {
27941 if (!hasProp.call(ref1, attName)) continue;
27942 att = ref1[attName];
27943 clonedSelf.attribs[attName] = att.clone();
27944 }
27945 clonedSelf.children = [];
27946 this.children.forEach(function (child) {
27947 var clonedChild;
27948 clonedChild = child.clone();
27949 clonedChild.parent = clonedSelf;
27950 return clonedSelf.children.push(clonedChild);
27951 });
27952 return clonedSelf;
27953 };
27954
27955 XMLElement.prototype.attribute = function (name, value) {
27956 var attName, attValue;
27957 if (name != null) {
27958 name = getValue(name);
27959 }
27960 if (isObject(name)) {
27961 for (attName in name) {
27962 if (!hasProp.call(name, attName)) continue;
27963 attValue = name[attName];
27964 this.attribute(attName, attValue);
27965 }
27966 } else {
27967 if (isFunction(value)) {
27968 value = value.apply();
27969 }
27970 if (this.options.keepNullAttributes && value == null) {
27971 this.attribs[name] = new XMLAttribute(this, name, "");
27972 } else if (value != null) {
27973 this.attribs[name] = new XMLAttribute(this, name, value);
27974 }
27975 }
27976 return this;
27977 };
27978
27979 XMLElement.prototype.removeAttribute = function (name) {
27980 var attName, j, len;
27981 if (name == null) {
27982 throw new Error("Missing attribute name. " + this.debugInfo());
27983 }
27984 name = getValue(name);
27985 if (Array.isArray(name)) {
27986 for (j = 0, len = name.length; j < len; j++) {
27987 attName = name[j];
27988 delete this.attribs[attName];
27989 }
27990 } else {
27991 delete this.attribs[name];
27992 }
27993 return this;
27994 };
27995
27996 XMLElement.prototype.toString = function (options) {
27997 return this.options.writer.element(this, this.options.writer.filterOptions(options));
27998 };
27999
28000 XMLElement.prototype.att = function (name, value) {
28001 return this.attribute(name, value);
28002 };
28003
28004 XMLElement.prototype.a = function (name, value) {
28005 return this.attribute(name, value);
28006 };
28007
28008 XMLElement.prototype.getAttribute = function (name) {
28009 if (this.attribs.hasOwnProperty(name)) {
28010 return this.attribs[name].value;
28011 } else {
28012 return null;
28013 }
28014 };
28015
28016 XMLElement.prototype.setAttribute = function (name, value) {
28017 throw new Error("This DOM method is not implemented." + this.debugInfo());
28018 };
28019
28020 XMLElement.prototype.getAttributeNode = function (name) {
28021 if (this.attribs.hasOwnProperty(name)) {
28022 return this.attribs[name];
28023 } else {
28024 return null;
28025 }
28026 };
28027
28028 XMLElement.prototype.setAttributeNode = function (newAttr) {
28029 throw new Error("This DOM method is not implemented." + this.debugInfo());
28030 };
28031
28032 XMLElement.prototype.removeAttributeNode = function (oldAttr) {
28033 throw new Error("This DOM method is not implemented." + this.debugInfo());
28034 };
28035
28036 XMLElement.prototype.getElementsByTagName = function (name) {
28037 throw new Error("This DOM method is not implemented." + this.debugInfo());
28038 };
28039
28040 XMLElement.prototype.getAttributeNS = function (namespaceURI, localName) {
28041 throw new Error("This DOM method is not implemented." + this.debugInfo());
28042 };
28043
28044 XMLElement.prototype.setAttributeNS = function (namespaceURI, qualifiedName, value) {
28045 throw new Error("This DOM method is not implemented." + this.debugInfo());
28046 };
28047
28048 XMLElement.prototype.removeAttributeNS = function (namespaceURI, localName) {
28049 throw new Error("This DOM method is not implemented." + this.debugInfo());
28050 };
28051
28052 XMLElement.prototype.getAttributeNodeNS = function (namespaceURI, localName) {
28053 throw new Error("This DOM method is not implemented." + this.debugInfo());
28054 };
28055
28056 XMLElement.prototype.setAttributeNodeNS = function (newAttr) {
28057 throw new Error("This DOM method is not implemented." + this.debugInfo());
28058 };
28059
28060 XMLElement.prototype.getElementsByTagNameNS = function (namespaceURI, localName) {
28061 throw new Error("This DOM method is not implemented." + this.debugInfo());
28062 };
28063
28064 XMLElement.prototype.hasAttribute = function (name) {
28065 return this.attribs.hasOwnProperty(name);
28066 };
28067
28068 XMLElement.prototype.hasAttributeNS = function (namespaceURI, localName) {
28069 throw new Error("This DOM method is not implemented." + this.debugInfo());
28070 };
28071
28072 XMLElement.prototype.setIdAttribute = function (name, isId) {
28073 if (this.attribs.hasOwnProperty(name)) {
28074 return this.attribs[name].isId;
28075 } else {
28076 return isId;
28077 }
28078 };
28079
28080 XMLElement.prototype.setIdAttributeNS = function (namespaceURI, localName, isId) {
28081 throw new Error("This DOM method is not implemented." + this.debugInfo());
28082 };
28083
28084 XMLElement.prototype.setIdAttributeNode = function (idAttr, isId) {
28085 throw new Error("This DOM method is not implemented." + this.debugInfo());
28086 };
28087
28088 XMLElement.prototype.getElementsByTagName = function (tagname) {
28089 throw new Error("This DOM method is not implemented." + this.debugInfo());
28090 };
28091
28092 XMLElement.prototype.getElementsByTagNameNS = function (namespaceURI, localName) {
28093 throw new Error("This DOM method is not implemented." + this.debugInfo());
28094 };
28095
28096 XMLElement.prototype.getElementsByClassName = function (classNames) {
28097 throw new Error("This DOM method is not implemented." + this.debugInfo());
28098 };
28099
28100 XMLElement.prototype.isEqualNode = function (node) {
28101 var i, j, ref1;
28102 if (!XMLElement.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
28103 return false;
28104 }
28105 if (node.namespaceURI !== this.namespaceURI) {
28106 return false;
28107 }
28108 if (node.prefix !== this.prefix) {
28109 return false;
28110 }
28111 if (node.localName !== this.localName) {
28112 return false;
28113 }
28114 if (node.attribs.length !== this.attribs.length) {
28115 return false;
28116 }
28117 for (i = j = 0, ref1 = this.attribs.length - 1; 0 <= ref1 ? j <= ref1 : j >= ref1; i = 0 <= ref1 ? ++j : --j) {
28118 if (!this.attribs[i].isEqualNode(node.attribs[i])) {
28119 return false;
28120 }
28121 }
28122 return true;
28123 };
28124
28125 return XMLElement;
28126 }(XMLNode);
28127}).call(undefined);
28128
28129},{"./NodeType":295,"./Utility":296,"./XMLAttribute":298,"./XMLNamedNodeMap":316,"./XMLNode":317,"babel-runtime/core-js/object/create":50}],316:[function(require,module,exports){
28130"use strict";
28131
28132var _keys = require("babel-runtime/core-js/object/keys");
28133
28134var _keys2 = _interopRequireDefault(_keys);
28135
28136function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28137
28138// Generated by CoffeeScript 1.12.7
28139(function () {
28140 var XMLNamedNodeMap;
28141
28142 module.exports = XMLNamedNodeMap = function () {
28143 function XMLNamedNodeMap(nodes) {
28144 this.nodes = nodes;
28145 }
28146
28147 Object.defineProperty(XMLNamedNodeMap.prototype, 'length', {
28148 get: function get() {
28149 return (0, _keys2.default)(this.nodes).length || 0;
28150 }
28151 });
28152
28153 XMLNamedNodeMap.prototype.clone = function () {
28154 return this.nodes = null;
28155 };
28156
28157 XMLNamedNodeMap.prototype.getNamedItem = function (name) {
28158 return this.nodes[name];
28159 };
28160
28161 XMLNamedNodeMap.prototype.setNamedItem = function (node) {
28162 var oldNode;
28163 oldNode = this.nodes[node.nodeName];
28164 this.nodes[node.nodeName] = node;
28165 return oldNode || null;
28166 };
28167
28168 XMLNamedNodeMap.prototype.removeNamedItem = function (name) {
28169 var oldNode;
28170 oldNode = this.nodes[name];
28171 delete this.nodes[name];
28172 return oldNode || null;
28173 };
28174
28175 XMLNamedNodeMap.prototype.item = function (index) {
28176 return this.nodes[(0, _keys2.default)(this.nodes)[index]] || null;
28177 };
28178
28179 XMLNamedNodeMap.prototype.getNamedItemNS = function (namespaceURI, localName) {
28180 throw new Error("This DOM method is not implemented.");
28181 };
28182
28183 XMLNamedNodeMap.prototype.setNamedItemNS = function (node) {
28184 throw new Error("This DOM method is not implemented.");
28185 };
28186
28187 XMLNamedNodeMap.prototype.removeNamedItemNS = function (namespaceURI, localName) {
28188 throw new Error("This DOM method is not implemented.");
28189 };
28190
28191 return XMLNamedNodeMap;
28192 }();
28193}).call(undefined);
28194
28195},{"babel-runtime/core-js/object/keys":55}],317:[function(require,module,exports){
28196'use strict';
28197
28198// Generated by CoffeeScript 1.12.7
28199(function () {
28200 var DocumentPosition,
28201 NodeType,
28202 XMLCData,
28203 XMLComment,
28204 XMLDeclaration,
28205 XMLDocType,
28206 XMLDummy,
28207 XMLElement,
28208 XMLNamedNodeMap,
28209 XMLNode,
28210 XMLNodeList,
28211 XMLProcessingInstruction,
28212 XMLRaw,
28213 XMLText,
28214 getValue,
28215 isEmpty,
28216 isFunction,
28217 isObject,
28218 ref1,
28219 hasProp = {}.hasOwnProperty;
28220
28221 ref1 = require('./Utility'), isObject = ref1.isObject, isFunction = ref1.isFunction, isEmpty = ref1.isEmpty, getValue = ref1.getValue;
28222
28223 XMLElement = null;
28224
28225 XMLCData = null;
28226
28227 XMLComment = null;
28228
28229 XMLDeclaration = null;
28230
28231 XMLDocType = null;
28232
28233 XMLRaw = null;
28234
28235 XMLText = null;
28236
28237 XMLProcessingInstruction = null;
28238
28239 XMLDummy = null;
28240
28241 NodeType = null;
28242
28243 XMLNodeList = null;
28244
28245 XMLNamedNodeMap = null;
28246
28247 DocumentPosition = null;
28248
28249 module.exports = XMLNode = function () {
28250 function XMLNode(parent1) {
28251 this.parent = parent1;
28252 if (this.parent) {
28253 this.options = this.parent.options;
28254 this.stringify = this.parent.stringify;
28255 }
28256 this.value = null;
28257 this.children = [];
28258 this.baseURI = null;
28259 if (!XMLElement) {
28260 XMLElement = require('./XMLElement');
28261 XMLCData = require('./XMLCData');
28262 XMLComment = require('./XMLComment');
28263 XMLDeclaration = require('./XMLDeclaration');
28264 XMLDocType = require('./XMLDocType');
28265 XMLRaw = require('./XMLRaw');
28266 XMLText = require('./XMLText');
28267 XMLProcessingInstruction = require('./XMLProcessingInstruction');
28268 XMLDummy = require('./XMLDummy');
28269 NodeType = require('./NodeType');
28270 XMLNodeList = require('./XMLNodeList');
28271 XMLNamedNodeMap = require('./XMLNamedNodeMap');
28272 DocumentPosition = require('./DocumentPosition');
28273 }
28274 }
28275
28276 Object.defineProperty(XMLNode.prototype, 'nodeName', {
28277 get: function get() {
28278 return this.name;
28279 }
28280 });
28281
28282 Object.defineProperty(XMLNode.prototype, 'nodeType', {
28283 get: function get() {
28284 return this.type;
28285 }
28286 });
28287
28288 Object.defineProperty(XMLNode.prototype, 'nodeValue', {
28289 get: function get() {
28290 return this.value;
28291 }
28292 });
28293
28294 Object.defineProperty(XMLNode.prototype, 'parentNode', {
28295 get: function get() {
28296 return this.parent;
28297 }
28298 });
28299
28300 Object.defineProperty(XMLNode.prototype, 'childNodes', {
28301 get: function get() {
28302 if (!this.childNodeList || !this.childNodeList.nodes) {
28303 this.childNodeList = new XMLNodeList(this.children);
28304 }
28305 return this.childNodeList;
28306 }
28307 });
28308
28309 Object.defineProperty(XMLNode.prototype, 'firstChild', {
28310 get: function get() {
28311 return this.children[0] || null;
28312 }
28313 });
28314
28315 Object.defineProperty(XMLNode.prototype, 'lastChild', {
28316 get: function get() {
28317 return this.children[this.children.length - 1] || null;
28318 }
28319 });
28320
28321 Object.defineProperty(XMLNode.prototype, 'previousSibling', {
28322 get: function get() {
28323 var i;
28324 i = this.parent.children.indexOf(this);
28325 return this.parent.children[i - 1] || null;
28326 }
28327 });
28328
28329 Object.defineProperty(XMLNode.prototype, 'nextSibling', {
28330 get: function get() {
28331 var i;
28332 i = this.parent.children.indexOf(this);
28333 return this.parent.children[i + 1] || null;
28334 }
28335 });
28336
28337 Object.defineProperty(XMLNode.prototype, 'ownerDocument', {
28338 get: function get() {
28339 return this.document() || null;
28340 }
28341 });
28342
28343 Object.defineProperty(XMLNode.prototype, 'textContent', {
28344 get: function get() {
28345 var child, j, len, ref2, str;
28346 if (this.nodeType === NodeType.Element || this.nodeType === NodeType.DocumentFragment) {
28347 str = '';
28348 ref2 = this.children;
28349 for (j = 0, len = ref2.length; j < len; j++) {
28350 child = ref2[j];
28351 if (child.textContent) {
28352 str += child.textContent;
28353 }
28354 }
28355 return str;
28356 } else {
28357 return null;
28358 }
28359 },
28360 set: function set(value) {
28361 throw new Error("This DOM method is not implemented." + this.debugInfo());
28362 }
28363 });
28364
28365 XMLNode.prototype.setParent = function (parent) {
28366 var child, j, len, ref2, results;
28367 this.parent = parent;
28368 if (parent) {
28369 this.options = parent.options;
28370 this.stringify = parent.stringify;
28371 }
28372 ref2 = this.children;
28373 results = [];
28374 for (j = 0, len = ref2.length; j < len; j++) {
28375 child = ref2[j];
28376 results.push(child.setParent(this));
28377 }
28378 return results;
28379 };
28380
28381 XMLNode.prototype.element = function (name, attributes, text) {
28382 var childNode, item, j, k, key, lastChild, len, len1, ref2, ref3, val;
28383 lastChild = null;
28384 if (attributes === null && text == null) {
28385 ref2 = [{}, null], attributes = ref2[0], text = ref2[1];
28386 }
28387 if (attributes == null) {
28388 attributes = {};
28389 }
28390 attributes = getValue(attributes);
28391 if (!isObject(attributes)) {
28392 ref3 = [attributes, text], text = ref3[0], attributes = ref3[1];
28393 }
28394 if (name != null) {
28395 name = getValue(name);
28396 }
28397 if (Array.isArray(name)) {
28398 for (j = 0, len = name.length; j < len; j++) {
28399 item = name[j];
28400 lastChild = this.element(item);
28401 }
28402 } else if (isFunction(name)) {
28403 lastChild = this.element(name.apply());
28404 } else if (isObject(name)) {
28405 for (key in name) {
28406 if (!hasProp.call(name, key)) continue;
28407 val = name[key];
28408 if (isFunction(val)) {
28409 val = val.apply();
28410 }
28411 if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) {
28412 lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val);
28413 } else if (!this.options.separateArrayItems && Array.isArray(val) && isEmpty(val)) {
28414 lastChild = this.dummy();
28415 } else if (isObject(val) && isEmpty(val)) {
28416 lastChild = this.element(key);
28417 } else if (!this.options.keepNullNodes && val == null) {
28418 lastChild = this.dummy();
28419 } else if (!this.options.separateArrayItems && Array.isArray(val)) {
28420 for (k = 0, len1 = val.length; k < len1; k++) {
28421 item = val[k];
28422 childNode = {};
28423 childNode[key] = item;
28424 lastChild = this.element(childNode);
28425 }
28426 } else if (isObject(val)) {
28427 if (!this.options.ignoreDecorators && this.stringify.convertTextKey && key.indexOf(this.stringify.convertTextKey) === 0) {
28428 lastChild = this.element(val);
28429 } else {
28430 lastChild = this.element(key);
28431 lastChild.element(val);
28432 }
28433 } else {
28434 lastChild = this.element(key, val);
28435 }
28436 }
28437 } else if (!this.options.keepNullNodes && text === null) {
28438 lastChild = this.dummy();
28439 } else {
28440 if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) {
28441 lastChild = this.text(text);
28442 } else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) {
28443 lastChild = this.cdata(text);
28444 } else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) {
28445 lastChild = this.comment(text);
28446 } else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) {
28447 lastChild = this.raw(text);
28448 } else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) {
28449 lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), text);
28450 } else {
28451 lastChild = this.node(name, attributes, text);
28452 }
28453 }
28454 if (lastChild == null) {
28455 throw new Error("Could not create any elements with: " + name + ". " + this.debugInfo());
28456 }
28457 return lastChild;
28458 };
28459
28460 XMLNode.prototype.insertBefore = function (name, attributes, text) {
28461 var child, i, newChild, refChild, removed;
28462 if (name != null ? name.type : void 0) {
28463 newChild = name;
28464 refChild = attributes;
28465 newChild.setParent(this);
28466 if (refChild) {
28467 i = children.indexOf(refChild);
28468 removed = children.splice(i);
28469 children.push(newChild);
28470 Array.prototype.push.apply(children, removed);
28471 } else {
28472 children.push(newChild);
28473 }
28474 return newChild;
28475 } else {
28476 if (this.isRoot) {
28477 throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
28478 }
28479 i = this.parent.children.indexOf(this);
28480 removed = this.parent.children.splice(i);
28481 child = this.parent.element(name, attributes, text);
28482 Array.prototype.push.apply(this.parent.children, removed);
28483 return child;
28484 }
28485 };
28486
28487 XMLNode.prototype.insertAfter = function (name, attributes, text) {
28488 var child, i, removed;
28489 if (this.isRoot) {
28490 throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
28491 }
28492 i = this.parent.children.indexOf(this);
28493 removed = this.parent.children.splice(i + 1);
28494 child = this.parent.element(name, attributes, text);
28495 Array.prototype.push.apply(this.parent.children, removed);
28496 return child;
28497 };
28498
28499 XMLNode.prototype.remove = function () {
28500 var i, ref2;
28501 if (this.isRoot) {
28502 throw new Error("Cannot remove the root element. " + this.debugInfo());
28503 }
28504 i = this.parent.children.indexOf(this);
28505 [].splice.apply(this.parent.children, [i, i - i + 1].concat(ref2 = [])), ref2;
28506 return this.parent;
28507 };
28508
28509 XMLNode.prototype.node = function (name, attributes, text) {
28510 var child, ref2;
28511 if (name != null) {
28512 name = getValue(name);
28513 }
28514 attributes || (attributes = {});
28515 attributes = getValue(attributes);
28516 if (!isObject(attributes)) {
28517 ref2 = [attributes, text], text = ref2[0], attributes = ref2[1];
28518 }
28519 child = new XMLElement(this, name, attributes);
28520 if (text != null) {
28521 child.text(text);
28522 }
28523 this.children.push(child);
28524 return child;
28525 };
28526
28527 XMLNode.prototype.text = function (value) {
28528 var child;
28529 if (isObject(value)) {
28530 this.element(value);
28531 }
28532 child = new XMLText(this, value);
28533 this.children.push(child);
28534 return this;
28535 };
28536
28537 XMLNode.prototype.cdata = function (value) {
28538 var child;
28539 child = new XMLCData(this, value);
28540 this.children.push(child);
28541 return this;
28542 };
28543
28544 XMLNode.prototype.comment = function (value) {
28545 var child;
28546 child = new XMLComment(this, value);
28547 this.children.push(child);
28548 return this;
28549 };
28550
28551 XMLNode.prototype.commentBefore = function (value) {
28552 var child, i, removed;
28553 i = this.parent.children.indexOf(this);
28554 removed = this.parent.children.splice(i);
28555 child = this.parent.comment(value);
28556 Array.prototype.push.apply(this.parent.children, removed);
28557 return this;
28558 };
28559
28560 XMLNode.prototype.commentAfter = function (value) {
28561 var child, i, removed;
28562 i = this.parent.children.indexOf(this);
28563 removed = this.parent.children.splice(i + 1);
28564 child = this.parent.comment(value);
28565 Array.prototype.push.apply(this.parent.children, removed);
28566 return this;
28567 };
28568
28569 XMLNode.prototype.raw = function (value) {
28570 var child;
28571 child = new XMLRaw(this, value);
28572 this.children.push(child);
28573 return this;
28574 };
28575
28576 XMLNode.prototype.dummy = function () {
28577 var child;
28578 child = new XMLDummy(this);
28579 return child;
28580 };
28581
28582 XMLNode.prototype.instruction = function (target, value) {
28583 var insTarget, insValue, instruction, j, len;
28584 if (target != null) {
28585 target = getValue(target);
28586 }
28587 if (value != null) {
28588 value = getValue(value);
28589 }
28590 if (Array.isArray(target)) {
28591 for (j = 0, len = target.length; j < len; j++) {
28592 insTarget = target[j];
28593 this.instruction(insTarget);
28594 }
28595 } else if (isObject(target)) {
28596 for (insTarget in target) {
28597 if (!hasProp.call(target, insTarget)) continue;
28598 insValue = target[insTarget];
28599 this.instruction(insTarget, insValue);
28600 }
28601 } else {
28602 if (isFunction(value)) {
28603 value = value.apply();
28604 }
28605 instruction = new XMLProcessingInstruction(this, target, value);
28606 this.children.push(instruction);
28607 }
28608 return this;
28609 };
28610
28611 XMLNode.prototype.instructionBefore = function (target, value) {
28612 var child, i, removed;
28613 i = this.parent.children.indexOf(this);
28614 removed = this.parent.children.splice(i);
28615 child = this.parent.instruction(target, value);
28616 Array.prototype.push.apply(this.parent.children, removed);
28617 return this;
28618 };
28619
28620 XMLNode.prototype.instructionAfter = function (target, value) {
28621 var child, i, removed;
28622 i = this.parent.children.indexOf(this);
28623 removed = this.parent.children.splice(i + 1);
28624 child = this.parent.instruction(target, value);
28625 Array.prototype.push.apply(this.parent.children, removed);
28626 return this;
28627 };
28628
28629 XMLNode.prototype.declaration = function (version, encoding, standalone) {
28630 var doc, xmldec;
28631 doc = this.document();
28632 xmldec = new XMLDeclaration(doc, version, encoding, standalone);
28633 if (doc.children.length === 0) {
28634 doc.children.unshift(xmldec);
28635 } else if (doc.children[0].type === NodeType.Declaration) {
28636 doc.children[0] = xmldec;
28637 } else {
28638 doc.children.unshift(xmldec);
28639 }
28640 return doc.root() || doc;
28641 };
28642
28643 XMLNode.prototype.dtd = function (pubID, sysID) {
28644 var child, doc, doctype, i, j, k, len, len1, ref2, ref3;
28645 doc = this.document();
28646 doctype = new XMLDocType(doc, pubID, sysID);
28647 ref2 = doc.children;
28648 for (i = j = 0, len = ref2.length; j < len; i = ++j) {
28649 child = ref2[i];
28650 if (child.type === NodeType.DocType) {
28651 doc.children[i] = doctype;
28652 return doctype;
28653 }
28654 }
28655 ref3 = doc.children;
28656 for (i = k = 0, len1 = ref3.length; k < len1; i = ++k) {
28657 child = ref3[i];
28658 if (child.isRoot) {
28659 doc.children.splice(i, 0, doctype);
28660 return doctype;
28661 }
28662 }
28663 doc.children.push(doctype);
28664 return doctype;
28665 };
28666
28667 XMLNode.prototype.up = function () {
28668 if (this.isRoot) {
28669 throw new Error("The root node has no parent. Use doc() if you need to get the document object.");
28670 }
28671 return this.parent;
28672 };
28673
28674 XMLNode.prototype.root = function () {
28675 var node;
28676 node = this;
28677 while (node) {
28678 if (node.type === NodeType.Document) {
28679 return node.rootObject;
28680 } else if (node.isRoot) {
28681 return node;
28682 } else {
28683 node = node.parent;
28684 }
28685 }
28686 };
28687
28688 XMLNode.prototype.document = function () {
28689 var node;
28690 node = this;
28691 while (node) {
28692 if (node.type === NodeType.Document) {
28693 return node;
28694 } else {
28695 node = node.parent;
28696 }
28697 }
28698 };
28699
28700 XMLNode.prototype.end = function (options) {
28701 return this.document().end(options);
28702 };
28703
28704 XMLNode.prototype.prev = function () {
28705 var i;
28706 i = this.parent.children.indexOf(this);
28707 if (i < 1) {
28708 throw new Error("Already at the first node. " + this.debugInfo());
28709 }
28710 return this.parent.children[i - 1];
28711 };
28712
28713 XMLNode.prototype.next = function () {
28714 var i;
28715 i = this.parent.children.indexOf(this);
28716 if (i === -1 || i === this.parent.children.length - 1) {
28717 throw new Error("Already at the last node. " + this.debugInfo());
28718 }
28719 return this.parent.children[i + 1];
28720 };
28721
28722 XMLNode.prototype.importDocument = function (doc) {
28723 var clonedRoot;
28724 clonedRoot = doc.root().clone();
28725 clonedRoot.parent = this;
28726 clonedRoot.isRoot = false;
28727 this.children.push(clonedRoot);
28728 return this;
28729 };
28730
28731 XMLNode.prototype.debugInfo = function (name) {
28732 var ref2, ref3;
28733 name = name || this.name;
28734 if (name == null && !((ref2 = this.parent) != null ? ref2.name : void 0)) {
28735 return "";
28736 } else if (name == null) {
28737 return "parent: <" + this.parent.name + ">";
28738 } else if (!((ref3 = this.parent) != null ? ref3.name : void 0)) {
28739 return "node: <" + name + ">";
28740 } else {
28741 return "node: <" + name + ">, parent: <" + this.parent.name + ">";
28742 }
28743 };
28744
28745 XMLNode.prototype.ele = function (name, attributes, text) {
28746 return this.element(name, attributes, text);
28747 };
28748
28749 XMLNode.prototype.nod = function (name, attributes, text) {
28750 return this.node(name, attributes, text);
28751 };
28752
28753 XMLNode.prototype.txt = function (value) {
28754 return this.text(value);
28755 };
28756
28757 XMLNode.prototype.dat = function (value) {
28758 return this.cdata(value);
28759 };
28760
28761 XMLNode.prototype.com = function (value) {
28762 return this.comment(value);
28763 };
28764
28765 XMLNode.prototype.ins = function (target, value) {
28766 return this.instruction(target, value);
28767 };
28768
28769 XMLNode.prototype.doc = function () {
28770 return this.document();
28771 };
28772
28773 XMLNode.prototype.dec = function (version, encoding, standalone) {
28774 return this.declaration(version, encoding, standalone);
28775 };
28776
28777 XMLNode.prototype.e = function (name, attributes, text) {
28778 return this.element(name, attributes, text);
28779 };
28780
28781 XMLNode.prototype.n = function (name, attributes, text) {
28782 return this.node(name, attributes, text);
28783 };
28784
28785 XMLNode.prototype.t = function (value) {
28786 return this.text(value);
28787 };
28788
28789 XMLNode.prototype.d = function (value) {
28790 return this.cdata(value);
28791 };
28792
28793 XMLNode.prototype.c = function (value) {
28794 return this.comment(value);
28795 };
28796
28797 XMLNode.prototype.r = function (value) {
28798 return this.raw(value);
28799 };
28800
28801 XMLNode.prototype.i = function (target, value) {
28802 return this.instruction(target, value);
28803 };
28804
28805 XMLNode.prototype.u = function () {
28806 return this.up();
28807 };
28808
28809 XMLNode.prototype.importXMLBuilder = function (doc) {
28810 return this.importDocument(doc);
28811 };
28812
28813 XMLNode.prototype.replaceChild = function (newChild, oldChild) {
28814 throw new Error("This DOM method is not implemented." + this.debugInfo());
28815 };
28816
28817 XMLNode.prototype.removeChild = function (oldChild) {
28818 throw new Error("This DOM method is not implemented." + this.debugInfo());
28819 };
28820
28821 XMLNode.prototype.appendChild = function (newChild) {
28822 throw new Error("This DOM method is not implemented." + this.debugInfo());
28823 };
28824
28825 XMLNode.prototype.hasChildNodes = function () {
28826 return this.children.length !== 0;
28827 };
28828
28829 XMLNode.prototype.cloneNode = function (deep) {
28830 throw new Error("This DOM method is not implemented." + this.debugInfo());
28831 };
28832
28833 XMLNode.prototype.normalize = function () {
28834 throw new Error("This DOM method is not implemented." + this.debugInfo());
28835 };
28836
28837 XMLNode.prototype.isSupported = function (feature, version) {
28838 return true;
28839 };
28840
28841 XMLNode.prototype.hasAttributes = function () {
28842 return this.attribs.length !== 0;
28843 };
28844
28845 XMLNode.prototype.compareDocumentPosition = function (other) {
28846 var ref, res;
28847 ref = this;
28848 if (ref === other) {
28849 return 0;
28850 } else if (this.document() !== other.document()) {
28851 res = DocumentPosition.Disconnected | DocumentPosition.ImplementationSpecific;
28852 if (Math.random() < 0.5) {
28853 res |= DocumentPosition.Preceding;
28854 } else {
28855 res |= DocumentPosition.Following;
28856 }
28857 return res;
28858 } else if (ref.isAncestor(other)) {
28859 return DocumentPosition.Contains | DocumentPosition.Preceding;
28860 } else if (ref.isDescendant(other)) {
28861 return DocumentPosition.Contains | DocumentPosition.Following;
28862 } else if (ref.isPreceding(other)) {
28863 return DocumentPosition.Preceding;
28864 } else {
28865 return DocumentPosition.Following;
28866 }
28867 };
28868
28869 XMLNode.prototype.isSameNode = function (other) {
28870 throw new Error("This DOM method is not implemented." + this.debugInfo());
28871 };
28872
28873 XMLNode.prototype.lookupPrefix = function (namespaceURI) {
28874 throw new Error("This DOM method is not implemented." + this.debugInfo());
28875 };
28876
28877 XMLNode.prototype.isDefaultNamespace = function (namespaceURI) {
28878 throw new Error("This DOM method is not implemented." + this.debugInfo());
28879 };
28880
28881 XMLNode.prototype.lookupNamespaceURI = function (prefix) {
28882 throw new Error("This DOM method is not implemented." + this.debugInfo());
28883 };
28884
28885 XMLNode.prototype.isEqualNode = function (node) {
28886 var i, j, ref2;
28887 if (node.nodeType !== this.nodeType) {
28888 return false;
28889 }
28890 if (node.children.length !== this.children.length) {
28891 return false;
28892 }
28893 for (i = j = 0, ref2 = this.children.length - 1; 0 <= ref2 ? j <= ref2 : j >= ref2; i = 0 <= ref2 ? ++j : --j) {
28894 if (!this.children[i].isEqualNode(node.children[i])) {
28895 return false;
28896 }
28897 }
28898 return true;
28899 };
28900
28901 XMLNode.prototype.getFeature = function (feature, version) {
28902 throw new Error("This DOM method is not implemented." + this.debugInfo());
28903 };
28904
28905 XMLNode.prototype.setUserData = function (key, data, handler) {
28906 throw new Error("This DOM method is not implemented." + this.debugInfo());
28907 };
28908
28909 XMLNode.prototype.getUserData = function (key) {
28910 throw new Error("This DOM method is not implemented." + this.debugInfo());
28911 };
28912
28913 XMLNode.prototype.contains = function (other) {
28914 if (!other) {
28915 return false;
28916 }
28917 return other === this || this.isDescendant(other);
28918 };
28919
28920 XMLNode.prototype.isDescendant = function (node) {
28921 var child, isDescendantChild, j, len, ref2;
28922 ref2 = this.children;
28923 for (j = 0, len = ref2.length; j < len; j++) {
28924 child = ref2[j];
28925 if (node === child) {
28926 return true;
28927 }
28928 isDescendantChild = child.isDescendant(node);
28929 if (isDescendantChild) {
28930 return true;
28931 }
28932 }
28933 return false;
28934 };
28935
28936 XMLNode.prototype.isAncestor = function (node) {
28937 return node.isDescendant(this);
28938 };
28939
28940 XMLNode.prototype.isPreceding = function (node) {
28941 var nodePos, thisPos;
28942 nodePos = this.treePosition(node);
28943 thisPos = this.treePosition(this);
28944 if (nodePos === -1 || thisPos === -1) {
28945 return false;
28946 } else {
28947 return nodePos < thisPos;
28948 }
28949 };
28950
28951 XMLNode.prototype.isFollowing = function (node) {
28952 var nodePos, thisPos;
28953 nodePos = this.treePosition(node);
28954 thisPos = this.treePosition(this);
28955 if (nodePos === -1 || thisPos === -1) {
28956 return false;
28957 } else {
28958 return nodePos > thisPos;
28959 }
28960 };
28961
28962 XMLNode.prototype.treePosition = function (node) {
28963 var found, pos;
28964 pos = 0;
28965 found = false;
28966 this.foreachTreeNode(this.document(), function (childNode) {
28967 pos++;
28968 if (!found && childNode === node) {
28969 return found = true;
28970 }
28971 });
28972 if (found) {
28973 return pos;
28974 } else {
28975 return -1;
28976 }
28977 };
28978
28979 XMLNode.prototype.foreachTreeNode = function (node, func) {
28980 var child, j, len, ref2, res;
28981 node || (node = this.document());
28982 ref2 = node.children;
28983 for (j = 0, len = ref2.length; j < len; j++) {
28984 child = ref2[j];
28985 if (res = func(child)) {
28986 return res;
28987 } else {
28988 res = this.foreachTreeNode(child, func);
28989 if (res) {
28990 return res;
28991 }
28992 }
28993 }
28994 };
28995
28996 return XMLNode;
28997 }();
28998}).call(undefined);
28999
29000},{"./DocumentPosition":294,"./NodeType":295,"./Utility":296,"./XMLCData":299,"./XMLComment":301,"./XMLDeclaration":310,"./XMLDocType":311,"./XMLDummy":314,"./XMLElement":315,"./XMLNamedNodeMap":316,"./XMLNodeList":318,"./XMLProcessingInstruction":319,"./XMLRaw":320,"./XMLText":324}],318:[function(require,module,exports){
29001'use strict';
29002
29003// Generated by CoffeeScript 1.12.7
29004(function () {
29005 var XMLNodeList;
29006
29007 module.exports = XMLNodeList = function () {
29008 function XMLNodeList(nodes) {
29009 this.nodes = nodes;
29010 }
29011
29012 Object.defineProperty(XMLNodeList.prototype, 'length', {
29013 get: function get() {
29014 return this.nodes.length || 0;
29015 }
29016 });
29017
29018 XMLNodeList.prototype.clone = function () {
29019 return this.nodes = null;
29020 };
29021
29022 XMLNodeList.prototype.item = function (index) {
29023 return this.nodes[index] || null;
29024 };
29025
29026 return XMLNodeList;
29027 }();
29028}).call(undefined);
29029
29030},{}],319:[function(require,module,exports){
29031'use strict';
29032
29033var _create = require('babel-runtime/core-js/object/create');
29034
29035var _create2 = _interopRequireDefault(_create);
29036
29037function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29038
29039// Generated by CoffeeScript 1.12.7
29040(function () {
29041 var NodeType,
29042 XMLCharacterData,
29043 XMLProcessingInstruction,
29044 extend = function extend(child, parent) {
29045 for (var key in parent) {
29046 if (hasProp.call(parent, key)) child[key] = parent[key];
29047 }function ctor() {
29048 this.constructor = child;
29049 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
29050 },
29051 hasProp = {}.hasOwnProperty;
29052
29053 NodeType = require('./NodeType');
29054
29055 XMLCharacterData = require('./XMLCharacterData');
29056
29057 module.exports = XMLProcessingInstruction = function (superClass) {
29058 extend(XMLProcessingInstruction, superClass);
29059
29060 function XMLProcessingInstruction(parent, target, value) {
29061 XMLProcessingInstruction.__super__.constructor.call(this, parent);
29062 if (target == null) {
29063 throw new Error("Missing instruction target. " + this.debugInfo());
29064 }
29065 this.type = NodeType.ProcessingInstruction;
29066 this.target = this.stringify.insTarget(target);
29067 this.name = this.target;
29068 if (value) {
29069 this.value = this.stringify.insValue(value);
29070 }
29071 }
29072
29073 XMLProcessingInstruction.prototype.clone = function () {
29074 return (0, _create2.default)(this);
29075 };
29076
29077 XMLProcessingInstruction.prototype.toString = function (options) {
29078 return this.options.writer.processingInstruction(this, this.options.writer.filterOptions(options));
29079 };
29080
29081 XMLProcessingInstruction.prototype.isEqualNode = function (node) {
29082 if (!XMLProcessingInstruction.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
29083 return false;
29084 }
29085 if (node.target !== this.target) {
29086 return false;
29087 }
29088 return true;
29089 };
29090
29091 return XMLProcessingInstruction;
29092 }(XMLCharacterData);
29093}).call(undefined);
29094
29095},{"./NodeType":295,"./XMLCharacterData":300,"babel-runtime/core-js/object/create":50}],320:[function(require,module,exports){
29096'use strict';
29097
29098var _create = require('babel-runtime/core-js/object/create');
29099
29100var _create2 = _interopRequireDefault(_create);
29101
29102function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29103
29104// Generated by CoffeeScript 1.12.7
29105(function () {
29106 var NodeType,
29107 XMLNode,
29108 XMLRaw,
29109 extend = function extend(child, parent) {
29110 for (var key in parent) {
29111 if (hasProp.call(parent, key)) child[key] = parent[key];
29112 }function ctor() {
29113 this.constructor = child;
29114 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
29115 },
29116 hasProp = {}.hasOwnProperty;
29117
29118 NodeType = require('./NodeType');
29119
29120 XMLNode = require('./XMLNode');
29121
29122 module.exports = XMLRaw = function (superClass) {
29123 extend(XMLRaw, superClass);
29124
29125 function XMLRaw(parent, text) {
29126 XMLRaw.__super__.constructor.call(this, parent);
29127 if (text == null) {
29128 throw new Error("Missing raw text. " + this.debugInfo());
29129 }
29130 this.type = NodeType.Raw;
29131 this.value = this.stringify.raw(text);
29132 }
29133
29134 XMLRaw.prototype.clone = function () {
29135 return (0, _create2.default)(this);
29136 };
29137
29138 XMLRaw.prototype.toString = function (options) {
29139 return this.options.writer.raw(this, this.options.writer.filterOptions(options));
29140 };
29141
29142 return XMLRaw;
29143 }(XMLNode);
29144}).call(undefined);
29145
29146},{"./NodeType":295,"./XMLNode":317,"babel-runtime/core-js/object/create":50}],321:[function(require,module,exports){
29147'use strict';
29148
29149// Generated by CoffeeScript 1.12.7
29150(function () {
29151 var NodeType,
29152 WriterState,
29153 XMLStreamWriter,
29154 XMLWriterBase,
29155 extend = function extend(child, parent) {
29156 for (var key in parent) {
29157 if (hasProp.call(parent, key)) child[key] = parent[key];
29158 }function ctor() {
29159 this.constructor = child;
29160 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
29161 },
29162 hasProp = {}.hasOwnProperty;
29163
29164 NodeType = require('./NodeType');
29165
29166 XMLWriterBase = require('./XMLWriterBase');
29167
29168 WriterState = require('./WriterState');
29169
29170 module.exports = XMLStreamWriter = function (superClass) {
29171 extend(XMLStreamWriter, superClass);
29172
29173 function XMLStreamWriter(stream, options) {
29174 this.stream = stream;
29175 XMLStreamWriter.__super__.constructor.call(this, options);
29176 }
29177
29178 XMLStreamWriter.prototype.endline = function (node, options, level) {
29179 if (node.isLastRootNode && options.state === WriterState.CloseTag) {
29180 return '';
29181 } else {
29182 return XMLStreamWriter.__super__.endline.call(this, node, options, level);
29183 }
29184 };
29185
29186 XMLStreamWriter.prototype.document = function (doc, options) {
29187 var child, i, j, k, len, len1, ref, ref1, results;
29188 ref = doc.children;
29189 for (i = j = 0, len = ref.length; j < len; i = ++j) {
29190 child = ref[i];
29191 child.isLastRootNode = i === doc.children.length - 1;
29192 }
29193 options = this.filterOptions(options);
29194 ref1 = doc.children;
29195 results = [];
29196 for (k = 0, len1 = ref1.length; k < len1; k++) {
29197 child = ref1[k];
29198 results.push(this.writeChildNode(child, options, 0));
29199 }
29200 return results;
29201 };
29202
29203 XMLStreamWriter.prototype.attribute = function (att, options, level) {
29204 return this.stream.write(XMLStreamWriter.__super__.attribute.call(this, att, options, level));
29205 };
29206
29207 XMLStreamWriter.prototype.cdata = function (node, options, level) {
29208 return this.stream.write(XMLStreamWriter.__super__.cdata.call(this, node, options, level));
29209 };
29210
29211 XMLStreamWriter.prototype.comment = function (node, options, level) {
29212 return this.stream.write(XMLStreamWriter.__super__.comment.call(this, node, options, level));
29213 };
29214
29215 XMLStreamWriter.prototype.declaration = function (node, options, level) {
29216 return this.stream.write(XMLStreamWriter.__super__.declaration.call(this, node, options, level));
29217 };
29218
29219 XMLStreamWriter.prototype.docType = function (node, options, level) {
29220 var child, j, len, ref;
29221 level || (level = 0);
29222 this.openNode(node, options, level);
29223 options.state = WriterState.OpenTag;
29224 this.stream.write(this.indent(node, options, level));
29225 this.stream.write('<!DOCTYPE ' + node.root().name);
29226 if (node.pubID && node.sysID) {
29227 this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
29228 } else if (node.sysID) {
29229 this.stream.write(' SYSTEM "' + node.sysID + '"');
29230 }
29231 if (node.children.length > 0) {
29232 this.stream.write(' [');
29233 this.stream.write(this.endline(node, options, level));
29234 options.state = WriterState.InsideTag;
29235 ref = node.children;
29236 for (j = 0, len = ref.length; j < len; j++) {
29237 child = ref[j];
29238 this.writeChildNode(child, options, level + 1);
29239 }
29240 options.state = WriterState.CloseTag;
29241 this.stream.write(']');
29242 }
29243 options.state = WriterState.CloseTag;
29244 this.stream.write(options.spaceBeforeSlash + '>');
29245 this.stream.write(this.endline(node, options, level));
29246 options.state = WriterState.None;
29247 return this.closeNode(node, options, level);
29248 };
29249
29250 XMLStreamWriter.prototype.element = function (node, options, level) {
29251 var att, child, childNodeCount, firstChildNode, j, len, name, prettySuppressed, ref, ref1;
29252 level || (level = 0);
29253 this.openNode(node, options, level);
29254 options.state = WriterState.OpenTag;
29255 this.stream.write(this.indent(node, options, level) + '<' + node.name);
29256 ref = node.attribs;
29257 for (name in ref) {
29258 if (!hasProp.call(ref, name)) continue;
29259 att = ref[name];
29260 this.attribute(att, options, level);
29261 }
29262 childNodeCount = node.children.length;
29263 firstChildNode = childNodeCount === 0 ? null : node.children[0];
29264 if (childNodeCount === 0 || node.children.every(function (e) {
29265 return (e.type === NodeType.Text || e.type === NodeType.Raw) && e.value === '';
29266 })) {
29267 if (options.allowEmpty) {
29268 this.stream.write('>');
29269 options.state = WriterState.CloseTag;
29270 this.stream.write('</' + node.name + '>');
29271 } else {
29272 options.state = WriterState.CloseTag;
29273 this.stream.write(options.spaceBeforeSlash + '/>');
29274 }
29275 } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && firstChildNode.value != null) {
29276 this.stream.write('>');
29277 options.state = WriterState.InsideTag;
29278 options.suppressPrettyCount++;
29279 prettySuppressed = true;
29280 this.writeChildNode(firstChildNode, options, level + 1);
29281 options.suppressPrettyCount--;
29282 prettySuppressed = false;
29283 options.state = WriterState.CloseTag;
29284 this.stream.write('</' + node.name + '>');
29285 } else {
29286 this.stream.write('>' + this.endline(node, options, level));
29287 options.state = WriterState.InsideTag;
29288 ref1 = node.children;
29289 for (j = 0, len = ref1.length; j < len; j++) {
29290 child = ref1[j];
29291 this.writeChildNode(child, options, level + 1);
29292 }
29293 options.state = WriterState.CloseTag;
29294 this.stream.write(this.indent(node, options, level) + '</' + node.name + '>');
29295 }
29296 this.stream.write(this.endline(node, options, level));
29297 options.state = WriterState.None;
29298 return this.closeNode(node, options, level);
29299 };
29300
29301 XMLStreamWriter.prototype.processingInstruction = function (node, options, level) {
29302 return this.stream.write(XMLStreamWriter.__super__.processingInstruction.call(this, node, options, level));
29303 };
29304
29305 XMLStreamWriter.prototype.raw = function (node, options, level) {
29306 return this.stream.write(XMLStreamWriter.__super__.raw.call(this, node, options, level));
29307 };
29308
29309 XMLStreamWriter.prototype.text = function (node, options, level) {
29310 return this.stream.write(XMLStreamWriter.__super__.text.call(this, node, options, level));
29311 };
29312
29313 XMLStreamWriter.prototype.dtdAttList = function (node, options, level) {
29314 return this.stream.write(XMLStreamWriter.__super__.dtdAttList.call(this, node, options, level));
29315 };
29316
29317 XMLStreamWriter.prototype.dtdElement = function (node, options, level) {
29318 return this.stream.write(XMLStreamWriter.__super__.dtdElement.call(this, node, options, level));
29319 };
29320
29321 XMLStreamWriter.prototype.dtdEntity = function (node, options, level) {
29322 return this.stream.write(XMLStreamWriter.__super__.dtdEntity.call(this, node, options, level));
29323 };
29324
29325 XMLStreamWriter.prototype.dtdNotation = function (node, options, level) {
29326 return this.stream.write(XMLStreamWriter.__super__.dtdNotation.call(this, node, options, level));
29327 };
29328
29329 return XMLStreamWriter;
29330 }(XMLWriterBase);
29331}).call(undefined);
29332
29333},{"./NodeType":295,"./WriterState":297,"./XMLWriterBase":325}],322:[function(require,module,exports){
29334'use strict';
29335
29336// Generated by CoffeeScript 1.12.7
29337(function () {
29338 var XMLStringWriter,
29339 XMLWriterBase,
29340 extend = function extend(child, parent) {
29341 for (var key in parent) {
29342 if (hasProp.call(parent, key)) child[key] = parent[key];
29343 }function ctor() {
29344 this.constructor = child;
29345 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
29346 },
29347 hasProp = {}.hasOwnProperty;
29348
29349 XMLWriterBase = require('./XMLWriterBase');
29350
29351 module.exports = XMLStringWriter = function (superClass) {
29352 extend(XMLStringWriter, superClass);
29353
29354 function XMLStringWriter(options) {
29355 XMLStringWriter.__super__.constructor.call(this, options);
29356 }
29357
29358 XMLStringWriter.prototype.document = function (doc, options) {
29359 var child, i, len, r, ref;
29360 options = this.filterOptions(options);
29361 r = '';
29362 ref = doc.children;
29363 for (i = 0, len = ref.length; i < len; i++) {
29364 child = ref[i];
29365 r += this.writeChildNode(child, options, 0);
29366 }
29367 if (options.pretty && r.slice(-options.newline.length) === options.newline) {
29368 r = r.slice(0, -options.newline.length);
29369 }
29370 return r;
29371 };
29372
29373 return XMLStringWriter;
29374 }(XMLWriterBase);
29375}).call(undefined);
29376
29377},{"./XMLWriterBase":325}],323:[function(require,module,exports){
29378'use strict';
29379
29380// Generated by CoffeeScript 1.12.7
29381(function () {
29382 var XMLStringifier,
29383 bind = function bind(fn, me) {
29384 return function () {
29385 return fn.apply(me, arguments);
29386 };
29387 },
29388 hasProp = {}.hasOwnProperty;
29389
29390 module.exports = XMLStringifier = function () {
29391 function XMLStringifier(options) {
29392 this.assertLegalName = bind(this.assertLegalName, this);
29393 this.assertLegalChar = bind(this.assertLegalChar, this);
29394 var key, ref, value;
29395 options || (options = {});
29396 this.options = options;
29397 if (!this.options.version) {
29398 this.options.version = '1.0';
29399 }
29400 ref = options.stringify || {};
29401 for (key in ref) {
29402 if (!hasProp.call(ref, key)) continue;
29403 value = ref[key];
29404 this[key] = value;
29405 }
29406 }
29407
29408 XMLStringifier.prototype.name = function (val) {
29409 if (this.options.noValidation) {
29410 return val;
29411 }
29412 return this.assertLegalName('' + val || '');
29413 };
29414
29415 XMLStringifier.prototype.text = function (val) {
29416 if (this.options.noValidation) {
29417 return val;
29418 }
29419 return this.assertLegalChar(this.textEscape('' + val || ''));
29420 };
29421
29422 XMLStringifier.prototype.cdata = function (val) {
29423 if (this.options.noValidation) {
29424 return val;
29425 }
29426 val = '' + val || '';
29427 val = val.replace(']]>', ']]]]><![CDATA[>');
29428 return this.assertLegalChar(val);
29429 };
29430
29431 XMLStringifier.prototype.comment = function (val) {
29432 if (this.options.noValidation) {
29433 return val;
29434 }
29435 val = '' + val || '';
29436 if (val.match(/--/)) {
29437 throw new Error("Comment text cannot contain double-hypen: " + val);
29438 }
29439 return this.assertLegalChar(val);
29440 };
29441
29442 XMLStringifier.prototype.raw = function (val) {
29443 if (this.options.noValidation) {
29444 return val;
29445 }
29446 return '' + val || '';
29447 };
29448
29449 XMLStringifier.prototype.attValue = function (val) {
29450 if (this.options.noValidation) {
29451 return val;
29452 }
29453 return this.assertLegalChar(this.attEscape(val = '' + val || ''));
29454 };
29455
29456 XMLStringifier.prototype.insTarget = function (val) {
29457 if (this.options.noValidation) {
29458 return val;
29459 }
29460 return this.assertLegalChar('' + val || '');
29461 };
29462
29463 XMLStringifier.prototype.insValue = function (val) {
29464 if (this.options.noValidation) {
29465 return val;
29466 }
29467 val = '' + val || '';
29468 if (val.match(/\?>/)) {
29469 throw new Error("Invalid processing instruction value: " + val);
29470 }
29471 return this.assertLegalChar(val);
29472 };
29473
29474 XMLStringifier.prototype.xmlVersion = function (val) {
29475 if (this.options.noValidation) {
29476 return val;
29477 }
29478 val = '' + val || '';
29479 if (!val.match(/1\.[0-9]+/)) {
29480 throw new Error("Invalid version number: " + val);
29481 }
29482 return val;
29483 };
29484
29485 XMLStringifier.prototype.xmlEncoding = function (val) {
29486 if (this.options.noValidation) {
29487 return val;
29488 }
29489 val = '' + val || '';
29490 if (!val.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/)) {
29491 throw new Error("Invalid encoding: " + val);
29492 }
29493 return this.assertLegalChar(val);
29494 };
29495
29496 XMLStringifier.prototype.xmlStandalone = function (val) {
29497 if (this.options.noValidation) {
29498 return val;
29499 }
29500 if (val) {
29501 return "yes";
29502 } else {
29503 return "no";
29504 }
29505 };
29506
29507 XMLStringifier.prototype.dtdPubID = function (val) {
29508 if (this.options.noValidation) {
29509 return val;
29510 }
29511 return this.assertLegalChar('' + val || '');
29512 };
29513
29514 XMLStringifier.prototype.dtdSysID = function (val) {
29515 if (this.options.noValidation) {
29516 return val;
29517 }
29518 return this.assertLegalChar('' + val || '');
29519 };
29520
29521 XMLStringifier.prototype.dtdElementValue = function (val) {
29522 if (this.options.noValidation) {
29523 return val;
29524 }
29525 return this.assertLegalChar('' + val || '');
29526 };
29527
29528 XMLStringifier.prototype.dtdAttType = function (val) {
29529 if (this.options.noValidation) {
29530 return val;
29531 }
29532 return this.assertLegalChar('' + val || '');
29533 };
29534
29535 XMLStringifier.prototype.dtdAttDefault = function (val) {
29536 if (this.options.noValidation) {
29537 return val;
29538 }
29539 return this.assertLegalChar('' + val || '');
29540 };
29541
29542 XMLStringifier.prototype.dtdEntityValue = function (val) {
29543 if (this.options.noValidation) {
29544 return val;
29545 }
29546 return this.assertLegalChar('' + val || '');
29547 };
29548
29549 XMLStringifier.prototype.dtdNData = function (val) {
29550 if (this.options.noValidation) {
29551 return val;
29552 }
29553 return this.assertLegalChar('' + val || '');
29554 };
29555
29556 XMLStringifier.prototype.convertAttKey = '@';
29557
29558 XMLStringifier.prototype.convertPIKey = '?';
29559
29560 XMLStringifier.prototype.convertTextKey = '#text';
29561
29562 XMLStringifier.prototype.convertCDataKey = '#cdata';
29563
29564 XMLStringifier.prototype.convertCommentKey = '#comment';
29565
29566 XMLStringifier.prototype.convertRawKey = '#raw';
29567
29568 XMLStringifier.prototype.assertLegalChar = function (str) {
29569 var regex, res;
29570 if (this.options.noValidation) {
29571 return str;
29572 }
29573 regex = '';
29574 if (this.options.version === '1.0') {
29575 regex = /[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
29576 if (res = str.match(regex)) {
29577 throw new Error("Invalid character in string: " + str + " at index " + res.index);
29578 }
29579 } else if (this.options.version === '1.1') {
29580 regex = /[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
29581 if (res = str.match(regex)) {
29582 throw new Error("Invalid character in string: " + str + " at index " + res.index);
29583 }
29584 }
29585 return str;
29586 };
29587
29588 XMLStringifier.prototype.assertLegalName = function (str) {
29589 var regex;
29590 if (this.options.noValidation) {
29591 return str;
29592 }
29593 this.assertLegalChar(str);
29594 regex = /^([:A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])([\x2D\.0-:A-Z_a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*$/;
29595 if (!str.match(regex)) {
29596 throw new Error("Invalid character in name");
29597 }
29598 return str;
29599 };
29600
29601 XMLStringifier.prototype.textEscape = function (str) {
29602 var ampregex;
29603 if (this.options.noValidation) {
29604 return str;
29605 }
29606 ampregex = this.options.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
29607 return str.replace(ampregex, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\r/g, '&#xD;');
29608 };
29609
29610 XMLStringifier.prototype.attEscape = function (str) {
29611 var ampregex;
29612 if (this.options.noValidation) {
29613 return str;
29614 }
29615 ampregex = this.options.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
29616 return str.replace(ampregex, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;').replace(/\t/g, '&#x9;').replace(/\n/g, '&#xA;').replace(/\r/g, '&#xD;');
29617 };
29618
29619 return XMLStringifier;
29620 }();
29621}).call(undefined);
29622
29623},{}],324:[function(require,module,exports){
29624'use strict';
29625
29626var _create = require('babel-runtime/core-js/object/create');
29627
29628var _create2 = _interopRequireDefault(_create);
29629
29630function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29631
29632// Generated by CoffeeScript 1.12.7
29633(function () {
29634 var NodeType,
29635 XMLCharacterData,
29636 XMLText,
29637 extend = function extend(child, parent) {
29638 for (var key in parent) {
29639 if (hasProp.call(parent, key)) child[key] = parent[key];
29640 }function ctor() {
29641 this.constructor = child;
29642 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
29643 },
29644 hasProp = {}.hasOwnProperty;
29645
29646 NodeType = require('./NodeType');
29647
29648 XMLCharacterData = require('./XMLCharacterData');
29649
29650 module.exports = XMLText = function (superClass) {
29651 extend(XMLText, superClass);
29652
29653 function XMLText(parent, text) {
29654 XMLText.__super__.constructor.call(this, parent);
29655 if (text == null) {
29656 throw new Error("Missing element text. " + this.debugInfo());
29657 }
29658 this.name = "#text";
29659 this.type = NodeType.Text;
29660 this.value = this.stringify.text(text);
29661 }
29662
29663 Object.defineProperty(XMLText.prototype, 'isElementContentWhitespace', {
29664 get: function get() {
29665 throw new Error("This DOM method is not implemented." + this.debugInfo());
29666 }
29667 });
29668
29669 Object.defineProperty(XMLText.prototype, 'wholeText', {
29670 get: function get() {
29671 var next, prev, str;
29672 str = '';
29673 prev = this.previousSibling;
29674 while (prev) {
29675 str = prev.data + str;
29676 prev = prev.previousSibling;
29677 }
29678 str += this.data;
29679 next = this.nextSibling;
29680 while (next) {
29681 str = str + next.data;
29682 next = next.nextSibling;
29683 }
29684 return str;
29685 }
29686 });
29687
29688 XMLText.prototype.clone = function () {
29689 return (0, _create2.default)(this);
29690 };
29691
29692 XMLText.prototype.toString = function (options) {
29693 return this.options.writer.text(this, this.options.writer.filterOptions(options));
29694 };
29695
29696 XMLText.prototype.splitText = function (offset) {
29697 throw new Error("This DOM method is not implemented." + this.debugInfo());
29698 };
29699
29700 XMLText.prototype.replaceWholeText = function (content) {
29701 throw new Error("This DOM method is not implemented." + this.debugInfo());
29702 };
29703
29704 return XMLText;
29705 }(XMLCharacterData);
29706}).call(undefined);
29707
29708},{"./NodeType":295,"./XMLCharacterData":300,"babel-runtime/core-js/object/create":50}],325:[function(require,module,exports){
29709'use strict';
29710
29711// Generated by CoffeeScript 1.12.7
29712(function () {
29713 var NodeType,
29714 WriterState,
29715 XMLCData,
29716 XMLComment,
29717 XMLDTDAttList,
29718 XMLDTDElement,
29719 XMLDTDEntity,
29720 XMLDTDNotation,
29721 XMLDeclaration,
29722 XMLDocType,
29723 XMLDummy,
29724 XMLElement,
29725 XMLProcessingInstruction,
29726 XMLRaw,
29727 XMLText,
29728 XMLWriterBase,
29729 assign,
29730 hasProp = {}.hasOwnProperty;
29731
29732 assign = require('./Utility').assign;
29733
29734 NodeType = require('./NodeType');
29735
29736 XMLDeclaration = require('./XMLDeclaration');
29737
29738 XMLDocType = require('./XMLDocType');
29739
29740 XMLCData = require('./XMLCData');
29741
29742 XMLComment = require('./XMLComment');
29743
29744 XMLElement = require('./XMLElement');
29745
29746 XMLRaw = require('./XMLRaw');
29747
29748 XMLText = require('./XMLText');
29749
29750 XMLProcessingInstruction = require('./XMLProcessingInstruction');
29751
29752 XMLDummy = require('./XMLDummy');
29753
29754 XMLDTDAttList = require('./XMLDTDAttList');
29755
29756 XMLDTDElement = require('./XMLDTDElement');
29757
29758 XMLDTDEntity = require('./XMLDTDEntity');
29759
29760 XMLDTDNotation = require('./XMLDTDNotation');
29761
29762 WriterState = require('./WriterState');
29763
29764 module.exports = XMLWriterBase = function () {
29765 function XMLWriterBase(options) {
29766 var key, ref, value;
29767 options || (options = {});
29768 this.options = options;
29769 ref = options.writer || {};
29770 for (key in ref) {
29771 if (!hasProp.call(ref, key)) continue;
29772 value = ref[key];
29773 this["_" + key] = this[key];
29774 this[key] = value;
29775 }
29776 }
29777
29778 XMLWriterBase.prototype.filterOptions = function (options) {
29779 var filteredOptions, ref, ref1, ref2, ref3, ref4, ref5, ref6;
29780 options || (options = {});
29781 options = assign({}, this.options, options);
29782 filteredOptions = {
29783 writer: this
29784 };
29785 filteredOptions.pretty = options.pretty || false;
29786 filteredOptions.allowEmpty = options.allowEmpty || false;
29787 filteredOptions.indent = (ref = options.indent) != null ? ref : ' ';
29788 filteredOptions.newline = (ref1 = options.newline) != null ? ref1 : '\n';
29789 filteredOptions.offset = (ref2 = options.offset) != null ? ref2 : 0;
29790 filteredOptions.dontPrettyTextNodes = (ref3 = (ref4 = options.dontPrettyTextNodes) != null ? ref4 : options.dontprettytextnodes) != null ? ref3 : 0;
29791 filteredOptions.spaceBeforeSlash = (ref5 = (ref6 = options.spaceBeforeSlash) != null ? ref6 : options.spacebeforeslash) != null ? ref5 : '';
29792 if (filteredOptions.spaceBeforeSlash === true) {
29793 filteredOptions.spaceBeforeSlash = ' ';
29794 }
29795 filteredOptions.suppressPrettyCount = 0;
29796 filteredOptions.user = {};
29797 filteredOptions.state = WriterState.None;
29798 return filteredOptions;
29799 };
29800
29801 XMLWriterBase.prototype.indent = function (node, options, level) {
29802 var indentLevel;
29803 if (!options.pretty || options.suppressPrettyCount) {
29804 return '';
29805 } else if (options.pretty) {
29806 indentLevel = (level || 0) + options.offset + 1;
29807 if (indentLevel > 0) {
29808 return new Array(indentLevel).join(options.indent);
29809 }
29810 }
29811 return '';
29812 };
29813
29814 XMLWriterBase.prototype.endline = function (node, options, level) {
29815 if (!options.pretty || options.suppressPrettyCount) {
29816 return '';
29817 } else {
29818 return options.newline;
29819 }
29820 };
29821
29822 XMLWriterBase.prototype.attribute = function (att, options, level) {
29823 var r;
29824 this.openAttribute(att, options, level);
29825 r = ' ' + att.name + '="' + att.value + '"';
29826 this.closeAttribute(att, options, level);
29827 return r;
29828 };
29829
29830 XMLWriterBase.prototype.cdata = function (node, options, level) {
29831 var r;
29832 this.openNode(node, options, level);
29833 options.state = WriterState.OpenTag;
29834 r = this.indent(node, options, level) + '<![CDATA[';
29835 options.state = WriterState.InsideTag;
29836 r += node.value;
29837 options.state = WriterState.CloseTag;
29838 r += ']]>' + this.endline(node, options, level);
29839 options.state = WriterState.None;
29840 this.closeNode(node, options, level);
29841 return r;
29842 };
29843
29844 XMLWriterBase.prototype.comment = function (node, options, level) {
29845 var r;
29846 this.openNode(node, options, level);
29847 options.state = WriterState.OpenTag;
29848 r = this.indent(node, options, level) + '<!-- ';
29849 options.state = WriterState.InsideTag;
29850 r += node.value;
29851 options.state = WriterState.CloseTag;
29852 r += ' -->' + this.endline(node, options, level);
29853 options.state = WriterState.None;
29854 this.closeNode(node, options, level);
29855 return r;
29856 };
29857
29858 XMLWriterBase.prototype.declaration = function (node, options, level) {
29859 var r;
29860 this.openNode(node, options, level);
29861 options.state = WriterState.OpenTag;
29862 r = this.indent(node, options, level) + '<?xml';
29863 options.state = WriterState.InsideTag;
29864 r += ' version="' + node.version + '"';
29865 if (node.encoding != null) {
29866 r += ' encoding="' + node.encoding + '"';
29867 }
29868 if (node.standalone != null) {
29869 r += ' standalone="' + node.standalone + '"';
29870 }
29871 options.state = WriterState.CloseTag;
29872 r += options.spaceBeforeSlash + '?>';
29873 r += this.endline(node, options, level);
29874 options.state = WriterState.None;
29875 this.closeNode(node, options, level);
29876 return r;
29877 };
29878
29879 XMLWriterBase.prototype.docType = function (node, options, level) {
29880 var child, i, len, r, ref;
29881 level || (level = 0);
29882 this.openNode(node, options, level);
29883 options.state = WriterState.OpenTag;
29884 r = this.indent(node, options, level);
29885 r += '<!DOCTYPE ' + node.root().name;
29886 if (node.pubID && node.sysID) {
29887 r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
29888 } else if (node.sysID) {
29889 r += ' SYSTEM "' + node.sysID + '"';
29890 }
29891 if (node.children.length > 0) {
29892 r += ' [';
29893 r += this.endline(node, options, level);
29894 options.state = WriterState.InsideTag;
29895 ref = node.children;
29896 for (i = 0, len = ref.length; i < len; i++) {
29897 child = ref[i];
29898 r += this.writeChildNode(child, options, level + 1);
29899 }
29900 options.state = WriterState.CloseTag;
29901 r += ']';
29902 }
29903 options.state = WriterState.CloseTag;
29904 r += options.spaceBeforeSlash + '>';
29905 r += this.endline(node, options, level);
29906 options.state = WriterState.None;
29907 this.closeNode(node, options, level);
29908 return r;
29909 };
29910
29911 XMLWriterBase.prototype.element = function (node, options, level) {
29912 var att, child, childNodeCount, firstChildNode, i, j, len, len1, name, prettySuppressed, r, ref, ref1, ref2;
29913 level || (level = 0);
29914 prettySuppressed = false;
29915 r = '';
29916 this.openNode(node, options, level);
29917 options.state = WriterState.OpenTag;
29918 r += this.indent(node, options, level) + '<' + node.name;
29919 ref = node.attribs;
29920 for (name in ref) {
29921 if (!hasProp.call(ref, name)) continue;
29922 att = ref[name];
29923 r += this.attribute(att, options, level);
29924 }
29925 childNodeCount = node.children.length;
29926 firstChildNode = childNodeCount === 0 ? null : node.children[0];
29927 if (childNodeCount === 0 || node.children.every(function (e) {
29928 return (e.type === NodeType.Text || e.type === NodeType.Raw) && e.value === '';
29929 })) {
29930 if (options.allowEmpty) {
29931 r += '>';
29932 options.state = WriterState.CloseTag;
29933 r += '</' + node.name + '>' + this.endline(node, options, level);
29934 } else {
29935 options.state = WriterState.CloseTag;
29936 r += options.spaceBeforeSlash + '/>' + this.endline(node, options, level);
29937 }
29938 } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && firstChildNode.value != null) {
29939 r += '>';
29940 options.state = WriterState.InsideTag;
29941 options.suppressPrettyCount++;
29942 prettySuppressed = true;
29943 r += this.writeChildNode(firstChildNode, options, level + 1);
29944 options.suppressPrettyCount--;
29945 prettySuppressed = false;
29946 options.state = WriterState.CloseTag;
29947 r += '</' + node.name + '>' + this.endline(node, options, level);
29948 } else {
29949 if (options.dontPrettyTextNodes) {
29950 ref1 = node.children;
29951 for (i = 0, len = ref1.length; i < len; i++) {
29952 child = ref1[i];
29953 if ((child.type === NodeType.Text || child.type === NodeType.Raw) && child.value != null) {
29954 options.suppressPrettyCount++;
29955 prettySuppressed = true;
29956 break;
29957 }
29958 }
29959 }
29960 r += '>' + this.endline(node, options, level);
29961 options.state = WriterState.InsideTag;
29962 ref2 = node.children;
29963 for (j = 0, len1 = ref2.length; j < len1; j++) {
29964 child = ref2[j];
29965 r += this.writeChildNode(child, options, level + 1);
29966 }
29967 options.state = WriterState.CloseTag;
29968 r += this.indent(node, options, level) + '</' + node.name + '>';
29969 if (prettySuppressed) {
29970 options.suppressPrettyCount--;
29971 }
29972 r += this.endline(node, options, level);
29973 options.state = WriterState.None;
29974 }
29975 this.closeNode(node, options, level);
29976 return r;
29977 };
29978
29979 XMLWriterBase.prototype.writeChildNode = function (node, options, level) {
29980 switch (node.type) {
29981 case NodeType.CData:
29982 return this.cdata(node, options, level);
29983 case NodeType.Comment:
29984 return this.comment(node, options, level);
29985 case NodeType.Element:
29986 return this.element(node, options, level);
29987 case NodeType.Raw:
29988 return this.raw(node, options, level);
29989 case NodeType.Text:
29990 return this.text(node, options, level);
29991 case NodeType.ProcessingInstruction:
29992 return this.processingInstruction(node, options, level);
29993 case NodeType.Dummy:
29994 return '';
29995 case NodeType.Declaration:
29996 return this.declaration(node, options, level);
29997 case NodeType.DocType:
29998 return this.docType(node, options, level);
29999 case NodeType.AttributeDeclaration:
30000 return this.dtdAttList(node, options, level);
30001 case NodeType.ElementDeclaration:
30002 return this.dtdElement(node, options, level);
30003 case NodeType.EntityDeclaration:
30004 return this.dtdEntity(node, options, level);
30005 case NodeType.NotationDeclaration:
30006 return this.dtdNotation(node, options, level);
30007 default:
30008 throw new Error("Unknown XML node type: " + node.constructor.name);
30009 }
30010 };
30011
30012 XMLWriterBase.prototype.processingInstruction = function (node, options, level) {
30013 var r;
30014 this.openNode(node, options, level);
30015 options.state = WriterState.OpenTag;
30016 r = this.indent(node, options, level) + '<?';
30017 options.state = WriterState.InsideTag;
30018 r += node.target;
30019 if (node.value) {
30020 r += ' ' + node.value;
30021 }
30022 options.state = WriterState.CloseTag;
30023 r += options.spaceBeforeSlash + '?>';
30024 r += this.endline(node, options, level);
30025 options.state = WriterState.None;
30026 this.closeNode(node, options, level);
30027 return r;
30028 };
30029
30030 XMLWriterBase.prototype.raw = function (node, options, level) {
30031 var r;
30032 this.openNode(node, options, level);
30033 options.state = WriterState.OpenTag;
30034 r = this.indent(node, options, level);
30035 options.state = WriterState.InsideTag;
30036 r += node.value;
30037 options.state = WriterState.CloseTag;
30038 r += this.endline(node, options, level);
30039 options.state = WriterState.None;
30040 this.closeNode(node, options, level);
30041 return r;
30042 };
30043
30044 XMLWriterBase.prototype.text = function (node, options, level) {
30045 var r;
30046 this.openNode(node, options, level);
30047 options.state = WriterState.OpenTag;
30048 r = this.indent(node, options, level);
30049 options.state = WriterState.InsideTag;
30050 r += node.value;
30051 options.state = WriterState.CloseTag;
30052 r += this.endline(node, options, level);
30053 options.state = WriterState.None;
30054 this.closeNode(node, options, level);
30055 return r;
30056 };
30057
30058 XMLWriterBase.prototype.dtdAttList = function (node, options, level) {
30059 var r;
30060 this.openNode(node, options, level);
30061 options.state = WriterState.OpenTag;
30062 r = this.indent(node, options, level) + '<!ATTLIST';
30063 options.state = WriterState.InsideTag;
30064 r += ' ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType;
30065 if (node.defaultValueType !== '#DEFAULT') {
30066 r += ' ' + node.defaultValueType;
30067 }
30068 if (node.defaultValue) {
30069 r += ' "' + node.defaultValue + '"';
30070 }
30071 options.state = WriterState.CloseTag;
30072 r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
30073 options.state = WriterState.None;
30074 this.closeNode(node, options, level);
30075 return r;
30076 };
30077
30078 XMLWriterBase.prototype.dtdElement = function (node, options, level) {
30079 var r;
30080 this.openNode(node, options, level);
30081 options.state = WriterState.OpenTag;
30082 r = this.indent(node, options, level) + '<!ELEMENT';
30083 options.state = WriterState.InsideTag;
30084 r += ' ' + node.name + ' ' + node.value;
30085 options.state = WriterState.CloseTag;
30086 r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
30087 options.state = WriterState.None;
30088 this.closeNode(node, options, level);
30089 return r;
30090 };
30091
30092 XMLWriterBase.prototype.dtdEntity = function (node, options, level) {
30093 var r;
30094 this.openNode(node, options, level);
30095 options.state = WriterState.OpenTag;
30096 r = this.indent(node, options, level) + '<!ENTITY';
30097 options.state = WriterState.InsideTag;
30098 if (node.pe) {
30099 r += ' %';
30100 }
30101 r += ' ' + node.name;
30102 if (node.value) {
30103 r += ' "' + node.value + '"';
30104 } else {
30105 if (node.pubID && node.sysID) {
30106 r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
30107 } else if (node.sysID) {
30108 r += ' SYSTEM "' + node.sysID + '"';
30109 }
30110 if (node.nData) {
30111 r += ' NDATA ' + node.nData;
30112 }
30113 }
30114 options.state = WriterState.CloseTag;
30115 r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
30116 options.state = WriterState.None;
30117 this.closeNode(node, options, level);
30118 return r;
30119 };
30120
30121 XMLWriterBase.prototype.dtdNotation = function (node, options, level) {
30122 var r;
30123 this.openNode(node, options, level);
30124 options.state = WriterState.OpenTag;
30125 r = this.indent(node, options, level) + '<!NOTATION';
30126 options.state = WriterState.InsideTag;
30127 r += ' ' + node.name;
30128 if (node.pubID && node.sysID) {
30129 r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
30130 } else if (node.pubID) {
30131 r += ' PUBLIC "' + node.pubID + '"';
30132 } else if (node.sysID) {
30133 r += ' SYSTEM "' + node.sysID + '"';
30134 }
30135 options.state = WriterState.CloseTag;
30136 r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
30137 options.state = WriterState.None;
30138 this.closeNode(node, options, level);
30139 return r;
30140 };
30141
30142 XMLWriterBase.prototype.openNode = function (node, options, level) {};
30143
30144 XMLWriterBase.prototype.closeNode = function (node, options, level) {};
30145
30146 XMLWriterBase.prototype.openAttribute = function (att, options, level) {};
30147
30148 XMLWriterBase.prototype.closeAttribute = function (att, options, level) {};
30149
30150 return XMLWriterBase;
30151 }();
30152}).call(undefined);
30153
30154},{"./NodeType":295,"./Utility":296,"./WriterState":297,"./XMLCData":299,"./XMLComment":301,"./XMLDTDAttList":306,"./XMLDTDElement":307,"./XMLDTDEntity":308,"./XMLDTDNotation":309,"./XMLDeclaration":310,"./XMLDocType":311,"./XMLDummy":314,"./XMLElement":315,"./XMLProcessingInstruction":319,"./XMLRaw":320,"./XMLText":324}],326:[function(require,module,exports){
30155'use strict';
30156
30157// Generated by CoffeeScript 1.12.7
30158(function () {
30159 var NodeType, WriterState, XMLDOMImplementation, XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref;
30160
30161 ref = require('./Utility'), assign = ref.assign, isFunction = ref.isFunction;
30162
30163 XMLDOMImplementation = require('./XMLDOMImplementation');
30164
30165 XMLDocument = require('./XMLDocument');
30166
30167 XMLDocumentCB = require('./XMLDocumentCB');
30168
30169 XMLStringWriter = require('./XMLStringWriter');
30170
30171 XMLStreamWriter = require('./XMLStreamWriter');
30172
30173 NodeType = require('./NodeType');
30174
30175 WriterState = require('./WriterState');
30176
30177 module.exports.create = function (name, xmldec, doctype, options) {
30178 var doc, root;
30179 if (name == null) {
30180 throw new Error("Root element needs a name.");
30181 }
30182 options = assign({}, xmldec, doctype, options);
30183 doc = new XMLDocument(options);
30184 root = doc.element(name);
30185 if (!options.headless) {
30186 doc.declaration(options);
30187 if (options.pubID != null || options.sysID != null) {
30188 doc.dtd(options);
30189 }
30190 }
30191 return root;
30192 };
30193
30194 module.exports.begin = function (options, onData, onEnd) {
30195 var ref1;
30196 if (isFunction(options)) {
30197 ref1 = [options, onData], onData = ref1[0], onEnd = ref1[1];
30198 options = {};
30199 }
30200 if (onData) {
30201 return new XMLDocumentCB(options, onData, onEnd);
30202 } else {
30203 return new XMLDocument(options);
30204 }
30205 };
30206
30207 module.exports.stringWriter = function (options) {
30208 return new XMLStringWriter(options);
30209 };
30210
30211 module.exports.streamWriter = function (stream, options) {
30212 return new XMLStreamWriter(stream, options);
30213 };
30214
30215 module.exports.implementation = new XMLDOMImplementation();
30216
30217 module.exports.nodeType = NodeType;
30218
30219 module.exports.writerState = WriterState;
30220}).call(undefined);
30221
30222},{"./NodeType":295,"./Utility":296,"./WriterState":297,"./XMLDOMImplementation":304,"./XMLDocument":312,"./XMLDocumentCB":313,"./XMLStreamWriter":321,"./XMLStringWriter":322}],327:[function(require,module,exports){
30223module.exports = extend
30224
30225var hasOwnProperty = Object.prototype.hasOwnProperty;
30226
30227function extend() {
30228 var target = {}
30229
30230 for (var i = 0; i < arguments.length; i++) {
30231 var source = arguments[i]
30232
30233 for (var key in source) {
30234 if (hasOwnProperty.call(source, key)) {
30235 target[key] = source[key]
30236 }
30237 }
30238 }
30239
30240 return target
30241}
30242
30243},{}],328:[function(require,module,exports){
30244'use strict';
30245
30246var Buffer = require('buffer').Buffer;
30247var sha = require('./sha');
30248var md5 = require('./md5');
30249
30250var algorithms = {
30251 sha1: sha,
30252 md5: md5
30253};
30254
30255var blocksize = 64;
30256var zeroBuffer = Buffer.alloc(blocksize);
30257zeroBuffer.fill(0);
30258
30259function hmac(fn, key, data) {
30260 if (!Buffer.isBuffer(key)) key = Buffer.from(key);
30261 if (!Buffer.isBuffer(data)) data = Buffer.from(data);
30262
30263 if (key.length > blocksize) {
30264 key = fn(key);
30265 } else if (key.length < blocksize) {
30266 key = Buffer.concat([key, zeroBuffer], blocksize);
30267 }
30268
30269 var ipad = Buffer.alloc(blocksize),
30270 opad = Buffer.alloc(blocksize);
30271 for (var i = 0; i < blocksize; i++) {
30272 ipad[i] = key[i] ^ 0x36;
30273 opad[i] = key[i] ^ 0x5C;
30274 }
30275
30276 var hash = fn(Buffer.concat([ipad, data]));
30277 return fn(Buffer.concat([opad, hash]));
30278}
30279
30280function hash(alg, key) {
30281 alg = alg || 'sha1';
30282 var fn = algorithms[alg];
30283 var bufs = [];
30284 var length = 0;
30285 if (!fn) error('algorithm:', alg, 'is not yet supported');
30286 return {
30287 update: function update(data) {
30288 if (!Buffer.isBuffer(data)) data = Buffer.from(data);
30289
30290 bufs.push(data);
30291 length += data.length;
30292 return this;
30293 },
30294 digest: function digest(enc) {
30295 var buf = Buffer.concat(bufs);
30296 var r = key ? hmac(fn, key, buf) : fn(buf);
30297 bufs = null;
30298 return enc ? r.toString(enc) : r;
30299 }
30300 };
30301}
30302
30303function error() {
30304 var m = [].slice.call(arguments).join(' ');
30305 throw new Error([m, 'we accept pull requests', 'http://github.com/dominictarr/crypto-browserify'].join('\n'));
30306}
30307
30308exports.createHash = function (alg) {
30309 return hash(alg);
30310};
30311exports.createHmac = function (alg, key) {
30312 return hash(alg, key);
30313};
30314
30315function each(a, f) {
30316 for (var i in a) {
30317 f(a[i], i);
30318 }
30319}
30320
30321// the least I can do is make error messages for the rest of the node.js/crypto api.
30322each(['createCredentials', 'createCipher', 'createCipheriv', 'createDecipher', 'createDecipheriv', 'createSign', 'createVerify', 'createDiffieHellman', 'pbkdf2'], function (name) {
30323 exports[name] = function () {
30324 error('sorry,', name, 'is not implemented yet');
30325 };
30326});
30327
30328},{"./md5":330,"./sha":331,"buffer":70}],329:[function(require,module,exports){
30329'use strict';
30330
30331var Buffer = require('buffer').Buffer;
30332var intSize = 4;
30333var zeroBuffer = Buffer.alloc(intSize);zeroBuffer.fill(0);
30334var chrsz = 8;
30335
30336function toArray(buf, bigEndian) {
30337 if (buf.length % intSize !== 0) {
30338 var len = buf.length + (intSize - buf.length % intSize);
30339 buf = Buffer.concat([buf, zeroBuffer], len);
30340 }
30341
30342 var arr = [];
30343 var fn = bigEndian ? buf.readInt32BE : buf.readInt32LE;
30344 for (var i = 0; i < buf.length; i += intSize) {
30345 arr.push(fn.call(buf, i));
30346 }
30347 return arr;
30348}
30349
30350function toBuffer(arr, size, bigEndian) {
30351 var buf = Buffer.alloc(size);
30352 var fn = bigEndian ? buf.writeInt32BE : buf.writeInt32LE;
30353 for (var i = 0; i < arr.length; i++) {
30354 fn.call(buf, arr[i], i * 4, true);
30355 }
30356 return buf;
30357}
30358
30359function hash(buf, fn, hashSize, bigEndian) {
30360 if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf);
30361 var arr = fn(toArray(buf, bigEndian), buf.length * chrsz);
30362 return toBuffer(arr, hashSize, bigEndian);
30363}
30364
30365module.exports = { hash: hash };
30366
30367},{"buffer":70}],330:[function(require,module,exports){
30368"use strict";
30369
30370/*
30371 * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
30372 * Digest Algorithm, as defined in RFC 1321.
30373 * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
30374 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
30375 * Distributed under the BSD License
30376 * See http://pajhome.org.uk/crypt/md5 for more info.
30377 */
30378
30379var helpers = require('./helpers');
30380
30381/*
30382 * Perform a simple self-test to see if the VM is working
30383 */
30384function md5_vm_test() {
30385 return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
30386}
30387
30388/*
30389 * Calculate the MD5 of an array of little-endian words, and a bit length
30390 */
30391function core_md5(x, len) {
30392 /* append padding */
30393 x[len >> 5] |= 0x80 << len % 32;
30394 x[(len + 64 >>> 9 << 4) + 14] = len;
30395
30396 var a = 1732584193;
30397 var b = -271733879;
30398 var c = -1732584194;
30399 var d = 271733878;
30400
30401 for (var i = 0; i < x.length; i += 16) {
30402 var olda = a;
30403 var oldb = b;
30404 var oldc = c;
30405 var oldd = d;
30406
30407 a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936);
30408 d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
30409 c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
30410 b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
30411 a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
30412 d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
30413 c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
30414 b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
30415 a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
30416 d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
30417 c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
30418 b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
30419 a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
30420 d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
30421 c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
30422 b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
30423
30424 a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
30425 d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
30426 c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
30427 b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302);
30428 a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
30429 d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
30430 c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
30431 b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
30432 a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
30433 d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
30434 c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
30435 b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
30436 a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
30437 d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
30438 c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
30439 b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
30440
30441 a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
30442 d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
30443 c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
30444 b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
30445 a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
30446 d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
30447 c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
30448 b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
30449 a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
30450 d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222);
30451 c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
30452 b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
30453 a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
30454 d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
30455 c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
30456 b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
30457
30458 a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844);
30459 d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
30460 c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
30461 b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
30462 a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
30463 d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
30464 c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
30465 b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
30466 a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
30467 d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
30468 c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
30469 b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
30470 a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
30471 d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
30472 c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
30473 b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
30474
30475 a = safe_add(a, olda);
30476 b = safe_add(b, oldb);
30477 c = safe_add(c, oldc);
30478 d = safe_add(d, oldd);
30479 }
30480 return Array(a, b, c, d);
30481}
30482
30483/*
30484 * These functions implement the four basic operations the algorithm uses.
30485 */
30486function md5_cmn(q, a, b, x, s, t) {
30487 return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
30488}
30489function md5_ff(a, b, c, d, x, s, t) {
30490 return md5_cmn(b & c | ~b & d, a, b, x, s, t);
30491}
30492function md5_gg(a, b, c, d, x, s, t) {
30493 return md5_cmn(b & d | c & ~d, a, b, x, s, t);
30494}
30495function md5_hh(a, b, c, d, x, s, t) {
30496 return md5_cmn(b ^ c ^ d, a, b, x, s, t);
30497}
30498function md5_ii(a, b, c, d, x, s, t) {
30499 return md5_cmn(c ^ (b | ~d), a, b, x, s, t);
30500}
30501
30502/*
30503 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
30504 * to work around bugs in some JS interpreters.
30505 */
30506function safe_add(x, y) {
30507 var lsw = (x & 0xFFFF) + (y & 0xFFFF);
30508 var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
30509 return msw << 16 | lsw & 0xFFFF;
30510}
30511
30512/*
30513 * Bitwise rotate a 32-bit number to the left.
30514 */
30515function bit_rol(num, cnt) {
30516 return num << cnt | num >>> 32 - cnt;
30517}
30518
30519module.exports = function md5(buf) {
30520 return helpers.hash(buf, core_md5, 16);
30521};
30522
30523},{"./helpers":329}],331:[function(require,module,exports){
30524'use strict';
30525
30526/*
30527 * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
30528 * in FIPS PUB 180-1
30529 * Version 2.1a Copyright Paul Johnston 2000 - 2002.
30530 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
30531 * Distributed under the BSD License
30532 * See http://pajhome.org.uk/crypt/md5 for details.
30533 */
30534
30535var helpers = require('./helpers');
30536
30537/*
30538 * Calculate the SHA-1 of an array of big-endian words, and a bit length
30539 */
30540function core_sha1(x, len) {
30541 /* append padding */
30542 x[len >> 5] |= 0x80 << 24 - len % 32;
30543 x[(len + 64 >> 9 << 4) + 15] = len;
30544
30545 var w = Array(80);
30546 var a = 1732584193;
30547 var b = -271733879;
30548 var c = -1732584194;
30549 var d = 271733878;
30550 var e = -1009589776;
30551
30552 for (var i = 0; i < x.length; i += 16) {
30553 var olda = a;
30554 var oldb = b;
30555 var oldc = c;
30556 var oldd = d;
30557 var olde = e;
30558
30559 for (var j = 0; j < 80; j++) {
30560 if (j < 16) w[j] = x[i + j];else w[j] = rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
30561 var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)), safe_add(safe_add(e, w[j]), sha1_kt(j)));
30562 e = d;
30563 d = c;
30564 c = rol(b, 30);
30565 b = a;
30566 a = t;
30567 }
30568
30569 a = safe_add(a, olda);
30570 b = safe_add(b, oldb);
30571 c = safe_add(c, oldc);
30572 d = safe_add(d, oldd);
30573 e = safe_add(e, olde);
30574 }
30575 return Array(a, b, c, d, e);
30576}
30577
30578/*
30579 * Perform the appropriate triplet combination function for the current
30580 * iteration
30581 */
30582function sha1_ft(t, b, c, d) {
30583 if (t < 20) return b & c | ~b & d;
30584 if (t < 40) return b ^ c ^ d;
30585 if (t < 60) return b & c | b & d | c & d;
30586 return b ^ c ^ d;
30587}
30588
30589/*
30590 * Determine the appropriate additive constant for the current iteration
30591 */
30592function sha1_kt(t) {
30593 return t < 20 ? 1518500249 : t < 40 ? 1859775393 : t < 60 ? -1894007588 : -899497514;
30594}
30595
30596/*
30597 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
30598 * to work around bugs in some JS interpreters.
30599 */
30600function safe_add(x, y) {
30601 var lsw = (x & 0xFFFF) + (y & 0xFFFF);
30602 var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
30603 return msw << 16 | lsw & 0xFFFF;
30604}
30605
30606/*
30607 * Bitwise rotate a 32-bit number to the left.
30608 */
30609function rol(num, cnt) {
30610 return num << cnt | num >>> 32 - cnt;
30611}
30612
30613module.exports = function sha1(buf) {
30614 return helpers.hash(buf, core_sha1, 20, true);
30615};
30616
30617},{"./helpers":329}],332:[function(require,module,exports){
30618(function (global){
30619"use strict";
30620
30621var _create = require("babel-runtime/core-js/object/create");
30622
30623var _create2 = _interopRequireDefault(_create);
30624
30625var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
30626
30627var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
30628
30629var _createClass2 = require("babel-runtime/helpers/createClass");
30630
30631var _createClass3 = _interopRequireDefault(_createClass2);
30632
30633var _typeof2 = require("babel-runtime/helpers/typeof");
30634
30635var _typeof3 = _interopRequireDefault(_typeof2);
30636
30637function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30638
30639(function (f) {
30640 if ((typeof exports === "undefined" ? "undefined" : (0, _typeof3.default)(exports)) === "object" && typeof module !== "undefined") {
30641 module.exports = f();
30642 } else if (typeof define === "function" && define.amd) {
30643 define([], f);
30644 } else {
30645 var g;if (typeof window !== "undefined") {
30646 g = window;
30647 } else if (typeof global !== "undefined") {
30648 g = global;
30649 } else if (typeof self !== "undefined") {
30650 g = self;
30651 } else {
30652 g = this;
30653 }g.mime = f();
30654 }
30655})(function () {
30656 var define, module, exports;return function e(t, n, r) {
30657 function s(o, u) {
30658 if (!n[o]) {
30659 if (!t[o]) {
30660 var a = typeof require == "function" && require;if (!u && a) return a(o, !0);if (i) return i(o, !0);var f = new Error("Cannot find module '" + o + "'");throw f.code = "MODULE_NOT_FOUND", f;
30661 }var l = n[o] = { exports: {} };t[o][0].call(l.exports, function (e) {
30662 var n = t[o][1][e];return s(n ? n : e);
30663 }, l, l.exports, e, t, n, r);
30664 }return n[o].exports;
30665 }var i = typeof require == "function" && require;for (var o = 0; o < r.length; o++) {
30666 s(r[o]);
30667 }return s;
30668 }({ 1: [function (require, module, exports) {
30669 'use strict';
30670
30671 /**
30672 * @param typeMap [Object] Map of MIME type -> Array[extensions]
30673 * @param ...
30674 */
30675
30676 var Mime = function () {
30677 function Mime() {
30678 (0, _classCallCheck3.default)(this, Mime);
30679
30680 this._types = (0, _create2.default)(null);
30681 this._extensions = (0, _create2.default)(null);
30682
30683 for (var i = 0; i < arguments.length; i++) {
30684 this.define(arguments[i]);
30685 }
30686 }
30687
30688 /**
30689 * Define mimetype -> xtension mappings. Each key is a mime-type that maps
30690 * to an array of extensions associated with the type. The first extension is
30691 * used as the default extension for the type.
30692 *
30693 * e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']});
30694 *
30695 * @param map (Object) type definitions
30696 */
30697
30698
30699 (0, _createClass3.default)(Mime, [{
30700 key: "define",
30701 value: function define(typeMap, force) {
30702 for (var type in typeMap) {
30703 var extensions = typeMap[type];
30704 for (var i = 0; i < extensions.length; i++) {
30705 var ext = extensions[i];
30706 if (!force && ext in this._types) {
30707 throw new Error("Attempt to change mapping for \"" + ext + "\" extension from \"" + this._types[ext] + "\" to \"" + type + "\". Pass `force=true` to allow this, otherwise remove \"" + ext + "\" from the list of extensions for \"" + type + "\".");
30708 }
30709
30710 this._types[ext] = type;
30711 }
30712
30713 // Use first extension as default
30714 if (force || !this._extensions[type]) {
30715 this._extensions[type] = extensions[0];
30716 }
30717 }
30718 }
30719
30720 /**
30721 * Lookup a mime type based on extension
30722 */
30723
30724 }, {
30725 key: "getType",
30726 value: function getType(path) {
30727 path = String(path);
30728 var last = path.replace(/^.*[/\\]/, '').toLowerCase();
30729 var ext = last.replace(/^.*\./, '').toLowerCase();
30730
30731 var hasPath = last.length < path.length;
30732 var hasDot = ext.length < last.length - 1;
30733
30734 return (hasDot || !hasPath) && this._types[ext] || null;
30735 }
30736
30737 /**
30738 * Return file extension associated with a mime type
30739 */
30740
30741 }, {
30742 key: "getExtension",
30743 value: function getExtension(type) {
30744 type = /^\s*([^;\s]*)/.test(type) && RegExp.$1;
30745 return type && this._extensions[type.toLowerCase()] || null;
30746 }
30747 }]);
30748 return Mime;
30749 }();
30750
30751 module.exports = Mime;
30752 }, {}], 2: [function (r, module, exports) {
30753 'use strict';
30754
30755 var Mime = r('./Mime');
30756 module.exports = new Mime(r('./types/standard'), r('./types/other'));
30757 }, { "./Mime": 1, "./types/other": 3, "./types/standard": 4 }], 3: [function (require, module, exports) {
30758 module.exports = { "application/prs.cww": ["cww"], "application/vnd.3gpp.pic-bw-large": ["plb"], "application/vnd.3gpp.pic-bw-small": ["psb"], "application/vnd.3gpp.pic-bw-var": ["pvb"], "application/vnd.3gpp2.tcap": ["tcap"], "application/vnd.3m.post-it-notes": ["pwn"], "application/vnd.accpac.simply.aso": ["aso"], "application/vnd.accpac.simply.imp": ["imp"], "application/vnd.acucobol": ["acu"], "application/vnd.acucorp": ["atc", "acutc"], "application/vnd.adobe.air-application-installer-package+zip": ["air"], "application/vnd.adobe.formscentral.fcdt": ["fcdt"], "application/vnd.adobe.fxp": ["fxp", "fxpl"], "application/vnd.adobe.xdp+xml": ["xdp"], "application/vnd.adobe.xfdf": ["xfdf"], "application/vnd.ahead.space": ["ahead"], "application/vnd.airzip.filesecure.azf": ["azf"], "application/vnd.airzip.filesecure.azs": ["azs"], "application/vnd.amazon.ebook": ["azw"], "application/vnd.americandynamics.acc": ["acc"], "application/vnd.amiga.ami": ["ami"], "application/vnd.android.package-archive": ["apk"], "application/vnd.anser-web-certificate-issue-initiation": ["cii"], "application/vnd.anser-web-funds-transfer-initiation": ["fti"], "application/vnd.antix.game-component": ["atx"], "application/vnd.apple.installer+xml": ["mpkg"], "application/vnd.apple.mpegurl": ["m3u8"], "application/vnd.apple.pkpass": ["pkpass"], "application/vnd.aristanetworks.swi": ["swi"], "application/vnd.astraea-software.iota": ["iota"], "application/vnd.audiograph": ["aep"], "application/vnd.blueice.multipass": ["mpm"], "application/vnd.bmi": ["bmi"], "application/vnd.businessobjects": ["rep"], "application/vnd.chemdraw+xml": ["cdxml"], "application/vnd.chipnuts.karaoke-mmd": ["mmd"], "application/vnd.cinderella": ["cdy"], "application/vnd.claymore": ["cla"], "application/vnd.cloanto.rp9": ["rp9"], "application/vnd.clonk.c4group": ["c4g", "c4d", "c4f", "c4p", "c4u"], "application/vnd.cluetrust.cartomobile-config": ["c11amc"], "application/vnd.cluetrust.cartomobile-config-pkg": ["c11amz"], "application/vnd.commonspace": ["csp"], "application/vnd.contact.cmsg": ["cdbcmsg"], "application/vnd.cosmocaller": ["cmc"], "application/vnd.crick.clicker": ["clkx"], "application/vnd.crick.clicker.keyboard": ["clkk"], "application/vnd.crick.clicker.palette": ["clkp"], "application/vnd.crick.clicker.template": ["clkt"], "application/vnd.crick.clicker.wordbank": ["clkw"], "application/vnd.criticaltools.wbs+xml": ["wbs"], "application/vnd.ctc-posml": ["pml"], "application/vnd.cups-ppd": ["ppd"], "application/vnd.curl.car": ["car"], "application/vnd.curl.pcurl": ["pcurl"], "application/vnd.dart": ["dart"], "application/vnd.data-vision.rdz": ["rdz"], "application/vnd.dece.data": ["uvf", "uvvf", "uvd", "uvvd"], "application/vnd.dece.ttml+xml": ["uvt", "uvvt"], "application/vnd.dece.unspecified": ["uvx", "uvvx"], "application/vnd.dece.zip": ["uvz", "uvvz"], "application/vnd.denovo.fcselayout-link": ["fe_launch"], "application/vnd.dna": ["dna"], "application/vnd.dolby.mlp": ["mlp"], "application/vnd.dpgraph": ["dpg"], "application/vnd.dreamfactory": ["dfac"], "application/vnd.ds-keypoint": ["kpxx"], "application/vnd.dvb.ait": ["ait"], "application/vnd.dvb.service": ["svc"], "application/vnd.dynageo": ["geo"], "application/vnd.ecowin.chart": ["mag"], "application/vnd.enliven": ["nml"], "application/vnd.epson.esf": ["esf"], "application/vnd.epson.msf": ["msf"], "application/vnd.epson.quickanime": ["qam"], "application/vnd.epson.salt": ["slt"], "application/vnd.epson.ssf": ["ssf"], "application/vnd.eszigno3+xml": ["es3", "et3"], "application/vnd.ezpix-album": ["ez2"], "application/vnd.ezpix-package": ["ez3"], "application/vnd.fdf": ["fdf"], "application/vnd.fdsn.mseed": ["mseed"], "application/vnd.fdsn.seed": ["seed", "dataless"], "application/vnd.flographit": ["gph"], "application/vnd.fluxtime.clip": ["ftc"], "application/vnd.framemaker": ["fm", "frame", "maker", "book"], "application/vnd.frogans.fnc": ["fnc"], "application/vnd.frogans.ltf": ["ltf"], "application/vnd.fsc.weblaunch": ["fsc"], "application/vnd.fujitsu.oasys": ["oas"], "application/vnd.fujitsu.oasys2": ["oa2"], "application/vnd.fujitsu.oasys3": ["oa3"], "application/vnd.fujitsu.oasysgp": ["fg5"], "application/vnd.fujitsu.oasysprs": ["bh2"], "application/vnd.fujixerox.ddd": ["ddd"], "application/vnd.fujixerox.docuworks": ["xdw"], "application/vnd.fujixerox.docuworks.binder": ["xbd"], "application/vnd.fuzzysheet": ["fzs"], "application/vnd.genomatix.tuxedo": ["txd"], "application/vnd.geogebra.file": ["ggb"], "application/vnd.geogebra.tool": ["ggt"], "application/vnd.geometry-explorer": ["gex", "gre"], "application/vnd.geonext": ["gxt"], "application/vnd.geoplan": ["g2w"], "application/vnd.geospace": ["g3w"], "application/vnd.gmx": ["gmx"], "application/vnd.google-apps.document": ["gdoc"], "application/vnd.google-apps.presentation": ["gslides"], "application/vnd.google-apps.spreadsheet": ["gsheet"], "application/vnd.google-earth.kml+xml": ["kml"], "application/vnd.google-earth.kmz": ["kmz"], "application/vnd.grafeq": ["gqf", "gqs"], "application/vnd.groove-account": ["gac"], "application/vnd.groove-help": ["ghf"], "application/vnd.groove-identity-message": ["gim"], "application/vnd.groove-injector": ["grv"], "application/vnd.groove-tool-message": ["gtm"], "application/vnd.groove-tool-template": ["tpl"], "application/vnd.groove-vcard": ["vcg"], "application/vnd.hal+xml": ["hal"], "application/vnd.handheld-entertainment+xml": ["zmm"], "application/vnd.hbci": ["hbci"], "application/vnd.hhe.lesson-player": ["les"], "application/vnd.hp-hpgl": ["hpgl"], "application/vnd.hp-hpid": ["hpid"], "application/vnd.hp-hps": ["hps"], "application/vnd.hp-jlyt": ["jlt"], "application/vnd.hp-pcl": ["pcl"], "application/vnd.hp-pclxl": ["pclxl"], "application/vnd.hydrostatix.sof-data": ["sfd-hdstx"], "application/vnd.ibm.minipay": ["mpy"], "application/vnd.ibm.modcap": ["afp", "listafp", "list3820"], "application/vnd.ibm.rights-management": ["irm"], "application/vnd.ibm.secure-container": ["sc"], "application/vnd.iccprofile": ["icc", "icm"], "application/vnd.igloader": ["igl"], "application/vnd.immervision-ivp": ["ivp"], "application/vnd.immervision-ivu": ["ivu"], "application/vnd.insors.igm": ["igm"], "application/vnd.intercon.formnet": ["xpw", "xpx"], "application/vnd.intergeo": ["i2g"], "application/vnd.intu.qbo": ["qbo"], "application/vnd.intu.qfx": ["qfx"], "application/vnd.ipunplugged.rcprofile": ["rcprofile"], "application/vnd.irepository.package+xml": ["irp"], "application/vnd.is-xpr": ["xpr"], "application/vnd.isac.fcs": ["fcs"], "application/vnd.jam": ["jam"], "application/vnd.jcp.javame.midlet-rms": ["rms"], "application/vnd.jisp": ["jisp"], "application/vnd.joost.joda-archive": ["joda"], "application/vnd.kahootz": ["ktz", "ktr"], "application/vnd.kde.karbon": ["karbon"], "application/vnd.kde.kchart": ["chrt"], "application/vnd.kde.kformula": ["kfo"], "application/vnd.kde.kivio": ["flw"], "application/vnd.kde.kontour": ["kon"], "application/vnd.kde.kpresenter": ["kpr", "kpt"], "application/vnd.kde.kspread": ["ksp"], "application/vnd.kde.kword": ["kwd", "kwt"], "application/vnd.kenameaapp": ["htke"], "application/vnd.kidspiration": ["kia"], "application/vnd.kinar": ["kne", "knp"], "application/vnd.koan": ["skp", "skd", "skt", "skm"], "application/vnd.kodak-descriptor": ["sse"], "application/vnd.las.las+xml": ["lasxml"], "application/vnd.llamagraphics.life-balance.desktop": ["lbd"], "application/vnd.llamagraphics.life-balance.exchange+xml": ["lbe"], "application/vnd.lotus-1-2-3": ["123"], "application/vnd.lotus-approach": ["apr"], "application/vnd.lotus-freelance": ["pre"], "application/vnd.lotus-notes": ["nsf"], "application/vnd.lotus-organizer": ["org"], "application/vnd.lotus-screencam": ["scm"], "application/vnd.lotus-wordpro": ["lwp"], "application/vnd.macports.portpkg": ["portpkg"], "application/vnd.mcd": ["mcd"], "application/vnd.medcalcdata": ["mc1"], "application/vnd.mediastation.cdkey": ["cdkey"], "application/vnd.mfer": ["mwf"], "application/vnd.mfmp": ["mfm"], "application/vnd.micrografx.flo": ["flo"], "application/vnd.micrografx.igx": ["igx"], "application/vnd.mif": ["mif"], "application/vnd.mobius.daf": ["daf"], "application/vnd.mobius.dis": ["dis"], "application/vnd.mobius.mbk": ["mbk"], "application/vnd.mobius.mqy": ["mqy"], "application/vnd.mobius.msl": ["msl"], "application/vnd.mobius.plc": ["plc"], "application/vnd.mobius.txf": ["txf"], "application/vnd.mophun.application": ["mpn"], "application/vnd.mophun.certificate": ["mpc"], "application/vnd.mozilla.xul+xml": ["xul"], "application/vnd.ms-artgalry": ["cil"], "application/vnd.ms-cab-compressed": ["cab"], "application/vnd.ms-excel": ["xls", "xlm", "xla", "xlc", "xlt", "xlw"], "application/vnd.ms-excel.addin.macroenabled.12": ["xlam"], "application/vnd.ms-excel.sheet.binary.macroenabled.12": ["xlsb"], "application/vnd.ms-excel.sheet.macroenabled.12": ["xlsm"], "application/vnd.ms-excel.template.macroenabled.12": ["xltm"], "application/vnd.ms-fontobject": ["eot"], "application/vnd.ms-htmlhelp": ["chm"], "application/vnd.ms-ims": ["ims"], "application/vnd.ms-lrm": ["lrm"], "application/vnd.ms-officetheme": ["thmx"], "application/vnd.ms-outlook": ["msg"], "application/vnd.ms-pki.seccat": ["cat"], "application/vnd.ms-pki.stl": ["stl"], "application/vnd.ms-powerpoint": ["ppt", "pps", "pot"], "application/vnd.ms-powerpoint.addin.macroenabled.12": ["ppam"], "application/vnd.ms-powerpoint.presentation.macroenabled.12": ["pptm"], "application/vnd.ms-powerpoint.slide.macroenabled.12": ["sldm"], "application/vnd.ms-powerpoint.slideshow.macroenabled.12": ["ppsm"], "application/vnd.ms-powerpoint.template.macroenabled.12": ["potm"], "application/vnd.ms-project": ["mpp", "mpt"], "application/vnd.ms-word.document.macroenabled.12": ["docm"], "application/vnd.ms-word.template.macroenabled.12": ["dotm"], "application/vnd.ms-works": ["wps", "wks", "wcm", "wdb"], "application/vnd.ms-wpl": ["wpl"], "application/vnd.ms-xpsdocument": ["xps"], "application/vnd.mseq": ["mseq"], "application/vnd.musician": ["mus"], "application/vnd.muvee.style": ["msty"], "application/vnd.mynfc": ["taglet"], "application/vnd.neurolanguage.nlu": ["nlu"], "application/vnd.nitf": ["ntf", "nitf"], "application/vnd.noblenet-directory": ["nnd"], "application/vnd.noblenet-sealer": ["nns"], "application/vnd.noblenet-web": ["nnw"], "application/vnd.nokia.n-gage.data": ["ngdat"], "application/vnd.nokia.n-gage.symbian.install": ["n-gage"], "application/vnd.nokia.radio-preset": ["rpst"], "application/vnd.nokia.radio-presets": ["rpss"], "application/vnd.novadigm.edm": ["edm"], "application/vnd.novadigm.edx": ["edx"], "application/vnd.novadigm.ext": ["ext"], "application/vnd.oasis.opendocument.chart": ["odc"], "application/vnd.oasis.opendocument.chart-template": ["otc"], "application/vnd.oasis.opendocument.database": ["odb"], "application/vnd.oasis.opendocument.formula": ["odf"], "application/vnd.oasis.opendocument.formula-template": ["odft"], "application/vnd.oasis.opendocument.graphics": ["odg"], "application/vnd.oasis.opendocument.graphics-template": ["otg"], "application/vnd.oasis.opendocument.image": ["odi"], "application/vnd.oasis.opendocument.image-template": ["oti"], "application/vnd.oasis.opendocument.presentation": ["odp"], "application/vnd.oasis.opendocument.presentation-template": ["otp"], "application/vnd.oasis.opendocument.spreadsheet": ["ods"], "application/vnd.oasis.opendocument.spreadsheet-template": ["ots"], "application/vnd.oasis.opendocument.text": ["odt"], "application/vnd.oasis.opendocument.text-master": ["odm"], "application/vnd.oasis.opendocument.text-template": ["ott"], "application/vnd.oasis.opendocument.text-web": ["oth"], "application/vnd.olpc-sugar": ["xo"], "application/vnd.oma.dd2+xml": ["dd2"], "application/vnd.openofficeorg.extension": ["oxt"], "application/vnd.openxmlformats-officedocument.presentationml.presentation": ["pptx"], "application/vnd.openxmlformats-officedocument.presentationml.slide": ["sldx"], "application/vnd.openxmlformats-officedocument.presentationml.slideshow": ["ppsx"], "application/vnd.openxmlformats-officedocument.presentationml.template": ["potx"], "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": ["xlsx"], "application/vnd.openxmlformats-officedocument.spreadsheetml.template": ["xltx"], "application/vnd.openxmlformats-officedocument.wordprocessingml.document": ["docx"], "application/vnd.openxmlformats-officedocument.wordprocessingml.template": ["dotx"], "application/vnd.osgeo.mapguide.package": ["mgp"], "application/vnd.osgi.dp": ["dp"], "application/vnd.osgi.subsystem": ["esa"], "application/vnd.palm": ["pdb", "pqa", "oprc"], "application/vnd.pawaafile": ["paw"], "application/vnd.pg.format": ["str"], "application/vnd.pg.osasli": ["ei6"], "application/vnd.picsel": ["efif"], "application/vnd.pmi.widget": ["wg"], "application/vnd.pocketlearn": ["plf"], "application/vnd.powerbuilder6": ["pbd"], "application/vnd.previewsystems.box": ["box"], "application/vnd.proteus.magazine": ["mgz"], "application/vnd.publishare-delta-tree": ["qps"], "application/vnd.pvi.ptid1": ["ptid"], "application/vnd.quark.quarkxpress": ["qxd", "qxt", "qwd", "qwt", "qxl", "qxb"], "application/vnd.realvnc.bed": ["bed"], "application/vnd.recordare.musicxml": ["mxl"], "application/vnd.recordare.musicxml+xml": ["musicxml"], "application/vnd.rig.cryptonote": ["cryptonote"], "application/vnd.rim.cod": ["cod"], "application/vnd.rn-realmedia": ["rm"], "application/vnd.rn-realmedia-vbr": ["rmvb"], "application/vnd.route66.link66+xml": ["link66"], "application/vnd.sailingtracker.track": ["st"], "application/vnd.seemail": ["see"], "application/vnd.sema": ["sema"], "application/vnd.semd": ["semd"], "application/vnd.semf": ["semf"], "application/vnd.shana.informed.formdata": ["ifm"], "application/vnd.shana.informed.formtemplate": ["itp"], "application/vnd.shana.informed.interchange": ["iif"], "application/vnd.shana.informed.package": ["ipk"], "application/vnd.simtech-mindmapper": ["twd", "twds"], "application/vnd.smaf": ["mmf"], "application/vnd.smart.teacher": ["teacher"], "application/vnd.solent.sdkm+xml": ["sdkm", "sdkd"], "application/vnd.spotfire.dxp": ["dxp"], "application/vnd.spotfire.sfs": ["sfs"], "application/vnd.stardivision.calc": ["sdc"], "application/vnd.stardivision.draw": ["sda"], "application/vnd.stardivision.impress": ["sdd"], "application/vnd.stardivision.math": ["smf"], "application/vnd.stardivision.writer": ["sdw", "vor"], "application/vnd.stardivision.writer-global": ["sgl"], "application/vnd.stepmania.package": ["smzip"], "application/vnd.stepmania.stepchart": ["sm"], "application/vnd.sun.wadl+xml": ["wadl"], "application/vnd.sun.xml.calc": ["sxc"], "application/vnd.sun.xml.calc.template": ["stc"], "application/vnd.sun.xml.draw": ["sxd"], "application/vnd.sun.xml.draw.template": ["std"], "application/vnd.sun.xml.impress": ["sxi"], "application/vnd.sun.xml.impress.template": ["sti"], "application/vnd.sun.xml.math": ["sxm"], "application/vnd.sun.xml.writer": ["sxw"], "application/vnd.sun.xml.writer.global": ["sxg"], "application/vnd.sun.xml.writer.template": ["stw"], "application/vnd.sus-calendar": ["sus", "susp"], "application/vnd.svd": ["svd"], "application/vnd.symbian.install": ["sis", "sisx"], "application/vnd.syncml+xml": ["xsm"], "application/vnd.syncml.dm+wbxml": ["bdm"], "application/vnd.syncml.dm+xml": ["xdm"], "application/vnd.tao.intent-module-archive": ["tao"], "application/vnd.tcpdump.pcap": ["pcap", "cap", "dmp"], "application/vnd.tmobile-livetv": ["tmo"], "application/vnd.trid.tpt": ["tpt"], "application/vnd.triscape.mxs": ["mxs"], "application/vnd.trueapp": ["tra"], "application/vnd.ufdl": ["ufd", "ufdl"], "application/vnd.uiq.theme": ["utz"], "application/vnd.umajin": ["umj"], "application/vnd.unity": ["unityweb"], "application/vnd.uoml+xml": ["uoml"], "application/vnd.vcx": ["vcx"], "application/vnd.visio": ["vsd", "vst", "vss", "vsw"], "application/vnd.visionary": ["vis"], "application/vnd.vsf": ["vsf"], "application/vnd.wap.wbxml": ["wbxml"], "application/vnd.wap.wmlc": ["wmlc"], "application/vnd.wap.wmlscriptc": ["wmlsc"], "application/vnd.webturbo": ["wtb"], "application/vnd.wolfram.player": ["nbp"], "application/vnd.wordperfect": ["wpd"], "application/vnd.wqd": ["wqd"], "application/vnd.wt.stf": ["stf"], "application/vnd.xara": ["xar"], "application/vnd.xfdl": ["xfdl"], "application/vnd.yamaha.hv-dic": ["hvd"], "application/vnd.yamaha.hv-script": ["hvs"], "application/vnd.yamaha.hv-voice": ["hvp"], "application/vnd.yamaha.openscoreformat": ["osf"], "application/vnd.yamaha.openscoreformat.osfpvg+xml": ["osfpvg"], "application/vnd.yamaha.smaf-audio": ["saf"], "application/vnd.yamaha.smaf-phrase": ["spf"], "application/vnd.yellowriver-custom-menu": ["cmp"], "application/vnd.zul": ["zir", "zirz"], "application/vnd.zzazz.deck+xml": ["zaz"], "application/x-7z-compressed": ["7z"], "application/x-abiword": ["abw"], "application/x-ace-compressed": ["ace"], "application/x-apple-diskimage": [], "application/x-arj": ["arj"], "application/x-authorware-bin": ["aab", "x32", "u32", "vox"], "application/x-authorware-map": ["aam"], "application/x-authorware-seg": ["aas"], "application/x-bcpio": ["bcpio"], "application/x-bdoc": [], "application/x-bittorrent": ["torrent"], "application/x-blorb": ["blb", "blorb"], "application/x-bzip": ["bz"], "application/x-bzip2": ["bz2", "boz"], "application/x-cbr": ["cbr", "cba", "cbt", "cbz", "cb7"], "application/x-cdlink": ["vcd"], "application/x-cfs-compressed": ["cfs"], "application/x-chat": ["chat"], "application/x-chess-pgn": ["pgn"], "application/x-chrome-extension": ["crx"], "application/x-cocoa": ["cco"], "application/x-conference": ["nsc"], "application/x-cpio": ["cpio"], "application/x-csh": ["csh"], "application/x-debian-package": ["udeb"], "application/x-dgc-compressed": ["dgc"], "application/x-director": ["dir", "dcr", "dxr", "cst", "cct", "cxt", "w3d", "fgd", "swa"], "application/x-doom": ["wad"], "application/x-dtbncx+xml": ["ncx"], "application/x-dtbook+xml": ["dtb"], "application/x-dtbresource+xml": ["res"], "application/x-dvi": ["dvi"], "application/x-envoy": ["evy"], "application/x-eva": ["eva"], "application/x-font-bdf": ["bdf"], "application/x-font-ghostscript": ["gsf"], "application/x-font-linux-psf": ["psf"], "application/x-font-otf": [], "application/x-font-pcf": ["pcf"], "application/x-font-snf": ["snf"], "application/x-font-ttf": ["ttf", "ttc"], "application/x-font-type1": ["pfa", "pfb", "pfm", "afm"], "application/x-freearc": ["arc"], "application/x-futuresplash": ["spl"], "application/x-gca-compressed": ["gca"], "application/x-glulx": ["ulx"], "application/x-gnumeric": ["gnumeric"], "application/x-gramps-xml": ["gramps"], "application/x-gtar": ["gtar"], "application/x-hdf": ["hdf"], "application/x-httpd-php": ["php"], "application/x-install-instructions": ["install"], "application/x-iso9660-image": [], "application/x-java-archive-diff": ["jardiff"], "application/x-java-jnlp-file": ["jnlp"], "application/x-latex": ["latex"], "application/x-lua-bytecode": ["luac"], "application/x-lzh-compressed": ["lzh", "lha"], "application/x-makeself": ["run"], "application/x-mie": ["mie"], "application/x-mobipocket-ebook": ["prc", "mobi"], "application/x-ms-application": ["application"], "application/x-ms-shortcut": ["lnk"], "application/x-ms-wmd": ["wmd"], "application/x-ms-wmz": ["wmz"], "application/x-ms-xbap": ["xbap"], "application/x-msaccess": ["mdb"], "application/x-msbinder": ["obd"], "application/x-mscardfile": ["crd"], "application/x-msclip": ["clp"], "application/x-msdos-program": [], "application/x-msdownload": ["com", "bat"], "application/x-msmediaview": ["mvb", "m13", "m14"], "application/x-msmetafile": ["wmf", "emf", "emz"], "application/x-msmoney": ["mny"], "application/x-mspublisher": ["pub"], "application/x-msschedule": ["scd"], "application/x-msterminal": ["trm"], "application/x-mswrite": ["wri"], "application/x-netcdf": ["nc", "cdf"], "application/x-ns-proxy-autoconfig": ["pac"], "application/x-nzb": ["nzb"], "application/x-perl": ["pl", "pm"], "application/x-pilot": [], "application/x-pkcs12": ["p12", "pfx"], "application/x-pkcs7-certificates": ["p7b", "spc"], "application/x-pkcs7-certreqresp": ["p7r"], "application/x-rar-compressed": ["rar"], "application/x-redhat-package-manager": ["rpm"], "application/x-research-info-systems": ["ris"], "application/x-sea": ["sea"], "application/x-sh": ["sh"], "application/x-shar": ["shar"], "application/x-shockwave-flash": ["swf"], "application/x-silverlight-app": ["xap"], "application/x-sql": ["sql"], "application/x-stuffit": ["sit"], "application/x-stuffitx": ["sitx"], "application/x-subrip": ["srt"], "application/x-sv4cpio": ["sv4cpio"], "application/x-sv4crc": ["sv4crc"], "application/x-t3vm-image": ["t3"], "application/x-tads": ["gam"], "application/x-tar": ["tar"], "application/x-tcl": ["tcl", "tk"], "application/x-tex": ["tex"], "application/x-tex-tfm": ["tfm"], "application/x-texinfo": ["texinfo", "texi"], "application/x-tgif": ["obj"], "application/x-ustar": ["ustar"], "application/x-virtualbox-hdd": ["hdd"], "application/x-virtualbox-ova": ["ova"], "application/x-virtualbox-ovf": ["ovf"], "application/x-virtualbox-vbox": ["vbox"], "application/x-virtualbox-vbox-extpack": ["vbox-extpack"], "application/x-virtualbox-vdi": ["vdi"], "application/x-virtualbox-vhd": ["vhd"], "application/x-virtualbox-vmdk": ["vmdk"], "application/x-wais-source": ["src"], "application/x-web-app-manifest+json": ["webapp"], "application/x-x509-ca-cert": ["der", "crt", "pem"], "application/x-xfig": ["fig"], "application/x-xliff+xml": ["xlf"], "application/x-xpinstall": ["xpi"], "application/x-xz": ["xz"], "application/x-zmachine": ["z1", "z2", "z3", "z4", "z5", "z6", "z7", "z8"], "audio/vnd.dece.audio": ["uva", "uvva"], "audio/vnd.digital-winds": ["eol"], "audio/vnd.dra": ["dra"], "audio/vnd.dts": ["dts"], "audio/vnd.dts.hd": ["dtshd"], "audio/vnd.lucent.voice": ["lvp"], "audio/vnd.ms-playready.media.pya": ["pya"], "audio/vnd.nuera.ecelp4800": ["ecelp4800"], "audio/vnd.nuera.ecelp7470": ["ecelp7470"], "audio/vnd.nuera.ecelp9600": ["ecelp9600"], "audio/vnd.rip": ["rip"], "audio/x-aac": ["aac"], "audio/x-aiff": ["aif", "aiff", "aifc"], "audio/x-caf": ["caf"], "audio/x-flac": ["flac"], "audio/x-m4a": [], "audio/x-matroska": ["mka"], "audio/x-mpegurl": ["m3u"], "audio/x-ms-wax": ["wax"], "audio/x-ms-wma": ["wma"], "audio/x-pn-realaudio": ["ram", "ra"], "audio/x-pn-realaudio-plugin": ["rmp"], "audio/x-realaudio": [], "audio/x-wav": [], "chemical/x-cdx": ["cdx"], "chemical/x-cif": ["cif"], "chemical/x-cmdf": ["cmdf"], "chemical/x-cml": ["cml"], "chemical/x-csml": ["csml"], "chemical/x-xyz": ["xyz"], "image/prs.btif": ["btif"], "image/vnd.adobe.photoshop": ["psd"], "image/vnd.dece.graphic": ["uvi", "uvvi", "uvg", "uvvg"], "image/vnd.djvu": ["djvu", "djv"], "image/vnd.dvb.subtitle": [], "image/vnd.dwg": ["dwg"], "image/vnd.dxf": ["dxf"], "image/vnd.fastbidsheet": ["fbs"], "image/vnd.fpx": ["fpx"], "image/vnd.fst": ["fst"], "image/vnd.fujixerox.edmics-mmr": ["mmr"], "image/vnd.fujixerox.edmics-rlc": ["rlc"], "image/vnd.ms-modi": ["mdi"], "image/vnd.ms-photo": ["wdp"], "image/vnd.net-fpx": ["npx"], "image/vnd.wap.wbmp": ["wbmp"], "image/vnd.xiff": ["xif"], "image/x-3ds": ["3ds"], "image/x-cmu-raster": ["ras"], "image/x-cmx": ["cmx"], "image/x-freehand": ["fh", "fhc", "fh4", "fh5", "fh7"], "image/x-icon": ["ico"], "image/x-jng": ["jng"], "image/x-mrsid-image": ["sid"], "image/x-ms-bmp": [], "image/x-pcx": ["pcx"], "image/x-pict": ["pic", "pct"], "image/x-portable-anymap": ["pnm"], "image/x-portable-bitmap": ["pbm"], "image/x-portable-graymap": ["pgm"], "image/x-portable-pixmap": ["ppm"], "image/x-rgb": ["rgb"], "image/x-tga": ["tga"], "image/x-xbitmap": ["xbm"], "image/x-xpixmap": ["xpm"], "image/x-xwindowdump": ["xwd"], "model/vnd.collada+xml": ["dae"], "model/vnd.dwf": ["dwf"], "model/vnd.gdl": ["gdl"], "model/vnd.gtw": ["gtw"], "model/vnd.mts": ["mts"], "model/vnd.vtu": ["vtu"], "text/prs.lines.tag": ["dsc"], "text/vnd.curl": ["curl"], "text/vnd.curl.dcurl": ["dcurl"], "text/vnd.curl.mcurl": ["mcurl"], "text/vnd.curl.scurl": ["scurl"], "text/vnd.dvb.subtitle": ["sub"], "text/vnd.fly": ["fly"], "text/vnd.fmi.flexstor": ["flx"], "text/vnd.graphviz": ["gv"], "text/vnd.in3d.3dml": ["3dml"], "text/vnd.in3d.spot": ["spot"], "text/vnd.sun.j2me.app-descriptor": ["jad"], "text/vnd.wap.wml": ["wml"], "text/vnd.wap.wmlscript": ["wmls"], "text/x-asm": ["s", "asm"], "text/x-c": ["c", "cc", "cxx", "cpp", "h", "hh", "dic"], "text/x-component": ["htc"], "text/x-fortran": ["f", "for", "f77", "f90"], "text/x-handlebars-template": ["hbs"], "text/x-java-source": ["java"], "text/x-lua": ["lua"], "text/x-markdown": ["mkd"], "text/x-nfo": ["nfo"], "text/x-opml": ["opml"], "text/x-org": [], "text/x-pascal": ["p", "pas"], "text/x-processing": ["pde"], "text/x-sass": ["sass"], "text/x-scss": ["scss"], "text/x-setext": ["etx"], "text/x-sfv": ["sfv"], "text/x-suse-ymp": ["ymp"], "text/x-uuencode": ["uu"], "text/x-vcalendar": ["vcs"], "text/x-vcard": ["vcf"], "video/vnd.dece.hd": ["uvh", "uvvh"], "video/vnd.dece.mobile": ["uvm", "uvvm"], "video/vnd.dece.pd": ["uvp", "uvvp"], "video/vnd.dece.sd": ["uvs", "uvvs"], "video/vnd.dece.video": ["uvv", "uvvv"], "video/vnd.dvb.file": ["dvb"], "video/vnd.fvt": ["fvt"], "video/vnd.mpegurl": ["mxu", "m4u"], "video/vnd.ms-playready.media.pyv": ["pyv"], "video/vnd.uvvu.mp4": ["uvu", "uvvu"], "video/vnd.vivo": ["viv"], "video/x-f4v": ["f4v"], "video/x-fli": ["fli"], "video/x-flv": ["flv"], "video/x-m4v": ["m4v"], "video/x-matroska": ["mkv", "mk3d", "mks"], "video/x-mng": ["mng"], "video/x-ms-asf": ["asf", "asx"], "video/x-ms-vob": ["vob"], "video/x-ms-wm": ["wm"], "video/x-ms-wmv": ["wmv"], "video/x-ms-wmx": ["wmx"], "video/x-ms-wvx": ["wvx"], "video/x-msvideo": ["avi"], "video/x-sgi-movie": ["movie"], "video/x-smv": ["smv"], "x-conference/x-cooltalk": ["ice"] };
30759 }, {}], 4: [function (require, module, exports) {
30760 module.exports = { "application/andrew-inset": ["ez"], "application/applixware": ["aw"], "application/atom+xml": ["atom"], "application/atomcat+xml": ["atomcat"], "application/atomsvc+xml": ["atomsvc"], "application/bdoc": ["bdoc"], "application/ccxml+xml": ["ccxml"], "application/cdmi-capability": ["cdmia"], "application/cdmi-container": ["cdmic"], "application/cdmi-domain": ["cdmid"], "application/cdmi-object": ["cdmio"], "application/cdmi-queue": ["cdmiq"], "application/cu-seeme": ["cu"], "application/dash+xml": ["mpd"], "application/davmount+xml": ["davmount"], "application/docbook+xml": ["dbk"], "application/dssc+der": ["dssc"], "application/dssc+xml": ["xdssc"], "application/ecmascript": ["ecma"], "application/emma+xml": ["emma"], "application/epub+zip": ["epub"], "application/exi": ["exi"], "application/font-tdpfr": ["pfr"], "application/font-woff": ["woff"], "application/font-woff2": ["woff2"], "application/geo+json": ["geojson"], "application/gml+xml": ["gml"], "application/gpx+xml": ["gpx"], "application/gxf": ["gxf"], "application/gzip": ["gz"], "application/hyperstudio": ["stk"], "application/inkml+xml": ["ink", "inkml"], "application/ipfix": ["ipfix"], "application/java-archive": ["jar", "war", "ear"], "application/java-serialized-object": ["ser"], "application/java-vm": ["class"], "application/javascript": ["js", "mjs"], "application/json": ["json", "map"], "application/json5": ["json5"], "application/jsonml+json": ["jsonml"], "application/ld+json": ["jsonld"], "application/lost+xml": ["lostxml"], "application/mac-binhex40": ["hqx"], "application/mac-compactpro": ["cpt"], "application/mads+xml": ["mads"], "application/manifest+json": ["webmanifest"], "application/marc": ["mrc"], "application/marcxml+xml": ["mrcx"], "application/mathematica": ["ma", "nb", "mb"], "application/mathml+xml": ["mathml"], "application/mbox": ["mbox"], "application/mediaservercontrol+xml": ["mscml"], "application/metalink+xml": ["metalink"], "application/metalink4+xml": ["meta4"], "application/mets+xml": ["mets"], "application/mods+xml": ["mods"], "application/mp21": ["m21", "mp21"], "application/mp4": ["mp4s", "m4p"], "application/msword": ["doc", "dot"], "application/mxf": ["mxf"], "application/octet-stream": ["bin", "dms", "lrf", "mar", "so", "dist", "distz", "pkg", "bpk", "dump", "elc", "deploy", "exe", "dll", "deb", "dmg", "iso", "img", "msi", "msp", "msm", "buffer"], "application/oda": ["oda"], "application/oebps-package+xml": ["opf"], "application/ogg": ["ogx"], "application/omdoc+xml": ["omdoc"], "application/onenote": ["onetoc", "onetoc2", "onetmp", "onepkg"], "application/oxps": ["oxps"], "application/patch-ops-error+xml": ["xer"], "application/pdf": ["pdf"], "application/pgp-encrypted": ["pgp"], "application/pgp-signature": ["asc", "sig"], "application/pics-rules": ["prf"], "application/pkcs10": ["p10"], "application/pkcs7-mime": ["p7m", "p7c"], "application/pkcs7-signature": ["p7s"], "application/pkcs8": ["p8"], "application/pkix-attr-cert": ["ac"], "application/pkix-cert": ["cer"], "application/pkix-crl": ["crl"], "application/pkix-pkipath": ["pkipath"], "application/pkixcmp": ["pki"], "application/pls+xml": ["pls"], "application/postscript": ["ai", "eps", "ps"], "application/pskc+xml": ["pskcxml"], "application/rdf+xml": ["rdf"], "application/reginfo+xml": ["rif"], "application/relax-ng-compact-syntax": ["rnc"], "application/resource-lists+xml": ["rl"], "application/resource-lists-diff+xml": ["rld"], "application/rls-services+xml": ["rs"], "application/rpki-ghostbusters": ["gbr"], "application/rpki-manifest": ["mft"], "application/rpki-roa": ["roa"], "application/rsd+xml": ["rsd"], "application/rss+xml": ["rss"], "application/rtf": ["rtf"], "application/sbml+xml": ["sbml"], "application/scvp-cv-request": ["scq"], "application/scvp-cv-response": ["scs"], "application/scvp-vp-request": ["spq"], "application/scvp-vp-response": ["spp"], "application/sdp": ["sdp"], "application/set-payment-initiation": ["setpay"], "application/set-registration-initiation": ["setreg"], "application/shf+xml": ["shf"], "application/smil+xml": ["smi", "smil"], "application/sparql-query": ["rq"], "application/sparql-results+xml": ["srx"], "application/srgs": ["gram"], "application/srgs+xml": ["grxml"], "application/sru+xml": ["sru"], "application/ssdl+xml": ["ssdl"], "application/ssml+xml": ["ssml"], "application/tei+xml": ["tei", "teicorpus"], "application/thraud+xml": ["tfi"], "application/timestamped-data": ["tsd"], "application/voicexml+xml": ["vxml"], "application/widget": ["wgt"], "application/winhlp": ["hlp"], "application/wsdl+xml": ["wsdl"], "application/wspolicy+xml": ["wspolicy"], "application/xaml+xml": ["xaml"], "application/xcap-diff+xml": ["xdf"], "application/xenc+xml": ["xenc"], "application/xhtml+xml": ["xhtml", "xht"], "application/xml": ["xml", "xsl", "xsd", "rng"], "application/xml-dtd": ["dtd"], "application/xop+xml": ["xop"], "application/xproc+xml": ["xpl"], "application/xslt+xml": ["xslt"], "application/xspf+xml": ["xspf"], "application/xv+xml": ["mxml", "xhvml", "xvml", "xvm"], "application/yang": ["yang"], "application/yin+xml": ["yin"], "application/zip": ["zip"], "audio/3gpp": [], "audio/adpcm": ["adp"], "audio/basic": ["au", "snd"], "audio/midi": ["mid", "midi", "kar", "rmi"], "audio/mp3": [], "audio/mp4": ["m4a", "mp4a"], "audio/mpeg": ["mpga", "mp2", "mp2a", "mp3", "m2a", "m3a"], "audio/ogg": ["oga", "ogg", "spx"], "audio/s3m": ["s3m"], "audio/silk": ["sil"], "audio/wav": ["wav"], "audio/wave": [], "audio/webm": ["weba"], "audio/xm": ["xm"], "font/otf": ["otf"], "image/apng": ["apng"], "image/bmp": ["bmp"], "image/cgm": ["cgm"], "image/g3fax": ["g3"], "image/gif": ["gif"], "image/ief": ["ief"], "image/jpeg": ["jpeg", "jpg", "jpe"], "image/ktx": ["ktx"], "image/png": ["png"], "image/sgi": ["sgi"], "image/svg+xml": ["svg", "svgz"], "image/tiff": ["tiff", "tif"], "image/webp": ["webp"], "message/rfc822": ["eml", "mime"], "model/gltf+json": ["gltf"], "model/gltf-binary": ["glb"], "model/iges": ["igs", "iges"], "model/mesh": ["msh", "mesh", "silo"], "model/vrml": ["wrl", "vrml"], "model/x3d+binary": ["x3db", "x3dbz"], "model/x3d+vrml": ["x3dv", "x3dvz"], "model/x3d+xml": ["x3d", "x3dz"], "text/cache-manifest": ["appcache", "manifest"], "text/calendar": ["ics", "ifb"], "text/coffeescript": ["coffee", "litcoffee"], "text/css": ["css"], "text/csv": ["csv"], "text/hjson": ["hjson"], "text/html": ["html", "htm", "shtml"], "text/jade": ["jade"], "text/jsx": ["jsx"], "text/less": ["less"], "text/markdown": ["markdown", "md"], "text/mathml": ["mml"], "text/n3": ["n3"], "text/plain": ["txt", "text", "conf", "def", "list", "log", "in", "ini"], "text/richtext": ["rtx"], "text/rtf": [], "text/sgml": ["sgml", "sgm"], "text/slim": ["slim", "slm"], "text/stylus": ["stylus", "styl"], "text/tab-separated-values": ["tsv"], "text/troff": ["t", "tr", "roff", "man", "me", "ms"], "text/turtle": ["ttl"], "text/uri-list": ["uri", "uris", "urls"], "text/vcard": ["vcard"], "text/vtt": ["vtt"], "text/xml": [], "text/yaml": ["yaml", "yml"], "video/3gpp": ["3gp", "3gpp"], "video/3gpp2": ["3g2"], "video/h261": ["h261"], "video/h263": ["h263"], "video/h264": ["h264"], "video/jpeg": ["jpgv"], "video/jpm": ["jpm", "jpgm"], "video/mj2": ["mj2", "mjp2"], "video/mp2t": ["ts"], "video/mp4": ["mp4", "mp4v", "mpg4"], "video/mpeg": ["mpeg", "mpg", "mpe", "m1v", "m2v"], "video/ogg": ["ogv"], "video/quicktime": ["qt", "mov"], "video/webm": ["webm"] };
30761 }, {}] }, {}, [2])(2);
30762});
30763
30764}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
30765},{"babel-runtime/core-js/object/create":50,"babel-runtime/helpers/classCallCheck":62,"babel-runtime/helpers/createClass":63,"babel-runtime/helpers/typeof":64}],333:[function(require,module,exports){
30766'use strict';
30767
30768// copy from https://github.com/node-modules/utility for browser
30769
30770exports.encodeURIComponent = function (text) {
30771 try {
30772 return encodeURIComponent(text);
30773 } catch (e) {
30774 return text;
30775 }
30776};
30777
30778exports.escape = require('escape-html');
30779
30780exports.timestamp = function timestamp(t) {
30781 if (t) {
30782 var v = t;
30783 if (typeof v === 'string') {
30784 v = Number(v);
30785 }
30786 if (String(t).length === 10) {
30787 v *= 1000;
30788 }
30789 return new Date(v);
30790 }
30791 return Math.round(Date.now() / 1000);
30792};
30793
30794},{"escape-html":215}],334:[function(require,module,exports){
30795(function (process,Buffer){
30796'use strict';
30797
30798var _stringify = require('babel-runtime/core-js/json/stringify');
30799
30800var _stringify2 = _interopRequireDefault(_stringify);
30801
30802var _typeof2 = require('babel-runtime/helpers/typeof');
30803
30804var _typeof3 = _interopRequireDefault(_typeof2);
30805
30806function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30807
30808var util = require('util');
30809var urlutil = require('url');
30810var http = require('http');
30811var https = require('https');
30812var debug = require('debug')('urllib');
30813var ms = require('humanize-ms');
30814
30815var _Promise;
30816
30817var REQUEST_ID = 0;
30818var MAX_VALUE = Math.pow(2, 31) - 10;
30819var PROTO_RE = /^https?:\/\//i;
30820
30821function getAgent(agent, defaultAgent) {
30822 return agent === undefined ? defaultAgent : agent;
30823}
30824
30825function makeCallback(resolve, reject) {
30826 return function (err, data, res) {
30827 if (err) {
30828 return reject(err);
30829 }
30830 resolve({
30831 data: data,
30832 status: res.statusCode,
30833 headers: res.headers,
30834 res: res
30835 });
30836 };
30837}
30838
30839// exports.TIMEOUT = ms('5s');
30840exports.TIMEOUTS = [ms('300s'), ms('300s')];
30841
30842var TEXT_DATA_TYPES = ['json', 'text'];
30843
30844exports.request = function request(url, args, callback) {
30845 // request(url, callback)
30846 if (arguments.length === 2 && typeof args === 'function') {
30847 callback = args;
30848 args = null;
30849 }
30850 if (typeof callback === 'function') {
30851 return exports.requestWithCallback(url, args, callback);
30852 }
30853
30854 // Promise
30855 if (!_Promise) {
30856 _Promise = require('any-promise');
30857 }
30858 return new _Promise(function (resolve, reject) {
30859 exports.requestWithCallback(url, args, makeCallback(resolve, reject));
30860 });
30861};
30862
30863exports.requestWithCallback = function requestWithCallback(url, args, callback) {
30864 // requestWithCallback(url, callback)
30865 if (!url || typeof url !== 'string' && (typeof url === 'undefined' ? 'undefined' : (0, _typeof3.default)(url)) !== 'object') {
30866 var msg = util.format('expect request url to be a string or a http request options, but got %j', url);
30867 throw new Error(msg);
30868 }
30869
30870 if (arguments.length === 2 && typeof args === 'function') {
30871 callback = args;
30872 args = null;
30873 }
30874
30875 args = args || {};
30876 if (REQUEST_ID >= MAX_VALUE) {
30877 REQUEST_ID = 0;
30878 }
30879 var reqId = ++REQUEST_ID;
30880
30881 args.requestUrls = args.requestUrls || [];
30882
30883 var reqMeta = {
30884 requestId: reqId,
30885 url: url,
30886 args: args,
30887 ctx: args.ctx
30888 };
30889 if (args.emitter) {
30890 args.emitter.emit('request', reqMeta);
30891 }
30892
30893 args.timeout = args.timeout || exports.TIMEOUTS;
30894 args.maxRedirects = args.maxRedirects || 10;
30895 args.streaming = args.streaming || args.customResponse;
30896 var requestStartTime = Date.now();
30897 var parsedUrl;
30898
30899 if (typeof url === 'string') {
30900 if (!PROTO_RE.test(url)) {
30901 // Support `request('www.server.com')`
30902 url = 'http://' + url;
30903 }
30904 parsedUrl = urlutil.parse(url);
30905 } else {
30906 parsedUrl = url;
30907 }
30908
30909 var method = (args.type || args.method || parsedUrl.method || 'GET').toUpperCase();
30910 var port = parsedUrl.port || 80;
30911 var httplib = http;
30912 var agent = getAgent(args.agent, exports.agent);
30913 var fixJSONCtlChars = args.fixJSONCtlChars;
30914
30915 if (parsedUrl.protocol === 'https:') {
30916 httplib = https;
30917 agent = getAgent(args.httpsAgent, exports.httpsAgent);
30918
30919 if (!parsedUrl.port) {
30920 port = 443;
30921 }
30922 }
30923
30924 // request through proxy tunnel
30925 // var proxyTunnelAgent = detectProxyAgent(parsedUrl, args);
30926 // if (proxyTunnelAgent) {
30927 // agent = proxyTunnelAgent;
30928 // }
30929
30930 var options = {
30931 host: parsedUrl.hostname || parsedUrl.host || 'localhost',
30932 path: parsedUrl.path || '/',
30933 method: method,
30934 port: port,
30935 agent: agent,
30936 headers: args.headers || {},
30937 // default is dns.lookup
30938 // https://github.com/nodejs/node/blob/master/lib/net.js#L986
30939 // custom dnslookup require node >= 4.0.0
30940 // https://github.com/nodejs/node/blob/archived-io.js-v0.12/lib/net.js#L952
30941 lookup: args.lookup
30942 };
30943
30944 if (Array.isArray(args.timeout)) {
30945 options.requestTimeout = args.timeout[args.timeout.length - 1];
30946 } else if (typeof args.timeout !== 'undefined') {
30947 options.requestTimeout = args.timeout;
30948 }
30949
30950 var sslNames = ['pfx', 'key', 'passphrase', 'cert', 'ca', 'ciphers', 'rejectUnauthorized', 'secureProtocol', 'secureOptions'];
30951 for (var i = 0; i < sslNames.length; i++) {
30952 var name = sslNames[i];
30953 if (args.hasOwnProperty(name)) {
30954 options[name] = args[name];
30955 }
30956 }
30957
30958 // don't check ssl
30959 if (options.rejectUnauthorized === false && !options.hasOwnProperty('secureOptions')) {
30960 options.secureOptions = require('constants').SSL_OP_NO_TLSv1_2;
30961 }
30962
30963 var auth = args.auth || parsedUrl.auth;
30964 if (auth) {
30965 options.auth = auth;
30966 }
30967
30968 var body = args.content || args.data;
30969 var dataAsQueryString = method === 'GET' || method === 'HEAD' || args.dataAsQueryString;
30970 if (!args.content) {
30971 if (body && !(typeof body === 'string' || Buffer.isBuffer(body))) {
30972 if (dataAsQueryString) {
30973 // read: GET, HEAD, use query string
30974 body = args.nestedQuerystring ? qs.stringify(body) : querystring.stringify(body);
30975 } else {
30976 var contentType = options.headers['Content-Type'] || options.headers['content-type'];
30977 // auto add application/x-www-form-urlencoded when using urlencode form request
30978 if (!contentType) {
30979 if (args.contentType === 'json') {
30980 contentType = 'application/json';
30981 } else {
30982 contentType = 'application/x-www-form-urlencoded';
30983 }
30984 options.headers['Content-Type'] = contentType;
30985 }
30986
30987 if (parseContentType(contentType).type === 'application/json') {
30988 body = (0, _stringify2.default)(body);
30989 } else {
30990 // 'application/x-www-form-urlencoded'
30991 body = args.nestedQuerystring ? qs.stringify(body) : querystring.stringify(body);
30992 }
30993 }
30994 }
30995 }
30996
30997 // if it's a GET or HEAD request, data should be sent as query string
30998 if (dataAsQueryString && body) {
30999 options.path += (parsedUrl.query ? '&' : '?') + body;
31000 body = null;
31001 }
31002
31003 var requestSize = 0;
31004 if (body) {
31005 var length = body.length;
31006 if (!Buffer.isBuffer(body)) {
31007 length = Buffer.byteLength(body);
31008 }
31009 requestSize = options.headers['Content-Length'] = length;
31010 }
31011
31012 if (args.dataType === 'json') {
31013 options.headers.Accept = 'application/json';
31014 }
31015
31016 if (typeof args.beforeRequest === 'function') {
31017 // you can use this hook to change every thing.
31018 args.beforeRequest(options);
31019 }
31020 var connectTimer = null;
31021 var responseTimer = null;
31022 var __err = null;
31023 var connected = false; // socket connected or not
31024 var keepAliveSocket = false; // request with keepalive socket
31025 var responseSize = 0;
31026 var statusCode = -1;
31027 var responseAborted = false;
31028 var remoteAddress = '';
31029 var remotePort = '';
31030 var timing = null;
31031 if (args.timing) {
31032 timing = {
31033 // socket assigned
31034 queuing: 0,
31035 // dns lookup time
31036 dnslookup: 0,
31037 // socket connected
31038 connected: 0,
31039 // request sent
31040 requestSent: 0,
31041 // Time to first byte (TTFB)
31042 waiting: 0,
31043 contentDownload: 0
31044 };
31045 }
31046
31047 function cancelConnectTimer() {
31048 if (connectTimer) {
31049 clearTimeout(connectTimer);
31050 connectTimer = null;
31051 }
31052 }
31053 function cancelResponseTimer() {
31054 if (responseTimer) {
31055 clearTimeout(responseTimer);
31056 responseTimer = null;
31057 }
31058 }
31059
31060 function done(err, data, res) {
31061 cancelResponseTimer();
31062 if (!callback) {
31063 console.warn('[urllib:warn] [%s] [%s] [worker:%s] %s %s callback twice!!!', Date(), reqId, process.pid, options.method, url);
31064 // https://github.com/node-modules/urllib/pull/30
31065 if (err) {
31066 console.warn('[urllib:warn] [%s] [%s] [worker:%s] %s: %s\nstack: %s', Date(), reqId, process.pid, err.name, err.message, err.stack);
31067 }
31068 return;
31069 }
31070 var cb = callback;
31071 callback = null;
31072 var headers = {};
31073 if (res) {
31074 statusCode = res.statusCode;
31075 headers = res.headers;
31076 }
31077
31078 // handle digest auth
31079 if (statusCode === 401 && headers['www-authenticate'] && (!args.headers || !args.headers.Authorization) && args.digestAuth) {
31080 var authenticate = headers['www-authenticate'];
31081 if (authenticate.indexOf('Digest ') >= 0) {
31082 debug('Request#%d %s: got digest auth header WWW-Authenticate: %s', reqId, url, authenticate);
31083 args.headers = args.headers || {};
31084 args.headers.Authorization = digestAuthHeader(options.method, options.path, authenticate, args.digestAuth);
31085 debug('Request#%d %s: auth with digest header: %s', reqId, url, args.headers.Authorization);
31086 if (res.headers['set-cookie']) {
31087 args.headers.Cookie = res.headers['set-cookie'].join(';');
31088 }
31089 return exports.requestWithCallback(url, args, cb);
31090 }
31091 }
31092
31093 var requestUseTime = Date.now() - requestStartTime;
31094 if (timing) {
31095 timing.contentDownload = requestUseTime;
31096 }
31097
31098 debug('[%sms] done, %s bytes HTTP %s %s %s %s, keepAliveSocket: %s, timing: %j', requestUseTime, responseSize, statusCode, options.method, options.host, options.path, keepAliveSocket, timing);
31099
31100 var response = {
31101 status: statusCode,
31102 statusCode: statusCode,
31103 headers: headers,
31104 size: responseSize,
31105 aborted: responseAborted,
31106 rt: requestUseTime,
31107 keepAliveSocket: keepAliveSocket,
31108 data: data,
31109 requestUrls: args.requestUrls,
31110 timing: timing,
31111 remoteAddress: remoteAddress,
31112 remotePort: remotePort
31113 };
31114
31115 if (err) {
31116 var agentStatus = '';
31117 if (agent && typeof agent.getCurrentStatus === 'function') {
31118 // add current agent status to error message for logging and debug
31119 agentStatus = ', agent status: ' + (0, _stringify2.default)(agent.getCurrentStatus());
31120 }
31121 err.message += ', ' + options.method + ' ' + url + ' ' + statusCode + ' (connected: ' + connected + ', keepalive socket: ' + keepAliveSocket + agentStatus + ')' + '\nheaders: ' + (0, _stringify2.default)(headers);
31122 err.data = data;
31123 err.path = options.path;
31124 err.status = statusCode;
31125 err.headers = headers;
31126 err.res = response;
31127 }
31128
31129 cb(err, data, args.streaming ? res : response);
31130
31131 if (args.emitter) {
31132 // keep to use the same reqMeta object on request event before
31133 reqMeta.url = url;
31134 reqMeta.socket = req && req.connection;
31135 reqMeta.options = options;
31136 reqMeta.size = requestSize;
31137
31138 args.emitter.emit('response', {
31139 requestId: reqId,
31140 error: err,
31141 ctx: args.ctx,
31142 req: reqMeta,
31143 res: response
31144 });
31145 }
31146 }
31147
31148 function handleRedirect(res) {
31149 var err = null;
31150 if (args.followRedirect && statuses.redirect[res.statusCode]) {
31151 // handle redirect
31152 args._followRedirectCount = (args._followRedirectCount || 0) + 1;
31153 var location = res.headers.location;
31154 if (!location) {
31155 err = new Error('Got statusCode ' + res.statusCode + ' but cannot resolve next location from headers');
31156 err.name = 'FollowRedirectError';
31157 } else if (args._followRedirectCount > args.maxRedirects) {
31158 err = new Error('Exceeded maxRedirects. Probably stuck in a redirect loop ' + url);
31159 err.name = 'MaxRedirectError';
31160 } else {
31161 var newUrl = args.formatRedirectUrl ? args.formatRedirectUrl(url, location) : urlutil.resolve(url, location);
31162 debug('Request#%d %s: `redirected` from %s to %s', reqId, options.path, url, newUrl);
31163 // make sure timer stop
31164 cancelResponseTimer();
31165 // should clean up headers.Host on `location: http://other-domain/url`
31166 if (args.headers && args.headers.Host && PROTO_RE.test(location)) {
31167 args.headers.Host = null;
31168 }
31169 // avoid done will be execute in the future change.
31170 var cb = callback;
31171 callback = null;
31172 exports.requestWithCallback(newUrl, args, cb);
31173 return {
31174 redirect: true,
31175 error: null
31176 };
31177 }
31178 }
31179 return {
31180 redirect: false,
31181 error: err
31182 };
31183 }
31184
31185 // set user-agent
31186 if (!options.headers['User-Agent'] && !options.headers['user-agent']) {
31187 options.headers['User-Agent'] = navigator.userAgent;
31188 }
31189
31190 if (args.gzip) {
31191 if (!options.headers['Accept-Encoding'] && !options.headers['accept-encoding']) {
31192 options.headers['Accept-Encoding'] = 'gzip';
31193 }
31194 }
31195
31196 function decodeContent(res, body, cb) {
31197 var encoding = res.headers['content-encoding'];
31198 // if (body.length === 0) {
31199 // return cb(null, body, encoding);
31200 // }
31201
31202 // if (!encoding || encoding.toLowerCase() !== 'gzip') {
31203 return cb(null, body, encoding);
31204 // }
31205
31206 // debug('gunzip %d length body', body.length);
31207 // zlib.gunzip(body, cb);
31208 }
31209
31210 var writeStream = args.writeStream;
31211
31212 debug('Request#%d %s %s with headers %j, options.path: %s', reqId, method, url, options.headers, options.path);
31213
31214 args.requestUrls.push(url);
31215
31216 function onResponse(res) {
31217 if (timing) {
31218 timing.waiting = Date.now() - requestStartTime;
31219 }
31220 debug('Request#%d %s `req response` event emit: status %d, headers: %j', reqId, url, res.statusCode, res.headers);
31221
31222 if (args.streaming) {
31223 var result = handleRedirect(res);
31224 if (result.redirect) {
31225 res.resume();
31226 return;
31227 }
31228 if (result.error) {
31229 res.resume();
31230 return done(result.error, null, res);
31231 }
31232
31233 return done(null, null, res);
31234 }
31235
31236 res.on('close', function () {
31237 debug('Request#%d %s: `res close` event emit, total size %d', reqId, url, responseSize);
31238 });
31239
31240 res.on('error', function () {
31241 debug('Request#%d %s: `res error` event emit, total size %d', reqId, url, responseSize);
31242 });
31243
31244 res.on('aborted', function () {
31245 responseAborted = true;
31246 debug('Request#%d %s: `res aborted` event emit, total size %d', reqId, url, responseSize);
31247 });
31248
31249 if (writeStream) {
31250 // If there's a writable stream to recieve the response data, just pipe the
31251 // response stream to that writable stream and call the callback when it has
31252 // finished writing.
31253 //
31254 // NOTE that when the response stream `res` emits an 'end' event it just
31255 // means that it has finished piping data to another stream. In the
31256 // meanwhile that writable stream may still writing data to the disk until
31257 // it emits a 'close' event.
31258 //
31259 // That means that we should not apply callback until the 'close' of the
31260 // writable stream is emited.
31261 //
31262 // See also:
31263 // - https://github.com/TBEDP/urllib/commit/959ac3365821e0e028c231a5e8efca6af410eabb
31264 // - http://nodejs.org/api/stream.html#stream_event_end
31265 // - http://nodejs.org/api/stream.html#stream_event_close_1
31266 var result = handleRedirect(res);
31267 if (result.redirect) {
31268 res.resume();
31269 return;
31270 }
31271 if (result.error) {
31272 res.resume();
31273 // end ths stream first
31274 writeStream.end();
31275 return done(result.error, null, res);
31276 }
31277 // you can set consumeWriteStream false that only wait response end
31278 if (args.consumeWriteStream === false) {
31279 res.on('end', done.bind(null, null, null, res));
31280 } else {
31281 // node 0.10, 0.12: only emit res aborted, writeStream close not fired
31282 if (isNode010 || isNode012) {
31283 first([[writeStream, 'close'], [res, 'aborted']], function (_, stream, event) {
31284 debug('Request#%d %s: writeStream or res %s event emitted', reqId, url, event);
31285 done(__err || null, null, res);
31286 });
31287 } else {
31288 writeStream.on('close', function () {
31289 debug('Request#%d %s: writeStream close event emitted', reqId, url);
31290 done(__err || null, null, res);
31291 });
31292 }
31293 }
31294 return res.pipe(writeStream);
31295 }
31296
31297 // Otherwise, just concat those buffers.
31298 //
31299 // NOTE that the `chunk` is not a String but a Buffer. It means that if
31300 // you simply concat two chunk with `+` you're actually converting both
31301 // Buffers into Strings before concating them. It'll cause problems when
31302 // dealing with multi-byte characters.
31303 //
31304 // The solution is to store each chunk in an array and concat them with
31305 // 'buffer-concat' when all chunks is recieved.
31306 //
31307 // See also:
31308 // http://cnodejs.org/topic/4faf65852e8fb5bc65113403
31309
31310 var chunks = [];
31311
31312 res.on('data', function (chunk) {
31313 debug('Request#%d %s: `res data` event emit, size %d', reqId, url, chunk.length);
31314 responseSize += chunk.length;
31315 chunks.push(chunk);
31316 });
31317
31318 res.on('end', function () {
31319 var body = Buffer.concat(chunks, responseSize);
31320 debug('Request#%d %s: `res end` event emit, total size %d, _dumped: %s', reqId, url, responseSize, res._dumped);
31321
31322 if (__err) {
31323 // req.abort() after `res data` event emit.
31324 return done(__err, body, res);
31325 }
31326
31327 var result = handleRedirect(res);
31328 if (result.error) {
31329 return done(result.error, body, res);
31330 }
31331 if (result.redirect) {
31332 return;
31333 }
31334
31335 decodeContent(res, body, function (err, data, encoding) {
31336 if (err) {
31337 return done(err, body, res);
31338 }
31339 // if body not decode, dont touch it
31340 if (!encoding && TEXT_DATA_TYPES.indexOf(args.dataType) >= 0) {
31341 // try to decode charset
31342 try {
31343 data = decodeBodyByCharset(data, res);
31344 } catch (e) {
31345 debug('decodeBodyByCharset error: %s', e);
31346 // if error, dont touch it
31347 return done(null, data, res);
31348 }
31349
31350 if (args.dataType === 'json') {
31351 if (responseSize === 0) {
31352 data = null;
31353 } else {
31354 var r = parseJSON(data, fixJSONCtlChars);
31355 if (r.error) {
31356 err = r.error;
31357 } else {
31358 data = r.data;
31359 }
31360 }
31361 }
31362 }
31363
31364 if (responseAborted) {
31365 // err = new Error('Remote socket was terminated before `response.end()` was called');
31366 // err.name = 'RemoteSocketClosedError';
31367 debug('Request#%d %s: Remote socket was terminated before `response.end()` was called', reqId, url);
31368 }
31369
31370 done(err, data, res);
31371 });
31372 });
31373 }
31374
31375 var connectTimeout, responseTimeout;
31376 if (Array.isArray(args.timeout)) {
31377 connectTimeout = ms(args.timeout[0]);
31378 responseTimeout = ms(args.timeout[1]);
31379 } else {
31380 // set both timeout equal
31381 connectTimeout = responseTimeout = ms(args.timeout);
31382 }
31383 debug('ConnectTimeout: %d, ResponseTimeout: %d', connectTimeout, responseTimeout);
31384
31385 function startConnectTimer() {
31386 debug('Connect timer ticking, timeout: %d', connectTimeout);
31387 connectTimer = setTimeout(function () {
31388 connectTimer = null;
31389 if (statusCode === -1) {
31390 statusCode = -2;
31391 }
31392 var msg = 'Connect timeout for ' + connectTimeout + 'ms';
31393 var errorName = 'ConnectionTimeoutError';
31394 if (!req.socket) {
31395 errorName = 'SocketAssignTimeoutError';
31396 msg += ', working sockets is full';
31397 }
31398 __err = new Error(msg);
31399 __err.name = errorName;
31400 __err.requestId = reqId;
31401 debug('ConnectTimeout: Request#%d %s %s: %s, connected: %s', reqId, url, __err.name, msg, connected);
31402 abortRequest();
31403 }, connectTimeout);
31404 }
31405
31406 function startResposneTimer() {
31407 debug('Response timer ticking, timeout: %d', responseTimeout);
31408 responseTimer = setTimeout(function () {
31409 responseTimer = null;
31410 var msg = 'Response timeout for ' + responseTimeout + 'ms';
31411 var errorName = 'ResponseTimeoutError';
31412 __err = new Error(msg);
31413 __err.name = errorName;
31414 __err.requestId = reqId;
31415 debug('ResponseTimeout: Request#%d %s %s: %s, connected: %s', reqId, url, __err.name, msg, connected);
31416 abortRequest();
31417 }, responseTimeout);
31418 }
31419
31420 var req;
31421 // request headers checker will throw error
31422 options.mode = args.mode ? args.mode : '';
31423 try {
31424 req = httplib.request(options, onResponse);
31425 } catch (err) {
31426 return done(err);
31427 }
31428
31429 // environment detection: browser or nodejs
31430 if (typeof window === 'undefined') {
31431 // start connect timer just after `request` return, and just in nodejs environment
31432 startConnectTimer();
31433 } else {
31434 req.on('requestTimeout', function () {
31435 if (statusCode === -1) {
31436 statusCode = -2;
31437 }
31438 var msg = 'Connect timeout for ' + connectTimeout + 'ms';
31439 var errorName = 'ConnectionTimeoutError';
31440 __err = new Error(msg);
31441 __err.name = errorName;
31442 __err.requestId = reqId;
31443 abortRequest();
31444 });
31445 }
31446
31447 function abortRequest() {
31448 debug('Request#%d %s abort, connected: %s', reqId, url, connected);
31449 // it wont case error event when req haven't been assigned a socket yet.
31450 if (!req.socket) {
31451 __err.noSocket = true;
31452 done(__err);
31453 }
31454 req.abort();
31455 }
31456
31457 if (timing) {
31458 // request sent
31459 req.on('finish', function () {
31460 timing.requestSent = Date.now() - requestStartTime;
31461 });
31462 }
31463
31464 req.once('socket', function (socket) {
31465 if (timing) {
31466 // socket queuing time
31467 timing.queuing = Date.now() - requestStartTime;
31468 }
31469
31470 // https://github.com/nodejs/node/blob/master/lib/net.js#L377
31471 // https://github.com/nodejs/node/blob/v0.10.40-release/lib/net.js#L352
31472 // should use socket.socket on 0.10.x
31473 if (isNode010 && socket.socket) {
31474 socket = socket.socket;
31475 }
31476
31477 var readyState = socket.readyState;
31478 if (readyState === 'opening') {
31479 socket.once('lookup', function (err, ip, addressType) {
31480 debug('Request#%d %s lookup: %s, %s, %s', reqId, url, err, ip, addressType);
31481 if (timing) {
31482 timing.dnslookup = Date.now() - requestStartTime;
31483 }
31484 if (ip) {
31485 remoteAddress = ip;
31486 }
31487 });
31488 socket.once('connect', function () {
31489 if (timing) {
31490 // socket connected
31491 timing.connected = Date.now() - requestStartTime;
31492 }
31493
31494 // cancel socket timer at first and start tick for TTFB
31495 cancelConnectTimer();
31496 startResposneTimer();
31497
31498 debug('Request#%d %s new socket connected', reqId, url);
31499 connected = true;
31500 if (!remoteAddress) {
31501 remoteAddress = socket.remoteAddress;
31502 }
31503 remotePort = socket.remotePort;
31504 });
31505 return;
31506 }
31507
31508 debug('Request#%d %s reuse socket connected, readyState: %s', reqId, url, readyState);
31509 connected = true;
31510 keepAliveSocket = true;
31511 if (!remoteAddress) {
31512 remoteAddress = socket.remoteAddress;
31513 }
31514 remotePort = socket.remotePort;
31515
31516 // reuse socket, timer should be canceled.
31517 cancelConnectTimer();
31518 startResposneTimer();
31519 });
31520
31521 req.on('error', function (err) {
31522 //TypeError for browser fetch api, Error for browser xmlhttprequest api
31523 if (err.name === 'Error' || err.name === 'TypeError') {
31524 err.name = connected ? 'ResponseError' : 'RequestError';
31525 }
31526 err.message += ' (req "error")';
31527 debug('Request#%d %s `req error` event emit, %s: %s', reqId, url, err.name, err.message);
31528 done(__err || err);
31529 });
31530
31531 if (writeStream) {
31532 writeStream.once('error', function (err) {
31533 err.message += ' (writeStream "error")';
31534 __err = err;
31535 debug('Request#%d %s `writeStream error` event emit, %s: %s', reqId, url, err.name, err.message);
31536 abortRequest();
31537 });
31538 }
31539
31540 if (args.stream) {
31541 args.stream.pipe(req);
31542 args.stream.once('error', function (err) {
31543 err.message += ' (stream "error")';
31544 __err = err;
31545 debug('Request#%d %s `readStream error` event emit, %s: %s', reqId, url, err.name, err.message);
31546 abortRequest();
31547 });
31548 } else {
31549 req.end(body);
31550 }
31551
31552 req.requestId = reqId;
31553 return req;
31554};
31555
31556}).call(this,require('_process'),require("buffer").Buffer)
31557},{"_process":249,"any-promise":44,"babel-runtime/core-js/json/stringify":48,"babel-runtime/helpers/typeof":64,"buffer":70,"constants":72,"debug":188,"http":272,"https":223,"humanize-ms":224,"url":279,"util":287}]},{},[1])(1)
31558});
31559