UNPKG

1.87 MBJavaScriptView Raw
1(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.neo4j = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2var asn1 = exports;
3
4asn1.bignum = require('bn.js');
5
6asn1.define = require('./asn1/api').define;
7asn1.base = require('./asn1/base');
8asn1.constants = require('./asn1/constants');
9asn1.decoders = require('./asn1/decoders');
10asn1.encoders = require('./asn1/encoders');
11
12},{"./asn1/api":2,"./asn1/base":4,"./asn1/constants":8,"./asn1/decoders":10,"./asn1/encoders":13,"bn.js":43}],2:[function(require,module,exports){
13var asn1 = require('../asn1');
14var inherits = require('inherits');
15
16var api = exports;
17
18api.define = function define(name, body) {
19 return new Entity(name, body);
20};
21
22function Entity(name, body) {
23 this.name = name;
24 this.body = body;
25
26 this.decoders = {};
27 this.encoders = {};
28};
29
30Entity.prototype._createNamed = function createNamed(base) {
31 var named;
32 try {
33 named = require('vm').runInThisContext(
34 '(function ' + this.name + '(entity) {\n' +
35 ' this._initNamed(entity);\n' +
36 '})'
37 );
38 } catch (e) {
39 named = function (entity) {
40 this._initNamed(entity);
41 };
42 }
43 inherits(named, base);
44 named.prototype._initNamed = function initnamed(entity) {
45 base.call(this, entity);
46 };
47
48 return new named(this);
49};
50
51Entity.prototype._getDecoder = function _getDecoder(enc) {
52 enc = enc || 'der';
53 // Lazily create decoder
54 if (!this.decoders.hasOwnProperty(enc))
55 this.decoders[enc] = this._createNamed(asn1.decoders[enc]);
56 return this.decoders[enc];
57};
58
59Entity.prototype.decode = function decode(data, enc, options) {
60 return this._getDecoder(enc).decode(data, options);
61};
62
63Entity.prototype._getEncoder = function _getEncoder(enc) {
64 enc = enc || 'der';
65 // Lazily create encoder
66 if (!this.encoders.hasOwnProperty(enc))
67 this.encoders[enc] = this._createNamed(asn1.encoders[enc]);
68 return this.encoders[enc];
69};
70
71Entity.prototype.encode = function encode(data, enc, /* internal */ reporter) {
72 return this._getEncoder(enc).encode(data, reporter);
73};
74
75},{"../asn1":1,"inherits":260,"vm":318}],3:[function(require,module,exports){
76var inherits = require('inherits');
77var Reporter = require('../base').Reporter;
78var Buffer = require('buffer').Buffer;
79
80function DecoderBuffer(base, options) {
81 Reporter.call(this, options);
82 if (!Buffer.isBuffer(base)) {
83 this.error('Input not Buffer');
84 return;
85 }
86
87 this.base = base;
88 this.offset = 0;
89 this.length = base.length;
90}
91inherits(DecoderBuffer, Reporter);
92exports.DecoderBuffer = DecoderBuffer;
93
94DecoderBuffer.prototype.save = function save() {
95 return { offset: this.offset, reporter: Reporter.prototype.save.call(this) };
96};
97
98DecoderBuffer.prototype.restore = function restore(save) {
99 // Return skipped data
100 var res = new DecoderBuffer(this.base);
101 res.offset = save.offset;
102 res.length = this.offset;
103
104 this.offset = save.offset;
105 Reporter.prototype.restore.call(this, save.reporter);
106
107 return res;
108};
109
110DecoderBuffer.prototype.isEmpty = function isEmpty() {
111 return this.offset === this.length;
112};
113
114DecoderBuffer.prototype.readUInt8 = function readUInt8(fail) {
115 if (this.offset + 1 <= this.length)
116 return this.base.readUInt8(this.offset++, true);
117 else
118 return this.error(fail || 'DecoderBuffer overrun');
119}
120
121DecoderBuffer.prototype.skip = function skip(bytes, fail) {
122 if (!(this.offset + bytes <= this.length))
123 return this.error(fail || 'DecoderBuffer overrun');
124
125 var res = new DecoderBuffer(this.base);
126
127 // Share reporter state
128 res._reporterState = this._reporterState;
129
130 res.offset = this.offset;
131 res.length = this.offset + bytes;
132 this.offset += bytes;
133 return res;
134}
135
136DecoderBuffer.prototype.raw = function raw(save) {
137 return this.base.slice(save ? save.offset : this.offset, this.length);
138}
139
140function EncoderBuffer(value, reporter) {
141 if (Array.isArray(value)) {
142 this.length = 0;
143 this.value = value.map(function(item) {
144 if (!(item instanceof EncoderBuffer))
145 item = new EncoderBuffer(item, reporter);
146 this.length += item.length;
147 return item;
148 }, this);
149 } else if (typeof value === 'number') {
150 if (!(0 <= value && value <= 0xff))
151 return reporter.error('non-byte EncoderBuffer value');
152 this.value = value;
153 this.length = 1;
154 } else if (typeof value === 'string') {
155 this.value = value;
156 this.length = Buffer.byteLength(value);
157 } else if (Buffer.isBuffer(value)) {
158 this.value = value;
159 this.length = value.length;
160 } else {
161 return reporter.error('Unsupported type: ' + typeof value);
162 }
163}
164exports.EncoderBuffer = EncoderBuffer;
165
166EncoderBuffer.prototype.join = function join(out, offset) {
167 if (!out)
168 out = new Buffer(this.length);
169 if (!offset)
170 offset = 0;
171
172 if (this.length === 0)
173 return out;
174
175 if (Array.isArray(this.value)) {
176 this.value.forEach(function(item) {
177 item.join(out, offset);
178 offset += item.length;
179 });
180 } else {
181 if (typeof this.value === 'number')
182 out[offset] = this.value;
183 else if (typeof this.value === 'string')
184 out.write(this.value, offset);
185 else if (Buffer.isBuffer(this.value))
186 this.value.copy(out, offset);
187 offset += this.length;
188 }
189
190 return out;
191};
192
193},{"../base":4,"buffer":75,"inherits":260}],4:[function(require,module,exports){
194var base = exports;
195
196base.Reporter = require('./reporter').Reporter;
197base.DecoderBuffer = require('./buffer').DecoderBuffer;
198base.EncoderBuffer = require('./buffer').EncoderBuffer;
199base.Node = require('./node');
200
201},{"./buffer":3,"./node":5,"./reporter":6}],5:[function(require,module,exports){
202var Reporter = require('../base').Reporter;
203var EncoderBuffer = require('../base').EncoderBuffer;
204var DecoderBuffer = require('../base').DecoderBuffer;
205var assert = require('minimalistic-assert');
206
207// Supported tags
208var tags = [
209 'seq', 'seqof', 'set', 'setof', 'objid', 'bool',
210 'gentime', 'utctime', 'null_', 'enum', 'int', 'objDesc',
211 'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str',
212 'numstr', 'octstr', 'printstr', 't61str', 'unistr', 'utf8str', 'videostr'
213];
214
215// Public methods list
216var methods = [
217 'key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice',
218 'any', 'contains'
219].concat(tags);
220
221// Overrided methods list
222var overrided = [
223 '_peekTag', '_decodeTag', '_use',
224 '_decodeStr', '_decodeObjid', '_decodeTime',
225 '_decodeNull', '_decodeInt', '_decodeBool', '_decodeList',
226
227 '_encodeComposite', '_encodeStr', '_encodeObjid', '_encodeTime',
228 '_encodeNull', '_encodeInt', '_encodeBool'
229];
230
231function Node(enc, parent) {
232 var state = {};
233 this._baseState = state;
234
235 state.enc = enc;
236
237 state.parent = parent || null;
238 state.children = null;
239
240 // State
241 state.tag = null;
242 state.args = null;
243 state.reverseArgs = null;
244 state.choice = null;
245 state.optional = false;
246 state.any = false;
247 state.obj = false;
248 state.use = null;
249 state.useDecoder = null;
250 state.key = null;
251 state['default'] = null;
252 state.explicit = null;
253 state.implicit = null;
254 state.contains = null;
255
256 // Should create new instance on each method
257 if (!state.parent) {
258 state.children = [];
259 this._wrap();
260 }
261}
262module.exports = Node;
263
264var stateProps = [
265 'enc', 'parent', 'children', 'tag', 'args', 'reverseArgs', 'choice',
266 'optional', 'any', 'obj', 'use', 'alteredUse', 'key', 'default', 'explicit',
267 'implicit', 'contains'
268];
269
270Node.prototype.clone = function clone() {
271 var state = this._baseState;
272 var cstate = {};
273 stateProps.forEach(function(prop) {
274 cstate[prop] = state[prop];
275 });
276 var res = new this.constructor(cstate.parent);
277 res._baseState = cstate;
278 return res;
279};
280
281Node.prototype._wrap = function wrap() {
282 var state = this._baseState;
283 methods.forEach(function(method) {
284 this[method] = function _wrappedMethod() {
285 var clone = new this.constructor(this);
286 state.children.push(clone);
287 return clone[method].apply(clone, arguments);
288 };
289 }, this);
290};
291
292Node.prototype._init = function init(body) {
293 var state = this._baseState;
294
295 assert(state.parent === null);
296 body.call(this);
297
298 // Filter children
299 state.children = state.children.filter(function(child) {
300 return child._baseState.parent === this;
301 }, this);
302 assert.equal(state.children.length, 1, 'Root node can have only one child');
303};
304
305Node.prototype._useArgs = function useArgs(args) {
306 var state = this._baseState;
307
308 // Filter children and args
309 var children = args.filter(function(arg) {
310 return arg instanceof this.constructor;
311 }, this);
312 args = args.filter(function(arg) {
313 return !(arg instanceof this.constructor);
314 }, this);
315
316 if (children.length !== 0) {
317 assert(state.children === null);
318 state.children = children;
319
320 // Replace parent to maintain backward link
321 children.forEach(function(child) {
322 child._baseState.parent = this;
323 }, this);
324 }
325 if (args.length !== 0) {
326 assert(state.args === null);
327 state.args = args;
328 state.reverseArgs = args.map(function(arg) {
329 if (typeof arg !== 'object' || arg.constructor !== Object)
330 return arg;
331
332 var res = {};
333 Object.keys(arg).forEach(function(key) {
334 if (key == (key | 0))
335 key |= 0;
336 var value = arg[key];
337 res[value] = key;
338 });
339 return res;
340 });
341 }
342};
343
344//
345// Overrided methods
346//
347
348overrided.forEach(function(method) {
349 Node.prototype[method] = function _overrided() {
350 var state = this._baseState;
351 throw new Error(method + ' not implemented for encoding: ' + state.enc);
352 };
353});
354
355//
356// Public methods
357//
358
359tags.forEach(function(tag) {
360 Node.prototype[tag] = function _tagMethod() {
361 var state = this._baseState;
362 var args = Array.prototype.slice.call(arguments);
363
364 assert(state.tag === null);
365 state.tag = tag;
366
367 this._useArgs(args);
368
369 return this;
370 };
371});
372
373Node.prototype.use = function use(item) {
374 assert(item);
375 var state = this._baseState;
376
377 assert(state.use === null);
378 state.use = item;
379
380 return this;
381};
382
383Node.prototype.optional = function optional() {
384 var state = this._baseState;
385
386 state.optional = true;
387
388 return this;
389};
390
391Node.prototype.def = function def(val) {
392 var state = this._baseState;
393
394 assert(state['default'] === null);
395 state['default'] = val;
396 state.optional = true;
397
398 return this;
399};
400
401Node.prototype.explicit = function explicit(num) {
402 var state = this._baseState;
403
404 assert(state.explicit === null && state.implicit === null);
405 state.explicit = num;
406
407 return this;
408};
409
410Node.prototype.implicit = function implicit(num) {
411 var state = this._baseState;
412
413 assert(state.explicit === null && state.implicit === null);
414 state.implicit = num;
415
416 return this;
417};
418
419Node.prototype.obj = function obj() {
420 var state = this._baseState;
421 var args = Array.prototype.slice.call(arguments);
422
423 state.obj = true;
424
425 if (args.length !== 0)
426 this._useArgs(args);
427
428 return this;
429};
430
431Node.prototype.key = function key(newKey) {
432 var state = this._baseState;
433
434 assert(state.key === null);
435 state.key = newKey;
436
437 return this;
438};
439
440Node.prototype.any = function any() {
441 var state = this._baseState;
442
443 state.any = true;
444
445 return this;
446};
447
448Node.prototype.choice = function choice(obj) {
449 var state = this._baseState;
450
451 assert(state.choice === null);
452 state.choice = obj;
453 this._useArgs(Object.keys(obj).map(function(key) {
454 return obj[key];
455 }));
456
457 return this;
458};
459
460Node.prototype.contains = function contains(item) {
461 var state = this._baseState;
462
463 assert(state.use === null);
464 state.contains = item;
465
466 return this;
467};
468
469//
470// Decoding
471//
472
473Node.prototype._decode = function decode(input, options) {
474 var state = this._baseState;
475
476 // Decode root node
477 if (state.parent === null)
478 return input.wrapResult(state.children[0]._decode(input, options));
479
480 var result = state['default'];
481 var present = true;
482
483 var prevKey = null;
484 if (state.key !== null)
485 prevKey = input.enterKey(state.key);
486
487 // Check if tag is there
488 if (state.optional) {
489 var tag = null;
490 if (state.explicit !== null)
491 tag = state.explicit;
492 else if (state.implicit !== null)
493 tag = state.implicit;
494 else if (state.tag !== null)
495 tag = state.tag;
496
497 if (tag === null && !state.any) {
498 // Trial and Error
499 var save = input.save();
500 try {
501 if (state.choice === null)
502 this._decodeGeneric(state.tag, input, options);
503 else
504 this._decodeChoice(input, options);
505 present = true;
506 } catch (e) {
507 present = false;
508 }
509 input.restore(save);
510 } else {
511 present = this._peekTag(input, tag, state.any);
512
513 if (input.isError(present))
514 return present;
515 }
516 }
517
518 // Push object on stack
519 var prevObj;
520 if (state.obj && present)
521 prevObj = input.enterObject();
522
523 if (present) {
524 // Unwrap explicit values
525 if (state.explicit !== null) {
526 var explicit = this._decodeTag(input, state.explicit);
527 if (input.isError(explicit))
528 return explicit;
529 input = explicit;
530 }
531
532 var start = input.offset;
533
534 // Unwrap implicit and normal values
535 if (state.use === null && state.choice === null) {
536 if (state.any)
537 var save = input.save();
538 var body = this._decodeTag(
539 input,
540 state.implicit !== null ? state.implicit : state.tag,
541 state.any
542 );
543 if (input.isError(body))
544 return body;
545
546 if (state.any)
547 result = input.raw(save);
548 else
549 input = body;
550 }
551
552 if (options && options.track && state.tag !== null)
553 options.track(input.path(), start, input.length, 'tagged');
554
555 if (options && options.track && state.tag !== null)
556 options.track(input.path(), input.offset, input.length, 'content');
557
558 // Select proper method for tag
559 if (state.any)
560 result = result;
561 else if (state.choice === null)
562 result = this._decodeGeneric(state.tag, input, options);
563 else
564 result = this._decodeChoice(input, options);
565
566 if (input.isError(result))
567 return result;
568
569 // Decode children
570 if (!state.any && state.choice === null && state.children !== null) {
571 state.children.forEach(function decodeChildren(child) {
572 // NOTE: We are ignoring errors here, to let parser continue with other
573 // parts of encoded data
574 child._decode(input, options);
575 });
576 }
577
578 // Decode contained/encoded by schema, only in bit or octet strings
579 if (state.contains && (state.tag === 'octstr' || state.tag === 'bitstr')) {
580 var data = new DecoderBuffer(result);
581 result = this._getUse(state.contains, input._reporterState.obj)
582 ._decode(data, options);
583 }
584 }
585
586 // Pop object
587 if (state.obj && present)
588 result = input.leaveObject(prevObj);
589
590 // Set key
591 if (state.key !== null && (result !== null || present === true))
592 input.leaveKey(prevKey, state.key, result);
593 else if (prevKey !== null)
594 input.exitKey(prevKey);
595
596 return result;
597};
598
599Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) {
600 var state = this._baseState;
601
602 if (tag === 'seq' || tag === 'set')
603 return null;
604 if (tag === 'seqof' || tag === 'setof')
605 return this._decodeList(input, tag, state.args[0], options);
606 else if (/str$/.test(tag))
607 return this._decodeStr(input, tag, options);
608 else if (tag === 'objid' && state.args)
609 return this._decodeObjid(input, state.args[0], state.args[1], options);
610 else if (tag === 'objid')
611 return this._decodeObjid(input, null, null, options);
612 else if (tag === 'gentime' || tag === 'utctime')
613 return this._decodeTime(input, tag, options);
614 else if (tag === 'null_')
615 return this._decodeNull(input, options);
616 else if (tag === 'bool')
617 return this._decodeBool(input, options);
618 else if (tag === 'objDesc')
619 return this._decodeStr(input, tag, options);
620 else if (tag === 'int' || tag === 'enum')
621 return this._decodeInt(input, state.args && state.args[0], options);
622
623 if (state.use !== null) {
624 return this._getUse(state.use, input._reporterState.obj)
625 ._decode(input, options);
626 } else {
627 return input.error('unknown tag: ' + tag);
628 }
629};
630
631Node.prototype._getUse = function _getUse(entity, obj) {
632
633 var state = this._baseState;
634 // Create altered use decoder if implicit is set
635 state.useDecoder = this._use(entity, obj);
636 assert(state.useDecoder._baseState.parent === null);
637 state.useDecoder = state.useDecoder._baseState.children[0];
638 if (state.implicit !== state.useDecoder._baseState.implicit) {
639 state.useDecoder = state.useDecoder.clone();
640 state.useDecoder._baseState.implicit = state.implicit;
641 }
642 return state.useDecoder;
643};
644
645Node.prototype._decodeChoice = function decodeChoice(input, options) {
646 var state = this._baseState;
647 var result = null;
648 var match = false;
649
650 Object.keys(state.choice).some(function(key) {
651 var save = input.save();
652 var node = state.choice[key];
653 try {
654 var value = node._decode(input, options);
655 if (input.isError(value))
656 return false;
657
658 result = { type: key, value: value };
659 match = true;
660 } catch (e) {
661 input.restore(save);
662 return false;
663 }
664 return true;
665 }, this);
666
667 if (!match)
668 return input.error('Choice not matched');
669
670 return result;
671};
672
673//
674// Encoding
675//
676
677Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) {
678 return new EncoderBuffer(data, this.reporter);
679};
680
681Node.prototype._encode = function encode(data, reporter, parent) {
682 var state = this._baseState;
683 if (state['default'] !== null && state['default'] === data)
684 return;
685
686 var result = this._encodeValue(data, reporter, parent);
687 if (result === undefined)
688 return;
689
690 if (this._skipDefault(result, reporter, parent))
691 return;
692
693 return result;
694};
695
696Node.prototype._encodeValue = function encode(data, reporter, parent) {
697 var state = this._baseState;
698
699 // Decode root node
700 if (state.parent === null)
701 return state.children[0]._encode(data, reporter || new Reporter());
702
703 var result = null;
704
705 // Set reporter to share it with a child class
706 this.reporter = reporter;
707
708 // Check if data is there
709 if (state.optional && data === undefined) {
710 if (state['default'] !== null)
711 data = state['default']
712 else
713 return;
714 }
715
716 // Encode children first
717 var content = null;
718 var primitive = false;
719 if (state.any) {
720 // Anything that was given is translated to buffer
721 result = this._createEncoderBuffer(data);
722 } else if (state.choice) {
723 result = this._encodeChoice(data, reporter);
724 } else if (state.contains) {
725 content = this._getUse(state.contains, parent)._encode(data, reporter);
726 primitive = true;
727 } else if (state.children) {
728 content = state.children.map(function(child) {
729 if (child._baseState.tag === 'null_')
730 return child._encode(null, reporter, data);
731
732 if (child._baseState.key === null)
733 return reporter.error('Child should have a key');
734 var prevKey = reporter.enterKey(child._baseState.key);
735
736 if (typeof data !== 'object')
737 return reporter.error('Child expected, but input is not object');
738
739 var res = child._encode(data[child._baseState.key], reporter, data);
740 reporter.leaveKey(prevKey);
741
742 return res;
743 }, this).filter(function(child) {
744 return child;
745 });
746 content = this._createEncoderBuffer(content);
747 } else {
748 if (state.tag === 'seqof' || state.tag === 'setof') {
749 // TODO(indutny): this should be thrown on DSL level
750 if (!(state.args && state.args.length === 1))
751 return reporter.error('Too many args for : ' + state.tag);
752
753 if (!Array.isArray(data))
754 return reporter.error('seqof/setof, but data is not Array');
755
756 var child = this.clone();
757 child._baseState.implicit = null;
758 content = this._createEncoderBuffer(data.map(function(item) {
759 var state = this._baseState;
760
761 return this._getUse(state.args[0], data)._encode(item, reporter);
762 }, child));
763 } else if (state.use !== null) {
764 result = this._getUse(state.use, parent)._encode(data, reporter);
765 } else {
766 content = this._encodePrimitive(state.tag, data);
767 primitive = true;
768 }
769 }
770
771 // Encode data itself
772 var result;
773 if (!state.any && state.choice === null) {
774 var tag = state.implicit !== null ? state.implicit : state.tag;
775 var cls = state.implicit === null ? 'universal' : 'context';
776
777 if (tag === null) {
778 if (state.use === null)
779 reporter.error('Tag could be omitted only for .use()');
780 } else {
781 if (state.use === null)
782 result = this._encodeComposite(tag, primitive, cls, content);
783 }
784 }
785
786 // Wrap in explicit
787 if (state.explicit !== null)
788 result = this._encodeComposite(state.explicit, false, 'context', result);
789
790 return result;
791};
792
793Node.prototype._encodeChoice = function encodeChoice(data, reporter) {
794 var state = this._baseState;
795
796 var node = state.choice[data.type];
797 if (!node) {
798 assert(
799 false,
800 data.type + ' not found in ' +
801 JSON.stringify(Object.keys(state.choice)));
802 }
803 return node._encode(data.value, reporter);
804};
805
806Node.prototype._encodePrimitive = function encodePrimitive(tag, data) {
807 var state = this._baseState;
808
809 if (/str$/.test(tag))
810 return this._encodeStr(data, tag);
811 else if (tag === 'objid' && state.args)
812 return this._encodeObjid(data, state.reverseArgs[0], state.args[1]);
813 else if (tag === 'objid')
814 return this._encodeObjid(data, null, null);
815 else if (tag === 'gentime' || tag === 'utctime')
816 return this._encodeTime(data, tag);
817 else if (tag === 'null_')
818 return this._encodeNull();
819 else if (tag === 'int' || tag === 'enum')
820 return this._encodeInt(data, state.args && state.reverseArgs[0]);
821 else if (tag === 'bool')
822 return this._encodeBool(data);
823 else if (tag === 'objDesc')
824 return this._encodeStr(data, tag);
825 else
826 throw new Error('Unsupported tag: ' + tag);
827};
828
829Node.prototype._isNumstr = function isNumstr(str) {
830 return /^[0-9 ]*$/.test(str);
831};
832
833Node.prototype._isPrintstr = function isPrintstr(str) {
834 return /^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(str);
835};
836
837},{"../base":4,"minimalistic-assert":266}],6:[function(require,module,exports){
838var inherits = require('inherits');
839
840function Reporter(options) {
841 this._reporterState = {
842 obj: null,
843 path: [],
844 options: options || {},
845 errors: []
846 };
847}
848exports.Reporter = Reporter;
849
850Reporter.prototype.isError = function isError(obj) {
851 return obj instanceof ReporterError;
852};
853
854Reporter.prototype.save = function save() {
855 var state = this._reporterState;
856
857 return { obj: state.obj, pathLen: state.path.length };
858};
859
860Reporter.prototype.restore = function restore(data) {
861 var state = this._reporterState;
862
863 state.obj = data.obj;
864 state.path = state.path.slice(0, data.pathLen);
865};
866
867Reporter.prototype.enterKey = function enterKey(key) {
868 return this._reporterState.path.push(key);
869};
870
871Reporter.prototype.exitKey = function exitKey(index) {
872 var state = this._reporterState;
873
874 state.path = state.path.slice(0, index - 1);
875};
876
877Reporter.prototype.leaveKey = function leaveKey(index, key, value) {
878 var state = this._reporterState;
879
880 this.exitKey(index);
881 if (state.obj !== null)
882 state.obj[key] = value;
883};
884
885Reporter.prototype.path = function path() {
886 return this._reporterState.path.join('/');
887};
888
889Reporter.prototype.enterObject = function enterObject() {
890 var state = this._reporterState;
891
892 var prev = state.obj;
893 state.obj = {};
894 return prev;
895};
896
897Reporter.prototype.leaveObject = function leaveObject(prev) {
898 var state = this._reporterState;
899
900 var now = state.obj;
901 state.obj = prev;
902 return now;
903};
904
905Reporter.prototype.error = function error(msg) {
906 var err;
907 var state = this._reporterState;
908
909 var inherited = msg instanceof ReporterError;
910 if (inherited) {
911 err = msg;
912 } else {
913 err = new ReporterError(state.path.map(function(elem) {
914 return '[' + JSON.stringify(elem) + ']';
915 }).join(''), msg.message || msg, msg.stack);
916 }
917
918 if (!state.options.partial)
919 throw err;
920
921 if (!inherited)
922 state.errors.push(err);
923
924 return err;
925};
926
927Reporter.prototype.wrapResult = function wrapResult(result) {
928 var state = this._reporterState;
929 if (!state.options.partial)
930 return result;
931
932 return {
933 result: this.isError(result) ? null : result,
934 errors: state.errors
935 };
936};
937
938function ReporterError(path, msg) {
939 this.path = path;
940 this.rethrow(msg);
941};
942inherits(ReporterError, Error);
943
944ReporterError.prototype.rethrow = function rethrow(msg) {
945 this.message = msg + ' at: ' + (this.path || '(shallow)');
946 if (Error.captureStackTrace)
947 Error.captureStackTrace(this, ReporterError);
948
949 if (!this.stack) {
950 try {
951 // IE only adds stack when thrown
952 throw new Error(this.message);
953 } catch (e) {
954 this.stack = e.stack;
955 }
956 }
957 return this;
958};
959
960},{"inherits":260}],7:[function(require,module,exports){
961var constants = require('../constants');
962
963exports.tagClass = {
964 0: 'universal',
965 1: 'application',
966 2: 'context',
967 3: 'private'
968};
969exports.tagClassByName = constants._reverse(exports.tagClass);
970
971exports.tag = {
972 0x00: 'end',
973 0x01: 'bool',
974 0x02: 'int',
975 0x03: 'bitstr',
976 0x04: 'octstr',
977 0x05: 'null_',
978 0x06: 'objid',
979 0x07: 'objDesc',
980 0x08: 'external',
981 0x09: 'real',
982 0x0a: 'enum',
983 0x0b: 'embed',
984 0x0c: 'utf8str',
985 0x0d: 'relativeOid',
986 0x10: 'seq',
987 0x11: 'set',
988 0x12: 'numstr',
989 0x13: 'printstr',
990 0x14: 't61str',
991 0x15: 'videostr',
992 0x16: 'ia5str',
993 0x17: 'utctime',
994 0x18: 'gentime',
995 0x19: 'graphstr',
996 0x1a: 'iso646str',
997 0x1b: 'genstr',
998 0x1c: 'unistr',
999 0x1d: 'charstr',
1000 0x1e: 'bmpstr'
1001};
1002exports.tagByName = constants._reverse(exports.tag);
1003
1004},{"../constants":8}],8:[function(require,module,exports){
1005var constants = exports;
1006
1007// Helper
1008constants._reverse = function reverse(map) {
1009 var res = {};
1010
1011 Object.keys(map).forEach(function(key) {
1012 // Convert key to integer if it is stringified
1013 if ((key | 0) == key)
1014 key = key | 0;
1015
1016 var value = map[key];
1017 res[value] = key;
1018 });
1019
1020 return res;
1021};
1022
1023constants.der = require('./der');
1024
1025},{"./der":7}],9:[function(require,module,exports){
1026var inherits = require('inherits');
1027
1028var asn1 = require('../../asn1');
1029var base = asn1.base;
1030var bignum = asn1.bignum;
1031
1032// Import DER constants
1033var der = asn1.constants.der;
1034
1035function DERDecoder(entity) {
1036 this.enc = 'der';
1037 this.name = entity.name;
1038 this.entity = entity;
1039
1040 // Construct base tree
1041 this.tree = new DERNode();
1042 this.tree._init(entity.body);
1043};
1044module.exports = DERDecoder;
1045
1046DERDecoder.prototype.decode = function decode(data, options) {
1047 if (!(data instanceof base.DecoderBuffer))
1048 data = new base.DecoderBuffer(data, options);
1049
1050 return this.tree._decode(data, options);
1051};
1052
1053// Tree methods
1054
1055function DERNode(parent) {
1056 base.Node.call(this, 'der', parent);
1057}
1058inherits(DERNode, base.Node);
1059
1060DERNode.prototype._peekTag = function peekTag(buffer, tag, any) {
1061 if (buffer.isEmpty())
1062 return false;
1063
1064 var state = buffer.save();
1065 var decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"');
1066 if (buffer.isError(decodedTag))
1067 return decodedTag;
1068
1069 buffer.restore(state);
1070
1071 return decodedTag.tag === tag || decodedTag.tagStr === tag ||
1072 (decodedTag.tagStr + 'of') === tag || any;
1073};
1074
1075DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) {
1076 var decodedTag = derDecodeTag(buffer,
1077 'Failed to decode tag of "' + tag + '"');
1078 if (buffer.isError(decodedTag))
1079 return decodedTag;
1080
1081 var len = derDecodeLen(buffer,
1082 decodedTag.primitive,
1083 'Failed to get length of "' + tag + '"');
1084
1085 // Failure
1086 if (buffer.isError(len))
1087 return len;
1088
1089 if (!any &&
1090 decodedTag.tag !== tag &&
1091 decodedTag.tagStr !== tag &&
1092 decodedTag.tagStr + 'of' !== tag) {
1093 return buffer.error('Failed to match tag: "' + tag + '"');
1094 }
1095
1096 if (decodedTag.primitive || len !== null)
1097 return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
1098
1099 // Indefinite length... find END tag
1100 var state = buffer.save();
1101 var res = this._skipUntilEnd(
1102 buffer,
1103 'Failed to skip indefinite length body: "' + this.tag + '"');
1104 if (buffer.isError(res))
1105 return res;
1106
1107 len = buffer.offset - state.offset;
1108 buffer.restore(state);
1109 return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
1110};
1111
1112DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) {
1113 while (true) {
1114 var tag = derDecodeTag(buffer, fail);
1115 if (buffer.isError(tag))
1116 return tag;
1117 var len = derDecodeLen(buffer, tag.primitive, fail);
1118 if (buffer.isError(len))
1119 return len;
1120
1121 var res;
1122 if (tag.primitive || len !== null)
1123 res = buffer.skip(len)
1124 else
1125 res = this._skipUntilEnd(buffer, fail);
1126
1127 // Failure
1128 if (buffer.isError(res))
1129 return res;
1130
1131 if (tag.tagStr === 'end')
1132 break;
1133 }
1134};
1135
1136DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder,
1137 options) {
1138 var result = [];
1139 while (!buffer.isEmpty()) {
1140 var possibleEnd = this._peekTag(buffer, 'end');
1141 if (buffer.isError(possibleEnd))
1142 return possibleEnd;
1143
1144 var res = decoder.decode(buffer, 'der', options);
1145 if (buffer.isError(res) && possibleEnd)
1146 break;
1147 result.push(res);
1148 }
1149 return result;
1150};
1151
1152DERNode.prototype._decodeStr = function decodeStr(buffer, tag) {
1153 if (tag === 'bitstr') {
1154 var unused = buffer.readUInt8();
1155 if (buffer.isError(unused))
1156 return unused;
1157 return { unused: unused, data: buffer.raw() };
1158 } else if (tag === 'bmpstr') {
1159 var raw = buffer.raw();
1160 if (raw.length % 2 === 1)
1161 return buffer.error('Decoding of string type: bmpstr length mismatch');
1162
1163 var str = '';
1164 for (var i = 0; i < raw.length / 2; i++) {
1165 str += String.fromCharCode(raw.readUInt16BE(i * 2));
1166 }
1167 return str;
1168 } else if (tag === 'numstr') {
1169 var numstr = buffer.raw().toString('ascii');
1170 if (!this._isNumstr(numstr)) {
1171 return buffer.error('Decoding of string type: ' +
1172 'numstr unsupported characters');
1173 }
1174 return numstr;
1175 } else if (tag === 'octstr') {
1176 return buffer.raw();
1177 } else if (tag === 'objDesc') {
1178 return buffer.raw();
1179 } else if (tag === 'printstr') {
1180 var printstr = buffer.raw().toString('ascii');
1181 if (!this._isPrintstr(printstr)) {
1182 return buffer.error('Decoding of string type: ' +
1183 'printstr unsupported characters');
1184 }
1185 return printstr;
1186 } else if (/str$/.test(tag)) {
1187 return buffer.raw().toString();
1188 } else {
1189 return buffer.error('Decoding of string type: ' + tag + ' unsupported');
1190 }
1191};
1192
1193DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) {
1194 var result;
1195 var identifiers = [];
1196 var ident = 0;
1197 while (!buffer.isEmpty()) {
1198 var subident = buffer.readUInt8();
1199 ident <<= 7;
1200 ident |= subident & 0x7f;
1201 if ((subident & 0x80) === 0) {
1202 identifiers.push(ident);
1203 ident = 0;
1204 }
1205 }
1206 if (subident & 0x80)
1207 identifiers.push(ident);
1208
1209 var first = (identifiers[0] / 40) | 0;
1210 var second = identifiers[0] % 40;
1211
1212 if (relative)
1213 result = identifiers;
1214 else
1215 result = [first, second].concat(identifiers.slice(1));
1216
1217 if (values) {
1218 var tmp = values[result.join(' ')];
1219 if (tmp === undefined)
1220 tmp = values[result.join('.')];
1221 if (tmp !== undefined)
1222 result = tmp;
1223 }
1224
1225 return result;
1226};
1227
1228DERNode.prototype._decodeTime = function decodeTime(buffer, tag) {
1229 var str = buffer.raw().toString();
1230 if (tag === 'gentime') {
1231 var year = str.slice(0, 4) | 0;
1232 var mon = str.slice(4, 6) | 0;
1233 var day = str.slice(6, 8) | 0;
1234 var hour = str.slice(8, 10) | 0;
1235 var min = str.slice(10, 12) | 0;
1236 var sec = str.slice(12, 14) | 0;
1237 } else if (tag === 'utctime') {
1238 var year = str.slice(0, 2) | 0;
1239 var mon = str.slice(2, 4) | 0;
1240 var day = str.slice(4, 6) | 0;
1241 var hour = str.slice(6, 8) | 0;
1242 var min = str.slice(8, 10) | 0;
1243 var sec = str.slice(10, 12) | 0;
1244 if (year < 70)
1245 year = 2000 + year;
1246 else
1247 year = 1900 + year;
1248 } else {
1249 return buffer.error('Decoding ' + tag + ' time is not supported yet');
1250 }
1251
1252 return Date.UTC(year, mon - 1, day, hour, min, sec, 0);
1253};
1254
1255DERNode.prototype._decodeNull = function decodeNull(buffer) {
1256 return null;
1257};
1258
1259DERNode.prototype._decodeBool = function decodeBool(buffer) {
1260 var res = buffer.readUInt8();
1261 if (buffer.isError(res))
1262 return res;
1263 else
1264 return res !== 0;
1265};
1266
1267DERNode.prototype._decodeInt = function decodeInt(buffer, values) {
1268 // Bigint, return as it is (assume big endian)
1269 var raw = buffer.raw();
1270 var res = new bignum(raw);
1271
1272 if (values)
1273 res = values[res.toString(10)] || res;
1274
1275 return res;
1276};
1277
1278DERNode.prototype._use = function use(entity, obj) {
1279 if (typeof entity === 'function')
1280 entity = entity(obj);
1281 return entity._getDecoder('der').tree;
1282};
1283
1284// Utility methods
1285
1286function derDecodeTag(buf, fail) {
1287 var tag = buf.readUInt8(fail);
1288 if (buf.isError(tag))
1289 return tag;
1290
1291 var cls = der.tagClass[tag >> 6];
1292 var primitive = (tag & 0x20) === 0;
1293
1294 // Multi-octet tag - load
1295 if ((tag & 0x1f) === 0x1f) {
1296 var oct = tag;
1297 tag = 0;
1298 while ((oct & 0x80) === 0x80) {
1299 oct = buf.readUInt8(fail);
1300 if (buf.isError(oct))
1301 return oct;
1302
1303 tag <<= 7;
1304 tag |= oct & 0x7f;
1305 }
1306 } else {
1307 tag &= 0x1f;
1308 }
1309 var tagStr = der.tag[tag];
1310
1311 return {
1312 cls: cls,
1313 primitive: primitive,
1314 tag: tag,
1315 tagStr: tagStr
1316 };
1317}
1318
1319function derDecodeLen(buf, primitive, fail) {
1320 var len = buf.readUInt8(fail);
1321 if (buf.isError(len))
1322 return len;
1323
1324 // Indefinite form
1325 if (!primitive && len === 0x80)
1326 return null;
1327
1328 // Definite form
1329 if ((len & 0x80) === 0) {
1330 // Short form
1331 return len;
1332 }
1333
1334 // Long form
1335 var num = len & 0x7f;
1336 if (num > 4)
1337 return buf.error('length octect is too long');
1338
1339 len = 0;
1340 for (var i = 0; i < num; i++) {
1341 len <<= 8;
1342 var j = buf.readUInt8(fail);
1343 if (buf.isError(j))
1344 return j;
1345 len |= j;
1346 }
1347
1348 return len;
1349}
1350
1351},{"../../asn1":1,"inherits":260}],10:[function(require,module,exports){
1352var decoders = exports;
1353
1354decoders.der = require('./der');
1355decoders.pem = require('./pem');
1356
1357},{"./der":9,"./pem":11}],11:[function(require,module,exports){
1358var inherits = require('inherits');
1359var Buffer = require('buffer').Buffer;
1360
1361var DERDecoder = require('./der');
1362
1363function PEMDecoder(entity) {
1364 DERDecoder.call(this, entity);
1365 this.enc = 'pem';
1366};
1367inherits(PEMDecoder, DERDecoder);
1368module.exports = PEMDecoder;
1369
1370PEMDecoder.prototype.decode = function decode(data, options) {
1371 var lines = data.toString().split(/[\r\n]+/g);
1372
1373 var label = options.label.toUpperCase();
1374
1375 var re = /^-----(BEGIN|END) ([^-]+)-----$/;
1376 var start = -1;
1377 var end = -1;
1378 for (var i = 0; i < lines.length; i++) {
1379 var match = lines[i].match(re);
1380 if (match === null)
1381 continue;
1382
1383 if (match[2] !== label)
1384 continue;
1385
1386 if (start === -1) {
1387 if (match[1] !== 'BEGIN')
1388 break;
1389 start = i;
1390 } else {
1391 if (match[1] !== 'END')
1392 break;
1393 end = i;
1394 break;
1395 }
1396 }
1397 if (start === -1 || end === -1)
1398 throw new Error('PEM section not found for: ' + label);
1399
1400 var base64 = lines.slice(start + 1, end).join('');
1401 // Remove excessive symbols
1402 base64.replace(/[^a-z0-9\+\/=]+/gi, '');
1403
1404 var input = new Buffer(base64, 'base64');
1405 return DERDecoder.prototype.decode.call(this, input, options);
1406};
1407
1408},{"./der":9,"buffer":75,"inherits":260}],12:[function(require,module,exports){
1409var inherits = require('inherits');
1410var Buffer = require('buffer').Buffer;
1411
1412var asn1 = require('../../asn1');
1413var base = asn1.base;
1414
1415// Import DER constants
1416var der = asn1.constants.der;
1417
1418function DEREncoder(entity) {
1419 this.enc = 'der';
1420 this.name = entity.name;
1421 this.entity = entity;
1422
1423 // Construct base tree
1424 this.tree = new DERNode();
1425 this.tree._init(entity.body);
1426};
1427module.exports = DEREncoder;
1428
1429DEREncoder.prototype.encode = function encode(data, reporter) {
1430 return this.tree._encode(data, reporter).join();
1431};
1432
1433// Tree methods
1434
1435function DERNode(parent) {
1436 base.Node.call(this, 'der', parent);
1437}
1438inherits(DERNode, base.Node);
1439
1440DERNode.prototype._encodeComposite = function encodeComposite(tag,
1441 primitive,
1442 cls,
1443 content) {
1444 var encodedTag = encodeTag(tag, primitive, cls, this.reporter);
1445
1446 // Short form
1447 if (content.length < 0x80) {
1448 var header = new Buffer(2);
1449 header[0] = encodedTag;
1450 header[1] = content.length;
1451 return this._createEncoderBuffer([ header, content ]);
1452 }
1453
1454 // Long form
1455 // Count octets required to store length
1456 var lenOctets = 1;
1457 for (var i = content.length; i >= 0x100; i >>= 8)
1458 lenOctets++;
1459
1460 var header = new Buffer(1 + 1 + lenOctets);
1461 header[0] = encodedTag;
1462 header[1] = 0x80 | lenOctets;
1463
1464 for (var i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8)
1465 header[i] = j & 0xff;
1466
1467 return this._createEncoderBuffer([ header, content ]);
1468};
1469
1470DERNode.prototype._encodeStr = function encodeStr(str, tag) {
1471 if (tag === 'bitstr') {
1472 return this._createEncoderBuffer([ str.unused | 0, str.data ]);
1473 } else if (tag === 'bmpstr') {
1474 var buf = new Buffer(str.length * 2);
1475 for (var i = 0; i < str.length; i++) {
1476 buf.writeUInt16BE(str.charCodeAt(i), i * 2);
1477 }
1478 return this._createEncoderBuffer(buf);
1479 } else if (tag === 'numstr') {
1480 if (!this._isNumstr(str)) {
1481 return this.reporter.error('Encoding of string type: numstr supports ' +
1482 'only digits and space');
1483 }
1484 return this._createEncoderBuffer(str);
1485 } else if (tag === 'printstr') {
1486 if (!this._isPrintstr(str)) {
1487 return this.reporter.error('Encoding of string type: printstr supports ' +
1488 'only latin upper and lower case letters, ' +
1489 'digits, space, apostrophe, left and rigth ' +
1490 'parenthesis, plus sign, comma, hyphen, ' +
1491 'dot, slash, colon, equal sign, ' +
1492 'question mark');
1493 }
1494 return this._createEncoderBuffer(str);
1495 } else if (/str$/.test(tag)) {
1496 return this._createEncoderBuffer(str);
1497 } else if (tag === 'objDesc') {
1498 return this._createEncoderBuffer(str);
1499 } else {
1500 return this.reporter.error('Encoding of string type: ' + tag +
1501 ' unsupported');
1502 }
1503};
1504
1505DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) {
1506 if (typeof id === 'string') {
1507 if (!values)
1508 return this.reporter.error('string objid given, but no values map found');
1509 if (!values.hasOwnProperty(id))
1510 return this.reporter.error('objid not found in values map');
1511 id = values[id].split(/[\s\.]+/g);
1512 for (var i = 0; i < id.length; i++)
1513 id[i] |= 0;
1514 } else if (Array.isArray(id)) {
1515 id = id.slice();
1516 for (var i = 0; i < id.length; i++)
1517 id[i] |= 0;
1518 }
1519
1520 if (!Array.isArray(id)) {
1521 return this.reporter.error('objid() should be either array or string, ' +
1522 'got: ' + JSON.stringify(id));
1523 }
1524
1525 if (!relative) {
1526 if (id[1] >= 40)
1527 return this.reporter.error('Second objid identifier OOB');
1528 id.splice(0, 2, id[0] * 40 + id[1]);
1529 }
1530
1531 // Count number of octets
1532 var size = 0;
1533 for (var i = 0; i < id.length; i++) {
1534 var ident = id[i];
1535 for (size++; ident >= 0x80; ident >>= 7)
1536 size++;
1537 }
1538
1539 var objid = new Buffer(size);
1540 var offset = objid.length - 1;
1541 for (var i = id.length - 1; i >= 0; i--) {
1542 var ident = id[i];
1543 objid[offset--] = ident & 0x7f;
1544 while ((ident >>= 7) > 0)
1545 objid[offset--] = 0x80 | (ident & 0x7f);
1546 }
1547
1548 return this._createEncoderBuffer(objid);
1549};
1550
1551function two(num) {
1552 if (num < 10)
1553 return '0' + num;
1554 else
1555 return num;
1556}
1557
1558DERNode.prototype._encodeTime = function encodeTime(time, tag) {
1559 var str;
1560 var date = new Date(time);
1561
1562 if (tag === 'gentime') {
1563 str = [
1564 two(date.getFullYear()),
1565 two(date.getUTCMonth() + 1),
1566 two(date.getUTCDate()),
1567 two(date.getUTCHours()),
1568 two(date.getUTCMinutes()),
1569 two(date.getUTCSeconds()),
1570 'Z'
1571 ].join('');
1572 } else if (tag === 'utctime') {
1573 str = [
1574 two(date.getFullYear() % 100),
1575 two(date.getUTCMonth() + 1),
1576 two(date.getUTCDate()),
1577 two(date.getUTCHours()),
1578 two(date.getUTCMinutes()),
1579 two(date.getUTCSeconds()),
1580 'Z'
1581 ].join('');
1582 } else {
1583 this.reporter.error('Encoding ' + tag + ' time is not supported yet');
1584 }
1585
1586 return this._encodeStr(str, 'octstr');
1587};
1588
1589DERNode.prototype._encodeNull = function encodeNull() {
1590 return this._createEncoderBuffer('');
1591};
1592
1593DERNode.prototype._encodeInt = function encodeInt(num, values) {
1594 if (typeof num === 'string') {
1595 if (!values)
1596 return this.reporter.error('String int or enum given, but no values map');
1597 if (!values.hasOwnProperty(num)) {
1598 return this.reporter.error('Values map doesn\'t contain: ' +
1599 JSON.stringify(num));
1600 }
1601 num = values[num];
1602 }
1603
1604 // Bignum, assume big endian
1605 if (typeof num !== 'number' && !Buffer.isBuffer(num)) {
1606 var numArray = num.toArray();
1607 if (!num.sign && numArray[0] & 0x80) {
1608 numArray.unshift(0);
1609 }
1610 num = new Buffer(numArray);
1611 }
1612
1613 if (Buffer.isBuffer(num)) {
1614 var size = num.length;
1615 if (num.length === 0)
1616 size++;
1617
1618 var out = new Buffer(size);
1619 num.copy(out);
1620 if (num.length === 0)
1621 out[0] = 0
1622 return this._createEncoderBuffer(out);
1623 }
1624
1625 if (num < 0x80)
1626 return this._createEncoderBuffer(num);
1627
1628 if (num < 0x100)
1629 return this._createEncoderBuffer([0, num]);
1630
1631 var size = 1;
1632 for (var i = num; i >= 0x100; i >>= 8)
1633 size++;
1634
1635 var out = new Array(size);
1636 for (var i = out.length - 1; i >= 0; i--) {
1637 out[i] = num & 0xff;
1638 num >>= 8;
1639 }
1640 if(out[0] & 0x80) {
1641 out.unshift(0);
1642 }
1643
1644 return this._createEncoderBuffer(new Buffer(out));
1645};
1646
1647DERNode.prototype._encodeBool = function encodeBool(value) {
1648 return this._createEncoderBuffer(value ? 0xff : 0);
1649};
1650
1651DERNode.prototype._use = function use(entity, obj) {
1652 if (typeof entity === 'function')
1653 entity = entity(obj);
1654 return entity._getEncoder('der').tree;
1655};
1656
1657DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) {
1658 var state = this._baseState;
1659 var i;
1660 if (state['default'] === null)
1661 return false;
1662
1663 var data = dataBuffer.join();
1664 if (state.defaultBuffer === undefined)
1665 state.defaultBuffer = this._encodeValue(state['default'], reporter, parent).join();
1666
1667 if (data.length !== state.defaultBuffer.length)
1668 return false;
1669
1670 for (i=0; i < data.length; i++)
1671 if (data[i] !== state.defaultBuffer[i])
1672 return false;
1673
1674 return true;
1675};
1676
1677// Utility methods
1678
1679function encodeTag(tag, primitive, cls, reporter) {
1680 var res;
1681
1682 if (tag === 'seqof')
1683 tag = 'seq';
1684 else if (tag === 'setof')
1685 tag = 'set';
1686
1687 if (der.tagByName.hasOwnProperty(tag))
1688 res = der.tagByName[tag];
1689 else if (typeof tag === 'number' && (tag | 0) === tag)
1690 res = tag;
1691 else
1692 return reporter.error('Unknown tag: ' + tag);
1693
1694 if (res >= 0x1f)
1695 return reporter.error('Multi-octet tag encoding unsupported');
1696
1697 if (!primitive)
1698 res |= 0x20;
1699
1700 res |= (der.tagClassByName[cls || 'universal'] << 6);
1701
1702 return res;
1703}
1704
1705},{"../../asn1":1,"buffer":75,"inherits":260}],13:[function(require,module,exports){
1706var encoders = exports;
1707
1708encoders.der = require('./der');
1709encoders.pem = require('./pem');
1710
1711},{"./der":12,"./pem":14}],14:[function(require,module,exports){
1712var inherits = require('inherits');
1713
1714var DEREncoder = require('./der');
1715
1716function PEMEncoder(entity) {
1717 DEREncoder.call(this, entity);
1718 this.enc = 'pem';
1719};
1720inherits(PEMEncoder, DEREncoder);
1721module.exports = PEMEncoder;
1722
1723PEMEncoder.prototype.encode = function encode(data, options) {
1724 var buf = DEREncoder.prototype.encode.call(this, data);
1725
1726 var p = buf.toString('base64');
1727 var out = [ '-----BEGIN ' + options.label + '-----' ];
1728 for (var i = 0; i < p.length; i += 64)
1729 out.push(p.slice(i, i + 64));
1730 out.push('-----END ' + options.label + '-----');
1731 return out.join('\n');
1732};
1733
1734},{"./der":12,"inherits":260}],15:[function(require,module,exports){
1735module.exports = { "default": require("core-js/library/fn/array/from"), __esModule: true };
1736},{"core-js/library/fn/array/from":77}],16:[function(require,module,exports){
1737module.exports = { "default": require("core-js/library/fn/get-iterator"), __esModule: true };
1738},{"core-js/library/fn/get-iterator":78}],17:[function(require,module,exports){
1739module.exports = { "default": require("core-js/library/fn/is-iterable"), __esModule: true };
1740},{"core-js/library/fn/is-iterable":79}],18:[function(require,module,exports){
1741module.exports = { "default": require("core-js/library/fn/json/stringify"), __esModule: true };
1742},{"core-js/library/fn/json/stringify":80}],19:[function(require,module,exports){
1743module.exports = { "default": require("core-js/library/fn/number/is-integer"), __esModule: true };
1744},{"core-js/library/fn/number/is-integer":81}],20:[function(require,module,exports){
1745module.exports = { "default": require("core-js/library/fn/number/max-safe-integer"), __esModule: true };
1746},{"core-js/library/fn/number/max-safe-integer":82}],21:[function(require,module,exports){
1747module.exports = { "default": require("core-js/library/fn/object/assign"), __esModule: true };
1748},{"core-js/library/fn/object/assign":83}],22:[function(require,module,exports){
1749module.exports = { "default": require("core-js/library/fn/object/create"), __esModule: true };
1750},{"core-js/library/fn/object/create":84}],23:[function(require,module,exports){
1751module.exports = { "default": require("core-js/library/fn/object/define-property"), __esModule: true };
1752},{"core-js/library/fn/object/define-property":85}],24:[function(require,module,exports){
1753module.exports = { "default": require("core-js/library/fn/object/freeze"), __esModule: true };
1754},{"core-js/library/fn/object/freeze":86}],25:[function(require,module,exports){
1755module.exports = { "default": require("core-js/library/fn/object/get-own-property-descriptor"), __esModule: true };
1756},{"core-js/library/fn/object/get-own-property-descriptor":87}],26:[function(require,module,exports){
1757module.exports = { "default": require("core-js/library/fn/object/get-prototype-of"), __esModule: true };
1758},{"core-js/library/fn/object/get-prototype-of":88}],27:[function(require,module,exports){
1759module.exports = { "default": require("core-js/library/fn/object/keys"), __esModule: true };
1760},{"core-js/library/fn/object/keys":89}],28:[function(require,module,exports){
1761module.exports = { "default": require("core-js/library/fn/object/set-prototype-of"), __esModule: true };
1762},{"core-js/library/fn/object/set-prototype-of":90}],29:[function(require,module,exports){
1763module.exports = { "default": require("core-js/library/fn/promise"), __esModule: true };
1764},{"core-js/library/fn/promise":91}],30:[function(require,module,exports){
1765module.exports = { "default": require("core-js/library/fn/set"), __esModule: true };
1766},{"core-js/library/fn/set":92}],31:[function(require,module,exports){
1767module.exports = { "default": require("core-js/library/fn/symbol"), __esModule: true };
1768},{"core-js/library/fn/symbol":93}],32:[function(require,module,exports){
1769module.exports = { "default": require("core-js/library/fn/symbol/iterator"), __esModule: true };
1770},{"core-js/library/fn/symbol/iterator":94}],33:[function(require,module,exports){
1771"use strict";
1772
1773exports.__esModule = true;
1774
1775exports.default = function (instance, Constructor) {
1776 if (!(instance instanceof Constructor)) {
1777 throw new TypeError("Cannot call a class as a function");
1778 }
1779};
1780},{}],34:[function(require,module,exports){
1781"use strict";
1782
1783exports.__esModule = true;
1784
1785var _defineProperty = require("../core-js/object/define-property");
1786
1787var _defineProperty2 = _interopRequireDefault(_defineProperty);
1788
1789function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1790
1791exports.default = function () {
1792 function defineProperties(target, props) {
1793 for (var i = 0; i < props.length; i++) {
1794 var descriptor = props[i];
1795 descriptor.enumerable = descriptor.enumerable || false;
1796 descriptor.configurable = true;
1797 if ("value" in descriptor) descriptor.writable = true;
1798 (0, _defineProperty2.default)(target, descriptor.key, descriptor);
1799 }
1800 }
1801
1802 return function (Constructor, protoProps, staticProps) {
1803 if (protoProps) defineProperties(Constructor.prototype, protoProps);
1804 if (staticProps) defineProperties(Constructor, staticProps);
1805 return Constructor;
1806 };
1807}();
1808},{"../core-js/object/define-property":23}],35:[function(require,module,exports){
1809"use strict";
1810
1811exports.__esModule = true;
1812
1813var _defineProperty = require("../core-js/object/define-property");
1814
1815var _defineProperty2 = _interopRequireDefault(_defineProperty);
1816
1817function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1818
1819exports.default = function (obj, key, value) {
1820 if (key in obj) {
1821 (0, _defineProperty2.default)(obj, key, {
1822 value: value,
1823 enumerable: true,
1824 configurable: true,
1825 writable: true
1826 });
1827 } else {
1828 obj[key] = value;
1829 }
1830
1831 return obj;
1832};
1833},{"../core-js/object/define-property":23}],36:[function(require,module,exports){
1834"use strict";
1835
1836exports.__esModule = true;
1837
1838var _getPrototypeOf = require("../core-js/object/get-prototype-of");
1839
1840var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
1841
1842var _getOwnPropertyDescriptor = require("../core-js/object/get-own-property-descriptor");
1843
1844var _getOwnPropertyDescriptor2 = _interopRequireDefault(_getOwnPropertyDescriptor);
1845
1846function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1847
1848exports.default = function get(object, property, receiver) {
1849 if (object === null) object = Function.prototype;
1850 var desc = (0, _getOwnPropertyDescriptor2.default)(object, property);
1851
1852 if (desc === undefined) {
1853 var parent = (0, _getPrototypeOf2.default)(object);
1854
1855 if (parent === null) {
1856 return undefined;
1857 } else {
1858 return get(parent, property, receiver);
1859 }
1860 } else if ("value" in desc) {
1861 return desc.value;
1862 } else {
1863 var getter = desc.get;
1864
1865 if (getter === undefined) {
1866 return undefined;
1867 }
1868
1869 return getter.call(receiver);
1870 }
1871};
1872},{"../core-js/object/get-own-property-descriptor":25,"../core-js/object/get-prototype-of":26}],37:[function(require,module,exports){
1873"use strict";
1874
1875exports.__esModule = true;
1876
1877var _setPrototypeOf = require("../core-js/object/set-prototype-of");
1878
1879var _setPrototypeOf2 = _interopRequireDefault(_setPrototypeOf);
1880
1881var _create = require("../core-js/object/create");
1882
1883var _create2 = _interopRequireDefault(_create);
1884
1885var _typeof2 = require("../helpers/typeof");
1886
1887var _typeof3 = _interopRequireDefault(_typeof2);
1888
1889function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1890
1891exports.default = function (subClass, superClass) {
1892 if (typeof superClass !== "function" && superClass !== null) {
1893 throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : (0, _typeof3.default)(superClass)));
1894 }
1895
1896 subClass.prototype = (0, _create2.default)(superClass && superClass.prototype, {
1897 constructor: {
1898 value: subClass,
1899 enumerable: false,
1900 writable: true,
1901 configurable: true
1902 }
1903 });
1904 if (superClass) _setPrototypeOf2.default ? (0, _setPrototypeOf2.default)(subClass, superClass) : subClass.__proto__ = superClass;
1905};
1906},{"../core-js/object/create":22,"../core-js/object/set-prototype-of":28,"../helpers/typeof":41}],38:[function(require,module,exports){
1907"use strict";
1908
1909exports.__esModule = true;
1910
1911var _typeof2 = require("../helpers/typeof");
1912
1913var _typeof3 = _interopRequireDefault(_typeof2);
1914
1915function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1916
1917exports.default = function (self, call) {
1918 if (!self) {
1919 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1920 }
1921
1922 return call && ((typeof call === "undefined" ? "undefined" : (0, _typeof3.default)(call)) === "object" || typeof call === "function") ? call : self;
1923};
1924},{"../helpers/typeof":41}],39:[function(require,module,exports){
1925"use strict";
1926
1927exports.__esModule = true;
1928
1929var _isIterable2 = require("../core-js/is-iterable");
1930
1931var _isIterable3 = _interopRequireDefault(_isIterable2);
1932
1933var _getIterator2 = require("../core-js/get-iterator");
1934
1935var _getIterator3 = _interopRequireDefault(_getIterator2);
1936
1937function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1938
1939exports.default = function () {
1940 function sliceIterator(arr, i) {
1941 var _arr = [];
1942 var _n = true;
1943 var _d = false;
1944 var _e = undefined;
1945
1946 try {
1947 for (var _i = (0, _getIterator3.default)(arr), _s; !(_n = (_s = _i.next()).done); _n = true) {
1948 _arr.push(_s.value);
1949
1950 if (i && _arr.length === i) break;
1951 }
1952 } catch (err) {
1953 _d = true;
1954 _e = err;
1955 } finally {
1956 try {
1957 if (!_n && _i["return"]) _i["return"]();
1958 } finally {
1959 if (_d) throw _e;
1960 }
1961 }
1962
1963 return _arr;
1964 }
1965
1966 return function (arr, i) {
1967 if (Array.isArray(arr)) {
1968 return arr;
1969 } else if ((0, _isIterable3.default)(Object(arr))) {
1970 return sliceIterator(arr, i);
1971 } else {
1972 throw new TypeError("Invalid attempt to destructure non-iterable instance");
1973 }
1974 };
1975}();
1976},{"../core-js/get-iterator":16,"../core-js/is-iterable":17}],40:[function(require,module,exports){
1977"use strict";
1978
1979exports.__esModule = true;
1980
1981var _from = require("../core-js/array/from");
1982
1983var _from2 = _interopRequireDefault(_from);
1984
1985function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1986
1987exports.default = function (arr) {
1988 if (Array.isArray(arr)) {
1989 for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
1990 arr2[i] = arr[i];
1991 }
1992
1993 return arr2;
1994 } else {
1995 return (0, _from2.default)(arr);
1996 }
1997};
1998},{"../core-js/array/from":15}],41:[function(require,module,exports){
1999"use strict";
2000
2001exports.__esModule = true;
2002
2003var _iterator = require("../core-js/symbol/iterator");
2004
2005var _iterator2 = _interopRequireDefault(_iterator);
2006
2007var _symbol = require("../core-js/symbol");
2008
2009var _symbol2 = _interopRequireDefault(_symbol);
2010
2011var _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; };
2012
2013function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2014
2015exports.default = typeof _symbol2.default === "function" && _typeof(_iterator2.default) === "symbol" ? function (obj) {
2016 return typeof obj === "undefined" ? "undefined" : _typeof(obj);
2017} : function (obj) {
2018 return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof(obj);
2019};
2020},{"../core-js/symbol":31,"../core-js/symbol/iterator":32}],42:[function(require,module,exports){
2021'use strict'
2022
2023exports.byteLength = byteLength
2024exports.toByteArray = toByteArray
2025exports.fromByteArray = fromByteArray
2026
2027var lookup = []
2028var revLookup = []
2029var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
2030
2031var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
2032for (var i = 0, len = code.length; i < len; ++i) {
2033 lookup[i] = code[i]
2034 revLookup[code.charCodeAt(i)] = i
2035}
2036
2037revLookup['-'.charCodeAt(0)] = 62
2038revLookup['_'.charCodeAt(0)] = 63
2039
2040function placeHoldersCount (b64) {
2041 var len = b64.length
2042 if (len % 4 > 0) {
2043 throw new Error('Invalid string. Length must be a multiple of 4')
2044 }
2045
2046 // the number of equal signs (place holders)
2047 // if there are two placeholders, than the two characters before it
2048 // represent one byte
2049 // if there is only one, then the three characters before it represent 2 bytes
2050 // this is just a cheap hack to not do indexOf twice
2051 return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
2052}
2053
2054function byteLength (b64) {
2055 // base64 is 4/3 + up to two characters of the original data
2056 return (b64.length * 3 / 4) - placeHoldersCount(b64)
2057}
2058
2059function toByteArray (b64) {
2060 var i, l, tmp, placeHolders, arr
2061 var len = b64.length
2062 placeHolders = placeHoldersCount(b64)
2063
2064 arr = new Arr((len * 3 / 4) - placeHolders)
2065
2066 // if there are placeholders, only get up to the last complete 4 chars
2067 l = placeHolders > 0 ? len - 4 : len
2068
2069 var L = 0
2070
2071 for (i = 0; i < l; i += 4) {
2072 tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
2073 arr[L++] = (tmp >> 16) & 0xFF
2074 arr[L++] = (tmp >> 8) & 0xFF
2075 arr[L++] = tmp & 0xFF
2076 }
2077
2078 if (placeHolders === 2) {
2079 tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
2080 arr[L++] = tmp & 0xFF
2081 } else if (placeHolders === 1) {
2082 tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
2083 arr[L++] = (tmp >> 8) & 0xFF
2084 arr[L++] = tmp & 0xFF
2085 }
2086
2087 return arr
2088}
2089
2090function tripletToBase64 (num) {
2091 return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
2092}
2093
2094function encodeChunk (uint8, start, end) {
2095 var tmp
2096 var output = []
2097 for (var i = start; i < end; i += 3) {
2098 tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
2099 output.push(tripletToBase64(tmp))
2100 }
2101 return output.join('')
2102}
2103
2104function fromByteArray (uint8) {
2105 var tmp
2106 var len = uint8.length
2107 var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
2108 var output = ''
2109 var parts = []
2110 var maxChunkLength = 16383 // must be multiple of 3
2111
2112 // go through the array every three bytes, we'll deal with trailing stuff later
2113 for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
2114 parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
2115 }
2116
2117 // pad the end with zeros, but make sure to not forget the extra bytes
2118 if (extraBytes === 1) {
2119 tmp = uint8[len - 1]
2120 output += lookup[tmp >> 2]
2121 output += lookup[(tmp << 4) & 0x3F]
2122 output += '=='
2123 } else if (extraBytes === 2) {
2124 tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
2125 output += lookup[tmp >> 10]
2126 output += lookup[(tmp >> 4) & 0x3F]
2127 output += lookup[(tmp << 2) & 0x3F]
2128 output += '='
2129 }
2130
2131 parts.push(output)
2132
2133 return parts.join('')
2134}
2135
2136},{}],43:[function(require,module,exports){
2137(function (module, exports) {
2138 'use strict';
2139
2140 // Utils
2141 function assert (val, msg) {
2142 if (!val) throw new Error(msg || 'Assertion failed');
2143 }
2144
2145 // Could use `inherits` module, but don't want to move from single file
2146 // architecture yet.
2147 function inherits (ctor, superCtor) {
2148 ctor.super_ = superCtor;
2149 var TempCtor = function () {};
2150 TempCtor.prototype = superCtor.prototype;
2151 ctor.prototype = new TempCtor();
2152 ctor.prototype.constructor = ctor;
2153 }
2154
2155 // BN
2156
2157 function BN (number, base, endian) {
2158 if (BN.isBN(number)) {
2159 return number;
2160 }
2161
2162 this.negative = 0;
2163 this.words = null;
2164 this.length = 0;
2165
2166 // Reduction context
2167 this.red = null;
2168
2169 if (number !== null) {
2170 if (base === 'le' || base === 'be') {
2171 endian = base;
2172 base = 10;
2173 }
2174
2175 this._init(number || 0, base || 10, endian || 'be');
2176 }
2177 }
2178 if (typeof module === 'object') {
2179 module.exports = BN;
2180 } else {
2181 exports.BN = BN;
2182 }
2183
2184 BN.BN = BN;
2185 BN.wordSize = 26;
2186
2187 var Buffer;
2188 try {
2189 Buffer = require('buffer').Buffer;
2190 } catch (e) {
2191 }
2192
2193 BN.isBN = function isBN (num) {
2194 if (num instanceof BN) {
2195 return true;
2196 }
2197
2198 return num !== null && typeof num === 'object' &&
2199 num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
2200 };
2201
2202 BN.max = function max (left, right) {
2203 if (left.cmp(right) > 0) return left;
2204 return right;
2205 };
2206
2207 BN.min = function min (left, right) {
2208 if (left.cmp(right) < 0) return left;
2209 return right;
2210 };
2211
2212 BN.prototype._init = function init (number, base, endian) {
2213 if (typeof number === 'number') {
2214 return this._initNumber(number, base, endian);
2215 }
2216
2217 if (typeof number === 'object') {
2218 return this._initArray(number, base, endian);
2219 }
2220
2221 if (base === 'hex') {
2222 base = 16;
2223 }
2224 assert(base === (base | 0) && base >= 2 && base <= 36);
2225
2226 number = number.toString().replace(/\s+/g, '');
2227 var start = 0;
2228 if (number[0] === '-') {
2229 start++;
2230 }
2231
2232 if (base === 16) {
2233 this._parseHex(number, start);
2234 } else {
2235 this._parseBase(number, base, start);
2236 }
2237
2238 if (number[0] === '-') {
2239 this.negative = 1;
2240 }
2241
2242 this.strip();
2243
2244 if (endian !== 'le') return;
2245
2246 this._initArray(this.toArray(), base, endian);
2247 };
2248
2249 BN.prototype._initNumber = function _initNumber (number, base, endian) {
2250 if (number < 0) {
2251 this.negative = 1;
2252 number = -number;
2253 }
2254 if (number < 0x4000000) {
2255 this.words = [ number & 0x3ffffff ];
2256 this.length = 1;
2257 } else if (number < 0x10000000000000) {
2258 this.words = [
2259 number & 0x3ffffff,
2260 (number / 0x4000000) & 0x3ffffff
2261 ];
2262 this.length = 2;
2263 } else {
2264 assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
2265 this.words = [
2266 number & 0x3ffffff,
2267 (number / 0x4000000) & 0x3ffffff,
2268 1
2269 ];
2270 this.length = 3;
2271 }
2272
2273 if (endian !== 'le') return;
2274
2275 // Reverse the bytes
2276 this._initArray(this.toArray(), base, endian);
2277 };
2278
2279 BN.prototype._initArray = function _initArray (number, base, endian) {
2280 // Perhaps a Uint8Array
2281 assert(typeof number.length === 'number');
2282 if (number.length <= 0) {
2283 this.words = [ 0 ];
2284 this.length = 1;
2285 return this;
2286 }
2287
2288 this.length = Math.ceil(number.length / 3);
2289 this.words = new Array(this.length);
2290 for (var i = 0; i < this.length; i++) {
2291 this.words[i] = 0;
2292 }
2293
2294 var j, w;
2295 var off = 0;
2296 if (endian === 'be') {
2297 for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
2298 w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);
2299 this.words[j] |= (w << off) & 0x3ffffff;
2300 this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
2301 off += 24;
2302 if (off >= 26) {
2303 off -= 26;
2304 j++;
2305 }
2306 }
2307 } else if (endian === 'le') {
2308 for (i = 0, j = 0; i < number.length; i += 3) {
2309 w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);
2310 this.words[j] |= (w << off) & 0x3ffffff;
2311 this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
2312 off += 24;
2313 if (off >= 26) {
2314 off -= 26;
2315 j++;
2316 }
2317 }
2318 }
2319 return this.strip();
2320 };
2321
2322 function parseHex (str, start, end) {
2323 var r = 0;
2324 var len = Math.min(str.length, end);
2325 for (var i = start; i < len; i++) {
2326 var c = str.charCodeAt(i) - 48;
2327
2328 r <<= 4;
2329
2330 // 'a' - 'f'
2331 if (c >= 49 && c <= 54) {
2332 r |= c - 49 + 0xa;
2333
2334 // 'A' - 'F'
2335 } else if (c >= 17 && c <= 22) {
2336 r |= c - 17 + 0xa;
2337
2338 // '0' - '9'
2339 } else {
2340 r |= c & 0xf;
2341 }
2342 }
2343 return r;
2344 }
2345
2346 BN.prototype._parseHex = function _parseHex (number, start) {
2347 // Create possibly bigger array to ensure that it fits the number
2348 this.length = Math.ceil((number.length - start) / 6);
2349 this.words = new Array(this.length);
2350 for (var i = 0; i < this.length; i++) {
2351 this.words[i] = 0;
2352 }
2353
2354 var j, w;
2355 // Scan 24-bit chunks and add them to the number
2356 var off = 0;
2357 for (i = number.length - 6, j = 0; i >= start; i -= 6) {
2358 w = parseHex(number, i, i + 6);
2359 this.words[j] |= (w << off) & 0x3ffffff;
2360 // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb
2361 this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
2362 off += 24;
2363 if (off >= 26) {
2364 off -= 26;
2365 j++;
2366 }
2367 }
2368 if (i + 6 !== start) {
2369 w = parseHex(number, start, i + 6);
2370 this.words[j] |= (w << off) & 0x3ffffff;
2371 this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
2372 }
2373 this.strip();
2374 };
2375
2376 function parseBase (str, start, end, mul) {
2377 var r = 0;
2378 var len = Math.min(str.length, end);
2379 for (var i = start; i < len; i++) {
2380 var c = str.charCodeAt(i) - 48;
2381
2382 r *= mul;
2383
2384 // 'a'
2385 if (c >= 49) {
2386 r += c - 49 + 0xa;
2387
2388 // 'A'
2389 } else if (c >= 17) {
2390 r += c - 17 + 0xa;
2391
2392 // '0' - '9'
2393 } else {
2394 r += c;
2395 }
2396 }
2397 return r;
2398 }
2399
2400 BN.prototype._parseBase = function _parseBase (number, base, start) {
2401 // Initialize as zero
2402 this.words = [ 0 ];
2403 this.length = 1;
2404
2405 // Find length of limb in base
2406 for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
2407 limbLen++;
2408 }
2409 limbLen--;
2410 limbPow = (limbPow / base) | 0;
2411
2412 var total = number.length - start;
2413 var mod = total % limbLen;
2414 var end = Math.min(total, total - mod) + start;
2415
2416 var word = 0;
2417 for (var i = start; i < end; i += limbLen) {
2418 word = parseBase(number, i, i + limbLen, base);
2419
2420 this.imuln(limbPow);
2421 if (this.words[0] + word < 0x4000000) {
2422 this.words[0] += word;
2423 } else {
2424 this._iaddn(word);
2425 }
2426 }
2427
2428 if (mod !== 0) {
2429 var pow = 1;
2430 word = parseBase(number, i, number.length, base);
2431
2432 for (i = 0; i < mod; i++) {
2433 pow *= base;
2434 }
2435
2436 this.imuln(pow);
2437 if (this.words[0] + word < 0x4000000) {
2438 this.words[0] += word;
2439 } else {
2440 this._iaddn(word);
2441 }
2442 }
2443 };
2444
2445 BN.prototype.copy = function copy (dest) {
2446 dest.words = new Array(this.length);
2447 for (var i = 0; i < this.length; i++) {
2448 dest.words[i] = this.words[i];
2449 }
2450 dest.length = this.length;
2451 dest.negative = this.negative;
2452 dest.red = this.red;
2453 };
2454
2455 BN.prototype.clone = function clone () {
2456 var r = new BN(null);
2457 this.copy(r);
2458 return r;
2459 };
2460
2461 BN.prototype._expand = function _expand (size) {
2462 while (this.length < size) {
2463 this.words[this.length++] = 0;
2464 }
2465 return this;
2466 };
2467
2468 // Remove leading `0` from `this`
2469 BN.prototype.strip = function strip () {
2470 while (this.length > 1 && this.words[this.length - 1] === 0) {
2471 this.length--;
2472 }
2473 return this._normSign();
2474 };
2475
2476 BN.prototype._normSign = function _normSign () {
2477 // -0 = 0
2478 if (this.length === 1 && this.words[0] === 0) {
2479 this.negative = 0;
2480 }
2481 return this;
2482 };
2483
2484 BN.prototype.inspect = function inspect () {
2485 return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
2486 };
2487
2488 /*
2489
2490 var zeros = [];
2491 var groupSizes = [];
2492 var groupBases = [];
2493
2494 var s = '';
2495 var i = -1;
2496 while (++i < BN.wordSize) {
2497 zeros[i] = s;
2498 s += '0';
2499 }
2500 groupSizes[0] = 0;
2501 groupSizes[1] = 0;
2502 groupBases[0] = 0;
2503 groupBases[1] = 0;
2504 var base = 2 - 1;
2505 while (++base < 36 + 1) {
2506 var groupSize = 0;
2507 var groupBase = 1;
2508 while (groupBase < (1 << BN.wordSize) / base) {
2509 groupBase *= base;
2510 groupSize += 1;
2511 }
2512 groupSizes[base] = groupSize;
2513 groupBases[base] = groupBase;
2514 }
2515
2516 */
2517
2518 var zeros = [
2519 '',
2520 '0',
2521 '00',
2522 '000',
2523 '0000',
2524 '00000',
2525 '000000',
2526 '0000000',
2527 '00000000',
2528 '000000000',
2529 '0000000000',
2530 '00000000000',
2531 '000000000000',
2532 '0000000000000',
2533 '00000000000000',
2534 '000000000000000',
2535 '0000000000000000',
2536 '00000000000000000',
2537 '000000000000000000',
2538 '0000000000000000000',
2539 '00000000000000000000',
2540 '000000000000000000000',
2541 '0000000000000000000000',
2542 '00000000000000000000000',
2543 '000000000000000000000000',
2544 '0000000000000000000000000'
2545 ];
2546
2547 var groupSizes = [
2548 0, 0,
2549 25, 16, 12, 11, 10, 9, 8,
2550 8, 7, 7, 7, 7, 6, 6,
2551 6, 6, 6, 6, 6, 5, 5,
2552 5, 5, 5, 5, 5, 5, 5,
2553 5, 5, 5, 5, 5, 5, 5
2554 ];
2555
2556 var groupBases = [
2557 0, 0,
2558 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,
2559 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,
2560 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,
2561 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,
2562 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176
2563 ];
2564
2565 BN.prototype.toString = function toString (base, padding) {
2566 base = base || 10;
2567 padding = padding | 0 || 1;
2568
2569 var out;
2570 if (base === 16 || base === 'hex') {
2571 out = '';
2572 var off = 0;
2573 var carry = 0;
2574 for (var i = 0; i < this.length; i++) {
2575 var w = this.words[i];
2576 var word = (((w << off) | carry) & 0xffffff).toString(16);
2577 carry = (w >>> (24 - off)) & 0xffffff;
2578 if (carry !== 0 || i !== this.length - 1) {
2579 out = zeros[6 - word.length] + word + out;
2580 } else {
2581 out = word + out;
2582 }
2583 off += 2;
2584 if (off >= 26) {
2585 off -= 26;
2586 i--;
2587 }
2588 }
2589 if (carry !== 0) {
2590 out = carry.toString(16) + out;
2591 }
2592 while (out.length % padding !== 0) {
2593 out = '0' + out;
2594 }
2595 if (this.negative !== 0) {
2596 out = '-' + out;
2597 }
2598 return out;
2599 }
2600
2601 if (base === (base | 0) && base >= 2 && base <= 36) {
2602 // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
2603 var groupSize = groupSizes[base];
2604 // var groupBase = Math.pow(base, groupSize);
2605 var groupBase = groupBases[base];
2606 out = '';
2607 var c = this.clone();
2608 c.negative = 0;
2609 while (!c.isZero()) {
2610 var r = c.modn(groupBase).toString(base);
2611 c = c.idivn(groupBase);
2612
2613 if (!c.isZero()) {
2614 out = zeros[groupSize - r.length] + r + out;
2615 } else {
2616 out = r + out;
2617 }
2618 }
2619 if (this.isZero()) {
2620 out = '0' + out;
2621 }
2622 while (out.length % padding !== 0) {
2623 out = '0' + out;
2624 }
2625 if (this.negative !== 0) {
2626 out = '-' + out;
2627 }
2628 return out;
2629 }
2630
2631 assert(false, 'Base should be between 2 and 36');
2632 };
2633
2634 BN.prototype.toNumber = function toNumber () {
2635 var ret = this.words[0];
2636 if (this.length === 2) {
2637 ret += this.words[1] * 0x4000000;
2638 } else if (this.length === 3 && this.words[2] === 0x01) {
2639 // NOTE: at this stage it is known that the top bit is set
2640 ret += 0x10000000000000 + (this.words[1] * 0x4000000);
2641 } else if (this.length > 2) {
2642 assert(false, 'Number can only safely store up to 53 bits');
2643 }
2644 return (this.negative !== 0) ? -ret : ret;
2645 };
2646
2647 BN.prototype.toJSON = function toJSON () {
2648 return this.toString(16);
2649 };
2650
2651 BN.prototype.toBuffer = function toBuffer (endian, length) {
2652 assert(typeof Buffer !== 'undefined');
2653 return this.toArrayLike(Buffer, endian, length);
2654 };
2655
2656 BN.prototype.toArray = function toArray (endian, length) {
2657 return this.toArrayLike(Array, endian, length);
2658 };
2659
2660 BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {
2661 var byteLength = this.byteLength();
2662 var reqLength = length || Math.max(1, byteLength);
2663 assert(byteLength <= reqLength, 'byte array longer than desired length');
2664 assert(reqLength > 0, 'Requested array length <= 0');
2665
2666 this.strip();
2667 var littleEndian = endian === 'le';
2668 var res = new ArrayType(reqLength);
2669
2670 var b, i;
2671 var q = this.clone();
2672 if (!littleEndian) {
2673 // Assume big-endian
2674 for (i = 0; i < reqLength - byteLength; i++) {
2675 res[i] = 0;
2676 }
2677
2678 for (i = 0; !q.isZero(); i++) {
2679 b = q.andln(0xff);
2680 q.iushrn(8);
2681
2682 res[reqLength - i - 1] = b;
2683 }
2684 } else {
2685 for (i = 0; !q.isZero(); i++) {
2686 b = q.andln(0xff);
2687 q.iushrn(8);
2688
2689 res[i] = b;
2690 }
2691
2692 for (; i < reqLength; i++) {
2693 res[i] = 0;
2694 }
2695 }
2696
2697 return res;
2698 };
2699
2700 if (Math.clz32) {
2701 BN.prototype._countBits = function _countBits (w) {
2702 return 32 - Math.clz32(w);
2703 };
2704 } else {
2705 BN.prototype._countBits = function _countBits (w) {
2706 var t = w;
2707 var r = 0;
2708 if (t >= 0x1000) {
2709 r += 13;
2710 t >>>= 13;
2711 }
2712 if (t >= 0x40) {
2713 r += 7;
2714 t >>>= 7;
2715 }
2716 if (t >= 0x8) {
2717 r += 4;
2718 t >>>= 4;
2719 }
2720 if (t >= 0x02) {
2721 r += 2;
2722 t >>>= 2;
2723 }
2724 return r + t;
2725 };
2726 }
2727
2728 BN.prototype._zeroBits = function _zeroBits (w) {
2729 // Short-cut
2730 if (w === 0) return 26;
2731
2732 var t = w;
2733 var r = 0;
2734 if ((t & 0x1fff) === 0) {
2735 r += 13;
2736 t >>>= 13;
2737 }
2738 if ((t & 0x7f) === 0) {
2739 r += 7;
2740 t >>>= 7;
2741 }
2742 if ((t & 0xf) === 0) {
2743 r += 4;
2744 t >>>= 4;
2745 }
2746 if ((t & 0x3) === 0) {
2747 r += 2;
2748 t >>>= 2;
2749 }
2750 if ((t & 0x1) === 0) {
2751 r++;
2752 }
2753 return r;
2754 };
2755
2756 // Return number of used bits in a BN
2757 BN.prototype.bitLength = function bitLength () {
2758 var w = this.words[this.length - 1];
2759 var hi = this._countBits(w);
2760 return (this.length - 1) * 26 + hi;
2761 };
2762
2763 function toBitArray (num) {
2764 var w = new Array(num.bitLength());
2765
2766 for (var bit = 0; bit < w.length; bit++) {
2767 var off = (bit / 26) | 0;
2768 var wbit = bit % 26;
2769
2770 w[bit] = (num.words[off] & (1 << wbit)) >>> wbit;
2771 }
2772
2773 return w;
2774 }
2775
2776 // Number of trailing zero bits
2777 BN.prototype.zeroBits = function zeroBits () {
2778 if (this.isZero()) return 0;
2779
2780 var r = 0;
2781 for (var i = 0; i < this.length; i++) {
2782 var b = this._zeroBits(this.words[i]);
2783 r += b;
2784 if (b !== 26) break;
2785 }
2786 return r;
2787 };
2788
2789 BN.prototype.byteLength = function byteLength () {
2790 return Math.ceil(this.bitLength() / 8);
2791 };
2792
2793 BN.prototype.toTwos = function toTwos (width) {
2794 if (this.negative !== 0) {
2795 return this.abs().inotn(width).iaddn(1);
2796 }
2797 return this.clone();
2798 };
2799
2800 BN.prototype.fromTwos = function fromTwos (width) {
2801 if (this.testn(width - 1)) {
2802 return this.notn(width).iaddn(1).ineg();
2803 }
2804 return this.clone();
2805 };
2806
2807 BN.prototype.isNeg = function isNeg () {
2808 return this.negative !== 0;
2809 };
2810
2811 // Return negative clone of `this`
2812 BN.prototype.neg = function neg () {
2813 return this.clone().ineg();
2814 };
2815
2816 BN.prototype.ineg = function ineg () {
2817 if (!this.isZero()) {
2818 this.negative ^= 1;
2819 }
2820
2821 return this;
2822 };
2823
2824 // Or `num` with `this` in-place
2825 BN.prototype.iuor = function iuor (num) {
2826 while (this.length < num.length) {
2827 this.words[this.length++] = 0;
2828 }
2829
2830 for (var i = 0; i < num.length; i++) {
2831 this.words[i] = this.words[i] | num.words[i];
2832 }
2833
2834 return this.strip();
2835 };
2836
2837 BN.prototype.ior = function ior (num) {
2838 assert((this.negative | num.negative) === 0);
2839 return this.iuor(num);
2840 };
2841
2842 // Or `num` with `this`
2843 BN.prototype.or = function or (num) {
2844 if (this.length > num.length) return this.clone().ior(num);
2845 return num.clone().ior(this);
2846 };
2847
2848 BN.prototype.uor = function uor (num) {
2849 if (this.length > num.length) return this.clone().iuor(num);
2850 return num.clone().iuor(this);
2851 };
2852
2853 // And `num` with `this` in-place
2854 BN.prototype.iuand = function iuand (num) {
2855 // b = min-length(num, this)
2856 var b;
2857 if (this.length > num.length) {
2858 b = num;
2859 } else {
2860 b = this;
2861 }
2862
2863 for (var i = 0; i < b.length; i++) {
2864 this.words[i] = this.words[i] & num.words[i];
2865 }
2866
2867 this.length = b.length;
2868
2869 return this.strip();
2870 };
2871
2872 BN.prototype.iand = function iand (num) {
2873 assert((this.negative | num.negative) === 0);
2874 return this.iuand(num);
2875 };
2876
2877 // And `num` with `this`
2878 BN.prototype.and = function and (num) {
2879 if (this.length > num.length) return this.clone().iand(num);
2880 return num.clone().iand(this);
2881 };
2882
2883 BN.prototype.uand = function uand (num) {
2884 if (this.length > num.length) return this.clone().iuand(num);
2885 return num.clone().iuand(this);
2886 };
2887
2888 // Xor `num` with `this` in-place
2889 BN.prototype.iuxor = function iuxor (num) {
2890 // a.length > b.length
2891 var a;
2892 var b;
2893 if (this.length > num.length) {
2894 a = this;
2895 b = num;
2896 } else {
2897 a = num;
2898 b = this;
2899 }
2900
2901 for (var i = 0; i < b.length; i++) {
2902 this.words[i] = a.words[i] ^ b.words[i];
2903 }
2904
2905 if (this !== a) {
2906 for (; i < a.length; i++) {
2907 this.words[i] = a.words[i];
2908 }
2909 }
2910
2911 this.length = a.length;
2912
2913 return this.strip();
2914 };
2915
2916 BN.prototype.ixor = function ixor (num) {
2917 assert((this.negative | num.negative) === 0);
2918 return this.iuxor(num);
2919 };
2920
2921 // Xor `num` with `this`
2922 BN.prototype.xor = function xor (num) {
2923 if (this.length > num.length) return this.clone().ixor(num);
2924 return num.clone().ixor(this);
2925 };
2926
2927 BN.prototype.uxor = function uxor (num) {
2928 if (this.length > num.length) return this.clone().iuxor(num);
2929 return num.clone().iuxor(this);
2930 };
2931
2932 // Not ``this`` with ``width`` bitwidth
2933 BN.prototype.inotn = function inotn (width) {
2934 assert(typeof width === 'number' && width >= 0);
2935
2936 var bytesNeeded = Math.ceil(width / 26) | 0;
2937 var bitsLeft = width % 26;
2938
2939 // Extend the buffer with leading zeroes
2940 this._expand(bytesNeeded);
2941
2942 if (bitsLeft > 0) {
2943 bytesNeeded--;
2944 }
2945
2946 // Handle complete words
2947 for (var i = 0; i < bytesNeeded; i++) {
2948 this.words[i] = ~this.words[i] & 0x3ffffff;
2949 }
2950
2951 // Handle the residue
2952 if (bitsLeft > 0) {
2953 this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));
2954 }
2955
2956 // And remove leading zeroes
2957 return this.strip();
2958 };
2959
2960 BN.prototype.notn = function notn (width) {
2961 return this.clone().inotn(width);
2962 };
2963
2964 // Set `bit` of `this`
2965 BN.prototype.setn = function setn (bit, val) {
2966 assert(typeof bit === 'number' && bit >= 0);
2967
2968 var off = (bit / 26) | 0;
2969 var wbit = bit % 26;
2970
2971 this._expand(off + 1);
2972
2973 if (val) {
2974 this.words[off] = this.words[off] | (1 << wbit);
2975 } else {
2976 this.words[off] = this.words[off] & ~(1 << wbit);
2977 }
2978
2979 return this.strip();
2980 };
2981
2982 // Add `num` to `this` in-place
2983 BN.prototype.iadd = function iadd (num) {
2984 var r;
2985
2986 // negative + positive
2987 if (this.negative !== 0 && num.negative === 0) {
2988 this.negative = 0;
2989 r = this.isub(num);
2990 this.negative ^= 1;
2991 return this._normSign();
2992
2993 // positive + negative
2994 } else if (this.negative === 0 && num.negative !== 0) {
2995 num.negative = 0;
2996 r = this.isub(num);
2997 num.negative = 1;
2998 return r._normSign();
2999 }
3000
3001 // a.length > b.length
3002 var a, b;
3003 if (this.length > num.length) {
3004 a = this;
3005 b = num;
3006 } else {
3007 a = num;
3008 b = this;
3009 }
3010
3011 var carry = 0;
3012 for (var i = 0; i < b.length; i++) {
3013 r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
3014 this.words[i] = r & 0x3ffffff;
3015 carry = r >>> 26;
3016 }
3017 for (; carry !== 0 && i < a.length; i++) {
3018 r = (a.words[i] | 0) + carry;
3019 this.words[i] = r & 0x3ffffff;
3020 carry = r >>> 26;
3021 }
3022
3023 this.length = a.length;
3024 if (carry !== 0) {
3025 this.words[this.length] = carry;
3026 this.length++;
3027 // Copy the rest of the words
3028 } else if (a !== this) {
3029 for (; i < a.length; i++) {
3030 this.words[i] = a.words[i];
3031 }
3032 }
3033
3034 return this;
3035 };
3036
3037 // Add `num` to `this`
3038 BN.prototype.add = function add (num) {
3039 var res;
3040 if (num.negative !== 0 && this.negative === 0) {
3041 num.negative = 0;
3042 res = this.sub(num);
3043 num.negative ^= 1;
3044 return res;
3045 } else if (num.negative === 0 && this.negative !== 0) {
3046 this.negative = 0;
3047 res = num.sub(this);
3048 this.negative = 1;
3049 return res;
3050 }
3051
3052 if (this.length > num.length) return this.clone().iadd(num);
3053
3054 return num.clone().iadd(this);
3055 };
3056
3057 // Subtract `num` from `this` in-place
3058 BN.prototype.isub = function isub (num) {
3059 // this - (-num) = this + num
3060 if (num.negative !== 0) {
3061 num.negative = 0;
3062 var r = this.iadd(num);
3063 num.negative = 1;
3064 return r._normSign();
3065
3066 // -this - num = -(this + num)
3067 } else if (this.negative !== 0) {
3068 this.negative = 0;
3069 this.iadd(num);
3070 this.negative = 1;
3071 return this._normSign();
3072 }
3073
3074 // At this point both numbers are positive
3075 var cmp = this.cmp(num);
3076
3077 // Optimization - zeroify
3078 if (cmp === 0) {
3079 this.negative = 0;
3080 this.length = 1;
3081 this.words[0] = 0;
3082 return this;
3083 }
3084
3085 // a > b
3086 var a, b;
3087 if (cmp > 0) {
3088 a = this;
3089 b = num;
3090 } else {
3091 a = num;
3092 b = this;
3093 }
3094
3095 var carry = 0;
3096 for (var i = 0; i < b.length; i++) {
3097 r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
3098 carry = r >> 26;
3099 this.words[i] = r & 0x3ffffff;
3100 }
3101 for (; carry !== 0 && i < a.length; i++) {
3102 r = (a.words[i] | 0) + carry;
3103 carry = r >> 26;
3104 this.words[i] = r & 0x3ffffff;
3105 }
3106
3107 // Copy rest of the words
3108 if (carry === 0 && i < a.length && a !== this) {
3109 for (; i < a.length; i++) {
3110 this.words[i] = a.words[i];
3111 }
3112 }
3113
3114 this.length = Math.max(this.length, i);
3115
3116 if (a !== this) {
3117 this.negative = 1;
3118 }
3119
3120 return this.strip();
3121 };
3122
3123 // Subtract `num` from `this`
3124 BN.prototype.sub = function sub (num) {
3125 return this.clone().isub(num);
3126 };
3127
3128 function smallMulTo (self, num, out) {
3129 out.negative = num.negative ^ self.negative;
3130 var len = (self.length + num.length) | 0;
3131 out.length = len;
3132 len = (len - 1) | 0;
3133
3134 // Peel one iteration (compiler can't do it, because of code complexity)
3135 var a = self.words[0] | 0;
3136 var b = num.words[0] | 0;
3137 var r = a * b;
3138
3139 var lo = r & 0x3ffffff;
3140 var carry = (r / 0x4000000) | 0;
3141 out.words[0] = lo;
3142
3143 for (var k = 1; k < len; k++) {
3144 // Sum all words with the same `i + j = k` and accumulate `ncarry`,
3145 // note that ncarry could be >= 0x3ffffff
3146 var ncarry = carry >>> 26;
3147 var rword = carry & 0x3ffffff;
3148 var maxJ = Math.min(k, num.length - 1);
3149 for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
3150 var i = (k - j) | 0;
3151 a = self.words[i] | 0;
3152 b = num.words[j] | 0;
3153 r = a * b + rword;
3154 ncarry += (r / 0x4000000) | 0;
3155 rword = r & 0x3ffffff;
3156 }
3157 out.words[k] = rword | 0;
3158 carry = ncarry | 0;
3159 }
3160 if (carry !== 0) {
3161 out.words[k] = carry | 0;
3162 } else {
3163 out.length--;
3164 }
3165
3166 return out.strip();
3167 }
3168
3169 // TODO(indutny): it may be reasonable to omit it for users who don't need
3170 // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
3171 // multiplication (like elliptic secp256k1).
3172 var comb10MulTo = function comb10MulTo (self, num, out) {
3173 var a = self.words;
3174 var b = num.words;
3175 var o = out.words;
3176 var c = 0;
3177 var lo;
3178 var mid;
3179 var hi;
3180 var a0 = a[0] | 0;
3181 var al0 = a0 & 0x1fff;
3182 var ah0 = a0 >>> 13;
3183 var a1 = a[1] | 0;
3184 var al1 = a1 & 0x1fff;
3185 var ah1 = a1 >>> 13;
3186 var a2 = a[2] | 0;
3187 var al2 = a2 & 0x1fff;
3188 var ah2 = a2 >>> 13;
3189 var a3 = a[3] | 0;
3190 var al3 = a3 & 0x1fff;
3191 var ah3 = a3 >>> 13;
3192 var a4 = a[4] | 0;
3193 var al4 = a4 & 0x1fff;
3194 var ah4 = a4 >>> 13;
3195 var a5 = a[5] | 0;
3196 var al5 = a5 & 0x1fff;
3197 var ah5 = a5 >>> 13;
3198 var a6 = a[6] | 0;
3199 var al6 = a6 & 0x1fff;
3200 var ah6 = a6 >>> 13;
3201 var a7 = a[7] | 0;
3202 var al7 = a7 & 0x1fff;
3203 var ah7 = a7 >>> 13;
3204 var a8 = a[8] | 0;
3205 var al8 = a8 & 0x1fff;
3206 var ah8 = a8 >>> 13;
3207 var a9 = a[9] | 0;
3208 var al9 = a9 & 0x1fff;
3209 var ah9 = a9 >>> 13;
3210 var b0 = b[0] | 0;
3211 var bl0 = b0 & 0x1fff;
3212 var bh0 = b0 >>> 13;
3213 var b1 = b[1] | 0;
3214 var bl1 = b1 & 0x1fff;
3215 var bh1 = b1 >>> 13;
3216 var b2 = b[2] | 0;
3217 var bl2 = b2 & 0x1fff;
3218 var bh2 = b2 >>> 13;
3219 var b3 = b[3] | 0;
3220 var bl3 = b3 & 0x1fff;
3221 var bh3 = b3 >>> 13;
3222 var b4 = b[4] | 0;
3223 var bl4 = b4 & 0x1fff;
3224 var bh4 = b4 >>> 13;
3225 var b5 = b[5] | 0;
3226 var bl5 = b5 & 0x1fff;
3227 var bh5 = b5 >>> 13;
3228 var b6 = b[6] | 0;
3229 var bl6 = b6 & 0x1fff;
3230 var bh6 = b6 >>> 13;
3231 var b7 = b[7] | 0;
3232 var bl7 = b7 & 0x1fff;
3233 var bh7 = b7 >>> 13;
3234 var b8 = b[8] | 0;
3235 var bl8 = b8 & 0x1fff;
3236 var bh8 = b8 >>> 13;
3237 var b9 = b[9] | 0;
3238 var bl9 = b9 & 0x1fff;
3239 var bh9 = b9 >>> 13;
3240
3241 out.negative = self.negative ^ num.negative;
3242 out.length = 19;
3243 /* k = 0 */
3244 lo = Math.imul(al0, bl0);
3245 mid = Math.imul(al0, bh0);
3246 mid = (mid + Math.imul(ah0, bl0)) | 0;
3247 hi = Math.imul(ah0, bh0);
3248 var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3249 c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;
3250 w0 &= 0x3ffffff;
3251 /* k = 1 */
3252 lo = Math.imul(al1, bl0);
3253 mid = Math.imul(al1, bh0);
3254 mid = (mid + Math.imul(ah1, bl0)) | 0;
3255 hi = Math.imul(ah1, bh0);
3256 lo = (lo + Math.imul(al0, bl1)) | 0;
3257 mid = (mid + Math.imul(al0, bh1)) | 0;
3258 mid = (mid + Math.imul(ah0, bl1)) | 0;
3259 hi = (hi + Math.imul(ah0, bh1)) | 0;
3260 var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3261 c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;
3262 w1 &= 0x3ffffff;
3263 /* k = 2 */
3264 lo = Math.imul(al2, bl0);
3265 mid = Math.imul(al2, bh0);
3266 mid = (mid + Math.imul(ah2, bl0)) | 0;
3267 hi = Math.imul(ah2, bh0);
3268 lo = (lo + Math.imul(al1, bl1)) | 0;
3269 mid = (mid + Math.imul(al1, bh1)) | 0;
3270 mid = (mid + Math.imul(ah1, bl1)) | 0;
3271 hi = (hi + Math.imul(ah1, bh1)) | 0;
3272 lo = (lo + Math.imul(al0, bl2)) | 0;
3273 mid = (mid + Math.imul(al0, bh2)) | 0;
3274 mid = (mid + Math.imul(ah0, bl2)) | 0;
3275 hi = (hi + Math.imul(ah0, bh2)) | 0;
3276 var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3277 c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;
3278 w2 &= 0x3ffffff;
3279 /* k = 3 */
3280 lo = Math.imul(al3, bl0);
3281 mid = Math.imul(al3, bh0);
3282 mid = (mid + Math.imul(ah3, bl0)) | 0;
3283 hi = Math.imul(ah3, bh0);
3284 lo = (lo + Math.imul(al2, bl1)) | 0;
3285 mid = (mid + Math.imul(al2, bh1)) | 0;
3286 mid = (mid + Math.imul(ah2, bl1)) | 0;
3287 hi = (hi + Math.imul(ah2, bh1)) | 0;
3288 lo = (lo + Math.imul(al1, bl2)) | 0;
3289 mid = (mid + Math.imul(al1, bh2)) | 0;
3290 mid = (mid + Math.imul(ah1, bl2)) | 0;
3291 hi = (hi + Math.imul(ah1, bh2)) | 0;
3292 lo = (lo + Math.imul(al0, bl3)) | 0;
3293 mid = (mid + Math.imul(al0, bh3)) | 0;
3294 mid = (mid + Math.imul(ah0, bl3)) | 0;
3295 hi = (hi + Math.imul(ah0, bh3)) | 0;
3296 var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3297 c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;
3298 w3 &= 0x3ffffff;
3299 /* k = 4 */
3300 lo = Math.imul(al4, bl0);
3301 mid = Math.imul(al4, bh0);
3302 mid = (mid + Math.imul(ah4, bl0)) | 0;
3303 hi = Math.imul(ah4, bh0);
3304 lo = (lo + Math.imul(al3, bl1)) | 0;
3305 mid = (mid + Math.imul(al3, bh1)) | 0;
3306 mid = (mid + Math.imul(ah3, bl1)) | 0;
3307 hi = (hi + Math.imul(ah3, bh1)) | 0;
3308 lo = (lo + Math.imul(al2, bl2)) | 0;
3309 mid = (mid + Math.imul(al2, bh2)) | 0;
3310 mid = (mid + Math.imul(ah2, bl2)) | 0;
3311 hi = (hi + Math.imul(ah2, bh2)) | 0;
3312 lo = (lo + Math.imul(al1, bl3)) | 0;
3313 mid = (mid + Math.imul(al1, bh3)) | 0;
3314 mid = (mid + Math.imul(ah1, bl3)) | 0;
3315 hi = (hi + Math.imul(ah1, bh3)) | 0;
3316 lo = (lo + Math.imul(al0, bl4)) | 0;
3317 mid = (mid + Math.imul(al0, bh4)) | 0;
3318 mid = (mid + Math.imul(ah0, bl4)) | 0;
3319 hi = (hi + Math.imul(ah0, bh4)) | 0;
3320 var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3321 c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;
3322 w4 &= 0x3ffffff;
3323 /* k = 5 */
3324 lo = Math.imul(al5, bl0);
3325 mid = Math.imul(al5, bh0);
3326 mid = (mid + Math.imul(ah5, bl0)) | 0;
3327 hi = Math.imul(ah5, bh0);
3328 lo = (lo + Math.imul(al4, bl1)) | 0;
3329 mid = (mid + Math.imul(al4, bh1)) | 0;
3330 mid = (mid + Math.imul(ah4, bl1)) | 0;
3331 hi = (hi + Math.imul(ah4, bh1)) | 0;
3332 lo = (lo + Math.imul(al3, bl2)) | 0;
3333 mid = (mid + Math.imul(al3, bh2)) | 0;
3334 mid = (mid + Math.imul(ah3, bl2)) | 0;
3335 hi = (hi + Math.imul(ah3, bh2)) | 0;
3336 lo = (lo + Math.imul(al2, bl3)) | 0;
3337 mid = (mid + Math.imul(al2, bh3)) | 0;
3338 mid = (mid + Math.imul(ah2, bl3)) | 0;
3339 hi = (hi + Math.imul(ah2, bh3)) | 0;
3340 lo = (lo + Math.imul(al1, bl4)) | 0;
3341 mid = (mid + Math.imul(al1, bh4)) | 0;
3342 mid = (mid + Math.imul(ah1, bl4)) | 0;
3343 hi = (hi + Math.imul(ah1, bh4)) | 0;
3344 lo = (lo + Math.imul(al0, bl5)) | 0;
3345 mid = (mid + Math.imul(al0, bh5)) | 0;
3346 mid = (mid + Math.imul(ah0, bl5)) | 0;
3347 hi = (hi + Math.imul(ah0, bh5)) | 0;
3348 var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3349 c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;
3350 w5 &= 0x3ffffff;
3351 /* k = 6 */
3352 lo = Math.imul(al6, bl0);
3353 mid = Math.imul(al6, bh0);
3354 mid = (mid + Math.imul(ah6, bl0)) | 0;
3355 hi = Math.imul(ah6, bh0);
3356 lo = (lo + Math.imul(al5, bl1)) | 0;
3357 mid = (mid + Math.imul(al5, bh1)) | 0;
3358 mid = (mid + Math.imul(ah5, bl1)) | 0;
3359 hi = (hi + Math.imul(ah5, bh1)) | 0;
3360 lo = (lo + Math.imul(al4, bl2)) | 0;
3361 mid = (mid + Math.imul(al4, bh2)) | 0;
3362 mid = (mid + Math.imul(ah4, bl2)) | 0;
3363 hi = (hi + Math.imul(ah4, bh2)) | 0;
3364 lo = (lo + Math.imul(al3, bl3)) | 0;
3365 mid = (mid + Math.imul(al3, bh3)) | 0;
3366 mid = (mid + Math.imul(ah3, bl3)) | 0;
3367 hi = (hi + Math.imul(ah3, bh3)) | 0;
3368 lo = (lo + Math.imul(al2, bl4)) | 0;
3369 mid = (mid + Math.imul(al2, bh4)) | 0;
3370 mid = (mid + Math.imul(ah2, bl4)) | 0;
3371 hi = (hi + Math.imul(ah2, bh4)) | 0;
3372 lo = (lo + Math.imul(al1, bl5)) | 0;
3373 mid = (mid + Math.imul(al1, bh5)) | 0;
3374 mid = (mid + Math.imul(ah1, bl5)) | 0;
3375 hi = (hi + Math.imul(ah1, bh5)) | 0;
3376 lo = (lo + Math.imul(al0, bl6)) | 0;
3377 mid = (mid + Math.imul(al0, bh6)) | 0;
3378 mid = (mid + Math.imul(ah0, bl6)) | 0;
3379 hi = (hi + Math.imul(ah0, bh6)) | 0;
3380 var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3381 c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;
3382 w6 &= 0x3ffffff;
3383 /* k = 7 */
3384 lo = Math.imul(al7, bl0);
3385 mid = Math.imul(al7, bh0);
3386 mid = (mid + Math.imul(ah7, bl0)) | 0;
3387 hi = Math.imul(ah7, bh0);
3388 lo = (lo + Math.imul(al6, bl1)) | 0;
3389 mid = (mid + Math.imul(al6, bh1)) | 0;
3390 mid = (mid + Math.imul(ah6, bl1)) | 0;
3391 hi = (hi + Math.imul(ah6, bh1)) | 0;
3392 lo = (lo + Math.imul(al5, bl2)) | 0;
3393 mid = (mid + Math.imul(al5, bh2)) | 0;
3394 mid = (mid + Math.imul(ah5, bl2)) | 0;
3395 hi = (hi + Math.imul(ah5, bh2)) | 0;
3396 lo = (lo + Math.imul(al4, bl3)) | 0;
3397 mid = (mid + Math.imul(al4, bh3)) | 0;
3398 mid = (mid + Math.imul(ah4, bl3)) | 0;
3399 hi = (hi + Math.imul(ah4, bh3)) | 0;
3400 lo = (lo + Math.imul(al3, bl4)) | 0;
3401 mid = (mid + Math.imul(al3, bh4)) | 0;
3402 mid = (mid + Math.imul(ah3, bl4)) | 0;
3403 hi = (hi + Math.imul(ah3, bh4)) | 0;
3404 lo = (lo + Math.imul(al2, bl5)) | 0;
3405 mid = (mid + Math.imul(al2, bh5)) | 0;
3406 mid = (mid + Math.imul(ah2, bl5)) | 0;
3407 hi = (hi + Math.imul(ah2, bh5)) | 0;
3408 lo = (lo + Math.imul(al1, bl6)) | 0;
3409 mid = (mid + Math.imul(al1, bh6)) | 0;
3410 mid = (mid + Math.imul(ah1, bl6)) | 0;
3411 hi = (hi + Math.imul(ah1, bh6)) | 0;
3412 lo = (lo + Math.imul(al0, bl7)) | 0;
3413 mid = (mid + Math.imul(al0, bh7)) | 0;
3414 mid = (mid + Math.imul(ah0, bl7)) | 0;
3415 hi = (hi + Math.imul(ah0, bh7)) | 0;
3416 var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3417 c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;
3418 w7 &= 0x3ffffff;
3419 /* k = 8 */
3420 lo = Math.imul(al8, bl0);
3421 mid = Math.imul(al8, bh0);
3422 mid = (mid + Math.imul(ah8, bl0)) | 0;
3423 hi = Math.imul(ah8, bh0);
3424 lo = (lo + Math.imul(al7, bl1)) | 0;
3425 mid = (mid + Math.imul(al7, bh1)) | 0;
3426 mid = (mid + Math.imul(ah7, bl1)) | 0;
3427 hi = (hi + Math.imul(ah7, bh1)) | 0;
3428 lo = (lo + Math.imul(al6, bl2)) | 0;
3429 mid = (mid + Math.imul(al6, bh2)) | 0;
3430 mid = (mid + Math.imul(ah6, bl2)) | 0;
3431 hi = (hi + Math.imul(ah6, bh2)) | 0;
3432 lo = (lo + Math.imul(al5, bl3)) | 0;
3433 mid = (mid + Math.imul(al5, bh3)) | 0;
3434 mid = (mid + Math.imul(ah5, bl3)) | 0;
3435 hi = (hi + Math.imul(ah5, bh3)) | 0;
3436 lo = (lo + Math.imul(al4, bl4)) | 0;
3437 mid = (mid + Math.imul(al4, bh4)) | 0;
3438 mid = (mid + Math.imul(ah4, bl4)) | 0;
3439 hi = (hi + Math.imul(ah4, bh4)) | 0;
3440 lo = (lo + Math.imul(al3, bl5)) | 0;
3441 mid = (mid + Math.imul(al3, bh5)) | 0;
3442 mid = (mid + Math.imul(ah3, bl5)) | 0;
3443 hi = (hi + Math.imul(ah3, bh5)) | 0;
3444 lo = (lo + Math.imul(al2, bl6)) | 0;
3445 mid = (mid + Math.imul(al2, bh6)) | 0;
3446 mid = (mid + Math.imul(ah2, bl6)) | 0;
3447 hi = (hi + Math.imul(ah2, bh6)) | 0;
3448 lo = (lo + Math.imul(al1, bl7)) | 0;
3449 mid = (mid + Math.imul(al1, bh7)) | 0;
3450 mid = (mid + Math.imul(ah1, bl7)) | 0;
3451 hi = (hi + Math.imul(ah1, bh7)) | 0;
3452 lo = (lo + Math.imul(al0, bl8)) | 0;
3453 mid = (mid + Math.imul(al0, bh8)) | 0;
3454 mid = (mid + Math.imul(ah0, bl8)) | 0;
3455 hi = (hi + Math.imul(ah0, bh8)) | 0;
3456 var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3457 c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;
3458 w8 &= 0x3ffffff;
3459 /* k = 9 */
3460 lo = Math.imul(al9, bl0);
3461 mid = Math.imul(al9, bh0);
3462 mid = (mid + Math.imul(ah9, bl0)) | 0;
3463 hi = Math.imul(ah9, bh0);
3464 lo = (lo + Math.imul(al8, bl1)) | 0;
3465 mid = (mid + Math.imul(al8, bh1)) | 0;
3466 mid = (mid + Math.imul(ah8, bl1)) | 0;
3467 hi = (hi + Math.imul(ah8, bh1)) | 0;
3468 lo = (lo + Math.imul(al7, bl2)) | 0;
3469 mid = (mid + Math.imul(al7, bh2)) | 0;
3470 mid = (mid + Math.imul(ah7, bl2)) | 0;
3471 hi = (hi + Math.imul(ah7, bh2)) | 0;
3472 lo = (lo + Math.imul(al6, bl3)) | 0;
3473 mid = (mid + Math.imul(al6, bh3)) | 0;
3474 mid = (mid + Math.imul(ah6, bl3)) | 0;
3475 hi = (hi + Math.imul(ah6, bh3)) | 0;
3476 lo = (lo + Math.imul(al5, bl4)) | 0;
3477 mid = (mid + Math.imul(al5, bh4)) | 0;
3478 mid = (mid + Math.imul(ah5, bl4)) | 0;
3479 hi = (hi + Math.imul(ah5, bh4)) | 0;
3480 lo = (lo + Math.imul(al4, bl5)) | 0;
3481 mid = (mid + Math.imul(al4, bh5)) | 0;
3482 mid = (mid + Math.imul(ah4, bl5)) | 0;
3483 hi = (hi + Math.imul(ah4, bh5)) | 0;
3484 lo = (lo + Math.imul(al3, bl6)) | 0;
3485 mid = (mid + Math.imul(al3, bh6)) | 0;
3486 mid = (mid + Math.imul(ah3, bl6)) | 0;
3487 hi = (hi + Math.imul(ah3, bh6)) | 0;
3488 lo = (lo + Math.imul(al2, bl7)) | 0;
3489 mid = (mid + Math.imul(al2, bh7)) | 0;
3490 mid = (mid + Math.imul(ah2, bl7)) | 0;
3491 hi = (hi + Math.imul(ah2, bh7)) | 0;
3492 lo = (lo + Math.imul(al1, bl8)) | 0;
3493 mid = (mid + Math.imul(al1, bh8)) | 0;
3494 mid = (mid + Math.imul(ah1, bl8)) | 0;
3495 hi = (hi + Math.imul(ah1, bh8)) | 0;
3496 lo = (lo + Math.imul(al0, bl9)) | 0;
3497 mid = (mid + Math.imul(al0, bh9)) | 0;
3498 mid = (mid + Math.imul(ah0, bl9)) | 0;
3499 hi = (hi + Math.imul(ah0, bh9)) | 0;
3500 var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3501 c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;
3502 w9 &= 0x3ffffff;
3503 /* k = 10 */
3504 lo = Math.imul(al9, bl1);
3505 mid = Math.imul(al9, bh1);
3506 mid = (mid + Math.imul(ah9, bl1)) | 0;
3507 hi = Math.imul(ah9, bh1);
3508 lo = (lo + Math.imul(al8, bl2)) | 0;
3509 mid = (mid + Math.imul(al8, bh2)) | 0;
3510 mid = (mid + Math.imul(ah8, bl2)) | 0;
3511 hi = (hi + Math.imul(ah8, bh2)) | 0;
3512 lo = (lo + Math.imul(al7, bl3)) | 0;
3513 mid = (mid + Math.imul(al7, bh3)) | 0;
3514 mid = (mid + Math.imul(ah7, bl3)) | 0;
3515 hi = (hi + Math.imul(ah7, bh3)) | 0;
3516 lo = (lo + Math.imul(al6, bl4)) | 0;
3517 mid = (mid + Math.imul(al6, bh4)) | 0;
3518 mid = (mid + Math.imul(ah6, bl4)) | 0;
3519 hi = (hi + Math.imul(ah6, bh4)) | 0;
3520 lo = (lo + Math.imul(al5, bl5)) | 0;
3521 mid = (mid + Math.imul(al5, bh5)) | 0;
3522 mid = (mid + Math.imul(ah5, bl5)) | 0;
3523 hi = (hi + Math.imul(ah5, bh5)) | 0;
3524 lo = (lo + Math.imul(al4, bl6)) | 0;
3525 mid = (mid + Math.imul(al4, bh6)) | 0;
3526 mid = (mid + Math.imul(ah4, bl6)) | 0;
3527 hi = (hi + Math.imul(ah4, bh6)) | 0;
3528 lo = (lo + Math.imul(al3, bl7)) | 0;
3529 mid = (mid + Math.imul(al3, bh7)) | 0;
3530 mid = (mid + Math.imul(ah3, bl7)) | 0;
3531 hi = (hi + Math.imul(ah3, bh7)) | 0;
3532 lo = (lo + Math.imul(al2, bl8)) | 0;
3533 mid = (mid + Math.imul(al2, bh8)) | 0;
3534 mid = (mid + Math.imul(ah2, bl8)) | 0;
3535 hi = (hi + Math.imul(ah2, bh8)) | 0;
3536 lo = (lo + Math.imul(al1, bl9)) | 0;
3537 mid = (mid + Math.imul(al1, bh9)) | 0;
3538 mid = (mid + Math.imul(ah1, bl9)) | 0;
3539 hi = (hi + Math.imul(ah1, bh9)) | 0;
3540 var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3541 c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;
3542 w10 &= 0x3ffffff;
3543 /* k = 11 */
3544 lo = Math.imul(al9, bl2);
3545 mid = Math.imul(al9, bh2);
3546 mid = (mid + Math.imul(ah9, bl2)) | 0;
3547 hi = Math.imul(ah9, bh2);
3548 lo = (lo + Math.imul(al8, bl3)) | 0;
3549 mid = (mid + Math.imul(al8, bh3)) | 0;
3550 mid = (mid + Math.imul(ah8, bl3)) | 0;
3551 hi = (hi + Math.imul(ah8, bh3)) | 0;
3552 lo = (lo + Math.imul(al7, bl4)) | 0;
3553 mid = (mid + Math.imul(al7, bh4)) | 0;
3554 mid = (mid + Math.imul(ah7, bl4)) | 0;
3555 hi = (hi + Math.imul(ah7, bh4)) | 0;
3556 lo = (lo + Math.imul(al6, bl5)) | 0;
3557 mid = (mid + Math.imul(al6, bh5)) | 0;
3558 mid = (mid + Math.imul(ah6, bl5)) | 0;
3559 hi = (hi + Math.imul(ah6, bh5)) | 0;
3560 lo = (lo + Math.imul(al5, bl6)) | 0;
3561 mid = (mid + Math.imul(al5, bh6)) | 0;
3562 mid = (mid + Math.imul(ah5, bl6)) | 0;
3563 hi = (hi + Math.imul(ah5, bh6)) | 0;
3564 lo = (lo + Math.imul(al4, bl7)) | 0;
3565 mid = (mid + Math.imul(al4, bh7)) | 0;
3566 mid = (mid + Math.imul(ah4, bl7)) | 0;
3567 hi = (hi + Math.imul(ah4, bh7)) | 0;
3568 lo = (lo + Math.imul(al3, bl8)) | 0;
3569 mid = (mid + Math.imul(al3, bh8)) | 0;
3570 mid = (mid + Math.imul(ah3, bl8)) | 0;
3571 hi = (hi + Math.imul(ah3, bh8)) | 0;
3572 lo = (lo + Math.imul(al2, bl9)) | 0;
3573 mid = (mid + Math.imul(al2, bh9)) | 0;
3574 mid = (mid + Math.imul(ah2, bl9)) | 0;
3575 hi = (hi + Math.imul(ah2, bh9)) | 0;
3576 var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3577 c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;
3578 w11 &= 0x3ffffff;
3579 /* k = 12 */
3580 lo = Math.imul(al9, bl3);
3581 mid = Math.imul(al9, bh3);
3582 mid = (mid + Math.imul(ah9, bl3)) | 0;
3583 hi = Math.imul(ah9, bh3);
3584 lo = (lo + Math.imul(al8, bl4)) | 0;
3585 mid = (mid + Math.imul(al8, bh4)) | 0;
3586 mid = (mid + Math.imul(ah8, bl4)) | 0;
3587 hi = (hi + Math.imul(ah8, bh4)) | 0;
3588 lo = (lo + Math.imul(al7, bl5)) | 0;
3589 mid = (mid + Math.imul(al7, bh5)) | 0;
3590 mid = (mid + Math.imul(ah7, bl5)) | 0;
3591 hi = (hi + Math.imul(ah7, bh5)) | 0;
3592 lo = (lo + Math.imul(al6, bl6)) | 0;
3593 mid = (mid + Math.imul(al6, bh6)) | 0;
3594 mid = (mid + Math.imul(ah6, bl6)) | 0;
3595 hi = (hi + Math.imul(ah6, bh6)) | 0;
3596 lo = (lo + Math.imul(al5, bl7)) | 0;
3597 mid = (mid + Math.imul(al5, bh7)) | 0;
3598 mid = (mid + Math.imul(ah5, bl7)) | 0;
3599 hi = (hi + Math.imul(ah5, bh7)) | 0;
3600 lo = (lo + Math.imul(al4, bl8)) | 0;
3601 mid = (mid + Math.imul(al4, bh8)) | 0;
3602 mid = (mid + Math.imul(ah4, bl8)) | 0;
3603 hi = (hi + Math.imul(ah4, bh8)) | 0;
3604 lo = (lo + Math.imul(al3, bl9)) | 0;
3605 mid = (mid + Math.imul(al3, bh9)) | 0;
3606 mid = (mid + Math.imul(ah3, bl9)) | 0;
3607 hi = (hi + Math.imul(ah3, bh9)) | 0;
3608 var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3609 c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;
3610 w12 &= 0x3ffffff;
3611 /* k = 13 */
3612 lo = Math.imul(al9, bl4);
3613 mid = Math.imul(al9, bh4);
3614 mid = (mid + Math.imul(ah9, bl4)) | 0;
3615 hi = Math.imul(ah9, bh4);
3616 lo = (lo + Math.imul(al8, bl5)) | 0;
3617 mid = (mid + Math.imul(al8, bh5)) | 0;
3618 mid = (mid + Math.imul(ah8, bl5)) | 0;
3619 hi = (hi + Math.imul(ah8, bh5)) | 0;
3620 lo = (lo + Math.imul(al7, bl6)) | 0;
3621 mid = (mid + Math.imul(al7, bh6)) | 0;
3622 mid = (mid + Math.imul(ah7, bl6)) | 0;
3623 hi = (hi + Math.imul(ah7, bh6)) | 0;
3624 lo = (lo + Math.imul(al6, bl7)) | 0;
3625 mid = (mid + Math.imul(al6, bh7)) | 0;
3626 mid = (mid + Math.imul(ah6, bl7)) | 0;
3627 hi = (hi + Math.imul(ah6, bh7)) | 0;
3628 lo = (lo + Math.imul(al5, bl8)) | 0;
3629 mid = (mid + Math.imul(al5, bh8)) | 0;
3630 mid = (mid + Math.imul(ah5, bl8)) | 0;
3631 hi = (hi + Math.imul(ah5, bh8)) | 0;
3632 lo = (lo + Math.imul(al4, bl9)) | 0;
3633 mid = (mid + Math.imul(al4, bh9)) | 0;
3634 mid = (mid + Math.imul(ah4, bl9)) | 0;
3635 hi = (hi + Math.imul(ah4, bh9)) | 0;
3636 var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3637 c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;
3638 w13 &= 0x3ffffff;
3639 /* k = 14 */
3640 lo = Math.imul(al9, bl5);
3641 mid = Math.imul(al9, bh5);
3642 mid = (mid + Math.imul(ah9, bl5)) | 0;
3643 hi = Math.imul(ah9, bh5);
3644 lo = (lo + Math.imul(al8, bl6)) | 0;
3645 mid = (mid + Math.imul(al8, bh6)) | 0;
3646 mid = (mid + Math.imul(ah8, bl6)) | 0;
3647 hi = (hi + Math.imul(ah8, bh6)) | 0;
3648 lo = (lo + Math.imul(al7, bl7)) | 0;
3649 mid = (mid + Math.imul(al7, bh7)) | 0;
3650 mid = (mid + Math.imul(ah7, bl7)) | 0;
3651 hi = (hi + Math.imul(ah7, bh7)) | 0;
3652 lo = (lo + Math.imul(al6, bl8)) | 0;
3653 mid = (mid + Math.imul(al6, bh8)) | 0;
3654 mid = (mid + Math.imul(ah6, bl8)) | 0;
3655 hi = (hi + Math.imul(ah6, bh8)) | 0;
3656 lo = (lo + Math.imul(al5, bl9)) | 0;
3657 mid = (mid + Math.imul(al5, bh9)) | 0;
3658 mid = (mid + Math.imul(ah5, bl9)) | 0;
3659 hi = (hi + Math.imul(ah5, bh9)) | 0;
3660 var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3661 c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;
3662 w14 &= 0x3ffffff;
3663 /* k = 15 */
3664 lo = Math.imul(al9, bl6);
3665 mid = Math.imul(al9, bh6);
3666 mid = (mid + Math.imul(ah9, bl6)) | 0;
3667 hi = Math.imul(ah9, bh6);
3668 lo = (lo + Math.imul(al8, bl7)) | 0;
3669 mid = (mid + Math.imul(al8, bh7)) | 0;
3670 mid = (mid + Math.imul(ah8, bl7)) | 0;
3671 hi = (hi + Math.imul(ah8, bh7)) | 0;
3672 lo = (lo + Math.imul(al7, bl8)) | 0;
3673 mid = (mid + Math.imul(al7, bh8)) | 0;
3674 mid = (mid + Math.imul(ah7, bl8)) | 0;
3675 hi = (hi + Math.imul(ah7, bh8)) | 0;
3676 lo = (lo + Math.imul(al6, bl9)) | 0;
3677 mid = (mid + Math.imul(al6, bh9)) | 0;
3678 mid = (mid + Math.imul(ah6, bl9)) | 0;
3679 hi = (hi + Math.imul(ah6, bh9)) | 0;
3680 var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3681 c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;
3682 w15 &= 0x3ffffff;
3683 /* k = 16 */
3684 lo = Math.imul(al9, bl7);
3685 mid = Math.imul(al9, bh7);
3686 mid = (mid + Math.imul(ah9, bl7)) | 0;
3687 hi = Math.imul(ah9, bh7);
3688 lo = (lo + Math.imul(al8, bl8)) | 0;
3689 mid = (mid + Math.imul(al8, bh8)) | 0;
3690 mid = (mid + Math.imul(ah8, bl8)) | 0;
3691 hi = (hi + Math.imul(ah8, bh8)) | 0;
3692 lo = (lo + Math.imul(al7, bl9)) | 0;
3693 mid = (mid + Math.imul(al7, bh9)) | 0;
3694 mid = (mid + Math.imul(ah7, bl9)) | 0;
3695 hi = (hi + Math.imul(ah7, bh9)) | 0;
3696 var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3697 c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;
3698 w16 &= 0x3ffffff;
3699 /* k = 17 */
3700 lo = Math.imul(al9, bl8);
3701 mid = Math.imul(al9, bh8);
3702 mid = (mid + Math.imul(ah9, bl8)) | 0;
3703 hi = Math.imul(ah9, bh8);
3704 lo = (lo + Math.imul(al8, bl9)) | 0;
3705 mid = (mid + Math.imul(al8, bh9)) | 0;
3706 mid = (mid + Math.imul(ah8, bl9)) | 0;
3707 hi = (hi + Math.imul(ah8, bh9)) | 0;
3708 var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3709 c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;
3710 w17 &= 0x3ffffff;
3711 /* k = 18 */
3712 lo = Math.imul(al9, bl9);
3713 mid = Math.imul(al9, bh9);
3714 mid = (mid + Math.imul(ah9, bl9)) | 0;
3715 hi = Math.imul(ah9, bh9);
3716 var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3717 c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;
3718 w18 &= 0x3ffffff;
3719 o[0] = w0;
3720 o[1] = w1;
3721 o[2] = w2;
3722 o[3] = w3;
3723 o[4] = w4;
3724 o[5] = w5;
3725 o[6] = w6;
3726 o[7] = w7;
3727 o[8] = w8;
3728 o[9] = w9;
3729 o[10] = w10;
3730 o[11] = w11;
3731 o[12] = w12;
3732 o[13] = w13;
3733 o[14] = w14;
3734 o[15] = w15;
3735 o[16] = w16;
3736 o[17] = w17;
3737 o[18] = w18;
3738 if (c !== 0) {
3739 o[19] = c;
3740 out.length++;
3741 }
3742 return out;
3743 };
3744
3745 // Polyfill comb
3746 if (!Math.imul) {
3747 comb10MulTo = smallMulTo;
3748 }
3749
3750 function bigMulTo (self, num, out) {
3751 out.negative = num.negative ^ self.negative;
3752 out.length = self.length + num.length;
3753
3754 var carry = 0;
3755 var hncarry = 0;
3756 for (var k = 0; k < out.length - 1; k++) {
3757 // Sum all words with the same `i + j = k` and accumulate `ncarry`,
3758 // note that ncarry could be >= 0x3ffffff
3759 var ncarry = hncarry;
3760 hncarry = 0;
3761 var rword = carry & 0x3ffffff;
3762 var maxJ = Math.min(k, num.length - 1);
3763 for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
3764 var i = k - j;
3765 var a = self.words[i] | 0;
3766 var b = num.words[j] | 0;
3767 var r = a * b;
3768
3769 var lo = r & 0x3ffffff;
3770 ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;
3771 lo = (lo + rword) | 0;
3772 rword = lo & 0x3ffffff;
3773 ncarry = (ncarry + (lo >>> 26)) | 0;
3774
3775 hncarry += ncarry >>> 26;
3776 ncarry &= 0x3ffffff;
3777 }
3778 out.words[k] = rword;
3779 carry = ncarry;
3780 ncarry = hncarry;
3781 }
3782 if (carry !== 0) {
3783 out.words[k] = carry;
3784 } else {
3785 out.length--;
3786 }
3787
3788 return out.strip();
3789 }
3790
3791 function jumboMulTo (self, num, out) {
3792 var fftm = new FFTM();
3793 return fftm.mulp(self, num, out);
3794 }
3795
3796 BN.prototype.mulTo = function mulTo (num, out) {
3797 var res;
3798 var len = this.length + num.length;
3799 if (this.length === 10 && num.length === 10) {
3800 res = comb10MulTo(this, num, out);
3801 } else if (len < 63) {
3802 res = smallMulTo(this, num, out);
3803 } else if (len < 1024) {
3804 res = bigMulTo(this, num, out);
3805 } else {
3806 res = jumboMulTo(this, num, out);
3807 }
3808
3809 return res;
3810 };
3811
3812 // Cooley-Tukey algorithm for FFT
3813 // slightly revisited to rely on looping instead of recursion
3814
3815 function FFTM (x, y) {
3816 this.x = x;
3817 this.y = y;
3818 }
3819
3820 FFTM.prototype.makeRBT = function makeRBT (N) {
3821 var t = new Array(N);
3822 var l = BN.prototype._countBits(N) - 1;
3823 for (var i = 0; i < N; i++) {
3824 t[i] = this.revBin(i, l, N);
3825 }
3826
3827 return t;
3828 };
3829
3830 // Returns binary-reversed representation of `x`
3831 FFTM.prototype.revBin = function revBin (x, l, N) {
3832 if (x === 0 || x === N - 1) return x;
3833
3834 var rb = 0;
3835 for (var i = 0; i < l; i++) {
3836 rb |= (x & 1) << (l - i - 1);
3837 x >>= 1;
3838 }
3839
3840 return rb;
3841 };
3842
3843 // Performs "tweedling" phase, therefore 'emulating'
3844 // behaviour of the recursive algorithm
3845 FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {
3846 for (var i = 0; i < N; i++) {
3847 rtws[i] = rws[rbt[i]];
3848 itws[i] = iws[rbt[i]];
3849 }
3850 };
3851
3852 FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {
3853 this.permute(rbt, rws, iws, rtws, itws, N);
3854
3855 for (var s = 1; s < N; s <<= 1) {
3856 var l = s << 1;
3857
3858 var rtwdf = Math.cos(2 * Math.PI / l);
3859 var itwdf = Math.sin(2 * Math.PI / l);
3860
3861 for (var p = 0; p < N; p += l) {
3862 var rtwdf_ = rtwdf;
3863 var itwdf_ = itwdf;
3864
3865 for (var j = 0; j < s; j++) {
3866 var re = rtws[p + j];
3867 var ie = itws[p + j];
3868
3869 var ro = rtws[p + j + s];
3870 var io = itws[p + j + s];
3871
3872 var rx = rtwdf_ * ro - itwdf_ * io;
3873
3874 io = rtwdf_ * io + itwdf_ * ro;
3875 ro = rx;
3876
3877 rtws[p + j] = re + ro;
3878 itws[p + j] = ie + io;
3879
3880 rtws[p + j + s] = re - ro;
3881 itws[p + j + s] = ie - io;
3882
3883 /* jshint maxdepth : false */
3884 if (j !== l) {
3885 rx = rtwdf * rtwdf_ - itwdf * itwdf_;
3886
3887 itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
3888 rtwdf_ = rx;
3889 }
3890 }
3891 }
3892 }
3893 };
3894
3895 FFTM.prototype.guessLen13b = function guessLen13b (n, m) {
3896 var N = Math.max(m, n) | 1;
3897 var odd = N & 1;
3898 var i = 0;
3899 for (N = N / 2 | 0; N; N = N >>> 1) {
3900 i++;
3901 }
3902
3903 return 1 << i + 1 + odd;
3904 };
3905
3906 FFTM.prototype.conjugate = function conjugate (rws, iws, N) {
3907 if (N <= 1) return;
3908
3909 for (var i = 0; i < N / 2; i++) {
3910 var t = rws[i];
3911
3912 rws[i] = rws[N - i - 1];
3913 rws[N - i - 1] = t;
3914
3915 t = iws[i];
3916
3917 iws[i] = -iws[N - i - 1];
3918 iws[N - i - 1] = -t;
3919 }
3920 };
3921
3922 FFTM.prototype.normalize13b = function normalize13b (ws, N) {
3923 var carry = 0;
3924 for (var i = 0; i < N / 2; i++) {
3925 var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +
3926 Math.round(ws[2 * i] / N) +
3927 carry;
3928
3929 ws[i] = w & 0x3ffffff;
3930
3931 if (w < 0x4000000) {
3932 carry = 0;
3933 } else {
3934 carry = w / 0x4000000 | 0;
3935 }
3936 }
3937
3938 return ws;
3939 };
3940
3941 FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {
3942 var carry = 0;
3943 for (var i = 0; i < len; i++) {
3944 carry = carry + (ws[i] | 0);
3945
3946 rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;
3947 rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;
3948 }
3949
3950 // Pad with zeroes
3951 for (i = 2 * len; i < N; ++i) {
3952 rws[i] = 0;
3953 }
3954
3955 assert(carry === 0);
3956 assert((carry & ~0x1fff) === 0);
3957 };
3958
3959 FFTM.prototype.stub = function stub (N) {
3960 var ph = new Array(N);
3961 for (var i = 0; i < N; i++) {
3962 ph[i] = 0;
3963 }
3964
3965 return ph;
3966 };
3967
3968 FFTM.prototype.mulp = function mulp (x, y, out) {
3969 var N = 2 * this.guessLen13b(x.length, y.length);
3970
3971 var rbt = this.makeRBT(N);
3972
3973 var _ = this.stub(N);
3974
3975 var rws = new Array(N);
3976 var rwst = new Array(N);
3977 var iwst = new Array(N);
3978
3979 var nrws = new Array(N);
3980 var nrwst = new Array(N);
3981 var niwst = new Array(N);
3982
3983 var rmws = out.words;
3984 rmws.length = N;
3985
3986 this.convert13b(x.words, x.length, rws, N);
3987 this.convert13b(y.words, y.length, nrws, N);
3988
3989 this.transform(rws, _, rwst, iwst, N, rbt);
3990 this.transform(nrws, _, nrwst, niwst, N, rbt);
3991
3992 for (var i = 0; i < N; i++) {
3993 var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
3994 iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
3995 rwst[i] = rx;
3996 }
3997
3998 this.conjugate(rwst, iwst, N);
3999 this.transform(rwst, iwst, rmws, _, N, rbt);
4000 this.conjugate(rmws, _, N);
4001 this.normalize13b(rmws, N);
4002
4003 out.negative = x.negative ^ y.negative;
4004 out.length = x.length + y.length;
4005 return out.strip();
4006 };
4007
4008 // Multiply `this` by `num`
4009 BN.prototype.mul = function mul (num) {
4010 var out = new BN(null);
4011 out.words = new Array(this.length + num.length);
4012 return this.mulTo(num, out);
4013 };
4014
4015 // Multiply employing FFT
4016 BN.prototype.mulf = function mulf (num) {
4017 var out = new BN(null);
4018 out.words = new Array(this.length + num.length);
4019 return jumboMulTo(this, num, out);
4020 };
4021
4022 // In-place Multiplication
4023 BN.prototype.imul = function imul (num) {
4024 return this.clone().mulTo(num, this);
4025 };
4026
4027 BN.prototype.imuln = function imuln (num) {
4028 assert(typeof num === 'number');
4029 assert(num < 0x4000000);
4030
4031 // Carry
4032 var carry = 0;
4033 for (var i = 0; i < this.length; i++) {
4034 var w = (this.words[i] | 0) * num;
4035 var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
4036 carry >>= 26;
4037 carry += (w / 0x4000000) | 0;
4038 // NOTE: lo is 27bit maximum
4039 carry += lo >>> 26;
4040 this.words[i] = lo & 0x3ffffff;
4041 }
4042
4043 if (carry !== 0) {
4044 this.words[i] = carry;
4045 this.length++;
4046 }
4047
4048 return this;
4049 };
4050
4051 BN.prototype.muln = function muln (num) {
4052 return this.clone().imuln(num);
4053 };
4054
4055 // `this` * `this`
4056 BN.prototype.sqr = function sqr () {
4057 return this.mul(this);
4058 };
4059
4060 // `this` * `this` in-place
4061 BN.prototype.isqr = function isqr () {
4062 return this.imul(this.clone());
4063 };
4064
4065 // Math.pow(`this`, `num`)
4066 BN.prototype.pow = function pow (num) {
4067 var w = toBitArray(num);
4068 if (w.length === 0) return new BN(1);
4069
4070 // Skip leading zeroes
4071 var res = this;
4072 for (var i = 0; i < w.length; i++, res = res.sqr()) {
4073 if (w[i] !== 0) break;
4074 }
4075
4076 if (++i < w.length) {
4077 for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
4078 if (w[i] === 0) continue;
4079
4080 res = res.mul(q);
4081 }
4082 }
4083
4084 return res;
4085 };
4086
4087 // Shift-left in-place
4088 BN.prototype.iushln = function iushln (bits) {
4089 assert(typeof bits === 'number' && bits >= 0);
4090 var r = bits % 26;
4091 var s = (bits - r) / 26;
4092 var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);
4093 var i;
4094
4095 if (r !== 0) {
4096 var carry = 0;
4097
4098 for (i = 0; i < this.length; i++) {
4099 var newCarry = this.words[i] & carryMask;
4100 var c = ((this.words[i] | 0) - newCarry) << r;
4101 this.words[i] = c | carry;
4102 carry = newCarry >>> (26 - r);
4103 }
4104
4105 if (carry) {
4106 this.words[i] = carry;
4107 this.length++;
4108 }
4109 }
4110
4111 if (s !== 0) {
4112 for (i = this.length - 1; i >= 0; i--) {
4113 this.words[i + s] = this.words[i];
4114 }
4115
4116 for (i = 0; i < s; i++) {
4117 this.words[i] = 0;
4118 }
4119
4120 this.length += s;
4121 }
4122
4123 return this.strip();
4124 };
4125
4126 BN.prototype.ishln = function ishln (bits) {
4127 // TODO(indutny): implement me
4128 assert(this.negative === 0);
4129 return this.iushln(bits);
4130 };
4131
4132 // Shift-right in-place
4133 // NOTE: `hint` is a lowest bit before trailing zeroes
4134 // NOTE: if `extended` is present - it will be filled with destroyed bits
4135 BN.prototype.iushrn = function iushrn (bits, hint, extended) {
4136 assert(typeof bits === 'number' && bits >= 0);
4137 var h;
4138 if (hint) {
4139 h = (hint - (hint % 26)) / 26;
4140 } else {
4141 h = 0;
4142 }
4143
4144 var r = bits % 26;
4145 var s = Math.min((bits - r) / 26, this.length);
4146 var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
4147 var maskedWords = extended;
4148
4149 h -= s;
4150 h = Math.max(0, h);
4151
4152 // Extended mode, copy masked part
4153 if (maskedWords) {
4154 for (var i = 0; i < s; i++) {
4155 maskedWords.words[i] = this.words[i];
4156 }
4157 maskedWords.length = s;
4158 }
4159
4160 if (s === 0) {
4161 // No-op, we should not move anything at all
4162 } else if (this.length > s) {
4163 this.length -= s;
4164 for (i = 0; i < this.length; i++) {
4165 this.words[i] = this.words[i + s];
4166 }
4167 } else {
4168 this.words[0] = 0;
4169 this.length = 1;
4170 }
4171
4172 var carry = 0;
4173 for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
4174 var word = this.words[i] | 0;
4175 this.words[i] = (carry << (26 - r)) | (word >>> r);
4176 carry = word & mask;
4177 }
4178
4179 // Push carried bits as a mask
4180 if (maskedWords && carry !== 0) {
4181 maskedWords.words[maskedWords.length++] = carry;
4182 }
4183
4184 if (this.length === 0) {
4185 this.words[0] = 0;
4186 this.length = 1;
4187 }
4188
4189 return this.strip();
4190 };
4191
4192 BN.prototype.ishrn = function ishrn (bits, hint, extended) {
4193 // TODO(indutny): implement me
4194 assert(this.negative === 0);
4195 return this.iushrn(bits, hint, extended);
4196 };
4197
4198 // Shift-left
4199 BN.prototype.shln = function shln (bits) {
4200 return this.clone().ishln(bits);
4201 };
4202
4203 BN.prototype.ushln = function ushln (bits) {
4204 return this.clone().iushln(bits);
4205 };
4206
4207 // Shift-right
4208 BN.prototype.shrn = function shrn (bits) {
4209 return this.clone().ishrn(bits);
4210 };
4211
4212 BN.prototype.ushrn = function ushrn (bits) {
4213 return this.clone().iushrn(bits);
4214 };
4215
4216 // Test if n bit is set
4217 BN.prototype.testn = function testn (bit) {
4218 assert(typeof bit === 'number' && bit >= 0);
4219 var r = bit % 26;
4220 var s = (bit - r) / 26;
4221 var q = 1 << r;
4222
4223 // Fast case: bit is much higher than all existing words
4224 if (this.length <= s) return false;
4225
4226 // Check bit and return
4227 var w = this.words[s];
4228
4229 return !!(w & q);
4230 };
4231
4232 // Return only lowers bits of number (in-place)
4233 BN.prototype.imaskn = function imaskn (bits) {
4234 assert(typeof bits === 'number' && bits >= 0);
4235 var r = bits % 26;
4236 var s = (bits - r) / 26;
4237
4238 assert(this.negative === 0, 'imaskn works only with positive numbers');
4239
4240 if (this.length <= s) {
4241 return this;
4242 }
4243
4244 if (r !== 0) {
4245 s++;
4246 }
4247 this.length = Math.min(s, this.length);
4248
4249 if (r !== 0) {
4250 var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
4251 this.words[this.length - 1] &= mask;
4252 }
4253
4254 return this.strip();
4255 };
4256
4257 // Return only lowers bits of number
4258 BN.prototype.maskn = function maskn (bits) {
4259 return this.clone().imaskn(bits);
4260 };
4261
4262 // Add plain number `num` to `this`
4263 BN.prototype.iaddn = function iaddn (num) {
4264 assert(typeof num === 'number');
4265 assert(num < 0x4000000);
4266 if (num < 0) return this.isubn(-num);
4267
4268 // Possible sign change
4269 if (this.negative !== 0) {
4270 if (this.length === 1 && (this.words[0] | 0) < num) {
4271 this.words[0] = num - (this.words[0] | 0);
4272 this.negative = 0;
4273 return this;
4274 }
4275
4276 this.negative = 0;
4277 this.isubn(num);
4278 this.negative = 1;
4279 return this;
4280 }
4281
4282 // Add without checks
4283 return this._iaddn(num);
4284 };
4285
4286 BN.prototype._iaddn = function _iaddn (num) {
4287 this.words[0] += num;
4288
4289 // Carry
4290 for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
4291 this.words[i] -= 0x4000000;
4292 if (i === this.length - 1) {
4293 this.words[i + 1] = 1;
4294 } else {
4295 this.words[i + 1]++;
4296 }
4297 }
4298 this.length = Math.max(this.length, i + 1);
4299
4300 return this;
4301 };
4302
4303 // Subtract plain number `num` from `this`
4304 BN.prototype.isubn = function isubn (num) {
4305 assert(typeof num === 'number');
4306 assert(num < 0x4000000);
4307 if (num < 0) return this.iaddn(-num);
4308
4309 if (this.negative !== 0) {
4310 this.negative = 0;
4311 this.iaddn(num);
4312 this.negative = 1;
4313 return this;
4314 }
4315
4316 this.words[0] -= num;
4317
4318 if (this.length === 1 && this.words[0] < 0) {
4319 this.words[0] = -this.words[0];
4320 this.negative = 1;
4321 } else {
4322 // Carry
4323 for (var i = 0; i < this.length && this.words[i] < 0; i++) {
4324 this.words[i] += 0x4000000;
4325 this.words[i + 1] -= 1;
4326 }
4327 }
4328
4329 return this.strip();
4330 };
4331
4332 BN.prototype.addn = function addn (num) {
4333 return this.clone().iaddn(num);
4334 };
4335
4336 BN.prototype.subn = function subn (num) {
4337 return this.clone().isubn(num);
4338 };
4339
4340 BN.prototype.iabs = function iabs () {
4341 this.negative = 0;
4342
4343 return this;
4344 };
4345
4346 BN.prototype.abs = function abs () {
4347 return this.clone().iabs();
4348 };
4349
4350 BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {
4351 var len = num.length + shift;
4352 var i;
4353
4354 this._expand(len);
4355
4356 var w;
4357 var carry = 0;
4358 for (i = 0; i < num.length; i++) {
4359 w = (this.words[i + shift] | 0) + carry;
4360 var right = (num.words[i] | 0) * mul;
4361 w -= right & 0x3ffffff;
4362 carry = (w >> 26) - ((right / 0x4000000) | 0);
4363 this.words[i + shift] = w & 0x3ffffff;
4364 }
4365 for (; i < this.length - shift; i++) {
4366 w = (this.words[i + shift] | 0) + carry;
4367 carry = w >> 26;
4368 this.words[i + shift] = w & 0x3ffffff;
4369 }
4370
4371 if (carry === 0) return this.strip();
4372
4373 // Subtraction overflow
4374 assert(carry === -1);
4375 carry = 0;
4376 for (i = 0; i < this.length; i++) {
4377 w = -(this.words[i] | 0) + carry;
4378 carry = w >> 26;
4379 this.words[i] = w & 0x3ffffff;
4380 }
4381 this.negative = 1;
4382
4383 return this.strip();
4384 };
4385
4386 BN.prototype._wordDiv = function _wordDiv (num, mode) {
4387 var shift = this.length - num.length;
4388
4389 var a = this.clone();
4390 var b = num;
4391
4392 // Normalize
4393 var bhi = b.words[b.length - 1] | 0;
4394 var bhiBits = this._countBits(bhi);
4395 shift = 26 - bhiBits;
4396 if (shift !== 0) {
4397 b = b.ushln(shift);
4398 a.iushln(shift);
4399 bhi = b.words[b.length - 1] | 0;
4400 }
4401
4402 // Initialize quotient
4403 var m = a.length - b.length;
4404 var q;
4405
4406 if (mode !== 'mod') {
4407 q = new BN(null);
4408 q.length = m + 1;
4409 q.words = new Array(q.length);
4410 for (var i = 0; i < q.length; i++) {
4411 q.words[i] = 0;
4412 }
4413 }
4414
4415 var diff = a.clone()._ishlnsubmul(b, 1, m);
4416 if (diff.negative === 0) {
4417 a = diff;
4418 if (q) {
4419 q.words[m] = 1;
4420 }
4421 }
4422
4423 for (var j = m - 1; j >= 0; j--) {
4424 var qj = (a.words[b.length + j] | 0) * 0x4000000 +
4425 (a.words[b.length + j - 1] | 0);
4426
4427 // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
4428 // (0x7ffffff)
4429 qj = Math.min((qj / bhi) | 0, 0x3ffffff);
4430
4431 a._ishlnsubmul(b, qj, j);
4432 while (a.negative !== 0) {
4433 qj--;
4434 a.negative = 0;
4435 a._ishlnsubmul(b, 1, j);
4436 if (!a.isZero()) {
4437 a.negative ^= 1;
4438 }
4439 }
4440 if (q) {
4441 q.words[j] = qj;
4442 }
4443 }
4444 if (q) {
4445 q.strip();
4446 }
4447 a.strip();
4448
4449 // Denormalize
4450 if (mode !== 'div' && shift !== 0) {
4451 a.iushrn(shift);
4452 }
4453
4454 return {
4455 div: q || null,
4456 mod: a
4457 };
4458 };
4459
4460 // NOTE: 1) `mode` can be set to `mod` to request mod only,
4461 // to `div` to request div only, or be absent to
4462 // request both div & mod
4463 // 2) `positive` is true if unsigned mod is requested
4464 BN.prototype.divmod = function divmod (num, mode, positive) {
4465 assert(!num.isZero());
4466
4467 if (this.isZero()) {
4468 return {
4469 div: new BN(0),
4470 mod: new BN(0)
4471 };
4472 }
4473
4474 var div, mod, res;
4475 if (this.negative !== 0 && num.negative === 0) {
4476 res = this.neg().divmod(num, mode);
4477
4478 if (mode !== 'mod') {
4479 div = res.div.neg();
4480 }
4481
4482 if (mode !== 'div') {
4483 mod = res.mod.neg();
4484 if (positive && mod.negative !== 0) {
4485 mod.iadd(num);
4486 }
4487 }
4488
4489 return {
4490 div: div,
4491 mod: mod
4492 };
4493 }
4494
4495 if (this.negative === 0 && num.negative !== 0) {
4496 res = this.divmod(num.neg(), mode);
4497
4498 if (mode !== 'mod') {
4499 div = res.div.neg();
4500 }
4501
4502 return {
4503 div: div,
4504 mod: res.mod
4505 };
4506 }
4507
4508 if ((this.negative & num.negative) !== 0) {
4509 res = this.neg().divmod(num.neg(), mode);
4510
4511 if (mode !== 'div') {
4512 mod = res.mod.neg();
4513 if (positive && mod.negative !== 0) {
4514 mod.isub(num);
4515 }
4516 }
4517
4518 return {
4519 div: res.div,
4520 mod: mod
4521 };
4522 }
4523
4524 // Both numbers are positive at this point
4525
4526 // Strip both numbers to approximate shift value
4527 if (num.length > this.length || this.cmp(num) < 0) {
4528 return {
4529 div: new BN(0),
4530 mod: this
4531 };
4532 }
4533
4534 // Very short reduction
4535 if (num.length === 1) {
4536 if (mode === 'div') {
4537 return {
4538 div: this.divn(num.words[0]),
4539 mod: null
4540 };
4541 }
4542
4543 if (mode === 'mod') {
4544 return {
4545 div: null,
4546 mod: new BN(this.modn(num.words[0]))
4547 };
4548 }
4549
4550 return {
4551 div: this.divn(num.words[0]),
4552 mod: new BN(this.modn(num.words[0]))
4553 };
4554 }
4555
4556 return this._wordDiv(num, mode);
4557 };
4558
4559 // Find `this` / `num`
4560 BN.prototype.div = function div (num) {
4561 return this.divmod(num, 'div', false).div;
4562 };
4563
4564 // Find `this` % `num`
4565 BN.prototype.mod = function mod (num) {
4566 return this.divmod(num, 'mod', false).mod;
4567 };
4568
4569 BN.prototype.umod = function umod (num) {
4570 return this.divmod(num, 'mod', true).mod;
4571 };
4572
4573 // Find Round(`this` / `num`)
4574 BN.prototype.divRound = function divRound (num) {
4575 var dm = this.divmod(num);
4576
4577 // Fast case - exact division
4578 if (dm.mod.isZero()) return dm.div;
4579
4580 var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
4581
4582 var half = num.ushrn(1);
4583 var r2 = num.andln(1);
4584 var cmp = mod.cmp(half);
4585
4586 // Round down
4587 if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
4588
4589 // Round up
4590 return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
4591 };
4592
4593 BN.prototype.modn = function modn (num) {
4594 assert(num <= 0x3ffffff);
4595 var p = (1 << 26) % num;
4596
4597 var acc = 0;
4598 for (var i = this.length - 1; i >= 0; i--) {
4599 acc = (p * acc + (this.words[i] | 0)) % num;
4600 }
4601
4602 return acc;
4603 };
4604
4605 // In-place division by number
4606 BN.prototype.idivn = function idivn (num) {
4607 assert(num <= 0x3ffffff);
4608
4609 var carry = 0;
4610 for (var i = this.length - 1; i >= 0; i--) {
4611 var w = (this.words[i] | 0) + carry * 0x4000000;
4612 this.words[i] = (w / num) | 0;
4613 carry = w % num;
4614 }
4615
4616 return this.strip();
4617 };
4618
4619 BN.prototype.divn = function divn (num) {
4620 return this.clone().idivn(num);
4621 };
4622
4623 BN.prototype.egcd = function egcd (p) {
4624 assert(p.negative === 0);
4625 assert(!p.isZero());
4626
4627 var x = this;
4628 var y = p.clone();
4629
4630 if (x.negative !== 0) {
4631 x = x.umod(p);
4632 } else {
4633 x = x.clone();
4634 }
4635
4636 // A * x + B * y = x
4637 var A = new BN(1);
4638 var B = new BN(0);
4639
4640 // C * x + D * y = y
4641 var C = new BN(0);
4642 var D = new BN(1);
4643
4644 var g = 0;
4645
4646 while (x.isEven() && y.isEven()) {
4647 x.iushrn(1);
4648 y.iushrn(1);
4649 ++g;
4650 }
4651
4652 var yp = y.clone();
4653 var xp = x.clone();
4654
4655 while (!x.isZero()) {
4656 for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
4657 if (i > 0) {
4658 x.iushrn(i);
4659 while (i-- > 0) {
4660 if (A.isOdd() || B.isOdd()) {
4661 A.iadd(yp);
4662 B.isub(xp);
4663 }
4664
4665 A.iushrn(1);
4666 B.iushrn(1);
4667 }
4668 }
4669
4670 for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
4671 if (j > 0) {
4672 y.iushrn(j);
4673 while (j-- > 0) {
4674 if (C.isOdd() || D.isOdd()) {
4675 C.iadd(yp);
4676 D.isub(xp);
4677 }
4678
4679 C.iushrn(1);
4680 D.iushrn(1);
4681 }
4682 }
4683
4684 if (x.cmp(y) >= 0) {
4685 x.isub(y);
4686 A.isub(C);
4687 B.isub(D);
4688 } else {
4689 y.isub(x);
4690 C.isub(A);
4691 D.isub(B);
4692 }
4693 }
4694
4695 return {
4696 a: C,
4697 b: D,
4698 gcd: y.iushln(g)
4699 };
4700 };
4701
4702 // This is reduced incarnation of the binary EEA
4703 // above, designated to invert members of the
4704 // _prime_ fields F(p) at a maximal speed
4705 BN.prototype._invmp = function _invmp (p) {
4706 assert(p.negative === 0);
4707 assert(!p.isZero());
4708
4709 var a = this;
4710 var b = p.clone();
4711
4712 if (a.negative !== 0) {
4713 a = a.umod(p);
4714 } else {
4715 a = a.clone();
4716 }
4717
4718 var x1 = new BN(1);
4719 var x2 = new BN(0);
4720
4721 var delta = b.clone();
4722
4723 while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
4724 for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
4725 if (i > 0) {
4726 a.iushrn(i);
4727 while (i-- > 0) {
4728 if (x1.isOdd()) {
4729 x1.iadd(delta);
4730 }
4731
4732 x1.iushrn(1);
4733 }
4734 }
4735
4736 for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
4737 if (j > 0) {
4738 b.iushrn(j);
4739 while (j-- > 0) {
4740 if (x2.isOdd()) {
4741 x2.iadd(delta);
4742 }
4743
4744 x2.iushrn(1);
4745 }
4746 }
4747
4748 if (a.cmp(b) >= 0) {
4749 a.isub(b);
4750 x1.isub(x2);
4751 } else {
4752 b.isub(a);
4753 x2.isub(x1);
4754 }
4755 }
4756
4757 var res;
4758 if (a.cmpn(1) === 0) {
4759 res = x1;
4760 } else {
4761 res = x2;
4762 }
4763
4764 if (res.cmpn(0) < 0) {
4765 res.iadd(p);
4766 }
4767
4768 return res;
4769 };
4770
4771 BN.prototype.gcd = function gcd (num) {
4772 if (this.isZero()) return num.abs();
4773 if (num.isZero()) return this.abs();
4774
4775 var a = this.clone();
4776 var b = num.clone();
4777 a.negative = 0;
4778 b.negative = 0;
4779
4780 // Remove common factor of two
4781 for (var shift = 0; a.isEven() && b.isEven(); shift++) {
4782 a.iushrn(1);
4783 b.iushrn(1);
4784 }
4785
4786 do {
4787 while (a.isEven()) {
4788 a.iushrn(1);
4789 }
4790 while (b.isEven()) {
4791 b.iushrn(1);
4792 }
4793
4794 var r = a.cmp(b);
4795 if (r < 0) {
4796 // Swap `a` and `b` to make `a` always bigger than `b`
4797 var t = a;
4798 a = b;
4799 b = t;
4800 } else if (r === 0 || b.cmpn(1) === 0) {
4801 break;
4802 }
4803
4804 a.isub(b);
4805 } while (true);
4806
4807 return b.iushln(shift);
4808 };
4809
4810 // Invert number in the field F(num)
4811 BN.prototype.invm = function invm (num) {
4812 return this.egcd(num).a.umod(num);
4813 };
4814
4815 BN.prototype.isEven = function isEven () {
4816 return (this.words[0] & 1) === 0;
4817 };
4818
4819 BN.prototype.isOdd = function isOdd () {
4820 return (this.words[0] & 1) === 1;
4821 };
4822
4823 // And first word and num
4824 BN.prototype.andln = function andln (num) {
4825 return this.words[0] & num;
4826 };
4827
4828 // Increment at the bit position in-line
4829 BN.prototype.bincn = function bincn (bit) {
4830 assert(typeof bit === 'number');
4831 var r = bit % 26;
4832 var s = (bit - r) / 26;
4833 var q = 1 << r;
4834
4835 // Fast case: bit is much higher than all existing words
4836 if (this.length <= s) {
4837 this._expand(s + 1);
4838 this.words[s] |= q;
4839 return this;
4840 }
4841
4842 // Add bit and propagate, if needed
4843 var carry = q;
4844 for (var i = s; carry !== 0 && i < this.length; i++) {
4845 var w = this.words[i] | 0;
4846 w += carry;
4847 carry = w >>> 26;
4848 w &= 0x3ffffff;
4849 this.words[i] = w;
4850 }
4851 if (carry !== 0) {
4852 this.words[i] = carry;
4853 this.length++;
4854 }
4855 return this;
4856 };
4857
4858 BN.prototype.isZero = function isZero () {
4859 return this.length === 1 && this.words[0] === 0;
4860 };
4861
4862 BN.prototype.cmpn = function cmpn (num) {
4863 var negative = num < 0;
4864
4865 if (this.negative !== 0 && !negative) return -1;
4866 if (this.negative === 0 && negative) return 1;
4867
4868 this.strip();
4869
4870 var res;
4871 if (this.length > 1) {
4872 res = 1;
4873 } else {
4874 if (negative) {
4875 num = -num;
4876 }
4877
4878 assert(num <= 0x3ffffff, 'Number is too big');
4879
4880 var w = this.words[0] | 0;
4881 res = w === num ? 0 : w < num ? -1 : 1;
4882 }
4883 if (this.negative !== 0) return -res | 0;
4884 return res;
4885 };
4886
4887 // Compare two numbers and return:
4888 // 1 - if `this` > `num`
4889 // 0 - if `this` == `num`
4890 // -1 - if `this` < `num`
4891 BN.prototype.cmp = function cmp (num) {
4892 if (this.negative !== 0 && num.negative === 0) return -1;
4893 if (this.negative === 0 && num.negative !== 0) return 1;
4894
4895 var res = this.ucmp(num);
4896 if (this.negative !== 0) return -res | 0;
4897 return res;
4898 };
4899
4900 // Unsigned comparison
4901 BN.prototype.ucmp = function ucmp (num) {
4902 // At this point both numbers have the same sign
4903 if (this.length > num.length) return 1;
4904 if (this.length < num.length) return -1;
4905
4906 var res = 0;
4907 for (var i = this.length - 1; i >= 0; i--) {
4908 var a = this.words[i] | 0;
4909 var b = num.words[i] | 0;
4910
4911 if (a === b) continue;
4912 if (a < b) {
4913 res = -1;
4914 } else if (a > b) {
4915 res = 1;
4916 }
4917 break;
4918 }
4919 return res;
4920 };
4921
4922 BN.prototype.gtn = function gtn (num) {
4923 return this.cmpn(num) === 1;
4924 };
4925
4926 BN.prototype.gt = function gt (num) {
4927 return this.cmp(num) === 1;
4928 };
4929
4930 BN.prototype.gten = function gten (num) {
4931 return this.cmpn(num) >= 0;
4932 };
4933
4934 BN.prototype.gte = function gte (num) {
4935 return this.cmp(num) >= 0;
4936 };
4937
4938 BN.prototype.ltn = function ltn (num) {
4939 return this.cmpn(num) === -1;
4940 };
4941
4942 BN.prototype.lt = function lt (num) {
4943 return this.cmp(num) === -1;
4944 };
4945
4946 BN.prototype.lten = function lten (num) {
4947 return this.cmpn(num) <= 0;
4948 };
4949
4950 BN.prototype.lte = function lte (num) {
4951 return this.cmp(num) <= 0;
4952 };
4953
4954 BN.prototype.eqn = function eqn (num) {
4955 return this.cmpn(num) === 0;
4956 };
4957
4958 BN.prototype.eq = function eq (num) {
4959 return this.cmp(num) === 0;
4960 };
4961
4962 //
4963 // A reduce context, could be using montgomery or something better, depending
4964 // on the `m` itself.
4965 //
4966 BN.red = function red (num) {
4967 return new Red(num);
4968 };
4969
4970 BN.prototype.toRed = function toRed (ctx) {
4971 assert(!this.red, 'Already a number in reduction context');
4972 assert(this.negative === 0, 'red works only with positives');
4973 return ctx.convertTo(this)._forceRed(ctx);
4974 };
4975
4976 BN.prototype.fromRed = function fromRed () {
4977 assert(this.red, 'fromRed works only with numbers in reduction context');
4978 return this.red.convertFrom(this);
4979 };
4980
4981 BN.prototype._forceRed = function _forceRed (ctx) {
4982 this.red = ctx;
4983 return this;
4984 };
4985
4986 BN.prototype.forceRed = function forceRed (ctx) {
4987 assert(!this.red, 'Already a number in reduction context');
4988 return this._forceRed(ctx);
4989 };
4990
4991 BN.prototype.redAdd = function redAdd (num) {
4992 assert(this.red, 'redAdd works only with red numbers');
4993 return this.red.add(this, num);
4994 };
4995
4996 BN.prototype.redIAdd = function redIAdd (num) {
4997 assert(this.red, 'redIAdd works only with red numbers');
4998 return this.red.iadd(this, num);
4999 };
5000
5001 BN.prototype.redSub = function redSub (num) {
5002 assert(this.red, 'redSub works only with red numbers');
5003 return this.red.sub(this, num);
5004 };
5005
5006 BN.prototype.redISub = function redISub (num) {
5007 assert(this.red, 'redISub works only with red numbers');
5008 return this.red.isub(this, num);
5009 };
5010
5011 BN.prototype.redShl = function redShl (num) {
5012 assert(this.red, 'redShl works only with red numbers');
5013 return this.red.shl(this, num);
5014 };
5015
5016 BN.prototype.redMul = function redMul (num) {
5017 assert(this.red, 'redMul works only with red numbers');
5018 this.red._verify2(this, num);
5019 return this.red.mul(this, num);
5020 };
5021
5022 BN.prototype.redIMul = function redIMul (num) {
5023 assert(this.red, 'redMul works only with red numbers');
5024 this.red._verify2(this, num);
5025 return this.red.imul(this, num);
5026 };
5027
5028 BN.prototype.redSqr = function redSqr () {
5029 assert(this.red, 'redSqr works only with red numbers');
5030 this.red._verify1(this);
5031 return this.red.sqr(this);
5032 };
5033
5034 BN.prototype.redISqr = function redISqr () {
5035 assert(this.red, 'redISqr works only with red numbers');
5036 this.red._verify1(this);
5037 return this.red.isqr(this);
5038 };
5039
5040 // Square root over p
5041 BN.prototype.redSqrt = function redSqrt () {
5042 assert(this.red, 'redSqrt works only with red numbers');
5043 this.red._verify1(this);
5044 return this.red.sqrt(this);
5045 };
5046
5047 BN.prototype.redInvm = function redInvm () {
5048 assert(this.red, 'redInvm works only with red numbers');
5049 this.red._verify1(this);
5050 return this.red.invm(this);
5051 };
5052
5053 // Return negative clone of `this` % `red modulo`
5054 BN.prototype.redNeg = function redNeg () {
5055 assert(this.red, 'redNeg works only with red numbers');
5056 this.red._verify1(this);
5057 return this.red.neg(this);
5058 };
5059
5060 BN.prototype.redPow = function redPow (num) {
5061 assert(this.red && !num.red, 'redPow(normalNum)');
5062 this.red._verify1(this);
5063 return this.red.pow(this, num);
5064 };
5065
5066 // Prime numbers with efficient reduction
5067 var primes = {
5068 k256: null,
5069 p224: null,
5070 p192: null,
5071 p25519: null
5072 };
5073
5074 // Pseudo-Mersenne prime
5075 function MPrime (name, p) {
5076 // P = 2 ^ N - K
5077 this.name = name;
5078 this.p = new BN(p, 16);
5079 this.n = this.p.bitLength();
5080 this.k = new BN(1).iushln(this.n).isub(this.p);
5081
5082 this.tmp = this._tmp();
5083 }
5084
5085 MPrime.prototype._tmp = function _tmp () {
5086 var tmp = new BN(null);
5087 tmp.words = new Array(Math.ceil(this.n / 13));
5088 return tmp;
5089 };
5090
5091 MPrime.prototype.ireduce = function ireduce (num) {
5092 // Assumes that `num` is less than `P^2`
5093 // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
5094 var r = num;
5095 var rlen;
5096
5097 do {
5098 this.split(r, this.tmp);
5099 r = this.imulK(r);
5100 r = r.iadd(this.tmp);
5101 rlen = r.bitLength();
5102 } while (rlen > this.n);
5103
5104 var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
5105 if (cmp === 0) {
5106 r.words[0] = 0;
5107 r.length = 1;
5108 } else if (cmp > 0) {
5109 r.isub(this.p);
5110 } else {
5111 r.strip();
5112 }
5113
5114 return r;
5115 };
5116
5117 MPrime.prototype.split = function split (input, out) {
5118 input.iushrn(this.n, 0, out);
5119 };
5120
5121 MPrime.prototype.imulK = function imulK (num) {
5122 return num.imul(this.k);
5123 };
5124
5125 function K256 () {
5126 MPrime.call(
5127 this,
5128 'k256',
5129 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
5130 }
5131 inherits(K256, MPrime);
5132
5133 K256.prototype.split = function split (input, output) {
5134 // 256 = 9 * 26 + 22
5135 var mask = 0x3fffff;
5136
5137 var outLen = Math.min(input.length, 9);
5138 for (var i = 0; i < outLen; i++) {
5139 output.words[i] = input.words[i];
5140 }
5141 output.length = outLen;
5142
5143 if (input.length <= 9) {
5144 input.words[0] = 0;
5145 input.length = 1;
5146 return;
5147 }
5148
5149 // Shift by 9 limbs
5150 var prev = input.words[9];
5151 output.words[output.length++] = prev & mask;
5152
5153 for (i = 10; i < input.length; i++) {
5154 var next = input.words[i] | 0;
5155 input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);
5156 prev = next;
5157 }
5158 prev >>>= 22;
5159 input.words[i - 10] = prev;
5160 if (prev === 0 && input.length > 10) {
5161 input.length -= 10;
5162 } else {
5163 input.length -= 9;
5164 }
5165 };
5166
5167 K256.prototype.imulK = function imulK (num) {
5168 // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
5169 num.words[num.length] = 0;
5170 num.words[num.length + 1] = 0;
5171 num.length += 2;
5172
5173 // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
5174 var lo = 0;
5175 for (var i = 0; i < num.length; i++) {
5176 var w = num.words[i] | 0;
5177 lo += w * 0x3d1;
5178 num.words[i] = lo & 0x3ffffff;
5179 lo = w * 0x40 + ((lo / 0x4000000) | 0);
5180 }
5181
5182 // Fast length reduction
5183 if (num.words[num.length - 1] === 0) {
5184 num.length--;
5185 if (num.words[num.length - 1] === 0) {
5186 num.length--;
5187 }
5188 }
5189 return num;
5190 };
5191
5192 function P224 () {
5193 MPrime.call(
5194 this,
5195 'p224',
5196 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
5197 }
5198 inherits(P224, MPrime);
5199
5200 function P192 () {
5201 MPrime.call(
5202 this,
5203 'p192',
5204 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
5205 }
5206 inherits(P192, MPrime);
5207
5208 function P25519 () {
5209 // 2 ^ 255 - 19
5210 MPrime.call(
5211 this,
5212 '25519',
5213 '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
5214 }
5215 inherits(P25519, MPrime);
5216
5217 P25519.prototype.imulK = function imulK (num) {
5218 // K = 0x13
5219 var carry = 0;
5220 for (var i = 0; i < num.length; i++) {
5221 var hi = (num.words[i] | 0) * 0x13 + carry;
5222 var lo = hi & 0x3ffffff;
5223 hi >>>= 26;
5224
5225 num.words[i] = lo;
5226 carry = hi;
5227 }
5228 if (carry !== 0) {
5229 num.words[num.length++] = carry;
5230 }
5231 return num;
5232 };
5233
5234 // Exported mostly for testing purposes, use plain name instead
5235 BN._prime = function prime (name) {
5236 // Cached version of prime
5237 if (primes[name]) return primes[name];
5238
5239 var prime;
5240 if (name === 'k256') {
5241 prime = new K256();
5242 } else if (name === 'p224') {
5243 prime = new P224();
5244 } else if (name === 'p192') {
5245 prime = new P192();
5246 } else if (name === 'p25519') {
5247 prime = new P25519();
5248 } else {
5249 throw new Error('Unknown prime ' + name);
5250 }
5251 primes[name] = prime;
5252
5253 return prime;
5254 };
5255
5256 //
5257 // Base reduction engine
5258 //
5259 function Red (m) {
5260 if (typeof m === 'string') {
5261 var prime = BN._prime(m);
5262 this.m = prime.p;
5263 this.prime = prime;
5264 } else {
5265 assert(m.gtn(1), 'modulus must be greater than 1');
5266 this.m = m;
5267 this.prime = null;
5268 }
5269 }
5270
5271 Red.prototype._verify1 = function _verify1 (a) {
5272 assert(a.negative === 0, 'red works only with positives');
5273 assert(a.red, 'red works only with red numbers');
5274 };
5275
5276 Red.prototype._verify2 = function _verify2 (a, b) {
5277 assert((a.negative | b.negative) === 0, 'red works only with positives');
5278 assert(a.red && a.red === b.red,
5279 'red works only with red numbers');
5280 };
5281
5282 Red.prototype.imod = function imod (a) {
5283 if (this.prime) return this.prime.ireduce(a)._forceRed(this);
5284 return a.umod(this.m)._forceRed(this);
5285 };
5286
5287 Red.prototype.neg = function neg (a) {
5288 if (a.isZero()) {
5289 return a.clone();
5290 }
5291
5292 return this.m.sub(a)._forceRed(this);
5293 };
5294
5295 Red.prototype.add = function add (a, b) {
5296 this._verify2(a, b);
5297
5298 var res = a.add(b);
5299 if (res.cmp(this.m) >= 0) {
5300 res.isub(this.m);
5301 }
5302 return res._forceRed(this);
5303 };
5304
5305 Red.prototype.iadd = function iadd (a, b) {
5306 this._verify2(a, b);
5307
5308 var res = a.iadd(b);
5309 if (res.cmp(this.m) >= 0) {
5310 res.isub(this.m);
5311 }
5312 return res;
5313 };
5314
5315 Red.prototype.sub = function sub (a, b) {
5316 this._verify2(a, b);
5317
5318 var res = a.sub(b);
5319 if (res.cmpn(0) < 0) {
5320 res.iadd(this.m);
5321 }
5322 return res._forceRed(this);
5323 };
5324
5325 Red.prototype.isub = function isub (a, b) {
5326 this._verify2(a, b);
5327
5328 var res = a.isub(b);
5329 if (res.cmpn(0) < 0) {
5330 res.iadd(this.m);
5331 }
5332 return res;
5333 };
5334
5335 Red.prototype.shl = function shl (a, num) {
5336 this._verify1(a);
5337 return this.imod(a.ushln(num));
5338 };
5339
5340 Red.prototype.imul = function imul (a, b) {
5341 this._verify2(a, b);
5342 return this.imod(a.imul(b));
5343 };
5344
5345 Red.prototype.mul = function mul (a, b) {
5346 this._verify2(a, b);
5347 return this.imod(a.mul(b));
5348 };
5349
5350 Red.prototype.isqr = function isqr (a) {
5351 return this.imul(a, a.clone());
5352 };
5353
5354 Red.prototype.sqr = function sqr (a) {
5355 return this.mul(a, a);
5356 };
5357
5358 Red.prototype.sqrt = function sqrt (a) {
5359 if (a.isZero()) return a.clone();
5360
5361 var mod3 = this.m.andln(3);
5362 assert(mod3 % 2 === 1);
5363
5364 // Fast case
5365 if (mod3 === 3) {
5366 var pow = this.m.add(new BN(1)).iushrn(2);
5367 return this.pow(a, pow);
5368 }
5369
5370 // Tonelli-Shanks algorithm (Totally unoptimized and slow)
5371 //
5372 // Find Q and S, that Q * 2 ^ S = (P - 1)
5373 var q = this.m.subn(1);
5374 var s = 0;
5375 while (!q.isZero() && q.andln(1) === 0) {
5376 s++;
5377 q.iushrn(1);
5378 }
5379 assert(!q.isZero());
5380
5381 var one = new BN(1).toRed(this);
5382 var nOne = one.redNeg();
5383
5384 // Find quadratic non-residue
5385 // NOTE: Max is such because of generalized Riemann hypothesis.
5386 var lpow = this.m.subn(1).iushrn(1);
5387 var z = this.m.bitLength();
5388 z = new BN(2 * z * z).toRed(this);
5389
5390 while (this.pow(z, lpow).cmp(nOne) !== 0) {
5391 z.redIAdd(nOne);
5392 }
5393
5394 var c = this.pow(z, q);
5395 var r = this.pow(a, q.addn(1).iushrn(1));
5396 var t = this.pow(a, q);
5397 var m = s;
5398 while (t.cmp(one) !== 0) {
5399 var tmp = t;
5400 for (var i = 0; tmp.cmp(one) !== 0; i++) {
5401 tmp = tmp.redSqr();
5402 }
5403 assert(i < m);
5404 var b = this.pow(c, new BN(1).iushln(m - i - 1));
5405
5406 r = r.redMul(b);
5407 c = b.redSqr();
5408 t = t.redMul(c);
5409 m = i;
5410 }
5411
5412 return r;
5413 };
5414
5415 Red.prototype.invm = function invm (a) {
5416 var inv = a._invmp(this.m);
5417 if (inv.negative !== 0) {
5418 inv.negative = 0;
5419 return this.imod(inv).redNeg();
5420 } else {
5421 return this.imod(inv);
5422 }
5423 };
5424
5425 Red.prototype.pow = function pow (a, num) {
5426 if (num.isZero()) return new BN(1).toRed(this);
5427 if (num.cmpn(1) === 0) return a.clone();
5428
5429 var windowSize = 4;
5430 var wnd = new Array(1 << windowSize);
5431 wnd[0] = new BN(1).toRed(this);
5432 wnd[1] = a;
5433 for (var i = 2; i < wnd.length; i++) {
5434 wnd[i] = this.mul(wnd[i - 1], a);
5435 }
5436
5437 var res = wnd[0];
5438 var current = 0;
5439 var currentLen = 0;
5440 var start = num.bitLength() % 26;
5441 if (start === 0) {
5442 start = 26;
5443 }
5444
5445 for (i = num.length - 1; i >= 0; i--) {
5446 var word = num.words[i];
5447 for (var j = start - 1; j >= 0; j--) {
5448 var bit = (word >> j) & 1;
5449 if (res !== wnd[0]) {
5450 res = this.sqr(res);
5451 }
5452
5453 if (bit === 0 && current === 0) {
5454 currentLen = 0;
5455 continue;
5456 }
5457
5458 current <<= 1;
5459 current |= bit;
5460 currentLen++;
5461 if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
5462
5463 res = this.mul(res, wnd[current]);
5464 currentLen = 0;
5465 current = 0;
5466 }
5467 start = 26;
5468 }
5469
5470 return res;
5471 };
5472
5473 Red.prototype.convertTo = function convertTo (num) {
5474 var r = num.umod(this.m);
5475
5476 return r === num ? r.clone() : r;
5477 };
5478
5479 Red.prototype.convertFrom = function convertFrom (num) {
5480 var res = num.clone();
5481 res.red = null;
5482 return res;
5483 };
5484
5485 //
5486 // Montgomery method engine
5487 //
5488
5489 BN.mont = function mont (num) {
5490 return new Mont(num);
5491 };
5492
5493 function Mont (m) {
5494 Red.call(this, m);
5495
5496 this.shift = this.m.bitLength();
5497 if (this.shift % 26 !== 0) {
5498 this.shift += 26 - (this.shift % 26);
5499 }
5500
5501 this.r = new BN(1).iushln(this.shift);
5502 this.r2 = this.imod(this.r.sqr());
5503 this.rinv = this.r._invmp(this.m);
5504
5505 this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
5506 this.minv = this.minv.umod(this.r);
5507 this.minv = this.r.sub(this.minv);
5508 }
5509 inherits(Mont, Red);
5510
5511 Mont.prototype.convertTo = function convertTo (num) {
5512 return this.imod(num.ushln(this.shift));
5513 };
5514
5515 Mont.prototype.convertFrom = function convertFrom (num) {
5516 var r = this.imod(num.mul(this.rinv));
5517 r.red = null;
5518 return r;
5519 };
5520
5521 Mont.prototype.imul = function imul (a, b) {
5522 if (a.isZero() || b.isZero()) {
5523 a.words[0] = 0;
5524 a.length = 1;
5525 return a;
5526 }
5527
5528 var t = a.imul(b);
5529 var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
5530 var u = t.isub(c).iushrn(this.shift);
5531 var res = u;
5532
5533 if (u.cmp(this.m) >= 0) {
5534 res = u.isub(this.m);
5535 } else if (u.cmpn(0) < 0) {
5536 res = u.iadd(this.m);
5537 }
5538
5539 return res._forceRed(this);
5540 };
5541
5542 Mont.prototype.mul = function mul (a, b) {
5543 if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
5544
5545 var t = a.mul(b);
5546 var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
5547 var u = t.isub(c).iushrn(this.shift);
5548 var res = u;
5549 if (u.cmp(this.m) >= 0) {
5550 res = u.isub(this.m);
5551 } else if (u.cmpn(0) < 0) {
5552 res = u.iadd(this.m);
5553 }
5554
5555 return res._forceRed(this);
5556 };
5557
5558 Mont.prototype.invm = function invm (a) {
5559 // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
5560 var res = this.imod(a._invmp(this.m).mul(this.r2));
5561 return res._forceRed(this);
5562 };
5563})(typeof module === 'undefined' || module, this);
5564
5565},{"buffer":45}],44:[function(require,module,exports){
5566var r;
5567
5568module.exports = function rand(len) {
5569 if (!r)
5570 r = new Rand(null);
5571
5572 return r.generate(len);
5573};
5574
5575function Rand(rand) {
5576 this.rand = rand;
5577}
5578module.exports.Rand = Rand;
5579
5580Rand.prototype.generate = function generate(len) {
5581 return this._rand(len);
5582};
5583
5584// Emulate crypto API using randy
5585Rand.prototype._rand = function _rand(n) {
5586 if (this.rand.getBytes)
5587 return this.rand.getBytes(n);
5588
5589 var res = new Uint8Array(n);
5590 for (var i = 0; i < res.length; i++)
5591 res[i] = this.rand.getByte();
5592 return res;
5593};
5594
5595if (typeof self === 'object') {
5596 if (self.crypto && self.crypto.getRandomValues) {
5597 // Modern browsers
5598 Rand.prototype._rand = function _rand(n) {
5599 var arr = new Uint8Array(n);
5600 self.crypto.getRandomValues(arr);
5601 return arr;
5602 };
5603 } else if (self.msCrypto && self.msCrypto.getRandomValues) {
5604 // IE
5605 Rand.prototype._rand = function _rand(n) {
5606 var arr = new Uint8Array(n);
5607 self.msCrypto.getRandomValues(arr);
5608 return arr;
5609 };
5610
5611 // Safari's WebWorkers do not have `crypto`
5612 } else if (typeof window === 'object') {
5613 // Old junk
5614 Rand.prototype._rand = function() {
5615 throw new Error('Not implemented yet');
5616 };
5617 }
5618} else {
5619 // Node.js or Web worker with no crypto support
5620 try {
5621 var crypto = require('crypto');
5622 if (typeof crypto.randomBytes !== 'function')
5623 throw new Error('Not supported');
5624
5625 Rand.prototype._rand = function _rand(n) {
5626 return crypto.randomBytes(n);
5627 };
5628 } catch (e) {
5629 }
5630}
5631
5632},{"crypto":45}],45:[function(require,module,exports){
5633
5634},{}],46:[function(require,module,exports){
5635// based on the aes implimentation in triple sec
5636// https://github.com/keybase/triplesec
5637// which is in turn based on the one from crypto-js
5638// https://code.google.com/p/crypto-js/
5639
5640var Buffer = require('safe-buffer').Buffer
5641
5642function asUInt32Array (buf) {
5643 if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf)
5644
5645 var len = (buf.length / 4) | 0
5646 var out = new Array(len)
5647
5648 for (var i = 0; i < len; i++) {
5649 out[i] = buf.readUInt32BE(i * 4)
5650 }
5651
5652 return out
5653}
5654
5655function scrubVec (v) {
5656 for (var i = 0; i < v.length; v++) {
5657 v[i] = 0
5658 }
5659}
5660
5661function cryptBlock (M, keySchedule, SUB_MIX, SBOX, nRounds) {
5662 var SUB_MIX0 = SUB_MIX[0]
5663 var SUB_MIX1 = SUB_MIX[1]
5664 var SUB_MIX2 = SUB_MIX[2]
5665 var SUB_MIX3 = SUB_MIX[3]
5666
5667 var s0 = M[0] ^ keySchedule[0]
5668 var s1 = M[1] ^ keySchedule[1]
5669 var s2 = M[2] ^ keySchedule[2]
5670 var s3 = M[3] ^ keySchedule[3]
5671 var t0, t1, t2, t3
5672 var ksRow = 4
5673
5674 for (var round = 1; round < nRounds; round++) {
5675 t0 = SUB_MIX0[s0 >>> 24] ^ SUB_MIX1[(s1 >>> 16) & 0xff] ^ SUB_MIX2[(s2 >>> 8) & 0xff] ^ SUB_MIX3[s3 & 0xff] ^ keySchedule[ksRow++]
5676 t1 = SUB_MIX0[s1 >>> 24] ^ SUB_MIX1[(s2 >>> 16) & 0xff] ^ SUB_MIX2[(s3 >>> 8) & 0xff] ^ SUB_MIX3[s0 & 0xff] ^ keySchedule[ksRow++]
5677 t2 = SUB_MIX0[s2 >>> 24] ^ SUB_MIX1[(s3 >>> 16) & 0xff] ^ SUB_MIX2[(s0 >>> 8) & 0xff] ^ SUB_MIX3[s1 & 0xff] ^ keySchedule[ksRow++]
5678 t3 = SUB_MIX0[s3 >>> 24] ^ SUB_MIX1[(s0 >>> 16) & 0xff] ^ SUB_MIX2[(s1 >>> 8) & 0xff] ^ SUB_MIX3[s2 & 0xff] ^ keySchedule[ksRow++]
5679 s0 = t0
5680 s1 = t1
5681 s2 = t2
5682 s3 = t3
5683 }
5684
5685 t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++]
5686 t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++]
5687 t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++]
5688 t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++]
5689 t0 = t0 >>> 0
5690 t1 = t1 >>> 0
5691 t2 = t2 >>> 0
5692 t3 = t3 >>> 0
5693
5694 return [t0, t1, t2, t3]
5695}
5696
5697// AES constants
5698var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36]
5699var G = (function () {
5700 // Compute double table
5701 var d = new Array(256)
5702 for (var j = 0; j < 256; j++) {
5703 if (j < 128) {
5704 d[j] = j << 1
5705 } else {
5706 d[j] = (j << 1) ^ 0x11b
5707 }
5708 }
5709
5710 var SBOX = []
5711 var INV_SBOX = []
5712 var SUB_MIX = [[], [], [], []]
5713 var INV_SUB_MIX = [[], [], [], []]
5714
5715 // Walk GF(2^8)
5716 var x = 0
5717 var xi = 0
5718 for (var i = 0; i < 256; ++i) {
5719 // Compute sbox
5720 var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4)
5721 sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63
5722 SBOX[x] = sx
5723 INV_SBOX[sx] = x
5724
5725 // Compute multiplication
5726 var x2 = d[x]
5727 var x4 = d[x2]
5728 var x8 = d[x4]
5729
5730 // Compute sub bytes, mix columns tables
5731 var t = (d[sx] * 0x101) ^ (sx * 0x1010100)
5732 SUB_MIX[0][x] = (t << 24) | (t >>> 8)
5733 SUB_MIX[1][x] = (t << 16) | (t >>> 16)
5734 SUB_MIX[2][x] = (t << 8) | (t >>> 24)
5735 SUB_MIX[3][x] = t
5736
5737 // Compute inv sub bytes, inv mix columns tables
5738 t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100)
5739 INV_SUB_MIX[0][sx] = (t << 24) | (t >>> 8)
5740 INV_SUB_MIX[1][sx] = (t << 16) | (t >>> 16)
5741 INV_SUB_MIX[2][sx] = (t << 8) | (t >>> 24)
5742 INV_SUB_MIX[3][sx] = t
5743
5744 if (x === 0) {
5745 x = xi = 1
5746 } else {
5747 x = x2 ^ d[d[d[x8 ^ x2]]]
5748 xi ^= d[d[xi]]
5749 }
5750 }
5751
5752 return {
5753 SBOX: SBOX,
5754 INV_SBOX: INV_SBOX,
5755 SUB_MIX: SUB_MIX,
5756 INV_SUB_MIX: INV_SUB_MIX
5757 }
5758})()
5759
5760function AES (key) {
5761 this._key = asUInt32Array(key)
5762 this._reset()
5763}
5764
5765AES.blockSize = 4 * 4
5766AES.keySize = 256 / 8
5767AES.prototype.blockSize = AES.blockSize
5768AES.prototype.keySize = AES.keySize
5769AES.prototype._reset = function () {
5770 var keyWords = this._key
5771 var keySize = keyWords.length
5772 var nRounds = keySize + 6
5773 var ksRows = (nRounds + 1) * 4
5774
5775 var keySchedule = []
5776 for (var k = 0; k < keySize; k++) {
5777 keySchedule[k] = keyWords[k]
5778 }
5779
5780 for (k = keySize; k < ksRows; k++) {
5781 var t = keySchedule[k - 1]
5782
5783 if (k % keySize === 0) {
5784 t = (t << 8) | (t >>> 24)
5785 t =
5786 (G.SBOX[t >>> 24] << 24) |
5787 (G.SBOX[(t >>> 16) & 0xff] << 16) |
5788 (G.SBOX[(t >>> 8) & 0xff] << 8) |
5789 (G.SBOX[t & 0xff])
5790
5791 t ^= RCON[(k / keySize) | 0] << 24
5792 } else if (keySize > 6 && k % keySize === 4) {
5793 t =
5794 (G.SBOX[t >>> 24] << 24) |
5795 (G.SBOX[(t >>> 16) & 0xff] << 16) |
5796 (G.SBOX[(t >>> 8) & 0xff] << 8) |
5797 (G.SBOX[t & 0xff])
5798 }
5799
5800 keySchedule[k] = keySchedule[k - keySize] ^ t
5801 }
5802
5803 var invKeySchedule = []
5804 for (var ik = 0; ik < ksRows; ik++) {
5805 var ksR = ksRows - ik
5806 var tt = keySchedule[ksR - (ik % 4 ? 0 : 4)]
5807
5808 if (ik < 4 || ksR <= 4) {
5809 invKeySchedule[ik] = tt
5810 } else {
5811 invKeySchedule[ik] =
5812 G.INV_SUB_MIX[0][G.SBOX[tt >>> 24]] ^
5813 G.INV_SUB_MIX[1][G.SBOX[(tt >>> 16) & 0xff]] ^
5814 G.INV_SUB_MIX[2][G.SBOX[(tt >>> 8) & 0xff]] ^
5815 G.INV_SUB_MIX[3][G.SBOX[tt & 0xff]]
5816 }
5817 }
5818
5819 this._nRounds = nRounds
5820 this._keySchedule = keySchedule
5821 this._invKeySchedule = invKeySchedule
5822}
5823
5824AES.prototype.encryptBlockRaw = function (M) {
5825 M = asUInt32Array(M)
5826 return cryptBlock(M, this._keySchedule, G.SUB_MIX, G.SBOX, this._nRounds)
5827}
5828
5829AES.prototype.encryptBlock = function (M) {
5830 var out = this.encryptBlockRaw(M)
5831 var buf = Buffer.allocUnsafe(16)
5832 buf.writeUInt32BE(out[0], 0)
5833 buf.writeUInt32BE(out[1], 4)
5834 buf.writeUInt32BE(out[2], 8)
5835 buf.writeUInt32BE(out[3], 12)
5836 return buf
5837}
5838
5839AES.prototype.decryptBlock = function (M) {
5840 M = asUInt32Array(M)
5841
5842 // swap
5843 var m1 = M[1]
5844 M[1] = M[3]
5845 M[3] = m1
5846
5847 var out = cryptBlock(M, this._invKeySchedule, G.INV_SUB_MIX, G.INV_SBOX, this._nRounds)
5848 var buf = Buffer.allocUnsafe(16)
5849 buf.writeUInt32BE(out[0], 0)
5850 buf.writeUInt32BE(out[3], 4)
5851 buf.writeUInt32BE(out[2], 8)
5852 buf.writeUInt32BE(out[1], 12)
5853 return buf
5854}
5855
5856AES.prototype.scrub = function () {
5857 scrubVec(this._keySchedule)
5858 scrubVec(this._invKeySchedule)
5859 scrubVec(this._key)
5860}
5861
5862module.exports.AES = AES
5863
5864},{"safe-buffer":305}],47:[function(require,module,exports){
5865var aes = require('./aes')
5866var Buffer = require('safe-buffer').Buffer
5867var Transform = require('cipher-base')
5868var inherits = require('inherits')
5869var GHASH = require('./ghash')
5870var xor = require('buffer-xor')
5871var incr32 = require('./incr32')
5872
5873function xorTest (a, b) {
5874 var out = 0
5875 if (a.length !== b.length) out++
5876
5877 var len = Math.min(a.length, b.length)
5878 for (var i = 0; i < len; ++i) {
5879 out += (a[i] ^ b[i])
5880 }
5881
5882 return out
5883}
5884
5885function calcIv (self, iv, ck) {
5886 if (iv.length === 12) {
5887 self._finID = Buffer.concat([iv, Buffer.from([0, 0, 0, 1])])
5888 return Buffer.concat([iv, Buffer.from([0, 0, 0, 2])])
5889 }
5890 var ghash = new GHASH(ck)
5891 var len = iv.length
5892 var toPad = len % 16
5893 ghash.update(iv)
5894 if (toPad) {
5895 toPad = 16 - toPad
5896 ghash.update(Buffer.alloc(toPad, 0))
5897 }
5898 ghash.update(Buffer.alloc(8, 0))
5899 var ivBits = len * 8
5900 var tail = Buffer.alloc(8)
5901 tail.writeUIntBE(ivBits, 0, 8)
5902 ghash.update(tail)
5903 self._finID = ghash.state
5904 var out = Buffer.from(self._finID)
5905 incr32(out)
5906 return out
5907}
5908function StreamCipher (mode, key, iv, decrypt) {
5909 Transform.call(this)
5910
5911 var h = Buffer.alloc(4, 0)
5912
5913 this._cipher = new aes.AES(key)
5914 var ck = this._cipher.encryptBlock(h)
5915 this._ghash = new GHASH(ck)
5916 iv = calcIv(this, iv, ck)
5917
5918 this._prev = Buffer.from(iv)
5919 this._cache = Buffer.allocUnsafe(0)
5920 this._secCache = Buffer.allocUnsafe(0)
5921 this._decrypt = decrypt
5922 this._alen = 0
5923 this._len = 0
5924 this._mode = mode
5925
5926 this._authTag = null
5927 this._called = false
5928}
5929
5930inherits(StreamCipher, Transform)
5931
5932StreamCipher.prototype._update = function (chunk) {
5933 if (!this._called && this._alen) {
5934 var rump = 16 - (this._alen % 16)
5935 if (rump < 16) {
5936 rump = Buffer.alloc(rump, 0)
5937 this._ghash.update(rump)
5938 }
5939 }
5940
5941 this._called = true
5942 var out = this._mode.encrypt(this, chunk)
5943 if (this._decrypt) {
5944 this._ghash.update(chunk)
5945 } else {
5946 this._ghash.update(out)
5947 }
5948 this._len += chunk.length
5949 return out
5950}
5951
5952StreamCipher.prototype._final = function () {
5953 if (this._decrypt && !this._authTag) throw new Error('Unsupported state or unable to authenticate data')
5954
5955 var tag = xor(this._ghash.final(this._alen * 8, this._len * 8), this._cipher.encryptBlock(this._finID))
5956 if (this._decrypt && xorTest(tag, this._authTag)) throw new Error('Unsupported state or unable to authenticate data')
5957
5958 this._authTag = tag
5959 this._cipher.scrub()
5960}
5961
5962StreamCipher.prototype.getAuthTag = function getAuthTag () {
5963 if (this._decrypt || !Buffer.isBuffer(this._authTag)) throw new Error('Attempting to get auth tag in unsupported state')
5964
5965 return this._authTag
5966}
5967
5968StreamCipher.prototype.setAuthTag = function setAuthTag (tag) {
5969 if (!this._decrypt) throw new Error('Attempting to set auth tag in unsupported state')
5970
5971 this._authTag = tag
5972}
5973
5974StreamCipher.prototype.setAAD = function setAAD (buf) {
5975 if (this._called) throw new Error('Attempting to set AAD in unsupported state')
5976
5977 this._ghash.update(buf)
5978 this._alen += buf.length
5979}
5980
5981module.exports = StreamCipher
5982
5983},{"./aes":46,"./ghash":51,"./incr32":52,"buffer-xor":74,"cipher-base":76,"inherits":260,"safe-buffer":305}],48:[function(require,module,exports){
5984var ciphers = require('./encrypter')
5985var deciphers = require('./decrypter')
5986var modes = require('./modes/list.json')
5987
5988function getCiphers () {
5989 return Object.keys(modes)
5990}
5991
5992exports.createCipher = exports.Cipher = ciphers.createCipher
5993exports.createCipheriv = exports.Cipheriv = ciphers.createCipheriv
5994exports.createDecipher = exports.Decipher = deciphers.createDecipher
5995exports.createDecipheriv = exports.Decipheriv = deciphers.createDecipheriv
5996exports.listCiphers = exports.getCiphers = getCiphers
5997
5998},{"./decrypter":49,"./encrypter":50,"./modes/list.json":60}],49:[function(require,module,exports){
5999var AuthCipher = require('./authCipher')
6000var Buffer = require('safe-buffer').Buffer
6001var MODES = require('./modes')
6002var StreamCipher = require('./streamCipher')
6003var Transform = require('cipher-base')
6004var aes = require('./aes')
6005var ebtk = require('evp_bytestokey')
6006var inherits = require('inherits')
6007
6008function Decipher (mode, key, iv) {
6009 Transform.call(this)
6010
6011 this._cache = new Splitter()
6012 this._last = void 0
6013 this._cipher = new aes.AES(key)
6014 this._prev = Buffer.from(iv)
6015 this._mode = mode
6016 this._autopadding = true
6017}
6018
6019inherits(Decipher, Transform)
6020
6021Decipher.prototype._update = function (data) {
6022 this._cache.add(data)
6023 var chunk
6024 var thing
6025 var out = []
6026 while ((chunk = this._cache.get(this._autopadding))) {
6027 thing = this._mode.decrypt(this, chunk)
6028 out.push(thing)
6029 }
6030 return Buffer.concat(out)
6031}
6032
6033Decipher.prototype._final = function () {
6034 var chunk = this._cache.flush()
6035 if (this._autopadding) {
6036 return unpad(this._mode.decrypt(this, chunk))
6037 } else if (chunk) {
6038 throw new Error('data not multiple of block length')
6039 }
6040}
6041
6042Decipher.prototype.setAutoPadding = function (setTo) {
6043 this._autopadding = !!setTo
6044 return this
6045}
6046
6047function Splitter () {
6048 this.cache = Buffer.allocUnsafe(0)
6049}
6050
6051Splitter.prototype.add = function (data) {
6052 this.cache = Buffer.concat([this.cache, data])
6053}
6054
6055Splitter.prototype.get = function (autoPadding) {
6056 var out
6057 if (autoPadding) {
6058 if (this.cache.length > 16) {
6059 out = this.cache.slice(0, 16)
6060 this.cache = this.cache.slice(16)
6061 return out
6062 }
6063 } else {
6064 if (this.cache.length >= 16) {
6065 out = this.cache.slice(0, 16)
6066 this.cache = this.cache.slice(16)
6067 return out
6068 }
6069 }
6070
6071 return null
6072}
6073
6074Splitter.prototype.flush = function () {
6075 if (this.cache.length) return this.cache
6076}
6077
6078function unpad (last) {
6079 var padded = last[15]
6080 var i = -1
6081 while (++i < padded) {
6082 if (last[(i + (16 - padded))] !== padded) {
6083 throw new Error('unable to decrypt data')
6084 }
6085 }
6086 if (padded === 16) return
6087
6088 return last.slice(0, 16 - padded)
6089}
6090
6091function createDecipheriv (suite, password, iv) {
6092 var config = MODES[suite.toLowerCase()]
6093 if (!config) throw new TypeError('invalid suite type')
6094
6095 if (typeof iv === 'string') iv = Buffer.from(iv)
6096 if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length)
6097
6098 if (typeof password === 'string') password = Buffer.from(password)
6099 if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length)
6100
6101 if (config.type === 'stream') {
6102 return new StreamCipher(config.module, password, iv, true)
6103 } else if (config.type === 'auth') {
6104 return new AuthCipher(config.module, password, iv, true)
6105 }
6106
6107 return new Decipher(config.module, password, iv)
6108}
6109
6110function createDecipher (suite, password) {
6111 var config = MODES[suite.toLowerCase()]
6112 if (!config) throw new TypeError('invalid suite type')
6113
6114 var keys = ebtk(password, false, config.key, config.iv)
6115 return createDecipheriv(suite, keys.key, keys.iv)
6116}
6117
6118exports.createDecipher = createDecipher
6119exports.createDecipheriv = createDecipheriv
6120
6121},{"./aes":46,"./authCipher":47,"./modes":59,"./streamCipher":62,"cipher-base":76,"evp_bytestokey":243,"inherits":260,"safe-buffer":305}],50:[function(require,module,exports){
6122var MODES = require('./modes')
6123var AuthCipher = require('./authCipher')
6124var Buffer = require('safe-buffer').Buffer
6125var StreamCipher = require('./streamCipher')
6126var Transform = require('cipher-base')
6127var aes = require('./aes')
6128var ebtk = require('evp_bytestokey')
6129var inherits = require('inherits')
6130
6131function Cipher (mode, key, iv) {
6132 Transform.call(this)
6133
6134 this._cache = new Splitter()
6135 this._cipher = new aes.AES(key)
6136 this._prev = Buffer.from(iv)
6137 this._mode = mode
6138 this._autopadding = true
6139}
6140
6141inherits(Cipher, Transform)
6142
6143Cipher.prototype._update = function (data) {
6144 this._cache.add(data)
6145 var chunk
6146 var thing
6147 var out = []
6148
6149 while ((chunk = this._cache.get())) {
6150 thing = this._mode.encrypt(this, chunk)
6151 out.push(thing)
6152 }
6153
6154 return Buffer.concat(out)
6155}
6156
6157var PADDING = Buffer.alloc(16, 0x10)
6158
6159Cipher.prototype._final = function () {
6160 var chunk = this._cache.flush()
6161 if (this._autopadding) {
6162 chunk = this._mode.encrypt(this, chunk)
6163 this._cipher.scrub()
6164 return chunk
6165 }
6166
6167 if (!chunk.equals(PADDING)) {
6168 this._cipher.scrub()
6169 throw new Error('data not multiple of block length')
6170 }
6171}
6172
6173Cipher.prototype.setAutoPadding = function (setTo) {
6174 this._autopadding = !!setTo
6175 return this
6176}
6177
6178function Splitter () {
6179 this.cache = Buffer.allocUnsafe(0)
6180}
6181
6182Splitter.prototype.add = function (data) {
6183 this.cache = Buffer.concat([this.cache, data])
6184}
6185
6186Splitter.prototype.get = function () {
6187 if (this.cache.length > 15) {
6188 var out = this.cache.slice(0, 16)
6189 this.cache = this.cache.slice(16)
6190 return out
6191 }
6192 return null
6193}
6194
6195Splitter.prototype.flush = function () {
6196 var len = 16 - this.cache.length
6197 var padBuff = Buffer.allocUnsafe(len)
6198
6199 var i = -1
6200 while (++i < len) {
6201 padBuff.writeUInt8(len, i)
6202 }
6203
6204 return Buffer.concat([this.cache, padBuff])
6205}
6206
6207function createCipheriv (suite, password, iv) {
6208 var config = MODES[suite.toLowerCase()]
6209 if (!config) throw new TypeError('invalid suite type')
6210
6211 if (typeof password === 'string') password = Buffer.from(password)
6212 if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length)
6213
6214 if (typeof iv === 'string') iv = Buffer.from(iv)
6215 if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length)
6216
6217 if (config.type === 'stream') {
6218 return new StreamCipher(config.module, password, iv)
6219 } else if (config.type === 'auth') {
6220 return new AuthCipher(config.module, password, iv)
6221 }
6222
6223 return new Cipher(config.module, password, iv)
6224}
6225
6226function createCipher (suite, password) {
6227 var config = MODES[suite.toLowerCase()]
6228 if (!config) throw new TypeError('invalid suite type')
6229
6230 var keys = ebtk(password, false, config.key, config.iv)
6231 return createCipheriv(suite, keys.key, keys.iv)
6232}
6233
6234exports.createCipheriv = createCipheriv
6235exports.createCipher = createCipher
6236
6237},{"./aes":46,"./authCipher":47,"./modes":59,"./streamCipher":62,"cipher-base":76,"evp_bytestokey":243,"inherits":260,"safe-buffer":305}],51:[function(require,module,exports){
6238var Buffer = require('safe-buffer').Buffer
6239var ZEROES = Buffer.alloc(16, 0)
6240
6241function toArray (buf) {
6242 return [
6243 buf.readUInt32BE(0),
6244 buf.readUInt32BE(4),
6245 buf.readUInt32BE(8),
6246 buf.readUInt32BE(12)
6247 ]
6248}
6249
6250function fromArray (out) {
6251 var buf = Buffer.allocUnsafe(16)
6252 buf.writeUInt32BE(out[0] >>> 0, 0)
6253 buf.writeUInt32BE(out[1] >>> 0, 4)
6254 buf.writeUInt32BE(out[2] >>> 0, 8)
6255 buf.writeUInt32BE(out[3] >>> 0, 12)
6256 return buf
6257}
6258
6259function GHASH (key) {
6260 this.h = key
6261 this.state = Buffer.alloc(16, 0)
6262 this.cache = Buffer.allocUnsafe(0)
6263}
6264
6265// from http://bitwiseshiftleft.github.io/sjcl/doc/symbols/src/core_gcm.js.html
6266// by Juho Vähä-Herttua
6267GHASH.prototype.ghash = function (block) {
6268 var i = -1
6269 while (++i < block.length) {
6270 this.state[i] ^= block[i]
6271 }
6272 this._multiply()
6273}
6274
6275GHASH.prototype._multiply = function () {
6276 var Vi = toArray(this.h)
6277 var Zi = [0, 0, 0, 0]
6278 var j, xi, lsbVi
6279 var i = -1
6280 while (++i < 128) {
6281 xi = (this.state[~~(i / 8)] & (1 << (7 - (i % 8)))) !== 0
6282 if (xi) {
6283 // Z_i+1 = Z_i ^ V_i
6284 Zi[0] ^= Vi[0]
6285 Zi[1] ^= Vi[1]
6286 Zi[2] ^= Vi[2]
6287 Zi[3] ^= Vi[3]
6288 }
6289
6290 // Store the value of LSB(V_i)
6291 lsbVi = (Vi[3] & 1) !== 0
6292
6293 // V_i+1 = V_i >> 1
6294 for (j = 3; j > 0; j--) {
6295 Vi[j] = (Vi[j] >>> 1) | ((Vi[j - 1] & 1) << 31)
6296 }
6297 Vi[0] = Vi[0] >>> 1
6298
6299 // If LSB(V_i) is 1, V_i+1 = (V_i >> 1) ^ R
6300 if (lsbVi) {
6301 Vi[0] = Vi[0] ^ (0xe1 << 24)
6302 }
6303 }
6304 this.state = fromArray(Zi)
6305}
6306
6307GHASH.prototype.update = function (buf) {
6308 this.cache = Buffer.concat([this.cache, buf])
6309 var chunk
6310 while (this.cache.length >= 16) {
6311 chunk = this.cache.slice(0, 16)
6312 this.cache = this.cache.slice(16)
6313 this.ghash(chunk)
6314 }
6315}
6316
6317GHASH.prototype.final = function (abl, bl) {
6318 if (this.cache.length) {
6319 this.ghash(Buffer.concat([this.cache, ZEROES], 16))
6320 }
6321
6322 this.ghash(fromArray([0, abl, 0, bl]))
6323 return this.state
6324}
6325
6326module.exports = GHASH
6327
6328},{"safe-buffer":305}],52:[function(require,module,exports){
6329function incr32 (iv) {
6330 var len = iv.length
6331 var item
6332 while (len--) {
6333 item = iv.readUInt8(len)
6334 if (item === 255) {
6335 iv.writeUInt8(0, len)
6336 } else {
6337 item++
6338 iv.writeUInt8(item, len)
6339 break
6340 }
6341 }
6342}
6343module.exports = incr32
6344
6345},{}],53:[function(require,module,exports){
6346var xor = require('buffer-xor')
6347
6348exports.encrypt = function (self, block) {
6349 var data = xor(block, self._prev)
6350
6351 self._prev = self._cipher.encryptBlock(data)
6352 return self._prev
6353}
6354
6355exports.decrypt = function (self, block) {
6356 var pad = self._prev
6357
6358 self._prev = block
6359 var out = self._cipher.decryptBlock(block)
6360
6361 return xor(out, pad)
6362}
6363
6364},{"buffer-xor":74}],54:[function(require,module,exports){
6365var Buffer = require('safe-buffer').Buffer
6366var xor = require('buffer-xor')
6367
6368function encryptStart (self, data, decrypt) {
6369 var len = data.length
6370 var out = xor(data, self._cache)
6371 self._cache = self._cache.slice(len)
6372 self._prev = Buffer.concat([self._prev, decrypt ? data : out])
6373 return out
6374}
6375
6376exports.encrypt = function (self, data, decrypt) {
6377 var out = Buffer.allocUnsafe(0)
6378 var len
6379
6380 while (data.length) {
6381 if (self._cache.length === 0) {
6382 self._cache = self._cipher.encryptBlock(self._prev)
6383 self._prev = Buffer.allocUnsafe(0)
6384 }
6385
6386 if (self._cache.length <= data.length) {
6387 len = self._cache.length
6388 out = Buffer.concat([out, encryptStart(self, data.slice(0, len), decrypt)])
6389 data = data.slice(len)
6390 } else {
6391 out = Buffer.concat([out, encryptStart(self, data, decrypt)])
6392 break
6393 }
6394 }
6395
6396 return out
6397}
6398
6399},{"buffer-xor":74,"safe-buffer":305}],55:[function(require,module,exports){
6400var Buffer = require('safe-buffer').Buffer
6401
6402function encryptByte (self, byteParam, decrypt) {
6403 var pad
6404 var i = -1
6405 var len = 8
6406 var out = 0
6407 var bit, value
6408 while (++i < len) {
6409 pad = self._cipher.encryptBlock(self._prev)
6410 bit = (byteParam & (1 << (7 - i))) ? 0x80 : 0
6411 value = pad[0] ^ bit
6412 out += ((value & 0x80) >> (i % 8))
6413 self._prev = shiftIn(self._prev, decrypt ? bit : value)
6414 }
6415 return out
6416}
6417
6418function shiftIn (buffer, value) {
6419 var len = buffer.length
6420 var i = -1
6421 var out = Buffer.allocUnsafe(buffer.length)
6422 buffer = Buffer.concat([buffer, Buffer.from([value])])
6423
6424 while (++i < len) {
6425 out[i] = buffer[i] << 1 | buffer[i + 1] >> (7)
6426 }
6427
6428 return out
6429}
6430
6431exports.encrypt = function (self, chunk, decrypt) {
6432 var len = chunk.length
6433 var out = Buffer.allocUnsafe(len)
6434 var i = -1
6435
6436 while (++i < len) {
6437 out[i] = encryptByte(self, chunk[i], decrypt)
6438 }
6439
6440 return out
6441}
6442
6443},{"safe-buffer":305}],56:[function(require,module,exports){
6444var Buffer = require('safe-buffer').Buffer
6445
6446function encryptByte (self, byteParam, decrypt) {
6447 var pad = self._cipher.encryptBlock(self._prev)
6448 var out = pad[0] ^ byteParam
6449
6450 self._prev = Buffer.concat([
6451 self._prev.slice(1),
6452 Buffer.from([decrypt ? byteParam : out])
6453 ])
6454
6455 return out
6456}
6457
6458exports.encrypt = function (self, chunk, decrypt) {
6459 var len = chunk.length
6460 var out = Buffer.allocUnsafe(len)
6461 var i = -1
6462
6463 while (++i < len) {
6464 out[i] = encryptByte(self, chunk[i], decrypt)
6465 }
6466
6467 return out
6468}
6469
6470},{"safe-buffer":305}],57:[function(require,module,exports){
6471var xor = require('buffer-xor')
6472var Buffer = require('safe-buffer').Buffer
6473var incr32 = require('../incr32')
6474
6475function getBlock (self) {
6476 var out = self._cipher.encryptBlockRaw(self._prev)
6477 incr32(self._prev)
6478 return out
6479}
6480
6481var blockSize = 16
6482exports.encrypt = function (self, chunk) {
6483 var chunkNum = Math.ceil(chunk.length / blockSize)
6484 var start = self._cache.length
6485 self._cache = Buffer.concat([
6486 self._cache,
6487 Buffer.allocUnsafe(chunkNum * blockSize)
6488 ])
6489 for (var i = 0; i < chunkNum; i++) {
6490 var out = getBlock(self)
6491 var offset = start + i * blockSize
6492 self._cache.writeUInt32BE(out[0], offset + 0)
6493 self._cache.writeUInt32BE(out[1], offset + 4)
6494 self._cache.writeUInt32BE(out[2], offset + 8)
6495 self._cache.writeUInt32BE(out[3], offset + 12)
6496 }
6497 var pad = self._cache.slice(0, chunk.length)
6498 self._cache = self._cache.slice(chunk.length)
6499 return xor(chunk, pad)
6500}
6501
6502},{"../incr32":52,"buffer-xor":74,"safe-buffer":305}],58:[function(require,module,exports){
6503exports.encrypt = function (self, block) {
6504 return self._cipher.encryptBlock(block)
6505}
6506
6507exports.decrypt = function (self, block) {
6508 return self._cipher.decryptBlock(block)
6509}
6510
6511},{}],59:[function(require,module,exports){
6512var modeModules = {
6513 ECB: require('./ecb'),
6514 CBC: require('./cbc'),
6515 CFB: require('./cfb'),
6516 CFB8: require('./cfb8'),
6517 CFB1: require('./cfb1'),
6518 OFB: require('./ofb'),
6519 CTR: require('./ctr'),
6520 GCM: require('./ctr')
6521}
6522
6523var modes = require('./list.json')
6524
6525for (var key in modes) {
6526 modes[key].module = modeModules[modes[key].mode]
6527}
6528
6529module.exports = modes
6530
6531},{"./cbc":53,"./cfb":54,"./cfb1":55,"./cfb8":56,"./ctr":57,"./ecb":58,"./list.json":60,"./ofb":61}],60:[function(require,module,exports){
6532module.exports={
6533 "aes-128-ecb": {
6534 "cipher": "AES",
6535 "key": 128,
6536 "iv": 0,
6537 "mode": "ECB",
6538 "type": "block"
6539 },
6540 "aes-192-ecb": {
6541 "cipher": "AES",
6542 "key": 192,
6543 "iv": 0,
6544 "mode": "ECB",
6545 "type": "block"
6546 },
6547 "aes-256-ecb": {
6548 "cipher": "AES",
6549 "key": 256,
6550 "iv": 0,
6551 "mode": "ECB",
6552 "type": "block"
6553 },
6554 "aes-128-cbc": {
6555 "cipher": "AES",
6556 "key": 128,
6557 "iv": 16,
6558 "mode": "CBC",
6559 "type": "block"
6560 },
6561 "aes-192-cbc": {
6562 "cipher": "AES",
6563 "key": 192,
6564 "iv": 16,
6565 "mode": "CBC",
6566 "type": "block"
6567 },
6568 "aes-256-cbc": {
6569 "cipher": "AES",
6570 "key": 256,
6571 "iv": 16,
6572 "mode": "CBC",
6573 "type": "block"
6574 },
6575 "aes128": {
6576 "cipher": "AES",
6577 "key": 128,
6578 "iv": 16,
6579 "mode": "CBC",
6580 "type": "block"
6581 },
6582 "aes192": {
6583 "cipher": "AES",
6584 "key": 192,
6585 "iv": 16,
6586 "mode": "CBC",
6587 "type": "block"
6588 },
6589 "aes256": {
6590 "cipher": "AES",
6591 "key": 256,
6592 "iv": 16,
6593 "mode": "CBC",
6594 "type": "block"
6595 },
6596 "aes-128-cfb": {
6597 "cipher": "AES",
6598 "key": 128,
6599 "iv": 16,
6600 "mode": "CFB",
6601 "type": "stream"
6602 },
6603 "aes-192-cfb": {
6604 "cipher": "AES",
6605 "key": 192,
6606 "iv": 16,
6607 "mode": "CFB",
6608 "type": "stream"
6609 },
6610 "aes-256-cfb": {
6611 "cipher": "AES",
6612 "key": 256,
6613 "iv": 16,
6614 "mode": "CFB",
6615 "type": "stream"
6616 },
6617 "aes-128-cfb8": {
6618 "cipher": "AES",
6619 "key": 128,
6620 "iv": 16,
6621 "mode": "CFB8",
6622 "type": "stream"
6623 },
6624 "aes-192-cfb8": {
6625 "cipher": "AES",
6626 "key": 192,
6627 "iv": 16,
6628 "mode": "CFB8",
6629 "type": "stream"
6630 },
6631 "aes-256-cfb8": {
6632 "cipher": "AES",
6633 "key": 256,
6634 "iv": 16,
6635 "mode": "CFB8",
6636 "type": "stream"
6637 },
6638 "aes-128-cfb1": {
6639 "cipher": "AES",
6640 "key": 128,
6641 "iv": 16,
6642 "mode": "CFB1",
6643 "type": "stream"
6644 },
6645 "aes-192-cfb1": {
6646 "cipher": "AES",
6647 "key": 192,
6648 "iv": 16,
6649 "mode": "CFB1",
6650 "type": "stream"
6651 },
6652 "aes-256-cfb1": {
6653 "cipher": "AES",
6654 "key": 256,
6655 "iv": 16,
6656 "mode": "CFB1",
6657 "type": "stream"
6658 },
6659 "aes-128-ofb": {
6660 "cipher": "AES",
6661 "key": 128,
6662 "iv": 16,
6663 "mode": "OFB",
6664 "type": "stream"
6665 },
6666 "aes-192-ofb": {
6667 "cipher": "AES",
6668 "key": 192,
6669 "iv": 16,
6670 "mode": "OFB",
6671 "type": "stream"
6672 },
6673 "aes-256-ofb": {
6674 "cipher": "AES",
6675 "key": 256,
6676 "iv": 16,
6677 "mode": "OFB",
6678 "type": "stream"
6679 },
6680 "aes-128-ctr": {
6681 "cipher": "AES",
6682 "key": 128,
6683 "iv": 16,
6684 "mode": "CTR",
6685 "type": "stream"
6686 },
6687 "aes-192-ctr": {
6688 "cipher": "AES",
6689 "key": 192,
6690 "iv": 16,
6691 "mode": "CTR",
6692 "type": "stream"
6693 },
6694 "aes-256-ctr": {
6695 "cipher": "AES",
6696 "key": 256,
6697 "iv": 16,
6698 "mode": "CTR",
6699 "type": "stream"
6700 },
6701 "aes-128-gcm": {
6702 "cipher": "AES",
6703 "key": 128,
6704 "iv": 12,
6705 "mode": "GCM",
6706 "type": "auth"
6707 },
6708 "aes-192-gcm": {
6709 "cipher": "AES",
6710 "key": 192,
6711 "iv": 12,
6712 "mode": "GCM",
6713 "type": "auth"
6714 },
6715 "aes-256-gcm": {
6716 "cipher": "AES",
6717 "key": 256,
6718 "iv": 12,
6719 "mode": "GCM",
6720 "type": "auth"
6721 }
6722}
6723
6724},{}],61:[function(require,module,exports){
6725(function (Buffer){
6726var xor = require('buffer-xor')
6727
6728function getBlock (self) {
6729 self._prev = self._cipher.encryptBlock(self._prev)
6730 return self._prev
6731}
6732
6733exports.encrypt = function (self, chunk) {
6734 while (self._cache.length < chunk.length) {
6735 self._cache = Buffer.concat([self._cache, getBlock(self)])
6736 }
6737
6738 var pad = self._cache.slice(0, chunk.length)
6739 self._cache = self._cache.slice(chunk.length)
6740 return xor(chunk, pad)
6741}
6742
6743}).call(this,require("buffer").Buffer)
6744},{"buffer":75,"buffer-xor":74}],62:[function(require,module,exports){
6745var aes = require('./aes')
6746var Buffer = require('safe-buffer').Buffer
6747var Transform = require('cipher-base')
6748var inherits = require('inherits')
6749
6750function StreamCipher (mode, key, iv, decrypt) {
6751 Transform.call(this)
6752
6753 this._cipher = new aes.AES(key)
6754 this._prev = Buffer.from(iv)
6755 this._cache = Buffer.allocUnsafe(0)
6756 this._secCache = Buffer.allocUnsafe(0)
6757 this._decrypt = decrypt
6758 this._mode = mode
6759}
6760
6761inherits(StreamCipher, Transform)
6762
6763StreamCipher.prototype._update = function (chunk) {
6764 return this._mode.encrypt(this, chunk, this._decrypt)
6765}
6766
6767StreamCipher.prototype._final = function () {
6768 this._cipher.scrub()
6769}
6770
6771module.exports = StreamCipher
6772
6773},{"./aes":46,"cipher-base":76,"inherits":260,"safe-buffer":305}],63:[function(require,module,exports){
6774var ebtk = require('evp_bytestokey')
6775var aes = require('browserify-aes/browser')
6776var DES = require('browserify-des')
6777var desModes = require('browserify-des/modes')
6778var aesModes = require('browserify-aes/modes')
6779function createCipher (suite, password) {
6780 var keyLen, ivLen
6781 suite = suite.toLowerCase()
6782 if (aesModes[suite]) {
6783 keyLen = aesModes[suite].key
6784 ivLen = aesModes[suite].iv
6785 } else if (desModes[suite]) {
6786 keyLen = desModes[suite].key * 8
6787 ivLen = desModes[suite].iv
6788 } else {
6789 throw new TypeError('invalid suite type')
6790 }
6791 var keys = ebtk(password, false, keyLen, ivLen)
6792 return createCipheriv(suite, keys.key, keys.iv)
6793}
6794function createDecipher (suite, password) {
6795 var keyLen, ivLen
6796 suite = suite.toLowerCase()
6797 if (aesModes[suite]) {
6798 keyLen = aesModes[suite].key
6799 ivLen = aesModes[suite].iv
6800 } else if (desModes[suite]) {
6801 keyLen = desModes[suite].key * 8
6802 ivLen = desModes[suite].iv
6803 } else {
6804 throw new TypeError('invalid suite type')
6805 }
6806 var keys = ebtk(password, false, keyLen, ivLen)
6807 return createDecipheriv(suite, keys.key, keys.iv)
6808}
6809
6810function createCipheriv (suite, key, iv) {
6811 suite = suite.toLowerCase()
6812 if (aesModes[suite]) {
6813 return aes.createCipheriv(suite, key, iv)
6814 } else if (desModes[suite]) {
6815 return new DES({
6816 key: key,
6817 iv: iv,
6818 mode: suite
6819 })
6820 } else {
6821 throw new TypeError('invalid suite type')
6822 }
6823}
6824function createDecipheriv (suite, key, iv) {
6825 suite = suite.toLowerCase()
6826 if (aesModes[suite]) {
6827 return aes.createDecipheriv(suite, key, iv)
6828 } else if (desModes[suite]) {
6829 return new DES({
6830 key: key,
6831 iv: iv,
6832 mode: suite,
6833 decrypt: true
6834 })
6835 } else {
6836 throw new TypeError('invalid suite type')
6837 }
6838}
6839exports.createCipher = exports.Cipher = createCipher
6840exports.createCipheriv = exports.Cipheriv = createCipheriv
6841exports.createDecipher = exports.Decipher = createDecipher
6842exports.createDecipheriv = exports.Decipheriv = createDecipheriv
6843function getCiphers () {
6844 return Object.keys(desModes).concat(aes.getCiphers())
6845}
6846exports.listCiphers = exports.getCiphers = getCiphers
6847
6848},{"browserify-aes/browser":48,"browserify-aes/modes":59,"browserify-des":64,"browserify-des/modes":65,"evp_bytestokey":243}],64:[function(require,module,exports){
6849(function (Buffer){
6850var CipherBase = require('cipher-base')
6851var des = require('des.js')
6852var inherits = require('inherits')
6853
6854var modes = {
6855 'des-ede3-cbc': des.CBC.instantiate(des.EDE),
6856 'des-ede3': des.EDE,
6857 'des-ede-cbc': des.CBC.instantiate(des.EDE),
6858 'des-ede': des.EDE,
6859 'des-cbc': des.CBC.instantiate(des.DES),
6860 'des-ecb': des.DES
6861}
6862modes.des = modes['des-cbc']
6863modes.des3 = modes['des-ede3-cbc']
6864module.exports = DES
6865inherits(DES, CipherBase)
6866function DES (opts) {
6867 CipherBase.call(this)
6868 var modeName = opts.mode.toLowerCase()
6869 var mode = modes[modeName]
6870 var type
6871 if (opts.decrypt) {
6872 type = 'decrypt'
6873 } else {
6874 type = 'encrypt'
6875 }
6876 var key = opts.key
6877 if (modeName === 'des-ede' || modeName === 'des-ede-cbc') {
6878 key = Buffer.concat([key, key.slice(0, 8)])
6879 }
6880 var iv = opts.iv
6881 this._des = mode.create({
6882 key: key,
6883 iv: iv,
6884 type: type
6885 })
6886}
6887DES.prototype._update = function (data) {
6888 return new Buffer(this._des.update(data))
6889}
6890DES.prototype._final = function () {
6891 return new Buffer(this._des.final())
6892}
6893
6894}).call(this,require("buffer").Buffer)
6895},{"buffer":75,"cipher-base":76,"des.js":216,"inherits":260}],65:[function(require,module,exports){
6896exports['des-ecb'] = {
6897 key: 8,
6898 iv: 0
6899}
6900exports['des-cbc'] = exports.des = {
6901 key: 8,
6902 iv: 8
6903}
6904exports['des-ede3-cbc'] = exports.des3 = {
6905 key: 24,
6906 iv: 8
6907}
6908exports['des-ede3'] = {
6909 key: 24,
6910 iv: 0
6911}
6912exports['des-ede-cbc'] = {
6913 key: 16,
6914 iv: 8
6915}
6916exports['des-ede'] = {
6917 key: 16,
6918 iv: 0
6919}
6920
6921},{}],66:[function(require,module,exports){
6922(function (Buffer){
6923var bn = require('bn.js');
6924var randomBytes = require('randombytes');
6925module.exports = crt;
6926function blind(priv) {
6927 var r = getr(priv);
6928 var blinder = r.toRed(bn.mont(priv.modulus))
6929 .redPow(new bn(priv.publicExponent)).fromRed();
6930 return {
6931 blinder: blinder,
6932 unblinder:r.invm(priv.modulus)
6933 };
6934}
6935function crt(msg, priv) {
6936 var blinds = blind(priv);
6937 var len = priv.modulus.byteLength();
6938 var mod = bn.mont(priv.modulus);
6939 var blinded = new bn(msg).mul(blinds.blinder).umod(priv.modulus);
6940 var c1 = blinded.toRed(bn.mont(priv.prime1));
6941 var c2 = blinded.toRed(bn.mont(priv.prime2));
6942 var qinv = priv.coefficient;
6943 var p = priv.prime1;
6944 var q = priv.prime2;
6945 var m1 = c1.redPow(priv.exponent1);
6946 var m2 = c2.redPow(priv.exponent2);
6947 m1 = m1.fromRed();
6948 m2 = m2.fromRed();
6949 var h = m1.isub(m2).imul(qinv).umod(p);
6950 h.imul(q);
6951 m2.iadd(h);
6952 return new Buffer(m2.imul(blinds.unblinder).umod(priv.modulus).toArray(false, len));
6953}
6954crt.getr = getr;
6955function getr(priv) {
6956 var len = priv.modulus.byteLength();
6957 var r = new bn(randomBytes(len));
6958 while (r.cmp(priv.modulus) >= 0 || !r.umod(priv.prime1) || !r.umod(priv.prime2)) {
6959 r = new bn(randomBytes(len));
6960 }
6961 return r;
6962}
6963
6964}).call(this,require("buffer").Buffer)
6965},{"bn.js":43,"buffer":75,"randombytes":288}],67:[function(require,module,exports){
6966module.exports = require('./browser/algorithms.json')
6967
6968},{"./browser/algorithms.json":68}],68:[function(require,module,exports){
6969module.exports={
6970 "sha224WithRSAEncryption": {
6971 "sign": "rsa",
6972 "hash": "sha224",
6973 "id": "302d300d06096086480165030402040500041c"
6974 },
6975 "RSA-SHA224": {
6976 "sign": "ecdsa/rsa",
6977 "hash": "sha224",
6978 "id": "302d300d06096086480165030402040500041c"
6979 },
6980 "sha256WithRSAEncryption": {
6981 "sign": "rsa",
6982 "hash": "sha256",
6983 "id": "3031300d060960864801650304020105000420"
6984 },
6985 "RSA-SHA256": {
6986 "sign": "ecdsa/rsa",
6987 "hash": "sha256",
6988 "id": "3031300d060960864801650304020105000420"
6989 },
6990 "sha384WithRSAEncryption": {
6991 "sign": "rsa",
6992 "hash": "sha384",
6993 "id": "3041300d060960864801650304020205000430"
6994 },
6995 "RSA-SHA384": {
6996 "sign": "ecdsa/rsa",
6997 "hash": "sha384",
6998 "id": "3041300d060960864801650304020205000430"
6999 },
7000 "sha512WithRSAEncryption": {
7001 "sign": "rsa",
7002 "hash": "sha512",
7003 "id": "3051300d060960864801650304020305000440"
7004 },
7005 "RSA-SHA512": {
7006 "sign": "ecdsa/rsa",
7007 "hash": "sha512",
7008 "id": "3051300d060960864801650304020305000440"
7009 },
7010 "RSA-SHA1": {
7011 "sign": "rsa",
7012 "hash": "sha1",
7013 "id": "3021300906052b0e03021a05000414"
7014 },
7015 "ecdsa-with-SHA1": {
7016 "sign": "ecdsa",
7017 "hash": "sha1",
7018 "id": ""
7019 },
7020 "sha256": {
7021 "sign": "ecdsa",
7022 "hash": "sha256",
7023 "id": ""
7024 },
7025 "sha224": {
7026 "sign": "ecdsa",
7027 "hash": "sha224",
7028 "id": ""
7029 },
7030 "sha384": {
7031 "sign": "ecdsa",
7032 "hash": "sha384",
7033 "id": ""
7034 },
7035 "sha512": {
7036 "sign": "ecdsa",
7037 "hash": "sha512",
7038 "id": ""
7039 },
7040 "DSA-SHA": {
7041 "sign": "dsa",
7042 "hash": "sha1",
7043 "id": ""
7044 },
7045 "DSA-SHA1": {
7046 "sign": "dsa",
7047 "hash": "sha1",
7048 "id": ""
7049 },
7050 "DSA": {
7051 "sign": "dsa",
7052 "hash": "sha1",
7053 "id": ""
7054 },
7055 "DSA-WITH-SHA224": {
7056 "sign": "dsa",
7057 "hash": "sha224",
7058 "id": ""
7059 },
7060 "DSA-SHA224": {
7061 "sign": "dsa",
7062 "hash": "sha224",
7063 "id": ""
7064 },
7065 "DSA-WITH-SHA256": {
7066 "sign": "dsa",
7067 "hash": "sha256",
7068 "id": ""
7069 },
7070 "DSA-SHA256": {
7071 "sign": "dsa",
7072 "hash": "sha256",
7073 "id": ""
7074 },
7075 "DSA-WITH-SHA384": {
7076 "sign": "dsa",
7077 "hash": "sha384",
7078 "id": ""
7079 },
7080 "DSA-SHA384": {
7081 "sign": "dsa",
7082 "hash": "sha384",
7083 "id": ""
7084 },
7085 "DSA-WITH-SHA512": {
7086 "sign": "dsa",
7087 "hash": "sha512",
7088 "id": ""
7089 },
7090 "DSA-SHA512": {
7091 "sign": "dsa",
7092 "hash": "sha512",
7093 "id": ""
7094 },
7095 "DSA-RIPEMD160": {
7096 "sign": "dsa",
7097 "hash": "rmd160",
7098 "id": ""
7099 },
7100 "ripemd160WithRSA": {
7101 "sign": "rsa",
7102 "hash": "rmd160",
7103 "id": "3021300906052b2403020105000414"
7104 },
7105 "RSA-RIPEMD160": {
7106 "sign": "rsa",
7107 "hash": "rmd160",
7108 "id": "3021300906052b2403020105000414"
7109 },
7110 "md5WithRSAEncryption": {
7111 "sign": "rsa",
7112 "hash": "md5",
7113 "id": "3020300c06082a864886f70d020505000410"
7114 },
7115 "RSA-MD5": {
7116 "sign": "rsa",
7117 "hash": "md5",
7118 "id": "3020300c06082a864886f70d020505000410"
7119 }
7120}
7121
7122},{}],69:[function(require,module,exports){
7123module.exports={
7124 "1.3.132.0.10": "secp256k1",
7125 "1.3.132.0.33": "p224",
7126 "1.2.840.10045.3.1.1": "p192",
7127 "1.2.840.10045.3.1.7": "p256",
7128 "1.3.132.0.34": "p384",
7129 "1.3.132.0.35": "p521"
7130}
7131
7132},{}],70:[function(require,module,exports){
7133(function (Buffer){
7134var createHash = require('create-hash')
7135var stream = require('stream')
7136var inherits = require('inherits')
7137var sign = require('./sign')
7138var verify = require('./verify')
7139
7140var algorithms = require('./algorithms.json')
7141Object.keys(algorithms).forEach(function (key) {
7142 algorithms[key].id = new Buffer(algorithms[key].id, 'hex')
7143 algorithms[key.toLowerCase()] = algorithms[key]
7144})
7145
7146function Sign (algorithm) {
7147 stream.Writable.call(this)
7148
7149 var data = algorithms[algorithm]
7150 if (!data) throw new Error('Unknown message digest')
7151
7152 this._hashType = data.hash
7153 this._hash = createHash(data.hash)
7154 this._tag = data.id
7155 this._signType = data.sign
7156}
7157inherits(Sign, stream.Writable)
7158
7159Sign.prototype._write = function _write (data, _, done) {
7160 this._hash.update(data)
7161 done()
7162}
7163
7164Sign.prototype.update = function update (data, enc) {
7165 if (typeof data === 'string') data = new Buffer(data, enc)
7166
7167 this._hash.update(data)
7168 return this
7169}
7170
7171Sign.prototype.sign = function signMethod (key, enc) {
7172 this.end()
7173 var hash = this._hash.digest()
7174 var sig = sign(hash, key, this._hashType, this._signType, this._tag)
7175
7176 return enc ? sig.toString(enc) : sig
7177}
7178
7179function Verify (algorithm) {
7180 stream.Writable.call(this)
7181
7182 var data = algorithms[algorithm]
7183 if (!data) throw new Error('Unknown message digest')
7184
7185 this._hash = createHash(data.hash)
7186 this._tag = data.id
7187 this._signType = data.sign
7188}
7189inherits(Verify, stream.Writable)
7190
7191Verify.prototype._write = function _write (data, _, done) {
7192 this._hash.update(data)
7193 done()
7194}
7195
7196Verify.prototype.update = function update (data, enc) {
7197 if (typeof data === 'string') data = new Buffer(data, enc)
7198
7199 this._hash.update(data)
7200 return this
7201}
7202
7203Verify.prototype.verify = function verifyMethod (key, sig, enc) {
7204 if (typeof sig === 'string') sig = new Buffer(sig, enc)
7205
7206 this.end()
7207 var hash = this._hash.digest()
7208 return verify(sig, hash, key, this._signType, this._tag)
7209}
7210
7211function createSign (algorithm) {
7212 return new Sign(algorithm)
7213}
7214
7215function createVerify (algorithm) {
7216 return new Verify(algorithm)
7217}
7218
7219module.exports = {
7220 Sign: createSign,
7221 Verify: createVerify,
7222 createSign: createSign,
7223 createVerify: createVerify
7224}
7225
7226}).call(this,require("buffer").Buffer)
7227},{"./algorithms.json":68,"./sign":71,"./verify":72,"buffer":75,"create-hash":210,"inherits":260,"stream":314}],71:[function(require,module,exports){
7228(function (Buffer){
7229// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
7230var createHmac = require('create-hmac')
7231var crt = require('browserify-rsa')
7232var EC = require('elliptic').ec
7233var BN = require('bn.js')
7234var parseKeys = require('parse-asn1')
7235var curves = require('./curves.json')
7236
7237function sign (hash, key, hashType, signType, tag) {
7238 var priv = parseKeys(key)
7239 if (priv.curve) {
7240 // rsa keys can be interpreted as ecdsa ones in openssl
7241 if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type')
7242 return ecSign(hash, priv)
7243 } else if (priv.type === 'dsa') {
7244 if (signType !== 'dsa') throw new Error('wrong private key type')
7245 return dsaSign(hash, priv, hashType)
7246 } else {
7247 if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type')
7248 }
7249 hash = Buffer.concat([tag, hash])
7250 var len = priv.modulus.byteLength()
7251 var pad = [ 0, 1 ]
7252 while (hash.length + pad.length + 1 < len) pad.push(0xff)
7253 pad.push(0x00)
7254 var i = -1
7255 while (++i < hash.length) pad.push(hash[i])
7256
7257 var out = crt(pad, priv)
7258 return out
7259}
7260
7261function ecSign (hash, priv) {
7262 var curveId = curves[priv.curve.join('.')]
7263 if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.'))
7264
7265 var curve = new EC(curveId)
7266 var key = curve.keyFromPrivate(priv.privateKey)
7267 var out = key.sign(hash)
7268
7269 return new Buffer(out.toDER())
7270}
7271
7272function dsaSign (hash, priv, algo) {
7273 var x = priv.params.priv_key
7274 var p = priv.params.p
7275 var q = priv.params.q
7276 var g = priv.params.g
7277 var r = new BN(0)
7278 var k
7279 var H = bits2int(hash, q).mod(q)
7280 var s = false
7281 var kv = getKey(x, q, hash, algo)
7282 while (s === false) {
7283 k = makeKey(q, kv, algo)
7284 r = makeR(g, k, p, q)
7285 s = k.invm(q).imul(H.add(x.mul(r))).mod(q)
7286 if (s.cmpn(0) === 0) {
7287 s = false
7288 r = new BN(0)
7289 }
7290 }
7291 return toDER(r, s)
7292}
7293
7294function toDER (r, s) {
7295 r = r.toArray()
7296 s = s.toArray()
7297
7298 // Pad values
7299 if (r[0] & 0x80) r = [ 0 ].concat(r)
7300 if (s[0] & 0x80) s = [ 0 ].concat(s)
7301
7302 var total = r.length + s.length + 4
7303 var res = [ 0x30, total, 0x02, r.length ]
7304 res = res.concat(r, [ 0x02, s.length ], s)
7305 return new Buffer(res)
7306}
7307
7308function getKey (x, q, hash, algo) {
7309 x = new Buffer(x.toArray())
7310 if (x.length < q.byteLength()) {
7311 var zeros = new Buffer(q.byteLength() - x.length)
7312 zeros.fill(0)
7313 x = Buffer.concat([ zeros, x ])
7314 }
7315 var hlen = hash.length
7316 var hbits = bits2octets(hash, q)
7317 var v = new Buffer(hlen)
7318 v.fill(1)
7319 var k = new Buffer(hlen)
7320 k.fill(0)
7321 k = createHmac(algo, k).update(v).update(new Buffer([ 0 ])).update(x).update(hbits).digest()
7322 v = createHmac(algo, k).update(v).digest()
7323 k = createHmac(algo, k).update(v).update(new Buffer([ 1 ])).update(x).update(hbits).digest()
7324 v = createHmac(algo, k).update(v).digest()
7325 return { k: k, v: v }
7326}
7327
7328function bits2int (obits, q) {
7329 var bits = new BN(obits)
7330 var shift = (obits.length << 3) - q.bitLength()
7331 if (shift > 0) bits.ishrn(shift)
7332 return bits
7333}
7334
7335function bits2octets (bits, q) {
7336 bits = bits2int(bits, q)
7337 bits = bits.mod(q)
7338 var out = new Buffer(bits.toArray())
7339 if (out.length < q.byteLength()) {
7340 var zeros = new Buffer(q.byteLength() - out.length)
7341 zeros.fill(0)
7342 out = Buffer.concat([ zeros, out ])
7343 }
7344 return out
7345}
7346
7347function makeKey (q, kv, algo) {
7348 var t
7349 var k
7350
7351 do {
7352 t = new Buffer(0)
7353
7354 while (t.length * 8 < q.bitLength()) {
7355 kv.v = createHmac(algo, kv.k).update(kv.v).digest()
7356 t = Buffer.concat([ t, kv.v ])
7357 }
7358
7359 k = bits2int(t, q)
7360 kv.k = createHmac(algo, kv.k).update(kv.v).update(new Buffer([ 0 ])).digest()
7361 kv.v = createHmac(algo, kv.k).update(kv.v).digest()
7362 } while (k.cmp(q) !== -1)
7363
7364 return k
7365}
7366
7367function makeR (g, k, p, q) {
7368 return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q)
7369}
7370
7371module.exports = sign
7372module.exports.getKey = getKey
7373module.exports.makeKey = makeKey
7374
7375}).call(this,require("buffer").Buffer)
7376},{"./curves.json":69,"bn.js":43,"browserify-rsa":66,"buffer":75,"create-hmac":213,"elliptic":226,"parse-asn1":273}],72:[function(require,module,exports){
7377(function (Buffer){
7378// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
7379var BN = require('bn.js')
7380var EC = require('elliptic').ec
7381var parseKeys = require('parse-asn1')
7382var curves = require('./curves.json')
7383
7384function verify (sig, hash, key, signType, tag) {
7385 var pub = parseKeys(key)
7386 if (pub.type === 'ec') {
7387 // rsa keys can be interpreted as ecdsa ones in openssl
7388 if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type')
7389 return ecVerify(sig, hash, pub)
7390 } else if (pub.type === 'dsa') {
7391 if (signType !== 'dsa') throw new Error('wrong public key type')
7392 return dsaVerify(sig, hash, pub)
7393 } else {
7394 if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type')
7395 }
7396 hash = Buffer.concat([tag, hash])
7397 var len = pub.modulus.byteLength()
7398 var pad = [ 1 ]
7399 var padNum = 0
7400 while (hash.length + pad.length + 2 < len) {
7401 pad.push(0xff)
7402 padNum++
7403 }
7404 pad.push(0x00)
7405 var i = -1
7406 while (++i < hash.length) {
7407 pad.push(hash[i])
7408 }
7409 pad = new Buffer(pad)
7410 var red = BN.mont(pub.modulus)
7411 sig = new BN(sig).toRed(red)
7412
7413 sig = sig.redPow(new BN(pub.publicExponent))
7414 sig = new Buffer(sig.fromRed().toArray())
7415 var out = padNum < 8 ? 1 : 0
7416 len = Math.min(sig.length, pad.length)
7417 if (sig.length !== pad.length) out = 1
7418
7419 i = -1
7420 while (++i < len) out |= sig[i] ^ pad[i]
7421 return out === 0
7422}
7423
7424function ecVerify (sig, hash, pub) {
7425 var curveId = curves[pub.data.algorithm.curve.join('.')]
7426 if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.'))
7427
7428 var curve = new EC(curveId)
7429 var pubkey = pub.data.subjectPrivateKey.data
7430
7431 return curve.verify(hash, sig, pubkey)
7432}
7433
7434function dsaVerify (sig, hash, pub) {
7435 var p = pub.data.p
7436 var q = pub.data.q
7437 var g = pub.data.g
7438 var y = pub.data.pub_key
7439 var unpacked = parseKeys.signature.decode(sig, 'der')
7440 var s = unpacked.s
7441 var r = unpacked.r
7442 checkValue(s, q)
7443 checkValue(r, q)
7444 var montp = BN.mont(p)
7445 var w = s.invm(q)
7446 var v = g.toRed(montp)
7447 .redPow(new BN(hash).mul(w).mod(q))
7448 .fromRed()
7449 .mul(y.toRed(montp).redPow(r.mul(w).mod(q)).fromRed())
7450 .mod(p)
7451 .mod(q)
7452 return v.cmp(r) === 0
7453}
7454
7455function checkValue (b, q) {
7456 if (b.cmpn(0) <= 0) throw new Error('invalid sig')
7457 if (b.cmp(q) >= q) throw new Error('invalid sig')
7458}
7459
7460module.exports = verify
7461
7462}).call(this,require("buffer").Buffer)
7463},{"./curves.json":69,"bn.js":43,"buffer":75,"elliptic":226,"parse-asn1":273}],73:[function(require,module,exports){
7464arguments[4][45][0].apply(exports,arguments)
7465},{"dup":45}],74:[function(require,module,exports){
7466(function (Buffer){
7467module.exports = function xor (a, b) {
7468 var length = Math.min(a.length, b.length)
7469 var buffer = new Buffer(length)
7470
7471 for (var i = 0; i < length; ++i) {
7472 buffer[i] = a[i] ^ b[i]
7473 }
7474
7475 return buffer
7476}
7477
7478}).call(this,require("buffer").Buffer)
7479},{"buffer":75}],75:[function(require,module,exports){
7480(function (global){
7481/*!
7482 * The buffer module from node.js, for the browser.
7483 *
7484 * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
7485 * @license MIT
7486 */
7487/* eslint-disable no-proto */
7488
7489'use strict'
7490
7491var base64 = require('base64-js')
7492var ieee754 = require('ieee754')
7493var isArray = require('isarray')
7494
7495exports.Buffer = Buffer
7496exports.SlowBuffer = SlowBuffer
7497exports.INSPECT_MAX_BYTES = 50
7498
7499/**
7500 * If `Buffer.TYPED_ARRAY_SUPPORT`:
7501 * === true Use Uint8Array implementation (fastest)
7502 * === false Use Object implementation (most compatible, even IE6)
7503 *
7504 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
7505 * Opera 11.6+, iOS 4.2+.
7506 *
7507 * Due to various browser bugs, sometimes the Object implementation will be used even
7508 * when the browser supports typed arrays.
7509 *
7510 * Note:
7511 *
7512 * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
7513 * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
7514 *
7515 * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
7516 *
7517 * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
7518 * incorrect length in some situations.
7519
7520 * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
7521 * get the Object implementation, which is slower but behaves correctly.
7522 */
7523Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
7524 ? global.TYPED_ARRAY_SUPPORT
7525 : typedArraySupport()
7526
7527/*
7528 * Export kMaxLength after typed array support is determined.
7529 */
7530exports.kMaxLength = kMaxLength()
7531
7532function typedArraySupport () {
7533 try {
7534 var arr = new Uint8Array(1)
7535 arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
7536 return arr.foo() === 42 && // typed array instances can be augmented
7537 typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
7538 arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
7539 } catch (e) {
7540 return false
7541 }
7542}
7543
7544function kMaxLength () {
7545 return Buffer.TYPED_ARRAY_SUPPORT
7546 ? 0x7fffffff
7547 : 0x3fffffff
7548}
7549
7550function createBuffer (that, length) {
7551 if (kMaxLength() < length) {
7552 throw new RangeError('Invalid typed array length')
7553 }
7554 if (Buffer.TYPED_ARRAY_SUPPORT) {
7555 // Return an augmented `Uint8Array` instance, for best performance
7556 that = new Uint8Array(length)
7557 that.__proto__ = Buffer.prototype
7558 } else {
7559 // Fallback: Return an object instance of the Buffer class
7560 if (that === null) {
7561 that = new Buffer(length)
7562 }
7563 that.length = length
7564 }
7565
7566 return that
7567}
7568
7569/**
7570 * The Buffer constructor returns instances of `Uint8Array` that have their
7571 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
7572 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
7573 * and the `Uint8Array` methods. Square bracket notation works as expected -- it
7574 * returns a single octet.
7575 *
7576 * The `Uint8Array` prototype remains unmodified.
7577 */
7578
7579function Buffer (arg, encodingOrOffset, length) {
7580 if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
7581 return new Buffer(arg, encodingOrOffset, length)
7582 }
7583
7584 // Common case.
7585 if (typeof arg === 'number') {
7586 if (typeof encodingOrOffset === 'string') {
7587 throw new Error(
7588 'If encoding is specified then the first argument must be a string'
7589 )
7590 }
7591 return allocUnsafe(this, arg)
7592 }
7593 return from(this, arg, encodingOrOffset, length)
7594}
7595
7596Buffer.poolSize = 8192 // not used by this implementation
7597
7598// TODO: Legacy, not needed anymore. Remove in next major version.
7599Buffer._augment = function (arr) {
7600 arr.__proto__ = Buffer.prototype
7601 return arr
7602}
7603
7604function from (that, value, encodingOrOffset, length) {
7605 if (typeof value === 'number') {
7606 throw new TypeError('"value" argument must not be a number')
7607 }
7608
7609 if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
7610 return fromArrayBuffer(that, value, encodingOrOffset, length)
7611 }
7612
7613 if (typeof value === 'string') {
7614 return fromString(that, value, encodingOrOffset)
7615 }
7616
7617 return fromObject(that, value)
7618}
7619
7620/**
7621 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
7622 * if value is a number.
7623 * Buffer.from(str[, encoding])
7624 * Buffer.from(array)
7625 * Buffer.from(buffer)
7626 * Buffer.from(arrayBuffer[, byteOffset[, length]])
7627 **/
7628Buffer.from = function (value, encodingOrOffset, length) {
7629 return from(null, value, encodingOrOffset, length)
7630}
7631
7632if (Buffer.TYPED_ARRAY_SUPPORT) {
7633 Buffer.prototype.__proto__ = Uint8Array.prototype
7634 Buffer.__proto__ = Uint8Array
7635 if (typeof Symbol !== 'undefined' && Symbol.species &&
7636 Buffer[Symbol.species] === Buffer) {
7637 // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
7638 Object.defineProperty(Buffer, Symbol.species, {
7639 value: null,
7640 configurable: true
7641 })
7642 }
7643}
7644
7645function assertSize (size) {
7646 if (typeof size !== 'number') {
7647 throw new TypeError('"size" argument must be a number')
7648 } else if (size < 0) {
7649 throw new RangeError('"size" argument must not be negative')
7650 }
7651}
7652
7653function alloc (that, size, fill, encoding) {
7654 assertSize(size)
7655 if (size <= 0) {
7656 return createBuffer(that, size)
7657 }
7658 if (fill !== undefined) {
7659 // Only pay attention to encoding if it's a string. This
7660 // prevents accidentally sending in a number that would
7661 // be interpretted as a start offset.
7662 return typeof encoding === 'string'
7663 ? createBuffer(that, size).fill(fill, encoding)
7664 : createBuffer(that, size).fill(fill)
7665 }
7666 return createBuffer(that, size)
7667}
7668
7669/**
7670 * Creates a new filled Buffer instance.
7671 * alloc(size[, fill[, encoding]])
7672 **/
7673Buffer.alloc = function (size, fill, encoding) {
7674 return alloc(null, size, fill, encoding)
7675}
7676
7677function allocUnsafe (that, size) {
7678 assertSize(size)
7679 that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
7680 if (!Buffer.TYPED_ARRAY_SUPPORT) {
7681 for (var i = 0; i < size; ++i) {
7682 that[i] = 0
7683 }
7684 }
7685 return that
7686}
7687
7688/**
7689 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
7690 * */
7691Buffer.allocUnsafe = function (size) {
7692 return allocUnsafe(null, size)
7693}
7694/**
7695 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
7696 */
7697Buffer.allocUnsafeSlow = function (size) {
7698 return allocUnsafe(null, size)
7699}
7700
7701function fromString (that, string, encoding) {
7702 if (typeof encoding !== 'string' || encoding === '') {
7703 encoding = 'utf8'
7704 }
7705
7706 if (!Buffer.isEncoding(encoding)) {
7707 throw new TypeError('"encoding" must be a valid string encoding')
7708 }
7709
7710 var length = byteLength(string, encoding) | 0
7711 that = createBuffer(that, length)
7712
7713 var actual = that.write(string, encoding)
7714
7715 if (actual !== length) {
7716 // Writing a hex string, for example, that contains invalid characters will
7717 // cause everything after the first invalid character to be ignored. (e.g.
7718 // 'abxxcd' will be treated as 'ab')
7719 that = that.slice(0, actual)
7720 }
7721
7722 return that
7723}
7724
7725function fromArrayLike (that, array) {
7726 var length = array.length < 0 ? 0 : checked(array.length) | 0
7727 that = createBuffer(that, length)
7728 for (var i = 0; i < length; i += 1) {
7729 that[i] = array[i] & 255
7730 }
7731 return that
7732}
7733
7734function fromArrayBuffer (that, array, byteOffset, length) {
7735 array.byteLength // this throws if `array` is not a valid ArrayBuffer
7736
7737 if (byteOffset < 0 || array.byteLength < byteOffset) {
7738 throw new RangeError('\'offset\' is out of bounds')
7739 }
7740
7741 if (array.byteLength < byteOffset + (length || 0)) {
7742 throw new RangeError('\'length\' is out of bounds')
7743 }
7744
7745 if (byteOffset === undefined && length === undefined) {
7746 array = new Uint8Array(array)
7747 } else if (length === undefined) {
7748 array = new Uint8Array(array, byteOffset)
7749 } else {
7750 array = new Uint8Array(array, byteOffset, length)
7751 }
7752
7753 if (Buffer.TYPED_ARRAY_SUPPORT) {
7754 // Return an augmented `Uint8Array` instance, for best performance
7755 that = array
7756 that.__proto__ = Buffer.prototype
7757 } else {
7758 // Fallback: Return an object instance of the Buffer class
7759 that = fromArrayLike(that, array)
7760 }
7761 return that
7762}
7763
7764function fromObject (that, obj) {
7765 if (Buffer.isBuffer(obj)) {
7766 var len = checked(obj.length) | 0
7767 that = createBuffer(that, len)
7768
7769 if (that.length === 0) {
7770 return that
7771 }
7772
7773 obj.copy(that, 0, 0, len)
7774 return that
7775 }
7776
7777 if (obj) {
7778 if ((typeof ArrayBuffer !== 'undefined' &&
7779 obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
7780 if (typeof obj.length !== 'number' || isnan(obj.length)) {
7781 return createBuffer(that, 0)
7782 }
7783 return fromArrayLike(that, obj)
7784 }
7785
7786 if (obj.type === 'Buffer' && isArray(obj.data)) {
7787 return fromArrayLike(that, obj.data)
7788 }
7789 }
7790
7791 throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
7792}
7793
7794function checked (length) {
7795 // Note: cannot use `length < kMaxLength()` here because that fails when
7796 // length is NaN (which is otherwise coerced to zero.)
7797 if (length >= kMaxLength()) {
7798 throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
7799 'size: 0x' + kMaxLength().toString(16) + ' bytes')
7800 }
7801 return length | 0
7802}
7803
7804function SlowBuffer (length) {
7805 if (+length != length) { // eslint-disable-line eqeqeq
7806 length = 0
7807 }
7808 return Buffer.alloc(+length)
7809}
7810
7811Buffer.isBuffer = function isBuffer (b) {
7812 return !!(b != null && b._isBuffer)
7813}
7814
7815Buffer.compare = function compare (a, b) {
7816 if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
7817 throw new TypeError('Arguments must be Buffers')
7818 }
7819
7820 if (a === b) return 0
7821
7822 var x = a.length
7823 var y = b.length
7824
7825 for (var i = 0, len = Math.min(x, y); i < len; ++i) {
7826 if (a[i] !== b[i]) {
7827 x = a[i]
7828 y = b[i]
7829 break
7830 }
7831 }
7832
7833 if (x < y) return -1
7834 if (y < x) return 1
7835 return 0
7836}
7837
7838Buffer.isEncoding = function isEncoding (encoding) {
7839 switch (String(encoding).toLowerCase()) {
7840 case 'hex':
7841 case 'utf8':
7842 case 'utf-8':
7843 case 'ascii':
7844 case 'latin1':
7845 case 'binary':
7846 case 'base64':
7847 case 'ucs2':
7848 case 'ucs-2':
7849 case 'utf16le':
7850 case 'utf-16le':
7851 return true
7852 default:
7853 return false
7854 }
7855}
7856
7857Buffer.concat = function concat (list, length) {
7858 if (!isArray(list)) {
7859 throw new TypeError('"list" argument must be an Array of Buffers')
7860 }
7861
7862 if (list.length === 0) {
7863 return Buffer.alloc(0)
7864 }
7865
7866 var i
7867 if (length === undefined) {
7868 length = 0
7869 for (i = 0; i < list.length; ++i) {
7870 length += list[i].length
7871 }
7872 }
7873
7874 var buffer = Buffer.allocUnsafe(length)
7875 var pos = 0
7876 for (i = 0; i < list.length; ++i) {
7877 var buf = list[i]
7878 if (!Buffer.isBuffer(buf)) {
7879 throw new TypeError('"list" argument must be an Array of Buffers')
7880 }
7881 buf.copy(buffer, pos)
7882 pos += buf.length
7883 }
7884 return buffer
7885}
7886
7887function byteLength (string, encoding) {
7888 if (Buffer.isBuffer(string)) {
7889 return string.length
7890 }
7891 if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
7892 (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
7893 return string.byteLength
7894 }
7895 if (typeof string !== 'string') {
7896 string = '' + string
7897 }
7898
7899 var len = string.length
7900 if (len === 0) return 0
7901
7902 // Use a for loop to avoid recursion
7903 var loweredCase = false
7904 for (;;) {
7905 switch (encoding) {
7906 case 'ascii':
7907 case 'latin1':
7908 case 'binary':
7909 return len
7910 case 'utf8':
7911 case 'utf-8':
7912 case undefined:
7913 return utf8ToBytes(string).length
7914 case 'ucs2':
7915 case 'ucs-2':
7916 case 'utf16le':
7917 case 'utf-16le':
7918 return len * 2
7919 case 'hex':
7920 return len >>> 1
7921 case 'base64':
7922 return base64ToBytes(string).length
7923 default:
7924 if (loweredCase) return utf8ToBytes(string).length // assume utf8
7925 encoding = ('' + encoding).toLowerCase()
7926 loweredCase = true
7927 }
7928 }
7929}
7930Buffer.byteLength = byteLength
7931
7932function slowToString (encoding, start, end) {
7933 var loweredCase = false
7934
7935 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
7936 // property of a typed array.
7937
7938 // This behaves neither like String nor Uint8Array in that we set start/end
7939 // to their upper/lower bounds if the value passed is out of range.
7940 // undefined is handled specially as per ECMA-262 6th Edition,
7941 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
7942 if (start === undefined || start < 0) {
7943 start = 0
7944 }
7945 // Return early if start > this.length. Done here to prevent potential uint32
7946 // coercion fail below.
7947 if (start > this.length) {
7948 return ''
7949 }
7950
7951 if (end === undefined || end > this.length) {
7952 end = this.length
7953 }
7954
7955 if (end <= 0) {
7956 return ''
7957 }
7958
7959 // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
7960 end >>>= 0
7961 start >>>= 0
7962
7963 if (end <= start) {
7964 return ''
7965 }
7966
7967 if (!encoding) encoding = 'utf8'
7968
7969 while (true) {
7970 switch (encoding) {
7971 case 'hex':
7972 return hexSlice(this, start, end)
7973
7974 case 'utf8':
7975 case 'utf-8':
7976 return utf8Slice(this, start, end)
7977
7978 case 'ascii':
7979 return asciiSlice(this, start, end)
7980
7981 case 'latin1':
7982 case 'binary':
7983 return latin1Slice(this, start, end)
7984
7985 case 'base64':
7986 return base64Slice(this, start, end)
7987
7988 case 'ucs2':
7989 case 'ucs-2':
7990 case 'utf16le':
7991 case 'utf-16le':
7992 return utf16leSlice(this, start, end)
7993
7994 default:
7995 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
7996 encoding = (encoding + '').toLowerCase()
7997 loweredCase = true
7998 }
7999 }
8000}
8001
8002// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
8003// Buffer instances.
8004Buffer.prototype._isBuffer = true
8005
8006function swap (b, n, m) {
8007 var i = b[n]
8008 b[n] = b[m]
8009 b[m] = i
8010}
8011
8012Buffer.prototype.swap16 = function swap16 () {
8013 var len = this.length
8014 if (len % 2 !== 0) {
8015 throw new RangeError('Buffer size must be a multiple of 16-bits')
8016 }
8017 for (var i = 0; i < len; i += 2) {
8018 swap(this, i, i + 1)
8019 }
8020 return this
8021}
8022
8023Buffer.prototype.swap32 = function swap32 () {
8024 var len = this.length
8025 if (len % 4 !== 0) {
8026 throw new RangeError('Buffer size must be a multiple of 32-bits')
8027 }
8028 for (var i = 0; i < len; i += 4) {
8029 swap(this, i, i + 3)
8030 swap(this, i + 1, i + 2)
8031 }
8032 return this
8033}
8034
8035Buffer.prototype.swap64 = function swap64 () {
8036 var len = this.length
8037 if (len % 8 !== 0) {
8038 throw new RangeError('Buffer size must be a multiple of 64-bits')
8039 }
8040 for (var i = 0; i < len; i += 8) {
8041 swap(this, i, i + 7)
8042 swap(this, i + 1, i + 6)
8043 swap(this, i + 2, i + 5)
8044 swap(this, i + 3, i + 4)
8045 }
8046 return this
8047}
8048
8049Buffer.prototype.toString = function toString () {
8050 var length = this.length | 0
8051 if (length === 0) return ''
8052 if (arguments.length === 0) return utf8Slice(this, 0, length)
8053 return slowToString.apply(this, arguments)
8054}
8055
8056Buffer.prototype.equals = function equals (b) {
8057 if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
8058 if (this === b) return true
8059 return Buffer.compare(this, b) === 0
8060}
8061
8062Buffer.prototype.inspect = function inspect () {
8063 var str = ''
8064 var max = exports.INSPECT_MAX_BYTES
8065 if (this.length > 0) {
8066 str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
8067 if (this.length > max) str += ' ... '
8068 }
8069 return '<Buffer ' + str + '>'
8070}
8071
8072Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
8073 if (!Buffer.isBuffer(target)) {
8074 throw new TypeError('Argument must be a Buffer')
8075 }
8076
8077 if (start === undefined) {
8078 start = 0
8079 }
8080 if (end === undefined) {
8081 end = target ? target.length : 0
8082 }
8083 if (thisStart === undefined) {
8084 thisStart = 0
8085 }
8086 if (thisEnd === undefined) {
8087 thisEnd = this.length
8088 }
8089
8090 if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
8091 throw new RangeError('out of range index')
8092 }
8093
8094 if (thisStart >= thisEnd && start >= end) {
8095 return 0
8096 }
8097 if (thisStart >= thisEnd) {
8098 return -1
8099 }
8100 if (start >= end) {
8101 return 1
8102 }
8103
8104 start >>>= 0
8105 end >>>= 0
8106 thisStart >>>= 0
8107 thisEnd >>>= 0
8108
8109 if (this === target) return 0
8110
8111 var x = thisEnd - thisStart
8112 var y = end - start
8113 var len = Math.min(x, y)
8114
8115 var thisCopy = this.slice(thisStart, thisEnd)
8116 var targetCopy = target.slice(start, end)
8117
8118 for (var i = 0; i < len; ++i) {
8119 if (thisCopy[i] !== targetCopy[i]) {
8120 x = thisCopy[i]
8121 y = targetCopy[i]
8122 break
8123 }
8124 }
8125
8126 if (x < y) return -1
8127 if (y < x) return 1
8128 return 0
8129}
8130
8131// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
8132// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
8133//
8134// Arguments:
8135// - buffer - a Buffer to search
8136// - val - a string, Buffer, or number
8137// - byteOffset - an index into `buffer`; will be clamped to an int32
8138// - encoding - an optional encoding, relevant is val is a string
8139// - dir - true for indexOf, false for lastIndexOf
8140function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
8141 // Empty buffer means no match
8142 if (buffer.length === 0) return -1
8143
8144 // Normalize byteOffset
8145 if (typeof byteOffset === 'string') {
8146 encoding = byteOffset
8147 byteOffset = 0
8148 } else if (byteOffset > 0x7fffffff) {
8149 byteOffset = 0x7fffffff
8150 } else if (byteOffset < -0x80000000) {
8151 byteOffset = -0x80000000
8152 }
8153 byteOffset = +byteOffset // Coerce to Number.
8154 if (isNaN(byteOffset)) {
8155 // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
8156 byteOffset = dir ? 0 : (buffer.length - 1)
8157 }
8158
8159 // Normalize byteOffset: negative offsets start from the end of the buffer
8160 if (byteOffset < 0) byteOffset = buffer.length + byteOffset
8161 if (byteOffset >= buffer.length) {
8162 if (dir) return -1
8163 else byteOffset = buffer.length - 1
8164 } else if (byteOffset < 0) {
8165 if (dir) byteOffset = 0
8166 else return -1
8167 }
8168
8169 // Normalize val
8170 if (typeof val === 'string') {
8171 val = Buffer.from(val, encoding)
8172 }
8173
8174 // Finally, search either indexOf (if dir is true) or lastIndexOf
8175 if (Buffer.isBuffer(val)) {
8176 // Special case: looking for empty string/buffer always fails
8177 if (val.length === 0) {
8178 return -1
8179 }
8180 return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
8181 } else if (typeof val === 'number') {
8182 val = val & 0xFF // Search for a byte value [0-255]
8183 if (Buffer.TYPED_ARRAY_SUPPORT &&
8184 typeof Uint8Array.prototype.indexOf === 'function') {
8185 if (dir) {
8186 return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
8187 } else {
8188 return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
8189 }
8190 }
8191 return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
8192 }
8193
8194 throw new TypeError('val must be string, number or Buffer')
8195}
8196
8197function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
8198 var indexSize = 1
8199 var arrLength = arr.length
8200 var valLength = val.length
8201
8202 if (encoding !== undefined) {
8203 encoding = String(encoding).toLowerCase()
8204 if (encoding === 'ucs2' || encoding === 'ucs-2' ||
8205 encoding === 'utf16le' || encoding === 'utf-16le') {
8206 if (arr.length < 2 || val.length < 2) {
8207 return -1
8208 }
8209 indexSize = 2
8210 arrLength /= 2
8211 valLength /= 2
8212 byteOffset /= 2
8213 }
8214 }
8215
8216 function read (buf, i) {
8217 if (indexSize === 1) {
8218 return buf[i]
8219 } else {
8220 return buf.readUInt16BE(i * indexSize)
8221 }
8222 }
8223
8224 var i
8225 if (dir) {
8226 var foundIndex = -1
8227 for (i = byteOffset; i < arrLength; i++) {
8228 if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
8229 if (foundIndex === -1) foundIndex = i
8230 if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
8231 } else {
8232 if (foundIndex !== -1) i -= i - foundIndex
8233 foundIndex = -1
8234 }
8235 }
8236 } else {
8237 if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
8238 for (i = byteOffset; i >= 0; i--) {
8239 var found = true
8240 for (var j = 0; j < valLength; j++) {
8241 if (read(arr, i + j) !== read(val, j)) {
8242 found = false
8243 break
8244 }
8245 }
8246 if (found) return i
8247 }
8248 }
8249
8250 return -1
8251}
8252
8253Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
8254 return this.indexOf(val, byteOffset, encoding) !== -1
8255}
8256
8257Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
8258 return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
8259}
8260
8261Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
8262 return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
8263}
8264
8265function hexWrite (buf, string, offset, length) {
8266 offset = Number(offset) || 0
8267 var remaining = buf.length - offset
8268 if (!length) {
8269 length = remaining
8270 } else {
8271 length = Number(length)
8272 if (length > remaining) {
8273 length = remaining
8274 }
8275 }
8276
8277 // must be an even number of digits
8278 var strLen = string.length
8279 if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
8280
8281 if (length > strLen / 2) {
8282 length = strLen / 2
8283 }
8284 for (var i = 0; i < length; ++i) {
8285 var parsed = parseInt(string.substr(i * 2, 2), 16)
8286 if (isNaN(parsed)) return i
8287 buf[offset + i] = parsed
8288 }
8289 return i
8290}
8291
8292function utf8Write (buf, string, offset, length) {
8293 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
8294}
8295
8296function asciiWrite (buf, string, offset, length) {
8297 return blitBuffer(asciiToBytes(string), buf, offset, length)
8298}
8299
8300function latin1Write (buf, string, offset, length) {
8301 return asciiWrite(buf, string, offset, length)
8302}
8303
8304function base64Write (buf, string, offset, length) {
8305 return blitBuffer(base64ToBytes(string), buf, offset, length)
8306}
8307
8308function ucs2Write (buf, string, offset, length) {
8309 return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
8310}
8311
8312Buffer.prototype.write = function write (string, offset, length, encoding) {
8313 // Buffer#write(string)
8314 if (offset === undefined) {
8315 encoding = 'utf8'
8316 length = this.length
8317 offset = 0
8318 // Buffer#write(string, encoding)
8319 } else if (length === undefined && typeof offset === 'string') {
8320 encoding = offset
8321 length = this.length
8322 offset = 0
8323 // Buffer#write(string, offset[, length][, encoding])
8324 } else if (isFinite(offset)) {
8325 offset = offset | 0
8326 if (isFinite(length)) {
8327 length = length | 0
8328 if (encoding === undefined) encoding = 'utf8'
8329 } else {
8330 encoding = length
8331 length = undefined
8332 }
8333 // legacy write(string, encoding, offset, length) - remove in v0.13
8334 } else {
8335 throw new Error(
8336 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
8337 )
8338 }
8339
8340 var remaining = this.length - offset
8341 if (length === undefined || length > remaining) length = remaining
8342
8343 if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
8344 throw new RangeError('Attempt to write outside buffer bounds')
8345 }
8346
8347 if (!encoding) encoding = 'utf8'
8348
8349 var loweredCase = false
8350 for (;;) {
8351 switch (encoding) {
8352 case 'hex':
8353 return hexWrite(this, string, offset, length)
8354
8355 case 'utf8':
8356 case 'utf-8':
8357 return utf8Write(this, string, offset, length)
8358
8359 case 'ascii':
8360 return asciiWrite(this, string, offset, length)
8361
8362 case 'latin1':
8363 case 'binary':
8364 return latin1Write(this, string, offset, length)
8365
8366 case 'base64':
8367 // Warning: maxLength not taken into account in base64Write
8368 return base64Write(this, string, offset, length)
8369
8370 case 'ucs2':
8371 case 'ucs-2':
8372 case 'utf16le':
8373 case 'utf-16le':
8374 return ucs2Write(this, string, offset, length)
8375
8376 default:
8377 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
8378 encoding = ('' + encoding).toLowerCase()
8379 loweredCase = true
8380 }
8381 }
8382}
8383
8384Buffer.prototype.toJSON = function toJSON () {
8385 return {
8386 type: 'Buffer',
8387 data: Array.prototype.slice.call(this._arr || this, 0)
8388 }
8389}
8390
8391function base64Slice (buf, start, end) {
8392 if (start === 0 && end === buf.length) {
8393 return base64.fromByteArray(buf)
8394 } else {
8395 return base64.fromByteArray(buf.slice(start, end))
8396 }
8397}
8398
8399function utf8Slice (buf, start, end) {
8400 end = Math.min(buf.length, end)
8401 var res = []
8402
8403 var i = start
8404 while (i < end) {
8405 var firstByte = buf[i]
8406 var codePoint = null
8407 var bytesPerSequence = (firstByte > 0xEF) ? 4
8408 : (firstByte > 0xDF) ? 3
8409 : (firstByte > 0xBF) ? 2
8410 : 1
8411
8412 if (i + bytesPerSequence <= end) {
8413 var secondByte, thirdByte, fourthByte, tempCodePoint
8414
8415 switch (bytesPerSequence) {
8416 case 1:
8417 if (firstByte < 0x80) {
8418 codePoint = firstByte
8419 }
8420 break
8421 case 2:
8422 secondByte = buf[i + 1]
8423 if ((secondByte & 0xC0) === 0x80) {
8424 tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
8425 if (tempCodePoint > 0x7F) {
8426 codePoint = tempCodePoint
8427 }
8428 }
8429 break
8430 case 3:
8431 secondByte = buf[i + 1]
8432 thirdByte = buf[i + 2]
8433 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
8434 tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
8435 if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
8436 codePoint = tempCodePoint
8437 }
8438 }
8439 break
8440 case 4:
8441 secondByte = buf[i + 1]
8442 thirdByte = buf[i + 2]
8443 fourthByte = buf[i + 3]
8444 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
8445 tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
8446 if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
8447 codePoint = tempCodePoint
8448 }
8449 }
8450 }
8451 }
8452
8453 if (codePoint === null) {
8454 // we did not generate a valid codePoint so insert a
8455 // replacement char (U+FFFD) and advance only 1 byte
8456 codePoint = 0xFFFD
8457 bytesPerSequence = 1
8458 } else if (codePoint > 0xFFFF) {
8459 // encode to utf16 (surrogate pair dance)
8460 codePoint -= 0x10000
8461 res.push(codePoint >>> 10 & 0x3FF | 0xD800)
8462 codePoint = 0xDC00 | codePoint & 0x3FF
8463 }
8464
8465 res.push(codePoint)
8466 i += bytesPerSequence
8467 }
8468
8469 return decodeCodePointsArray(res)
8470}
8471
8472// Based on http://stackoverflow.com/a/22747272/680742, the browser with
8473// the lowest limit is Chrome, with 0x10000 args.
8474// We go 1 magnitude less, for safety
8475var MAX_ARGUMENTS_LENGTH = 0x1000
8476
8477function decodeCodePointsArray (codePoints) {
8478 var len = codePoints.length
8479 if (len <= MAX_ARGUMENTS_LENGTH) {
8480 return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
8481 }
8482
8483 // Decode in chunks to avoid "call stack size exceeded".
8484 var res = ''
8485 var i = 0
8486 while (i < len) {
8487 res += String.fromCharCode.apply(
8488 String,
8489 codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
8490 )
8491 }
8492 return res
8493}
8494
8495function asciiSlice (buf, start, end) {
8496 var ret = ''
8497 end = Math.min(buf.length, end)
8498
8499 for (var i = start; i < end; ++i) {
8500 ret += String.fromCharCode(buf[i] & 0x7F)
8501 }
8502 return ret
8503}
8504
8505function latin1Slice (buf, start, end) {
8506 var ret = ''
8507 end = Math.min(buf.length, end)
8508
8509 for (var i = start; i < end; ++i) {
8510 ret += String.fromCharCode(buf[i])
8511 }
8512 return ret
8513}
8514
8515function hexSlice (buf, start, end) {
8516 var len = buf.length
8517
8518 if (!start || start < 0) start = 0
8519 if (!end || end < 0 || end > len) end = len
8520
8521 var out = ''
8522 for (var i = start; i < end; ++i) {
8523 out += toHex(buf[i])
8524 }
8525 return out
8526}
8527
8528function utf16leSlice (buf, start, end) {
8529 var bytes = buf.slice(start, end)
8530 var res = ''
8531 for (var i = 0; i < bytes.length; i += 2) {
8532 res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
8533 }
8534 return res
8535}
8536
8537Buffer.prototype.slice = function slice (start, end) {
8538 var len = this.length
8539 start = ~~start
8540 end = end === undefined ? len : ~~end
8541
8542 if (start < 0) {
8543 start += len
8544 if (start < 0) start = 0
8545 } else if (start > len) {
8546 start = len
8547 }
8548
8549 if (end < 0) {
8550 end += len
8551 if (end < 0) end = 0
8552 } else if (end > len) {
8553 end = len
8554 }
8555
8556 if (end < start) end = start
8557
8558 var newBuf
8559 if (Buffer.TYPED_ARRAY_SUPPORT) {
8560 newBuf = this.subarray(start, end)
8561 newBuf.__proto__ = Buffer.prototype
8562 } else {
8563 var sliceLen = end - start
8564 newBuf = new Buffer(sliceLen, undefined)
8565 for (var i = 0; i < sliceLen; ++i) {
8566 newBuf[i] = this[i + start]
8567 }
8568 }
8569
8570 return newBuf
8571}
8572
8573/*
8574 * Need to make sure that buffer isn't trying to write out of bounds.
8575 */
8576function checkOffset (offset, ext, length) {
8577 if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
8578 if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
8579}
8580
8581Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
8582 offset = offset | 0
8583 byteLength = byteLength | 0
8584 if (!noAssert) checkOffset(offset, byteLength, this.length)
8585
8586 var val = this[offset]
8587 var mul = 1
8588 var i = 0
8589 while (++i < byteLength && (mul *= 0x100)) {
8590 val += this[offset + i] * mul
8591 }
8592
8593 return val
8594}
8595
8596Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
8597 offset = offset | 0
8598 byteLength = byteLength | 0
8599 if (!noAssert) {
8600 checkOffset(offset, byteLength, this.length)
8601 }
8602
8603 var val = this[offset + --byteLength]
8604 var mul = 1
8605 while (byteLength > 0 && (mul *= 0x100)) {
8606 val += this[offset + --byteLength] * mul
8607 }
8608
8609 return val
8610}
8611
8612Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
8613 if (!noAssert) checkOffset(offset, 1, this.length)
8614 return this[offset]
8615}
8616
8617Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
8618 if (!noAssert) checkOffset(offset, 2, this.length)
8619 return this[offset] | (this[offset + 1] << 8)
8620}
8621
8622Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
8623 if (!noAssert) checkOffset(offset, 2, this.length)
8624 return (this[offset] << 8) | this[offset + 1]
8625}
8626
8627Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
8628 if (!noAssert) checkOffset(offset, 4, this.length)
8629
8630 return ((this[offset]) |
8631 (this[offset + 1] << 8) |
8632 (this[offset + 2] << 16)) +
8633 (this[offset + 3] * 0x1000000)
8634}
8635
8636Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
8637 if (!noAssert) checkOffset(offset, 4, this.length)
8638
8639 return (this[offset] * 0x1000000) +
8640 ((this[offset + 1] << 16) |
8641 (this[offset + 2] << 8) |
8642 this[offset + 3])
8643}
8644
8645Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
8646 offset = offset | 0
8647 byteLength = byteLength | 0
8648 if (!noAssert) checkOffset(offset, byteLength, this.length)
8649
8650 var val = this[offset]
8651 var mul = 1
8652 var i = 0
8653 while (++i < byteLength && (mul *= 0x100)) {
8654 val += this[offset + i] * mul
8655 }
8656 mul *= 0x80
8657
8658 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
8659
8660 return val
8661}
8662
8663Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
8664 offset = offset | 0
8665 byteLength = byteLength | 0
8666 if (!noAssert) checkOffset(offset, byteLength, this.length)
8667
8668 var i = byteLength
8669 var mul = 1
8670 var val = this[offset + --i]
8671 while (i > 0 && (mul *= 0x100)) {
8672 val += this[offset + --i] * mul
8673 }
8674 mul *= 0x80
8675
8676 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
8677
8678 return val
8679}
8680
8681Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
8682 if (!noAssert) checkOffset(offset, 1, this.length)
8683 if (!(this[offset] & 0x80)) return (this[offset])
8684 return ((0xff - this[offset] + 1) * -1)
8685}
8686
8687Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
8688 if (!noAssert) checkOffset(offset, 2, this.length)
8689 var val = this[offset] | (this[offset + 1] << 8)
8690 return (val & 0x8000) ? val | 0xFFFF0000 : val
8691}
8692
8693Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
8694 if (!noAssert) checkOffset(offset, 2, this.length)
8695 var val = this[offset + 1] | (this[offset] << 8)
8696 return (val & 0x8000) ? val | 0xFFFF0000 : val
8697}
8698
8699Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
8700 if (!noAssert) checkOffset(offset, 4, this.length)
8701
8702 return (this[offset]) |
8703 (this[offset + 1] << 8) |
8704 (this[offset + 2] << 16) |
8705 (this[offset + 3] << 24)
8706}
8707
8708Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
8709 if (!noAssert) checkOffset(offset, 4, this.length)
8710
8711 return (this[offset] << 24) |
8712 (this[offset + 1] << 16) |
8713 (this[offset + 2] << 8) |
8714 (this[offset + 3])
8715}
8716
8717Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
8718 if (!noAssert) checkOffset(offset, 4, this.length)
8719 return ieee754.read(this, offset, true, 23, 4)
8720}
8721
8722Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
8723 if (!noAssert) checkOffset(offset, 4, this.length)
8724 return ieee754.read(this, offset, false, 23, 4)
8725}
8726
8727Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
8728 if (!noAssert) checkOffset(offset, 8, this.length)
8729 return ieee754.read(this, offset, true, 52, 8)
8730}
8731
8732Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
8733 if (!noAssert) checkOffset(offset, 8, this.length)
8734 return ieee754.read(this, offset, false, 52, 8)
8735}
8736
8737function checkInt (buf, value, offset, ext, max, min) {
8738 if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
8739 if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
8740 if (offset + ext > buf.length) throw new RangeError('Index out of range')
8741}
8742
8743Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
8744 value = +value
8745 offset = offset | 0
8746 byteLength = byteLength | 0
8747 if (!noAssert) {
8748 var maxBytes = Math.pow(2, 8 * byteLength) - 1
8749 checkInt(this, value, offset, byteLength, maxBytes, 0)
8750 }
8751
8752 var mul = 1
8753 var i = 0
8754 this[offset] = value & 0xFF
8755 while (++i < byteLength && (mul *= 0x100)) {
8756 this[offset + i] = (value / mul) & 0xFF
8757 }
8758
8759 return offset + byteLength
8760}
8761
8762Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
8763 value = +value
8764 offset = offset | 0
8765 byteLength = byteLength | 0
8766 if (!noAssert) {
8767 var maxBytes = Math.pow(2, 8 * byteLength) - 1
8768 checkInt(this, value, offset, byteLength, maxBytes, 0)
8769 }
8770
8771 var i = byteLength - 1
8772 var mul = 1
8773 this[offset + i] = value & 0xFF
8774 while (--i >= 0 && (mul *= 0x100)) {
8775 this[offset + i] = (value / mul) & 0xFF
8776 }
8777
8778 return offset + byteLength
8779}
8780
8781Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
8782 value = +value
8783 offset = offset | 0
8784 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
8785 if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
8786 this[offset] = (value & 0xff)
8787 return offset + 1
8788}
8789
8790function objectWriteUInt16 (buf, value, offset, littleEndian) {
8791 if (value < 0) value = 0xffff + value + 1
8792 for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
8793 buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
8794 (littleEndian ? i : 1 - i) * 8
8795 }
8796}
8797
8798Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
8799 value = +value
8800 offset = offset | 0
8801 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
8802 if (Buffer.TYPED_ARRAY_SUPPORT) {
8803 this[offset] = (value & 0xff)
8804 this[offset + 1] = (value >>> 8)
8805 } else {
8806 objectWriteUInt16(this, value, offset, true)
8807 }
8808 return offset + 2
8809}
8810
8811Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
8812 value = +value
8813 offset = offset | 0
8814 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
8815 if (Buffer.TYPED_ARRAY_SUPPORT) {
8816 this[offset] = (value >>> 8)
8817 this[offset + 1] = (value & 0xff)
8818 } else {
8819 objectWriteUInt16(this, value, offset, false)
8820 }
8821 return offset + 2
8822}
8823
8824function objectWriteUInt32 (buf, value, offset, littleEndian) {
8825 if (value < 0) value = 0xffffffff + value + 1
8826 for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
8827 buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
8828 }
8829}
8830
8831Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
8832 value = +value
8833 offset = offset | 0
8834 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
8835 if (Buffer.TYPED_ARRAY_SUPPORT) {
8836 this[offset + 3] = (value >>> 24)
8837 this[offset + 2] = (value >>> 16)
8838 this[offset + 1] = (value >>> 8)
8839 this[offset] = (value & 0xff)
8840 } else {
8841 objectWriteUInt32(this, value, offset, true)
8842 }
8843 return offset + 4
8844}
8845
8846Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
8847 value = +value
8848 offset = offset | 0
8849 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
8850 if (Buffer.TYPED_ARRAY_SUPPORT) {
8851 this[offset] = (value >>> 24)
8852 this[offset + 1] = (value >>> 16)
8853 this[offset + 2] = (value >>> 8)
8854 this[offset + 3] = (value & 0xff)
8855 } else {
8856 objectWriteUInt32(this, value, offset, false)
8857 }
8858 return offset + 4
8859}
8860
8861Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
8862 value = +value
8863 offset = offset | 0
8864 if (!noAssert) {
8865 var limit = Math.pow(2, 8 * byteLength - 1)
8866
8867 checkInt(this, value, offset, byteLength, limit - 1, -limit)
8868 }
8869
8870 var i = 0
8871 var mul = 1
8872 var sub = 0
8873 this[offset] = value & 0xFF
8874 while (++i < byteLength && (mul *= 0x100)) {
8875 if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
8876 sub = 1
8877 }
8878 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
8879 }
8880
8881 return offset + byteLength
8882}
8883
8884Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
8885 value = +value
8886 offset = offset | 0
8887 if (!noAssert) {
8888 var limit = Math.pow(2, 8 * byteLength - 1)
8889
8890 checkInt(this, value, offset, byteLength, limit - 1, -limit)
8891 }
8892
8893 var i = byteLength - 1
8894 var mul = 1
8895 var sub = 0
8896 this[offset + i] = value & 0xFF
8897 while (--i >= 0 && (mul *= 0x100)) {
8898 if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
8899 sub = 1
8900 }
8901 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
8902 }
8903
8904 return offset + byteLength
8905}
8906
8907Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
8908 value = +value
8909 offset = offset | 0
8910 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
8911 if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
8912 if (value < 0) value = 0xff + value + 1
8913 this[offset] = (value & 0xff)
8914 return offset + 1
8915}
8916
8917Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
8918 value = +value
8919 offset = offset | 0
8920 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
8921 if (Buffer.TYPED_ARRAY_SUPPORT) {
8922 this[offset] = (value & 0xff)
8923 this[offset + 1] = (value >>> 8)
8924 } else {
8925 objectWriteUInt16(this, value, offset, true)
8926 }
8927 return offset + 2
8928}
8929
8930Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
8931 value = +value
8932 offset = offset | 0
8933 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
8934 if (Buffer.TYPED_ARRAY_SUPPORT) {
8935 this[offset] = (value >>> 8)
8936 this[offset + 1] = (value & 0xff)
8937 } else {
8938 objectWriteUInt16(this, value, offset, false)
8939 }
8940 return offset + 2
8941}
8942
8943Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
8944 value = +value
8945 offset = offset | 0
8946 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
8947 if (Buffer.TYPED_ARRAY_SUPPORT) {
8948 this[offset] = (value & 0xff)
8949 this[offset + 1] = (value >>> 8)
8950 this[offset + 2] = (value >>> 16)
8951 this[offset + 3] = (value >>> 24)
8952 } else {
8953 objectWriteUInt32(this, value, offset, true)
8954 }
8955 return offset + 4
8956}
8957
8958Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
8959 value = +value
8960 offset = offset | 0
8961 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
8962 if (value < 0) value = 0xffffffff + value + 1
8963 if (Buffer.TYPED_ARRAY_SUPPORT) {
8964 this[offset] = (value >>> 24)
8965 this[offset + 1] = (value >>> 16)
8966 this[offset + 2] = (value >>> 8)
8967 this[offset + 3] = (value & 0xff)
8968 } else {
8969 objectWriteUInt32(this, value, offset, false)
8970 }
8971 return offset + 4
8972}
8973
8974function checkIEEE754 (buf, value, offset, ext, max, min) {
8975 if (offset + ext > buf.length) throw new RangeError('Index out of range')
8976 if (offset < 0) throw new RangeError('Index out of range')
8977}
8978
8979function writeFloat (buf, value, offset, littleEndian, noAssert) {
8980 if (!noAssert) {
8981 checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
8982 }
8983 ieee754.write(buf, value, offset, littleEndian, 23, 4)
8984 return offset + 4
8985}
8986
8987Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
8988 return writeFloat(this, value, offset, true, noAssert)
8989}
8990
8991Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
8992 return writeFloat(this, value, offset, false, noAssert)
8993}
8994
8995function writeDouble (buf, value, offset, littleEndian, noAssert) {
8996 if (!noAssert) {
8997 checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
8998 }
8999 ieee754.write(buf, value, offset, littleEndian, 52, 8)
9000 return offset + 8
9001}
9002
9003Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
9004 return writeDouble(this, value, offset, true, noAssert)
9005}
9006
9007Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
9008 return writeDouble(this, value, offset, false, noAssert)
9009}
9010
9011// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
9012Buffer.prototype.copy = function copy (target, targetStart, start, end) {
9013 if (!start) start = 0
9014 if (!end && end !== 0) end = this.length
9015 if (targetStart >= target.length) targetStart = target.length
9016 if (!targetStart) targetStart = 0
9017 if (end > 0 && end < start) end = start
9018
9019 // Copy 0 bytes; we're done
9020 if (end === start) return 0
9021 if (target.length === 0 || this.length === 0) return 0
9022
9023 // Fatal error conditions
9024 if (targetStart < 0) {
9025 throw new RangeError('targetStart out of bounds')
9026 }
9027 if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
9028 if (end < 0) throw new RangeError('sourceEnd out of bounds')
9029
9030 // Are we oob?
9031 if (end > this.length) end = this.length
9032 if (target.length - targetStart < end - start) {
9033 end = target.length - targetStart + start
9034 }
9035
9036 var len = end - start
9037 var i
9038
9039 if (this === target && start < targetStart && targetStart < end) {
9040 // descending copy from end
9041 for (i = len - 1; i >= 0; --i) {
9042 target[i + targetStart] = this[i + start]
9043 }
9044 } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
9045 // ascending copy from start
9046 for (i = 0; i < len; ++i) {
9047 target[i + targetStart] = this[i + start]
9048 }
9049 } else {
9050 Uint8Array.prototype.set.call(
9051 target,
9052 this.subarray(start, start + len),
9053 targetStart
9054 )
9055 }
9056
9057 return len
9058}
9059
9060// Usage:
9061// buffer.fill(number[, offset[, end]])
9062// buffer.fill(buffer[, offset[, end]])
9063// buffer.fill(string[, offset[, end]][, encoding])
9064Buffer.prototype.fill = function fill (val, start, end, encoding) {
9065 // Handle string cases:
9066 if (typeof val === 'string') {
9067 if (typeof start === 'string') {
9068 encoding = start
9069 start = 0
9070 end = this.length
9071 } else if (typeof end === 'string') {
9072 encoding = end
9073 end = this.length
9074 }
9075 if (val.length === 1) {
9076 var code = val.charCodeAt(0)
9077 if (code < 256) {
9078 val = code
9079 }
9080 }
9081 if (encoding !== undefined && typeof encoding !== 'string') {
9082 throw new TypeError('encoding must be a string')
9083 }
9084 if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
9085 throw new TypeError('Unknown encoding: ' + encoding)
9086 }
9087 } else if (typeof val === 'number') {
9088 val = val & 255
9089 }
9090
9091 // Invalid ranges are not set to a default, so can range check early.
9092 if (start < 0 || this.length < start || this.length < end) {
9093 throw new RangeError('Out of range index')
9094 }
9095
9096 if (end <= start) {
9097 return this
9098 }
9099
9100 start = start >>> 0
9101 end = end === undefined ? this.length : end >>> 0
9102
9103 if (!val) val = 0
9104
9105 var i
9106 if (typeof val === 'number') {
9107 for (i = start; i < end; ++i) {
9108 this[i] = val
9109 }
9110 } else {
9111 var bytes = Buffer.isBuffer(val)
9112 ? val
9113 : utf8ToBytes(new Buffer(val, encoding).toString())
9114 var len = bytes.length
9115 for (i = 0; i < end - start; ++i) {
9116 this[i + start] = bytes[i % len]
9117 }
9118 }
9119
9120 return this
9121}
9122
9123// HELPER FUNCTIONS
9124// ================
9125
9126var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
9127
9128function base64clean (str) {
9129 // Node strips out invalid characters like \n and \t from the string, base64-js does not
9130 str = stringtrim(str).replace(INVALID_BASE64_RE, '')
9131 // Node converts strings with length < 2 to ''
9132 if (str.length < 2) return ''
9133 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
9134 while (str.length % 4 !== 0) {
9135 str = str + '='
9136 }
9137 return str
9138}
9139
9140function stringtrim (str) {
9141 if (str.trim) return str.trim()
9142 return str.replace(/^\s+|\s+$/g, '')
9143}
9144
9145function toHex (n) {
9146 if (n < 16) return '0' + n.toString(16)
9147 return n.toString(16)
9148}
9149
9150function utf8ToBytes (string, units) {
9151 units = units || Infinity
9152 var codePoint
9153 var length = string.length
9154 var leadSurrogate = null
9155 var bytes = []
9156
9157 for (var i = 0; i < length; ++i) {
9158 codePoint = string.charCodeAt(i)
9159
9160 // is surrogate component
9161 if (codePoint > 0xD7FF && codePoint < 0xE000) {
9162 // last char was a lead
9163 if (!leadSurrogate) {
9164 // no lead yet
9165 if (codePoint > 0xDBFF) {
9166 // unexpected trail
9167 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
9168 continue
9169 } else if (i + 1 === length) {
9170 // unpaired lead
9171 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
9172 continue
9173 }
9174
9175 // valid lead
9176 leadSurrogate = codePoint
9177
9178 continue
9179 }
9180
9181 // 2 leads in a row
9182 if (codePoint < 0xDC00) {
9183 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
9184 leadSurrogate = codePoint
9185 continue
9186 }
9187
9188 // valid surrogate pair
9189 codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
9190 } else if (leadSurrogate) {
9191 // valid bmp char, but last char was a lead
9192 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
9193 }
9194
9195 leadSurrogate = null
9196
9197 // encode utf8
9198 if (codePoint < 0x80) {
9199 if ((units -= 1) < 0) break
9200 bytes.push(codePoint)
9201 } else if (codePoint < 0x800) {
9202 if ((units -= 2) < 0) break
9203 bytes.push(
9204 codePoint >> 0x6 | 0xC0,
9205 codePoint & 0x3F | 0x80
9206 )
9207 } else if (codePoint < 0x10000) {
9208 if ((units -= 3) < 0) break
9209 bytes.push(
9210 codePoint >> 0xC | 0xE0,
9211 codePoint >> 0x6 & 0x3F | 0x80,
9212 codePoint & 0x3F | 0x80
9213 )
9214 } else if (codePoint < 0x110000) {
9215 if ((units -= 4) < 0) break
9216 bytes.push(
9217 codePoint >> 0x12 | 0xF0,
9218 codePoint >> 0xC & 0x3F | 0x80,
9219 codePoint >> 0x6 & 0x3F | 0x80,
9220 codePoint & 0x3F | 0x80
9221 )
9222 } else {
9223 throw new Error('Invalid code point')
9224 }
9225 }
9226
9227 return bytes
9228}
9229
9230function asciiToBytes (str) {
9231 var byteArray = []
9232 for (var i = 0; i < str.length; ++i) {
9233 // Node's code seems to be doing this and not & 0x7F..
9234 byteArray.push(str.charCodeAt(i) & 0xFF)
9235 }
9236 return byteArray
9237}
9238
9239function utf16leToBytes (str, units) {
9240 var c, hi, lo
9241 var byteArray = []
9242 for (var i = 0; i < str.length; ++i) {
9243 if ((units -= 2) < 0) break
9244
9245 c = str.charCodeAt(i)
9246 hi = c >> 8
9247 lo = c % 256
9248 byteArray.push(lo)
9249 byteArray.push(hi)
9250 }
9251
9252 return byteArray
9253}
9254
9255function base64ToBytes (str) {
9256 return base64.toByteArray(base64clean(str))
9257}
9258
9259function blitBuffer (src, dst, offset, length) {
9260 for (var i = 0; i < length; ++i) {
9261 if ((i + offset >= dst.length) || (i >= src.length)) break
9262 dst[i + offset] = src[i]
9263 }
9264 return i
9265}
9266
9267function isnan (val) {
9268 return val !== val // eslint-disable-line no-self-compare
9269}
9270
9271}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
9272},{"base64-js":42,"ieee754":258,"isarray":262}],76:[function(require,module,exports){
9273var Buffer = require('safe-buffer').Buffer
9274var Transform = require('stream').Transform
9275var StringDecoder = require('string_decoder').StringDecoder
9276var inherits = require('inherits')
9277
9278function CipherBase (hashMode) {
9279 Transform.call(this)
9280 this.hashMode = typeof hashMode === 'string'
9281 if (this.hashMode) {
9282 this[hashMode] = this._finalOrDigest
9283 } else {
9284 this.final = this._finalOrDigest
9285 }
9286 if (this._final) {
9287 this.__final = this._final
9288 this._final = null
9289 }
9290 this._decoder = null
9291 this._encoding = null
9292}
9293inherits(CipherBase, Transform)
9294
9295CipherBase.prototype.update = function (data, inputEnc, outputEnc) {
9296 if (typeof data === 'string') {
9297 data = Buffer.from(data, inputEnc)
9298 }
9299
9300 var outData = this._update(data)
9301 if (this.hashMode) return this
9302
9303 if (outputEnc) {
9304 outData = this._toString(outData, outputEnc)
9305 }
9306
9307 return outData
9308}
9309
9310CipherBase.prototype.setAutoPadding = function () {}
9311CipherBase.prototype.getAuthTag = function () {
9312 throw new Error('trying to get auth tag in unsupported state')
9313}
9314
9315CipherBase.prototype.setAuthTag = function () {
9316 throw new Error('trying to set auth tag in unsupported state')
9317}
9318
9319CipherBase.prototype.setAAD = function () {
9320 throw new Error('trying to set aad in unsupported state')
9321}
9322
9323CipherBase.prototype._transform = function (data, _, next) {
9324 var err
9325 try {
9326 if (this.hashMode) {
9327 this._update(data)
9328 } else {
9329 this.push(this._update(data))
9330 }
9331 } catch (e) {
9332 err = e
9333 } finally {
9334 next(err)
9335 }
9336}
9337CipherBase.prototype._flush = function (done) {
9338 var err
9339 try {
9340 this.push(this.__final())
9341 } catch (e) {
9342 err = e
9343 }
9344
9345 done(err)
9346}
9347CipherBase.prototype._finalOrDigest = function (outputEnc) {
9348 var outData = this.__final() || Buffer.alloc(0)
9349 if (outputEnc) {
9350 outData = this._toString(outData, outputEnc, true)
9351 }
9352 return outData
9353}
9354
9355CipherBase.prototype._toString = function (value, enc, fin) {
9356 if (!this._decoder) {
9357 this._decoder = new StringDecoder(enc)
9358 this._encoding = enc
9359 }
9360
9361 if (this._encoding !== enc) throw new Error('can\'t switch encodings')
9362
9363 var out = this._decoder.write(value)
9364 if (fin) {
9365 out += this._decoder.end()
9366 }
9367
9368 return out
9369}
9370
9371module.exports = CipherBase
9372
9373},{"inherits":260,"safe-buffer":305,"stream":314,"string_decoder":315}],77:[function(require,module,exports){
9374require('../../modules/es6.string.iterator');
9375require('../../modules/es6.array.from');
9376module.exports = require('../../modules/_core').Array.from;
9377
9378},{"../../modules/_core":109,"../../modules/es6.array.from":183,"../../modules/es6.string.iterator":198}],78:[function(require,module,exports){
9379require('../modules/web.dom.iterable');
9380require('../modules/es6.string.iterator');
9381module.exports = require('../modules/core.get-iterator');
9382
9383},{"../modules/core.get-iterator":181,"../modules/es6.string.iterator":198,"../modules/web.dom.iterable":207}],79:[function(require,module,exports){
9384require('../modules/web.dom.iterable');
9385require('../modules/es6.string.iterator');
9386module.exports = require('../modules/core.is-iterable');
9387
9388},{"../modules/core.is-iterable":182,"../modules/es6.string.iterator":198,"../modules/web.dom.iterable":207}],80:[function(require,module,exports){
9389var core = require('../../modules/_core');
9390var $JSON = core.JSON || (core.JSON = { stringify: JSON.stringify });
9391module.exports = function stringify(it) { // eslint-disable-line no-unused-vars
9392 return $JSON.stringify.apply($JSON, arguments);
9393};
9394
9395},{"../../modules/_core":109}],81:[function(require,module,exports){
9396require('../../modules/es6.number.is-integer');
9397module.exports = require('../../modules/_core').Number.isInteger;
9398
9399},{"../../modules/_core":109,"../../modules/es6.number.is-integer":185}],82:[function(require,module,exports){
9400require('../../modules/es6.number.max-safe-integer');
9401module.exports = 0x1fffffffffffff;
9402
9403},{"../../modules/es6.number.max-safe-integer":186}],83:[function(require,module,exports){
9404require('../../modules/es6.object.assign');
9405module.exports = require('../../modules/_core').Object.assign;
9406
9407},{"../../modules/_core":109,"../../modules/es6.object.assign":187}],84:[function(require,module,exports){
9408require('../../modules/es6.object.create');
9409var $Object = require('../../modules/_core').Object;
9410module.exports = function create(P, D) {
9411 return $Object.create(P, D);
9412};
9413
9414},{"../../modules/_core":109,"../../modules/es6.object.create":188}],85:[function(require,module,exports){
9415require('../../modules/es6.object.define-property');
9416var $Object = require('../../modules/_core').Object;
9417module.exports = function defineProperty(it, key, desc) {
9418 return $Object.defineProperty(it, key, desc);
9419};
9420
9421},{"../../modules/_core":109,"../../modules/es6.object.define-property":189}],86:[function(require,module,exports){
9422require('../../modules/es6.object.freeze');
9423module.exports = require('../../modules/_core').Object.freeze;
9424
9425},{"../../modules/_core":109,"../../modules/es6.object.freeze":190}],87:[function(require,module,exports){
9426require('../../modules/es6.object.get-own-property-descriptor');
9427var $Object = require('../../modules/_core').Object;
9428module.exports = function getOwnPropertyDescriptor(it, key) {
9429 return $Object.getOwnPropertyDescriptor(it, key);
9430};
9431
9432},{"../../modules/_core":109,"../../modules/es6.object.get-own-property-descriptor":191}],88:[function(require,module,exports){
9433require('../../modules/es6.object.get-prototype-of');
9434module.exports = require('../../modules/_core').Object.getPrototypeOf;
9435
9436},{"../../modules/_core":109,"../../modules/es6.object.get-prototype-of":192}],89:[function(require,module,exports){
9437require('../../modules/es6.object.keys');
9438module.exports = require('../../modules/_core').Object.keys;
9439
9440},{"../../modules/_core":109,"../../modules/es6.object.keys":193}],90:[function(require,module,exports){
9441require('../../modules/es6.object.set-prototype-of');
9442module.exports = require('../../modules/_core').Object.setPrototypeOf;
9443
9444},{"../../modules/_core":109,"../../modules/es6.object.set-prototype-of":194}],91:[function(require,module,exports){
9445require('../modules/es6.object.to-string');
9446require('../modules/es6.string.iterator');
9447require('../modules/web.dom.iterable');
9448require('../modules/es6.promise');
9449require('../modules/es7.promise.finally');
9450require('../modules/es7.promise.try');
9451module.exports = require('../modules/_core').Promise;
9452
9453},{"../modules/_core":109,"../modules/es6.object.to-string":195,"../modules/es6.promise":196,"../modules/es6.string.iterator":198,"../modules/es7.promise.finally":200,"../modules/es7.promise.try":201,"../modules/web.dom.iterable":207}],92:[function(require,module,exports){
9454require('../modules/es6.object.to-string');
9455require('../modules/es6.string.iterator');
9456require('../modules/web.dom.iterable');
9457require('../modules/es6.set');
9458require('../modules/es7.set.to-json');
9459require('../modules/es7.set.of');
9460require('../modules/es7.set.from');
9461module.exports = require('../modules/_core').Set;
9462
9463},{"../modules/_core":109,"../modules/es6.object.to-string":195,"../modules/es6.set":197,"../modules/es6.string.iterator":198,"../modules/es7.set.from":202,"../modules/es7.set.of":203,"../modules/es7.set.to-json":204,"../modules/web.dom.iterable":207}],93:[function(require,module,exports){
9464require('../../modules/es6.symbol');
9465require('../../modules/es6.object.to-string');
9466require('../../modules/es7.symbol.async-iterator');
9467require('../../modules/es7.symbol.observable');
9468module.exports = require('../../modules/_core').Symbol;
9469
9470},{"../../modules/_core":109,"../../modules/es6.object.to-string":195,"../../modules/es6.symbol":199,"../../modules/es7.symbol.async-iterator":205,"../../modules/es7.symbol.observable":206}],94:[function(require,module,exports){
9471require('../../modules/es6.string.iterator');
9472require('../../modules/web.dom.iterable');
9473module.exports = require('../../modules/_wks-ext').f('iterator');
9474
9475},{"../../modules/_wks-ext":178,"../../modules/es6.string.iterator":198,"../../modules/web.dom.iterable":207}],95:[function(require,module,exports){
9476module.exports = function (it) {
9477 if (typeof it != 'function') throw TypeError(it + ' is not a function!');
9478 return it;
9479};
9480
9481},{}],96:[function(require,module,exports){
9482module.exports = function () { /* empty */ };
9483
9484},{}],97:[function(require,module,exports){
9485module.exports = function (it, Constructor, name, forbiddenField) {
9486 if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) {
9487 throw TypeError(name + ': incorrect invocation!');
9488 } return it;
9489};
9490
9491},{}],98:[function(require,module,exports){
9492var isObject = require('./_is-object');
9493module.exports = function (it) {
9494 if (!isObject(it)) throw TypeError(it + ' is not an object!');
9495 return it;
9496};
9497
9498},{"./_is-object":130}],99:[function(require,module,exports){
9499var forOf = require('./_for-of');
9500
9501module.exports = function (iter, ITERATOR) {
9502 var result = [];
9503 forOf(iter, false, result.push, result, ITERATOR);
9504 return result;
9505};
9506
9507},{"./_for-of":119}],100:[function(require,module,exports){
9508// false -> Array#indexOf
9509// true -> Array#includes
9510var toIObject = require('./_to-iobject');
9511var toLength = require('./_to-length');
9512var toAbsoluteIndex = require('./_to-absolute-index');
9513module.exports = function (IS_INCLUDES) {
9514 return function ($this, el, fromIndex) {
9515 var O = toIObject($this);
9516 var length = toLength(O.length);
9517 var index = toAbsoluteIndex(fromIndex, length);
9518 var value;
9519 // Array#includes uses SameValueZero equality algorithm
9520 // eslint-disable-next-line no-self-compare
9521 if (IS_INCLUDES && el != el) while (length > index) {
9522 value = O[index++];
9523 // eslint-disable-next-line no-self-compare
9524 if (value != value) return true;
9525 // Array#indexOf ignores holes, Array#includes - not
9526 } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
9527 if (O[index] === el) return IS_INCLUDES || index || 0;
9528 } return !IS_INCLUDES && -1;
9529 };
9530};
9531
9532},{"./_to-absolute-index":169,"./_to-iobject":171,"./_to-length":172}],101:[function(require,module,exports){
9533// 0 -> Array#forEach
9534// 1 -> Array#map
9535// 2 -> Array#filter
9536// 3 -> Array#some
9537// 4 -> Array#every
9538// 5 -> Array#find
9539// 6 -> Array#findIndex
9540var ctx = require('./_ctx');
9541var IObject = require('./_iobject');
9542var toObject = require('./_to-object');
9543var toLength = require('./_to-length');
9544var asc = require('./_array-species-create');
9545module.exports = function (TYPE, $create) {
9546 var IS_MAP = TYPE == 1;
9547 var IS_FILTER = TYPE == 2;
9548 var IS_SOME = TYPE == 3;
9549 var IS_EVERY = TYPE == 4;
9550 var IS_FIND_INDEX = TYPE == 6;
9551 var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
9552 var create = $create || asc;
9553 return function ($this, callbackfn, that) {
9554 var O = toObject($this);
9555 var self = IObject(O);
9556 var f = ctx(callbackfn, that, 3);
9557 var length = toLength(self.length);
9558 var index = 0;
9559 var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
9560 var val, res;
9561 for (;length > index; index++) if (NO_HOLES || index in self) {
9562 val = self[index];
9563 res = f(val, index, O);
9564 if (TYPE) {
9565 if (IS_MAP) result[index] = res; // map
9566 else if (res) switch (TYPE) {
9567 case 3: return true; // some
9568 case 5: return val; // find
9569 case 6: return index; // findIndex
9570 case 2: result.push(val); // filter
9571 } else if (IS_EVERY) return false; // every
9572 }
9573 }
9574 return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
9575 };
9576};
9577
9578},{"./_array-species-create":103,"./_ctx":111,"./_iobject":126,"./_to-length":172,"./_to-object":173}],102:[function(require,module,exports){
9579var isObject = require('./_is-object');
9580var isArray = require('./_is-array');
9581var SPECIES = require('./_wks')('species');
9582
9583module.exports = function (original) {
9584 var C;
9585 if (isArray(original)) {
9586 C = original.constructor;
9587 // cross-realm fallback
9588 if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
9589 if (isObject(C)) {
9590 C = C[SPECIES];
9591 if (C === null) C = undefined;
9592 }
9593 } return C === undefined ? Array : C;
9594};
9595
9596},{"./_is-array":128,"./_is-object":130,"./_wks":179}],103:[function(require,module,exports){
9597// 9.4.2.3 ArraySpeciesCreate(originalArray, length)
9598var speciesConstructor = require('./_array-species-constructor');
9599
9600module.exports = function (original, length) {
9601 return new (speciesConstructor(original))(length);
9602};
9603
9604},{"./_array-species-constructor":102}],104:[function(require,module,exports){
9605// getting tag from 19.1.3.6 Object.prototype.toString()
9606var cof = require('./_cof');
9607var TAG = require('./_wks')('toStringTag');
9608// ES3 wrong here
9609var ARG = cof(function () { return arguments; }()) == 'Arguments';
9610
9611// fallback for IE11 Script Access Denied error
9612var tryGet = function (it, key) {
9613 try {
9614 return it[key];
9615 } catch (e) { /* empty */ }
9616};
9617
9618module.exports = function (it) {
9619 var O, T, B;
9620 return it === undefined ? 'Undefined' : it === null ? 'Null'
9621 // @@toStringTag case
9622 : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
9623 // builtinTag case
9624 : ARG ? cof(O)
9625 // ES3 arguments fallback
9626 : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
9627};
9628
9629},{"./_cof":105,"./_wks":179}],105:[function(require,module,exports){
9630var toString = {}.toString;
9631
9632module.exports = function (it) {
9633 return toString.call(it).slice(8, -1);
9634};
9635
9636},{}],106:[function(require,module,exports){
9637'use strict';
9638var dP = require('./_object-dp').f;
9639var create = require('./_object-create');
9640var redefineAll = require('./_redefine-all');
9641var ctx = require('./_ctx');
9642var anInstance = require('./_an-instance');
9643var forOf = require('./_for-of');
9644var $iterDefine = require('./_iter-define');
9645var step = require('./_iter-step');
9646var setSpecies = require('./_set-species');
9647var DESCRIPTORS = require('./_descriptors');
9648var fastKey = require('./_meta').fastKey;
9649var validate = require('./_validate-collection');
9650var SIZE = DESCRIPTORS ? '_s' : 'size';
9651
9652var getEntry = function (that, key) {
9653 // fast case
9654 var index = fastKey(key);
9655 var entry;
9656 if (index !== 'F') return that._i[index];
9657 // frozen object case
9658 for (entry = that._f; entry; entry = entry.n) {
9659 if (entry.k == key) return entry;
9660 }
9661};
9662
9663module.exports = {
9664 getConstructor: function (wrapper, NAME, IS_MAP, ADDER) {
9665 var C = wrapper(function (that, iterable) {
9666 anInstance(that, C, NAME, '_i');
9667 that._t = NAME; // collection type
9668 that._i = create(null); // index
9669 that._f = undefined; // first entry
9670 that._l = undefined; // last entry
9671 that[SIZE] = 0; // size
9672 if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
9673 });
9674 redefineAll(C.prototype, {
9675 // 23.1.3.1 Map.prototype.clear()
9676 // 23.2.3.2 Set.prototype.clear()
9677 clear: function clear() {
9678 for (var that = validate(this, NAME), data = that._i, entry = that._f; entry; entry = entry.n) {
9679 entry.r = true;
9680 if (entry.p) entry.p = entry.p.n = undefined;
9681 delete data[entry.i];
9682 }
9683 that._f = that._l = undefined;
9684 that[SIZE] = 0;
9685 },
9686 // 23.1.3.3 Map.prototype.delete(key)
9687 // 23.2.3.4 Set.prototype.delete(value)
9688 'delete': function (key) {
9689 var that = validate(this, NAME);
9690 var entry = getEntry(that, key);
9691 if (entry) {
9692 var next = entry.n;
9693 var prev = entry.p;
9694 delete that._i[entry.i];
9695 entry.r = true;
9696 if (prev) prev.n = next;
9697 if (next) next.p = prev;
9698 if (that._f == entry) that._f = next;
9699 if (that._l == entry) that._l = prev;
9700 that[SIZE]--;
9701 } return !!entry;
9702 },
9703 // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)
9704 // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)
9705 forEach: function forEach(callbackfn /* , that = undefined */) {
9706 validate(this, NAME);
9707 var f = ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);
9708 var entry;
9709 while (entry = entry ? entry.n : this._f) {
9710 f(entry.v, entry.k, this);
9711 // revert to the last existing entry
9712 while (entry && entry.r) entry = entry.p;
9713 }
9714 },
9715 // 23.1.3.7 Map.prototype.has(key)
9716 // 23.2.3.7 Set.prototype.has(value)
9717 has: function has(key) {
9718 return !!getEntry(validate(this, NAME), key);
9719 }
9720 });
9721 if (DESCRIPTORS) dP(C.prototype, 'size', {
9722 get: function () {
9723 return validate(this, NAME)[SIZE];
9724 }
9725 });
9726 return C;
9727 },
9728 def: function (that, key, value) {
9729 var entry = getEntry(that, key);
9730 var prev, index;
9731 // change existing entry
9732 if (entry) {
9733 entry.v = value;
9734 // create new entry
9735 } else {
9736 that._l = entry = {
9737 i: index = fastKey(key, true), // <- index
9738 k: key, // <- key
9739 v: value, // <- value
9740 p: prev = that._l, // <- previous entry
9741 n: undefined, // <- next entry
9742 r: false // <- removed
9743 };
9744 if (!that._f) that._f = entry;
9745 if (prev) prev.n = entry;
9746 that[SIZE]++;
9747 // add to index
9748 if (index !== 'F') that._i[index] = entry;
9749 } return that;
9750 },
9751 getEntry: getEntry,
9752 setStrong: function (C, NAME, IS_MAP) {
9753 // add .keys, .values, .entries, [@@iterator]
9754 // 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11
9755 $iterDefine(C, NAME, function (iterated, kind) {
9756 this._t = validate(iterated, NAME); // target
9757 this._k = kind; // kind
9758 this._l = undefined; // previous
9759 }, function () {
9760 var that = this;
9761 var kind = that._k;
9762 var entry = that._l;
9763 // revert to the last existing entry
9764 while (entry && entry.r) entry = entry.p;
9765 // get next entry
9766 if (!that._t || !(that._l = entry = entry ? entry.n : that._t._f)) {
9767 // or finish the iteration
9768 that._t = undefined;
9769 return step(1);
9770 }
9771 // return step by kind
9772 if (kind == 'keys') return step(0, entry.k);
9773 if (kind == 'values') return step(0, entry.v);
9774 return step(0, [entry.k, entry.v]);
9775 }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
9776
9777 // add [@@species], 23.1.2.2, 23.2.2.2
9778 setSpecies(NAME);
9779 }
9780};
9781
9782},{"./_an-instance":97,"./_ctx":111,"./_descriptors":113,"./_for-of":119,"./_iter-define":133,"./_iter-step":135,"./_meta":138,"./_object-create":142,"./_object-dp":143,"./_redefine-all":157,"./_set-species":162,"./_validate-collection":176}],107:[function(require,module,exports){
9783// https://github.com/DavidBruant/Map-Set.prototype.toJSON
9784var classof = require('./_classof');
9785var from = require('./_array-from-iterable');
9786module.exports = function (NAME) {
9787 return function toJSON() {
9788 if (classof(this) != NAME) throw TypeError(NAME + "#toJSON isn't generic");
9789 return from(this);
9790 };
9791};
9792
9793},{"./_array-from-iterable":99,"./_classof":104}],108:[function(require,module,exports){
9794'use strict';
9795var global = require('./_global');
9796var $export = require('./_export');
9797var meta = require('./_meta');
9798var fails = require('./_fails');
9799var hide = require('./_hide');
9800var redefineAll = require('./_redefine-all');
9801var forOf = require('./_for-of');
9802var anInstance = require('./_an-instance');
9803var isObject = require('./_is-object');
9804var setToStringTag = require('./_set-to-string-tag');
9805var dP = require('./_object-dp').f;
9806var each = require('./_array-methods')(0);
9807var DESCRIPTORS = require('./_descriptors');
9808
9809module.exports = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {
9810 var Base = global[NAME];
9811 var C = Base;
9812 var ADDER = IS_MAP ? 'set' : 'add';
9813 var proto = C && C.prototype;
9814 var O = {};
9815 if (!DESCRIPTORS || typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function () {
9816 new C().entries().next();
9817 }))) {
9818 // create collection constructor
9819 C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
9820 redefineAll(C.prototype, methods);
9821 meta.NEED = true;
9822 } else {
9823 C = wrapper(function (target, iterable) {
9824 anInstance(target, C, NAME, '_c');
9825 target._c = new Base();
9826 if (iterable != undefined) forOf(iterable, IS_MAP, target[ADDER], target);
9827 });
9828 each('add,clear,delete,forEach,get,has,set,keys,values,entries,toJSON'.split(','), function (KEY) {
9829 var IS_ADDER = KEY == 'add' || KEY == 'set';
9830 if (KEY in proto && !(IS_WEAK && KEY == 'clear')) hide(C.prototype, KEY, function (a, b) {
9831 anInstance(this, C, KEY);
9832 if (!IS_ADDER && IS_WEAK && !isObject(a)) return KEY == 'get' ? undefined : false;
9833 var result = this._c[KEY](a === 0 ? 0 : a, b);
9834 return IS_ADDER ? this : result;
9835 });
9836 });
9837 IS_WEAK || dP(C.prototype, 'size', {
9838 get: function () {
9839 return this._c.size;
9840 }
9841 });
9842 }
9843
9844 setToStringTag(C, NAME);
9845
9846 O[NAME] = C;
9847 $export($export.G + $export.W + $export.F, O);
9848
9849 if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP);
9850
9851 return C;
9852};
9853
9854},{"./_an-instance":97,"./_array-methods":101,"./_descriptors":113,"./_export":117,"./_fails":118,"./_for-of":119,"./_global":120,"./_hide":122,"./_is-object":130,"./_meta":138,"./_object-dp":143,"./_redefine-all":157,"./_set-to-string-tag":163}],109:[function(require,module,exports){
9855var core = module.exports = { version: '2.5.3' };
9856if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
9857
9858},{}],110:[function(require,module,exports){
9859'use strict';
9860var $defineProperty = require('./_object-dp');
9861var createDesc = require('./_property-desc');
9862
9863module.exports = function (object, index, value) {
9864 if (index in object) $defineProperty.f(object, index, createDesc(0, value));
9865 else object[index] = value;
9866};
9867
9868},{"./_object-dp":143,"./_property-desc":156}],111:[function(require,module,exports){
9869// optional / simple context binding
9870var aFunction = require('./_a-function');
9871module.exports = function (fn, that, length) {
9872 aFunction(fn);
9873 if (that === undefined) return fn;
9874 switch (length) {
9875 case 1: return function (a) {
9876 return fn.call(that, a);
9877 };
9878 case 2: return function (a, b) {
9879 return fn.call(that, a, b);
9880 };
9881 case 3: return function (a, b, c) {
9882 return fn.call(that, a, b, c);
9883 };
9884 }
9885 return function (/* ...args */) {
9886 return fn.apply(that, arguments);
9887 };
9888};
9889
9890},{"./_a-function":95}],112:[function(require,module,exports){
9891// 7.2.1 RequireObjectCoercible(argument)
9892module.exports = function (it) {
9893 if (it == undefined) throw TypeError("Can't call method on " + it);
9894 return it;
9895};
9896
9897},{}],113:[function(require,module,exports){
9898// Thank's IE8 for his funny defineProperty
9899module.exports = !require('./_fails')(function () {
9900 return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
9901});
9902
9903},{"./_fails":118}],114:[function(require,module,exports){
9904var isObject = require('./_is-object');
9905var document = require('./_global').document;
9906// typeof document.createElement is 'object' in old IE
9907var is = isObject(document) && isObject(document.createElement);
9908module.exports = function (it) {
9909 return is ? document.createElement(it) : {};
9910};
9911
9912},{"./_global":120,"./_is-object":130}],115:[function(require,module,exports){
9913// IE 8- don't enum bug keys
9914module.exports = (
9915 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
9916).split(',');
9917
9918},{}],116:[function(require,module,exports){
9919// all enumerable object keys, includes symbols
9920var getKeys = require('./_object-keys');
9921var gOPS = require('./_object-gops');
9922var pIE = require('./_object-pie');
9923module.exports = function (it) {
9924 var result = getKeys(it);
9925 var getSymbols = gOPS.f;
9926 if (getSymbols) {
9927 var symbols = getSymbols(it);
9928 var isEnum = pIE.f;
9929 var i = 0;
9930 var key;
9931 while (symbols.length > i) if (isEnum.call(it, key = symbols[i++])) result.push(key);
9932 } return result;
9933};
9934
9935},{"./_object-gops":148,"./_object-keys":151,"./_object-pie":152}],117:[function(require,module,exports){
9936var global = require('./_global');
9937var core = require('./_core');
9938var ctx = require('./_ctx');
9939var hide = require('./_hide');
9940var PROTOTYPE = 'prototype';
9941
9942var $export = function (type, name, source) {
9943 var IS_FORCED = type & $export.F;
9944 var IS_GLOBAL = type & $export.G;
9945 var IS_STATIC = type & $export.S;
9946 var IS_PROTO = type & $export.P;
9947 var IS_BIND = type & $export.B;
9948 var IS_WRAP = type & $export.W;
9949 var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});
9950 var expProto = exports[PROTOTYPE];
9951 var target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE];
9952 var key, own, out;
9953 if (IS_GLOBAL) source = name;
9954 for (key in source) {
9955 // contains in native
9956 own = !IS_FORCED && target && target[key] !== undefined;
9957 if (own && key in exports) continue;
9958 // export native or passed
9959 out = own ? target[key] : source[key];
9960 // prevent global pollution for namespaces
9961 exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
9962 // bind timers to global for call from export context
9963 : IS_BIND && own ? ctx(out, global)
9964 // wrap global constructors for prevent change them in library
9965 : IS_WRAP && target[key] == out ? (function (C) {
9966 var F = function (a, b, c) {
9967 if (this instanceof C) {
9968 switch (arguments.length) {
9969 case 0: return new C();
9970 case 1: return new C(a);
9971 case 2: return new C(a, b);
9972 } return new C(a, b, c);
9973 } return C.apply(this, arguments);
9974 };
9975 F[PROTOTYPE] = C[PROTOTYPE];
9976 return F;
9977 // make static versions for prototype methods
9978 })(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
9979 // export proto methods to core.%CONSTRUCTOR%.methods.%NAME%
9980 if (IS_PROTO) {
9981 (exports.virtual || (exports.virtual = {}))[key] = out;
9982 // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%
9983 if (type & $export.R && expProto && !expProto[key]) hide(expProto, key, out);
9984 }
9985 }
9986};
9987// type bitmap
9988$export.F = 1; // forced
9989$export.G = 2; // global
9990$export.S = 4; // static
9991$export.P = 8; // proto
9992$export.B = 16; // bind
9993$export.W = 32; // wrap
9994$export.U = 64; // safe
9995$export.R = 128; // real proto method for `library`
9996module.exports = $export;
9997
9998},{"./_core":109,"./_ctx":111,"./_global":120,"./_hide":122}],118:[function(require,module,exports){
9999module.exports = function (exec) {
10000 try {
10001 return !!exec();
10002 } catch (e) {
10003 return true;
10004 }
10005};
10006
10007},{}],119:[function(require,module,exports){
10008var ctx = require('./_ctx');
10009var call = require('./_iter-call');
10010var isArrayIter = require('./_is-array-iter');
10011var anObject = require('./_an-object');
10012var toLength = require('./_to-length');
10013var getIterFn = require('./core.get-iterator-method');
10014var BREAK = {};
10015var RETURN = {};
10016var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
10017 var iterFn = ITERATOR ? function () { return iterable; } : getIterFn(iterable);
10018 var f = ctx(fn, that, entries ? 2 : 1);
10019 var index = 0;
10020 var length, step, iterator, result;
10021 if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
10022 // fast case for arrays with default iterator
10023 if (isArrayIter(iterFn)) for (length = toLength(iterable.length); length > index; index++) {
10024 result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
10025 if (result === BREAK || result === RETURN) return result;
10026 } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
10027 result = call(iterator, f, step.value, entries);
10028 if (result === BREAK || result === RETURN) return result;
10029 }
10030};
10031exports.BREAK = BREAK;
10032exports.RETURN = RETURN;
10033
10034},{"./_an-object":98,"./_ctx":111,"./_is-array-iter":127,"./_iter-call":131,"./_to-length":172,"./core.get-iterator-method":180}],120:[function(require,module,exports){
10035// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
10036var global = module.exports = typeof window != 'undefined' && window.Math == Math
10037 ? window : typeof self != 'undefined' && self.Math == Math ? self
10038 // eslint-disable-next-line no-new-func
10039 : Function('return this')();
10040if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
10041
10042},{}],121:[function(require,module,exports){
10043var hasOwnProperty = {}.hasOwnProperty;
10044module.exports = function (it, key) {
10045 return hasOwnProperty.call(it, key);
10046};
10047
10048},{}],122:[function(require,module,exports){
10049var dP = require('./_object-dp');
10050var createDesc = require('./_property-desc');
10051module.exports = require('./_descriptors') ? function (object, key, value) {
10052 return dP.f(object, key, createDesc(1, value));
10053} : function (object, key, value) {
10054 object[key] = value;
10055 return object;
10056};
10057
10058},{"./_descriptors":113,"./_object-dp":143,"./_property-desc":156}],123:[function(require,module,exports){
10059var document = require('./_global').document;
10060module.exports = document && document.documentElement;
10061
10062},{"./_global":120}],124:[function(require,module,exports){
10063module.exports = !require('./_descriptors') && !require('./_fails')(function () {
10064 return Object.defineProperty(require('./_dom-create')('div'), 'a', { get: function () { return 7; } }).a != 7;
10065});
10066
10067},{"./_descriptors":113,"./_dom-create":114,"./_fails":118}],125:[function(require,module,exports){
10068// fast apply, http://jsperf.lnkit.com/fast-apply/5
10069module.exports = function (fn, args, that) {
10070 var un = that === undefined;
10071 switch (args.length) {
10072 case 0: return un ? fn()
10073 : fn.call(that);
10074 case 1: return un ? fn(args[0])
10075 : fn.call(that, args[0]);
10076 case 2: return un ? fn(args[0], args[1])
10077 : fn.call(that, args[0], args[1]);
10078 case 3: return un ? fn(args[0], args[1], args[2])
10079 : fn.call(that, args[0], args[1], args[2]);
10080 case 4: return un ? fn(args[0], args[1], args[2], args[3])
10081 : fn.call(that, args[0], args[1], args[2], args[3]);
10082 } return fn.apply(that, args);
10083};
10084
10085},{}],126:[function(require,module,exports){
10086// fallback for non-array-like ES3 and non-enumerable old V8 strings
10087var cof = require('./_cof');
10088// eslint-disable-next-line no-prototype-builtins
10089module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
10090 return cof(it) == 'String' ? it.split('') : Object(it);
10091};
10092
10093},{"./_cof":105}],127:[function(require,module,exports){
10094// check on default Array iterator
10095var Iterators = require('./_iterators');
10096var ITERATOR = require('./_wks')('iterator');
10097var ArrayProto = Array.prototype;
10098
10099module.exports = function (it) {
10100 return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
10101};
10102
10103},{"./_iterators":136,"./_wks":179}],128:[function(require,module,exports){
10104// 7.2.2 IsArray(argument)
10105var cof = require('./_cof');
10106module.exports = Array.isArray || function isArray(arg) {
10107 return cof(arg) == 'Array';
10108};
10109
10110},{"./_cof":105}],129:[function(require,module,exports){
10111// 20.1.2.3 Number.isInteger(number)
10112var isObject = require('./_is-object');
10113var floor = Math.floor;
10114module.exports = function isInteger(it) {
10115 return !isObject(it) && isFinite(it) && floor(it) === it;
10116};
10117
10118},{"./_is-object":130}],130:[function(require,module,exports){
10119module.exports = function (it) {
10120 return typeof it === 'object' ? it !== null : typeof it === 'function';
10121};
10122
10123},{}],131:[function(require,module,exports){
10124// call something on iterator step with safe closing on error
10125var anObject = require('./_an-object');
10126module.exports = function (iterator, fn, value, entries) {
10127 try {
10128 return entries ? fn(anObject(value)[0], value[1]) : fn(value);
10129 // 7.4.6 IteratorClose(iterator, completion)
10130 } catch (e) {
10131 var ret = iterator['return'];
10132 if (ret !== undefined) anObject(ret.call(iterator));
10133 throw e;
10134 }
10135};
10136
10137},{"./_an-object":98}],132:[function(require,module,exports){
10138'use strict';
10139var create = require('./_object-create');
10140var descriptor = require('./_property-desc');
10141var setToStringTag = require('./_set-to-string-tag');
10142var IteratorPrototype = {};
10143
10144// 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
10145require('./_hide')(IteratorPrototype, require('./_wks')('iterator'), function () { return this; });
10146
10147module.exports = function (Constructor, NAME, next) {
10148 Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) });
10149 setToStringTag(Constructor, NAME + ' Iterator');
10150};
10151
10152},{"./_hide":122,"./_object-create":142,"./_property-desc":156,"./_set-to-string-tag":163,"./_wks":179}],133:[function(require,module,exports){
10153'use strict';
10154var LIBRARY = require('./_library');
10155var $export = require('./_export');
10156var redefine = require('./_redefine');
10157var hide = require('./_hide');
10158var has = require('./_has');
10159var Iterators = require('./_iterators');
10160var $iterCreate = require('./_iter-create');
10161var setToStringTag = require('./_set-to-string-tag');
10162var getPrototypeOf = require('./_object-gpo');
10163var ITERATOR = require('./_wks')('iterator');
10164var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
10165var FF_ITERATOR = '@@iterator';
10166var KEYS = 'keys';
10167var VALUES = 'values';
10168
10169var returnThis = function () { return this; };
10170
10171module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
10172 $iterCreate(Constructor, NAME, next);
10173 var getMethod = function (kind) {
10174 if (!BUGGY && kind in proto) return proto[kind];
10175 switch (kind) {
10176 case KEYS: return function keys() { return new Constructor(this, kind); };
10177 case VALUES: return function values() { return new Constructor(this, kind); };
10178 } return function entries() { return new Constructor(this, kind); };
10179 };
10180 var TAG = NAME + ' Iterator';
10181 var DEF_VALUES = DEFAULT == VALUES;
10182 var VALUES_BUG = false;
10183 var proto = Base.prototype;
10184 var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
10185 var $default = (!BUGGY && $native) || getMethod(DEFAULT);
10186 var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
10187 var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
10188 var methods, key, IteratorPrototype;
10189 // Fix native
10190 if ($anyNative) {
10191 IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));
10192 if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
10193 // Set @@toStringTag to native iterators
10194 setToStringTag(IteratorPrototype, TAG, true);
10195 // fix for some old engines
10196 if (!LIBRARY && !has(IteratorPrototype, ITERATOR)) hide(IteratorPrototype, ITERATOR, returnThis);
10197 }
10198 }
10199 // fix Array#{values, @@iterator}.name in V8 / FF
10200 if (DEF_VALUES && $native && $native.name !== VALUES) {
10201 VALUES_BUG = true;
10202 $default = function values() { return $native.call(this); };
10203 }
10204 // Define iterator
10205 if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
10206 hide(proto, ITERATOR, $default);
10207 }
10208 // Plug for library
10209 Iterators[NAME] = $default;
10210 Iterators[TAG] = returnThis;
10211 if (DEFAULT) {
10212 methods = {
10213 values: DEF_VALUES ? $default : getMethod(VALUES),
10214 keys: IS_SET ? $default : getMethod(KEYS),
10215 entries: $entries
10216 };
10217 if (FORCED) for (key in methods) {
10218 if (!(key in proto)) redefine(proto, key, methods[key]);
10219 } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
10220 }
10221 return methods;
10222};
10223
10224},{"./_export":117,"./_has":121,"./_hide":122,"./_iter-create":132,"./_iterators":136,"./_library":137,"./_object-gpo":149,"./_redefine":158,"./_set-to-string-tag":163,"./_wks":179}],134:[function(require,module,exports){
10225var ITERATOR = require('./_wks')('iterator');
10226var SAFE_CLOSING = false;
10227
10228try {
10229 var riter = [7][ITERATOR]();
10230 riter['return'] = function () { SAFE_CLOSING = true; };
10231 // eslint-disable-next-line no-throw-literal
10232 Array.from(riter, function () { throw 2; });
10233} catch (e) { /* empty */ }
10234
10235module.exports = function (exec, skipClosing) {
10236 if (!skipClosing && !SAFE_CLOSING) return false;
10237 var safe = false;
10238 try {
10239 var arr = [7];
10240 var iter = arr[ITERATOR]();
10241 iter.next = function () { return { done: safe = true }; };
10242 arr[ITERATOR] = function () { return iter; };
10243 exec(arr);
10244 } catch (e) { /* empty */ }
10245 return safe;
10246};
10247
10248},{"./_wks":179}],135:[function(require,module,exports){
10249module.exports = function (done, value) {
10250 return { value: value, done: !!done };
10251};
10252
10253},{}],136:[function(require,module,exports){
10254module.exports = {};
10255
10256},{}],137:[function(require,module,exports){
10257module.exports = true;
10258
10259},{}],138:[function(require,module,exports){
10260var META = require('./_uid')('meta');
10261var isObject = require('./_is-object');
10262var has = require('./_has');
10263var setDesc = require('./_object-dp').f;
10264var id = 0;
10265var isExtensible = Object.isExtensible || function () {
10266 return true;
10267};
10268var FREEZE = !require('./_fails')(function () {
10269 return isExtensible(Object.preventExtensions({}));
10270});
10271var setMeta = function (it) {
10272 setDesc(it, META, { value: {
10273 i: 'O' + ++id, // object ID
10274 w: {} // weak collections IDs
10275 } });
10276};
10277var fastKey = function (it, create) {
10278 // return primitive with prefix
10279 if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
10280 if (!has(it, META)) {
10281 // can't set metadata to uncaught frozen object
10282 if (!isExtensible(it)) return 'F';
10283 // not necessary to add metadata
10284 if (!create) return 'E';
10285 // add missing metadata
10286 setMeta(it);
10287 // return object ID
10288 } return it[META].i;
10289};
10290var getWeak = function (it, create) {
10291 if (!has(it, META)) {
10292 // can't set metadata to uncaught frozen object
10293 if (!isExtensible(it)) return true;
10294 // not necessary to add metadata
10295 if (!create) return false;
10296 // add missing metadata
10297 setMeta(it);
10298 // return hash weak collections IDs
10299 } return it[META].w;
10300};
10301// add metadata on freeze-family methods calling
10302var onFreeze = function (it) {
10303 if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it);
10304 return it;
10305};
10306var meta = module.exports = {
10307 KEY: META,
10308 NEED: false,
10309 fastKey: fastKey,
10310 getWeak: getWeak,
10311 onFreeze: onFreeze
10312};
10313
10314},{"./_fails":118,"./_has":121,"./_is-object":130,"./_object-dp":143,"./_uid":175}],139:[function(require,module,exports){
10315var global = require('./_global');
10316var macrotask = require('./_task').set;
10317var Observer = global.MutationObserver || global.WebKitMutationObserver;
10318var process = global.process;
10319var Promise = global.Promise;
10320var isNode = require('./_cof')(process) == 'process';
10321
10322module.exports = function () {
10323 var head, last, notify;
10324
10325 var flush = function () {
10326 var parent, fn;
10327 if (isNode && (parent = process.domain)) parent.exit();
10328 while (head) {
10329 fn = head.fn;
10330 head = head.next;
10331 try {
10332 fn();
10333 } catch (e) {
10334 if (head) notify();
10335 else last = undefined;
10336 throw e;
10337 }
10338 } last = undefined;
10339 if (parent) parent.enter();
10340 };
10341
10342 // Node.js
10343 if (isNode) {
10344 notify = function () {
10345 process.nextTick(flush);
10346 };
10347 // browsers with MutationObserver, except iOS Safari - https://github.com/zloirock/core-js/issues/339
10348 } else if (Observer && !(global.navigator && global.navigator.standalone)) {
10349 var toggle = true;
10350 var node = document.createTextNode('');
10351 new Observer(flush).observe(node, { characterData: true }); // eslint-disable-line no-new
10352 notify = function () {
10353 node.data = toggle = !toggle;
10354 };
10355 // environments with maybe non-completely correct, but existent Promise
10356 } else if (Promise && Promise.resolve) {
10357 var promise = Promise.resolve();
10358 notify = function () {
10359 promise.then(flush);
10360 };
10361 // for other environments - macrotask based on:
10362 // - setImmediate
10363 // - MessageChannel
10364 // - window.postMessag
10365 // - onreadystatechange
10366 // - setTimeout
10367 } else {
10368 notify = function () {
10369 // strange IE + webpack dev server bug - use .call(global)
10370 macrotask.call(global, flush);
10371 };
10372 }
10373
10374 return function (fn) {
10375 var task = { fn: fn, next: undefined };
10376 if (last) last.next = task;
10377 if (!head) {
10378 head = task;
10379 notify();
10380 } last = task;
10381 };
10382};
10383
10384},{"./_cof":105,"./_global":120,"./_task":168}],140:[function(require,module,exports){
10385'use strict';
10386// 25.4.1.5 NewPromiseCapability(C)
10387var aFunction = require('./_a-function');
10388
10389function PromiseCapability(C) {
10390 var resolve, reject;
10391 this.promise = new C(function ($$resolve, $$reject) {
10392 if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
10393 resolve = $$resolve;
10394 reject = $$reject;
10395 });
10396 this.resolve = aFunction(resolve);
10397 this.reject = aFunction(reject);
10398}
10399
10400module.exports.f = function (C) {
10401 return new PromiseCapability(C);
10402};
10403
10404},{"./_a-function":95}],141:[function(require,module,exports){
10405'use strict';
10406// 19.1.2.1 Object.assign(target, source, ...)
10407var getKeys = require('./_object-keys');
10408var gOPS = require('./_object-gops');
10409var pIE = require('./_object-pie');
10410var toObject = require('./_to-object');
10411var IObject = require('./_iobject');
10412var $assign = Object.assign;
10413
10414// should work with symbols and should have deterministic property order (V8 bug)
10415module.exports = !$assign || require('./_fails')(function () {
10416 var A = {};
10417 var B = {};
10418 // eslint-disable-next-line no-undef
10419 var S = Symbol();
10420 var K = 'abcdefghijklmnopqrst';
10421 A[S] = 7;
10422 K.split('').forEach(function (k) { B[k] = k; });
10423 return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
10424}) ? function assign(target, source) { // eslint-disable-line no-unused-vars
10425 var T = toObject(target);
10426 var aLen = arguments.length;
10427 var index = 1;
10428 var getSymbols = gOPS.f;
10429 var isEnum = pIE.f;
10430 while (aLen > index) {
10431 var S = IObject(arguments[index++]);
10432 var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S);
10433 var length = keys.length;
10434 var j = 0;
10435 var key;
10436 while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key];
10437 } return T;
10438} : $assign;
10439
10440},{"./_fails":118,"./_iobject":126,"./_object-gops":148,"./_object-keys":151,"./_object-pie":152,"./_to-object":173}],142:[function(require,module,exports){
10441// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
10442var anObject = require('./_an-object');
10443var dPs = require('./_object-dps');
10444var enumBugKeys = require('./_enum-bug-keys');
10445var IE_PROTO = require('./_shared-key')('IE_PROTO');
10446var Empty = function () { /* empty */ };
10447var PROTOTYPE = 'prototype';
10448
10449// Create object with fake `null` prototype: use iframe Object with cleared prototype
10450var createDict = function () {
10451 // Thrash, waste and sodomy: IE GC bug
10452 var iframe = require('./_dom-create')('iframe');
10453 var i = enumBugKeys.length;
10454 var lt = '<';
10455 var gt = '>';
10456 var iframeDocument;
10457 iframe.style.display = 'none';
10458 require('./_html').appendChild(iframe);
10459 iframe.src = 'javascript:'; // eslint-disable-line no-script-url
10460 // createDict = iframe.contentWindow.Object;
10461 // html.removeChild(iframe);
10462 iframeDocument = iframe.contentWindow.document;
10463 iframeDocument.open();
10464 iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
10465 iframeDocument.close();
10466 createDict = iframeDocument.F;
10467 while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]];
10468 return createDict();
10469};
10470
10471module.exports = Object.create || function create(O, Properties) {
10472 var result;
10473 if (O !== null) {
10474 Empty[PROTOTYPE] = anObject(O);
10475 result = new Empty();
10476 Empty[PROTOTYPE] = null;
10477 // add "__proto__" for Object.getPrototypeOf polyfill
10478 result[IE_PROTO] = O;
10479 } else result = createDict();
10480 return Properties === undefined ? result : dPs(result, Properties);
10481};
10482
10483},{"./_an-object":98,"./_dom-create":114,"./_enum-bug-keys":115,"./_html":123,"./_object-dps":144,"./_shared-key":164}],143:[function(require,module,exports){
10484var anObject = require('./_an-object');
10485var IE8_DOM_DEFINE = require('./_ie8-dom-define');
10486var toPrimitive = require('./_to-primitive');
10487var dP = Object.defineProperty;
10488
10489exports.f = require('./_descriptors') ? Object.defineProperty : function defineProperty(O, P, Attributes) {
10490 anObject(O);
10491 P = toPrimitive(P, true);
10492 anObject(Attributes);
10493 if (IE8_DOM_DEFINE) try {
10494 return dP(O, P, Attributes);
10495 } catch (e) { /* empty */ }
10496 if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
10497 if ('value' in Attributes) O[P] = Attributes.value;
10498 return O;
10499};
10500
10501},{"./_an-object":98,"./_descriptors":113,"./_ie8-dom-define":124,"./_to-primitive":174}],144:[function(require,module,exports){
10502var dP = require('./_object-dp');
10503var anObject = require('./_an-object');
10504var getKeys = require('./_object-keys');
10505
10506module.exports = require('./_descriptors') ? Object.defineProperties : function defineProperties(O, Properties) {
10507 anObject(O);
10508 var keys = getKeys(Properties);
10509 var length = keys.length;
10510 var i = 0;
10511 var P;
10512 while (length > i) dP.f(O, P = keys[i++], Properties[P]);
10513 return O;
10514};
10515
10516},{"./_an-object":98,"./_descriptors":113,"./_object-dp":143,"./_object-keys":151}],145:[function(require,module,exports){
10517var pIE = require('./_object-pie');
10518var createDesc = require('./_property-desc');
10519var toIObject = require('./_to-iobject');
10520var toPrimitive = require('./_to-primitive');
10521var has = require('./_has');
10522var IE8_DOM_DEFINE = require('./_ie8-dom-define');
10523var gOPD = Object.getOwnPropertyDescriptor;
10524
10525exports.f = require('./_descriptors') ? gOPD : function getOwnPropertyDescriptor(O, P) {
10526 O = toIObject(O);
10527 P = toPrimitive(P, true);
10528 if (IE8_DOM_DEFINE) try {
10529 return gOPD(O, P);
10530 } catch (e) { /* empty */ }
10531 if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]);
10532};
10533
10534},{"./_descriptors":113,"./_has":121,"./_ie8-dom-define":124,"./_object-pie":152,"./_property-desc":156,"./_to-iobject":171,"./_to-primitive":174}],146:[function(require,module,exports){
10535// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
10536var toIObject = require('./_to-iobject');
10537var gOPN = require('./_object-gopn').f;
10538var toString = {}.toString;
10539
10540var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
10541 ? Object.getOwnPropertyNames(window) : [];
10542
10543var getWindowNames = function (it) {
10544 try {
10545 return gOPN(it);
10546 } catch (e) {
10547 return windowNames.slice();
10548 }
10549};
10550
10551module.exports.f = function getOwnPropertyNames(it) {
10552 return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it));
10553};
10554
10555},{"./_object-gopn":147,"./_to-iobject":171}],147:[function(require,module,exports){
10556// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
10557var $keys = require('./_object-keys-internal');
10558var hiddenKeys = require('./_enum-bug-keys').concat('length', 'prototype');
10559
10560exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
10561 return $keys(O, hiddenKeys);
10562};
10563
10564},{"./_enum-bug-keys":115,"./_object-keys-internal":150}],148:[function(require,module,exports){
10565exports.f = Object.getOwnPropertySymbols;
10566
10567},{}],149:[function(require,module,exports){
10568// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
10569var has = require('./_has');
10570var toObject = require('./_to-object');
10571var IE_PROTO = require('./_shared-key')('IE_PROTO');
10572var ObjectProto = Object.prototype;
10573
10574module.exports = Object.getPrototypeOf || function (O) {
10575 O = toObject(O);
10576 if (has(O, IE_PROTO)) return O[IE_PROTO];
10577 if (typeof O.constructor == 'function' && O instanceof O.constructor) {
10578 return O.constructor.prototype;
10579 } return O instanceof Object ? ObjectProto : null;
10580};
10581
10582},{"./_has":121,"./_shared-key":164,"./_to-object":173}],150:[function(require,module,exports){
10583var has = require('./_has');
10584var toIObject = require('./_to-iobject');
10585var arrayIndexOf = require('./_array-includes')(false);
10586var IE_PROTO = require('./_shared-key')('IE_PROTO');
10587
10588module.exports = function (object, names) {
10589 var O = toIObject(object);
10590 var i = 0;
10591 var result = [];
10592 var key;
10593 for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key);
10594 // Don't enum bug & hidden keys
10595 while (names.length > i) if (has(O, key = names[i++])) {
10596 ~arrayIndexOf(result, key) || result.push(key);
10597 }
10598 return result;
10599};
10600
10601},{"./_array-includes":100,"./_has":121,"./_shared-key":164,"./_to-iobject":171}],151:[function(require,module,exports){
10602// 19.1.2.14 / 15.2.3.14 Object.keys(O)
10603var $keys = require('./_object-keys-internal');
10604var enumBugKeys = require('./_enum-bug-keys');
10605
10606module.exports = Object.keys || function keys(O) {
10607 return $keys(O, enumBugKeys);
10608};
10609
10610},{"./_enum-bug-keys":115,"./_object-keys-internal":150}],152:[function(require,module,exports){
10611exports.f = {}.propertyIsEnumerable;
10612
10613},{}],153:[function(require,module,exports){
10614// most Object methods by ES6 should accept primitives
10615var $export = require('./_export');
10616var core = require('./_core');
10617var fails = require('./_fails');
10618module.exports = function (KEY, exec) {
10619 var fn = (core.Object || {})[KEY] || Object[KEY];
10620 var exp = {};
10621 exp[KEY] = exec(fn);
10622 $export($export.S + $export.F * fails(function () { fn(1); }), 'Object', exp);
10623};
10624
10625},{"./_core":109,"./_export":117,"./_fails":118}],154:[function(require,module,exports){
10626module.exports = function (exec) {
10627 try {
10628 return { e: false, v: exec() };
10629 } catch (e) {
10630 return { e: true, v: e };
10631 }
10632};
10633
10634},{}],155:[function(require,module,exports){
10635var anObject = require('./_an-object');
10636var isObject = require('./_is-object');
10637var newPromiseCapability = require('./_new-promise-capability');
10638
10639module.exports = function (C, x) {
10640 anObject(C);
10641 if (isObject(x) && x.constructor === C) return x;
10642 var promiseCapability = newPromiseCapability.f(C);
10643 var resolve = promiseCapability.resolve;
10644 resolve(x);
10645 return promiseCapability.promise;
10646};
10647
10648},{"./_an-object":98,"./_is-object":130,"./_new-promise-capability":140}],156:[function(require,module,exports){
10649module.exports = function (bitmap, value) {
10650 return {
10651 enumerable: !(bitmap & 1),
10652 configurable: !(bitmap & 2),
10653 writable: !(bitmap & 4),
10654 value: value
10655 };
10656};
10657
10658},{}],157:[function(require,module,exports){
10659var hide = require('./_hide');
10660module.exports = function (target, src, safe) {
10661 for (var key in src) {
10662 if (safe && target[key]) target[key] = src[key];
10663 else hide(target, key, src[key]);
10664 } return target;
10665};
10666
10667},{"./_hide":122}],158:[function(require,module,exports){
10668module.exports = require('./_hide');
10669
10670},{"./_hide":122}],159:[function(require,module,exports){
10671'use strict';
10672// https://tc39.github.io/proposal-setmap-offrom/
10673var $export = require('./_export');
10674var aFunction = require('./_a-function');
10675var ctx = require('./_ctx');
10676var forOf = require('./_for-of');
10677
10678module.exports = function (COLLECTION) {
10679 $export($export.S, COLLECTION, { from: function from(source /* , mapFn, thisArg */) {
10680 var mapFn = arguments[1];
10681 var mapping, A, n, cb;
10682 aFunction(this);
10683 mapping = mapFn !== undefined;
10684 if (mapping) aFunction(mapFn);
10685 if (source == undefined) return new this();
10686 A = [];
10687 if (mapping) {
10688 n = 0;
10689 cb = ctx(mapFn, arguments[2], 2);
10690 forOf(source, false, function (nextItem) {
10691 A.push(cb(nextItem, n++));
10692 });
10693 } else {
10694 forOf(source, false, A.push, A);
10695 }
10696 return new this(A);
10697 } });
10698};
10699
10700},{"./_a-function":95,"./_ctx":111,"./_export":117,"./_for-of":119}],160:[function(require,module,exports){
10701'use strict';
10702// https://tc39.github.io/proposal-setmap-offrom/
10703var $export = require('./_export');
10704
10705module.exports = function (COLLECTION) {
10706 $export($export.S, COLLECTION, { of: function of() {
10707 var length = arguments.length;
10708 var A = new Array(length);
10709 while (length--) A[length] = arguments[length];
10710 return new this(A);
10711 } });
10712};
10713
10714},{"./_export":117}],161:[function(require,module,exports){
10715// Works with __proto__ only. Old v8 can't work with null proto objects.
10716/* eslint-disable no-proto */
10717var isObject = require('./_is-object');
10718var anObject = require('./_an-object');
10719var check = function (O, proto) {
10720 anObject(O);
10721 if (!isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!");
10722};
10723module.exports = {
10724 set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line
10725 function (test, buggy, set) {
10726 try {
10727 set = require('./_ctx')(Function.call, require('./_object-gopd').f(Object.prototype, '__proto__').set, 2);
10728 set(test, []);
10729 buggy = !(test instanceof Array);
10730 } catch (e) { buggy = true; }
10731 return function setPrototypeOf(O, proto) {
10732 check(O, proto);
10733 if (buggy) O.__proto__ = proto;
10734 else set(O, proto);
10735 return O;
10736 };
10737 }({}, false) : undefined),
10738 check: check
10739};
10740
10741},{"./_an-object":98,"./_ctx":111,"./_is-object":130,"./_object-gopd":145}],162:[function(require,module,exports){
10742'use strict';
10743var global = require('./_global');
10744var core = require('./_core');
10745var dP = require('./_object-dp');
10746var DESCRIPTORS = require('./_descriptors');
10747var SPECIES = require('./_wks')('species');
10748
10749module.exports = function (KEY) {
10750 var C = typeof core[KEY] == 'function' ? core[KEY] : global[KEY];
10751 if (DESCRIPTORS && C && !C[SPECIES]) dP.f(C, SPECIES, {
10752 configurable: true,
10753 get: function () { return this; }
10754 });
10755};
10756
10757},{"./_core":109,"./_descriptors":113,"./_global":120,"./_object-dp":143,"./_wks":179}],163:[function(require,module,exports){
10758var def = require('./_object-dp').f;
10759var has = require('./_has');
10760var TAG = require('./_wks')('toStringTag');
10761
10762module.exports = function (it, tag, stat) {
10763 if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });
10764};
10765
10766},{"./_has":121,"./_object-dp":143,"./_wks":179}],164:[function(require,module,exports){
10767var shared = require('./_shared')('keys');
10768var uid = require('./_uid');
10769module.exports = function (key) {
10770 return shared[key] || (shared[key] = uid(key));
10771};
10772
10773},{"./_shared":165,"./_uid":175}],165:[function(require,module,exports){
10774var global = require('./_global');
10775var SHARED = '__core-js_shared__';
10776var store = global[SHARED] || (global[SHARED] = {});
10777module.exports = function (key) {
10778 return store[key] || (store[key] = {});
10779};
10780
10781},{"./_global":120}],166:[function(require,module,exports){
10782// 7.3.20 SpeciesConstructor(O, defaultConstructor)
10783var anObject = require('./_an-object');
10784var aFunction = require('./_a-function');
10785var SPECIES = require('./_wks')('species');
10786module.exports = function (O, D) {
10787 var C = anObject(O).constructor;
10788 var S;
10789 return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);
10790};
10791
10792},{"./_a-function":95,"./_an-object":98,"./_wks":179}],167:[function(require,module,exports){
10793var toInteger = require('./_to-integer');
10794var defined = require('./_defined');
10795// true -> String#at
10796// false -> String#codePointAt
10797module.exports = function (TO_STRING) {
10798 return function (that, pos) {
10799 var s = String(defined(that));
10800 var i = toInteger(pos);
10801 var l = s.length;
10802 var a, b;
10803 if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
10804 a = s.charCodeAt(i);
10805 return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
10806 ? TO_STRING ? s.charAt(i) : a
10807 : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
10808 };
10809};
10810
10811},{"./_defined":112,"./_to-integer":170}],168:[function(require,module,exports){
10812var ctx = require('./_ctx');
10813var invoke = require('./_invoke');
10814var html = require('./_html');
10815var cel = require('./_dom-create');
10816var global = require('./_global');
10817var process = global.process;
10818var setTask = global.setImmediate;
10819var clearTask = global.clearImmediate;
10820var MessageChannel = global.MessageChannel;
10821var Dispatch = global.Dispatch;
10822var counter = 0;
10823var queue = {};
10824var ONREADYSTATECHANGE = 'onreadystatechange';
10825var defer, channel, port;
10826var run = function () {
10827 var id = +this;
10828 // eslint-disable-next-line no-prototype-builtins
10829 if (queue.hasOwnProperty(id)) {
10830 var fn = queue[id];
10831 delete queue[id];
10832 fn();
10833 }
10834};
10835var listener = function (event) {
10836 run.call(event.data);
10837};
10838// Node.js 0.9+ & IE10+ has setImmediate, otherwise:
10839if (!setTask || !clearTask) {
10840 setTask = function setImmediate(fn) {
10841 var args = [];
10842 var i = 1;
10843 while (arguments.length > i) args.push(arguments[i++]);
10844 queue[++counter] = function () {
10845 // eslint-disable-next-line no-new-func
10846 invoke(typeof fn == 'function' ? fn : Function(fn), args);
10847 };
10848 defer(counter);
10849 return counter;
10850 };
10851 clearTask = function clearImmediate(id) {
10852 delete queue[id];
10853 };
10854 // Node.js 0.8-
10855 if (require('./_cof')(process) == 'process') {
10856 defer = function (id) {
10857 process.nextTick(ctx(run, id, 1));
10858 };
10859 // Sphere (JS game engine) Dispatch API
10860 } else if (Dispatch && Dispatch.now) {
10861 defer = function (id) {
10862 Dispatch.now(ctx(run, id, 1));
10863 };
10864 // Browsers with MessageChannel, includes WebWorkers
10865 } else if (MessageChannel) {
10866 channel = new MessageChannel();
10867 port = channel.port2;
10868 channel.port1.onmessage = listener;
10869 defer = ctx(port.postMessage, port, 1);
10870 // Browsers with postMessage, skip WebWorkers
10871 // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
10872 } else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts) {
10873 defer = function (id) {
10874 global.postMessage(id + '', '*');
10875 };
10876 global.addEventListener('message', listener, false);
10877 // IE8-
10878 } else if (ONREADYSTATECHANGE in cel('script')) {
10879 defer = function (id) {
10880 html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function () {
10881 html.removeChild(this);
10882 run.call(id);
10883 };
10884 };
10885 // Rest old browsers
10886 } else {
10887 defer = function (id) {
10888 setTimeout(ctx(run, id, 1), 0);
10889 };
10890 }
10891}
10892module.exports = {
10893 set: setTask,
10894 clear: clearTask
10895};
10896
10897},{"./_cof":105,"./_ctx":111,"./_dom-create":114,"./_global":120,"./_html":123,"./_invoke":125}],169:[function(require,module,exports){
10898var toInteger = require('./_to-integer');
10899var max = Math.max;
10900var min = Math.min;
10901module.exports = function (index, length) {
10902 index = toInteger(index);
10903 return index < 0 ? max(index + length, 0) : min(index, length);
10904};
10905
10906},{"./_to-integer":170}],170:[function(require,module,exports){
10907// 7.1.4 ToInteger
10908var ceil = Math.ceil;
10909var floor = Math.floor;
10910module.exports = function (it) {
10911 return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
10912};
10913
10914},{}],171:[function(require,module,exports){
10915// to indexed object, toObject with fallback for non-array-like ES3 strings
10916var IObject = require('./_iobject');
10917var defined = require('./_defined');
10918module.exports = function (it) {
10919 return IObject(defined(it));
10920};
10921
10922},{"./_defined":112,"./_iobject":126}],172:[function(require,module,exports){
10923// 7.1.15 ToLength
10924var toInteger = require('./_to-integer');
10925var min = Math.min;
10926module.exports = function (it) {
10927 return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
10928};
10929
10930},{"./_to-integer":170}],173:[function(require,module,exports){
10931// 7.1.13 ToObject(argument)
10932var defined = require('./_defined');
10933module.exports = function (it) {
10934 return Object(defined(it));
10935};
10936
10937},{"./_defined":112}],174:[function(require,module,exports){
10938// 7.1.1 ToPrimitive(input [, PreferredType])
10939var isObject = require('./_is-object');
10940// instead of the ES6 spec version, we didn't implement @@toPrimitive case
10941// and the second argument - flag - preferred type is a string
10942module.exports = function (it, S) {
10943 if (!isObject(it)) return it;
10944 var fn, val;
10945 if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
10946 if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
10947 if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
10948 throw TypeError("Can't convert object to primitive value");
10949};
10950
10951},{"./_is-object":130}],175:[function(require,module,exports){
10952var id = 0;
10953var px = Math.random();
10954module.exports = function (key) {
10955 return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
10956};
10957
10958},{}],176:[function(require,module,exports){
10959var isObject = require('./_is-object');
10960module.exports = function (it, TYPE) {
10961 if (!isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!');
10962 return it;
10963};
10964
10965},{"./_is-object":130}],177:[function(require,module,exports){
10966var global = require('./_global');
10967var core = require('./_core');
10968var LIBRARY = require('./_library');
10969var wksExt = require('./_wks-ext');
10970var defineProperty = require('./_object-dp').f;
10971module.exports = function (name) {
10972 var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});
10973 if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: wksExt.f(name) });
10974};
10975
10976},{"./_core":109,"./_global":120,"./_library":137,"./_object-dp":143,"./_wks-ext":178}],178:[function(require,module,exports){
10977exports.f = require('./_wks');
10978
10979},{"./_wks":179}],179:[function(require,module,exports){
10980var store = require('./_shared')('wks');
10981var uid = require('./_uid');
10982var Symbol = require('./_global').Symbol;
10983var USE_SYMBOL = typeof Symbol == 'function';
10984
10985var $exports = module.exports = function (name) {
10986 return store[name] || (store[name] =
10987 USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
10988};
10989
10990$exports.store = store;
10991
10992},{"./_global":120,"./_shared":165,"./_uid":175}],180:[function(require,module,exports){
10993var classof = require('./_classof');
10994var ITERATOR = require('./_wks')('iterator');
10995var Iterators = require('./_iterators');
10996module.exports = require('./_core').getIteratorMethod = function (it) {
10997 if (it != undefined) return it[ITERATOR]
10998 || it['@@iterator']
10999 || Iterators[classof(it)];
11000};
11001
11002},{"./_classof":104,"./_core":109,"./_iterators":136,"./_wks":179}],181:[function(require,module,exports){
11003var anObject = require('./_an-object');
11004var get = require('./core.get-iterator-method');
11005module.exports = require('./_core').getIterator = function (it) {
11006 var iterFn = get(it);
11007 if (typeof iterFn != 'function') throw TypeError(it + ' is not iterable!');
11008 return anObject(iterFn.call(it));
11009};
11010
11011},{"./_an-object":98,"./_core":109,"./core.get-iterator-method":180}],182:[function(require,module,exports){
11012var classof = require('./_classof');
11013var ITERATOR = require('./_wks')('iterator');
11014var Iterators = require('./_iterators');
11015module.exports = require('./_core').isIterable = function (it) {
11016 var O = Object(it);
11017 return O[ITERATOR] !== undefined
11018 || '@@iterator' in O
11019 // eslint-disable-next-line no-prototype-builtins
11020 || Iterators.hasOwnProperty(classof(O));
11021};
11022
11023},{"./_classof":104,"./_core":109,"./_iterators":136,"./_wks":179}],183:[function(require,module,exports){
11024'use strict';
11025var ctx = require('./_ctx');
11026var $export = require('./_export');
11027var toObject = require('./_to-object');
11028var call = require('./_iter-call');
11029var isArrayIter = require('./_is-array-iter');
11030var toLength = require('./_to-length');
11031var createProperty = require('./_create-property');
11032var getIterFn = require('./core.get-iterator-method');
11033
11034$export($export.S + $export.F * !require('./_iter-detect')(function (iter) { Array.from(iter); }), 'Array', {
11035 // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
11036 from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
11037 var O = toObject(arrayLike);
11038 var C = typeof this == 'function' ? this : Array;
11039 var aLen = arguments.length;
11040 var mapfn = aLen > 1 ? arguments[1] : undefined;
11041 var mapping = mapfn !== undefined;
11042 var index = 0;
11043 var iterFn = getIterFn(O);
11044 var length, result, step, iterator;
11045 if (mapping) mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
11046 // if object isn't iterable or it's array with default iterator - use simple case
11047 if (iterFn != undefined && !(C == Array && isArrayIter(iterFn))) {
11048 for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) {
11049 createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value);
11050 }
11051 } else {
11052 length = toLength(O.length);
11053 for (result = new C(length); length > index; index++) {
11054 createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
11055 }
11056 }
11057 result.length = index;
11058 return result;
11059 }
11060});
11061
11062},{"./_create-property":110,"./_ctx":111,"./_export":117,"./_is-array-iter":127,"./_iter-call":131,"./_iter-detect":134,"./_to-length":172,"./_to-object":173,"./core.get-iterator-method":180}],184:[function(require,module,exports){
11063'use strict';
11064var addToUnscopables = require('./_add-to-unscopables');
11065var step = require('./_iter-step');
11066var Iterators = require('./_iterators');
11067var toIObject = require('./_to-iobject');
11068
11069// 22.1.3.4 Array.prototype.entries()
11070// 22.1.3.13 Array.prototype.keys()
11071// 22.1.3.29 Array.prototype.values()
11072// 22.1.3.30 Array.prototype[@@iterator]()
11073module.exports = require('./_iter-define')(Array, 'Array', function (iterated, kind) {
11074 this._t = toIObject(iterated); // target
11075 this._i = 0; // next index
11076 this._k = kind; // kind
11077// 22.1.5.2.1 %ArrayIteratorPrototype%.next()
11078}, function () {
11079 var O = this._t;
11080 var kind = this._k;
11081 var index = this._i++;
11082 if (!O || index >= O.length) {
11083 this._t = undefined;
11084 return step(1);
11085 }
11086 if (kind == 'keys') return step(0, index);
11087 if (kind == 'values') return step(0, O[index]);
11088 return step(0, [index, O[index]]);
11089}, 'values');
11090
11091// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
11092Iterators.Arguments = Iterators.Array;
11093
11094addToUnscopables('keys');
11095addToUnscopables('values');
11096addToUnscopables('entries');
11097
11098},{"./_add-to-unscopables":96,"./_iter-define":133,"./_iter-step":135,"./_iterators":136,"./_to-iobject":171}],185:[function(require,module,exports){
11099// 20.1.2.3 Number.isInteger(number)
11100var $export = require('./_export');
11101
11102$export($export.S, 'Number', { isInteger: require('./_is-integer') });
11103
11104},{"./_export":117,"./_is-integer":129}],186:[function(require,module,exports){
11105// 20.1.2.6 Number.MAX_SAFE_INTEGER
11106var $export = require('./_export');
11107
11108$export($export.S, 'Number', { MAX_SAFE_INTEGER: 0x1fffffffffffff });
11109
11110},{"./_export":117}],187:[function(require,module,exports){
11111// 19.1.3.1 Object.assign(target, source)
11112var $export = require('./_export');
11113
11114$export($export.S + $export.F, 'Object', { assign: require('./_object-assign') });
11115
11116},{"./_export":117,"./_object-assign":141}],188:[function(require,module,exports){
11117var $export = require('./_export');
11118// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
11119$export($export.S, 'Object', { create: require('./_object-create') });
11120
11121},{"./_export":117,"./_object-create":142}],189:[function(require,module,exports){
11122var $export = require('./_export');
11123// 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
11124$export($export.S + $export.F * !require('./_descriptors'), 'Object', { defineProperty: require('./_object-dp').f });
11125
11126},{"./_descriptors":113,"./_export":117,"./_object-dp":143}],190:[function(require,module,exports){
11127// 19.1.2.5 Object.freeze(O)
11128var isObject = require('./_is-object');
11129var meta = require('./_meta').onFreeze;
11130
11131require('./_object-sap')('freeze', function ($freeze) {
11132 return function freeze(it) {
11133 return $freeze && isObject(it) ? $freeze(meta(it)) : it;
11134 };
11135});
11136
11137},{"./_is-object":130,"./_meta":138,"./_object-sap":153}],191:[function(require,module,exports){
11138// 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
11139var toIObject = require('./_to-iobject');
11140var $getOwnPropertyDescriptor = require('./_object-gopd').f;
11141
11142require('./_object-sap')('getOwnPropertyDescriptor', function () {
11143 return function getOwnPropertyDescriptor(it, key) {
11144 return $getOwnPropertyDescriptor(toIObject(it), key);
11145 };
11146});
11147
11148},{"./_object-gopd":145,"./_object-sap":153,"./_to-iobject":171}],192:[function(require,module,exports){
11149// 19.1.2.9 Object.getPrototypeOf(O)
11150var toObject = require('./_to-object');
11151var $getPrototypeOf = require('./_object-gpo');
11152
11153require('./_object-sap')('getPrototypeOf', function () {
11154 return function getPrototypeOf(it) {
11155 return $getPrototypeOf(toObject(it));
11156 };
11157});
11158
11159},{"./_object-gpo":149,"./_object-sap":153,"./_to-object":173}],193:[function(require,module,exports){
11160// 19.1.2.14 Object.keys(O)
11161var toObject = require('./_to-object');
11162var $keys = require('./_object-keys');
11163
11164require('./_object-sap')('keys', function () {
11165 return function keys(it) {
11166 return $keys(toObject(it));
11167 };
11168});
11169
11170},{"./_object-keys":151,"./_object-sap":153,"./_to-object":173}],194:[function(require,module,exports){
11171// 19.1.3.19 Object.setPrototypeOf(O, proto)
11172var $export = require('./_export');
11173$export($export.S, 'Object', { setPrototypeOf: require('./_set-proto').set });
11174
11175},{"./_export":117,"./_set-proto":161}],195:[function(require,module,exports){
11176arguments[4][45][0].apply(exports,arguments)
11177},{"dup":45}],196:[function(require,module,exports){
11178'use strict';
11179var LIBRARY = require('./_library');
11180var global = require('./_global');
11181var ctx = require('./_ctx');
11182var classof = require('./_classof');
11183var $export = require('./_export');
11184var isObject = require('./_is-object');
11185var aFunction = require('./_a-function');
11186var anInstance = require('./_an-instance');
11187var forOf = require('./_for-of');
11188var speciesConstructor = require('./_species-constructor');
11189var task = require('./_task').set;
11190var microtask = require('./_microtask')();
11191var newPromiseCapabilityModule = require('./_new-promise-capability');
11192var perform = require('./_perform');
11193var promiseResolve = require('./_promise-resolve');
11194var PROMISE = 'Promise';
11195var TypeError = global.TypeError;
11196var process = global.process;
11197var $Promise = global[PROMISE];
11198var isNode = classof(process) == 'process';
11199var empty = function () { /* empty */ };
11200var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper;
11201var newPromiseCapability = newGenericPromiseCapability = newPromiseCapabilityModule.f;
11202
11203var USE_NATIVE = !!function () {
11204 try {
11205 // correct subclassing with @@species support
11206 var promise = $Promise.resolve(1);
11207 var FakePromise = (promise.constructor = {})[require('./_wks')('species')] = function (exec) {
11208 exec(empty, empty);
11209 };
11210 // unhandled rejections tracking support, NodeJS Promise without it fails @@species test
11211 return (isNode || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise;
11212 } catch (e) { /* empty */ }
11213}();
11214
11215// helpers
11216var isThenable = function (it) {
11217 var then;
11218 return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
11219};
11220var notify = function (promise, isReject) {
11221 if (promise._n) return;
11222 promise._n = true;
11223 var chain = promise._c;
11224 microtask(function () {
11225 var value = promise._v;
11226 var ok = promise._s == 1;
11227 var i = 0;
11228 var run = function (reaction) {
11229 var handler = ok ? reaction.ok : reaction.fail;
11230 var resolve = reaction.resolve;
11231 var reject = reaction.reject;
11232 var domain = reaction.domain;
11233 var result, then;
11234 try {
11235 if (handler) {
11236 if (!ok) {
11237 if (promise._h == 2) onHandleUnhandled(promise);
11238 promise._h = 1;
11239 }
11240 if (handler === true) result = value;
11241 else {
11242 if (domain) domain.enter();
11243 result = handler(value);
11244 if (domain) domain.exit();
11245 }
11246 if (result === reaction.promise) {
11247 reject(TypeError('Promise-chain cycle'));
11248 } else if (then = isThenable(result)) {
11249 then.call(result, resolve, reject);
11250 } else resolve(result);
11251 } else reject(value);
11252 } catch (e) {
11253 reject(e);
11254 }
11255 };
11256 while (chain.length > i) run(chain[i++]); // variable length - can't use forEach
11257 promise._c = [];
11258 promise._n = false;
11259 if (isReject && !promise._h) onUnhandled(promise);
11260 });
11261};
11262var onUnhandled = function (promise) {
11263 task.call(global, function () {
11264 var value = promise._v;
11265 var unhandled = isUnhandled(promise);
11266 var result, handler, console;
11267 if (unhandled) {
11268 result = perform(function () {
11269 if (isNode) {
11270 process.emit('unhandledRejection', value, promise);
11271 } else if (handler = global.onunhandledrejection) {
11272 handler({ promise: promise, reason: value });
11273 } else if ((console = global.console) && console.error) {
11274 console.error('Unhandled promise rejection', value);
11275 }
11276 });
11277 // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
11278 promise._h = isNode || isUnhandled(promise) ? 2 : 1;
11279 } promise._a = undefined;
11280 if (unhandled && result.e) throw result.v;
11281 });
11282};
11283var isUnhandled = function (promise) {
11284 return promise._h !== 1 && (promise._a || promise._c).length === 0;
11285};
11286var onHandleUnhandled = function (promise) {
11287 task.call(global, function () {
11288 var handler;
11289 if (isNode) {
11290 process.emit('rejectionHandled', promise);
11291 } else if (handler = global.onrejectionhandled) {
11292 handler({ promise: promise, reason: promise._v });
11293 }
11294 });
11295};
11296var $reject = function (value) {
11297 var promise = this;
11298 if (promise._d) return;
11299 promise._d = true;
11300 promise = promise._w || promise; // unwrap
11301 promise._v = value;
11302 promise._s = 2;
11303 if (!promise._a) promise._a = promise._c.slice();
11304 notify(promise, true);
11305};
11306var $resolve = function (value) {
11307 var promise = this;
11308 var then;
11309 if (promise._d) return;
11310 promise._d = true;
11311 promise = promise._w || promise; // unwrap
11312 try {
11313 if (promise === value) throw TypeError("Promise can't be resolved itself");
11314 if (then = isThenable(value)) {
11315 microtask(function () {
11316 var wrapper = { _w: promise, _d: false }; // wrap
11317 try {
11318 then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
11319 } catch (e) {
11320 $reject.call(wrapper, e);
11321 }
11322 });
11323 } else {
11324 promise._v = value;
11325 promise._s = 1;
11326 notify(promise, false);
11327 }
11328 } catch (e) {
11329 $reject.call({ _w: promise, _d: false }, e); // wrap
11330 }
11331};
11332
11333// constructor polyfill
11334if (!USE_NATIVE) {
11335 // 25.4.3.1 Promise(executor)
11336 $Promise = function Promise(executor) {
11337 anInstance(this, $Promise, PROMISE, '_h');
11338 aFunction(executor);
11339 Internal.call(this);
11340 try {
11341 executor(ctx($resolve, this, 1), ctx($reject, this, 1));
11342 } catch (err) {
11343 $reject.call(this, err);
11344 }
11345 };
11346 // eslint-disable-next-line no-unused-vars
11347 Internal = function Promise(executor) {
11348 this._c = []; // <- awaiting reactions
11349 this._a = undefined; // <- checked in isUnhandled reactions
11350 this._s = 0; // <- state
11351 this._d = false; // <- done
11352 this._v = undefined; // <- value
11353 this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled
11354 this._n = false; // <- notify
11355 };
11356 Internal.prototype = require('./_redefine-all')($Promise.prototype, {
11357 // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
11358 then: function then(onFulfilled, onRejected) {
11359 var reaction = newPromiseCapability(speciesConstructor(this, $Promise));
11360 reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
11361 reaction.fail = typeof onRejected == 'function' && onRejected;
11362 reaction.domain = isNode ? process.domain : undefined;
11363 this._c.push(reaction);
11364 if (this._a) this._a.push(reaction);
11365 if (this._s) notify(this, false);
11366 return reaction.promise;
11367 },
11368 // 25.4.5.1 Promise.prototype.catch(onRejected)
11369 'catch': function (onRejected) {
11370 return this.then(undefined, onRejected);
11371 }
11372 });
11373 OwnPromiseCapability = function () {
11374 var promise = new Internal();
11375 this.promise = promise;
11376 this.resolve = ctx($resolve, promise, 1);
11377 this.reject = ctx($reject, promise, 1);
11378 };
11379 newPromiseCapabilityModule.f = newPromiseCapability = function (C) {
11380 return C === $Promise || C === Wrapper
11381 ? new OwnPromiseCapability(C)
11382 : newGenericPromiseCapability(C);
11383 };
11384}
11385
11386$export($export.G + $export.W + $export.F * !USE_NATIVE, { Promise: $Promise });
11387require('./_set-to-string-tag')($Promise, PROMISE);
11388require('./_set-species')(PROMISE);
11389Wrapper = require('./_core')[PROMISE];
11390
11391// statics
11392$export($export.S + $export.F * !USE_NATIVE, PROMISE, {
11393 // 25.4.4.5 Promise.reject(r)
11394 reject: function reject(r) {
11395 var capability = newPromiseCapability(this);
11396 var $$reject = capability.reject;
11397 $$reject(r);
11398 return capability.promise;
11399 }
11400});
11401$export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, {
11402 // 25.4.4.6 Promise.resolve(x)
11403 resolve: function resolve(x) {
11404 return promiseResolve(LIBRARY && this === Wrapper ? $Promise : this, x);
11405 }
11406});
11407$export($export.S + $export.F * !(USE_NATIVE && require('./_iter-detect')(function (iter) {
11408 $Promise.all(iter)['catch'](empty);
11409})), PROMISE, {
11410 // 25.4.4.1 Promise.all(iterable)
11411 all: function all(iterable) {
11412 var C = this;
11413 var capability = newPromiseCapability(C);
11414 var resolve = capability.resolve;
11415 var reject = capability.reject;
11416 var result = perform(function () {
11417 var values = [];
11418 var index = 0;
11419 var remaining = 1;
11420 forOf(iterable, false, function (promise) {
11421 var $index = index++;
11422 var alreadyCalled = false;
11423 values.push(undefined);
11424 remaining++;
11425 C.resolve(promise).then(function (value) {
11426 if (alreadyCalled) return;
11427 alreadyCalled = true;
11428 values[$index] = value;
11429 --remaining || resolve(values);
11430 }, reject);
11431 });
11432 --remaining || resolve(values);
11433 });
11434 if (result.e) reject(result.v);
11435 return capability.promise;
11436 },
11437 // 25.4.4.4 Promise.race(iterable)
11438 race: function race(iterable) {
11439 var C = this;
11440 var capability = newPromiseCapability(C);
11441 var reject = capability.reject;
11442 var result = perform(function () {
11443 forOf(iterable, false, function (promise) {
11444 C.resolve(promise).then(capability.resolve, reject);
11445 });
11446 });
11447 if (result.e) reject(result.v);
11448 return capability.promise;
11449 }
11450});
11451
11452},{"./_a-function":95,"./_an-instance":97,"./_classof":104,"./_core":109,"./_ctx":111,"./_export":117,"./_for-of":119,"./_global":120,"./_is-object":130,"./_iter-detect":134,"./_library":137,"./_microtask":139,"./_new-promise-capability":140,"./_perform":154,"./_promise-resolve":155,"./_redefine-all":157,"./_set-species":162,"./_set-to-string-tag":163,"./_species-constructor":166,"./_task":168,"./_wks":179}],197:[function(require,module,exports){
11453'use strict';
11454var strong = require('./_collection-strong');
11455var validate = require('./_validate-collection');
11456var SET = 'Set';
11457
11458// 23.2 Set Objects
11459module.exports = require('./_collection')(SET, function (get) {
11460 return function Set() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };
11461}, {
11462 // 23.2.3.1 Set.prototype.add(value)
11463 add: function add(value) {
11464 return strong.def(validate(this, SET), value = value === 0 ? 0 : value, value);
11465 }
11466}, strong);
11467
11468},{"./_collection":108,"./_collection-strong":106,"./_validate-collection":176}],198:[function(require,module,exports){
11469'use strict';
11470var $at = require('./_string-at')(true);
11471
11472// 21.1.3.27 String.prototype[@@iterator]()
11473require('./_iter-define')(String, 'String', function (iterated) {
11474 this._t = String(iterated); // target
11475 this._i = 0; // next index
11476// 21.1.5.2.1 %StringIteratorPrototype%.next()
11477}, function () {
11478 var O = this._t;
11479 var index = this._i;
11480 var point;
11481 if (index >= O.length) return { value: undefined, done: true };
11482 point = $at(O, index);
11483 this._i += point.length;
11484 return { value: point, done: false };
11485});
11486
11487},{"./_iter-define":133,"./_string-at":167}],199:[function(require,module,exports){
11488'use strict';
11489// ECMAScript 6 symbols shim
11490var global = require('./_global');
11491var has = require('./_has');
11492var DESCRIPTORS = require('./_descriptors');
11493var $export = require('./_export');
11494var redefine = require('./_redefine');
11495var META = require('./_meta').KEY;
11496var $fails = require('./_fails');
11497var shared = require('./_shared');
11498var setToStringTag = require('./_set-to-string-tag');
11499var uid = require('./_uid');
11500var wks = require('./_wks');
11501var wksExt = require('./_wks-ext');
11502var wksDefine = require('./_wks-define');
11503var enumKeys = require('./_enum-keys');
11504var isArray = require('./_is-array');
11505var anObject = require('./_an-object');
11506var isObject = require('./_is-object');
11507var toIObject = require('./_to-iobject');
11508var toPrimitive = require('./_to-primitive');
11509var createDesc = require('./_property-desc');
11510var _create = require('./_object-create');
11511var gOPNExt = require('./_object-gopn-ext');
11512var $GOPD = require('./_object-gopd');
11513var $DP = require('./_object-dp');
11514var $keys = require('./_object-keys');
11515var gOPD = $GOPD.f;
11516var dP = $DP.f;
11517var gOPN = gOPNExt.f;
11518var $Symbol = global.Symbol;
11519var $JSON = global.JSON;
11520var _stringify = $JSON && $JSON.stringify;
11521var PROTOTYPE = 'prototype';
11522var HIDDEN = wks('_hidden');
11523var TO_PRIMITIVE = wks('toPrimitive');
11524var isEnum = {}.propertyIsEnumerable;
11525var SymbolRegistry = shared('symbol-registry');
11526var AllSymbols = shared('symbols');
11527var OPSymbols = shared('op-symbols');
11528var ObjectProto = Object[PROTOTYPE];
11529var USE_NATIVE = typeof $Symbol == 'function';
11530var QObject = global.QObject;
11531// Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
11532var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
11533
11534// fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
11535var setSymbolDesc = DESCRIPTORS && $fails(function () {
11536 return _create(dP({}, 'a', {
11537 get: function () { return dP(this, 'a', { value: 7 }).a; }
11538 })).a != 7;
11539}) ? function (it, key, D) {
11540 var protoDesc = gOPD(ObjectProto, key);
11541 if (protoDesc) delete ObjectProto[key];
11542 dP(it, key, D);
11543 if (protoDesc && it !== ObjectProto) dP(ObjectProto, key, protoDesc);
11544} : dP;
11545
11546var wrap = function (tag) {
11547 var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]);
11548 sym._k = tag;
11549 return sym;
11550};
11551
11552var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function (it) {
11553 return typeof it == 'symbol';
11554} : function (it) {
11555 return it instanceof $Symbol;
11556};
11557
11558var $defineProperty = function defineProperty(it, key, D) {
11559 if (it === ObjectProto) $defineProperty(OPSymbols, key, D);
11560 anObject(it);
11561 key = toPrimitive(key, true);
11562 anObject(D);
11563 if (has(AllSymbols, key)) {
11564 if (!D.enumerable) {
11565 if (!has(it, HIDDEN)) dP(it, HIDDEN, createDesc(1, {}));
11566 it[HIDDEN][key] = true;
11567 } else {
11568 if (has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false;
11569 D = _create(D, { enumerable: createDesc(0, false) });
11570 } return setSymbolDesc(it, key, D);
11571 } return dP(it, key, D);
11572};
11573var $defineProperties = function defineProperties(it, P) {
11574 anObject(it);
11575 var keys = enumKeys(P = toIObject(P));
11576 var i = 0;
11577 var l = keys.length;
11578 var key;
11579 while (l > i) $defineProperty(it, key = keys[i++], P[key]);
11580 return it;
11581};
11582var $create = function create(it, P) {
11583 return P === undefined ? _create(it) : $defineProperties(_create(it), P);
11584};
11585var $propertyIsEnumerable = function propertyIsEnumerable(key) {
11586 var E = isEnum.call(this, key = toPrimitive(key, true));
11587 if (this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return false;
11588 return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
11589};
11590var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) {
11591 it = toIObject(it);
11592 key = toPrimitive(key, true);
11593 if (it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return;
11594 var D = gOPD(it, key);
11595 if (D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true;
11596 return D;
11597};
11598var $getOwnPropertyNames = function getOwnPropertyNames(it) {
11599 var names = gOPN(toIObject(it));
11600 var result = [];
11601 var i = 0;
11602 var key;
11603 while (names.length > i) {
11604 if (!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key);
11605 } return result;
11606};
11607var $getOwnPropertySymbols = function getOwnPropertySymbols(it) {
11608 var IS_OP = it === ObjectProto;
11609 var names = gOPN(IS_OP ? OPSymbols : toIObject(it));
11610 var result = [];
11611 var i = 0;
11612 var key;
11613 while (names.length > i) {
11614 if (has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true)) result.push(AllSymbols[key]);
11615 } return result;
11616};
11617
11618// 19.4.1.1 Symbol([description])
11619if (!USE_NATIVE) {
11620 $Symbol = function Symbol() {
11621 if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!');
11622 var tag = uid(arguments.length > 0 ? arguments[0] : undefined);
11623 var $set = function (value) {
11624 if (this === ObjectProto) $set.call(OPSymbols, value);
11625 if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
11626 setSymbolDesc(this, tag, createDesc(1, value));
11627 };
11628 if (DESCRIPTORS && setter) setSymbolDesc(ObjectProto, tag, { configurable: true, set: $set });
11629 return wrap(tag);
11630 };
11631 redefine($Symbol[PROTOTYPE], 'toString', function toString() {
11632 return this._k;
11633 });
11634
11635 $GOPD.f = $getOwnPropertyDescriptor;
11636 $DP.f = $defineProperty;
11637 require('./_object-gopn').f = gOPNExt.f = $getOwnPropertyNames;
11638 require('./_object-pie').f = $propertyIsEnumerable;
11639 require('./_object-gops').f = $getOwnPropertySymbols;
11640
11641 if (DESCRIPTORS && !require('./_library')) {
11642 redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);
11643 }
11644
11645 wksExt.f = function (name) {
11646 return wrap(wks(name));
11647 };
11648}
11649
11650$export($export.G + $export.W + $export.F * !USE_NATIVE, { Symbol: $Symbol });
11651
11652for (var es6Symbols = (
11653 // 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
11654 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'
11655).split(','), j = 0; es6Symbols.length > j;)wks(es6Symbols[j++]);
11656
11657for (var wellKnownSymbols = $keys(wks.store), k = 0; wellKnownSymbols.length > k;) wksDefine(wellKnownSymbols[k++]);
11658
11659$export($export.S + $export.F * !USE_NATIVE, 'Symbol', {
11660 // 19.4.2.1 Symbol.for(key)
11661 'for': function (key) {
11662 return has(SymbolRegistry, key += '')
11663 ? SymbolRegistry[key]
11664 : SymbolRegistry[key] = $Symbol(key);
11665 },
11666 // 19.4.2.5 Symbol.keyFor(sym)
11667 keyFor: function keyFor(sym) {
11668 if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!');
11669 for (var key in SymbolRegistry) if (SymbolRegistry[key] === sym) return key;
11670 },
11671 useSetter: function () { setter = true; },
11672 useSimple: function () { setter = false; }
11673});
11674
11675$export($export.S + $export.F * !USE_NATIVE, 'Object', {
11676 // 19.1.2.2 Object.create(O [, Properties])
11677 create: $create,
11678 // 19.1.2.4 Object.defineProperty(O, P, Attributes)
11679 defineProperty: $defineProperty,
11680 // 19.1.2.3 Object.defineProperties(O, Properties)
11681 defineProperties: $defineProperties,
11682 // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
11683 getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
11684 // 19.1.2.7 Object.getOwnPropertyNames(O)
11685 getOwnPropertyNames: $getOwnPropertyNames,
11686 // 19.1.2.8 Object.getOwnPropertySymbols(O)
11687 getOwnPropertySymbols: $getOwnPropertySymbols
11688});
11689
11690// 24.3.2 JSON.stringify(value [, replacer [, space]])
11691$JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function () {
11692 var S = $Symbol();
11693 // MS Edge converts symbol values to JSON as {}
11694 // WebKit converts symbol values to JSON as null
11695 // V8 throws on boxed symbols
11696 return _stringify([S]) != '[null]' || _stringify({ a: S }) != '{}' || _stringify(Object(S)) != '{}';
11697})), 'JSON', {
11698 stringify: function stringify(it) {
11699 var args = [it];
11700 var i = 1;
11701 var replacer, $replacer;
11702 while (arguments.length > i) args.push(arguments[i++]);
11703 $replacer = replacer = args[1];
11704 if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
11705 if (!isArray(replacer)) replacer = function (key, value) {
11706 if (typeof $replacer == 'function') value = $replacer.call(this, key, value);
11707 if (!isSymbol(value)) return value;
11708 };
11709 args[1] = replacer;
11710 return _stringify.apply($JSON, args);
11711 }
11712});
11713
11714// 19.4.3.4 Symbol.prototype[@@toPrimitive](hint)
11715$Symbol[PROTOTYPE][TO_PRIMITIVE] || require('./_hide')($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
11716// 19.4.3.5 Symbol.prototype[@@toStringTag]
11717setToStringTag($Symbol, 'Symbol');
11718// 20.2.1.9 Math[@@toStringTag]
11719setToStringTag(Math, 'Math', true);
11720// 24.3.3 JSON[@@toStringTag]
11721setToStringTag(global.JSON, 'JSON', true);
11722
11723},{"./_an-object":98,"./_descriptors":113,"./_enum-keys":116,"./_export":117,"./_fails":118,"./_global":120,"./_has":121,"./_hide":122,"./_is-array":128,"./_is-object":130,"./_library":137,"./_meta":138,"./_object-create":142,"./_object-dp":143,"./_object-gopd":145,"./_object-gopn":147,"./_object-gopn-ext":146,"./_object-gops":148,"./_object-keys":151,"./_object-pie":152,"./_property-desc":156,"./_redefine":158,"./_set-to-string-tag":163,"./_shared":165,"./_to-iobject":171,"./_to-primitive":174,"./_uid":175,"./_wks":179,"./_wks-define":177,"./_wks-ext":178}],200:[function(require,module,exports){
11724// https://github.com/tc39/proposal-promise-finally
11725'use strict';
11726var $export = require('./_export');
11727var core = require('./_core');
11728var global = require('./_global');
11729var speciesConstructor = require('./_species-constructor');
11730var promiseResolve = require('./_promise-resolve');
11731
11732$export($export.P + $export.R, 'Promise', { 'finally': function (onFinally) {
11733 var C = speciesConstructor(this, core.Promise || global.Promise);
11734 var isFunction = typeof onFinally == 'function';
11735 return this.then(
11736 isFunction ? function (x) {
11737 return promiseResolve(C, onFinally()).then(function () { return x; });
11738 } : onFinally,
11739 isFunction ? function (e) {
11740 return promiseResolve(C, onFinally()).then(function () { throw e; });
11741 } : onFinally
11742 );
11743} });
11744
11745},{"./_core":109,"./_export":117,"./_global":120,"./_promise-resolve":155,"./_species-constructor":166}],201:[function(require,module,exports){
11746'use strict';
11747// https://github.com/tc39/proposal-promise-try
11748var $export = require('./_export');
11749var newPromiseCapability = require('./_new-promise-capability');
11750var perform = require('./_perform');
11751
11752$export($export.S, 'Promise', { 'try': function (callbackfn) {
11753 var promiseCapability = newPromiseCapability.f(this);
11754 var result = perform(callbackfn);
11755 (result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v);
11756 return promiseCapability.promise;
11757} });
11758
11759},{"./_export":117,"./_new-promise-capability":140,"./_perform":154}],202:[function(require,module,exports){
11760// https://tc39.github.io/proposal-setmap-offrom/#sec-set.from
11761require('./_set-collection-from')('Set');
11762
11763},{"./_set-collection-from":159}],203:[function(require,module,exports){
11764// https://tc39.github.io/proposal-setmap-offrom/#sec-set.of
11765require('./_set-collection-of')('Set');
11766
11767},{"./_set-collection-of":160}],204:[function(require,module,exports){
11768// https://github.com/DavidBruant/Map-Set.prototype.toJSON
11769var $export = require('./_export');
11770
11771$export($export.P + $export.R, 'Set', { toJSON: require('./_collection-to-json')('Set') });
11772
11773},{"./_collection-to-json":107,"./_export":117}],205:[function(require,module,exports){
11774require('./_wks-define')('asyncIterator');
11775
11776},{"./_wks-define":177}],206:[function(require,module,exports){
11777require('./_wks-define')('observable');
11778
11779},{"./_wks-define":177}],207:[function(require,module,exports){
11780require('./es6.array.iterator');
11781var global = require('./_global');
11782var hide = require('./_hide');
11783var Iterators = require('./_iterators');
11784var TO_STRING_TAG = require('./_wks')('toStringTag');
11785
11786var DOMIterables = ('CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,' +
11787 'DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,' +
11788 'MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,' +
11789 'SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,' +
11790 'TextTrackList,TouchList').split(',');
11791
11792for (var i = 0; i < DOMIterables.length; i++) {
11793 var NAME = DOMIterables[i];
11794 var Collection = global[NAME];
11795 var proto = Collection && Collection.prototype;
11796 if (proto && !proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME);
11797 Iterators[NAME] = Iterators.Array;
11798}
11799
11800},{"./_global":120,"./_hide":122,"./_iterators":136,"./_wks":179,"./es6.array.iterator":184}],208:[function(require,module,exports){
11801(function (Buffer){
11802// Copyright Joyent, Inc. and other Node contributors.
11803//
11804// Permission is hereby granted, free of charge, to any person obtaining a
11805// copy of this software and associated documentation files (the
11806// "Software"), to deal in the Software without restriction, including
11807// without limitation the rights to use, copy, modify, merge, publish,
11808// distribute, sublicense, and/or sell copies of the Software, and to permit
11809// persons to whom the Software is furnished to do so, subject to the
11810// following conditions:
11811//
11812// The above copyright notice and this permission notice shall be included
11813// in all copies or substantial portions of the Software.
11814//
11815// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
11816// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
11817// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
11818// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
11819// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
11820// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
11821// USE OR OTHER DEALINGS IN THE SOFTWARE.
11822
11823// NOTE: These type checking functions intentionally don't use `instanceof`
11824// because it is fragile and can be easily faked with `Object.create()`.
11825
11826function isArray(arg) {
11827 if (Array.isArray) {
11828 return Array.isArray(arg);
11829 }
11830 return objectToString(arg) === '[object Array]';
11831}
11832exports.isArray = isArray;
11833
11834function isBoolean(arg) {
11835 return typeof arg === 'boolean';
11836}
11837exports.isBoolean = isBoolean;
11838
11839function isNull(arg) {
11840 return arg === null;
11841}
11842exports.isNull = isNull;
11843
11844function isNullOrUndefined(arg) {
11845 return arg == null;
11846}
11847exports.isNullOrUndefined = isNullOrUndefined;
11848
11849function isNumber(arg) {
11850 return typeof arg === 'number';
11851}
11852exports.isNumber = isNumber;
11853
11854function isString(arg) {
11855 return typeof arg === 'string';
11856}
11857exports.isString = isString;
11858
11859function isSymbol(arg) {
11860 return typeof arg === 'symbol';
11861}
11862exports.isSymbol = isSymbol;
11863
11864function isUndefined(arg) {
11865 return arg === void 0;
11866}
11867exports.isUndefined = isUndefined;
11868
11869function isRegExp(re) {
11870 return objectToString(re) === '[object RegExp]';
11871}
11872exports.isRegExp = isRegExp;
11873
11874function isObject(arg) {
11875 return typeof arg === 'object' && arg !== null;
11876}
11877exports.isObject = isObject;
11878
11879function isDate(d) {
11880 return objectToString(d) === '[object Date]';
11881}
11882exports.isDate = isDate;
11883
11884function isError(e) {
11885 return (objectToString(e) === '[object Error]' || e instanceof Error);
11886}
11887exports.isError = isError;
11888
11889function isFunction(arg) {
11890 return typeof arg === 'function';
11891}
11892exports.isFunction = isFunction;
11893
11894function isPrimitive(arg) {
11895 return arg === null ||
11896 typeof arg === 'boolean' ||
11897 typeof arg === 'number' ||
11898 typeof arg === 'string' ||
11899 typeof arg === 'symbol' || // ES6 symbol
11900 typeof arg === 'undefined';
11901}
11902exports.isPrimitive = isPrimitive;
11903
11904exports.isBuffer = Buffer.isBuffer;
11905
11906function objectToString(o) {
11907 return Object.prototype.toString.call(o);
11908}
11909
11910}).call(this,{"isBuffer":require("../../is-buffer/index.js")})
11911},{"../../is-buffer/index.js":261}],209:[function(require,module,exports){
11912(function (Buffer){
11913var elliptic = require('elliptic');
11914var BN = require('bn.js');
11915
11916module.exports = function createECDH(curve) {
11917 return new ECDH(curve);
11918};
11919
11920var aliases = {
11921 secp256k1: {
11922 name: 'secp256k1',
11923 byteLength: 32
11924 },
11925 secp224r1: {
11926 name: 'p224',
11927 byteLength: 28
11928 },
11929 prime256v1: {
11930 name: 'p256',
11931 byteLength: 32
11932 },
11933 prime192v1: {
11934 name: 'p192',
11935 byteLength: 24
11936 },
11937 ed25519: {
11938 name: 'ed25519',
11939 byteLength: 32
11940 },
11941 secp384r1: {
11942 name: 'p384',
11943 byteLength: 48
11944 },
11945 secp521r1: {
11946 name: 'p521',
11947 byteLength: 66
11948 }
11949};
11950
11951aliases.p224 = aliases.secp224r1;
11952aliases.p256 = aliases.secp256r1 = aliases.prime256v1;
11953aliases.p192 = aliases.secp192r1 = aliases.prime192v1;
11954aliases.p384 = aliases.secp384r1;
11955aliases.p521 = aliases.secp521r1;
11956
11957function ECDH(curve) {
11958 this.curveType = aliases[curve];
11959 if (!this.curveType ) {
11960 this.curveType = {
11961 name: curve
11962 };
11963 }
11964 this.curve = new elliptic.ec(this.curveType.name);
11965 this.keys = void 0;
11966}
11967
11968ECDH.prototype.generateKeys = function (enc, format) {
11969 this.keys = this.curve.genKeyPair();
11970 return this.getPublicKey(enc, format);
11971};
11972
11973ECDH.prototype.computeSecret = function (other, inenc, enc) {
11974 inenc = inenc || 'utf8';
11975 if (!Buffer.isBuffer(other)) {
11976 other = new Buffer(other, inenc);
11977 }
11978 var otherPub = this.curve.keyFromPublic(other).getPublic();
11979 var out = otherPub.mul(this.keys.getPrivate()).getX();
11980 return formatReturnValue(out, enc, this.curveType.byteLength);
11981};
11982
11983ECDH.prototype.getPublicKey = function (enc, format) {
11984 var key = this.keys.getPublic(format === 'compressed', true);
11985 if (format === 'hybrid') {
11986 if (key[key.length - 1] % 2) {
11987 key[0] = 7;
11988 } else {
11989 key [0] = 6;
11990 }
11991 }
11992 return formatReturnValue(key, enc);
11993};
11994
11995ECDH.prototype.getPrivateKey = function (enc) {
11996 return formatReturnValue(this.keys.getPrivate(), enc);
11997};
11998
11999ECDH.prototype.setPublicKey = function (pub, enc) {
12000 enc = enc || 'utf8';
12001 if (!Buffer.isBuffer(pub)) {
12002 pub = new Buffer(pub, enc);
12003 }
12004 this.keys._importPublic(pub);
12005 return this;
12006};
12007
12008ECDH.prototype.setPrivateKey = function (priv, enc) {
12009 enc = enc || 'utf8';
12010 if (!Buffer.isBuffer(priv)) {
12011 priv = new Buffer(priv, enc);
12012 }
12013 var _priv = new BN(priv);
12014 _priv = _priv.toString(16);
12015 this.keys._importPrivate(_priv);
12016 return this;
12017};
12018
12019function formatReturnValue(bn, enc, len) {
12020 if (!Array.isArray(bn)) {
12021 bn = bn.toArray();
12022 }
12023 var buf = new Buffer(bn);
12024 if (len && buf.length < len) {
12025 var zeros = new Buffer(len - buf.length);
12026 zeros.fill(0);
12027 buf = Buffer.concat([zeros, buf]);
12028 }
12029 if (!enc) {
12030 return buf;
12031 } else {
12032 return buf.toString(enc);
12033 }
12034}
12035
12036}).call(this,require("buffer").Buffer)
12037},{"bn.js":43,"buffer":75,"elliptic":226}],210:[function(require,module,exports){
12038(function (Buffer){
12039'use strict'
12040var inherits = require('inherits')
12041var md5 = require('./md5')
12042var RIPEMD160 = require('ripemd160')
12043var sha = require('sha.js')
12044
12045var Base = require('cipher-base')
12046
12047function HashNoConstructor (hash) {
12048 Base.call(this, 'digest')
12049
12050 this._hash = hash
12051 this.buffers = []
12052}
12053
12054inherits(HashNoConstructor, Base)
12055
12056HashNoConstructor.prototype._update = function (data) {
12057 this.buffers.push(data)
12058}
12059
12060HashNoConstructor.prototype._final = function () {
12061 var buf = Buffer.concat(this.buffers)
12062 var r = this._hash(buf)
12063 this.buffers = null
12064
12065 return r
12066}
12067
12068function Hash (hash) {
12069 Base.call(this, 'digest')
12070
12071 this._hash = hash
12072}
12073
12074inherits(Hash, Base)
12075
12076Hash.prototype._update = function (data) {
12077 this._hash.update(data)
12078}
12079
12080Hash.prototype._final = function () {
12081 return this._hash.digest()
12082}
12083
12084module.exports = function createHash (alg) {
12085 alg = alg.toLowerCase()
12086 if (alg === 'md5') return new HashNoConstructor(md5)
12087 if (alg === 'rmd160' || alg === 'ripemd160') return new Hash(new RIPEMD160())
12088
12089 return new Hash(sha(alg))
12090}
12091
12092}).call(this,require("buffer").Buffer)
12093},{"./md5":212,"buffer":75,"cipher-base":76,"inherits":260,"ripemd160":304,"sha.js":307}],211:[function(require,module,exports){
12094(function (Buffer){
12095'use strict'
12096var intSize = 4
12097var zeroBuffer = new Buffer(intSize)
12098zeroBuffer.fill(0)
12099
12100var charSize = 8
12101var hashSize = 16
12102
12103function toArray (buf) {
12104 if ((buf.length % intSize) !== 0) {
12105 var len = buf.length + (intSize - (buf.length % intSize))
12106 buf = Buffer.concat([buf, zeroBuffer], len)
12107 }
12108
12109 var arr = new Array(buf.length >>> 2)
12110 for (var i = 0, j = 0; i < buf.length; i += intSize, j++) {
12111 arr[j] = buf.readInt32LE(i)
12112 }
12113
12114 return arr
12115}
12116
12117module.exports = function hash (buf, fn) {
12118 var arr = fn(toArray(buf), buf.length * charSize)
12119 buf = new Buffer(hashSize)
12120 for (var i = 0; i < arr.length; i++) {
12121 buf.writeInt32LE(arr[i], i << 2, true)
12122 }
12123 return buf
12124}
12125
12126}).call(this,require("buffer").Buffer)
12127},{"buffer":75}],212:[function(require,module,exports){
12128'use strict'
12129/*
12130 * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
12131 * Digest Algorithm, as defined in RFC 1321.
12132 * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
12133 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
12134 * Distributed under the BSD License
12135 * See http://pajhome.org.uk/crypt/md5 for more info.
12136 */
12137
12138var makeHash = require('./make-hash')
12139
12140/*
12141 * Calculate the MD5 of an array of little-endian words, and a bit length
12142 */
12143function core_md5 (x, len) {
12144 /* append padding */
12145 x[len >> 5] |= 0x80 << ((len) % 32)
12146 x[(((len + 64) >>> 9) << 4) + 14] = len
12147
12148 var a = 1732584193
12149 var b = -271733879
12150 var c = -1732584194
12151 var d = 271733878
12152
12153 for (var i = 0; i < x.length; i += 16) {
12154 var olda = a
12155 var oldb = b
12156 var oldc = c
12157 var oldd = d
12158
12159 a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936)
12160 d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586)
12161 c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819)
12162 b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330)
12163 a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897)
12164 d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426)
12165 c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341)
12166 b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983)
12167 a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416)
12168 d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417)
12169 c = md5_ff(c, d, a, b, x[i + 10], 17, -42063)
12170 b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162)
12171 a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682)
12172 d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101)
12173 c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290)
12174 b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329)
12175
12176 a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510)
12177 d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632)
12178 c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713)
12179 b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302)
12180 a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691)
12181 d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083)
12182 c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335)
12183 b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848)
12184 a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438)
12185 d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690)
12186 c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961)
12187 b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501)
12188 a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467)
12189 d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784)
12190 c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473)
12191 b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734)
12192
12193 a = md5_hh(a, b, c, d, x[i + 5], 4, -378558)
12194 d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463)
12195 c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562)
12196 b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556)
12197 a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060)
12198 d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353)
12199 c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632)
12200 b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640)
12201 a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174)
12202 d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222)
12203 c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979)
12204 b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189)
12205 a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487)
12206 d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835)
12207 c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520)
12208 b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651)
12209
12210 a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844)
12211 d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415)
12212 c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905)
12213 b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055)
12214 a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571)
12215 d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606)
12216 c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523)
12217 b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799)
12218 a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359)
12219 d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744)
12220 c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380)
12221 b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649)
12222 a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070)
12223 d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379)
12224 c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259)
12225 b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551)
12226
12227 a = safe_add(a, olda)
12228 b = safe_add(b, oldb)
12229 c = safe_add(c, oldc)
12230 d = safe_add(d, oldd)
12231 }
12232
12233 return [a, b, c, d]
12234}
12235
12236/*
12237 * These functions implement the four basic operations the algorithm uses.
12238 */
12239function md5_cmn (q, a, b, x, s, t) {
12240 return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b)
12241}
12242
12243function md5_ff (a, b, c, d, x, s, t) {
12244 return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t)
12245}
12246
12247function md5_gg (a, b, c, d, x, s, t) {
12248 return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t)
12249}
12250
12251function md5_hh (a, b, c, d, x, s, t) {
12252 return md5_cmn(b ^ c ^ d, a, b, x, s, t)
12253}
12254
12255function md5_ii (a, b, c, d, x, s, t) {
12256 return md5_cmn(c ^ (b | (~d)), a, b, x, s, t)
12257}
12258
12259/*
12260 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
12261 * to work around bugs in some JS interpreters.
12262 */
12263function safe_add (x, y) {
12264 var lsw = (x & 0xFFFF) + (y & 0xFFFF)
12265 var msw = (x >> 16) + (y >> 16) + (lsw >> 16)
12266 return (msw << 16) | (lsw & 0xFFFF)
12267}
12268
12269/*
12270 * Bitwise rotate a 32-bit number to the left.
12271 */
12272function bit_rol (num, cnt) {
12273 return (num << cnt) | (num >>> (32 - cnt))
12274}
12275
12276module.exports = function md5 (buf) {
12277 return makeHash(buf, core_md5)
12278}
12279
12280},{"./make-hash":211}],213:[function(require,module,exports){
12281'use strict'
12282var inherits = require('inherits')
12283var Legacy = require('./legacy')
12284var Base = require('cipher-base')
12285var Buffer = require('safe-buffer').Buffer
12286var md5 = require('create-hash/md5')
12287var RIPEMD160 = require('ripemd160')
12288
12289var sha = require('sha.js')
12290
12291var ZEROS = Buffer.alloc(128)
12292
12293function Hmac (alg, key) {
12294 Base.call(this, 'digest')
12295 if (typeof key === 'string') {
12296 key = Buffer.from(key)
12297 }
12298
12299 var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64
12300
12301 this._alg = alg
12302 this._key = key
12303 if (key.length > blocksize) {
12304 var hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg)
12305 key = hash.update(key).digest()
12306 } else if (key.length < blocksize) {
12307 key = Buffer.concat([key, ZEROS], blocksize)
12308 }
12309
12310 var ipad = this._ipad = Buffer.allocUnsafe(blocksize)
12311 var opad = this._opad = Buffer.allocUnsafe(blocksize)
12312
12313 for (var i = 0; i < blocksize; i++) {
12314 ipad[i] = key[i] ^ 0x36
12315 opad[i] = key[i] ^ 0x5C
12316 }
12317 this._hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg)
12318 this._hash.update(ipad)
12319}
12320
12321inherits(Hmac, Base)
12322
12323Hmac.prototype._update = function (data) {
12324 this._hash.update(data)
12325}
12326
12327Hmac.prototype._final = function () {
12328 var h = this._hash.digest()
12329 var hash = this._alg === 'rmd160' ? new RIPEMD160() : sha(this._alg)
12330 return hash.update(this._opad).update(h).digest()
12331}
12332
12333module.exports = function createHmac (alg, key) {
12334 alg = alg.toLowerCase()
12335 if (alg === 'rmd160' || alg === 'ripemd160') {
12336 return new Hmac('rmd160', key)
12337 }
12338 if (alg === 'md5') {
12339 return new Legacy(md5, key)
12340 }
12341 return new Hmac(alg, key)
12342}
12343
12344},{"./legacy":214,"cipher-base":76,"create-hash/md5":212,"inherits":260,"ripemd160":304,"safe-buffer":305,"sha.js":307}],214:[function(require,module,exports){
12345'use strict'
12346var inherits = require('inherits')
12347var Buffer = require('safe-buffer').Buffer
12348
12349var Base = require('cipher-base')
12350
12351var ZEROS = Buffer.alloc(128)
12352var blocksize = 64
12353
12354function Hmac (alg, key) {
12355 Base.call(this, 'digest')
12356 if (typeof key === 'string') {
12357 key = Buffer.from(key)
12358 }
12359
12360 this._alg = alg
12361 this._key = key
12362
12363 if (key.length > blocksize) {
12364 key = alg(key)
12365 } else if (key.length < blocksize) {
12366 key = Buffer.concat([key, ZEROS], blocksize)
12367 }
12368
12369 var ipad = this._ipad = Buffer.allocUnsafe(blocksize)
12370 var opad = this._opad = Buffer.allocUnsafe(blocksize)
12371
12372 for (var i = 0; i < blocksize; i++) {
12373 ipad[i] = key[i] ^ 0x36
12374 opad[i] = key[i] ^ 0x5C
12375 }
12376
12377 this._hash = [ipad]
12378}
12379
12380inherits(Hmac, Base)
12381
12382Hmac.prototype._update = function (data) {
12383 this._hash.push(data)
12384}
12385
12386Hmac.prototype._final = function () {
12387 var h = this._alg(Buffer.concat(this._hash))
12388 return this._alg(Buffer.concat([this._opad, h]))
12389}
12390module.exports = Hmac
12391
12392},{"cipher-base":76,"inherits":260,"safe-buffer":305}],215:[function(require,module,exports){
12393'use strict'
12394
12395exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = require('randombytes')
12396exports.createHash = exports.Hash = require('create-hash')
12397exports.createHmac = exports.Hmac = require('create-hmac')
12398
12399var algos = require('browserify-sign/algos')
12400var algoKeys = Object.keys(algos)
12401var hashes = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(algoKeys)
12402exports.getHashes = function () {
12403 return hashes
12404}
12405
12406var p = require('pbkdf2')
12407exports.pbkdf2 = p.pbkdf2
12408exports.pbkdf2Sync = p.pbkdf2Sync
12409
12410var aes = require('browserify-cipher')
12411
12412exports.Cipher = aes.Cipher
12413exports.createCipher = aes.createCipher
12414exports.Cipheriv = aes.Cipheriv
12415exports.createCipheriv = aes.createCipheriv
12416exports.Decipher = aes.Decipher
12417exports.createDecipher = aes.createDecipher
12418exports.Decipheriv = aes.Decipheriv
12419exports.createDecipheriv = aes.createDecipheriv
12420exports.getCiphers = aes.getCiphers
12421exports.listCiphers = aes.listCiphers
12422
12423var dh = require('diffie-hellman')
12424
12425exports.DiffieHellmanGroup = dh.DiffieHellmanGroup
12426exports.createDiffieHellmanGroup = dh.createDiffieHellmanGroup
12427exports.getDiffieHellman = dh.getDiffieHellman
12428exports.createDiffieHellman = dh.createDiffieHellman
12429exports.DiffieHellman = dh.DiffieHellman
12430
12431var sign = require('browserify-sign')
12432
12433exports.createSign = sign.createSign
12434exports.Sign = sign.Sign
12435exports.createVerify = sign.createVerify
12436exports.Verify = sign.Verify
12437
12438exports.createECDH = require('create-ecdh')
12439
12440var publicEncrypt = require('public-encrypt')
12441
12442exports.publicEncrypt = publicEncrypt.publicEncrypt
12443exports.privateEncrypt = publicEncrypt.privateEncrypt
12444exports.publicDecrypt = publicEncrypt.publicDecrypt
12445exports.privateDecrypt = publicEncrypt.privateDecrypt
12446
12447// the least I can do is make error messages for the rest of the node.js/crypto api.
12448// ;[
12449// 'createCredentials'
12450// ].forEach(function (name) {
12451// exports[name] = function () {
12452// throw new Error([
12453// 'sorry, ' + name + ' is not implemented yet',
12454// 'we accept pull requests',
12455// 'https://github.com/crypto-browserify/crypto-browserify'
12456// ].join('\n'))
12457// }
12458// })
12459
12460var rf = require('randomfill')
12461
12462exports.randomFill = rf.randomFill
12463exports.randomFillSync = rf.randomFillSync
12464
12465exports.createCredentials = function () {
12466 throw new Error([
12467 'sorry, createCredentials is not implemented yet',
12468 'we accept pull requests',
12469 'https://github.com/crypto-browserify/crypto-browserify'
12470 ].join('\n'))
12471}
12472
12473exports.constants = {
12474 'DH_CHECK_P_NOT_SAFE_PRIME': 2,
12475 'DH_CHECK_P_NOT_PRIME': 1,
12476 'DH_UNABLE_TO_CHECK_GENERATOR': 4,
12477 'DH_NOT_SUITABLE_GENERATOR': 8,
12478 'NPN_ENABLED': 1,
12479 'ALPN_ENABLED': 1,
12480 'RSA_PKCS1_PADDING': 1,
12481 'RSA_SSLV23_PADDING': 2,
12482 'RSA_NO_PADDING': 3,
12483 'RSA_PKCS1_OAEP_PADDING': 4,
12484 'RSA_X931_PADDING': 5,
12485 'RSA_PKCS1_PSS_PADDING': 6,
12486 'POINT_CONVERSION_COMPRESSED': 2,
12487 'POINT_CONVERSION_UNCOMPRESSED': 4,
12488 'POINT_CONVERSION_HYBRID': 6
12489}
12490
12491},{"browserify-cipher":63,"browserify-sign":70,"browserify-sign/algos":67,"create-ecdh":209,"create-hash":210,"create-hmac":213,"diffie-hellman":222,"pbkdf2":275,"public-encrypt":282,"randombytes":288,"randomfill":289}],216:[function(require,module,exports){
12492'use strict';
12493
12494exports.utils = require('./des/utils');
12495exports.Cipher = require('./des/cipher');
12496exports.DES = require('./des/des');
12497exports.CBC = require('./des/cbc');
12498exports.EDE = require('./des/ede');
12499
12500},{"./des/cbc":217,"./des/cipher":218,"./des/des":219,"./des/ede":220,"./des/utils":221}],217:[function(require,module,exports){
12501'use strict';
12502
12503var assert = require('minimalistic-assert');
12504var inherits = require('inherits');
12505
12506var proto = {};
12507
12508function CBCState(iv) {
12509 assert.equal(iv.length, 8, 'Invalid IV length');
12510
12511 this.iv = new Array(8);
12512 for (var i = 0; i < this.iv.length; i++)
12513 this.iv[i] = iv[i];
12514}
12515
12516function instantiate(Base) {
12517 function CBC(options) {
12518 Base.call(this, options);
12519 this._cbcInit();
12520 }
12521 inherits(CBC, Base);
12522
12523 var keys = Object.keys(proto);
12524 for (var i = 0; i < keys.length; i++) {
12525 var key = keys[i];
12526 CBC.prototype[key] = proto[key];
12527 }
12528
12529 CBC.create = function create(options) {
12530 return new CBC(options);
12531 };
12532
12533 return CBC;
12534}
12535
12536exports.instantiate = instantiate;
12537
12538proto._cbcInit = function _cbcInit() {
12539 var state = new CBCState(this.options.iv);
12540 this._cbcState = state;
12541};
12542
12543proto._update = function _update(inp, inOff, out, outOff) {
12544 var state = this._cbcState;
12545 var superProto = this.constructor.super_.prototype;
12546
12547 var iv = state.iv;
12548 if (this.type === 'encrypt') {
12549 for (var i = 0; i < this.blockSize; i++)
12550 iv[i] ^= inp[inOff + i];
12551
12552 superProto._update.call(this, iv, 0, out, outOff);
12553
12554 for (var i = 0; i < this.blockSize; i++)
12555 iv[i] = out[outOff + i];
12556 } else {
12557 superProto._update.call(this, inp, inOff, out, outOff);
12558
12559 for (var i = 0; i < this.blockSize; i++)
12560 out[outOff + i] ^= iv[i];
12561
12562 for (var i = 0; i < this.blockSize; i++)
12563 iv[i] = inp[inOff + i];
12564 }
12565};
12566
12567},{"inherits":260,"minimalistic-assert":266}],218:[function(require,module,exports){
12568'use strict';
12569
12570var assert = require('minimalistic-assert');
12571
12572function Cipher(options) {
12573 this.options = options;
12574
12575 this.type = this.options.type;
12576 this.blockSize = 8;
12577 this._init();
12578
12579 this.buffer = new Array(this.blockSize);
12580 this.bufferOff = 0;
12581}
12582module.exports = Cipher;
12583
12584Cipher.prototype._init = function _init() {
12585 // Might be overrided
12586};
12587
12588Cipher.prototype.update = function update(data) {
12589 if (data.length === 0)
12590 return [];
12591
12592 if (this.type === 'decrypt')
12593 return this._updateDecrypt(data);
12594 else
12595 return this._updateEncrypt(data);
12596};
12597
12598Cipher.prototype._buffer = function _buffer(data, off) {
12599 // Append data to buffer
12600 var min = Math.min(this.buffer.length - this.bufferOff, data.length - off);
12601 for (var i = 0; i < min; i++)
12602 this.buffer[this.bufferOff + i] = data[off + i];
12603 this.bufferOff += min;
12604
12605 // Shift next
12606 return min;
12607};
12608
12609Cipher.prototype._flushBuffer = function _flushBuffer(out, off) {
12610 this._update(this.buffer, 0, out, off);
12611 this.bufferOff = 0;
12612 return this.blockSize;
12613};
12614
12615Cipher.prototype._updateEncrypt = function _updateEncrypt(data) {
12616 var inputOff = 0;
12617 var outputOff = 0;
12618
12619 var count = ((this.bufferOff + data.length) / this.blockSize) | 0;
12620 var out = new Array(count * this.blockSize);
12621
12622 if (this.bufferOff !== 0) {
12623 inputOff += this._buffer(data, inputOff);
12624
12625 if (this.bufferOff === this.buffer.length)
12626 outputOff += this._flushBuffer(out, outputOff);
12627 }
12628
12629 // Write blocks
12630 var max = data.length - ((data.length - inputOff) % this.blockSize);
12631 for (; inputOff < max; inputOff += this.blockSize) {
12632 this._update(data, inputOff, out, outputOff);
12633 outputOff += this.blockSize;
12634 }
12635
12636 // Queue rest
12637 for (; inputOff < data.length; inputOff++, this.bufferOff++)
12638 this.buffer[this.bufferOff] = data[inputOff];
12639
12640 return out;
12641};
12642
12643Cipher.prototype._updateDecrypt = function _updateDecrypt(data) {
12644 var inputOff = 0;
12645 var outputOff = 0;
12646
12647 var count = Math.ceil((this.bufferOff + data.length) / this.blockSize) - 1;
12648 var out = new Array(count * this.blockSize);
12649
12650 // TODO(indutny): optimize it, this is far from optimal
12651 for (; count > 0; count--) {
12652 inputOff += this._buffer(data, inputOff);
12653 outputOff += this._flushBuffer(out, outputOff);
12654 }
12655
12656 // Buffer rest of the input
12657 inputOff += this._buffer(data, inputOff);
12658
12659 return out;
12660};
12661
12662Cipher.prototype.final = function final(buffer) {
12663 var first;
12664 if (buffer)
12665 first = this.update(buffer);
12666
12667 var last;
12668 if (this.type === 'encrypt')
12669 last = this._finalEncrypt();
12670 else
12671 last = this._finalDecrypt();
12672
12673 if (first)
12674 return first.concat(last);
12675 else
12676 return last;
12677};
12678
12679Cipher.prototype._pad = function _pad(buffer, off) {
12680 if (off === 0)
12681 return false;
12682
12683 while (off < buffer.length)
12684 buffer[off++] = 0;
12685
12686 return true;
12687};
12688
12689Cipher.prototype._finalEncrypt = function _finalEncrypt() {
12690 if (!this._pad(this.buffer, this.bufferOff))
12691 return [];
12692
12693 var out = new Array(this.blockSize);
12694 this._update(this.buffer, 0, out, 0);
12695 return out;
12696};
12697
12698Cipher.prototype._unpad = function _unpad(buffer) {
12699 return buffer;
12700};
12701
12702Cipher.prototype._finalDecrypt = function _finalDecrypt() {
12703 assert.equal(this.bufferOff, this.blockSize, 'Not enough data to decrypt');
12704 var out = new Array(this.blockSize);
12705 this._flushBuffer(out, 0);
12706
12707 return this._unpad(out);
12708};
12709
12710},{"minimalistic-assert":266}],219:[function(require,module,exports){
12711'use strict';
12712
12713var assert = require('minimalistic-assert');
12714var inherits = require('inherits');
12715
12716var des = require('../des');
12717var utils = des.utils;
12718var Cipher = des.Cipher;
12719
12720function DESState() {
12721 this.tmp = new Array(2);
12722 this.keys = null;
12723}
12724
12725function DES(options) {
12726 Cipher.call(this, options);
12727
12728 var state = new DESState();
12729 this._desState = state;
12730
12731 this.deriveKeys(state, options.key);
12732}
12733inherits(DES, Cipher);
12734module.exports = DES;
12735
12736DES.create = function create(options) {
12737 return new DES(options);
12738};
12739
12740var shiftTable = [
12741 1, 1, 2, 2, 2, 2, 2, 2,
12742 1, 2, 2, 2, 2, 2, 2, 1
12743];
12744
12745DES.prototype.deriveKeys = function deriveKeys(state, key) {
12746 state.keys = new Array(16 * 2);
12747
12748 assert.equal(key.length, this.blockSize, 'Invalid key length');
12749
12750 var kL = utils.readUInt32BE(key, 0);
12751 var kR = utils.readUInt32BE(key, 4);
12752
12753 utils.pc1(kL, kR, state.tmp, 0);
12754 kL = state.tmp[0];
12755 kR = state.tmp[1];
12756 for (var i = 0; i < state.keys.length; i += 2) {
12757 var shift = shiftTable[i >>> 1];
12758 kL = utils.r28shl(kL, shift);
12759 kR = utils.r28shl(kR, shift);
12760 utils.pc2(kL, kR, state.keys, i);
12761 }
12762};
12763
12764DES.prototype._update = function _update(inp, inOff, out, outOff) {
12765 var state = this._desState;
12766
12767 var l = utils.readUInt32BE(inp, inOff);
12768 var r = utils.readUInt32BE(inp, inOff + 4);
12769
12770 // Initial Permutation
12771 utils.ip(l, r, state.tmp, 0);
12772 l = state.tmp[0];
12773 r = state.tmp[1];
12774
12775 if (this.type === 'encrypt')
12776 this._encrypt(state, l, r, state.tmp, 0);
12777 else
12778 this._decrypt(state, l, r, state.tmp, 0);
12779
12780 l = state.tmp[0];
12781 r = state.tmp[1];
12782
12783 utils.writeUInt32BE(out, l, outOff);
12784 utils.writeUInt32BE(out, r, outOff + 4);
12785};
12786
12787DES.prototype._pad = function _pad(buffer, off) {
12788 var value = buffer.length - off;
12789 for (var i = off; i < buffer.length; i++)
12790 buffer[i] = value;
12791
12792 return true;
12793};
12794
12795DES.prototype._unpad = function _unpad(buffer) {
12796 var pad = buffer[buffer.length - 1];
12797 for (var i = buffer.length - pad; i < buffer.length; i++)
12798 assert.equal(buffer[i], pad);
12799
12800 return buffer.slice(0, buffer.length - pad);
12801};
12802
12803DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) {
12804 var l = lStart;
12805 var r = rStart;
12806
12807 // Apply f() x16 times
12808 for (var i = 0; i < state.keys.length; i += 2) {
12809 var keyL = state.keys[i];
12810 var keyR = state.keys[i + 1];
12811
12812 // f(r, k)
12813 utils.expand(r, state.tmp, 0);
12814
12815 keyL ^= state.tmp[0];
12816 keyR ^= state.tmp[1];
12817 var s = utils.substitute(keyL, keyR);
12818 var f = utils.permute(s);
12819
12820 var t = r;
12821 r = (l ^ f) >>> 0;
12822 l = t;
12823 }
12824
12825 // Reverse Initial Permutation
12826 utils.rip(r, l, out, off);
12827};
12828
12829DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) {
12830 var l = rStart;
12831 var r = lStart;
12832
12833 // Apply f() x16 times
12834 for (var i = state.keys.length - 2; i >= 0; i -= 2) {
12835 var keyL = state.keys[i];
12836 var keyR = state.keys[i + 1];
12837
12838 // f(r, k)
12839 utils.expand(l, state.tmp, 0);
12840
12841 keyL ^= state.tmp[0];
12842 keyR ^= state.tmp[1];
12843 var s = utils.substitute(keyL, keyR);
12844 var f = utils.permute(s);
12845
12846 var t = l;
12847 l = (r ^ f) >>> 0;
12848 r = t;
12849 }
12850
12851 // Reverse Initial Permutation
12852 utils.rip(l, r, out, off);
12853};
12854
12855},{"../des":216,"inherits":260,"minimalistic-assert":266}],220:[function(require,module,exports){
12856'use strict';
12857
12858var assert = require('minimalistic-assert');
12859var inherits = require('inherits');
12860
12861var des = require('../des');
12862var Cipher = des.Cipher;
12863var DES = des.DES;
12864
12865function EDEState(type, key) {
12866 assert.equal(key.length, 24, 'Invalid key length');
12867
12868 var k1 = key.slice(0, 8);
12869 var k2 = key.slice(8, 16);
12870 var k3 = key.slice(16, 24);
12871
12872 if (type === 'encrypt') {
12873 this.ciphers = [
12874 DES.create({ type: 'encrypt', key: k1 }),
12875 DES.create({ type: 'decrypt', key: k2 }),
12876 DES.create({ type: 'encrypt', key: k3 })
12877 ];
12878 } else {
12879 this.ciphers = [
12880 DES.create({ type: 'decrypt', key: k3 }),
12881 DES.create({ type: 'encrypt', key: k2 }),
12882 DES.create({ type: 'decrypt', key: k1 })
12883 ];
12884 }
12885}
12886
12887function EDE(options) {
12888 Cipher.call(this, options);
12889
12890 var state = new EDEState(this.type, this.options.key);
12891 this._edeState = state;
12892}
12893inherits(EDE, Cipher);
12894
12895module.exports = EDE;
12896
12897EDE.create = function create(options) {
12898 return new EDE(options);
12899};
12900
12901EDE.prototype._update = function _update(inp, inOff, out, outOff) {
12902 var state = this._edeState;
12903
12904 state.ciphers[0]._update(inp, inOff, out, outOff);
12905 state.ciphers[1]._update(out, outOff, out, outOff);
12906 state.ciphers[2]._update(out, outOff, out, outOff);
12907};
12908
12909EDE.prototype._pad = DES.prototype._pad;
12910EDE.prototype._unpad = DES.prototype._unpad;
12911
12912},{"../des":216,"inherits":260,"minimalistic-assert":266}],221:[function(require,module,exports){
12913'use strict';
12914
12915exports.readUInt32BE = function readUInt32BE(bytes, off) {
12916 var res = (bytes[0 + off] << 24) |
12917 (bytes[1 + off] << 16) |
12918 (bytes[2 + off] << 8) |
12919 bytes[3 + off];
12920 return res >>> 0;
12921};
12922
12923exports.writeUInt32BE = function writeUInt32BE(bytes, value, off) {
12924 bytes[0 + off] = value >>> 24;
12925 bytes[1 + off] = (value >>> 16) & 0xff;
12926 bytes[2 + off] = (value >>> 8) & 0xff;
12927 bytes[3 + off] = value & 0xff;
12928};
12929
12930exports.ip = function ip(inL, inR, out, off) {
12931 var outL = 0;
12932 var outR = 0;
12933
12934 for (var i = 6; i >= 0; i -= 2) {
12935 for (var j = 0; j <= 24; j += 8) {
12936 outL <<= 1;
12937 outL |= (inR >>> (j + i)) & 1;
12938 }
12939 for (var j = 0; j <= 24; j += 8) {
12940 outL <<= 1;
12941 outL |= (inL >>> (j + i)) & 1;
12942 }
12943 }
12944
12945 for (var i = 6; i >= 0; i -= 2) {
12946 for (var j = 1; j <= 25; j += 8) {
12947 outR <<= 1;
12948 outR |= (inR >>> (j + i)) & 1;
12949 }
12950 for (var j = 1; j <= 25; j += 8) {
12951 outR <<= 1;
12952 outR |= (inL >>> (j + i)) & 1;
12953 }
12954 }
12955
12956 out[off + 0] = outL >>> 0;
12957 out[off + 1] = outR >>> 0;
12958};
12959
12960exports.rip = function rip(inL, inR, out, off) {
12961 var outL = 0;
12962 var outR = 0;
12963
12964 for (var i = 0; i < 4; i++) {
12965 for (var j = 24; j >= 0; j -= 8) {
12966 outL <<= 1;
12967 outL |= (inR >>> (j + i)) & 1;
12968 outL <<= 1;
12969 outL |= (inL >>> (j + i)) & 1;
12970 }
12971 }
12972 for (var i = 4; i < 8; i++) {
12973 for (var j = 24; j >= 0; j -= 8) {
12974 outR <<= 1;
12975 outR |= (inR >>> (j + i)) & 1;
12976 outR <<= 1;
12977 outR |= (inL >>> (j + i)) & 1;
12978 }
12979 }
12980
12981 out[off + 0] = outL >>> 0;
12982 out[off + 1] = outR >>> 0;
12983};
12984
12985exports.pc1 = function pc1(inL, inR, out, off) {
12986 var outL = 0;
12987 var outR = 0;
12988
12989 // 7, 15, 23, 31, 39, 47, 55, 63
12990 // 6, 14, 22, 30, 39, 47, 55, 63
12991 // 5, 13, 21, 29, 39, 47, 55, 63
12992 // 4, 12, 20, 28
12993 for (var i = 7; i >= 5; i--) {
12994 for (var j = 0; j <= 24; j += 8) {
12995 outL <<= 1;
12996 outL |= (inR >> (j + i)) & 1;
12997 }
12998 for (var j = 0; j <= 24; j += 8) {
12999 outL <<= 1;
13000 outL |= (inL >> (j + i)) & 1;
13001 }
13002 }
13003 for (var j = 0; j <= 24; j += 8) {
13004 outL <<= 1;
13005 outL |= (inR >> (j + i)) & 1;
13006 }
13007
13008 // 1, 9, 17, 25, 33, 41, 49, 57
13009 // 2, 10, 18, 26, 34, 42, 50, 58
13010 // 3, 11, 19, 27, 35, 43, 51, 59
13011 // 36, 44, 52, 60
13012 for (var i = 1; i <= 3; i++) {
13013 for (var j = 0; j <= 24; j += 8) {
13014 outR <<= 1;
13015 outR |= (inR >> (j + i)) & 1;
13016 }
13017 for (var j = 0; j <= 24; j += 8) {
13018 outR <<= 1;
13019 outR |= (inL >> (j + i)) & 1;
13020 }
13021 }
13022 for (var j = 0; j <= 24; j += 8) {
13023 outR <<= 1;
13024 outR |= (inL >> (j + i)) & 1;
13025 }
13026
13027 out[off + 0] = outL >>> 0;
13028 out[off + 1] = outR >>> 0;
13029};
13030
13031exports.r28shl = function r28shl(num, shift) {
13032 return ((num << shift) & 0xfffffff) | (num >>> (28 - shift));
13033};
13034
13035var pc2table = [
13036 // inL => outL
13037 14, 11, 17, 4, 27, 23, 25, 0,
13038 13, 22, 7, 18, 5, 9, 16, 24,
13039 2, 20, 12, 21, 1, 8, 15, 26,
13040
13041 // inR => outR
13042 15, 4, 25, 19, 9, 1, 26, 16,
13043 5, 11, 23, 8, 12, 7, 17, 0,
13044 22, 3, 10, 14, 6, 20, 27, 24
13045];
13046
13047exports.pc2 = function pc2(inL, inR, out, off) {
13048 var outL = 0;
13049 var outR = 0;
13050
13051 var len = pc2table.length >>> 1;
13052 for (var i = 0; i < len; i++) {
13053 outL <<= 1;
13054 outL |= (inL >>> pc2table[i]) & 0x1;
13055 }
13056 for (var i = len; i < pc2table.length; i++) {
13057 outR <<= 1;
13058 outR |= (inR >>> pc2table[i]) & 0x1;
13059 }
13060
13061 out[off + 0] = outL >>> 0;
13062 out[off + 1] = outR >>> 0;
13063};
13064
13065exports.expand = function expand(r, out, off) {
13066 var outL = 0;
13067 var outR = 0;
13068
13069 outL = ((r & 1) << 5) | (r >>> 27);
13070 for (var i = 23; i >= 15; i -= 4) {
13071 outL <<= 6;
13072 outL |= (r >>> i) & 0x3f;
13073 }
13074 for (var i = 11; i >= 3; i -= 4) {
13075 outR |= (r >>> i) & 0x3f;
13076 outR <<= 6;
13077 }
13078 outR |= ((r & 0x1f) << 1) | (r >>> 31);
13079
13080 out[off + 0] = outL >>> 0;
13081 out[off + 1] = outR >>> 0;
13082};
13083
13084var sTable = [
13085 14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1,
13086 3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8,
13087 4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7,
13088 15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13,
13089
13090 15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14,
13091 9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5,
13092 0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2,
13093 5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9,
13094
13095 10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10,
13096 1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1,
13097 13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7,
13098 11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12,
13099
13100 7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3,
13101 1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9,
13102 10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8,
13103 15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14,
13104
13105 2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1,
13106 8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6,
13107 4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13,
13108 15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3,
13109
13110 12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5,
13111 0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8,
13112 9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10,
13113 7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13,
13114
13115 4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10,
13116 3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6,
13117 1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7,
13118 10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12,
13119
13120 13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4,
13121 10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2,
13122 7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13,
13123 0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11
13124];
13125
13126exports.substitute = function substitute(inL, inR) {
13127 var out = 0;
13128 for (var i = 0; i < 4; i++) {
13129 var b = (inL >>> (18 - i * 6)) & 0x3f;
13130 var sb = sTable[i * 0x40 + b];
13131
13132 out <<= 4;
13133 out |= sb;
13134 }
13135 for (var i = 0; i < 4; i++) {
13136 var b = (inR >>> (18 - i * 6)) & 0x3f;
13137 var sb = sTable[4 * 0x40 + i * 0x40 + b];
13138
13139 out <<= 4;
13140 out |= sb;
13141 }
13142 return out >>> 0;
13143};
13144
13145var permuteTable = [
13146 16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22,
13147 30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 7
13148];
13149
13150exports.permute = function permute(num) {
13151 var out = 0;
13152 for (var i = 0; i < permuteTable.length; i++) {
13153 out <<= 1;
13154 out |= (num >>> permuteTable[i]) & 0x1;
13155 }
13156 return out >>> 0;
13157};
13158
13159exports.padSplit = function padSplit(num, size, group) {
13160 var str = num.toString(2);
13161 while (str.length < size)
13162 str = '0' + str;
13163
13164 var out = [];
13165 for (var i = 0; i < size; i += group)
13166 out.push(str.slice(i, i + group));
13167 return out.join(' ');
13168};
13169
13170},{}],222:[function(require,module,exports){
13171(function (Buffer){
13172var generatePrime = require('./lib/generatePrime')
13173var primes = require('./lib/primes.json')
13174
13175var DH = require('./lib/dh')
13176
13177function getDiffieHellman (mod) {
13178 var prime = new Buffer(primes[mod].prime, 'hex')
13179 var gen = new Buffer(primes[mod].gen, 'hex')
13180
13181 return new DH(prime, gen)
13182}
13183
13184var ENCODINGS = {
13185 'binary': true, 'hex': true, 'base64': true
13186}
13187
13188function createDiffieHellman (prime, enc, generator, genc) {
13189 if (Buffer.isBuffer(enc) || ENCODINGS[enc] === undefined) {
13190 return createDiffieHellman(prime, 'binary', enc, generator)
13191 }
13192
13193 enc = enc || 'binary'
13194 genc = genc || 'binary'
13195 generator = generator || new Buffer([2])
13196
13197 if (!Buffer.isBuffer(generator)) {
13198 generator = new Buffer(generator, genc)
13199 }
13200
13201 if (typeof prime === 'number') {
13202 return new DH(generatePrime(prime, generator), generator, true)
13203 }
13204
13205 if (!Buffer.isBuffer(prime)) {
13206 prime = new Buffer(prime, enc)
13207 }
13208
13209 return new DH(prime, generator, true)
13210}
13211
13212exports.DiffieHellmanGroup = exports.createDiffieHellmanGroup = exports.getDiffieHellman = getDiffieHellman
13213exports.createDiffieHellman = exports.DiffieHellman = createDiffieHellman
13214
13215}).call(this,require("buffer").Buffer)
13216},{"./lib/dh":223,"./lib/generatePrime":224,"./lib/primes.json":225,"buffer":75}],223:[function(require,module,exports){
13217(function (Buffer){
13218var BN = require('bn.js');
13219var MillerRabin = require('miller-rabin');
13220var millerRabin = new MillerRabin();
13221var TWENTYFOUR = new BN(24);
13222var ELEVEN = new BN(11);
13223var TEN = new BN(10);
13224var THREE = new BN(3);
13225var SEVEN = new BN(7);
13226var primes = require('./generatePrime');
13227var randomBytes = require('randombytes');
13228module.exports = DH;
13229
13230function setPublicKey(pub, enc) {
13231 enc = enc || 'utf8';
13232 if (!Buffer.isBuffer(pub)) {
13233 pub = new Buffer(pub, enc);
13234 }
13235 this._pub = new BN(pub);
13236 return this;
13237}
13238
13239function setPrivateKey(priv, enc) {
13240 enc = enc || 'utf8';
13241 if (!Buffer.isBuffer(priv)) {
13242 priv = new Buffer(priv, enc);
13243 }
13244 this._priv = new BN(priv);
13245 return this;
13246}
13247
13248var primeCache = {};
13249function checkPrime(prime, generator) {
13250 var gen = generator.toString('hex');
13251 var hex = [gen, prime.toString(16)].join('_');
13252 if (hex in primeCache) {
13253 return primeCache[hex];
13254 }
13255 var error = 0;
13256
13257 if (prime.isEven() ||
13258 !primes.simpleSieve ||
13259 !primes.fermatTest(prime) ||
13260 !millerRabin.test(prime)) {
13261 //not a prime so +1
13262 error += 1;
13263
13264 if (gen === '02' || gen === '05') {
13265 // we'd be able to check the generator
13266 // it would fail so +8
13267 error += 8;
13268 } else {
13269 //we wouldn't be able to test the generator
13270 // so +4
13271 error += 4;
13272 }
13273 primeCache[hex] = error;
13274 return error;
13275 }
13276 if (!millerRabin.test(prime.shrn(1))) {
13277 //not a safe prime
13278 error += 2;
13279 }
13280 var rem;
13281 switch (gen) {
13282 case '02':
13283 if (prime.mod(TWENTYFOUR).cmp(ELEVEN)) {
13284 // unsuidable generator
13285 error += 8;
13286 }
13287 break;
13288 case '05':
13289 rem = prime.mod(TEN);
13290 if (rem.cmp(THREE) && rem.cmp(SEVEN)) {
13291 // prime mod 10 needs to equal 3 or 7
13292 error += 8;
13293 }
13294 break;
13295 default:
13296 error += 4;
13297 }
13298 primeCache[hex] = error;
13299 return error;
13300}
13301
13302function DH(prime, generator, malleable) {
13303 this.setGenerator(generator);
13304 this.__prime = new BN(prime);
13305 this._prime = BN.mont(this.__prime);
13306 this._primeLen = prime.length;
13307 this._pub = undefined;
13308 this._priv = undefined;
13309 this._primeCode = undefined;
13310 if (malleable) {
13311 this.setPublicKey = setPublicKey;
13312 this.setPrivateKey = setPrivateKey;
13313 } else {
13314 this._primeCode = 8;
13315 }
13316}
13317Object.defineProperty(DH.prototype, 'verifyError', {
13318 enumerable: true,
13319 get: function () {
13320 if (typeof this._primeCode !== 'number') {
13321 this._primeCode = checkPrime(this.__prime, this.__gen);
13322 }
13323 return this._primeCode;
13324 }
13325});
13326DH.prototype.generateKeys = function () {
13327 if (!this._priv) {
13328 this._priv = new BN(randomBytes(this._primeLen));
13329 }
13330 this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed();
13331 return this.getPublicKey();
13332};
13333
13334DH.prototype.computeSecret = function (other) {
13335 other = new BN(other);
13336 other = other.toRed(this._prime);
13337 var secret = other.redPow(this._priv).fromRed();
13338 var out = new Buffer(secret.toArray());
13339 var prime = this.getPrime();
13340 if (out.length < prime.length) {
13341 var front = new Buffer(prime.length - out.length);
13342 front.fill(0);
13343 out = Buffer.concat([front, out]);
13344 }
13345 return out;
13346};
13347
13348DH.prototype.getPublicKey = function getPublicKey(enc) {
13349 return formatReturnValue(this._pub, enc);
13350};
13351
13352DH.prototype.getPrivateKey = function getPrivateKey(enc) {
13353 return formatReturnValue(this._priv, enc);
13354};
13355
13356DH.prototype.getPrime = function (enc) {
13357 return formatReturnValue(this.__prime, enc);
13358};
13359
13360DH.prototype.getGenerator = function (enc) {
13361 return formatReturnValue(this._gen, enc);
13362};
13363
13364DH.prototype.setGenerator = function (gen, enc) {
13365 enc = enc || 'utf8';
13366 if (!Buffer.isBuffer(gen)) {
13367 gen = new Buffer(gen, enc);
13368 }
13369 this.__gen = gen;
13370 this._gen = new BN(gen);
13371 return this;
13372};
13373
13374function formatReturnValue(bn, enc) {
13375 var buf = new Buffer(bn.toArray());
13376 if (!enc) {
13377 return buf;
13378 } else {
13379 return buf.toString(enc);
13380 }
13381}
13382
13383}).call(this,require("buffer").Buffer)
13384},{"./generatePrime":224,"bn.js":43,"buffer":75,"miller-rabin":265,"randombytes":288}],224:[function(require,module,exports){
13385var randomBytes = require('randombytes');
13386module.exports = findPrime;
13387findPrime.simpleSieve = simpleSieve;
13388findPrime.fermatTest = fermatTest;
13389var BN = require('bn.js');
13390var TWENTYFOUR = new BN(24);
13391var MillerRabin = require('miller-rabin');
13392var millerRabin = new MillerRabin();
13393var ONE = new BN(1);
13394var TWO = new BN(2);
13395var FIVE = new BN(5);
13396var SIXTEEN = new BN(16);
13397var EIGHT = new BN(8);
13398var TEN = new BN(10);
13399var THREE = new BN(3);
13400var SEVEN = new BN(7);
13401var ELEVEN = new BN(11);
13402var FOUR = new BN(4);
13403var TWELVE = new BN(12);
13404var primes = null;
13405
13406function _getPrimes() {
13407 if (primes !== null)
13408 return primes;
13409
13410 var limit = 0x100000;
13411 var res = [];
13412 res[0] = 2;
13413 for (var i = 1, k = 3; k < limit; k += 2) {
13414 var sqrt = Math.ceil(Math.sqrt(k));
13415 for (var j = 0; j < i && res[j] <= sqrt; j++)
13416 if (k % res[j] === 0)
13417 break;
13418
13419 if (i !== j && res[j] <= sqrt)
13420 continue;
13421
13422 res[i++] = k;
13423 }
13424 primes = res;
13425 return res;
13426}
13427
13428function simpleSieve(p) {
13429 var primes = _getPrimes();
13430
13431 for (var i = 0; i < primes.length; i++)
13432 if (p.modn(primes[i]) === 0) {
13433 if (p.cmpn(primes[i]) === 0) {
13434 return true;
13435 } else {
13436 return false;
13437 }
13438 }
13439
13440 return true;
13441}
13442
13443function fermatTest(p) {
13444 var red = BN.mont(p);
13445 return TWO.toRed(red).redPow(p.subn(1)).fromRed().cmpn(1) === 0;
13446}
13447
13448function findPrime(bits, gen) {
13449 if (bits < 16) {
13450 // this is what openssl does
13451 if (gen === 2 || gen === 5) {
13452 return new BN([0x8c, 0x7b]);
13453 } else {
13454 return new BN([0x8c, 0x27]);
13455 }
13456 }
13457 gen = new BN(gen);
13458
13459 var num, n2;
13460
13461 while (true) {
13462 num = new BN(randomBytes(Math.ceil(bits / 8)));
13463 while (num.bitLength() > bits) {
13464 num.ishrn(1);
13465 }
13466 if (num.isEven()) {
13467 num.iadd(ONE);
13468 }
13469 if (!num.testn(1)) {
13470 num.iadd(TWO);
13471 }
13472 if (!gen.cmp(TWO)) {
13473 while (num.mod(TWENTYFOUR).cmp(ELEVEN)) {
13474 num.iadd(FOUR);
13475 }
13476 } else if (!gen.cmp(FIVE)) {
13477 while (num.mod(TEN).cmp(THREE)) {
13478 num.iadd(FOUR);
13479 }
13480 }
13481 n2 = num.shrn(1);
13482 if (simpleSieve(n2) && simpleSieve(num) &&
13483 fermatTest(n2) && fermatTest(num) &&
13484 millerRabin.test(n2) && millerRabin.test(num)) {
13485 return num;
13486 }
13487 }
13488
13489}
13490
13491},{"bn.js":43,"miller-rabin":265,"randombytes":288}],225:[function(require,module,exports){
13492module.exports={
13493 "modp1": {
13494 "gen": "02",
13495 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"
13496 },
13497 "modp2": {
13498 "gen": "02",
13499 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"
13500 },
13501 "modp5": {
13502 "gen": "02",
13503 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"
13504 },
13505 "modp14": {
13506 "gen": "02",
13507 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"
13508 },
13509 "modp15": {
13510 "gen": "02",
13511 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"
13512 },
13513 "modp16": {
13514 "gen": "02",
13515 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"
13516 },
13517 "modp17": {
13518 "gen": "02",
13519 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"
13520 },
13521 "modp18": {
13522 "gen": "02",
13523 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"
13524 }
13525}
13526},{}],226:[function(require,module,exports){
13527'use strict';
13528
13529var elliptic = exports;
13530
13531elliptic.version = require('../package.json').version;
13532elliptic.utils = require('./elliptic/utils');
13533elliptic.rand = require('brorand');
13534elliptic.curve = require('./elliptic/curve');
13535elliptic.curves = require('./elliptic/curves');
13536
13537// Protocols
13538elliptic.ec = require('./elliptic/ec');
13539elliptic.eddsa = require('./elliptic/eddsa');
13540
13541},{"../package.json":241,"./elliptic/curve":229,"./elliptic/curves":232,"./elliptic/ec":233,"./elliptic/eddsa":236,"./elliptic/utils":240,"brorand":44}],227:[function(require,module,exports){
13542'use strict';
13543
13544var BN = require('bn.js');
13545var elliptic = require('../../elliptic');
13546var utils = elliptic.utils;
13547var getNAF = utils.getNAF;
13548var getJSF = utils.getJSF;
13549var assert = utils.assert;
13550
13551function BaseCurve(type, conf) {
13552 this.type = type;
13553 this.p = new BN(conf.p, 16);
13554
13555 // Use Montgomery, when there is no fast reduction for the prime
13556 this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p);
13557
13558 // Useful for many curves
13559 this.zero = new BN(0).toRed(this.red);
13560 this.one = new BN(1).toRed(this.red);
13561 this.two = new BN(2).toRed(this.red);
13562
13563 // Curve configuration, optional
13564 this.n = conf.n && new BN(conf.n, 16);
13565 this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed);
13566
13567 // Temporary arrays
13568 this._wnafT1 = new Array(4);
13569 this._wnafT2 = new Array(4);
13570 this._wnafT3 = new Array(4);
13571 this._wnafT4 = new Array(4);
13572
13573 // Generalized Greg Maxwell's trick
13574 var adjustCount = this.n && this.p.div(this.n);
13575 if (!adjustCount || adjustCount.cmpn(100) > 0) {
13576 this.redN = null;
13577 } else {
13578 this._maxwellTrick = true;
13579 this.redN = this.n.toRed(this.red);
13580 }
13581}
13582module.exports = BaseCurve;
13583
13584BaseCurve.prototype.point = function point() {
13585 throw new Error('Not implemented');
13586};
13587
13588BaseCurve.prototype.validate = function validate() {
13589 throw new Error('Not implemented');
13590};
13591
13592BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) {
13593 assert(p.precomputed);
13594 var doubles = p._getDoubles();
13595
13596 var naf = getNAF(k, 1);
13597 var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1);
13598 I /= 3;
13599
13600 // Translate into more windowed form
13601 var repr = [];
13602 for (var j = 0; j < naf.length; j += doubles.step) {
13603 var nafW = 0;
13604 for (var k = j + doubles.step - 1; k >= j; k--)
13605 nafW = (nafW << 1) + naf[k];
13606 repr.push(nafW);
13607 }
13608
13609 var a = this.jpoint(null, null, null);
13610 var b = this.jpoint(null, null, null);
13611 for (var i = I; i > 0; i--) {
13612 for (var j = 0; j < repr.length; j++) {
13613 var nafW = repr[j];
13614 if (nafW === i)
13615 b = b.mixedAdd(doubles.points[j]);
13616 else if (nafW === -i)
13617 b = b.mixedAdd(doubles.points[j].neg());
13618 }
13619 a = a.add(b);
13620 }
13621 return a.toP();
13622};
13623
13624BaseCurve.prototype._wnafMul = function _wnafMul(p, k) {
13625 var w = 4;
13626
13627 // Precompute window
13628 var nafPoints = p._getNAFPoints(w);
13629 w = nafPoints.wnd;
13630 var wnd = nafPoints.points;
13631
13632 // Get NAF form
13633 var naf = getNAF(k, w);
13634
13635 // Add `this`*(N+1) for every w-NAF index
13636 var acc = this.jpoint(null, null, null);
13637 for (var i = naf.length - 1; i >= 0; i--) {
13638 // Count zeroes
13639 for (var k = 0; i >= 0 && naf[i] === 0; i--)
13640 k++;
13641 if (i >= 0)
13642 k++;
13643 acc = acc.dblp(k);
13644
13645 if (i < 0)
13646 break;
13647 var z = naf[i];
13648 assert(z !== 0);
13649 if (p.type === 'affine') {
13650 // J +- P
13651 if (z > 0)
13652 acc = acc.mixedAdd(wnd[(z - 1) >> 1]);
13653 else
13654 acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg());
13655 } else {
13656 // J +- J
13657 if (z > 0)
13658 acc = acc.add(wnd[(z - 1) >> 1]);
13659 else
13660 acc = acc.add(wnd[(-z - 1) >> 1].neg());
13661 }
13662 }
13663 return p.type === 'affine' ? acc.toP() : acc;
13664};
13665
13666BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW,
13667 points,
13668 coeffs,
13669 len,
13670 jacobianResult) {
13671 var wndWidth = this._wnafT1;
13672 var wnd = this._wnafT2;
13673 var naf = this._wnafT3;
13674
13675 // Fill all arrays
13676 var max = 0;
13677 for (var i = 0; i < len; i++) {
13678 var p = points[i];
13679 var nafPoints = p._getNAFPoints(defW);
13680 wndWidth[i] = nafPoints.wnd;
13681 wnd[i] = nafPoints.points;
13682 }
13683
13684 // Comb small window NAFs
13685 for (var i = len - 1; i >= 1; i -= 2) {
13686 var a = i - 1;
13687 var b = i;
13688 if (wndWidth[a] !== 1 || wndWidth[b] !== 1) {
13689 naf[a] = getNAF(coeffs[a], wndWidth[a]);
13690 naf[b] = getNAF(coeffs[b], wndWidth[b]);
13691 max = Math.max(naf[a].length, max);
13692 max = Math.max(naf[b].length, max);
13693 continue;
13694 }
13695
13696 var comb = [
13697 points[a], /* 1 */
13698 null, /* 3 */
13699 null, /* 5 */
13700 points[b] /* 7 */
13701 ];
13702
13703 // Try to avoid Projective points, if possible
13704 if (points[a].y.cmp(points[b].y) === 0) {
13705 comb[1] = points[a].add(points[b]);
13706 comb[2] = points[a].toJ().mixedAdd(points[b].neg());
13707 } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) {
13708 comb[1] = points[a].toJ().mixedAdd(points[b]);
13709 comb[2] = points[a].add(points[b].neg());
13710 } else {
13711 comb[1] = points[a].toJ().mixedAdd(points[b]);
13712 comb[2] = points[a].toJ().mixedAdd(points[b].neg());
13713 }
13714
13715 var index = [
13716 -3, /* -1 -1 */
13717 -1, /* -1 0 */
13718 -5, /* -1 1 */
13719 -7, /* 0 -1 */
13720 0, /* 0 0 */
13721 7, /* 0 1 */
13722 5, /* 1 -1 */
13723 1, /* 1 0 */
13724 3 /* 1 1 */
13725 ];
13726
13727 var jsf = getJSF(coeffs[a], coeffs[b]);
13728 max = Math.max(jsf[0].length, max);
13729 naf[a] = new Array(max);
13730 naf[b] = new Array(max);
13731 for (var j = 0; j < max; j++) {
13732 var ja = jsf[0][j] | 0;
13733 var jb = jsf[1][j] | 0;
13734
13735 naf[a][j] = index[(ja + 1) * 3 + (jb + 1)];
13736 naf[b][j] = 0;
13737 wnd[a] = comb;
13738 }
13739 }
13740
13741 var acc = this.jpoint(null, null, null);
13742 var tmp = this._wnafT4;
13743 for (var i = max; i >= 0; i--) {
13744 var k = 0;
13745
13746 while (i >= 0) {
13747 var zero = true;
13748 for (var j = 0; j < len; j++) {
13749 tmp[j] = naf[j][i] | 0;
13750 if (tmp[j] !== 0)
13751 zero = false;
13752 }
13753 if (!zero)
13754 break;
13755 k++;
13756 i--;
13757 }
13758 if (i >= 0)
13759 k++;
13760 acc = acc.dblp(k);
13761 if (i < 0)
13762 break;
13763
13764 for (var j = 0; j < len; j++) {
13765 var z = tmp[j];
13766 var p;
13767 if (z === 0)
13768 continue;
13769 else if (z > 0)
13770 p = wnd[j][(z - 1) >> 1];
13771 else if (z < 0)
13772 p = wnd[j][(-z - 1) >> 1].neg();
13773
13774 if (p.type === 'affine')
13775 acc = acc.mixedAdd(p);
13776 else
13777 acc = acc.add(p);
13778 }
13779 }
13780 // Zeroify references
13781 for (var i = 0; i < len; i++)
13782 wnd[i] = null;
13783
13784 if (jacobianResult)
13785 return acc;
13786 else
13787 return acc.toP();
13788};
13789
13790function BasePoint(curve, type) {
13791 this.curve = curve;
13792 this.type = type;
13793 this.precomputed = null;
13794}
13795BaseCurve.BasePoint = BasePoint;
13796
13797BasePoint.prototype.eq = function eq(/*other*/) {
13798 throw new Error('Not implemented');
13799};
13800
13801BasePoint.prototype.validate = function validate() {
13802 return this.curve.validate(this);
13803};
13804
13805BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
13806 bytes = utils.toArray(bytes, enc);
13807
13808 var len = this.p.byteLength();
13809
13810 // uncompressed, hybrid-odd, hybrid-even
13811 if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) &&
13812 bytes.length - 1 === 2 * len) {
13813 if (bytes[0] === 0x06)
13814 assert(bytes[bytes.length - 1] % 2 === 0);
13815 else if (bytes[0] === 0x07)
13816 assert(bytes[bytes.length - 1] % 2 === 1);
13817
13818 var res = this.point(bytes.slice(1, 1 + len),
13819 bytes.slice(1 + len, 1 + 2 * len));
13820
13821 return res;
13822 } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) &&
13823 bytes.length - 1 === len) {
13824 return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03);
13825 }
13826 throw new Error('Unknown point format');
13827};
13828
13829BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) {
13830 return this.encode(enc, true);
13831};
13832
13833BasePoint.prototype._encode = function _encode(compact) {
13834 var len = this.curve.p.byteLength();
13835 var x = this.getX().toArray('be', len);
13836
13837 if (compact)
13838 return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x);
13839
13840 return [ 0x04 ].concat(x, this.getY().toArray('be', len)) ;
13841};
13842
13843BasePoint.prototype.encode = function encode(enc, compact) {
13844 return utils.encode(this._encode(compact), enc);
13845};
13846
13847BasePoint.prototype.precompute = function precompute(power) {
13848 if (this.precomputed)
13849 return this;
13850
13851 var precomputed = {
13852 doubles: null,
13853 naf: null,
13854 beta: null
13855 };
13856 precomputed.naf = this._getNAFPoints(8);
13857 precomputed.doubles = this._getDoubles(4, power);
13858 precomputed.beta = this._getBeta();
13859 this.precomputed = precomputed;
13860
13861 return this;
13862};
13863
13864BasePoint.prototype._hasDoubles = function _hasDoubles(k) {
13865 if (!this.precomputed)
13866 return false;
13867
13868 var doubles = this.precomputed.doubles;
13869 if (!doubles)
13870 return false;
13871
13872 return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step);
13873};
13874
13875BasePoint.prototype._getDoubles = function _getDoubles(step, power) {
13876 if (this.precomputed && this.precomputed.doubles)
13877 return this.precomputed.doubles;
13878
13879 var doubles = [ this ];
13880 var acc = this;
13881 for (var i = 0; i < power; i += step) {
13882 for (var j = 0; j < step; j++)
13883 acc = acc.dbl();
13884 doubles.push(acc);
13885 }
13886 return {
13887 step: step,
13888 points: doubles
13889 };
13890};
13891
13892BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) {
13893 if (this.precomputed && this.precomputed.naf)
13894 return this.precomputed.naf;
13895
13896 var res = [ this ];
13897 var max = (1 << wnd) - 1;
13898 var dbl = max === 1 ? null : this.dbl();
13899 for (var i = 1; i < max; i++)
13900 res[i] = res[i - 1].add(dbl);
13901 return {
13902 wnd: wnd,
13903 points: res
13904 };
13905};
13906
13907BasePoint.prototype._getBeta = function _getBeta() {
13908 return null;
13909};
13910
13911BasePoint.prototype.dblp = function dblp(k) {
13912 var r = this;
13913 for (var i = 0; i < k; i++)
13914 r = r.dbl();
13915 return r;
13916};
13917
13918},{"../../elliptic":226,"bn.js":43}],228:[function(require,module,exports){
13919'use strict';
13920
13921var curve = require('../curve');
13922var elliptic = require('../../elliptic');
13923var BN = require('bn.js');
13924var inherits = require('inherits');
13925var Base = curve.base;
13926
13927var assert = elliptic.utils.assert;
13928
13929function EdwardsCurve(conf) {
13930 // NOTE: Important as we are creating point in Base.call()
13931 this.twisted = (conf.a | 0) !== 1;
13932 this.mOneA = this.twisted && (conf.a | 0) === -1;
13933 this.extended = this.mOneA;
13934
13935 Base.call(this, 'edwards', conf);
13936
13937 this.a = new BN(conf.a, 16).umod(this.red.m);
13938 this.a = this.a.toRed(this.red);
13939 this.c = new BN(conf.c, 16).toRed(this.red);
13940 this.c2 = this.c.redSqr();
13941 this.d = new BN(conf.d, 16).toRed(this.red);
13942 this.dd = this.d.redAdd(this.d);
13943
13944 assert(!this.twisted || this.c.fromRed().cmpn(1) === 0);
13945 this.oneC = (conf.c | 0) === 1;
13946}
13947inherits(EdwardsCurve, Base);
13948module.exports = EdwardsCurve;
13949
13950EdwardsCurve.prototype._mulA = function _mulA(num) {
13951 if (this.mOneA)
13952 return num.redNeg();
13953 else
13954 return this.a.redMul(num);
13955};
13956
13957EdwardsCurve.prototype._mulC = function _mulC(num) {
13958 if (this.oneC)
13959 return num;
13960 else
13961 return this.c.redMul(num);
13962};
13963
13964// Just for compatibility with Short curve
13965EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) {
13966 return this.point(x, y, z, t);
13967};
13968
13969EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) {
13970 x = new BN(x, 16);
13971 if (!x.red)
13972 x = x.toRed(this.red);
13973
13974 var x2 = x.redSqr();
13975 var rhs = this.c2.redSub(this.a.redMul(x2));
13976 var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2));
13977
13978 var y2 = rhs.redMul(lhs.redInvm());
13979 var y = y2.redSqrt();
13980 if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
13981 throw new Error('invalid point');
13982
13983 var isOdd = y.fromRed().isOdd();
13984 if (odd && !isOdd || !odd && isOdd)
13985 y = y.redNeg();
13986
13987 return this.point(x, y);
13988};
13989
13990EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {
13991 y = new BN(y, 16);
13992 if (!y.red)
13993 y = y.toRed(this.red);
13994
13995 // x^2 = (y^2 - 1) / (d y^2 + 1)
13996 var y2 = y.redSqr();
13997 var lhs = y2.redSub(this.one);
13998 var rhs = y2.redMul(this.d).redAdd(this.one);
13999 var x2 = lhs.redMul(rhs.redInvm());
14000
14001 if (x2.cmp(this.zero) === 0) {
14002 if (odd)
14003 throw new Error('invalid point');
14004 else
14005 return this.point(this.zero, y);
14006 }
14007
14008 var x = x2.redSqrt();
14009 if (x.redSqr().redSub(x2).cmp(this.zero) !== 0)
14010 throw new Error('invalid point');
14011
14012 if (x.isOdd() !== odd)
14013 x = x.redNeg();
14014
14015 return this.point(x, y);
14016};
14017
14018EdwardsCurve.prototype.validate = function validate(point) {
14019 if (point.isInfinity())
14020 return true;
14021
14022 // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2)
14023 point.normalize();
14024
14025 var x2 = point.x.redSqr();
14026 var y2 = point.y.redSqr();
14027 var lhs = x2.redMul(this.a).redAdd(y2);
14028 var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));
14029
14030 return lhs.cmp(rhs) === 0;
14031};
14032
14033function Point(curve, x, y, z, t) {
14034 Base.BasePoint.call(this, curve, 'projective');
14035 if (x === null && y === null && z === null) {
14036 this.x = this.curve.zero;
14037 this.y = this.curve.one;
14038 this.z = this.curve.one;
14039 this.t = this.curve.zero;
14040 this.zOne = true;
14041 } else {
14042 this.x = new BN(x, 16);
14043 this.y = new BN(y, 16);
14044 this.z = z ? new BN(z, 16) : this.curve.one;
14045 this.t = t && new BN(t, 16);
14046 if (!this.x.red)
14047 this.x = this.x.toRed(this.curve.red);
14048 if (!this.y.red)
14049 this.y = this.y.toRed(this.curve.red);
14050 if (!this.z.red)
14051 this.z = this.z.toRed(this.curve.red);
14052 if (this.t && !this.t.red)
14053 this.t = this.t.toRed(this.curve.red);
14054 this.zOne = this.z === this.curve.one;
14055
14056 // Use extended coordinates
14057 if (this.curve.extended && !this.t) {
14058 this.t = this.x.redMul(this.y);
14059 if (!this.zOne)
14060 this.t = this.t.redMul(this.z.redInvm());
14061 }
14062 }
14063}
14064inherits(Point, Base.BasePoint);
14065
14066EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
14067 return Point.fromJSON(this, obj);
14068};
14069
14070EdwardsCurve.prototype.point = function point(x, y, z, t) {
14071 return new Point(this, x, y, z, t);
14072};
14073
14074Point.fromJSON = function fromJSON(curve, obj) {
14075 return new Point(curve, obj[0], obj[1], obj[2]);
14076};
14077
14078Point.prototype.inspect = function inspect() {
14079 if (this.isInfinity())
14080 return '<EC Point Infinity>';
14081 return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
14082 ' y: ' + this.y.fromRed().toString(16, 2) +
14083 ' z: ' + this.z.fromRed().toString(16, 2) + '>';
14084};
14085
14086Point.prototype.isInfinity = function isInfinity() {
14087 // XXX This code assumes that zero is always zero in red
14088 return this.x.cmpn(0) === 0 &&
14089 this.y.cmp(this.z) === 0;
14090};
14091
14092Point.prototype._extDbl = function _extDbl() {
14093 // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
14094 // #doubling-dbl-2008-hwcd
14095 // 4M + 4S
14096
14097 // A = X1^2
14098 var a = this.x.redSqr();
14099 // B = Y1^2
14100 var b = this.y.redSqr();
14101 // C = 2 * Z1^2
14102 var c = this.z.redSqr();
14103 c = c.redIAdd(c);
14104 // D = a * A
14105 var d = this.curve._mulA(a);
14106 // E = (X1 + Y1)^2 - A - B
14107 var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b);
14108 // G = D + B
14109 var g = d.redAdd(b);
14110 // F = G - C
14111 var f = g.redSub(c);
14112 // H = D - B
14113 var h = d.redSub(b);
14114 // X3 = E * F
14115 var nx = e.redMul(f);
14116 // Y3 = G * H
14117 var ny = g.redMul(h);
14118 // T3 = E * H
14119 var nt = e.redMul(h);
14120 // Z3 = F * G
14121 var nz = f.redMul(g);
14122 return this.curve.point(nx, ny, nz, nt);
14123};
14124
14125Point.prototype._projDbl = function _projDbl() {
14126 // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
14127 // #doubling-dbl-2008-bbjlp
14128 // #doubling-dbl-2007-bl
14129 // and others
14130 // Generally 3M + 4S or 2M + 4S
14131
14132 // B = (X1 + Y1)^2
14133 var b = this.x.redAdd(this.y).redSqr();
14134 // C = X1^2
14135 var c = this.x.redSqr();
14136 // D = Y1^2
14137 var d = this.y.redSqr();
14138
14139 var nx;
14140 var ny;
14141 var nz;
14142 if (this.curve.twisted) {
14143 // E = a * C
14144 var e = this.curve._mulA(c);
14145 // F = E + D
14146 var f = e.redAdd(d);
14147 if (this.zOne) {
14148 // X3 = (B - C - D) * (F - 2)
14149 nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two));
14150 // Y3 = F * (E - D)
14151 ny = f.redMul(e.redSub(d));
14152 // Z3 = F^2 - 2 * F
14153 nz = f.redSqr().redSub(f).redSub(f);
14154 } else {
14155 // H = Z1^2
14156 var h = this.z.redSqr();
14157 // J = F - 2 * H
14158 var j = f.redSub(h).redISub(h);
14159 // X3 = (B-C-D)*J
14160 nx = b.redSub(c).redISub(d).redMul(j);
14161 // Y3 = F * (E - D)
14162 ny = f.redMul(e.redSub(d));
14163 // Z3 = F * J
14164 nz = f.redMul(j);
14165 }
14166 } else {
14167 // E = C + D
14168 var e = c.redAdd(d);
14169 // H = (c * Z1)^2
14170 var h = this.curve._mulC(this.c.redMul(this.z)).redSqr();
14171 // J = E - 2 * H
14172 var j = e.redSub(h).redSub(h);
14173 // X3 = c * (B - E) * J
14174 nx = this.curve._mulC(b.redISub(e)).redMul(j);
14175 // Y3 = c * E * (C - D)
14176 ny = this.curve._mulC(e).redMul(c.redISub(d));
14177 // Z3 = E * J
14178 nz = e.redMul(j);
14179 }
14180 return this.curve.point(nx, ny, nz);
14181};
14182
14183Point.prototype.dbl = function dbl() {
14184 if (this.isInfinity())
14185 return this;
14186
14187 // Double in extended coordinates
14188 if (this.curve.extended)
14189 return this._extDbl();
14190 else
14191 return this._projDbl();
14192};
14193
14194Point.prototype._extAdd = function _extAdd(p) {
14195 // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
14196 // #addition-add-2008-hwcd-3
14197 // 8M
14198
14199 // A = (Y1 - X1) * (Y2 - X2)
14200 var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x));
14201 // B = (Y1 + X1) * (Y2 + X2)
14202 var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x));
14203 // C = T1 * k * T2
14204 var c = this.t.redMul(this.curve.dd).redMul(p.t);
14205 // D = Z1 * 2 * Z2
14206 var d = this.z.redMul(p.z.redAdd(p.z));
14207 // E = B - A
14208 var e = b.redSub(a);
14209 // F = D - C
14210 var f = d.redSub(c);
14211 // G = D + C
14212 var g = d.redAdd(c);
14213 // H = B + A
14214 var h = b.redAdd(a);
14215 // X3 = E * F
14216 var nx = e.redMul(f);
14217 // Y3 = G * H
14218 var ny = g.redMul(h);
14219 // T3 = E * H
14220 var nt = e.redMul(h);
14221 // Z3 = F * G
14222 var nz = f.redMul(g);
14223 return this.curve.point(nx, ny, nz, nt);
14224};
14225
14226Point.prototype._projAdd = function _projAdd(p) {
14227 // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
14228 // #addition-add-2008-bbjlp
14229 // #addition-add-2007-bl
14230 // 10M + 1S
14231
14232 // A = Z1 * Z2
14233 var a = this.z.redMul(p.z);
14234 // B = A^2
14235 var b = a.redSqr();
14236 // C = X1 * X2
14237 var c = this.x.redMul(p.x);
14238 // D = Y1 * Y2
14239 var d = this.y.redMul(p.y);
14240 // E = d * C * D
14241 var e = this.curve.d.redMul(c).redMul(d);
14242 // F = B - E
14243 var f = b.redSub(e);
14244 // G = B + E
14245 var g = b.redAdd(e);
14246 // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D)
14247 var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d);
14248 var nx = a.redMul(f).redMul(tmp);
14249 var ny;
14250 var nz;
14251 if (this.curve.twisted) {
14252 // Y3 = A * G * (D - a * C)
14253 ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c)));
14254 // Z3 = F * G
14255 nz = f.redMul(g);
14256 } else {
14257 // Y3 = A * G * (D - C)
14258 ny = a.redMul(g).redMul(d.redSub(c));
14259 // Z3 = c * F * G
14260 nz = this.curve._mulC(f).redMul(g);
14261 }
14262 return this.curve.point(nx, ny, nz);
14263};
14264
14265Point.prototype.add = function add(p) {
14266 if (this.isInfinity())
14267 return p;
14268 if (p.isInfinity())
14269 return this;
14270
14271 if (this.curve.extended)
14272 return this._extAdd(p);
14273 else
14274 return this._projAdd(p);
14275};
14276
14277Point.prototype.mul = function mul(k) {
14278 if (this._hasDoubles(k))
14279 return this.curve._fixedNafMul(this, k);
14280 else
14281 return this.curve._wnafMul(this, k);
14282};
14283
14284Point.prototype.mulAdd = function mulAdd(k1, p, k2) {
14285 return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false);
14286};
14287
14288Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) {
14289 return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true);
14290};
14291
14292Point.prototype.normalize = function normalize() {
14293 if (this.zOne)
14294 return this;
14295
14296 // Normalize coordinates
14297 var zi = this.z.redInvm();
14298 this.x = this.x.redMul(zi);
14299 this.y = this.y.redMul(zi);
14300 if (this.t)
14301 this.t = this.t.redMul(zi);
14302 this.z = this.curve.one;
14303 this.zOne = true;
14304 return this;
14305};
14306
14307Point.prototype.neg = function neg() {
14308 return this.curve.point(this.x.redNeg(),
14309 this.y,
14310 this.z,
14311 this.t && this.t.redNeg());
14312};
14313
14314Point.prototype.getX = function getX() {
14315 this.normalize();
14316 return this.x.fromRed();
14317};
14318
14319Point.prototype.getY = function getY() {
14320 this.normalize();
14321 return this.y.fromRed();
14322};
14323
14324Point.prototype.eq = function eq(other) {
14325 return this === other ||
14326 this.getX().cmp(other.getX()) === 0 &&
14327 this.getY().cmp(other.getY()) === 0;
14328};
14329
14330Point.prototype.eqXToP = function eqXToP(x) {
14331 var rx = x.toRed(this.curve.red).redMul(this.z);
14332 if (this.x.cmp(rx) === 0)
14333 return true;
14334
14335 var xc = x.clone();
14336 var t = this.curve.redN.redMul(this.z);
14337 for (;;) {
14338 xc.iadd(this.curve.n);
14339 if (xc.cmp(this.curve.p) >= 0)
14340 return false;
14341
14342 rx.redIAdd(t);
14343 if (this.x.cmp(rx) === 0)
14344 return true;
14345 }
14346 return false;
14347};
14348
14349// Compatibility with BaseCurve
14350Point.prototype.toP = Point.prototype.normalize;
14351Point.prototype.mixedAdd = Point.prototype.add;
14352
14353},{"../../elliptic":226,"../curve":229,"bn.js":43,"inherits":260}],229:[function(require,module,exports){
14354'use strict';
14355
14356var curve = exports;
14357
14358curve.base = require('./base');
14359curve.short = require('./short');
14360curve.mont = require('./mont');
14361curve.edwards = require('./edwards');
14362
14363},{"./base":227,"./edwards":228,"./mont":230,"./short":231}],230:[function(require,module,exports){
14364'use strict';
14365
14366var curve = require('../curve');
14367var BN = require('bn.js');
14368var inherits = require('inherits');
14369var Base = curve.base;
14370
14371var elliptic = require('../../elliptic');
14372var utils = elliptic.utils;
14373
14374function MontCurve(conf) {
14375 Base.call(this, 'mont', conf);
14376
14377 this.a = new BN(conf.a, 16).toRed(this.red);
14378 this.b = new BN(conf.b, 16).toRed(this.red);
14379 this.i4 = new BN(4).toRed(this.red).redInvm();
14380 this.two = new BN(2).toRed(this.red);
14381 this.a24 = this.i4.redMul(this.a.redAdd(this.two));
14382}
14383inherits(MontCurve, Base);
14384module.exports = MontCurve;
14385
14386MontCurve.prototype.validate = function validate(point) {
14387 var x = point.normalize().x;
14388 var x2 = x.redSqr();
14389 var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x);
14390 var y = rhs.redSqrt();
14391
14392 return y.redSqr().cmp(rhs) === 0;
14393};
14394
14395function Point(curve, x, z) {
14396 Base.BasePoint.call(this, curve, 'projective');
14397 if (x === null && z === null) {
14398 this.x = this.curve.one;
14399 this.z = this.curve.zero;
14400 } else {
14401 this.x = new BN(x, 16);
14402 this.z = new BN(z, 16);
14403 if (!this.x.red)
14404 this.x = this.x.toRed(this.curve.red);
14405 if (!this.z.red)
14406 this.z = this.z.toRed(this.curve.red);
14407 }
14408}
14409inherits(Point, Base.BasePoint);
14410
14411MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
14412 return this.point(utils.toArray(bytes, enc), 1);
14413};
14414
14415MontCurve.prototype.point = function point(x, z) {
14416 return new Point(this, x, z);
14417};
14418
14419MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
14420 return Point.fromJSON(this, obj);
14421};
14422
14423Point.prototype.precompute = function precompute() {
14424 // No-op
14425};
14426
14427Point.prototype._encode = function _encode() {
14428 return this.getX().toArray('be', this.curve.p.byteLength());
14429};
14430
14431Point.fromJSON = function fromJSON(curve, obj) {
14432 return new Point(curve, obj[0], obj[1] || curve.one);
14433};
14434
14435Point.prototype.inspect = function inspect() {
14436 if (this.isInfinity())
14437 return '<EC Point Infinity>';
14438 return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
14439 ' z: ' + this.z.fromRed().toString(16, 2) + '>';
14440};
14441
14442Point.prototype.isInfinity = function isInfinity() {
14443 // XXX This code assumes that zero is always zero in red
14444 return this.z.cmpn(0) === 0;
14445};
14446
14447Point.prototype.dbl = function dbl() {
14448 // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3
14449 // 2M + 2S + 4A
14450
14451 // A = X1 + Z1
14452 var a = this.x.redAdd(this.z);
14453 // AA = A^2
14454 var aa = a.redSqr();
14455 // B = X1 - Z1
14456 var b = this.x.redSub(this.z);
14457 // BB = B^2
14458 var bb = b.redSqr();
14459 // C = AA - BB
14460 var c = aa.redSub(bb);
14461 // X3 = AA * BB
14462 var nx = aa.redMul(bb);
14463 // Z3 = C * (BB + A24 * C)
14464 var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c)));
14465 return this.curve.point(nx, nz);
14466};
14467
14468Point.prototype.add = function add() {
14469 throw new Error('Not supported on Montgomery curve');
14470};
14471
14472Point.prototype.diffAdd = function diffAdd(p, diff) {
14473 // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3
14474 // 4M + 2S + 6A
14475
14476 // A = X2 + Z2
14477 var a = this.x.redAdd(this.z);
14478 // B = X2 - Z2
14479 var b = this.x.redSub(this.z);
14480 // C = X3 + Z3
14481 var c = p.x.redAdd(p.z);
14482 // D = X3 - Z3
14483 var d = p.x.redSub(p.z);
14484 // DA = D * A
14485 var da = d.redMul(a);
14486 // CB = C * B
14487 var cb = c.redMul(b);
14488 // X5 = Z1 * (DA + CB)^2
14489 var nx = diff.z.redMul(da.redAdd(cb).redSqr());
14490 // Z5 = X1 * (DA - CB)^2
14491 var nz = diff.x.redMul(da.redISub(cb).redSqr());
14492 return this.curve.point(nx, nz);
14493};
14494
14495Point.prototype.mul = function mul(k) {
14496 var t = k.clone();
14497 var a = this; // (N / 2) * Q + Q
14498 var b = this.curve.point(null, null); // (N / 2) * Q
14499 var c = this; // Q
14500
14501 for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1))
14502 bits.push(t.andln(1));
14503
14504 for (var i = bits.length - 1; i >= 0; i--) {
14505 if (bits[i] === 0) {
14506 // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q
14507 a = a.diffAdd(b, c);
14508 // N * Q = 2 * ((N / 2) * Q + Q))
14509 b = b.dbl();
14510 } else {
14511 // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q)
14512 b = a.diffAdd(b, c);
14513 // N * Q + Q = 2 * ((N / 2) * Q + Q)
14514 a = a.dbl();
14515 }
14516 }
14517 return b;
14518};
14519
14520Point.prototype.mulAdd = function mulAdd() {
14521 throw new Error('Not supported on Montgomery curve');
14522};
14523
14524Point.prototype.jumlAdd = function jumlAdd() {
14525 throw new Error('Not supported on Montgomery curve');
14526};
14527
14528Point.prototype.eq = function eq(other) {
14529 return this.getX().cmp(other.getX()) === 0;
14530};
14531
14532Point.prototype.normalize = function normalize() {
14533 this.x = this.x.redMul(this.z.redInvm());
14534 this.z = this.curve.one;
14535 return this;
14536};
14537
14538Point.prototype.getX = function getX() {
14539 // Normalize coordinates
14540 this.normalize();
14541
14542 return this.x.fromRed();
14543};
14544
14545},{"../../elliptic":226,"../curve":229,"bn.js":43,"inherits":260}],231:[function(require,module,exports){
14546'use strict';
14547
14548var curve = require('../curve');
14549var elliptic = require('../../elliptic');
14550var BN = require('bn.js');
14551var inherits = require('inherits');
14552var Base = curve.base;
14553
14554var assert = elliptic.utils.assert;
14555
14556function ShortCurve(conf) {
14557 Base.call(this, 'short', conf);
14558
14559 this.a = new BN(conf.a, 16).toRed(this.red);
14560 this.b = new BN(conf.b, 16).toRed(this.red);
14561 this.tinv = this.two.redInvm();
14562
14563 this.zeroA = this.a.fromRed().cmpn(0) === 0;
14564 this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0;
14565
14566 // If the curve is endomorphic, precalculate beta and lambda
14567 this.endo = this._getEndomorphism(conf);
14568 this._endoWnafT1 = new Array(4);
14569 this._endoWnafT2 = new Array(4);
14570}
14571inherits(ShortCurve, Base);
14572module.exports = ShortCurve;
14573
14574ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) {
14575 // No efficient endomorphism
14576 if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)
14577 return;
14578
14579 // Compute beta and lambda, that lambda * P = (beta * Px; Py)
14580 var beta;
14581 var lambda;
14582 if (conf.beta) {
14583 beta = new BN(conf.beta, 16).toRed(this.red);
14584 } else {
14585 var betas = this._getEndoRoots(this.p);
14586 // Choose the smallest beta
14587 beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1];
14588 beta = beta.toRed(this.red);
14589 }
14590 if (conf.lambda) {
14591 lambda = new BN(conf.lambda, 16);
14592 } else {
14593 // Choose the lambda that is matching selected beta
14594 var lambdas = this._getEndoRoots(this.n);
14595 if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) {
14596 lambda = lambdas[0];
14597 } else {
14598 lambda = lambdas[1];
14599 assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0);
14600 }
14601 }
14602
14603 // Get basis vectors, used for balanced length-two representation
14604 var basis;
14605 if (conf.basis) {
14606 basis = conf.basis.map(function(vec) {
14607 return {
14608 a: new BN(vec.a, 16),
14609 b: new BN(vec.b, 16)
14610 };
14611 });
14612 } else {
14613 basis = this._getEndoBasis(lambda);
14614 }
14615
14616 return {
14617 beta: beta,
14618 lambda: lambda,
14619 basis: basis
14620 };
14621};
14622
14623ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) {
14624 // Find roots of for x^2 + x + 1 in F
14625 // Root = (-1 +- Sqrt(-3)) / 2
14626 //
14627 var red = num === this.p ? this.red : BN.mont(num);
14628 var tinv = new BN(2).toRed(red).redInvm();
14629 var ntinv = tinv.redNeg();
14630
14631 var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv);
14632
14633 var l1 = ntinv.redAdd(s).fromRed();
14634 var l2 = ntinv.redSub(s).fromRed();
14635 return [ l1, l2 ];
14636};
14637
14638ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) {
14639 // aprxSqrt >= sqrt(this.n)
14640 var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2));
14641
14642 // 3.74
14643 // Run EGCD, until r(L + 1) < aprxSqrt
14644 var u = lambda;
14645 var v = this.n.clone();
14646 var x1 = new BN(1);
14647 var y1 = new BN(0);
14648 var x2 = new BN(0);
14649 var y2 = new BN(1);
14650
14651 // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n)
14652 var a0;
14653 var b0;
14654 // First vector
14655 var a1;
14656 var b1;
14657 // Second vector
14658 var a2;
14659 var b2;
14660
14661 var prevR;
14662 var i = 0;
14663 var r;
14664 var x;
14665 while (u.cmpn(0) !== 0) {
14666 var q = v.div(u);
14667 r = v.sub(q.mul(u));
14668 x = x2.sub(q.mul(x1));
14669 var y = y2.sub(q.mul(y1));
14670
14671 if (!a1 && r.cmp(aprxSqrt) < 0) {
14672 a0 = prevR.neg();
14673 b0 = x1;
14674 a1 = r.neg();
14675 b1 = x;
14676 } else if (a1 && ++i === 2) {
14677 break;
14678 }
14679 prevR = r;
14680
14681 v = u;
14682 u = r;
14683 x2 = x1;
14684 x1 = x;
14685 y2 = y1;
14686 y1 = y;
14687 }
14688 a2 = r.neg();
14689 b2 = x;
14690
14691 var len1 = a1.sqr().add(b1.sqr());
14692 var len2 = a2.sqr().add(b2.sqr());
14693 if (len2.cmp(len1) >= 0) {
14694 a2 = a0;
14695 b2 = b0;
14696 }
14697
14698 // Normalize signs
14699 if (a1.negative) {
14700 a1 = a1.neg();
14701 b1 = b1.neg();
14702 }
14703 if (a2.negative) {
14704 a2 = a2.neg();
14705 b2 = b2.neg();
14706 }
14707
14708 return [
14709 { a: a1, b: b1 },
14710 { a: a2, b: b2 }
14711 ];
14712};
14713
14714ShortCurve.prototype._endoSplit = function _endoSplit(k) {
14715 var basis = this.endo.basis;
14716 var v1 = basis[0];
14717 var v2 = basis[1];
14718
14719 var c1 = v2.b.mul(k).divRound(this.n);
14720 var c2 = v1.b.neg().mul(k).divRound(this.n);
14721
14722 var p1 = c1.mul(v1.a);
14723 var p2 = c2.mul(v2.a);
14724 var q1 = c1.mul(v1.b);
14725 var q2 = c2.mul(v2.b);
14726
14727 // Calculate answer
14728 var k1 = k.sub(p1).sub(p2);
14729 var k2 = q1.add(q2).neg();
14730 return { k1: k1, k2: k2 };
14731};
14732
14733ShortCurve.prototype.pointFromX = function pointFromX(x, odd) {
14734 x = new BN(x, 16);
14735 if (!x.red)
14736 x = x.toRed(this.red);
14737
14738 var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b);
14739 var y = y2.redSqrt();
14740 if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
14741 throw new Error('invalid point');
14742
14743 // XXX Is there any way to tell if the number is odd without converting it
14744 // to non-red form?
14745 var isOdd = y.fromRed().isOdd();
14746 if (odd && !isOdd || !odd && isOdd)
14747 y = y.redNeg();
14748
14749 return this.point(x, y);
14750};
14751
14752ShortCurve.prototype.validate = function validate(point) {
14753 if (point.inf)
14754 return true;
14755
14756 var x = point.x;
14757 var y = point.y;
14758
14759 var ax = this.a.redMul(x);
14760 var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b);
14761 return y.redSqr().redISub(rhs).cmpn(0) === 0;
14762};
14763
14764ShortCurve.prototype._endoWnafMulAdd =
14765 function _endoWnafMulAdd(points, coeffs, jacobianResult) {
14766 var npoints = this._endoWnafT1;
14767 var ncoeffs = this._endoWnafT2;
14768 for (var i = 0; i < points.length; i++) {
14769 var split = this._endoSplit(coeffs[i]);
14770 var p = points[i];
14771 var beta = p._getBeta();
14772
14773 if (split.k1.negative) {
14774 split.k1.ineg();
14775 p = p.neg(true);
14776 }
14777 if (split.k2.negative) {
14778 split.k2.ineg();
14779 beta = beta.neg(true);
14780 }
14781
14782 npoints[i * 2] = p;
14783 npoints[i * 2 + 1] = beta;
14784 ncoeffs[i * 2] = split.k1;
14785 ncoeffs[i * 2 + 1] = split.k2;
14786 }
14787 var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult);
14788
14789 // Clean-up references to points and coefficients
14790 for (var j = 0; j < i * 2; j++) {
14791 npoints[j] = null;
14792 ncoeffs[j] = null;
14793 }
14794 return res;
14795};
14796
14797function Point(curve, x, y, isRed) {
14798 Base.BasePoint.call(this, curve, 'affine');
14799 if (x === null && y === null) {
14800 this.x = null;
14801 this.y = null;
14802 this.inf = true;
14803 } else {
14804 this.x = new BN(x, 16);
14805 this.y = new BN(y, 16);
14806 // Force redgomery representation when loading from JSON
14807 if (isRed) {
14808 this.x.forceRed(this.curve.red);
14809 this.y.forceRed(this.curve.red);
14810 }
14811 if (!this.x.red)
14812 this.x = this.x.toRed(this.curve.red);
14813 if (!this.y.red)
14814 this.y = this.y.toRed(this.curve.red);
14815 this.inf = false;
14816 }
14817}
14818inherits(Point, Base.BasePoint);
14819
14820ShortCurve.prototype.point = function point(x, y, isRed) {
14821 return new Point(this, x, y, isRed);
14822};
14823
14824ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) {
14825 return Point.fromJSON(this, obj, red);
14826};
14827
14828Point.prototype._getBeta = function _getBeta() {
14829 if (!this.curve.endo)
14830 return;
14831
14832 var pre = this.precomputed;
14833 if (pre && pre.beta)
14834 return pre.beta;
14835
14836 var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y);
14837 if (pre) {
14838 var curve = this.curve;
14839 var endoMul = function(p) {
14840 return curve.point(p.x.redMul(curve.endo.beta), p.y);
14841 };
14842 pre.beta = beta;
14843 beta.precomputed = {
14844 beta: null,
14845 naf: pre.naf && {
14846 wnd: pre.naf.wnd,
14847 points: pre.naf.points.map(endoMul)
14848 },
14849 doubles: pre.doubles && {
14850 step: pre.doubles.step,
14851 points: pre.doubles.points.map(endoMul)
14852 }
14853 };
14854 }
14855 return beta;
14856};
14857
14858Point.prototype.toJSON = function toJSON() {
14859 if (!this.precomputed)
14860 return [ this.x, this.y ];
14861
14862 return [ this.x, this.y, this.precomputed && {
14863 doubles: this.precomputed.doubles && {
14864 step: this.precomputed.doubles.step,
14865 points: this.precomputed.doubles.points.slice(1)
14866 },
14867 naf: this.precomputed.naf && {
14868 wnd: this.precomputed.naf.wnd,
14869 points: this.precomputed.naf.points.slice(1)
14870 }
14871 } ];
14872};
14873
14874Point.fromJSON = function fromJSON(curve, obj, red) {
14875 if (typeof obj === 'string')
14876 obj = JSON.parse(obj);
14877 var res = curve.point(obj[0], obj[1], red);
14878 if (!obj[2])
14879 return res;
14880
14881 function obj2point(obj) {
14882 return curve.point(obj[0], obj[1], red);
14883 }
14884
14885 var pre = obj[2];
14886 res.precomputed = {
14887 beta: null,
14888 doubles: pre.doubles && {
14889 step: pre.doubles.step,
14890 points: [ res ].concat(pre.doubles.points.map(obj2point))
14891 },
14892 naf: pre.naf && {
14893 wnd: pre.naf.wnd,
14894 points: [ res ].concat(pre.naf.points.map(obj2point))
14895 }
14896 };
14897 return res;
14898};
14899
14900Point.prototype.inspect = function inspect() {
14901 if (this.isInfinity())
14902 return '<EC Point Infinity>';
14903 return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
14904 ' y: ' + this.y.fromRed().toString(16, 2) + '>';
14905};
14906
14907Point.prototype.isInfinity = function isInfinity() {
14908 return this.inf;
14909};
14910
14911Point.prototype.add = function add(p) {
14912 // O + P = P
14913 if (this.inf)
14914 return p;
14915
14916 // P + O = P
14917 if (p.inf)
14918 return this;
14919
14920 // P + P = 2P
14921 if (this.eq(p))
14922 return this.dbl();
14923
14924 // P + (-P) = O
14925 if (this.neg().eq(p))
14926 return this.curve.point(null, null);
14927
14928 // P + Q = O
14929 if (this.x.cmp(p.x) === 0)
14930 return this.curve.point(null, null);
14931
14932 var c = this.y.redSub(p.y);
14933 if (c.cmpn(0) !== 0)
14934 c = c.redMul(this.x.redSub(p.x).redInvm());
14935 var nx = c.redSqr().redISub(this.x).redISub(p.x);
14936 var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
14937 return this.curve.point(nx, ny);
14938};
14939
14940Point.prototype.dbl = function dbl() {
14941 if (this.inf)
14942 return this;
14943
14944 // 2P = O
14945 var ys1 = this.y.redAdd(this.y);
14946 if (ys1.cmpn(0) === 0)
14947 return this.curve.point(null, null);
14948
14949 var a = this.curve.a;
14950
14951 var x2 = this.x.redSqr();
14952 var dyinv = ys1.redInvm();
14953 var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv);
14954
14955 var nx = c.redSqr().redISub(this.x.redAdd(this.x));
14956 var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
14957 return this.curve.point(nx, ny);
14958};
14959
14960Point.prototype.getX = function getX() {
14961 return this.x.fromRed();
14962};
14963
14964Point.prototype.getY = function getY() {
14965 return this.y.fromRed();
14966};
14967
14968Point.prototype.mul = function mul(k) {
14969 k = new BN(k, 16);
14970
14971 if (this._hasDoubles(k))
14972 return this.curve._fixedNafMul(this, k);
14973 else if (this.curve.endo)
14974 return this.curve._endoWnafMulAdd([ this ], [ k ]);
14975 else
14976 return this.curve._wnafMul(this, k);
14977};
14978
14979Point.prototype.mulAdd = function mulAdd(k1, p2, k2) {
14980 var points = [ this, p2 ];
14981 var coeffs = [ k1, k2 ];
14982 if (this.curve.endo)
14983 return this.curve._endoWnafMulAdd(points, coeffs);
14984 else
14985 return this.curve._wnafMulAdd(1, points, coeffs, 2);
14986};
14987
14988Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) {
14989 var points = [ this, p2 ];
14990 var coeffs = [ k1, k2 ];
14991 if (this.curve.endo)
14992 return this.curve._endoWnafMulAdd(points, coeffs, true);
14993 else
14994 return this.curve._wnafMulAdd(1, points, coeffs, 2, true);
14995};
14996
14997Point.prototype.eq = function eq(p) {
14998 return this === p ||
14999 this.inf === p.inf &&
15000 (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0);
15001};
15002
15003Point.prototype.neg = function neg(_precompute) {
15004 if (this.inf)
15005 return this;
15006
15007 var res = this.curve.point(this.x, this.y.redNeg());
15008 if (_precompute && this.precomputed) {
15009 var pre = this.precomputed;
15010 var negate = function(p) {
15011 return p.neg();
15012 };
15013 res.precomputed = {
15014 naf: pre.naf && {
15015 wnd: pre.naf.wnd,
15016 points: pre.naf.points.map(negate)
15017 },
15018 doubles: pre.doubles && {
15019 step: pre.doubles.step,
15020 points: pre.doubles.points.map(negate)
15021 }
15022 };
15023 }
15024 return res;
15025};
15026
15027Point.prototype.toJ = function toJ() {
15028 if (this.inf)
15029 return this.curve.jpoint(null, null, null);
15030
15031 var res = this.curve.jpoint(this.x, this.y, this.curve.one);
15032 return res;
15033};
15034
15035function JPoint(curve, x, y, z) {
15036 Base.BasePoint.call(this, curve, 'jacobian');
15037 if (x === null && y === null && z === null) {
15038 this.x = this.curve.one;
15039 this.y = this.curve.one;
15040 this.z = new BN(0);
15041 } else {
15042 this.x = new BN(x, 16);
15043 this.y = new BN(y, 16);
15044 this.z = new BN(z, 16);
15045 }
15046 if (!this.x.red)
15047 this.x = this.x.toRed(this.curve.red);
15048 if (!this.y.red)
15049 this.y = this.y.toRed(this.curve.red);
15050 if (!this.z.red)
15051 this.z = this.z.toRed(this.curve.red);
15052
15053 this.zOne = this.z === this.curve.one;
15054}
15055inherits(JPoint, Base.BasePoint);
15056
15057ShortCurve.prototype.jpoint = function jpoint(x, y, z) {
15058 return new JPoint(this, x, y, z);
15059};
15060
15061JPoint.prototype.toP = function toP() {
15062 if (this.isInfinity())
15063 return this.curve.point(null, null);
15064
15065 var zinv = this.z.redInvm();
15066 var zinv2 = zinv.redSqr();
15067 var ax = this.x.redMul(zinv2);
15068 var ay = this.y.redMul(zinv2).redMul(zinv);
15069
15070 return this.curve.point(ax, ay);
15071};
15072
15073JPoint.prototype.neg = function neg() {
15074 return this.curve.jpoint(this.x, this.y.redNeg(), this.z);
15075};
15076
15077JPoint.prototype.add = function add(p) {
15078 // O + P = P
15079 if (this.isInfinity())
15080 return p;
15081
15082 // P + O = P
15083 if (p.isInfinity())
15084 return this;
15085
15086 // 12M + 4S + 7A
15087 var pz2 = p.z.redSqr();
15088 var z2 = this.z.redSqr();
15089 var u1 = this.x.redMul(pz2);
15090 var u2 = p.x.redMul(z2);
15091 var s1 = this.y.redMul(pz2.redMul(p.z));
15092 var s2 = p.y.redMul(z2.redMul(this.z));
15093
15094 var h = u1.redSub(u2);
15095 var r = s1.redSub(s2);
15096 if (h.cmpn(0) === 0) {
15097 if (r.cmpn(0) !== 0)
15098 return this.curve.jpoint(null, null, null);
15099 else
15100 return this.dbl();
15101 }
15102
15103 var h2 = h.redSqr();
15104 var h3 = h2.redMul(h);
15105 var v = u1.redMul(h2);
15106
15107 var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
15108 var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
15109 var nz = this.z.redMul(p.z).redMul(h);
15110
15111 return this.curve.jpoint(nx, ny, nz);
15112};
15113
15114JPoint.prototype.mixedAdd = function mixedAdd(p) {
15115 // O + P = P
15116 if (this.isInfinity())
15117 return p.toJ();
15118
15119 // P + O = P
15120 if (p.isInfinity())
15121 return this;
15122
15123 // 8M + 3S + 7A
15124 var z2 = this.z.redSqr();
15125 var u1 = this.x;
15126 var u2 = p.x.redMul(z2);
15127 var s1 = this.y;
15128 var s2 = p.y.redMul(z2).redMul(this.z);
15129
15130 var h = u1.redSub(u2);
15131 var r = s1.redSub(s2);
15132 if (h.cmpn(0) === 0) {
15133 if (r.cmpn(0) !== 0)
15134 return this.curve.jpoint(null, null, null);
15135 else
15136 return this.dbl();
15137 }
15138
15139 var h2 = h.redSqr();
15140 var h3 = h2.redMul(h);
15141 var v = u1.redMul(h2);
15142
15143 var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
15144 var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
15145 var nz = this.z.redMul(h);
15146
15147 return this.curve.jpoint(nx, ny, nz);
15148};
15149
15150JPoint.prototype.dblp = function dblp(pow) {
15151 if (pow === 0)
15152 return this;
15153 if (this.isInfinity())
15154 return this;
15155 if (!pow)
15156 return this.dbl();
15157
15158 if (this.curve.zeroA || this.curve.threeA) {
15159 var r = this;
15160 for (var i = 0; i < pow; i++)
15161 r = r.dbl();
15162 return r;
15163 }
15164
15165 // 1M + 2S + 1A + N * (4S + 5M + 8A)
15166 // N = 1 => 6M + 6S + 9A
15167 var a = this.curve.a;
15168 var tinv = this.curve.tinv;
15169
15170 var jx = this.x;
15171 var jy = this.y;
15172 var jz = this.z;
15173 var jz4 = jz.redSqr().redSqr();
15174
15175 // Reuse results
15176 var jyd = jy.redAdd(jy);
15177 for (var i = 0; i < pow; i++) {
15178 var jx2 = jx.redSqr();
15179 var jyd2 = jyd.redSqr();
15180 var jyd4 = jyd2.redSqr();
15181 var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
15182
15183 var t1 = jx.redMul(jyd2);
15184 var nx = c.redSqr().redISub(t1.redAdd(t1));
15185 var t2 = t1.redISub(nx);
15186 var dny = c.redMul(t2);
15187 dny = dny.redIAdd(dny).redISub(jyd4);
15188 var nz = jyd.redMul(jz);
15189 if (i + 1 < pow)
15190 jz4 = jz4.redMul(jyd4);
15191
15192 jx = nx;
15193 jz = nz;
15194 jyd = dny;
15195 }
15196
15197 return this.curve.jpoint(jx, jyd.redMul(tinv), jz);
15198};
15199
15200JPoint.prototype.dbl = function dbl() {
15201 if (this.isInfinity())
15202 return this;
15203
15204 if (this.curve.zeroA)
15205 return this._zeroDbl();
15206 else if (this.curve.threeA)
15207 return this._threeDbl();
15208 else
15209 return this._dbl();
15210};
15211
15212JPoint.prototype._zeroDbl = function _zeroDbl() {
15213 var nx;
15214 var ny;
15215 var nz;
15216 // Z = 1
15217 if (this.zOne) {
15218 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
15219 // #doubling-mdbl-2007-bl
15220 // 1M + 5S + 14A
15221
15222 // XX = X1^2
15223 var xx = this.x.redSqr();
15224 // YY = Y1^2
15225 var yy = this.y.redSqr();
15226 // YYYY = YY^2
15227 var yyyy = yy.redSqr();
15228 // S = 2 * ((X1 + YY)^2 - XX - YYYY)
15229 var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
15230 s = s.redIAdd(s);
15231 // M = 3 * XX + a; a = 0
15232 var m = xx.redAdd(xx).redIAdd(xx);
15233 // T = M ^ 2 - 2*S
15234 var t = m.redSqr().redISub(s).redISub(s);
15235
15236 // 8 * YYYY
15237 var yyyy8 = yyyy.redIAdd(yyyy);
15238 yyyy8 = yyyy8.redIAdd(yyyy8);
15239 yyyy8 = yyyy8.redIAdd(yyyy8);
15240
15241 // X3 = T
15242 nx = t;
15243 // Y3 = M * (S - T) - 8 * YYYY
15244 ny = m.redMul(s.redISub(t)).redISub(yyyy8);
15245 // Z3 = 2*Y1
15246 nz = this.y.redAdd(this.y);
15247 } else {
15248 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
15249 // #doubling-dbl-2009-l
15250 // 2M + 5S + 13A
15251
15252 // A = X1^2
15253 var a = this.x.redSqr();
15254 // B = Y1^2
15255 var b = this.y.redSqr();
15256 // C = B^2
15257 var c = b.redSqr();
15258 // D = 2 * ((X1 + B)^2 - A - C)
15259 var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c);
15260 d = d.redIAdd(d);
15261 // E = 3 * A
15262 var e = a.redAdd(a).redIAdd(a);
15263 // F = E^2
15264 var f = e.redSqr();
15265
15266 // 8 * C
15267 var c8 = c.redIAdd(c);
15268 c8 = c8.redIAdd(c8);
15269 c8 = c8.redIAdd(c8);
15270
15271 // X3 = F - 2 * D
15272 nx = f.redISub(d).redISub(d);
15273 // Y3 = E * (D - X3) - 8 * C
15274 ny = e.redMul(d.redISub(nx)).redISub(c8);
15275 // Z3 = 2 * Y1 * Z1
15276 nz = this.y.redMul(this.z);
15277 nz = nz.redIAdd(nz);
15278 }
15279
15280 return this.curve.jpoint(nx, ny, nz);
15281};
15282
15283JPoint.prototype._threeDbl = function _threeDbl() {
15284 var nx;
15285 var ny;
15286 var nz;
15287 // Z = 1
15288 if (this.zOne) {
15289 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html
15290 // #doubling-mdbl-2007-bl
15291 // 1M + 5S + 15A
15292
15293 // XX = X1^2
15294 var xx = this.x.redSqr();
15295 // YY = Y1^2
15296 var yy = this.y.redSqr();
15297 // YYYY = YY^2
15298 var yyyy = yy.redSqr();
15299 // S = 2 * ((X1 + YY)^2 - XX - YYYY)
15300 var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
15301 s = s.redIAdd(s);
15302 // M = 3 * XX + a
15303 var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a);
15304 // T = M^2 - 2 * S
15305 var t = m.redSqr().redISub(s).redISub(s);
15306 // X3 = T
15307 nx = t;
15308 // Y3 = M * (S - T) - 8 * YYYY
15309 var yyyy8 = yyyy.redIAdd(yyyy);
15310 yyyy8 = yyyy8.redIAdd(yyyy8);
15311 yyyy8 = yyyy8.redIAdd(yyyy8);
15312 ny = m.redMul(s.redISub(t)).redISub(yyyy8);
15313 // Z3 = 2 * Y1
15314 nz = this.y.redAdd(this.y);
15315 } else {
15316 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b
15317 // 3M + 5S
15318
15319 // delta = Z1^2
15320 var delta = this.z.redSqr();
15321 // gamma = Y1^2
15322 var gamma = this.y.redSqr();
15323 // beta = X1 * gamma
15324 var beta = this.x.redMul(gamma);
15325 // alpha = 3 * (X1 - delta) * (X1 + delta)
15326 var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta));
15327 alpha = alpha.redAdd(alpha).redIAdd(alpha);
15328 // X3 = alpha^2 - 8 * beta
15329 var beta4 = beta.redIAdd(beta);
15330 beta4 = beta4.redIAdd(beta4);
15331 var beta8 = beta4.redAdd(beta4);
15332 nx = alpha.redSqr().redISub(beta8);
15333 // Z3 = (Y1 + Z1)^2 - gamma - delta
15334 nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta);
15335 // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2
15336 var ggamma8 = gamma.redSqr();
15337 ggamma8 = ggamma8.redIAdd(ggamma8);
15338 ggamma8 = ggamma8.redIAdd(ggamma8);
15339 ggamma8 = ggamma8.redIAdd(ggamma8);
15340 ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8);
15341 }
15342
15343 return this.curve.jpoint(nx, ny, nz);
15344};
15345
15346JPoint.prototype._dbl = function _dbl() {
15347 var a = this.curve.a;
15348
15349 // 4M + 6S + 10A
15350 var jx = this.x;
15351 var jy = this.y;
15352 var jz = this.z;
15353 var jz4 = jz.redSqr().redSqr();
15354
15355 var jx2 = jx.redSqr();
15356 var jy2 = jy.redSqr();
15357
15358 var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
15359
15360 var jxd4 = jx.redAdd(jx);
15361 jxd4 = jxd4.redIAdd(jxd4);
15362 var t1 = jxd4.redMul(jy2);
15363 var nx = c.redSqr().redISub(t1.redAdd(t1));
15364 var t2 = t1.redISub(nx);
15365
15366 var jyd8 = jy2.redSqr();
15367 jyd8 = jyd8.redIAdd(jyd8);
15368 jyd8 = jyd8.redIAdd(jyd8);
15369 jyd8 = jyd8.redIAdd(jyd8);
15370 var ny = c.redMul(t2).redISub(jyd8);
15371 var nz = jy.redAdd(jy).redMul(jz);
15372
15373 return this.curve.jpoint(nx, ny, nz);
15374};
15375
15376JPoint.prototype.trpl = function trpl() {
15377 if (!this.curve.zeroA)
15378 return this.dbl().add(this);
15379
15380 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl
15381 // 5M + 10S + ...
15382
15383 // XX = X1^2
15384 var xx = this.x.redSqr();
15385 // YY = Y1^2
15386 var yy = this.y.redSqr();
15387 // ZZ = Z1^2
15388 var zz = this.z.redSqr();
15389 // YYYY = YY^2
15390 var yyyy = yy.redSqr();
15391 // M = 3 * XX + a * ZZ2; a = 0
15392 var m = xx.redAdd(xx).redIAdd(xx);
15393 // MM = M^2
15394 var mm = m.redSqr();
15395 // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM
15396 var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
15397 e = e.redIAdd(e);
15398 e = e.redAdd(e).redIAdd(e);
15399 e = e.redISub(mm);
15400 // EE = E^2
15401 var ee = e.redSqr();
15402 // T = 16*YYYY
15403 var t = yyyy.redIAdd(yyyy);
15404 t = t.redIAdd(t);
15405 t = t.redIAdd(t);
15406 t = t.redIAdd(t);
15407 // U = (M + E)^2 - MM - EE - T
15408 var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t);
15409 // X3 = 4 * (X1 * EE - 4 * YY * U)
15410 var yyu4 = yy.redMul(u);
15411 yyu4 = yyu4.redIAdd(yyu4);
15412 yyu4 = yyu4.redIAdd(yyu4);
15413 var nx = this.x.redMul(ee).redISub(yyu4);
15414 nx = nx.redIAdd(nx);
15415 nx = nx.redIAdd(nx);
15416 // Y3 = 8 * Y1 * (U * (T - U) - E * EE)
15417 var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee)));
15418 ny = ny.redIAdd(ny);
15419 ny = ny.redIAdd(ny);
15420 ny = ny.redIAdd(ny);
15421 // Z3 = (Z1 + E)^2 - ZZ - EE
15422 var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee);
15423
15424 return this.curve.jpoint(nx, ny, nz);
15425};
15426
15427JPoint.prototype.mul = function mul(k, kbase) {
15428 k = new BN(k, kbase);
15429
15430 return this.curve._wnafMul(this, k);
15431};
15432
15433JPoint.prototype.eq = function eq(p) {
15434 if (p.type === 'affine')
15435 return this.eq(p.toJ());
15436
15437 if (this === p)
15438 return true;
15439
15440 // x1 * z2^2 == x2 * z1^2
15441 var z2 = this.z.redSqr();
15442 var pz2 = p.z.redSqr();
15443 if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0)
15444 return false;
15445
15446 // y1 * z2^3 == y2 * z1^3
15447 var z3 = z2.redMul(this.z);
15448 var pz3 = pz2.redMul(p.z);
15449 return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0;
15450};
15451
15452JPoint.prototype.eqXToP = function eqXToP(x) {
15453 var zs = this.z.redSqr();
15454 var rx = x.toRed(this.curve.red).redMul(zs);
15455 if (this.x.cmp(rx) === 0)
15456 return true;
15457
15458 var xc = x.clone();
15459 var t = this.curve.redN.redMul(zs);
15460 for (;;) {
15461 xc.iadd(this.curve.n);
15462 if (xc.cmp(this.curve.p) >= 0)
15463 return false;
15464
15465 rx.redIAdd(t);
15466 if (this.x.cmp(rx) === 0)
15467 return true;
15468 }
15469 return false;
15470};
15471
15472JPoint.prototype.inspect = function inspect() {
15473 if (this.isInfinity())
15474 return '<EC JPoint Infinity>';
15475 return '<EC JPoint x: ' + this.x.toString(16, 2) +
15476 ' y: ' + this.y.toString(16, 2) +
15477 ' z: ' + this.z.toString(16, 2) + '>';
15478};
15479
15480JPoint.prototype.isInfinity = function isInfinity() {
15481 // XXX This code assumes that zero is always zero in red
15482 return this.z.cmpn(0) === 0;
15483};
15484
15485},{"../../elliptic":226,"../curve":229,"bn.js":43,"inherits":260}],232:[function(require,module,exports){
15486'use strict';
15487
15488var curves = exports;
15489
15490var hash = require('hash.js');
15491var elliptic = require('../elliptic');
15492
15493var assert = elliptic.utils.assert;
15494
15495function PresetCurve(options) {
15496 if (options.type === 'short')
15497 this.curve = new elliptic.curve.short(options);
15498 else if (options.type === 'edwards')
15499 this.curve = new elliptic.curve.edwards(options);
15500 else
15501 this.curve = new elliptic.curve.mont(options);
15502 this.g = this.curve.g;
15503 this.n = this.curve.n;
15504 this.hash = options.hash;
15505
15506 assert(this.g.validate(), 'Invalid curve');
15507 assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O');
15508}
15509curves.PresetCurve = PresetCurve;
15510
15511function defineCurve(name, options) {
15512 Object.defineProperty(curves, name, {
15513 configurable: true,
15514 enumerable: true,
15515 get: function() {
15516 var curve = new PresetCurve(options);
15517 Object.defineProperty(curves, name, {
15518 configurable: true,
15519 enumerable: true,
15520 value: curve
15521 });
15522 return curve;
15523 }
15524 });
15525}
15526
15527defineCurve('p192', {
15528 type: 'short',
15529 prime: 'p192',
15530 p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff',
15531 a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc',
15532 b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1',
15533 n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831',
15534 hash: hash.sha256,
15535 gRed: false,
15536 g: [
15537 '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012',
15538 '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811'
15539 ]
15540});
15541
15542defineCurve('p224', {
15543 type: 'short',
15544 prime: 'p224',
15545 p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001',
15546 a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe',
15547 b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4',
15548 n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d',
15549 hash: hash.sha256,
15550 gRed: false,
15551 g: [
15552 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21',
15553 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34'
15554 ]
15555});
15556
15557defineCurve('p256', {
15558 type: 'short',
15559 prime: null,
15560 p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff',
15561 a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc',
15562 b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b',
15563 n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551',
15564 hash: hash.sha256,
15565 gRed: false,
15566 g: [
15567 '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296',
15568 '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5'
15569 ]
15570});
15571
15572defineCurve('p384', {
15573 type: 'short',
15574 prime: null,
15575 p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
15576 'fffffffe ffffffff 00000000 00000000 ffffffff',
15577 a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
15578 'fffffffe ffffffff 00000000 00000000 fffffffc',
15579 b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' +
15580 '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef',
15581 n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' +
15582 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973',
15583 hash: hash.sha384,
15584 gRed: false,
15585 g: [
15586 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' +
15587 '5502f25d bf55296c 3a545e38 72760ab7',
15588 '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' +
15589 '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f'
15590 ]
15591});
15592
15593defineCurve('p521', {
15594 type: 'short',
15595 prime: null,
15596 p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
15597 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
15598 'ffffffff ffffffff ffffffff ffffffff ffffffff',
15599 a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
15600 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
15601 'ffffffff ffffffff ffffffff ffffffff fffffffc',
15602 b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' +
15603 '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' +
15604 '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00',
15605 n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
15606 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' +
15607 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409',
15608 hash: hash.sha512,
15609 gRed: false,
15610 g: [
15611 '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' +
15612 '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' +
15613 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66',
15614 '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' +
15615 '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' +
15616 '3fad0761 353c7086 a272c240 88be9476 9fd16650'
15617 ]
15618});
15619
15620defineCurve('curve25519', {
15621 type: 'mont',
15622 prime: 'p25519',
15623 p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
15624 a: '76d06',
15625 b: '1',
15626 n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
15627 hash: hash.sha256,
15628 gRed: false,
15629 g: [
15630 '9'
15631 ]
15632});
15633
15634defineCurve('ed25519', {
15635 type: 'edwards',
15636 prime: 'p25519',
15637 p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
15638 a: '-1',
15639 c: '1',
15640 // -121665 * (121666^(-1)) (mod P)
15641 d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3',
15642 n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
15643 hash: hash.sha256,
15644 gRed: false,
15645 g: [
15646 '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a',
15647
15648 // 4/5
15649 '6666666666666666666666666666666666666666666666666666666666666658'
15650 ]
15651});
15652
15653var pre;
15654try {
15655 pre = require('./precomputed/secp256k1');
15656} catch (e) {
15657 pre = undefined;
15658}
15659
15660defineCurve('secp256k1', {
15661 type: 'short',
15662 prime: 'k256',
15663 p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f',
15664 a: '0',
15665 b: '7',
15666 n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141',
15667 h: '1',
15668 hash: hash.sha256,
15669
15670 // Precomputed endomorphism
15671 beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee',
15672 lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72',
15673 basis: [
15674 {
15675 a: '3086d221a7d46bcde86c90e49284eb15',
15676 b: '-e4437ed6010e88286f547fa90abfe4c3'
15677 },
15678 {
15679 a: '114ca50f7a8e2f3f657c1108d9d44cfd8',
15680 b: '3086d221a7d46bcde86c90e49284eb15'
15681 }
15682 ],
15683
15684 gRed: false,
15685 g: [
15686 '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
15687 '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8',
15688 pre
15689 ]
15690});
15691
15692},{"../elliptic":226,"./precomputed/secp256k1":239,"hash.js":245}],233:[function(require,module,exports){
15693'use strict';
15694
15695var BN = require('bn.js');
15696var HmacDRBG = require('hmac-drbg');
15697var elliptic = require('../../elliptic');
15698var utils = elliptic.utils;
15699var assert = utils.assert;
15700
15701var KeyPair = require('./key');
15702var Signature = require('./signature');
15703
15704function EC(options) {
15705 if (!(this instanceof EC))
15706 return new EC(options);
15707
15708 // Shortcut `elliptic.ec(curve-name)`
15709 if (typeof options === 'string') {
15710 assert(elliptic.curves.hasOwnProperty(options), 'Unknown curve ' + options);
15711
15712 options = elliptic.curves[options];
15713 }
15714
15715 // Shortcut for `elliptic.ec(elliptic.curves.curveName)`
15716 if (options instanceof elliptic.curves.PresetCurve)
15717 options = { curve: options };
15718
15719 this.curve = options.curve.curve;
15720 this.n = this.curve.n;
15721 this.nh = this.n.ushrn(1);
15722 this.g = this.curve.g;
15723
15724 // Point on curve
15725 this.g = options.curve.g;
15726 this.g.precompute(options.curve.n.bitLength() + 1);
15727
15728 // Hash for function for DRBG
15729 this.hash = options.hash || options.curve.hash;
15730}
15731module.exports = EC;
15732
15733EC.prototype.keyPair = function keyPair(options) {
15734 return new KeyPair(this, options);
15735};
15736
15737EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) {
15738 return KeyPair.fromPrivate(this, priv, enc);
15739};
15740
15741EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) {
15742 return KeyPair.fromPublic(this, pub, enc);
15743};
15744
15745EC.prototype.genKeyPair = function genKeyPair(options) {
15746 if (!options)
15747 options = {};
15748
15749 // Instantiate Hmac_DRBG
15750 var drbg = new HmacDRBG({
15751 hash: this.hash,
15752 pers: options.pers,
15753 persEnc: options.persEnc || 'utf8',
15754 entropy: options.entropy || elliptic.rand(this.hash.hmacStrength),
15755 entropyEnc: options.entropy && options.entropyEnc || 'utf8',
15756 nonce: this.n.toArray()
15757 });
15758
15759 var bytes = this.n.byteLength();
15760 var ns2 = this.n.sub(new BN(2));
15761 do {
15762 var priv = new BN(drbg.generate(bytes));
15763 if (priv.cmp(ns2) > 0)
15764 continue;
15765
15766 priv.iaddn(1);
15767 return this.keyFromPrivate(priv);
15768 } while (true);
15769};
15770
15771EC.prototype._truncateToN = function truncateToN(msg, truncOnly) {
15772 var delta = msg.byteLength() * 8 - this.n.bitLength();
15773 if (delta > 0)
15774 msg = msg.ushrn(delta);
15775 if (!truncOnly && msg.cmp(this.n) >= 0)
15776 return msg.sub(this.n);
15777 else
15778 return msg;
15779};
15780
15781EC.prototype.sign = function sign(msg, key, enc, options) {
15782 if (typeof enc === 'object') {
15783 options = enc;
15784 enc = null;
15785 }
15786 if (!options)
15787 options = {};
15788
15789 key = this.keyFromPrivate(key, enc);
15790 msg = this._truncateToN(new BN(msg, 16));
15791
15792 // Zero-extend key to provide enough entropy
15793 var bytes = this.n.byteLength();
15794 var bkey = key.getPrivate().toArray('be', bytes);
15795
15796 // Zero-extend nonce to have the same byte size as N
15797 var nonce = msg.toArray('be', bytes);
15798
15799 // Instantiate Hmac_DRBG
15800 var drbg = new HmacDRBG({
15801 hash: this.hash,
15802 entropy: bkey,
15803 nonce: nonce,
15804 pers: options.pers,
15805 persEnc: options.persEnc || 'utf8'
15806 });
15807
15808 // Number of bytes to generate
15809 var ns1 = this.n.sub(new BN(1));
15810
15811 for (var iter = 0; true; iter++) {
15812 var k = options.k ?
15813 options.k(iter) :
15814 new BN(drbg.generate(this.n.byteLength()));
15815 k = this._truncateToN(k, true);
15816 if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0)
15817 continue;
15818
15819 var kp = this.g.mul(k);
15820 if (kp.isInfinity())
15821 continue;
15822
15823 var kpX = kp.getX();
15824 var r = kpX.umod(this.n);
15825 if (r.cmpn(0) === 0)
15826 continue;
15827
15828 var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg));
15829 s = s.umod(this.n);
15830 if (s.cmpn(0) === 0)
15831 continue;
15832
15833 var recoveryParam = (kp.getY().isOdd() ? 1 : 0) |
15834 (kpX.cmp(r) !== 0 ? 2 : 0);
15835
15836 // Use complement of `s`, if it is > `n / 2`
15837 if (options.canonical && s.cmp(this.nh) > 0) {
15838 s = this.n.sub(s);
15839 recoveryParam ^= 1;
15840 }
15841
15842 return new Signature({ r: r, s: s, recoveryParam: recoveryParam });
15843 }
15844};
15845
15846EC.prototype.verify = function verify(msg, signature, key, enc) {
15847 msg = this._truncateToN(new BN(msg, 16));
15848 key = this.keyFromPublic(key, enc);
15849 signature = new Signature(signature, 'hex');
15850
15851 // Perform primitive values validation
15852 var r = signature.r;
15853 var s = signature.s;
15854 if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0)
15855 return false;
15856 if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0)
15857 return false;
15858
15859 // Validate signature
15860 var sinv = s.invm(this.n);
15861 var u1 = sinv.mul(msg).umod(this.n);
15862 var u2 = sinv.mul(r).umod(this.n);
15863
15864 if (!this.curve._maxwellTrick) {
15865 var p = this.g.mulAdd(u1, key.getPublic(), u2);
15866 if (p.isInfinity())
15867 return false;
15868
15869 return p.getX().umod(this.n).cmp(r) === 0;
15870 }
15871
15872 // NOTE: Greg Maxwell's trick, inspired by:
15873 // https://git.io/vad3K
15874
15875 var p = this.g.jmulAdd(u1, key.getPublic(), u2);
15876 if (p.isInfinity())
15877 return false;
15878
15879 // Compare `p.x` of Jacobian point with `r`,
15880 // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the
15881 // inverse of `p.z^2`
15882 return p.eqXToP(r);
15883};
15884
15885EC.prototype.recoverPubKey = function(msg, signature, j, enc) {
15886 assert((3 & j) === j, 'The recovery param is more than two bits');
15887 signature = new Signature(signature, enc);
15888
15889 var n = this.n;
15890 var e = new BN(msg);
15891 var r = signature.r;
15892 var s = signature.s;
15893
15894 // A set LSB signifies that the y-coordinate is odd
15895 var isYOdd = j & 1;
15896 var isSecondKey = j >> 1;
15897 if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey)
15898 throw new Error('Unable to find sencond key candinate');
15899
15900 // 1.1. Let x = r + jn.
15901 if (isSecondKey)
15902 r = this.curve.pointFromX(r.add(this.curve.n), isYOdd);
15903 else
15904 r = this.curve.pointFromX(r, isYOdd);
15905
15906 var rInv = signature.r.invm(n);
15907 var s1 = n.sub(e).mul(rInv).umod(n);
15908 var s2 = s.mul(rInv).umod(n);
15909
15910 // 1.6.1 Compute Q = r^-1 (sR - eG)
15911 // Q = r^-1 (sR + -eG)
15912 return this.g.mulAdd(s1, r, s2);
15913};
15914
15915EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) {
15916 signature = new Signature(signature, enc);
15917 if (signature.recoveryParam !== null)
15918 return signature.recoveryParam;
15919
15920 for (var i = 0; i < 4; i++) {
15921 var Qprime;
15922 try {
15923 Qprime = this.recoverPubKey(e, signature, i);
15924 } catch (e) {
15925 continue;
15926 }
15927
15928 if (Qprime.eq(Q))
15929 return i;
15930 }
15931 throw new Error('Unable to find valid recovery factor');
15932};
15933
15934},{"../../elliptic":226,"./key":234,"./signature":235,"bn.js":43,"hmac-drbg":257}],234:[function(require,module,exports){
15935'use strict';
15936
15937var BN = require('bn.js');
15938var elliptic = require('../../elliptic');
15939var utils = elliptic.utils;
15940var assert = utils.assert;
15941
15942function KeyPair(ec, options) {
15943 this.ec = ec;
15944 this.priv = null;
15945 this.pub = null;
15946
15947 // KeyPair(ec, { priv: ..., pub: ... })
15948 if (options.priv)
15949 this._importPrivate(options.priv, options.privEnc);
15950 if (options.pub)
15951 this._importPublic(options.pub, options.pubEnc);
15952}
15953module.exports = KeyPair;
15954
15955KeyPair.fromPublic = function fromPublic(ec, pub, enc) {
15956 if (pub instanceof KeyPair)
15957 return pub;
15958
15959 return new KeyPair(ec, {
15960 pub: pub,
15961 pubEnc: enc
15962 });
15963};
15964
15965KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) {
15966 if (priv instanceof KeyPair)
15967 return priv;
15968
15969 return new KeyPair(ec, {
15970 priv: priv,
15971 privEnc: enc
15972 });
15973};
15974
15975KeyPair.prototype.validate = function validate() {
15976 var pub = this.getPublic();
15977
15978 if (pub.isInfinity())
15979 return { result: false, reason: 'Invalid public key' };
15980 if (!pub.validate())
15981 return { result: false, reason: 'Public key is not a point' };
15982 if (!pub.mul(this.ec.curve.n).isInfinity())
15983 return { result: false, reason: 'Public key * N != O' };
15984
15985 return { result: true, reason: null };
15986};
15987
15988KeyPair.prototype.getPublic = function getPublic(compact, enc) {
15989 // compact is optional argument
15990 if (typeof compact === 'string') {
15991 enc = compact;
15992 compact = null;
15993 }
15994
15995 if (!this.pub)
15996 this.pub = this.ec.g.mul(this.priv);
15997
15998 if (!enc)
15999 return this.pub;
16000
16001 return this.pub.encode(enc, compact);
16002};
16003
16004KeyPair.prototype.getPrivate = function getPrivate(enc) {
16005 if (enc === 'hex')
16006 return this.priv.toString(16, 2);
16007 else
16008 return this.priv;
16009};
16010
16011KeyPair.prototype._importPrivate = function _importPrivate(key, enc) {
16012 this.priv = new BN(key, enc || 16);
16013
16014 // Ensure that the priv won't be bigger than n, otherwise we may fail
16015 // in fixed multiplication method
16016 this.priv = this.priv.umod(this.ec.curve.n);
16017};
16018
16019KeyPair.prototype._importPublic = function _importPublic(key, enc) {
16020 if (key.x || key.y) {
16021 // Montgomery points only have an `x` coordinate.
16022 // Weierstrass/Edwards points on the other hand have both `x` and
16023 // `y` coordinates.
16024 if (this.ec.curve.type === 'mont') {
16025 assert(key.x, 'Need x coordinate');
16026 } else if (this.ec.curve.type === 'short' ||
16027 this.ec.curve.type === 'edwards') {
16028 assert(key.x && key.y, 'Need both x and y coordinate');
16029 }
16030 this.pub = this.ec.curve.point(key.x, key.y);
16031 return;
16032 }
16033 this.pub = this.ec.curve.decodePoint(key, enc);
16034};
16035
16036// ECDH
16037KeyPair.prototype.derive = function derive(pub) {
16038 return pub.mul(this.priv).getX();
16039};
16040
16041// ECDSA
16042KeyPair.prototype.sign = function sign(msg, enc, options) {
16043 return this.ec.sign(msg, this, enc, options);
16044};
16045
16046KeyPair.prototype.verify = function verify(msg, signature) {
16047 return this.ec.verify(msg, signature, this);
16048};
16049
16050KeyPair.prototype.inspect = function inspect() {
16051 return '<Key priv: ' + (this.priv && this.priv.toString(16, 2)) +
16052 ' pub: ' + (this.pub && this.pub.inspect()) + ' >';
16053};
16054
16055},{"../../elliptic":226,"bn.js":43}],235:[function(require,module,exports){
16056'use strict';
16057
16058var BN = require('bn.js');
16059
16060var elliptic = require('../../elliptic');
16061var utils = elliptic.utils;
16062var assert = utils.assert;
16063
16064function Signature(options, enc) {
16065 if (options instanceof Signature)
16066 return options;
16067
16068 if (this._importDER(options, enc))
16069 return;
16070
16071 assert(options.r && options.s, 'Signature without r or s');
16072 this.r = new BN(options.r, 16);
16073 this.s = new BN(options.s, 16);
16074 if (options.recoveryParam === undefined)
16075 this.recoveryParam = null;
16076 else
16077 this.recoveryParam = options.recoveryParam;
16078}
16079module.exports = Signature;
16080
16081function Position() {
16082 this.place = 0;
16083}
16084
16085function getLength(buf, p) {
16086 var initial = buf[p.place++];
16087 if (!(initial & 0x80)) {
16088 return initial;
16089 }
16090 var octetLen = initial & 0xf;
16091 var val = 0;
16092 for (var i = 0, off = p.place; i < octetLen; i++, off++) {
16093 val <<= 8;
16094 val |= buf[off];
16095 }
16096 p.place = off;
16097 return val;
16098}
16099
16100function rmPadding(buf) {
16101 var i = 0;
16102 var len = buf.length - 1;
16103 while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) {
16104 i++;
16105 }
16106 if (i === 0) {
16107 return buf;
16108 }
16109 return buf.slice(i);
16110}
16111
16112Signature.prototype._importDER = function _importDER(data, enc) {
16113 data = utils.toArray(data, enc);
16114 var p = new Position();
16115 if (data[p.place++] !== 0x30) {
16116 return false;
16117 }
16118 var len = getLength(data, p);
16119 if ((len + p.place) !== data.length) {
16120 return false;
16121 }
16122 if (data[p.place++] !== 0x02) {
16123 return false;
16124 }
16125 var rlen = getLength(data, p);
16126 var r = data.slice(p.place, rlen + p.place);
16127 p.place += rlen;
16128 if (data[p.place++] !== 0x02) {
16129 return false;
16130 }
16131 var slen = getLength(data, p);
16132 if (data.length !== slen + p.place) {
16133 return false;
16134 }
16135 var s = data.slice(p.place, slen + p.place);
16136 if (r[0] === 0 && (r[1] & 0x80)) {
16137 r = r.slice(1);
16138 }
16139 if (s[0] === 0 && (s[1] & 0x80)) {
16140 s = s.slice(1);
16141 }
16142
16143 this.r = new BN(r);
16144 this.s = new BN(s);
16145 this.recoveryParam = null;
16146
16147 return true;
16148};
16149
16150function constructLength(arr, len) {
16151 if (len < 0x80) {
16152 arr.push(len);
16153 return;
16154 }
16155 var octets = 1 + (Math.log(len) / Math.LN2 >>> 3);
16156 arr.push(octets | 0x80);
16157 while (--octets) {
16158 arr.push((len >>> (octets << 3)) & 0xff);
16159 }
16160 arr.push(len);
16161}
16162
16163Signature.prototype.toDER = function toDER(enc) {
16164 var r = this.r.toArray();
16165 var s = this.s.toArray();
16166
16167 // Pad values
16168 if (r[0] & 0x80)
16169 r = [ 0 ].concat(r);
16170 // Pad values
16171 if (s[0] & 0x80)
16172 s = [ 0 ].concat(s);
16173
16174 r = rmPadding(r);
16175 s = rmPadding(s);
16176
16177 while (!s[0] && !(s[1] & 0x80)) {
16178 s = s.slice(1);
16179 }
16180 var arr = [ 0x02 ];
16181 constructLength(arr, r.length);
16182 arr = arr.concat(r);
16183 arr.push(0x02);
16184 constructLength(arr, s.length);
16185 var backHalf = arr.concat(s);
16186 var res = [ 0x30 ];
16187 constructLength(res, backHalf.length);
16188 res = res.concat(backHalf);
16189 return utils.encode(res, enc);
16190};
16191
16192},{"../../elliptic":226,"bn.js":43}],236:[function(require,module,exports){
16193'use strict';
16194
16195var hash = require('hash.js');
16196var elliptic = require('../../elliptic');
16197var utils = elliptic.utils;
16198var assert = utils.assert;
16199var parseBytes = utils.parseBytes;
16200var KeyPair = require('./key');
16201var Signature = require('./signature');
16202
16203function EDDSA(curve) {
16204 assert(curve === 'ed25519', 'only tested with ed25519 so far');
16205
16206 if (!(this instanceof EDDSA))
16207 return new EDDSA(curve);
16208
16209 var curve = elliptic.curves[curve].curve;
16210 this.curve = curve;
16211 this.g = curve.g;
16212 this.g.precompute(curve.n.bitLength() + 1);
16213
16214 this.pointClass = curve.point().constructor;
16215 this.encodingLength = Math.ceil(curve.n.bitLength() / 8);
16216 this.hash = hash.sha512;
16217}
16218
16219module.exports = EDDSA;
16220
16221/**
16222* @param {Array|String} message - message bytes
16223* @param {Array|String|KeyPair} secret - secret bytes or a keypair
16224* @returns {Signature} - signature
16225*/
16226EDDSA.prototype.sign = function sign(message, secret) {
16227 message = parseBytes(message);
16228 var key = this.keyFromSecret(secret);
16229 var r = this.hashInt(key.messagePrefix(), message);
16230 var R = this.g.mul(r);
16231 var Rencoded = this.encodePoint(R);
16232 var s_ = this.hashInt(Rencoded, key.pubBytes(), message)
16233 .mul(key.priv());
16234 var S = r.add(s_).umod(this.curve.n);
16235 return this.makeSignature({ R: R, S: S, Rencoded: Rencoded });
16236};
16237
16238/**
16239* @param {Array} message - message bytes
16240* @param {Array|String|Signature} sig - sig bytes
16241* @param {Array|String|Point|KeyPair} pub - public key
16242* @returns {Boolean} - true if public key matches sig of message
16243*/
16244EDDSA.prototype.verify = function verify(message, sig, pub) {
16245 message = parseBytes(message);
16246 sig = this.makeSignature(sig);
16247 var key = this.keyFromPublic(pub);
16248 var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message);
16249 var SG = this.g.mul(sig.S());
16250 var RplusAh = sig.R().add(key.pub().mul(h));
16251 return RplusAh.eq(SG);
16252};
16253
16254EDDSA.prototype.hashInt = function hashInt() {
16255 var hash = this.hash();
16256 for (var i = 0; i < arguments.length; i++)
16257 hash.update(arguments[i]);
16258 return utils.intFromLE(hash.digest()).umod(this.curve.n);
16259};
16260
16261EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) {
16262 return KeyPair.fromPublic(this, pub);
16263};
16264
16265EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) {
16266 return KeyPair.fromSecret(this, secret);
16267};
16268
16269EDDSA.prototype.makeSignature = function makeSignature(sig) {
16270 if (sig instanceof Signature)
16271 return sig;
16272 return new Signature(this, sig);
16273};
16274
16275/**
16276* * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2
16277*
16278* EDDSA defines methods for encoding and decoding points and integers. These are
16279* helper convenience methods, that pass along to utility functions implied
16280* parameters.
16281*
16282*/
16283EDDSA.prototype.encodePoint = function encodePoint(point) {
16284 var enc = point.getY().toArray('le', this.encodingLength);
16285 enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0;
16286 return enc;
16287};
16288
16289EDDSA.prototype.decodePoint = function decodePoint(bytes) {
16290 bytes = utils.parseBytes(bytes);
16291
16292 var lastIx = bytes.length - 1;
16293 var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80);
16294 var xIsOdd = (bytes[lastIx] & 0x80) !== 0;
16295
16296 var y = utils.intFromLE(normed);
16297 return this.curve.pointFromY(y, xIsOdd);
16298};
16299
16300EDDSA.prototype.encodeInt = function encodeInt(num) {
16301 return num.toArray('le', this.encodingLength);
16302};
16303
16304EDDSA.prototype.decodeInt = function decodeInt(bytes) {
16305 return utils.intFromLE(bytes);
16306};
16307
16308EDDSA.prototype.isPoint = function isPoint(val) {
16309 return val instanceof this.pointClass;
16310};
16311
16312},{"../../elliptic":226,"./key":237,"./signature":238,"hash.js":245}],237:[function(require,module,exports){
16313'use strict';
16314
16315var elliptic = require('../../elliptic');
16316var utils = elliptic.utils;
16317var assert = utils.assert;
16318var parseBytes = utils.parseBytes;
16319var cachedProperty = utils.cachedProperty;
16320
16321/**
16322* @param {EDDSA} eddsa - instance
16323* @param {Object} params - public/private key parameters
16324*
16325* @param {Array<Byte>} [params.secret] - secret seed bytes
16326* @param {Point} [params.pub] - public key point (aka `A` in eddsa terms)
16327* @param {Array<Byte>} [params.pub] - public key point encoded as bytes
16328*
16329*/
16330function KeyPair(eddsa, params) {
16331 this.eddsa = eddsa;
16332 this._secret = parseBytes(params.secret);
16333 if (eddsa.isPoint(params.pub))
16334 this._pub = params.pub;
16335 else
16336 this._pubBytes = parseBytes(params.pub);
16337}
16338
16339KeyPair.fromPublic = function fromPublic(eddsa, pub) {
16340 if (pub instanceof KeyPair)
16341 return pub;
16342 return new KeyPair(eddsa, { pub: pub });
16343};
16344
16345KeyPair.fromSecret = function fromSecret(eddsa, secret) {
16346 if (secret instanceof KeyPair)
16347 return secret;
16348 return new KeyPair(eddsa, { secret: secret });
16349};
16350
16351KeyPair.prototype.secret = function secret() {
16352 return this._secret;
16353};
16354
16355cachedProperty(KeyPair, 'pubBytes', function pubBytes() {
16356 return this.eddsa.encodePoint(this.pub());
16357});
16358
16359cachedProperty(KeyPair, 'pub', function pub() {
16360 if (this._pubBytes)
16361 return this.eddsa.decodePoint(this._pubBytes);
16362 return this.eddsa.g.mul(this.priv());
16363});
16364
16365cachedProperty(KeyPair, 'privBytes', function privBytes() {
16366 var eddsa = this.eddsa;
16367 var hash = this.hash();
16368 var lastIx = eddsa.encodingLength - 1;
16369
16370 var a = hash.slice(0, eddsa.encodingLength);
16371 a[0] &= 248;
16372 a[lastIx] &= 127;
16373 a[lastIx] |= 64;
16374
16375 return a;
16376});
16377
16378cachedProperty(KeyPair, 'priv', function priv() {
16379 return this.eddsa.decodeInt(this.privBytes());
16380});
16381
16382cachedProperty(KeyPair, 'hash', function hash() {
16383 return this.eddsa.hash().update(this.secret()).digest();
16384});
16385
16386cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() {
16387 return this.hash().slice(this.eddsa.encodingLength);
16388});
16389
16390KeyPair.prototype.sign = function sign(message) {
16391 assert(this._secret, 'KeyPair can only verify');
16392 return this.eddsa.sign(message, this);
16393};
16394
16395KeyPair.prototype.verify = function verify(message, sig) {
16396 return this.eddsa.verify(message, sig, this);
16397};
16398
16399KeyPair.prototype.getSecret = function getSecret(enc) {
16400 assert(this._secret, 'KeyPair is public only');
16401 return utils.encode(this.secret(), enc);
16402};
16403
16404KeyPair.prototype.getPublic = function getPublic(enc) {
16405 return utils.encode(this.pubBytes(), enc);
16406};
16407
16408module.exports = KeyPair;
16409
16410},{"../../elliptic":226}],238:[function(require,module,exports){
16411'use strict';
16412
16413var BN = require('bn.js');
16414var elliptic = require('../../elliptic');
16415var utils = elliptic.utils;
16416var assert = utils.assert;
16417var cachedProperty = utils.cachedProperty;
16418var parseBytes = utils.parseBytes;
16419
16420/**
16421* @param {EDDSA} eddsa - eddsa instance
16422* @param {Array<Bytes>|Object} sig -
16423* @param {Array<Bytes>|Point} [sig.R] - R point as Point or bytes
16424* @param {Array<Bytes>|bn} [sig.S] - S scalar as bn or bytes
16425* @param {Array<Bytes>} [sig.Rencoded] - R point encoded
16426* @param {Array<Bytes>} [sig.Sencoded] - S scalar encoded
16427*/
16428function Signature(eddsa, sig) {
16429 this.eddsa = eddsa;
16430
16431 if (typeof sig !== 'object')
16432 sig = parseBytes(sig);
16433
16434 if (Array.isArray(sig)) {
16435 sig = {
16436 R: sig.slice(0, eddsa.encodingLength),
16437 S: sig.slice(eddsa.encodingLength)
16438 };
16439 }
16440
16441 assert(sig.R && sig.S, 'Signature without R or S');
16442
16443 if (eddsa.isPoint(sig.R))
16444 this._R = sig.R;
16445 if (sig.S instanceof BN)
16446 this._S = sig.S;
16447
16448 this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded;
16449 this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded;
16450}
16451
16452cachedProperty(Signature, 'S', function S() {
16453 return this.eddsa.decodeInt(this.Sencoded());
16454});
16455
16456cachedProperty(Signature, 'R', function R() {
16457 return this.eddsa.decodePoint(this.Rencoded());
16458});
16459
16460cachedProperty(Signature, 'Rencoded', function Rencoded() {
16461 return this.eddsa.encodePoint(this.R());
16462});
16463
16464cachedProperty(Signature, 'Sencoded', function Sencoded() {
16465 return this.eddsa.encodeInt(this.S());
16466});
16467
16468Signature.prototype.toBytes = function toBytes() {
16469 return this.Rencoded().concat(this.Sencoded());
16470};
16471
16472Signature.prototype.toHex = function toHex() {
16473 return utils.encode(this.toBytes(), 'hex').toUpperCase();
16474};
16475
16476module.exports = Signature;
16477
16478},{"../../elliptic":226,"bn.js":43}],239:[function(require,module,exports){
16479module.exports = {
16480 doubles: {
16481 step: 4,
16482 points: [
16483 [
16484 'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a',
16485 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821'
16486 ],
16487 [
16488 '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508',
16489 '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf'
16490 ],
16491 [
16492 '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739',
16493 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695'
16494 ],
16495 [
16496 '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640',
16497 '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9'
16498 ],
16499 [
16500 '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c',
16501 '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36'
16502 ],
16503 [
16504 '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda',
16505 '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f'
16506 ],
16507 [
16508 'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa',
16509 '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999'
16510 ],
16511 [
16512 '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0',
16513 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09'
16514 ],
16515 [
16516 'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d',
16517 '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d'
16518 ],
16519 [
16520 'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d',
16521 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088'
16522 ],
16523 [
16524 'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1',
16525 '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d'
16526 ],
16527 [
16528 '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0',
16529 '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8'
16530 ],
16531 [
16532 '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047',
16533 '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a'
16534 ],
16535 [
16536 '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862',
16537 '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453'
16538 ],
16539 [
16540 '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7',
16541 '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160'
16542 ],
16543 [
16544 '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd',
16545 '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0'
16546 ],
16547 [
16548 '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83',
16549 '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6'
16550 ],
16551 [
16552 '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a',
16553 '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589'
16554 ],
16555 [
16556 '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8',
16557 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17'
16558 ],
16559 [
16560 'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d',
16561 '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda'
16562 ],
16563 [
16564 'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725',
16565 '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd'
16566 ],
16567 [
16568 '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754',
16569 '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2'
16570 ],
16571 [
16572 '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c',
16573 '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6'
16574 ],
16575 [
16576 'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6',
16577 '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f'
16578 ],
16579 [
16580 '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39',
16581 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01'
16582 ],
16583 [
16584 'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891',
16585 '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3'
16586 ],
16587 [
16588 'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b',
16589 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f'
16590 ],
16591 [
16592 'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03',
16593 '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7'
16594 ],
16595 [
16596 'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d',
16597 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78'
16598 ],
16599 [
16600 'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070',
16601 '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1'
16602 ],
16603 [
16604 '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4',
16605 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150'
16606 ],
16607 [
16608 '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da',
16609 '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82'
16610 ],
16611 [
16612 'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11',
16613 '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc'
16614 ],
16615 [
16616 '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e',
16617 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b'
16618 ],
16619 [
16620 'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41',
16621 '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51'
16622 ],
16623 [
16624 'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef',
16625 '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45'
16626 ],
16627 [
16628 'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8',
16629 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120'
16630 ],
16631 [
16632 '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d',
16633 '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84'
16634 ],
16635 [
16636 '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96',
16637 '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d'
16638 ],
16639 [
16640 '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd',
16641 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d'
16642 ],
16643 [
16644 '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5',
16645 '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8'
16646 ],
16647 [
16648 'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266',
16649 '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8'
16650 ],
16651 [
16652 '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71',
16653 '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac'
16654 ],
16655 [
16656 '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac',
16657 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f'
16658 ],
16659 [
16660 '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751',
16661 '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962'
16662 ],
16663 [
16664 'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e',
16665 '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907'
16666 ],
16667 [
16668 '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241',
16669 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec'
16670 ],
16671 [
16672 'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3',
16673 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d'
16674 ],
16675 [
16676 'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f',
16677 '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414'
16678 ],
16679 [
16680 '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19',
16681 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd'
16682 ],
16683 [
16684 '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be',
16685 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0'
16686 ],
16687 [
16688 'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9',
16689 '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811'
16690 ],
16691 [
16692 'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2',
16693 '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1'
16694 ],
16695 [
16696 'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13',
16697 '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c'
16698 ],
16699 [
16700 '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c',
16701 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73'
16702 ],
16703 [
16704 '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba',
16705 '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd'
16706 ],
16707 [
16708 'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151',
16709 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405'
16710 ],
16711 [
16712 '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073',
16713 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589'
16714 ],
16715 [
16716 '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458',
16717 '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e'
16718 ],
16719 [
16720 '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b',
16721 '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27'
16722 ],
16723 [
16724 'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366',
16725 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1'
16726 ],
16727 [
16728 '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa',
16729 '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482'
16730 ],
16731 [
16732 '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0',
16733 '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945'
16734 ],
16735 [
16736 'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787',
16737 '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573'
16738 ],
16739 [
16740 'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e',
16741 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82'
16742 ]
16743 ]
16744 },
16745 naf: {
16746 wnd: 7,
16747 points: [
16748 [
16749 'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9',
16750 '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672'
16751 ],
16752 [
16753 '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4',
16754 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6'
16755 ],
16756 [
16757 '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc',
16758 '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da'
16759 ],
16760 [
16761 'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe',
16762 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37'
16763 ],
16764 [
16765 '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb',
16766 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b'
16767 ],
16768 [
16769 'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8',
16770 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81'
16771 ],
16772 [
16773 'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e',
16774 '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58'
16775 ],
16776 [
16777 'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34',
16778 '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77'
16779 ],
16780 [
16781 '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c',
16782 '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a'
16783 ],
16784 [
16785 '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5',
16786 '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c'
16787 ],
16788 [
16789 '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f',
16790 '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67'
16791 ],
16792 [
16793 '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714',
16794 '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402'
16795 ],
16796 [
16797 'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729',
16798 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55'
16799 ],
16800 [
16801 'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db',
16802 '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482'
16803 ],
16804 [
16805 '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4',
16806 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82'
16807 ],
16808 [
16809 '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5',
16810 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396'
16811 ],
16812 [
16813 '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479',
16814 '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49'
16815 ],
16816 [
16817 '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d',
16818 '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf'
16819 ],
16820 [
16821 '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f',
16822 '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a'
16823 ],
16824 [
16825 '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb',
16826 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7'
16827 ],
16828 [
16829 'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9',
16830 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933'
16831 ],
16832 [
16833 '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963',
16834 '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a'
16835 ],
16836 [
16837 '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74',
16838 '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6'
16839 ],
16840 [
16841 'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530',
16842 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37'
16843 ],
16844 [
16845 '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b',
16846 '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e'
16847 ],
16848 [
16849 'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247',
16850 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6'
16851 ],
16852 [
16853 'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1',
16854 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476'
16855 ],
16856 [
16857 '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120',
16858 '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40'
16859 ],
16860 [
16861 '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435',
16862 '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61'
16863 ],
16864 [
16865 '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18',
16866 '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683'
16867 ],
16868 [
16869 'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8',
16870 '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5'
16871 ],
16872 [
16873 '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb',
16874 '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b'
16875 ],
16876 [
16877 'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f',
16878 '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417'
16879 ],
16880 [
16881 '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143',
16882 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868'
16883 ],
16884 [
16885 '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba',
16886 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a'
16887 ],
16888 [
16889 'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45',
16890 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6'
16891 ],
16892 [
16893 '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a',
16894 '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996'
16895 ],
16896 [
16897 '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e',
16898 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e'
16899 ],
16900 [
16901 'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8',
16902 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d'
16903 ],
16904 [
16905 '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c',
16906 '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2'
16907 ],
16908 [
16909 '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519',
16910 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e'
16911 ],
16912 [
16913 '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab',
16914 '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437'
16915 ],
16916 [
16917 '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca',
16918 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311'
16919 ],
16920 [
16921 'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf',
16922 '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4'
16923 ],
16924 [
16925 '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610',
16926 '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575'
16927 ],
16928 [
16929 '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4',
16930 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d'
16931 ],
16932 [
16933 '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c',
16934 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d'
16935 ],
16936 [
16937 'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940',
16938 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629'
16939 ],
16940 [
16941 'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980',
16942 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06'
16943 ],
16944 [
16945 '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3',
16946 '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374'
16947 ],
16948 [
16949 '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf',
16950 '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee'
16951 ],
16952 [
16953 'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63',
16954 '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1'
16955 ],
16956 [
16957 'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448',
16958 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b'
16959 ],
16960 [
16961 '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf',
16962 '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661'
16963 ],
16964 [
16965 '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5',
16966 '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6'
16967 ],
16968 [
16969 'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6',
16970 '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e'
16971 ],
16972 [
16973 '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5',
16974 '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d'
16975 ],
16976 [
16977 'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99',
16978 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc'
16979 ],
16980 [
16981 '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51',
16982 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4'
16983 ],
16984 [
16985 '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5',
16986 '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c'
16987 ],
16988 [
16989 'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5',
16990 '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b'
16991 ],
16992 [
16993 'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997',
16994 '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913'
16995 ],
16996 [
16997 '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881',
16998 '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154'
16999 ],
17000 [
17001 '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5',
17002 '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865'
17003 ],
17004 [
17005 '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66',
17006 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc'
17007 ],
17008 [
17009 '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726',
17010 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224'
17011 ],
17012 [
17013 '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede',
17014 '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e'
17015 ],
17016 [
17017 '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94',
17018 '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6'
17019 ],
17020 [
17021 '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31',
17022 '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511'
17023 ],
17024 [
17025 '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51',
17026 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b'
17027 ],
17028 [
17029 'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252',
17030 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2'
17031 ],
17032 [
17033 '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5',
17034 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c'
17035 ],
17036 [
17037 'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b',
17038 '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3'
17039 ],
17040 [
17041 'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4',
17042 '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d'
17043 ],
17044 [
17045 'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f',
17046 '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700'
17047 ],
17048 [
17049 'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889',
17050 '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4'
17051 ],
17052 [
17053 '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246',
17054 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196'
17055 ],
17056 [
17057 '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984',
17058 '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4'
17059 ],
17060 [
17061 '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a',
17062 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257'
17063 ],
17064 [
17065 'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030',
17066 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13'
17067 ],
17068 [
17069 'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197',
17070 '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096'
17071 ],
17072 [
17073 'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593',
17074 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38'
17075 ],
17076 [
17077 'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef',
17078 '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f'
17079 ],
17080 [
17081 '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38',
17082 '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448'
17083 ],
17084 [
17085 'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a',
17086 '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a'
17087 ],
17088 [
17089 'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111',
17090 '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4'
17091 ],
17092 [
17093 '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502',
17094 '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437'
17095 ],
17096 [
17097 '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea',
17098 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7'
17099 ],
17100 [
17101 'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26',
17102 '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d'
17103 ],
17104 [
17105 'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986',
17106 '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a'
17107 ],
17108 [
17109 'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e',
17110 '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54'
17111 ],
17112 [
17113 '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4',
17114 '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77'
17115 ],
17116 [
17117 'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda',
17118 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517'
17119 ],
17120 [
17121 '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859',
17122 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10'
17123 ],
17124 [
17125 'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f',
17126 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125'
17127 ],
17128 [
17129 'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c',
17130 '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e'
17131 ],
17132 [
17133 '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942',
17134 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1'
17135 ],
17136 [
17137 'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a',
17138 '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2'
17139 ],
17140 [
17141 'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80',
17142 '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423'
17143 ],
17144 [
17145 'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d',
17146 '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8'
17147 ],
17148 [
17149 '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1',
17150 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758'
17151 ],
17152 [
17153 '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63',
17154 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375'
17155 ],
17156 [
17157 'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352',
17158 '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d'
17159 ],
17160 [
17161 '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193',
17162 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec'
17163 ],
17164 [
17165 '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00',
17166 '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0'
17167 ],
17168 [
17169 '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58',
17170 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c'
17171 ],
17172 [
17173 'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7',
17174 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4'
17175 ],
17176 [
17177 '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8',
17178 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f'
17179 ],
17180 [
17181 '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e',
17182 '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649'
17183 ],
17184 [
17185 '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d',
17186 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826'
17187 ],
17188 [
17189 '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b',
17190 '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5'
17191 ],
17192 [
17193 'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f',
17194 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87'
17195 ],
17196 [
17197 '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6',
17198 '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b'
17199 ],
17200 [
17201 'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297',
17202 '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc'
17203 ],
17204 [
17205 '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a',
17206 '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c'
17207 ],
17208 [
17209 'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c',
17210 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f'
17211 ],
17212 [
17213 'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52',
17214 '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a'
17215 ],
17216 [
17217 'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb',
17218 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46'
17219 ],
17220 [
17221 '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065',
17222 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f'
17223 ],
17224 [
17225 '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917',
17226 '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03'
17227 ],
17228 [
17229 '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9',
17230 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08'
17231 ],
17232 [
17233 '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3',
17234 '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8'
17235 ],
17236 [
17237 '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57',
17238 '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373'
17239 ],
17240 [
17241 '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66',
17242 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3'
17243 ],
17244 [
17245 '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8',
17246 '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8'
17247 ],
17248 [
17249 '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721',
17250 '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1'
17251 ],
17252 [
17253 '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180',
17254 '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9'
17255 ]
17256 ]
17257 }
17258};
17259
17260},{}],240:[function(require,module,exports){
17261'use strict';
17262
17263var utils = exports;
17264var BN = require('bn.js');
17265var minAssert = require('minimalistic-assert');
17266var minUtils = require('minimalistic-crypto-utils');
17267
17268utils.assert = minAssert;
17269utils.toArray = minUtils.toArray;
17270utils.zero2 = minUtils.zero2;
17271utils.toHex = minUtils.toHex;
17272utils.encode = minUtils.encode;
17273
17274// Represent num in a w-NAF form
17275function getNAF(num, w) {
17276 var naf = [];
17277 var ws = 1 << (w + 1);
17278 var k = num.clone();
17279 while (k.cmpn(1) >= 0) {
17280 var z;
17281 if (k.isOdd()) {
17282 var mod = k.andln(ws - 1);
17283 if (mod > (ws >> 1) - 1)
17284 z = (ws >> 1) - mod;
17285 else
17286 z = mod;
17287 k.isubn(z);
17288 } else {
17289 z = 0;
17290 }
17291 naf.push(z);
17292
17293 // Optimization, shift by word if possible
17294 var shift = (k.cmpn(0) !== 0 && k.andln(ws - 1) === 0) ? (w + 1) : 1;
17295 for (var i = 1; i < shift; i++)
17296 naf.push(0);
17297 k.iushrn(shift);
17298 }
17299
17300 return naf;
17301}
17302utils.getNAF = getNAF;
17303
17304// Represent k1, k2 in a Joint Sparse Form
17305function getJSF(k1, k2) {
17306 var jsf = [
17307 [],
17308 []
17309 ];
17310
17311 k1 = k1.clone();
17312 k2 = k2.clone();
17313 var d1 = 0;
17314 var d2 = 0;
17315 while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) {
17316
17317 // First phase
17318 var m14 = (k1.andln(3) + d1) & 3;
17319 var m24 = (k2.andln(3) + d2) & 3;
17320 if (m14 === 3)
17321 m14 = -1;
17322 if (m24 === 3)
17323 m24 = -1;
17324 var u1;
17325 if ((m14 & 1) === 0) {
17326 u1 = 0;
17327 } else {
17328 var m8 = (k1.andln(7) + d1) & 7;
17329 if ((m8 === 3 || m8 === 5) && m24 === 2)
17330 u1 = -m14;
17331 else
17332 u1 = m14;
17333 }
17334 jsf[0].push(u1);
17335
17336 var u2;
17337 if ((m24 & 1) === 0) {
17338 u2 = 0;
17339 } else {
17340 var m8 = (k2.andln(7) + d2) & 7;
17341 if ((m8 === 3 || m8 === 5) && m14 === 2)
17342 u2 = -m24;
17343 else
17344 u2 = m24;
17345 }
17346 jsf[1].push(u2);
17347
17348 // Second phase
17349 if (2 * d1 === u1 + 1)
17350 d1 = 1 - d1;
17351 if (2 * d2 === u2 + 1)
17352 d2 = 1 - d2;
17353 k1.iushrn(1);
17354 k2.iushrn(1);
17355 }
17356
17357 return jsf;
17358}
17359utils.getJSF = getJSF;
17360
17361function cachedProperty(obj, name, computer) {
17362 var key = '_' + name;
17363 obj.prototype[name] = function cachedProperty() {
17364 return this[key] !== undefined ? this[key] :
17365 this[key] = computer.call(this);
17366 };
17367}
17368utils.cachedProperty = cachedProperty;
17369
17370function parseBytes(bytes) {
17371 return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') :
17372 bytes;
17373}
17374utils.parseBytes = parseBytes;
17375
17376function intFromLE(bytes) {
17377 return new BN(bytes, 'hex', 'le');
17378}
17379utils.intFromLE = intFromLE;
17380
17381
17382},{"bn.js":43,"minimalistic-assert":266,"minimalistic-crypto-utils":267}],241:[function(require,module,exports){
17383module.exports={
17384 "_args": [
17385 [
17386 "elliptic@6.4.0",
17387 "/mnt/teamcity/work/c19f76d16f40cf26"
17388 ]
17389 ],
17390 "_development": true,
17391 "_from": "elliptic@6.4.0",
17392 "_id": "elliptic@6.4.0",
17393 "_inBundle": false,
17394 "_integrity": "sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=",
17395 "_location": "/elliptic",
17396 "_phantomChildren": {},
17397 "_requested": {
17398 "type": "version",
17399 "registry": true,
17400 "raw": "elliptic@6.4.0",
17401 "name": "elliptic",
17402 "escapedName": "elliptic",
17403 "rawSpec": "6.4.0",
17404 "saveSpec": null,
17405 "fetchSpec": "6.4.0"
17406 },
17407 "_requiredBy": [
17408 "/browserify-sign",
17409 "/create-ecdh"
17410 ],
17411 "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz",
17412 "_spec": "6.4.0",
17413 "_where": "/mnt/teamcity/work/c19f76d16f40cf26",
17414 "author": {
17415 "name": "Fedor Indutny",
17416 "email": "fedor@indutny.com"
17417 },
17418 "bugs": {
17419 "url": "https://github.com/indutny/elliptic/issues"
17420 },
17421 "dependencies": {
17422 "bn.js": "^4.4.0",
17423 "brorand": "^1.0.1",
17424 "hash.js": "^1.0.0",
17425 "hmac-drbg": "^1.0.0",
17426 "inherits": "^2.0.1",
17427 "minimalistic-assert": "^1.0.0",
17428 "minimalistic-crypto-utils": "^1.0.0"
17429 },
17430 "description": "EC cryptography",
17431 "devDependencies": {
17432 "brfs": "^1.4.3",
17433 "coveralls": "^2.11.3",
17434 "grunt": "^0.4.5",
17435 "grunt-browserify": "^5.0.0",
17436 "grunt-cli": "^1.2.0",
17437 "grunt-contrib-connect": "^1.0.0",
17438 "grunt-contrib-copy": "^1.0.0",
17439 "grunt-contrib-uglify": "^1.0.1",
17440 "grunt-mocha-istanbul": "^3.0.1",
17441 "grunt-saucelabs": "^8.6.2",
17442 "istanbul": "^0.4.2",
17443 "jscs": "^2.9.0",
17444 "jshint": "^2.6.0",
17445 "mocha": "^2.1.0"
17446 },
17447 "files": [
17448 "lib"
17449 ],
17450 "homepage": "https://github.com/indutny/elliptic",
17451 "keywords": [
17452 "EC",
17453 "Elliptic",
17454 "curve",
17455 "Cryptography"
17456 ],
17457 "license": "MIT",
17458 "main": "lib/elliptic.js",
17459 "name": "elliptic",
17460 "repository": {
17461 "type": "git",
17462 "url": "git+ssh://git@github.com/indutny/elliptic.git"
17463 },
17464 "scripts": {
17465 "jscs": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
17466 "jshint": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
17467 "lint": "npm run jscs && npm run jshint",
17468 "test": "npm run lint && npm run unit",
17469 "unit": "istanbul test _mocha --reporter=spec test/index.js",
17470 "version": "grunt dist && git add dist/"
17471 },
17472 "version": "6.4.0"
17473}
17474
17475},{}],242:[function(require,module,exports){
17476// Copyright Joyent, Inc. and other Node contributors.
17477//
17478// Permission is hereby granted, free of charge, to any person obtaining a
17479// copy of this software and associated documentation files (the
17480// "Software"), to deal in the Software without restriction, including
17481// without limitation the rights to use, copy, modify, merge, publish,
17482// distribute, sublicense, and/or sell copies of the Software, and to permit
17483// persons to whom the Software is furnished to do so, subject to the
17484// following conditions:
17485//
17486// The above copyright notice and this permission notice shall be included
17487// in all copies or substantial portions of the Software.
17488//
17489// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17490// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17491// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17492// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17493// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17494// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
17495// USE OR OTHER DEALINGS IN THE SOFTWARE.
17496
17497function EventEmitter() {
17498 this._events = this._events || {};
17499 this._maxListeners = this._maxListeners || undefined;
17500}
17501module.exports = EventEmitter;
17502
17503// Backwards-compat with node 0.10.x
17504EventEmitter.EventEmitter = EventEmitter;
17505
17506EventEmitter.prototype._events = undefined;
17507EventEmitter.prototype._maxListeners = undefined;
17508
17509// By default EventEmitters will print a warning if more than 10 listeners are
17510// added to it. This is a useful default which helps finding memory leaks.
17511EventEmitter.defaultMaxListeners = 10;
17512
17513// Obviously not all Emitters should be limited to 10. This function allows
17514// that to be increased. Set to zero for unlimited.
17515EventEmitter.prototype.setMaxListeners = function(n) {
17516 if (!isNumber(n) || n < 0 || isNaN(n))
17517 throw TypeError('n must be a positive number');
17518 this._maxListeners = n;
17519 return this;
17520};
17521
17522EventEmitter.prototype.emit = function(type) {
17523 var er, handler, len, args, i, listeners;
17524
17525 if (!this._events)
17526 this._events = {};
17527
17528 // If there is no 'error' event listener then throw.
17529 if (type === 'error') {
17530 if (!this._events.error ||
17531 (isObject(this._events.error) && !this._events.error.length)) {
17532 er = arguments[1];
17533 if (er instanceof Error) {
17534 throw er; // Unhandled 'error' event
17535 } else {
17536 // At least give some kind of context to the user
17537 var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
17538 err.context = er;
17539 throw err;
17540 }
17541 }
17542 }
17543
17544 handler = this._events[type];
17545
17546 if (isUndefined(handler))
17547 return false;
17548
17549 if (isFunction(handler)) {
17550 switch (arguments.length) {
17551 // fast cases
17552 case 1:
17553 handler.call(this);
17554 break;
17555 case 2:
17556 handler.call(this, arguments[1]);
17557 break;
17558 case 3:
17559 handler.call(this, arguments[1], arguments[2]);
17560 break;
17561 // slower
17562 default:
17563 args = Array.prototype.slice.call(arguments, 1);
17564 handler.apply(this, args);
17565 }
17566 } else if (isObject(handler)) {
17567 args = Array.prototype.slice.call(arguments, 1);
17568 listeners = handler.slice();
17569 len = listeners.length;
17570 for (i = 0; i < len; i++)
17571 listeners[i].apply(this, args);
17572 }
17573
17574 return true;
17575};
17576
17577EventEmitter.prototype.addListener = function(type, listener) {
17578 var m;
17579
17580 if (!isFunction(listener))
17581 throw TypeError('listener must be a function');
17582
17583 if (!this._events)
17584 this._events = {};
17585
17586 // To avoid recursion in the case that type === "newListener"! Before
17587 // adding it to the listeners, first emit "newListener".
17588 if (this._events.newListener)
17589 this.emit('newListener', type,
17590 isFunction(listener.listener) ?
17591 listener.listener : listener);
17592
17593 if (!this._events[type])
17594 // Optimize the case of one listener. Don't need the extra array object.
17595 this._events[type] = listener;
17596 else if (isObject(this._events[type]))
17597 // If we've already got an array, just append.
17598 this._events[type].push(listener);
17599 else
17600 // Adding the second element, need to change to array.
17601 this._events[type] = [this._events[type], listener];
17602
17603 // Check for listener leak
17604 if (isObject(this._events[type]) && !this._events[type].warned) {
17605 if (!isUndefined(this._maxListeners)) {
17606 m = this._maxListeners;
17607 } else {
17608 m = EventEmitter.defaultMaxListeners;
17609 }
17610
17611 if (m && m > 0 && this._events[type].length > m) {
17612 this._events[type].warned = true;
17613 console.error('(node) warning: possible EventEmitter memory ' +
17614 'leak detected. %d listeners added. ' +
17615 'Use emitter.setMaxListeners() to increase limit.',
17616 this._events[type].length);
17617 if (typeof console.trace === 'function') {
17618 // not supported in IE 10
17619 console.trace();
17620 }
17621 }
17622 }
17623
17624 return this;
17625};
17626
17627EventEmitter.prototype.on = EventEmitter.prototype.addListener;
17628
17629EventEmitter.prototype.once = function(type, listener) {
17630 if (!isFunction(listener))
17631 throw TypeError('listener must be a function');
17632
17633 var fired = false;
17634
17635 function g() {
17636 this.removeListener(type, g);
17637
17638 if (!fired) {
17639 fired = true;
17640 listener.apply(this, arguments);
17641 }
17642 }
17643
17644 g.listener = listener;
17645 this.on(type, g);
17646
17647 return this;
17648};
17649
17650// emits a 'removeListener' event iff the listener was removed
17651EventEmitter.prototype.removeListener = function(type, listener) {
17652 var list, position, length, i;
17653
17654 if (!isFunction(listener))
17655 throw TypeError('listener must be a function');
17656
17657 if (!this._events || !this._events[type])
17658 return this;
17659
17660 list = this._events[type];
17661 length = list.length;
17662 position = -1;
17663
17664 if (list === listener ||
17665 (isFunction(list.listener) && list.listener === listener)) {
17666 delete this._events[type];
17667 if (this._events.removeListener)
17668 this.emit('removeListener', type, listener);
17669
17670 } else if (isObject(list)) {
17671 for (i = length; i-- > 0;) {
17672 if (list[i] === listener ||
17673 (list[i].listener && list[i].listener === listener)) {
17674 position = i;
17675 break;
17676 }
17677 }
17678
17679 if (position < 0)
17680 return this;
17681
17682 if (list.length === 1) {
17683 list.length = 0;
17684 delete this._events[type];
17685 } else {
17686 list.splice(position, 1);
17687 }
17688
17689 if (this._events.removeListener)
17690 this.emit('removeListener', type, listener);
17691 }
17692
17693 return this;
17694};
17695
17696EventEmitter.prototype.removeAllListeners = function(type) {
17697 var key, listeners;
17698
17699 if (!this._events)
17700 return this;
17701
17702 // not listening for removeListener, no need to emit
17703 if (!this._events.removeListener) {
17704 if (arguments.length === 0)
17705 this._events = {};
17706 else if (this._events[type])
17707 delete this._events[type];
17708 return this;
17709 }
17710
17711 // emit removeListener for all listeners on all events
17712 if (arguments.length === 0) {
17713 for (key in this._events) {
17714 if (key === 'removeListener') continue;
17715 this.removeAllListeners(key);
17716 }
17717 this.removeAllListeners('removeListener');
17718 this._events = {};
17719 return this;
17720 }
17721
17722 listeners = this._events[type];
17723
17724 if (isFunction(listeners)) {
17725 this.removeListener(type, listeners);
17726 } else if (listeners) {
17727 // LIFO order
17728 while (listeners.length)
17729 this.removeListener(type, listeners[listeners.length - 1]);
17730 }
17731 delete this._events[type];
17732
17733 return this;
17734};
17735
17736EventEmitter.prototype.listeners = function(type) {
17737 var ret;
17738 if (!this._events || !this._events[type])
17739 ret = [];
17740 else if (isFunction(this._events[type]))
17741 ret = [this._events[type]];
17742 else
17743 ret = this._events[type].slice();
17744 return ret;
17745};
17746
17747EventEmitter.prototype.listenerCount = function(type) {
17748 if (this._events) {
17749 var evlistener = this._events[type];
17750
17751 if (isFunction(evlistener))
17752 return 1;
17753 else if (evlistener)
17754 return evlistener.length;
17755 }
17756 return 0;
17757};
17758
17759EventEmitter.listenerCount = function(emitter, type) {
17760 return emitter.listenerCount(type);
17761};
17762
17763function isFunction(arg) {
17764 return typeof arg === 'function';
17765}
17766
17767function isNumber(arg) {
17768 return typeof arg === 'number';
17769}
17770
17771function isObject(arg) {
17772 return typeof arg === 'object' && arg !== null;
17773}
17774
17775function isUndefined(arg) {
17776 return arg === void 0;
17777}
17778
17779},{}],243:[function(require,module,exports){
17780var Buffer = require('safe-buffer').Buffer
17781var MD5 = require('md5.js')
17782
17783/* eslint-disable camelcase */
17784function EVP_BytesToKey (password, salt, keyBits, ivLen) {
17785 if (!Buffer.isBuffer(password)) password = Buffer.from(password, 'binary')
17786 if (salt) {
17787 if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, 'binary')
17788 if (salt.length !== 8) throw new RangeError('salt should be Buffer with 8 byte length')
17789 }
17790
17791 var keyLen = keyBits / 8
17792 var key = Buffer.alloc(keyLen)
17793 var iv = Buffer.alloc(ivLen || 0)
17794 var tmp = Buffer.alloc(0)
17795
17796 while (keyLen > 0 || ivLen > 0) {
17797 var hash = new MD5()
17798 hash.update(tmp)
17799 hash.update(password)
17800 if (salt) hash.update(salt)
17801 tmp = hash.digest()
17802
17803 var used = 0
17804
17805 if (keyLen > 0) {
17806 var keyStart = key.length - keyLen
17807 used = Math.min(keyLen, tmp.length)
17808 tmp.copy(key, keyStart, 0, used)
17809 keyLen -= used
17810 }
17811
17812 if (used < tmp.length && ivLen > 0) {
17813 var ivStart = iv.length - ivLen
17814 var length = Math.min(ivLen, tmp.length - used)
17815 tmp.copy(iv, ivStart, used, used + length)
17816 ivLen -= length
17817 }
17818 }
17819
17820 tmp.fill(0)
17821 return { key: key, iv: iv }
17822}
17823
17824module.exports = EVP_BytesToKey
17825
17826},{"md5.js":263,"safe-buffer":305}],244:[function(require,module,exports){
17827(function (Buffer){
17828'use strict'
17829var Transform = require('stream').Transform
17830var inherits = require('inherits')
17831
17832function HashBase (blockSize) {
17833 Transform.call(this)
17834
17835 this._block = new Buffer(blockSize)
17836 this._blockSize = blockSize
17837 this._blockOffset = 0
17838 this._length = [0, 0, 0, 0]
17839
17840 this._finalized = false
17841}
17842
17843inherits(HashBase, Transform)
17844
17845HashBase.prototype._transform = function (chunk, encoding, callback) {
17846 var error = null
17847 try {
17848 if (encoding !== 'buffer') chunk = new Buffer(chunk, encoding)
17849 this.update(chunk)
17850 } catch (err) {
17851 error = err
17852 }
17853
17854 callback(error)
17855}
17856
17857HashBase.prototype._flush = function (callback) {
17858 var error = null
17859 try {
17860 this.push(this._digest())
17861 } catch (err) {
17862 error = err
17863 }
17864
17865 callback(error)
17866}
17867
17868HashBase.prototype.update = function (data, encoding) {
17869 if (!Buffer.isBuffer(data) && typeof data !== 'string') throw new TypeError('Data must be a string or a buffer')
17870 if (this._finalized) throw new Error('Digest already called')
17871 if (!Buffer.isBuffer(data)) data = new Buffer(data, encoding || 'binary')
17872
17873 // consume data
17874 var block = this._block
17875 var offset = 0
17876 while (this._blockOffset + data.length - offset >= this._blockSize) {
17877 for (var i = this._blockOffset; i < this._blockSize;) block[i++] = data[offset++]
17878 this._update()
17879 this._blockOffset = 0
17880 }
17881 while (offset < data.length) block[this._blockOffset++] = data[offset++]
17882
17883 // update length
17884 for (var j = 0, carry = data.length * 8; carry > 0; ++j) {
17885 this._length[j] += carry
17886 carry = (this._length[j] / 0x0100000000) | 0
17887 if (carry > 0) this._length[j] -= 0x0100000000 * carry
17888 }
17889
17890 return this
17891}
17892
17893HashBase.prototype._update = function (data) {
17894 throw new Error('_update is not implemented')
17895}
17896
17897HashBase.prototype.digest = function (encoding) {
17898 if (this._finalized) throw new Error('Digest already called')
17899 this._finalized = true
17900
17901 var digest = this._digest()
17902 if (encoding !== undefined) digest = digest.toString(encoding)
17903 return digest
17904}
17905
17906HashBase.prototype._digest = function () {
17907 throw new Error('_digest is not implemented')
17908}
17909
17910module.exports = HashBase
17911
17912}).call(this,require("buffer").Buffer)
17913},{"buffer":75,"inherits":260,"stream":314}],245:[function(require,module,exports){
17914var hash = exports;
17915
17916hash.utils = require('./hash/utils');
17917hash.common = require('./hash/common');
17918hash.sha = require('./hash/sha');
17919hash.ripemd = require('./hash/ripemd');
17920hash.hmac = require('./hash/hmac');
17921
17922// Proxy hash functions to the main object
17923hash.sha1 = hash.sha.sha1;
17924hash.sha256 = hash.sha.sha256;
17925hash.sha224 = hash.sha.sha224;
17926hash.sha384 = hash.sha.sha384;
17927hash.sha512 = hash.sha.sha512;
17928hash.ripemd160 = hash.ripemd.ripemd160;
17929
17930},{"./hash/common":246,"./hash/hmac":247,"./hash/ripemd":248,"./hash/sha":249,"./hash/utils":256}],246:[function(require,module,exports){
17931'use strict';
17932
17933var utils = require('./utils');
17934var assert = require('minimalistic-assert');
17935
17936function BlockHash() {
17937 this.pending = null;
17938 this.pendingTotal = 0;
17939 this.blockSize = this.constructor.blockSize;
17940 this.outSize = this.constructor.outSize;
17941 this.hmacStrength = this.constructor.hmacStrength;
17942 this.padLength = this.constructor.padLength / 8;
17943 this.endian = 'big';
17944
17945 this._delta8 = this.blockSize / 8;
17946 this._delta32 = this.blockSize / 32;
17947}
17948exports.BlockHash = BlockHash;
17949
17950BlockHash.prototype.update = function update(msg, enc) {
17951 // Convert message to array, pad it, and join into 32bit blocks
17952 msg = utils.toArray(msg, enc);
17953 if (!this.pending)
17954 this.pending = msg;
17955 else
17956 this.pending = this.pending.concat(msg);
17957 this.pendingTotal += msg.length;
17958
17959 // Enough data, try updating
17960 if (this.pending.length >= this._delta8) {
17961 msg = this.pending;
17962
17963 // Process pending data in blocks
17964 var r = msg.length % this._delta8;
17965 this.pending = msg.slice(msg.length - r, msg.length);
17966 if (this.pending.length === 0)
17967 this.pending = null;
17968
17969 msg = utils.join32(msg, 0, msg.length - r, this.endian);
17970 for (var i = 0; i < msg.length; i += this._delta32)
17971 this._update(msg, i, i + this._delta32);
17972 }
17973
17974 return this;
17975};
17976
17977BlockHash.prototype.digest = function digest(enc) {
17978 this.update(this._pad());
17979 assert(this.pending === null);
17980
17981 return this._digest(enc);
17982};
17983
17984BlockHash.prototype._pad = function pad() {
17985 var len = this.pendingTotal;
17986 var bytes = this._delta8;
17987 var k = bytes - ((len + this.padLength) % bytes);
17988 var res = new Array(k + this.padLength);
17989 res[0] = 0x80;
17990 for (var i = 1; i < k; i++)
17991 res[i] = 0;
17992
17993 // Append length
17994 len <<= 3;
17995 if (this.endian === 'big') {
17996 for (var t = 8; t < this.padLength; t++)
17997 res[i++] = 0;
17998
17999 res[i++] = 0;
18000 res[i++] = 0;
18001 res[i++] = 0;
18002 res[i++] = 0;
18003 res[i++] = (len >>> 24) & 0xff;
18004 res[i++] = (len >>> 16) & 0xff;
18005 res[i++] = (len >>> 8) & 0xff;
18006 res[i++] = len & 0xff;
18007 } else {
18008 res[i++] = len & 0xff;
18009 res[i++] = (len >>> 8) & 0xff;
18010 res[i++] = (len >>> 16) & 0xff;
18011 res[i++] = (len >>> 24) & 0xff;
18012 res[i++] = 0;
18013 res[i++] = 0;
18014 res[i++] = 0;
18015 res[i++] = 0;
18016
18017 for (t = 8; t < this.padLength; t++)
18018 res[i++] = 0;
18019 }
18020
18021 return res;
18022};
18023
18024},{"./utils":256,"minimalistic-assert":266}],247:[function(require,module,exports){
18025'use strict';
18026
18027var utils = require('./utils');
18028var assert = require('minimalistic-assert');
18029
18030function Hmac(hash, key, enc) {
18031 if (!(this instanceof Hmac))
18032 return new Hmac(hash, key, enc);
18033 this.Hash = hash;
18034 this.blockSize = hash.blockSize / 8;
18035 this.outSize = hash.outSize / 8;
18036 this.inner = null;
18037 this.outer = null;
18038
18039 this._init(utils.toArray(key, enc));
18040}
18041module.exports = Hmac;
18042
18043Hmac.prototype._init = function init(key) {
18044 // Shorten key, if needed
18045 if (key.length > this.blockSize)
18046 key = new this.Hash().update(key).digest();
18047 assert(key.length <= this.blockSize);
18048
18049 // Add padding to key
18050 for (var i = key.length; i < this.blockSize; i++)
18051 key.push(0);
18052
18053 for (i = 0; i < key.length; i++)
18054 key[i] ^= 0x36;
18055 this.inner = new this.Hash().update(key);
18056
18057 // 0x36 ^ 0x5c = 0x6a
18058 for (i = 0; i < key.length; i++)
18059 key[i] ^= 0x6a;
18060 this.outer = new this.Hash().update(key);
18061};
18062
18063Hmac.prototype.update = function update(msg, enc) {
18064 this.inner.update(msg, enc);
18065 return this;
18066};
18067
18068Hmac.prototype.digest = function digest(enc) {
18069 this.outer.update(this.inner.digest());
18070 return this.outer.digest(enc);
18071};
18072
18073},{"./utils":256,"minimalistic-assert":266}],248:[function(require,module,exports){
18074'use strict';
18075
18076var utils = require('./utils');
18077var common = require('./common');
18078
18079var rotl32 = utils.rotl32;
18080var sum32 = utils.sum32;
18081var sum32_3 = utils.sum32_3;
18082var sum32_4 = utils.sum32_4;
18083var BlockHash = common.BlockHash;
18084
18085function RIPEMD160() {
18086 if (!(this instanceof RIPEMD160))
18087 return new RIPEMD160();
18088
18089 BlockHash.call(this);
18090
18091 this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ];
18092 this.endian = 'little';
18093}
18094utils.inherits(RIPEMD160, BlockHash);
18095exports.ripemd160 = RIPEMD160;
18096
18097RIPEMD160.blockSize = 512;
18098RIPEMD160.outSize = 160;
18099RIPEMD160.hmacStrength = 192;
18100RIPEMD160.padLength = 64;
18101
18102RIPEMD160.prototype._update = function update(msg, start) {
18103 var A = this.h[0];
18104 var B = this.h[1];
18105 var C = this.h[2];
18106 var D = this.h[3];
18107 var E = this.h[4];
18108 var Ah = A;
18109 var Bh = B;
18110 var Ch = C;
18111 var Dh = D;
18112 var Eh = E;
18113 for (var j = 0; j < 80; j++) {
18114 var T = sum32(
18115 rotl32(
18116 sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)),
18117 s[j]),
18118 E);
18119 A = E;
18120 E = D;
18121 D = rotl32(C, 10);
18122 C = B;
18123 B = T;
18124 T = sum32(
18125 rotl32(
18126 sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),
18127 sh[j]),
18128 Eh);
18129 Ah = Eh;
18130 Eh = Dh;
18131 Dh = rotl32(Ch, 10);
18132 Ch = Bh;
18133 Bh = T;
18134 }
18135 T = sum32_3(this.h[1], C, Dh);
18136 this.h[1] = sum32_3(this.h[2], D, Eh);
18137 this.h[2] = sum32_3(this.h[3], E, Ah);
18138 this.h[3] = sum32_3(this.h[4], A, Bh);
18139 this.h[4] = sum32_3(this.h[0], B, Ch);
18140 this.h[0] = T;
18141};
18142
18143RIPEMD160.prototype._digest = function digest(enc) {
18144 if (enc === 'hex')
18145 return utils.toHex32(this.h, 'little');
18146 else
18147 return utils.split32(this.h, 'little');
18148};
18149
18150function f(j, x, y, z) {
18151 if (j <= 15)
18152 return x ^ y ^ z;
18153 else if (j <= 31)
18154 return (x & y) | ((~x) & z);
18155 else if (j <= 47)
18156 return (x | (~y)) ^ z;
18157 else if (j <= 63)
18158 return (x & z) | (y & (~z));
18159 else
18160 return x ^ (y | (~z));
18161}
18162
18163function K(j) {
18164 if (j <= 15)
18165 return 0x00000000;
18166 else if (j <= 31)
18167 return 0x5a827999;
18168 else if (j <= 47)
18169 return 0x6ed9eba1;
18170 else if (j <= 63)
18171 return 0x8f1bbcdc;
18172 else
18173 return 0xa953fd4e;
18174}
18175
18176function Kh(j) {
18177 if (j <= 15)
18178 return 0x50a28be6;
18179 else if (j <= 31)
18180 return 0x5c4dd124;
18181 else if (j <= 47)
18182 return 0x6d703ef3;
18183 else if (j <= 63)
18184 return 0x7a6d76e9;
18185 else
18186 return 0x00000000;
18187}
18188
18189var r = [
18190 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
18191 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
18192 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
18193 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
18194 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
18195];
18196
18197var rh = [
18198 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
18199 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
18200 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
18201 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
18202 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
18203];
18204
18205var s = [
18206 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
18207 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
18208 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
18209 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
18210 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
18211];
18212
18213var sh = [
18214 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
18215 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
18216 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
18217 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
18218 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
18219];
18220
18221},{"./common":246,"./utils":256}],249:[function(require,module,exports){
18222'use strict';
18223
18224exports.sha1 = require('./sha/1');
18225exports.sha224 = require('./sha/224');
18226exports.sha256 = require('./sha/256');
18227exports.sha384 = require('./sha/384');
18228exports.sha512 = require('./sha/512');
18229
18230},{"./sha/1":250,"./sha/224":251,"./sha/256":252,"./sha/384":253,"./sha/512":254}],250:[function(require,module,exports){
18231'use strict';
18232
18233var utils = require('../utils');
18234var common = require('../common');
18235var shaCommon = require('./common');
18236
18237var rotl32 = utils.rotl32;
18238var sum32 = utils.sum32;
18239var sum32_5 = utils.sum32_5;
18240var ft_1 = shaCommon.ft_1;
18241var BlockHash = common.BlockHash;
18242
18243var sha1_K = [
18244 0x5A827999, 0x6ED9EBA1,
18245 0x8F1BBCDC, 0xCA62C1D6
18246];
18247
18248function SHA1() {
18249 if (!(this instanceof SHA1))
18250 return new SHA1();
18251
18252 BlockHash.call(this);
18253 this.h = [
18254 0x67452301, 0xefcdab89, 0x98badcfe,
18255 0x10325476, 0xc3d2e1f0 ];
18256 this.W = new Array(80);
18257}
18258
18259utils.inherits(SHA1, BlockHash);
18260module.exports = SHA1;
18261
18262SHA1.blockSize = 512;
18263SHA1.outSize = 160;
18264SHA1.hmacStrength = 80;
18265SHA1.padLength = 64;
18266
18267SHA1.prototype._update = function _update(msg, start) {
18268 var W = this.W;
18269
18270 for (var i = 0; i < 16; i++)
18271 W[i] = msg[start + i];
18272
18273 for(; i < W.length; i++)
18274 W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
18275
18276 var a = this.h[0];
18277 var b = this.h[1];
18278 var c = this.h[2];
18279 var d = this.h[3];
18280 var e = this.h[4];
18281
18282 for (i = 0; i < W.length; i++) {
18283 var s = ~~(i / 20);
18284 var t = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
18285 e = d;
18286 d = c;
18287 c = rotl32(b, 30);
18288 b = a;
18289 a = t;
18290 }
18291
18292 this.h[0] = sum32(this.h[0], a);
18293 this.h[1] = sum32(this.h[1], b);
18294 this.h[2] = sum32(this.h[2], c);
18295 this.h[3] = sum32(this.h[3], d);
18296 this.h[4] = sum32(this.h[4], e);
18297};
18298
18299SHA1.prototype._digest = function digest(enc) {
18300 if (enc === 'hex')
18301 return utils.toHex32(this.h, 'big');
18302 else
18303 return utils.split32(this.h, 'big');
18304};
18305
18306},{"../common":246,"../utils":256,"./common":255}],251:[function(require,module,exports){
18307'use strict';
18308
18309var utils = require('../utils');
18310var SHA256 = require('./256');
18311
18312function SHA224() {
18313 if (!(this instanceof SHA224))
18314 return new SHA224();
18315
18316 SHA256.call(this);
18317 this.h = [
18318 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
18319 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];
18320}
18321utils.inherits(SHA224, SHA256);
18322module.exports = SHA224;
18323
18324SHA224.blockSize = 512;
18325SHA224.outSize = 224;
18326SHA224.hmacStrength = 192;
18327SHA224.padLength = 64;
18328
18329SHA224.prototype._digest = function digest(enc) {
18330 // Just truncate output
18331 if (enc === 'hex')
18332 return utils.toHex32(this.h.slice(0, 7), 'big');
18333 else
18334 return utils.split32(this.h.slice(0, 7), 'big');
18335};
18336
18337
18338},{"../utils":256,"./256":252}],252:[function(require,module,exports){
18339'use strict';
18340
18341var utils = require('../utils');
18342var common = require('../common');
18343var shaCommon = require('./common');
18344var assert = require('minimalistic-assert');
18345
18346var sum32 = utils.sum32;
18347var sum32_4 = utils.sum32_4;
18348var sum32_5 = utils.sum32_5;
18349var ch32 = shaCommon.ch32;
18350var maj32 = shaCommon.maj32;
18351var s0_256 = shaCommon.s0_256;
18352var s1_256 = shaCommon.s1_256;
18353var g0_256 = shaCommon.g0_256;
18354var g1_256 = shaCommon.g1_256;
18355
18356var BlockHash = common.BlockHash;
18357
18358var sha256_K = [
18359 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
18360 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
18361 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
18362 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
18363 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
18364 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
18365 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
18366 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
18367 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
18368 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
18369 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
18370 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
18371 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
18372 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
18373 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
18374 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
18375];
18376
18377function SHA256() {
18378 if (!(this instanceof SHA256))
18379 return new SHA256();
18380
18381 BlockHash.call(this);
18382 this.h = [
18383 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
18384 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
18385 ];
18386 this.k = sha256_K;
18387 this.W = new Array(64);
18388}
18389utils.inherits(SHA256, BlockHash);
18390module.exports = SHA256;
18391
18392SHA256.blockSize = 512;
18393SHA256.outSize = 256;
18394SHA256.hmacStrength = 192;
18395SHA256.padLength = 64;
18396
18397SHA256.prototype._update = function _update(msg, start) {
18398 var W = this.W;
18399
18400 for (var i = 0; i < 16; i++)
18401 W[i] = msg[start + i];
18402 for (; i < W.length; i++)
18403 W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
18404
18405 var a = this.h[0];
18406 var b = this.h[1];
18407 var c = this.h[2];
18408 var d = this.h[3];
18409 var e = this.h[4];
18410 var f = this.h[5];
18411 var g = this.h[6];
18412 var h = this.h[7];
18413
18414 assert(this.k.length === W.length);
18415 for (i = 0; i < W.length; i++) {
18416 var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
18417 var T2 = sum32(s0_256(a), maj32(a, b, c));
18418 h = g;
18419 g = f;
18420 f = e;
18421 e = sum32(d, T1);
18422 d = c;
18423 c = b;
18424 b = a;
18425 a = sum32(T1, T2);
18426 }
18427
18428 this.h[0] = sum32(this.h[0], a);
18429 this.h[1] = sum32(this.h[1], b);
18430 this.h[2] = sum32(this.h[2], c);
18431 this.h[3] = sum32(this.h[3], d);
18432 this.h[4] = sum32(this.h[4], e);
18433 this.h[5] = sum32(this.h[5], f);
18434 this.h[6] = sum32(this.h[6], g);
18435 this.h[7] = sum32(this.h[7], h);
18436};
18437
18438SHA256.prototype._digest = function digest(enc) {
18439 if (enc === 'hex')
18440 return utils.toHex32(this.h, 'big');
18441 else
18442 return utils.split32(this.h, 'big');
18443};
18444
18445},{"../common":246,"../utils":256,"./common":255,"minimalistic-assert":266}],253:[function(require,module,exports){
18446'use strict';
18447
18448var utils = require('../utils');
18449
18450var SHA512 = require('./512');
18451
18452function SHA384() {
18453 if (!(this instanceof SHA384))
18454 return new SHA384();
18455
18456 SHA512.call(this);
18457 this.h = [
18458 0xcbbb9d5d, 0xc1059ed8,
18459 0x629a292a, 0x367cd507,
18460 0x9159015a, 0x3070dd17,
18461 0x152fecd8, 0xf70e5939,
18462 0x67332667, 0xffc00b31,
18463 0x8eb44a87, 0x68581511,
18464 0xdb0c2e0d, 0x64f98fa7,
18465 0x47b5481d, 0xbefa4fa4 ];
18466}
18467utils.inherits(SHA384, SHA512);
18468module.exports = SHA384;
18469
18470SHA384.blockSize = 1024;
18471SHA384.outSize = 384;
18472SHA384.hmacStrength = 192;
18473SHA384.padLength = 128;
18474
18475SHA384.prototype._digest = function digest(enc) {
18476 if (enc === 'hex')
18477 return utils.toHex32(this.h.slice(0, 12), 'big');
18478 else
18479 return utils.split32(this.h.slice(0, 12), 'big');
18480};
18481
18482},{"../utils":256,"./512":254}],254:[function(require,module,exports){
18483'use strict';
18484
18485var utils = require('../utils');
18486var common = require('../common');
18487var assert = require('minimalistic-assert');
18488
18489var rotr64_hi = utils.rotr64_hi;
18490var rotr64_lo = utils.rotr64_lo;
18491var shr64_hi = utils.shr64_hi;
18492var shr64_lo = utils.shr64_lo;
18493var sum64 = utils.sum64;
18494var sum64_hi = utils.sum64_hi;
18495var sum64_lo = utils.sum64_lo;
18496var sum64_4_hi = utils.sum64_4_hi;
18497var sum64_4_lo = utils.sum64_4_lo;
18498var sum64_5_hi = utils.sum64_5_hi;
18499var sum64_5_lo = utils.sum64_5_lo;
18500
18501var BlockHash = common.BlockHash;
18502
18503var sha512_K = [
18504 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
18505 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
18506 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
18507 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
18508 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
18509 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
18510 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
18511 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
18512 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
18513 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
18514 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
18515 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
18516 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
18517 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
18518 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
18519 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
18520 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
18521 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
18522 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
18523 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
18524 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
18525 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
18526 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
18527 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
18528 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
18529 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
18530 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
18531 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
18532 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
18533 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
18534 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
18535 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
18536 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
18537 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
18538 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
18539 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
18540 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
18541 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
18542 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
18543 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
18544];
18545
18546function SHA512() {
18547 if (!(this instanceof SHA512))
18548 return new SHA512();
18549
18550 BlockHash.call(this);
18551 this.h = [
18552 0x6a09e667, 0xf3bcc908,
18553 0xbb67ae85, 0x84caa73b,
18554 0x3c6ef372, 0xfe94f82b,
18555 0xa54ff53a, 0x5f1d36f1,
18556 0x510e527f, 0xade682d1,
18557 0x9b05688c, 0x2b3e6c1f,
18558 0x1f83d9ab, 0xfb41bd6b,
18559 0x5be0cd19, 0x137e2179 ];
18560 this.k = sha512_K;
18561 this.W = new Array(160);
18562}
18563utils.inherits(SHA512, BlockHash);
18564module.exports = SHA512;
18565
18566SHA512.blockSize = 1024;
18567SHA512.outSize = 512;
18568SHA512.hmacStrength = 192;
18569SHA512.padLength = 128;
18570
18571SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) {
18572 var W = this.W;
18573
18574 // 32 x 32bit words
18575 for (var i = 0; i < 32; i++)
18576 W[i] = msg[start + i];
18577 for (; i < W.length; i += 2) {
18578 var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2
18579 var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
18580 var c1_hi = W[i - 14]; // i - 7
18581 var c1_lo = W[i - 13];
18582 var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15
18583 var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
18584 var c3_hi = W[i - 32]; // i - 16
18585 var c3_lo = W[i - 31];
18586
18587 W[i] = sum64_4_hi(
18588 c0_hi, c0_lo,
18589 c1_hi, c1_lo,
18590 c2_hi, c2_lo,
18591 c3_hi, c3_lo);
18592 W[i + 1] = sum64_4_lo(
18593 c0_hi, c0_lo,
18594 c1_hi, c1_lo,
18595 c2_hi, c2_lo,
18596 c3_hi, c3_lo);
18597 }
18598};
18599
18600SHA512.prototype._update = function _update(msg, start) {
18601 this._prepareBlock(msg, start);
18602
18603 var W = this.W;
18604
18605 var ah = this.h[0];
18606 var al = this.h[1];
18607 var bh = this.h[2];
18608 var bl = this.h[3];
18609 var ch = this.h[4];
18610 var cl = this.h[5];
18611 var dh = this.h[6];
18612 var dl = this.h[7];
18613 var eh = this.h[8];
18614 var el = this.h[9];
18615 var fh = this.h[10];
18616 var fl = this.h[11];
18617 var gh = this.h[12];
18618 var gl = this.h[13];
18619 var hh = this.h[14];
18620 var hl = this.h[15];
18621
18622 assert(this.k.length === W.length);
18623 for (var i = 0; i < W.length; i += 2) {
18624 var c0_hi = hh;
18625 var c0_lo = hl;
18626 var c1_hi = s1_512_hi(eh, el);
18627 var c1_lo = s1_512_lo(eh, el);
18628 var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl);
18629 var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
18630 var c3_hi = this.k[i];
18631 var c3_lo = this.k[i + 1];
18632 var c4_hi = W[i];
18633 var c4_lo = W[i + 1];
18634
18635 var T1_hi = sum64_5_hi(
18636 c0_hi, c0_lo,
18637 c1_hi, c1_lo,
18638 c2_hi, c2_lo,
18639 c3_hi, c3_lo,
18640 c4_hi, c4_lo);
18641 var T1_lo = sum64_5_lo(
18642 c0_hi, c0_lo,
18643 c1_hi, c1_lo,
18644 c2_hi, c2_lo,
18645 c3_hi, c3_lo,
18646 c4_hi, c4_lo);
18647
18648 c0_hi = s0_512_hi(ah, al);
18649 c0_lo = s0_512_lo(ah, al);
18650 c1_hi = maj64_hi(ah, al, bh, bl, ch, cl);
18651 c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);
18652
18653 var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);
18654 var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);
18655
18656 hh = gh;
18657 hl = gl;
18658
18659 gh = fh;
18660 gl = fl;
18661
18662 fh = eh;
18663 fl = el;
18664
18665 eh = sum64_hi(dh, dl, T1_hi, T1_lo);
18666 el = sum64_lo(dl, dl, T1_hi, T1_lo);
18667
18668 dh = ch;
18669 dl = cl;
18670
18671 ch = bh;
18672 cl = bl;
18673
18674 bh = ah;
18675 bl = al;
18676
18677 ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);
18678 al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);
18679 }
18680
18681 sum64(this.h, 0, ah, al);
18682 sum64(this.h, 2, bh, bl);
18683 sum64(this.h, 4, ch, cl);
18684 sum64(this.h, 6, dh, dl);
18685 sum64(this.h, 8, eh, el);
18686 sum64(this.h, 10, fh, fl);
18687 sum64(this.h, 12, gh, gl);
18688 sum64(this.h, 14, hh, hl);
18689};
18690
18691SHA512.prototype._digest = function digest(enc) {
18692 if (enc === 'hex')
18693 return utils.toHex32(this.h, 'big');
18694 else
18695 return utils.split32(this.h, 'big');
18696};
18697
18698function ch64_hi(xh, xl, yh, yl, zh) {
18699 var r = (xh & yh) ^ ((~xh) & zh);
18700 if (r < 0)
18701 r += 0x100000000;
18702 return r;
18703}
18704
18705function ch64_lo(xh, xl, yh, yl, zh, zl) {
18706 var r = (xl & yl) ^ ((~xl) & zl);
18707 if (r < 0)
18708 r += 0x100000000;
18709 return r;
18710}
18711
18712function maj64_hi(xh, xl, yh, yl, zh) {
18713 var r = (xh & yh) ^ (xh & zh) ^ (yh & zh);
18714 if (r < 0)
18715 r += 0x100000000;
18716 return r;
18717}
18718
18719function maj64_lo(xh, xl, yh, yl, zh, zl) {
18720 var r = (xl & yl) ^ (xl & zl) ^ (yl & zl);
18721 if (r < 0)
18722 r += 0x100000000;
18723 return r;
18724}
18725
18726function s0_512_hi(xh, xl) {
18727 var c0_hi = rotr64_hi(xh, xl, 28);
18728 var c1_hi = rotr64_hi(xl, xh, 2); // 34
18729 var c2_hi = rotr64_hi(xl, xh, 7); // 39
18730
18731 var r = c0_hi ^ c1_hi ^ c2_hi;
18732 if (r < 0)
18733 r += 0x100000000;
18734 return r;
18735}
18736
18737function s0_512_lo(xh, xl) {
18738 var c0_lo = rotr64_lo(xh, xl, 28);
18739 var c1_lo = rotr64_lo(xl, xh, 2); // 34
18740 var c2_lo = rotr64_lo(xl, xh, 7); // 39
18741
18742 var r = c0_lo ^ c1_lo ^ c2_lo;
18743 if (r < 0)
18744 r += 0x100000000;
18745 return r;
18746}
18747
18748function s1_512_hi(xh, xl) {
18749 var c0_hi = rotr64_hi(xh, xl, 14);
18750 var c1_hi = rotr64_hi(xh, xl, 18);
18751 var c2_hi = rotr64_hi(xl, xh, 9); // 41
18752
18753 var r = c0_hi ^ c1_hi ^ c2_hi;
18754 if (r < 0)
18755 r += 0x100000000;
18756 return r;
18757}
18758
18759function s1_512_lo(xh, xl) {
18760 var c0_lo = rotr64_lo(xh, xl, 14);
18761 var c1_lo = rotr64_lo(xh, xl, 18);
18762 var c2_lo = rotr64_lo(xl, xh, 9); // 41
18763
18764 var r = c0_lo ^ c1_lo ^ c2_lo;
18765 if (r < 0)
18766 r += 0x100000000;
18767 return r;
18768}
18769
18770function g0_512_hi(xh, xl) {
18771 var c0_hi = rotr64_hi(xh, xl, 1);
18772 var c1_hi = rotr64_hi(xh, xl, 8);
18773 var c2_hi = shr64_hi(xh, xl, 7);
18774
18775 var r = c0_hi ^ c1_hi ^ c2_hi;
18776 if (r < 0)
18777 r += 0x100000000;
18778 return r;
18779}
18780
18781function g0_512_lo(xh, xl) {
18782 var c0_lo = rotr64_lo(xh, xl, 1);
18783 var c1_lo = rotr64_lo(xh, xl, 8);
18784 var c2_lo = shr64_lo(xh, xl, 7);
18785
18786 var r = c0_lo ^ c1_lo ^ c2_lo;
18787 if (r < 0)
18788 r += 0x100000000;
18789 return r;
18790}
18791
18792function g1_512_hi(xh, xl) {
18793 var c0_hi = rotr64_hi(xh, xl, 19);
18794 var c1_hi = rotr64_hi(xl, xh, 29); // 61
18795 var c2_hi = shr64_hi(xh, xl, 6);
18796
18797 var r = c0_hi ^ c1_hi ^ c2_hi;
18798 if (r < 0)
18799 r += 0x100000000;
18800 return r;
18801}
18802
18803function g1_512_lo(xh, xl) {
18804 var c0_lo = rotr64_lo(xh, xl, 19);
18805 var c1_lo = rotr64_lo(xl, xh, 29); // 61
18806 var c2_lo = shr64_lo(xh, xl, 6);
18807
18808 var r = c0_lo ^ c1_lo ^ c2_lo;
18809 if (r < 0)
18810 r += 0x100000000;
18811 return r;
18812}
18813
18814},{"../common":246,"../utils":256,"minimalistic-assert":266}],255:[function(require,module,exports){
18815'use strict';
18816
18817var utils = require('../utils');
18818var rotr32 = utils.rotr32;
18819
18820function ft_1(s, x, y, z) {
18821 if (s === 0)
18822 return ch32(x, y, z);
18823 if (s === 1 || s === 3)
18824 return p32(x, y, z);
18825 if (s === 2)
18826 return maj32(x, y, z);
18827}
18828exports.ft_1 = ft_1;
18829
18830function ch32(x, y, z) {
18831 return (x & y) ^ ((~x) & z);
18832}
18833exports.ch32 = ch32;
18834
18835function maj32(x, y, z) {
18836 return (x & y) ^ (x & z) ^ (y & z);
18837}
18838exports.maj32 = maj32;
18839
18840function p32(x, y, z) {
18841 return x ^ y ^ z;
18842}
18843exports.p32 = p32;
18844
18845function s0_256(x) {
18846 return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
18847}
18848exports.s0_256 = s0_256;
18849
18850function s1_256(x) {
18851 return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
18852}
18853exports.s1_256 = s1_256;
18854
18855function g0_256(x) {
18856 return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);
18857}
18858exports.g0_256 = g0_256;
18859
18860function g1_256(x) {
18861 return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);
18862}
18863exports.g1_256 = g1_256;
18864
18865},{"../utils":256}],256:[function(require,module,exports){
18866'use strict';
18867
18868var assert = require('minimalistic-assert');
18869var inherits = require('inherits');
18870
18871exports.inherits = inherits;
18872
18873function toArray(msg, enc) {
18874 if (Array.isArray(msg))
18875 return msg.slice();
18876 if (!msg)
18877 return [];
18878 var res = [];
18879 if (typeof msg === 'string') {
18880 if (!enc) {
18881 for (var i = 0; i < msg.length; i++) {
18882 var c = msg.charCodeAt(i);
18883 var hi = c >> 8;
18884 var lo = c & 0xff;
18885 if (hi)
18886 res.push(hi, lo);
18887 else
18888 res.push(lo);
18889 }
18890 } else if (enc === 'hex') {
18891 msg = msg.replace(/[^a-z0-9]+/ig, '');
18892 if (msg.length % 2 !== 0)
18893 msg = '0' + msg;
18894 for (i = 0; i < msg.length; i += 2)
18895 res.push(parseInt(msg[i] + msg[i + 1], 16));
18896 }
18897 } else {
18898 for (i = 0; i < msg.length; i++)
18899 res[i] = msg[i] | 0;
18900 }
18901 return res;
18902}
18903exports.toArray = toArray;
18904
18905function toHex(msg) {
18906 var res = '';
18907 for (var i = 0; i < msg.length; i++)
18908 res += zero2(msg[i].toString(16));
18909 return res;
18910}
18911exports.toHex = toHex;
18912
18913function htonl(w) {
18914 var res = (w >>> 24) |
18915 ((w >>> 8) & 0xff00) |
18916 ((w << 8) & 0xff0000) |
18917 ((w & 0xff) << 24);
18918 return res >>> 0;
18919}
18920exports.htonl = htonl;
18921
18922function toHex32(msg, endian) {
18923 var res = '';
18924 for (var i = 0; i < msg.length; i++) {
18925 var w = msg[i];
18926 if (endian === 'little')
18927 w = htonl(w);
18928 res += zero8(w.toString(16));
18929 }
18930 return res;
18931}
18932exports.toHex32 = toHex32;
18933
18934function zero2(word) {
18935 if (word.length === 1)
18936 return '0' + word;
18937 else
18938 return word;
18939}
18940exports.zero2 = zero2;
18941
18942function zero8(word) {
18943 if (word.length === 7)
18944 return '0' + word;
18945 else if (word.length === 6)
18946 return '00' + word;
18947 else if (word.length === 5)
18948 return '000' + word;
18949 else if (word.length === 4)
18950 return '0000' + word;
18951 else if (word.length === 3)
18952 return '00000' + word;
18953 else if (word.length === 2)
18954 return '000000' + word;
18955 else if (word.length === 1)
18956 return '0000000' + word;
18957 else
18958 return word;
18959}
18960exports.zero8 = zero8;
18961
18962function join32(msg, start, end, endian) {
18963 var len = end - start;
18964 assert(len % 4 === 0);
18965 var res = new Array(len / 4);
18966 for (var i = 0, k = start; i < res.length; i++, k += 4) {
18967 var w;
18968 if (endian === 'big')
18969 w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
18970 else
18971 w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
18972 res[i] = w >>> 0;
18973 }
18974 return res;
18975}
18976exports.join32 = join32;
18977
18978function split32(msg, endian) {
18979 var res = new Array(msg.length * 4);
18980 for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
18981 var m = msg[i];
18982 if (endian === 'big') {
18983 res[k] = m >>> 24;
18984 res[k + 1] = (m >>> 16) & 0xff;
18985 res[k + 2] = (m >>> 8) & 0xff;
18986 res[k + 3] = m & 0xff;
18987 } else {
18988 res[k + 3] = m >>> 24;
18989 res[k + 2] = (m >>> 16) & 0xff;
18990 res[k + 1] = (m >>> 8) & 0xff;
18991 res[k] = m & 0xff;
18992 }
18993 }
18994 return res;
18995}
18996exports.split32 = split32;
18997
18998function rotr32(w, b) {
18999 return (w >>> b) | (w << (32 - b));
19000}
19001exports.rotr32 = rotr32;
19002
19003function rotl32(w, b) {
19004 return (w << b) | (w >>> (32 - b));
19005}
19006exports.rotl32 = rotl32;
19007
19008function sum32(a, b) {
19009 return (a + b) >>> 0;
19010}
19011exports.sum32 = sum32;
19012
19013function sum32_3(a, b, c) {
19014 return (a + b + c) >>> 0;
19015}
19016exports.sum32_3 = sum32_3;
19017
19018function sum32_4(a, b, c, d) {
19019 return (a + b + c + d) >>> 0;
19020}
19021exports.sum32_4 = sum32_4;
19022
19023function sum32_5(a, b, c, d, e) {
19024 return (a + b + c + d + e) >>> 0;
19025}
19026exports.sum32_5 = sum32_5;
19027
19028function sum64(buf, pos, ah, al) {
19029 var bh = buf[pos];
19030 var bl = buf[pos + 1];
19031
19032 var lo = (al + bl) >>> 0;
19033 var hi = (lo < al ? 1 : 0) + ah + bh;
19034 buf[pos] = hi >>> 0;
19035 buf[pos + 1] = lo;
19036}
19037exports.sum64 = sum64;
19038
19039function sum64_hi(ah, al, bh, bl) {
19040 var lo = (al + bl) >>> 0;
19041 var hi = (lo < al ? 1 : 0) + ah + bh;
19042 return hi >>> 0;
19043}
19044exports.sum64_hi = sum64_hi;
19045
19046function sum64_lo(ah, al, bh, bl) {
19047 var lo = al + bl;
19048 return lo >>> 0;
19049}
19050exports.sum64_lo = sum64_lo;
19051
19052function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) {
19053 var carry = 0;
19054 var lo = al;
19055 lo = (lo + bl) >>> 0;
19056 carry += lo < al ? 1 : 0;
19057 lo = (lo + cl) >>> 0;
19058 carry += lo < cl ? 1 : 0;
19059 lo = (lo + dl) >>> 0;
19060 carry += lo < dl ? 1 : 0;
19061
19062 var hi = ah + bh + ch + dh + carry;
19063 return hi >>> 0;
19064}
19065exports.sum64_4_hi = sum64_4_hi;
19066
19067function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) {
19068 var lo = al + bl + cl + dl;
19069 return lo >>> 0;
19070}
19071exports.sum64_4_lo = sum64_4_lo;
19072
19073function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
19074 var carry = 0;
19075 var lo = al;
19076 lo = (lo + bl) >>> 0;
19077 carry += lo < al ? 1 : 0;
19078 lo = (lo + cl) >>> 0;
19079 carry += lo < cl ? 1 : 0;
19080 lo = (lo + dl) >>> 0;
19081 carry += lo < dl ? 1 : 0;
19082 lo = (lo + el) >>> 0;
19083 carry += lo < el ? 1 : 0;
19084
19085 var hi = ah + bh + ch + dh + eh + carry;
19086 return hi >>> 0;
19087}
19088exports.sum64_5_hi = sum64_5_hi;
19089
19090function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
19091 var lo = al + bl + cl + dl + el;
19092
19093 return lo >>> 0;
19094}
19095exports.sum64_5_lo = sum64_5_lo;
19096
19097function rotr64_hi(ah, al, num) {
19098 var r = (al << (32 - num)) | (ah >>> num);
19099 return r >>> 0;
19100}
19101exports.rotr64_hi = rotr64_hi;
19102
19103function rotr64_lo(ah, al, num) {
19104 var r = (ah << (32 - num)) | (al >>> num);
19105 return r >>> 0;
19106}
19107exports.rotr64_lo = rotr64_lo;
19108
19109function shr64_hi(ah, al, num) {
19110 return ah >>> num;
19111}
19112exports.shr64_hi = shr64_hi;
19113
19114function shr64_lo(ah, al, num) {
19115 var r = (ah << (32 - num)) | (al >>> num);
19116 return r >>> 0;
19117}
19118exports.shr64_lo = shr64_lo;
19119
19120},{"inherits":260,"minimalistic-assert":266}],257:[function(require,module,exports){
19121'use strict';
19122
19123var hash = require('hash.js');
19124var utils = require('minimalistic-crypto-utils');
19125var assert = require('minimalistic-assert');
19126
19127function HmacDRBG(options) {
19128 if (!(this instanceof HmacDRBG))
19129 return new HmacDRBG(options);
19130 this.hash = options.hash;
19131 this.predResist = !!options.predResist;
19132
19133 this.outLen = this.hash.outSize;
19134 this.minEntropy = options.minEntropy || this.hash.hmacStrength;
19135
19136 this._reseed = null;
19137 this.reseedInterval = null;
19138 this.K = null;
19139 this.V = null;
19140
19141 var entropy = utils.toArray(options.entropy, options.entropyEnc || 'hex');
19142 var nonce = utils.toArray(options.nonce, options.nonceEnc || 'hex');
19143 var pers = utils.toArray(options.pers, options.persEnc || 'hex');
19144 assert(entropy.length >= (this.minEntropy / 8),
19145 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
19146 this._init(entropy, nonce, pers);
19147}
19148module.exports = HmacDRBG;
19149
19150HmacDRBG.prototype._init = function init(entropy, nonce, pers) {
19151 var seed = entropy.concat(nonce).concat(pers);
19152
19153 this.K = new Array(this.outLen / 8);
19154 this.V = new Array(this.outLen / 8);
19155 for (var i = 0; i < this.V.length; i++) {
19156 this.K[i] = 0x00;
19157 this.V[i] = 0x01;
19158 }
19159
19160 this._update(seed);
19161 this._reseed = 1;
19162 this.reseedInterval = 0x1000000000000; // 2^48
19163};
19164
19165HmacDRBG.prototype._hmac = function hmac() {
19166 return new hash.hmac(this.hash, this.K);
19167};
19168
19169HmacDRBG.prototype._update = function update(seed) {
19170 var kmac = this._hmac()
19171 .update(this.V)
19172 .update([ 0x00 ]);
19173 if (seed)
19174 kmac = kmac.update(seed);
19175 this.K = kmac.digest();
19176 this.V = this._hmac().update(this.V).digest();
19177 if (!seed)
19178 return;
19179
19180 this.K = this._hmac()
19181 .update(this.V)
19182 .update([ 0x01 ])
19183 .update(seed)
19184 .digest();
19185 this.V = this._hmac().update(this.V).digest();
19186};
19187
19188HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) {
19189 // Optional entropy enc
19190 if (typeof entropyEnc !== 'string') {
19191 addEnc = add;
19192 add = entropyEnc;
19193 entropyEnc = null;
19194 }
19195
19196 entropy = utils.toArray(entropy, entropyEnc);
19197 add = utils.toArray(add, addEnc);
19198
19199 assert(entropy.length >= (this.minEntropy / 8),
19200 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
19201
19202 this._update(entropy.concat(add || []));
19203 this._reseed = 1;
19204};
19205
19206HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) {
19207 if (this._reseed > this.reseedInterval)
19208 throw new Error('Reseed is required');
19209
19210 // Optional encoding
19211 if (typeof enc !== 'string') {
19212 addEnc = add;
19213 add = enc;
19214 enc = null;
19215 }
19216
19217 // Optional additional data
19218 if (add) {
19219 add = utils.toArray(add, addEnc || 'hex');
19220 this._update(add);
19221 }
19222
19223 var temp = [];
19224 while (temp.length < len) {
19225 this.V = this._hmac().update(this.V).digest();
19226 temp = temp.concat(this.V);
19227 }
19228
19229 var res = temp.slice(0, len);
19230 this._update(add);
19231 this._reseed++;
19232 return utils.encode(res, enc);
19233};
19234
19235},{"hash.js":245,"minimalistic-assert":266,"minimalistic-crypto-utils":267}],258:[function(require,module,exports){
19236exports.read = function (buffer, offset, isLE, mLen, nBytes) {
19237 var e, m
19238 var eLen = nBytes * 8 - mLen - 1
19239 var eMax = (1 << eLen) - 1
19240 var eBias = eMax >> 1
19241 var nBits = -7
19242 var i = isLE ? (nBytes - 1) : 0
19243 var d = isLE ? -1 : 1
19244 var s = buffer[offset + i]
19245
19246 i += d
19247
19248 e = s & ((1 << (-nBits)) - 1)
19249 s >>= (-nBits)
19250 nBits += eLen
19251 for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
19252
19253 m = e & ((1 << (-nBits)) - 1)
19254 e >>= (-nBits)
19255 nBits += mLen
19256 for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
19257
19258 if (e === 0) {
19259 e = 1 - eBias
19260 } else if (e === eMax) {
19261 return m ? NaN : ((s ? -1 : 1) * Infinity)
19262 } else {
19263 m = m + Math.pow(2, mLen)
19264 e = e - eBias
19265 }
19266 return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
19267}
19268
19269exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
19270 var e, m, c
19271 var eLen = nBytes * 8 - mLen - 1
19272 var eMax = (1 << eLen) - 1
19273 var eBias = eMax >> 1
19274 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
19275 var i = isLE ? 0 : (nBytes - 1)
19276 var d = isLE ? 1 : -1
19277 var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
19278
19279 value = Math.abs(value)
19280
19281 if (isNaN(value) || value === Infinity) {
19282 m = isNaN(value) ? 1 : 0
19283 e = eMax
19284 } else {
19285 e = Math.floor(Math.log(value) / Math.LN2)
19286 if (value * (c = Math.pow(2, -e)) < 1) {
19287 e--
19288 c *= 2
19289 }
19290 if (e + eBias >= 1) {
19291 value += rt / c
19292 } else {
19293 value += rt * Math.pow(2, 1 - eBias)
19294 }
19295 if (value * c >= 2) {
19296 e++
19297 c /= 2
19298 }
19299
19300 if (e + eBias >= eMax) {
19301 m = 0
19302 e = eMax
19303 } else if (e + eBias >= 1) {
19304 m = (value * c - 1) * Math.pow(2, mLen)
19305 e = e + eBias
19306 } else {
19307 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
19308 e = 0
19309 }
19310 }
19311
19312 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
19313
19314 e = (e << mLen) | m
19315 eLen += mLen
19316 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
19317
19318 buffer[offset + i - d] |= s * 128
19319}
19320
19321},{}],259:[function(require,module,exports){
19322
19323var indexOf = [].indexOf;
19324
19325module.exports = function(arr, obj){
19326 if (indexOf) return arr.indexOf(obj);
19327 for (var i = 0; i < arr.length; ++i) {
19328 if (arr[i] === obj) return i;
19329 }
19330 return -1;
19331};
19332},{}],260:[function(require,module,exports){
19333if (typeof Object.create === 'function') {
19334 // implementation from standard node.js 'util' module
19335 module.exports = function inherits(ctor, superCtor) {
19336 ctor.super_ = superCtor
19337 ctor.prototype = Object.create(superCtor.prototype, {
19338 constructor: {
19339 value: ctor,
19340 enumerable: false,
19341 writable: true,
19342 configurable: true
19343 }
19344 });
19345 };
19346} else {
19347 // old school shim for old browsers
19348 module.exports = function inherits(ctor, superCtor) {
19349 ctor.super_ = superCtor
19350 var TempCtor = function () {}
19351 TempCtor.prototype = superCtor.prototype
19352 ctor.prototype = new TempCtor()
19353 ctor.prototype.constructor = ctor
19354 }
19355}
19356
19357},{}],261:[function(require,module,exports){
19358/*!
19359 * Determine if an object is a Buffer
19360 *
19361 * @author Feross Aboukhadijeh <https://feross.org>
19362 * @license MIT
19363 */
19364
19365// The _isBuffer check is for Safari 5-7 support, because it's missing
19366// Object.prototype.constructor. Remove this eventually
19367module.exports = function (obj) {
19368 return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
19369}
19370
19371function isBuffer (obj) {
19372 return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
19373}
19374
19375// For Node v0.10 support. Remove this eventually.
19376function isSlowBuffer (obj) {
19377 return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
19378}
19379
19380},{}],262:[function(require,module,exports){
19381var toString = {}.toString;
19382
19383module.exports = Array.isArray || function (arr) {
19384 return toString.call(arr) == '[object Array]';
19385};
19386
19387},{}],263:[function(require,module,exports){
19388(function (Buffer){
19389'use strict'
19390var inherits = require('inherits')
19391var HashBase = require('hash-base')
19392
19393var ARRAY16 = new Array(16)
19394
19395function MD5 () {
19396 HashBase.call(this, 64)
19397
19398 // state
19399 this._a = 0x67452301
19400 this._b = 0xefcdab89
19401 this._c = 0x98badcfe
19402 this._d = 0x10325476
19403}
19404
19405inherits(MD5, HashBase)
19406
19407MD5.prototype._update = function () {
19408 var M = ARRAY16
19409 for (var i = 0; i < 16; ++i) M[i] = this._block.readInt32LE(i * 4)
19410
19411 var a = this._a
19412 var b = this._b
19413 var c = this._c
19414 var d = this._d
19415
19416 a = fnF(a, b, c, d, M[0], 0xd76aa478, 7)
19417 d = fnF(d, a, b, c, M[1], 0xe8c7b756, 12)
19418 c = fnF(c, d, a, b, M[2], 0x242070db, 17)
19419 b = fnF(b, c, d, a, M[3], 0xc1bdceee, 22)
19420 a = fnF(a, b, c, d, M[4], 0xf57c0faf, 7)
19421 d = fnF(d, a, b, c, M[5], 0x4787c62a, 12)
19422 c = fnF(c, d, a, b, M[6], 0xa8304613, 17)
19423 b = fnF(b, c, d, a, M[7], 0xfd469501, 22)
19424 a = fnF(a, b, c, d, M[8], 0x698098d8, 7)
19425 d = fnF(d, a, b, c, M[9], 0x8b44f7af, 12)
19426 c = fnF(c, d, a, b, M[10], 0xffff5bb1, 17)
19427 b = fnF(b, c, d, a, M[11], 0x895cd7be, 22)
19428 a = fnF(a, b, c, d, M[12], 0x6b901122, 7)
19429 d = fnF(d, a, b, c, M[13], 0xfd987193, 12)
19430 c = fnF(c, d, a, b, M[14], 0xa679438e, 17)
19431 b = fnF(b, c, d, a, M[15], 0x49b40821, 22)
19432
19433 a = fnG(a, b, c, d, M[1], 0xf61e2562, 5)
19434 d = fnG(d, a, b, c, M[6], 0xc040b340, 9)
19435 c = fnG(c, d, a, b, M[11], 0x265e5a51, 14)
19436 b = fnG(b, c, d, a, M[0], 0xe9b6c7aa, 20)
19437 a = fnG(a, b, c, d, M[5], 0xd62f105d, 5)
19438 d = fnG(d, a, b, c, M[10], 0x02441453, 9)
19439 c = fnG(c, d, a, b, M[15], 0xd8a1e681, 14)
19440 b = fnG(b, c, d, a, M[4], 0xe7d3fbc8, 20)
19441 a = fnG(a, b, c, d, M[9], 0x21e1cde6, 5)
19442 d = fnG(d, a, b, c, M[14], 0xc33707d6, 9)
19443 c = fnG(c, d, a, b, M[3], 0xf4d50d87, 14)
19444 b = fnG(b, c, d, a, M[8], 0x455a14ed, 20)
19445 a = fnG(a, b, c, d, M[13], 0xa9e3e905, 5)
19446 d = fnG(d, a, b, c, M[2], 0xfcefa3f8, 9)
19447 c = fnG(c, d, a, b, M[7], 0x676f02d9, 14)
19448 b = fnG(b, c, d, a, M[12], 0x8d2a4c8a, 20)
19449
19450 a = fnH(a, b, c, d, M[5], 0xfffa3942, 4)
19451 d = fnH(d, a, b, c, M[8], 0x8771f681, 11)
19452 c = fnH(c, d, a, b, M[11], 0x6d9d6122, 16)
19453 b = fnH(b, c, d, a, M[14], 0xfde5380c, 23)
19454 a = fnH(a, b, c, d, M[1], 0xa4beea44, 4)
19455 d = fnH(d, a, b, c, M[4], 0x4bdecfa9, 11)
19456 c = fnH(c, d, a, b, M[7], 0xf6bb4b60, 16)
19457 b = fnH(b, c, d, a, M[10], 0xbebfbc70, 23)
19458 a = fnH(a, b, c, d, M[13], 0x289b7ec6, 4)
19459 d = fnH(d, a, b, c, M[0], 0xeaa127fa, 11)
19460 c = fnH(c, d, a, b, M[3], 0xd4ef3085, 16)
19461 b = fnH(b, c, d, a, M[6], 0x04881d05, 23)
19462 a = fnH(a, b, c, d, M[9], 0xd9d4d039, 4)
19463 d = fnH(d, a, b, c, M[12], 0xe6db99e5, 11)
19464 c = fnH(c, d, a, b, M[15], 0x1fa27cf8, 16)
19465 b = fnH(b, c, d, a, M[2], 0xc4ac5665, 23)
19466
19467 a = fnI(a, b, c, d, M[0], 0xf4292244, 6)
19468 d = fnI(d, a, b, c, M[7], 0x432aff97, 10)
19469 c = fnI(c, d, a, b, M[14], 0xab9423a7, 15)
19470 b = fnI(b, c, d, a, M[5], 0xfc93a039, 21)
19471 a = fnI(a, b, c, d, M[12], 0x655b59c3, 6)
19472 d = fnI(d, a, b, c, M[3], 0x8f0ccc92, 10)
19473 c = fnI(c, d, a, b, M[10], 0xffeff47d, 15)
19474 b = fnI(b, c, d, a, M[1], 0x85845dd1, 21)
19475 a = fnI(a, b, c, d, M[8], 0x6fa87e4f, 6)
19476 d = fnI(d, a, b, c, M[15], 0xfe2ce6e0, 10)
19477 c = fnI(c, d, a, b, M[6], 0xa3014314, 15)
19478 b = fnI(b, c, d, a, M[13], 0x4e0811a1, 21)
19479 a = fnI(a, b, c, d, M[4], 0xf7537e82, 6)
19480 d = fnI(d, a, b, c, M[11], 0xbd3af235, 10)
19481 c = fnI(c, d, a, b, M[2], 0x2ad7d2bb, 15)
19482 b = fnI(b, c, d, a, M[9], 0xeb86d391, 21)
19483
19484 this._a = (this._a + a) | 0
19485 this._b = (this._b + b) | 0
19486 this._c = (this._c + c) | 0
19487 this._d = (this._d + d) | 0
19488}
19489
19490MD5.prototype._digest = function () {
19491 // create padding and handle blocks
19492 this._block[this._blockOffset++] = 0x80
19493 if (this._blockOffset > 56) {
19494 this._block.fill(0, this._blockOffset, 64)
19495 this._update()
19496 this._blockOffset = 0
19497 }
19498
19499 this._block.fill(0, this._blockOffset, 56)
19500 this._block.writeUInt32LE(this._length[0], 56)
19501 this._block.writeUInt32LE(this._length[1], 60)
19502 this._update()
19503
19504 // produce result
19505 var buffer = new Buffer(16)
19506 buffer.writeInt32LE(this._a, 0)
19507 buffer.writeInt32LE(this._b, 4)
19508 buffer.writeInt32LE(this._c, 8)
19509 buffer.writeInt32LE(this._d, 12)
19510 return buffer
19511}
19512
19513function rotl (x, n) {
19514 return (x << n) | (x >>> (32 - n))
19515}
19516
19517function fnF (a, b, c, d, m, k, s) {
19518 return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + b) | 0
19519}
19520
19521function fnG (a, b, c, d, m, k, s) {
19522 return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + b) | 0
19523}
19524
19525function fnH (a, b, c, d, m, k, s) {
19526 return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + b) | 0
19527}
19528
19529function fnI (a, b, c, d, m, k, s) {
19530 return (rotl((a + ((c ^ (b | (~d)))) + m + k) | 0, s) + b) | 0
19531}
19532
19533module.exports = MD5
19534
19535}).call(this,require("buffer").Buffer)
19536},{"buffer":75,"hash-base":264,"inherits":260}],264:[function(require,module,exports){
19537'use strict'
19538var Buffer = require('safe-buffer').Buffer
19539var Transform = require('stream').Transform
19540var inherits = require('inherits')
19541
19542function throwIfNotStringOrBuffer (val, prefix) {
19543 if (!Buffer.isBuffer(val) && typeof val !== 'string') {
19544 throw new TypeError(prefix + ' must be a string or a buffer')
19545 }
19546}
19547
19548function HashBase (blockSize) {
19549 Transform.call(this)
19550
19551 this._block = Buffer.allocUnsafe(blockSize)
19552 this._blockSize = blockSize
19553 this._blockOffset = 0
19554 this._length = [0, 0, 0, 0]
19555
19556 this._finalized = false
19557}
19558
19559inherits(HashBase, Transform)
19560
19561HashBase.prototype._transform = function (chunk, encoding, callback) {
19562 var error = null
19563 try {
19564 this.update(chunk, encoding)
19565 } catch (err) {
19566 error = err
19567 }
19568
19569 callback(error)
19570}
19571
19572HashBase.prototype._flush = function (callback) {
19573 var error = null
19574 try {
19575 this.push(this.digest())
19576 } catch (err) {
19577 error = err
19578 }
19579
19580 callback(error)
19581}
19582
19583HashBase.prototype.update = function (data, encoding) {
19584 throwIfNotStringOrBuffer(data, 'Data')
19585 if (this._finalized) throw new Error('Digest already called')
19586 if (!Buffer.isBuffer(data)) data = Buffer.from(data, encoding)
19587
19588 // consume data
19589 var block = this._block
19590 var offset = 0
19591 while (this._blockOffset + data.length - offset >= this._blockSize) {
19592 for (var i = this._blockOffset; i < this._blockSize;) block[i++] = data[offset++]
19593 this._update()
19594 this._blockOffset = 0
19595 }
19596 while (offset < data.length) block[this._blockOffset++] = data[offset++]
19597
19598 // update length
19599 for (var j = 0, carry = data.length * 8; carry > 0; ++j) {
19600 this._length[j] += carry
19601 carry = (this._length[j] / 0x0100000000) | 0
19602 if (carry > 0) this._length[j] -= 0x0100000000 * carry
19603 }
19604
19605 return this
19606}
19607
19608HashBase.prototype._update = function () {
19609 throw new Error('_update is not implemented')
19610}
19611
19612HashBase.prototype.digest = function (encoding) {
19613 if (this._finalized) throw new Error('Digest already called')
19614 this._finalized = true
19615
19616 var digest = this._digest()
19617 if (encoding !== undefined) digest = digest.toString(encoding)
19618
19619 // reset state
19620 this._block.fill(0)
19621 this._blockOffset = 0
19622 for (var i = 0; i < 4; ++i) this._length[i] = 0
19623
19624 return digest
19625}
19626
19627HashBase.prototype._digest = function () {
19628 throw new Error('_digest is not implemented')
19629}
19630
19631module.exports = HashBase
19632
19633},{"inherits":260,"safe-buffer":305,"stream":314}],265:[function(require,module,exports){
19634var bn = require('bn.js');
19635var brorand = require('brorand');
19636
19637function MillerRabin(rand) {
19638 this.rand = rand || new brorand.Rand();
19639}
19640module.exports = MillerRabin;
19641
19642MillerRabin.create = function create(rand) {
19643 return new MillerRabin(rand);
19644};
19645
19646MillerRabin.prototype._randbelow = function _randbelow(n) {
19647 var len = n.bitLength();
19648 var min_bytes = Math.ceil(len / 8);
19649
19650 // Generage random bytes until a number less than n is found.
19651 // This ensures that 0..n-1 have an equal probability of being selected.
19652 do
19653 var a = new bn(this.rand.generate(min_bytes));
19654 while (a.cmp(n) >= 0);
19655
19656 return a;
19657};
19658
19659MillerRabin.prototype._randrange = function _randrange(start, stop) {
19660 // Generate a random number greater than or equal to start and less than stop.
19661 var size = stop.sub(start);
19662 return start.add(this._randbelow(size));
19663};
19664
19665MillerRabin.prototype.test = function test(n, k, cb) {
19666 var len = n.bitLength();
19667 var red = bn.mont(n);
19668 var rone = new bn(1).toRed(red);
19669
19670 if (!k)
19671 k = Math.max(1, (len / 48) | 0);
19672
19673 // Find d and s, (n - 1) = (2 ^ s) * d;
19674 var n1 = n.subn(1);
19675 for (var s = 0; !n1.testn(s); s++) {}
19676 var d = n.shrn(s);
19677
19678 var rn1 = n1.toRed(red);
19679
19680 var prime = true;
19681 for (; k > 0; k--) {
19682 var a = this._randrange(new bn(2), n1);
19683 if (cb)
19684 cb(a);
19685
19686 var x = a.toRed(red).redPow(d);
19687 if (x.cmp(rone) === 0 || x.cmp(rn1) === 0)
19688 continue;
19689
19690 for (var i = 1; i < s; i++) {
19691 x = x.redSqr();
19692
19693 if (x.cmp(rone) === 0)
19694 return false;
19695 if (x.cmp(rn1) === 0)
19696 break;
19697 }
19698
19699 if (i === s)
19700 return false;
19701 }
19702
19703 return prime;
19704};
19705
19706MillerRabin.prototype.getDivisor = function getDivisor(n, k) {
19707 var len = n.bitLength();
19708 var red = bn.mont(n);
19709 var rone = new bn(1).toRed(red);
19710
19711 if (!k)
19712 k = Math.max(1, (len / 48) | 0);
19713
19714 // Find d and s, (n - 1) = (2 ^ s) * d;
19715 var n1 = n.subn(1);
19716 for (var s = 0; !n1.testn(s); s++) {}
19717 var d = n.shrn(s);
19718
19719 var rn1 = n1.toRed(red);
19720
19721 for (; k > 0; k--) {
19722 var a = this._randrange(new bn(2), n1);
19723
19724 var g = n.gcd(a);
19725 if (g.cmpn(1) !== 0)
19726 return g;
19727
19728 var x = a.toRed(red).redPow(d);
19729 if (x.cmp(rone) === 0 || x.cmp(rn1) === 0)
19730 continue;
19731
19732 for (var i = 1; i < s; i++) {
19733 x = x.redSqr();
19734
19735 if (x.cmp(rone) === 0)
19736 return x.fromRed().subn(1).gcd(n);
19737 if (x.cmp(rn1) === 0)
19738 break;
19739 }
19740
19741 if (i === s) {
19742 x = x.redSqr();
19743 return x.fromRed().subn(1).gcd(n);
19744 }
19745 }
19746
19747 return false;
19748};
19749
19750},{"bn.js":43,"brorand":44}],266:[function(require,module,exports){
19751module.exports = assert;
19752
19753function assert(val, msg) {
19754 if (!val)
19755 throw new Error(msg || 'Assertion failed');
19756}
19757
19758assert.equal = function assertEqual(l, r, msg) {
19759 if (l != r)
19760 throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
19761};
19762
19763},{}],267:[function(require,module,exports){
19764'use strict';
19765
19766var utils = exports;
19767
19768function toArray(msg, enc) {
19769 if (Array.isArray(msg))
19770 return msg.slice();
19771 if (!msg)
19772 return [];
19773 var res = [];
19774 if (typeof msg !== 'string') {
19775 for (var i = 0; i < msg.length; i++)
19776 res[i] = msg[i] | 0;
19777 return res;
19778 }
19779 if (enc === 'hex') {
19780 msg = msg.replace(/[^a-z0-9]+/ig, '');
19781 if (msg.length % 2 !== 0)
19782 msg = '0' + msg;
19783 for (var i = 0; i < msg.length; i += 2)
19784 res.push(parseInt(msg[i] + msg[i + 1], 16));
19785 } else {
19786 for (var i = 0; i < msg.length; i++) {
19787 var c = msg.charCodeAt(i);
19788 var hi = c >> 8;
19789 var lo = c & 0xff;
19790 if (hi)
19791 res.push(hi, lo);
19792 else
19793 res.push(lo);
19794 }
19795 }
19796 return res;
19797}
19798utils.toArray = toArray;
19799
19800function zero2(word) {
19801 if (word.length === 1)
19802 return '0' + word;
19803 else
19804 return word;
19805}
19806utils.zero2 = zero2;
19807
19808function toHex(msg) {
19809 var res = '';
19810 for (var i = 0; i < msg.length; i++)
19811 res += zero2(msg[i].toString(16));
19812 return res;
19813}
19814utils.toHex = toHex;
19815
19816utils.encode = function encode(arr, enc) {
19817 if (enc === 'hex')
19818 return toHex(arr);
19819 else
19820 return arr;
19821};
19822
19823},{}],268:[function(require,module,exports){
19824exports.endianness = function () { return 'LE' };
19825
19826exports.hostname = function () {
19827 if (typeof location !== 'undefined') {
19828 return location.hostname
19829 }
19830 else return '';
19831};
19832
19833exports.loadavg = function () { return [] };
19834
19835exports.uptime = function () { return 0 };
19836
19837exports.freemem = function () {
19838 return Number.MAX_VALUE;
19839};
19840
19841exports.totalmem = function () {
19842 return Number.MAX_VALUE;
19843};
19844
19845exports.cpus = function () { return [] };
19846
19847exports.type = function () { return 'Browser' };
19848
19849exports.release = function () {
19850 if (typeof navigator !== 'undefined') {
19851 return navigator.appVersion;
19852 }
19853 return '';
19854};
19855
19856exports.networkInterfaces
19857= exports.getNetworkInterfaces
19858= function () { return {} };
19859
19860exports.arch = function () { return 'javascript' };
19861
19862exports.platform = function () { return 'browser' };
19863
19864exports.tmpdir = exports.tmpDir = function () {
19865 return '/tmp';
19866};
19867
19868exports.EOL = '\n';
19869
19870},{}],269:[function(require,module,exports){
19871module.exports={"2.16.840.1.101.3.4.1.1": "aes-128-ecb",
19872"2.16.840.1.101.3.4.1.2": "aes-128-cbc",
19873"2.16.840.1.101.3.4.1.3": "aes-128-ofb",
19874"2.16.840.1.101.3.4.1.4": "aes-128-cfb",
19875"2.16.840.1.101.3.4.1.21": "aes-192-ecb",
19876"2.16.840.1.101.3.4.1.22": "aes-192-cbc",
19877"2.16.840.1.101.3.4.1.23": "aes-192-ofb",
19878"2.16.840.1.101.3.4.1.24": "aes-192-cfb",
19879"2.16.840.1.101.3.4.1.41": "aes-256-ecb",
19880"2.16.840.1.101.3.4.1.42": "aes-256-cbc",
19881"2.16.840.1.101.3.4.1.43": "aes-256-ofb",
19882"2.16.840.1.101.3.4.1.44": "aes-256-cfb"
19883}
19884},{}],270:[function(require,module,exports){
19885// from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js
19886// Fedor, you are amazing.
19887'use strict'
19888
19889var asn1 = require('asn1.js')
19890
19891exports.certificate = require('./certificate')
19892
19893var RSAPrivateKey = asn1.define('RSAPrivateKey', function () {
19894 this.seq().obj(
19895 this.key('version').int(),
19896 this.key('modulus').int(),
19897 this.key('publicExponent').int(),
19898 this.key('privateExponent').int(),
19899 this.key('prime1').int(),
19900 this.key('prime2').int(),
19901 this.key('exponent1').int(),
19902 this.key('exponent2').int(),
19903 this.key('coefficient').int()
19904 )
19905})
19906exports.RSAPrivateKey = RSAPrivateKey
19907
19908var RSAPublicKey = asn1.define('RSAPublicKey', function () {
19909 this.seq().obj(
19910 this.key('modulus').int(),
19911 this.key('publicExponent').int()
19912 )
19913})
19914exports.RSAPublicKey = RSAPublicKey
19915
19916var PublicKey = asn1.define('SubjectPublicKeyInfo', function () {
19917 this.seq().obj(
19918 this.key('algorithm').use(AlgorithmIdentifier),
19919 this.key('subjectPublicKey').bitstr()
19920 )
19921})
19922exports.PublicKey = PublicKey
19923
19924var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function () {
19925 this.seq().obj(
19926 this.key('algorithm').objid(),
19927 this.key('none').null_().optional(),
19928 this.key('curve').objid().optional(),
19929 this.key('params').seq().obj(
19930 this.key('p').int(),
19931 this.key('q').int(),
19932 this.key('g').int()
19933 ).optional()
19934 )
19935})
19936
19937var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function () {
19938 this.seq().obj(
19939 this.key('version').int(),
19940 this.key('algorithm').use(AlgorithmIdentifier),
19941 this.key('subjectPrivateKey').octstr()
19942 )
19943})
19944exports.PrivateKey = PrivateKeyInfo
19945var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function () {
19946 this.seq().obj(
19947 this.key('algorithm').seq().obj(
19948 this.key('id').objid(),
19949 this.key('decrypt').seq().obj(
19950 this.key('kde').seq().obj(
19951 this.key('id').objid(),
19952 this.key('kdeparams').seq().obj(
19953 this.key('salt').octstr(),
19954 this.key('iters').int()
19955 )
19956 ),
19957 this.key('cipher').seq().obj(
19958 this.key('algo').objid(),
19959 this.key('iv').octstr()
19960 )
19961 )
19962 ),
19963 this.key('subjectPrivateKey').octstr()
19964 )
19965})
19966
19967exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo
19968
19969var DSAPrivateKey = asn1.define('DSAPrivateKey', function () {
19970 this.seq().obj(
19971 this.key('version').int(),
19972 this.key('p').int(),
19973 this.key('q').int(),
19974 this.key('g').int(),
19975 this.key('pub_key').int(),
19976 this.key('priv_key').int()
19977 )
19978})
19979exports.DSAPrivateKey = DSAPrivateKey
19980
19981exports.DSAparam = asn1.define('DSAparam', function () {
19982 this.int()
19983})
19984
19985var ECPrivateKey = asn1.define('ECPrivateKey', function () {
19986 this.seq().obj(
19987 this.key('version').int(),
19988 this.key('privateKey').octstr(),
19989 this.key('parameters').optional().explicit(0).use(ECParameters),
19990 this.key('publicKey').optional().explicit(1).bitstr()
19991 )
19992})
19993exports.ECPrivateKey = ECPrivateKey
19994
19995var ECParameters = asn1.define('ECParameters', function () {
19996 this.choice({
19997 namedCurve: this.objid()
19998 })
19999})
20000
20001exports.signature = asn1.define('signature', function () {
20002 this.seq().obj(
20003 this.key('r').int(),
20004 this.key('s').int()
20005 )
20006})
20007
20008},{"./certificate":271,"asn1.js":1}],271:[function(require,module,exports){
20009// from https://github.com/Rantanen/node-dtls/blob/25a7dc861bda38cfeac93a723500eea4f0ac2e86/Certificate.js
20010// thanks to @Rantanen
20011
20012'use strict'
20013
20014var asn = require('asn1.js')
20015
20016var Time = asn.define('Time', function () {
20017 this.choice({
20018 utcTime: this.utctime(),
20019 generalTime: this.gentime()
20020 })
20021})
20022
20023var AttributeTypeValue = asn.define('AttributeTypeValue', function () {
20024 this.seq().obj(
20025 this.key('type').objid(),
20026 this.key('value').any()
20027 )
20028})
20029
20030var AlgorithmIdentifier = asn.define('AlgorithmIdentifier', function () {
20031 this.seq().obj(
20032 this.key('algorithm').objid(),
20033 this.key('parameters').optional()
20034 )
20035})
20036
20037var SubjectPublicKeyInfo = asn.define('SubjectPublicKeyInfo', function () {
20038 this.seq().obj(
20039 this.key('algorithm').use(AlgorithmIdentifier),
20040 this.key('subjectPublicKey').bitstr()
20041 )
20042})
20043
20044var RelativeDistinguishedName = asn.define('RelativeDistinguishedName', function () {
20045 this.setof(AttributeTypeValue)
20046})
20047
20048var RDNSequence = asn.define('RDNSequence', function () {
20049 this.seqof(RelativeDistinguishedName)
20050})
20051
20052var Name = asn.define('Name', function () {
20053 this.choice({
20054 rdnSequence: this.use(RDNSequence)
20055 })
20056})
20057
20058var Validity = asn.define('Validity', function () {
20059 this.seq().obj(
20060 this.key('notBefore').use(Time),
20061 this.key('notAfter').use(Time)
20062 )
20063})
20064
20065var Extension = asn.define('Extension', function () {
20066 this.seq().obj(
20067 this.key('extnID').objid(),
20068 this.key('critical').bool().def(false),
20069 this.key('extnValue').octstr()
20070 )
20071})
20072
20073var TBSCertificate = asn.define('TBSCertificate', function () {
20074 this.seq().obj(
20075 this.key('version').explicit(0).int(),
20076 this.key('serialNumber').int(),
20077 this.key('signature').use(AlgorithmIdentifier),
20078 this.key('issuer').use(Name),
20079 this.key('validity').use(Validity),
20080 this.key('subject').use(Name),
20081 this.key('subjectPublicKeyInfo').use(SubjectPublicKeyInfo),
20082 this.key('issuerUniqueID').implicit(1).bitstr().optional(),
20083 this.key('subjectUniqueID').implicit(2).bitstr().optional(),
20084 this.key('extensions').explicit(3).seqof(Extension).optional()
20085 )
20086})
20087
20088var X509Certificate = asn.define('X509Certificate', function () {
20089 this.seq().obj(
20090 this.key('tbsCertificate').use(TBSCertificate),
20091 this.key('signatureAlgorithm').use(AlgorithmIdentifier),
20092 this.key('signatureValue').bitstr()
20093 )
20094})
20095
20096module.exports = X509Certificate
20097
20098},{"asn1.js":1}],272:[function(require,module,exports){
20099(function (Buffer){
20100// adapted from https://github.com/apatil/pemstrip
20101var findProc = /Proc-Type: 4,ENCRYPTED\n\r?DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)\n\r?\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?/m
20102var startRegex = /^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n/m
20103var fullRegex = /^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?-----END \1-----$/m
20104var evp = require('evp_bytestokey')
20105var ciphers = require('browserify-aes')
20106module.exports = function (okey, password) {
20107 var key = okey.toString()
20108 var match = key.match(findProc)
20109 var decrypted
20110 if (!match) {
20111 var match2 = key.match(fullRegex)
20112 decrypted = new Buffer(match2[2].replace(/\r?\n/g, ''), 'base64')
20113 } else {
20114 var suite = 'aes' + match[1]
20115 var iv = new Buffer(match[2], 'hex')
20116 var cipherText = new Buffer(match[3].replace(/\r?\n/g, ''), 'base64')
20117 var cipherKey = evp(password, iv.slice(0, 8), parseInt(match[1], 10)).key
20118 var out = []
20119 var cipher = ciphers.createDecipheriv(suite, cipherKey, iv)
20120 out.push(cipher.update(cipherText))
20121 out.push(cipher.final())
20122 decrypted = Buffer.concat(out)
20123 }
20124 var tag = key.match(startRegex)[1]
20125 return {
20126 tag: tag,
20127 data: decrypted
20128 }
20129}
20130
20131}).call(this,require("buffer").Buffer)
20132},{"browserify-aes":48,"buffer":75,"evp_bytestokey":243}],273:[function(require,module,exports){
20133(function (Buffer){
20134var asn1 = require('./asn1')
20135var aesid = require('./aesid.json')
20136var fixProc = require('./fixProc')
20137var ciphers = require('browserify-aes')
20138var compat = require('pbkdf2')
20139module.exports = parseKeys
20140
20141function parseKeys (buffer) {
20142 var password
20143 if (typeof buffer === 'object' && !Buffer.isBuffer(buffer)) {
20144 password = buffer.passphrase
20145 buffer = buffer.key
20146 }
20147 if (typeof buffer === 'string') {
20148 buffer = new Buffer(buffer)
20149 }
20150
20151 var stripped = fixProc(buffer, password)
20152
20153 var type = stripped.tag
20154 var data = stripped.data
20155 var subtype, ndata
20156 switch (type) {
20157 case 'CERTIFICATE':
20158 ndata = asn1.certificate.decode(data, 'der').tbsCertificate.subjectPublicKeyInfo
20159 // falls through
20160 case 'PUBLIC KEY':
20161 if (!ndata) {
20162 ndata = asn1.PublicKey.decode(data, 'der')
20163 }
20164 subtype = ndata.algorithm.algorithm.join('.')
20165 switch (subtype) {
20166 case '1.2.840.113549.1.1.1':
20167 return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data, 'der')
20168 case '1.2.840.10045.2.1':
20169 ndata.subjectPrivateKey = ndata.subjectPublicKey
20170 return {
20171 type: 'ec',
20172 data: ndata
20173 }
20174 case '1.2.840.10040.4.1':
20175 ndata.algorithm.params.pub_key = asn1.DSAparam.decode(ndata.subjectPublicKey.data, 'der')
20176 return {
20177 type: 'dsa',
20178 data: ndata.algorithm.params
20179 }
20180 default: throw new Error('unknown key id ' + subtype)
20181 }
20182 throw new Error('unknown key type ' + type)
20183 case 'ENCRYPTED PRIVATE KEY':
20184 data = asn1.EncryptedPrivateKey.decode(data, 'der')
20185 data = decrypt(data, password)
20186 // falls through
20187 case 'PRIVATE KEY':
20188 ndata = asn1.PrivateKey.decode(data, 'der')
20189 subtype = ndata.algorithm.algorithm.join('.')
20190 switch (subtype) {
20191 case '1.2.840.113549.1.1.1':
20192 return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey, 'der')
20193 case '1.2.840.10045.2.1':
20194 return {
20195 curve: ndata.algorithm.curve,
20196 privateKey: asn1.ECPrivateKey.decode(ndata.subjectPrivateKey, 'der').privateKey
20197 }
20198 case '1.2.840.10040.4.1':
20199 ndata.algorithm.params.priv_key = asn1.DSAparam.decode(ndata.subjectPrivateKey, 'der')
20200 return {
20201 type: 'dsa',
20202 params: ndata.algorithm.params
20203 }
20204 default: throw new Error('unknown key id ' + subtype)
20205 }
20206 throw new Error('unknown key type ' + type)
20207 case 'RSA PUBLIC KEY':
20208 return asn1.RSAPublicKey.decode(data, 'der')
20209 case 'RSA PRIVATE KEY':
20210 return asn1.RSAPrivateKey.decode(data, 'der')
20211 case 'DSA PRIVATE KEY':
20212 return {
20213 type: 'dsa',
20214 params: asn1.DSAPrivateKey.decode(data, 'der')
20215 }
20216 case 'EC PRIVATE KEY':
20217 data = asn1.ECPrivateKey.decode(data, 'der')
20218 return {
20219 curve: data.parameters.value,
20220 privateKey: data.privateKey
20221 }
20222 default: throw new Error('unknown key type ' + type)
20223 }
20224}
20225parseKeys.signature = asn1.signature
20226function decrypt (data, password) {
20227 var salt = data.algorithm.decrypt.kde.kdeparams.salt
20228 var iters = parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(), 10)
20229 var algo = aesid[data.algorithm.decrypt.cipher.algo.join('.')]
20230 var iv = data.algorithm.decrypt.cipher.iv
20231 var cipherText = data.subjectPrivateKey
20232 var keylen = parseInt(algo.split('-')[1], 10) / 8
20233 var key = compat.pbkdf2Sync(password, salt, iters, keylen)
20234 var cipher = ciphers.createDecipheriv(algo, key, iv)
20235 var out = []
20236 out.push(cipher.update(cipherText))
20237 out.push(cipher.final())
20238 return Buffer.concat(out)
20239}
20240
20241}).call(this,require("buffer").Buffer)
20242},{"./aesid.json":269,"./asn1":270,"./fixProc":272,"browserify-aes":48,"buffer":75,"pbkdf2":275}],274:[function(require,module,exports){
20243(function (process){
20244// Copyright Joyent, Inc. and other Node contributors.
20245//
20246// Permission is hereby granted, free of charge, to any person obtaining a
20247// copy of this software and associated documentation files (the
20248// "Software"), to deal in the Software without restriction, including
20249// without limitation the rights to use, copy, modify, merge, publish,
20250// distribute, sublicense, and/or sell copies of the Software, and to permit
20251// persons to whom the Software is furnished to do so, subject to the
20252// following conditions:
20253//
20254// The above copyright notice and this permission notice shall be included
20255// in all copies or substantial portions of the Software.
20256//
20257// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20258// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20259// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
20260// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20261// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20262// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20263// USE OR OTHER DEALINGS IN THE SOFTWARE.
20264
20265// resolves . and .. elements in a path array with directory names there
20266// must be no slashes, empty elements, or device names (c:\) in the array
20267// (so also no leading and trailing slashes - it does not distinguish
20268// relative and absolute paths)
20269function normalizeArray(parts, allowAboveRoot) {
20270 // if the path tries to go above the root, `up` ends up > 0
20271 var up = 0;
20272 for (var i = parts.length - 1; i >= 0; i--) {
20273 var last = parts[i];
20274 if (last === '.') {
20275 parts.splice(i, 1);
20276 } else if (last === '..') {
20277 parts.splice(i, 1);
20278 up++;
20279 } else if (up) {
20280 parts.splice(i, 1);
20281 up--;
20282 }
20283 }
20284
20285 // if the path is allowed to go above the root, restore leading ..s
20286 if (allowAboveRoot) {
20287 for (; up--; up) {
20288 parts.unshift('..');
20289 }
20290 }
20291
20292 return parts;
20293}
20294
20295// Split a filename into [root, dir, basename, ext], unix version
20296// 'root' is just a slash, or nothing.
20297var splitPathRe =
20298 /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
20299var splitPath = function(filename) {
20300 return splitPathRe.exec(filename).slice(1);
20301};
20302
20303// path.resolve([from ...], to)
20304// posix version
20305exports.resolve = function() {
20306 var resolvedPath = '',
20307 resolvedAbsolute = false;
20308
20309 for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
20310 var path = (i >= 0) ? arguments[i] : process.cwd();
20311
20312 // Skip empty and invalid entries
20313 if (typeof path !== 'string') {
20314 throw new TypeError('Arguments to path.resolve must be strings');
20315 } else if (!path) {
20316 continue;
20317 }
20318
20319 resolvedPath = path + '/' + resolvedPath;
20320 resolvedAbsolute = path.charAt(0) === '/';
20321 }
20322
20323 // At this point the path should be resolved to a full absolute path, but
20324 // handle relative paths to be safe (might happen when process.cwd() fails)
20325
20326 // Normalize the path
20327 resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
20328 return !!p;
20329 }), !resolvedAbsolute).join('/');
20330
20331 return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
20332};
20333
20334// path.normalize(path)
20335// posix version
20336exports.normalize = function(path) {
20337 var isAbsolute = exports.isAbsolute(path),
20338 trailingSlash = substr(path, -1) === '/';
20339
20340 // Normalize the path
20341 path = normalizeArray(filter(path.split('/'), function(p) {
20342 return !!p;
20343 }), !isAbsolute).join('/');
20344
20345 if (!path && !isAbsolute) {
20346 path = '.';
20347 }
20348 if (path && trailingSlash) {
20349 path += '/';
20350 }
20351
20352 return (isAbsolute ? '/' : '') + path;
20353};
20354
20355// posix version
20356exports.isAbsolute = function(path) {
20357 return path.charAt(0) === '/';
20358};
20359
20360// posix version
20361exports.join = function() {
20362 var paths = Array.prototype.slice.call(arguments, 0);
20363 return exports.normalize(filter(paths, function(p, index) {
20364 if (typeof p !== 'string') {
20365 throw new TypeError('Arguments to path.join must be strings');
20366 }
20367 return p;
20368 }).join('/'));
20369};
20370
20371
20372// path.relative(from, to)
20373// posix version
20374exports.relative = function(from, to) {
20375 from = exports.resolve(from).substr(1);
20376 to = exports.resolve(to).substr(1);
20377
20378 function trim(arr) {
20379 var start = 0;
20380 for (; start < arr.length; start++) {
20381 if (arr[start] !== '') break;
20382 }
20383
20384 var end = arr.length - 1;
20385 for (; end >= 0; end--) {
20386 if (arr[end] !== '') break;
20387 }
20388
20389 if (start > end) return [];
20390 return arr.slice(start, end - start + 1);
20391 }
20392
20393 var fromParts = trim(from.split('/'));
20394 var toParts = trim(to.split('/'));
20395
20396 var length = Math.min(fromParts.length, toParts.length);
20397 var samePartsLength = length;
20398 for (var i = 0; i < length; i++) {
20399 if (fromParts[i] !== toParts[i]) {
20400 samePartsLength = i;
20401 break;
20402 }
20403 }
20404
20405 var outputParts = [];
20406 for (var i = samePartsLength; i < fromParts.length; i++) {
20407 outputParts.push('..');
20408 }
20409
20410 outputParts = outputParts.concat(toParts.slice(samePartsLength));
20411
20412 return outputParts.join('/');
20413};
20414
20415exports.sep = '/';
20416exports.delimiter = ':';
20417
20418exports.dirname = function(path) {
20419 var result = splitPath(path),
20420 root = result[0],
20421 dir = result[1];
20422
20423 if (!root && !dir) {
20424 // No dirname whatsoever
20425 return '.';
20426 }
20427
20428 if (dir) {
20429 // It has a dirname, strip trailing slash
20430 dir = dir.substr(0, dir.length - 1);
20431 }
20432
20433 return root + dir;
20434};
20435
20436
20437exports.basename = function(path, ext) {
20438 var f = splitPath(path)[2];
20439 // TODO: make this comparison case-insensitive on windows?
20440 if (ext && f.substr(-1 * ext.length) === ext) {
20441 f = f.substr(0, f.length - ext.length);
20442 }
20443 return f;
20444};
20445
20446
20447exports.extname = function(path) {
20448 return splitPath(path)[3];
20449};
20450
20451function filter (xs, f) {
20452 if (xs.filter) return xs.filter(f);
20453 var res = [];
20454 for (var i = 0; i < xs.length; i++) {
20455 if (f(xs[i], i, xs)) res.push(xs[i]);
20456 }
20457 return res;
20458}
20459
20460// String.prototype.substr - negative index don't work in IE8
20461var substr = 'ab'.substr(-1) === 'b'
20462 ? function (str, start, len) { return str.substr(start, len) }
20463 : function (str, start, len) {
20464 if (start < 0) start = str.length + start;
20465 return str.substr(start, len);
20466 }
20467;
20468
20469}).call(this,require('_process'))
20470},{"_process":281}],275:[function(require,module,exports){
20471
20472exports.pbkdf2 = require('./lib/async')
20473
20474exports.pbkdf2Sync = require('./lib/sync')
20475
20476},{"./lib/async":276,"./lib/sync":279}],276:[function(require,module,exports){
20477(function (process,global){
20478var checkParameters = require('./precondition')
20479var defaultEncoding = require('./default-encoding')
20480var sync = require('./sync')
20481var Buffer = require('safe-buffer').Buffer
20482
20483var ZERO_BUF
20484var subtle = global.crypto && global.crypto.subtle
20485var toBrowser = {
20486 'sha': 'SHA-1',
20487 'sha-1': 'SHA-1',
20488 'sha1': 'SHA-1',
20489 'sha256': 'SHA-256',
20490 'sha-256': 'SHA-256',
20491 'sha384': 'SHA-384',
20492 'sha-384': 'SHA-384',
20493 'sha-512': 'SHA-512',
20494 'sha512': 'SHA-512'
20495}
20496var checks = []
20497function checkNative (algo) {
20498 if (global.process && !global.process.browser) {
20499 return Promise.resolve(false)
20500 }
20501 if (!subtle || !subtle.importKey || !subtle.deriveBits) {
20502 return Promise.resolve(false)
20503 }
20504 if (checks[algo] !== undefined) {
20505 return checks[algo]
20506 }
20507 ZERO_BUF = ZERO_BUF || Buffer.alloc(8)
20508 var prom = browserPbkdf2(ZERO_BUF, ZERO_BUF, 10, 128, algo)
20509 .then(function () {
20510 return true
20511 }).catch(function () {
20512 return false
20513 })
20514 checks[algo] = prom
20515 return prom
20516}
20517function browserPbkdf2 (password, salt, iterations, length, algo) {
20518 return subtle.importKey(
20519 'raw', password, {name: 'PBKDF2'}, false, ['deriveBits']
20520 ).then(function (key) {
20521 return subtle.deriveBits({
20522 name: 'PBKDF2',
20523 salt: salt,
20524 iterations: iterations,
20525 hash: {
20526 name: algo
20527 }
20528 }, key, length << 3)
20529 }).then(function (res) {
20530 return Buffer.from(res)
20531 })
20532}
20533function resolvePromise (promise, callback) {
20534 promise.then(function (out) {
20535 process.nextTick(function () {
20536 callback(null, out)
20537 })
20538 }, function (e) {
20539 process.nextTick(function () {
20540 callback(e)
20541 })
20542 })
20543}
20544module.exports = function (password, salt, iterations, keylen, digest, callback) {
20545 if (!Buffer.isBuffer(password)) password = Buffer.from(password, defaultEncoding)
20546 if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, defaultEncoding)
20547
20548 checkParameters(iterations, keylen)
20549 if (typeof digest === 'function') {
20550 callback = digest
20551 digest = undefined
20552 }
20553 if (typeof callback !== 'function') throw new Error('No callback provided to pbkdf2')
20554
20555 digest = digest || 'sha1'
20556 var algo = toBrowser[digest.toLowerCase()]
20557 if (!algo || typeof global.Promise !== 'function') {
20558 return process.nextTick(function () {
20559 var out
20560 try {
20561 out = sync(password, salt, iterations, keylen, digest)
20562 } catch (e) {
20563 return callback(e)
20564 }
20565 callback(null, out)
20566 })
20567 }
20568 resolvePromise(checkNative(algo).then(function (resp) {
20569 if (resp) {
20570 return browserPbkdf2(password, salt, iterations, keylen, algo)
20571 } else {
20572 return sync(password, salt, iterations, keylen, digest)
20573 }
20574 }), callback)
20575}
20576
20577}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
20578},{"./default-encoding":277,"./precondition":278,"./sync":279,"_process":281,"safe-buffer":305}],277:[function(require,module,exports){
20579(function (process){
20580var defaultEncoding
20581/* istanbul ignore next */
20582if (process.browser) {
20583 defaultEncoding = 'utf-8'
20584} else {
20585 var pVersionMajor = parseInt(process.version.split('.')[0].slice(1), 10)
20586
20587 defaultEncoding = pVersionMajor >= 6 ? 'utf-8' : 'binary'
20588}
20589module.exports = defaultEncoding
20590
20591}).call(this,require('_process'))
20592},{"_process":281}],278:[function(require,module,exports){
20593var MAX_ALLOC = Math.pow(2, 30) - 1 // default in iojs
20594module.exports = function (iterations, keylen) {
20595 if (typeof iterations !== 'number') {
20596 throw new TypeError('Iterations not a number')
20597 }
20598
20599 if (iterations < 0) {
20600 throw new TypeError('Bad iterations')
20601 }
20602
20603 if (typeof keylen !== 'number') {
20604 throw new TypeError('Key length not a number')
20605 }
20606
20607 if (keylen < 0 || keylen > MAX_ALLOC || keylen !== keylen) { /* eslint no-self-compare: 0 */
20608 throw new TypeError('Bad key length')
20609 }
20610}
20611
20612},{}],279:[function(require,module,exports){
20613var md5 = require('create-hash/md5')
20614var rmd160 = require('ripemd160')
20615var sha = require('sha.js')
20616
20617var checkParameters = require('./precondition')
20618var defaultEncoding = require('./default-encoding')
20619var Buffer = require('safe-buffer').Buffer
20620var ZEROS = Buffer.alloc(128)
20621var sizes = {
20622 md5: 16,
20623 sha1: 20,
20624 sha224: 28,
20625 sha256: 32,
20626 sha384: 48,
20627 sha512: 64,
20628 rmd160: 20,
20629 ripemd160: 20
20630}
20631
20632function Hmac (alg, key, saltLen) {
20633 var hash = getDigest(alg)
20634 var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64
20635
20636 if (key.length > blocksize) {
20637 key = hash(key)
20638 } else if (key.length < blocksize) {
20639 key = Buffer.concat([key, ZEROS], blocksize)
20640 }
20641
20642 var ipad = Buffer.allocUnsafe(blocksize + sizes[alg])
20643 var opad = Buffer.allocUnsafe(blocksize + sizes[alg])
20644 for (var i = 0; i < blocksize; i++) {
20645 ipad[i] = key[i] ^ 0x36
20646 opad[i] = key[i] ^ 0x5C
20647 }
20648
20649 var ipad1 = Buffer.allocUnsafe(blocksize + saltLen + 4)
20650 ipad.copy(ipad1, 0, 0, blocksize)
20651 this.ipad1 = ipad1
20652 this.ipad2 = ipad
20653 this.opad = opad
20654 this.alg = alg
20655 this.blocksize = blocksize
20656 this.hash = hash
20657 this.size = sizes[alg]
20658}
20659
20660Hmac.prototype.run = function (data, ipad) {
20661 data.copy(ipad, this.blocksize)
20662 var h = this.hash(ipad)
20663 h.copy(this.opad, this.blocksize)
20664 return this.hash(this.opad)
20665}
20666
20667function getDigest (alg) {
20668 function shaFunc (data) {
20669 return sha(alg).update(data).digest()
20670 }
20671
20672 if (alg === 'rmd160' || alg === 'ripemd160') return rmd160
20673 if (alg === 'md5') return md5
20674 return shaFunc
20675}
20676
20677function pbkdf2 (password, salt, iterations, keylen, digest) {
20678 if (!Buffer.isBuffer(password)) password = Buffer.from(password, defaultEncoding)
20679 if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, defaultEncoding)
20680
20681 checkParameters(iterations, keylen)
20682
20683 digest = digest || 'sha1'
20684
20685 var hmac = new Hmac(digest, password, salt.length)
20686
20687 var DK = Buffer.allocUnsafe(keylen)
20688 var block1 = Buffer.allocUnsafe(salt.length + 4)
20689 salt.copy(block1, 0, 0, salt.length)
20690
20691 var destPos = 0
20692 var hLen = sizes[digest]
20693 var l = Math.ceil(keylen / hLen)
20694
20695 for (var i = 1; i <= l; i++) {
20696 block1.writeUInt32BE(i, salt.length)
20697
20698 var T = hmac.run(block1, hmac.ipad1)
20699 var U = T
20700
20701 for (var j = 1; j < iterations; j++) {
20702 U = hmac.run(U, hmac.ipad2)
20703 for (var k = 0; k < hLen; k++) T[k] ^= U[k]
20704 }
20705
20706 T.copy(DK, destPos)
20707 destPos += hLen
20708 }
20709
20710 return DK
20711}
20712
20713module.exports = pbkdf2
20714
20715},{"./default-encoding":277,"./precondition":278,"create-hash/md5":212,"ripemd160":304,"safe-buffer":305,"sha.js":307}],280:[function(require,module,exports){
20716(function (process){
20717'use strict';
20718
20719if (!process.version ||
20720 process.version.indexOf('v0.') === 0 ||
20721 process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
20722 module.exports = nextTick;
20723} else {
20724 module.exports = process.nextTick;
20725}
20726
20727function nextTick(fn, arg1, arg2, arg3) {
20728 if (typeof fn !== 'function') {
20729 throw new TypeError('"callback" argument must be a function');
20730 }
20731 var len = arguments.length;
20732 var args, i;
20733 switch (len) {
20734 case 0:
20735 case 1:
20736 return process.nextTick(fn);
20737 case 2:
20738 return process.nextTick(function afterTickOne() {
20739 fn.call(null, arg1);
20740 });
20741 case 3:
20742 return process.nextTick(function afterTickTwo() {
20743 fn.call(null, arg1, arg2);
20744 });
20745 case 4:
20746 return process.nextTick(function afterTickThree() {
20747 fn.call(null, arg1, arg2, arg3);
20748 });
20749 default:
20750 args = new Array(len - 1);
20751 i = 0;
20752 while (i < args.length) {
20753 args[i++] = arguments[i];
20754 }
20755 return process.nextTick(function afterTick() {
20756 fn.apply(null, args);
20757 });
20758 }
20759}
20760
20761}).call(this,require('_process'))
20762},{"_process":281}],281:[function(require,module,exports){
20763// shim for using process in browser
20764var process = module.exports = {};
20765
20766// cached from whatever global is present so that test runners that stub it
20767// don't break things. But we need to wrap it in a try catch in case it is
20768// wrapped in strict mode code which doesn't define any globals. It's inside a
20769// function because try/catches deoptimize in certain engines.
20770
20771var cachedSetTimeout;
20772var cachedClearTimeout;
20773
20774function defaultSetTimout() {
20775 throw new Error('setTimeout has not been defined');
20776}
20777function defaultClearTimeout () {
20778 throw new Error('clearTimeout has not been defined');
20779}
20780(function () {
20781 try {
20782 if (typeof setTimeout === 'function') {
20783 cachedSetTimeout = setTimeout;
20784 } else {
20785 cachedSetTimeout = defaultSetTimout;
20786 }
20787 } catch (e) {
20788 cachedSetTimeout = defaultSetTimout;
20789 }
20790 try {
20791 if (typeof clearTimeout === 'function') {
20792 cachedClearTimeout = clearTimeout;
20793 } else {
20794 cachedClearTimeout = defaultClearTimeout;
20795 }
20796 } catch (e) {
20797 cachedClearTimeout = defaultClearTimeout;
20798 }
20799} ())
20800function runTimeout(fun) {
20801 if (cachedSetTimeout === setTimeout) {
20802 //normal enviroments in sane situations
20803 return setTimeout(fun, 0);
20804 }
20805 // if setTimeout wasn't available but was latter defined
20806 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
20807 cachedSetTimeout = setTimeout;
20808 return setTimeout(fun, 0);
20809 }
20810 try {
20811 // when when somebody has screwed with setTimeout but no I.E. maddness
20812 return cachedSetTimeout(fun, 0);
20813 } catch(e){
20814 try {
20815 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
20816 return cachedSetTimeout.call(null, fun, 0);
20817 } catch(e){
20818 // 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
20819 return cachedSetTimeout.call(this, fun, 0);
20820 }
20821 }
20822
20823
20824}
20825function runClearTimeout(marker) {
20826 if (cachedClearTimeout === clearTimeout) {
20827 //normal enviroments in sane situations
20828 return clearTimeout(marker);
20829 }
20830 // if clearTimeout wasn't available but was latter defined
20831 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
20832 cachedClearTimeout = clearTimeout;
20833 return clearTimeout(marker);
20834 }
20835 try {
20836 // when when somebody has screwed with setTimeout but no I.E. maddness
20837 return cachedClearTimeout(marker);
20838 } catch (e){
20839 try {
20840 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
20841 return cachedClearTimeout.call(null, marker);
20842 } catch (e){
20843 // 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.
20844 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
20845 return cachedClearTimeout.call(this, marker);
20846 }
20847 }
20848
20849
20850
20851}
20852var queue = [];
20853var draining = false;
20854var currentQueue;
20855var queueIndex = -1;
20856
20857function cleanUpNextTick() {
20858 if (!draining || !currentQueue) {
20859 return;
20860 }
20861 draining = false;
20862 if (currentQueue.length) {
20863 queue = currentQueue.concat(queue);
20864 } else {
20865 queueIndex = -1;
20866 }
20867 if (queue.length) {
20868 drainQueue();
20869 }
20870}
20871
20872function drainQueue() {
20873 if (draining) {
20874 return;
20875 }
20876 var timeout = runTimeout(cleanUpNextTick);
20877 draining = true;
20878
20879 var len = queue.length;
20880 while(len) {
20881 currentQueue = queue;
20882 queue = [];
20883 while (++queueIndex < len) {
20884 if (currentQueue) {
20885 currentQueue[queueIndex].run();
20886 }
20887 }
20888 queueIndex = -1;
20889 len = queue.length;
20890 }
20891 currentQueue = null;
20892 draining = false;
20893 runClearTimeout(timeout);
20894}
20895
20896process.nextTick = function (fun) {
20897 var args = new Array(arguments.length - 1);
20898 if (arguments.length > 1) {
20899 for (var i = 1; i < arguments.length; i++) {
20900 args[i - 1] = arguments[i];
20901 }
20902 }
20903 queue.push(new Item(fun, args));
20904 if (queue.length === 1 && !draining) {
20905 runTimeout(drainQueue);
20906 }
20907};
20908
20909// v8 likes predictible objects
20910function Item(fun, array) {
20911 this.fun = fun;
20912 this.array = array;
20913}
20914Item.prototype.run = function () {
20915 this.fun.apply(null, this.array);
20916};
20917process.title = 'browser';
20918process.browser = true;
20919process.env = {};
20920process.argv = [];
20921process.version = ''; // empty string to avoid regexp issues
20922process.versions = {};
20923
20924function noop() {}
20925
20926process.on = noop;
20927process.addListener = noop;
20928process.once = noop;
20929process.off = noop;
20930process.removeListener = noop;
20931process.removeAllListeners = noop;
20932process.emit = noop;
20933process.prependListener = noop;
20934process.prependOnceListener = noop;
20935
20936process.listeners = function (name) { return [] }
20937
20938process.binding = function (name) {
20939 throw new Error('process.binding is not supported');
20940};
20941
20942process.cwd = function () { return '/' };
20943process.chdir = function (dir) {
20944 throw new Error('process.chdir is not supported');
20945};
20946process.umask = function() { return 0; };
20947
20948},{}],282:[function(require,module,exports){
20949exports.publicEncrypt = require('./publicEncrypt');
20950exports.privateDecrypt = require('./privateDecrypt');
20951
20952exports.privateEncrypt = function privateEncrypt(key, buf) {
20953 return exports.publicEncrypt(key, buf, true);
20954};
20955
20956exports.publicDecrypt = function publicDecrypt(key, buf) {
20957 return exports.privateDecrypt(key, buf, true);
20958};
20959},{"./privateDecrypt":284,"./publicEncrypt":285}],283:[function(require,module,exports){
20960(function (Buffer){
20961var createHash = require('create-hash');
20962module.exports = function (seed, len) {
20963 var t = new Buffer('');
20964 var i = 0, c;
20965 while (t.length < len) {
20966 c = i2ops(i++);
20967 t = Buffer.concat([t, createHash('sha1').update(seed).update(c).digest()]);
20968 }
20969 return t.slice(0, len);
20970};
20971
20972function i2ops(c) {
20973 var out = new Buffer(4);
20974 out.writeUInt32BE(c,0);
20975 return out;
20976}
20977}).call(this,require("buffer").Buffer)
20978},{"buffer":75,"create-hash":210}],284:[function(require,module,exports){
20979(function (Buffer){
20980var parseKeys = require('parse-asn1');
20981var mgf = require('./mgf');
20982var xor = require('./xor');
20983var bn = require('bn.js');
20984var crt = require('browserify-rsa');
20985var createHash = require('create-hash');
20986var withPublic = require('./withPublic');
20987module.exports = function privateDecrypt(private_key, enc, reverse) {
20988 var padding;
20989 if (private_key.padding) {
20990 padding = private_key.padding;
20991 } else if (reverse) {
20992 padding = 1;
20993 } else {
20994 padding = 4;
20995 }
20996
20997 var key = parseKeys(private_key);
20998 var k = key.modulus.byteLength();
20999 if (enc.length > k || new bn(enc).cmp(key.modulus) >= 0) {
21000 throw new Error('decryption error');
21001 }
21002 var msg;
21003 if (reverse) {
21004 msg = withPublic(new bn(enc), key);
21005 } else {
21006 msg = crt(enc, key);
21007 }
21008 var zBuffer = new Buffer(k - msg.length);
21009 zBuffer.fill(0);
21010 msg = Buffer.concat([zBuffer, msg], k);
21011 if (padding === 4) {
21012 return oaep(key, msg);
21013 } else if (padding === 1) {
21014 return pkcs1(key, msg, reverse);
21015 } else if (padding === 3) {
21016 return msg;
21017 } else {
21018 throw new Error('unknown padding');
21019 }
21020};
21021
21022function oaep(key, msg){
21023 var n = key.modulus;
21024 var k = key.modulus.byteLength();
21025 var mLen = msg.length;
21026 var iHash = createHash('sha1').update(new Buffer('')).digest();
21027 var hLen = iHash.length;
21028 var hLen2 = 2 * hLen;
21029 if (msg[0] !== 0) {
21030 throw new Error('decryption error');
21031 }
21032 var maskedSeed = msg.slice(1, hLen + 1);
21033 var maskedDb = msg.slice(hLen + 1);
21034 var seed = xor(maskedSeed, mgf(maskedDb, hLen));
21035 var db = xor(maskedDb, mgf(seed, k - hLen - 1));
21036 if (compare(iHash, db.slice(0, hLen))) {
21037 throw new Error('decryption error');
21038 }
21039 var i = hLen;
21040 while (db[i] === 0) {
21041 i++;
21042 }
21043 if (db[i++] !== 1) {
21044 throw new Error('decryption error');
21045 }
21046 return db.slice(i);
21047}
21048
21049function pkcs1(key, msg, reverse){
21050 var p1 = msg.slice(0, 2);
21051 var i = 2;
21052 var status = 0;
21053 while (msg[i++] !== 0) {
21054 if (i >= msg.length) {
21055 status++;
21056 break;
21057 }
21058 }
21059 var ps = msg.slice(2, i - 1);
21060 var p2 = msg.slice(i - 1, i);
21061
21062 if ((p1.toString('hex') !== '0002' && !reverse) || (p1.toString('hex') !== '0001' && reverse)){
21063 status++;
21064 }
21065 if (ps.length < 8) {
21066 status++;
21067 }
21068 if (status) {
21069 throw new Error('decryption error');
21070 }
21071 return msg.slice(i);
21072}
21073function compare(a, b){
21074 a = new Buffer(a);
21075 b = new Buffer(b);
21076 var dif = 0;
21077 var len = a.length;
21078 if (a.length !== b.length) {
21079 dif++;
21080 len = Math.min(a.length, b.length);
21081 }
21082 var i = -1;
21083 while (++i < len) {
21084 dif += (a[i] ^ b[i]);
21085 }
21086 return dif;
21087}
21088}).call(this,require("buffer").Buffer)
21089},{"./mgf":283,"./withPublic":286,"./xor":287,"bn.js":43,"browserify-rsa":66,"buffer":75,"create-hash":210,"parse-asn1":273}],285:[function(require,module,exports){
21090(function (Buffer){
21091var parseKeys = require('parse-asn1');
21092var randomBytes = require('randombytes');
21093var createHash = require('create-hash');
21094var mgf = require('./mgf');
21095var xor = require('./xor');
21096var bn = require('bn.js');
21097var withPublic = require('./withPublic');
21098var crt = require('browserify-rsa');
21099
21100var constants = {
21101 RSA_PKCS1_OAEP_PADDING: 4,
21102 RSA_PKCS1_PADDIN: 1,
21103 RSA_NO_PADDING: 3
21104};
21105
21106module.exports = function publicEncrypt(public_key, msg, reverse) {
21107 var padding;
21108 if (public_key.padding) {
21109 padding = public_key.padding;
21110 } else if (reverse) {
21111 padding = 1;
21112 } else {
21113 padding = 4;
21114 }
21115 var key = parseKeys(public_key);
21116 var paddedMsg;
21117 if (padding === 4) {
21118 paddedMsg = oaep(key, msg);
21119 } else if (padding === 1) {
21120 paddedMsg = pkcs1(key, msg, reverse);
21121 } else if (padding === 3) {
21122 paddedMsg = new bn(msg);
21123 if (paddedMsg.cmp(key.modulus) >= 0) {
21124 throw new Error('data too long for modulus');
21125 }
21126 } else {
21127 throw new Error('unknown padding');
21128 }
21129 if (reverse) {
21130 return crt(paddedMsg, key);
21131 } else {
21132 return withPublic(paddedMsg, key);
21133 }
21134};
21135
21136function oaep(key, msg){
21137 var k = key.modulus.byteLength();
21138 var mLen = msg.length;
21139 var iHash = createHash('sha1').update(new Buffer('')).digest();
21140 var hLen = iHash.length;
21141 var hLen2 = 2 * hLen;
21142 if (mLen > k - hLen2 - 2) {
21143 throw new Error('message too long');
21144 }
21145 var ps = new Buffer(k - mLen - hLen2 - 2);
21146 ps.fill(0);
21147 var dblen = k - hLen - 1;
21148 var seed = randomBytes(hLen);
21149 var maskedDb = xor(Buffer.concat([iHash, ps, new Buffer([1]), msg], dblen), mgf(seed, dblen));
21150 var maskedSeed = xor(seed, mgf(maskedDb, hLen));
21151 return new bn(Buffer.concat([new Buffer([0]), maskedSeed, maskedDb], k));
21152}
21153function pkcs1(key, msg, reverse){
21154 var mLen = msg.length;
21155 var k = key.modulus.byteLength();
21156 if (mLen > k - 11) {
21157 throw new Error('message too long');
21158 }
21159 var ps;
21160 if (reverse) {
21161 ps = new Buffer(k - mLen - 3);
21162 ps.fill(0xff);
21163 } else {
21164 ps = nonZero(k - mLen - 3);
21165 }
21166 return new bn(Buffer.concat([new Buffer([0, reverse?1:2]), ps, new Buffer([0]), msg], k));
21167}
21168function nonZero(len, crypto) {
21169 var out = new Buffer(len);
21170 var i = 0;
21171 var cache = randomBytes(len*2);
21172 var cur = 0;
21173 var num;
21174 while (i < len) {
21175 if (cur === cache.length) {
21176 cache = randomBytes(len*2);
21177 cur = 0;
21178 }
21179 num = cache[cur++];
21180 if (num) {
21181 out[i++] = num;
21182 }
21183 }
21184 return out;
21185}
21186}).call(this,require("buffer").Buffer)
21187},{"./mgf":283,"./withPublic":286,"./xor":287,"bn.js":43,"browserify-rsa":66,"buffer":75,"create-hash":210,"parse-asn1":273,"randombytes":288}],286:[function(require,module,exports){
21188(function (Buffer){
21189var bn = require('bn.js');
21190function withPublic(paddedMsg, key) {
21191 return new Buffer(paddedMsg
21192 .toRed(bn.mont(key.modulus))
21193 .redPow(new bn(key.publicExponent))
21194 .fromRed()
21195 .toArray());
21196}
21197
21198module.exports = withPublic;
21199}).call(this,require("buffer").Buffer)
21200},{"bn.js":43,"buffer":75}],287:[function(require,module,exports){
21201module.exports = function xor(a, b) {
21202 var len = a.length;
21203 var i = -1;
21204 while (++i < len) {
21205 a[i] ^= b[i];
21206 }
21207 return a
21208};
21209},{}],288:[function(require,module,exports){
21210(function (process,global){
21211'use strict'
21212
21213function oldBrowser () {
21214 throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11')
21215}
21216
21217var Buffer = require('safe-buffer').Buffer
21218var crypto = global.crypto || global.msCrypto
21219
21220if (crypto && crypto.getRandomValues) {
21221 module.exports = randomBytes
21222} else {
21223 module.exports = oldBrowser
21224}
21225
21226function randomBytes (size, cb) {
21227 // phantomjs needs to throw
21228 if (size > 65536) throw new Error('requested too many random bytes')
21229 // in case browserify isn't using the Uint8Array version
21230 var rawBytes = new global.Uint8Array(size)
21231
21232 // This will not work in older browsers.
21233 // See https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
21234 if (size > 0) { // getRandomValues fails on IE if size == 0
21235 crypto.getRandomValues(rawBytes)
21236 }
21237
21238 // XXX: phantomjs doesn't like a buffer being passed here
21239 var bytes = Buffer.from(rawBytes.buffer)
21240
21241 if (typeof cb === 'function') {
21242 return process.nextTick(function () {
21243 cb(null, bytes)
21244 })
21245 }
21246
21247 return bytes
21248}
21249
21250}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
21251},{"_process":281,"safe-buffer":305}],289:[function(require,module,exports){
21252(function (process,global){
21253'use strict'
21254
21255function oldBrowser () {
21256 throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11')
21257}
21258var safeBuffer = require('safe-buffer')
21259var randombytes = require('randombytes')
21260var Buffer = safeBuffer.Buffer
21261var kBufferMaxLength = safeBuffer.kMaxLength
21262var crypto = global.crypto || global.msCrypto
21263var kMaxUint32 = Math.pow(2, 32) - 1
21264function assertOffset (offset, length) {
21265 if (typeof offset !== 'number' || offset !== offset) { // eslint-disable-line no-self-compare
21266 throw new TypeError('offset must be a number')
21267 }
21268
21269 if (offset > kMaxUint32 || offset < 0) {
21270 throw new TypeError('offset must be a uint32')
21271 }
21272
21273 if (offset > kBufferMaxLength || offset > length) {
21274 throw new RangeError('offset out of range')
21275 }
21276}
21277
21278function assertSize (size, offset, length) {
21279 if (typeof size !== 'number' || size !== size) { // eslint-disable-line no-self-compare
21280 throw new TypeError('size must be a number')
21281 }
21282
21283 if (size > kMaxUint32 || size < 0) {
21284 throw new TypeError('size must be a uint32')
21285 }
21286
21287 if (size + offset > length || size > kBufferMaxLength) {
21288 throw new RangeError('buffer too small')
21289 }
21290}
21291if ((crypto && crypto.getRandomValues) || !process.browser) {
21292 exports.randomFill = randomFill
21293 exports.randomFillSync = randomFillSync
21294} else {
21295 exports.randomFill = oldBrowser
21296 exports.randomFillSync = oldBrowser
21297}
21298function randomFill (buf, offset, size, cb) {
21299 if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) {
21300 throw new TypeError('"buf" argument must be a Buffer or Uint8Array')
21301 }
21302
21303 if (typeof offset === 'function') {
21304 cb = offset
21305 offset = 0
21306 size = buf.length
21307 } else if (typeof size === 'function') {
21308 cb = size
21309 size = buf.length - offset
21310 } else if (typeof cb !== 'function') {
21311 throw new TypeError('"cb" argument must be a function')
21312 }
21313 assertOffset(offset, buf.length)
21314 assertSize(size, offset, buf.length)
21315 return actualFill(buf, offset, size, cb)
21316}
21317
21318function actualFill (buf, offset, size, cb) {
21319 if (process.browser) {
21320 var ourBuf = buf.buffer
21321 var uint = new Uint8Array(ourBuf, offset, size)
21322 crypto.getRandomValues(uint)
21323 if (cb) {
21324 process.nextTick(function () {
21325 cb(null, buf)
21326 })
21327 return
21328 }
21329 return buf
21330 }
21331 if (cb) {
21332 randombytes(size, function (err, bytes) {
21333 if (err) {
21334 return cb(err)
21335 }
21336 bytes.copy(buf, offset)
21337 cb(null, buf)
21338 })
21339 return
21340 }
21341 var bytes = randombytes(size)
21342 bytes.copy(buf, offset)
21343 return buf
21344}
21345function randomFillSync (buf, offset, size) {
21346 if (typeof offset === 'undefined') {
21347 offset = 0
21348 }
21349 if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) {
21350 throw new TypeError('"buf" argument must be a Buffer or Uint8Array')
21351 }
21352
21353 assertOffset(offset, buf.length)
21354
21355 if (size === undefined) size = buf.length - offset
21356
21357 assertSize(size, offset, buf.length)
21358
21359 return actualFill(buf, offset, size)
21360}
21361
21362}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
21363},{"_process":281,"randombytes":288,"safe-buffer":305}],290:[function(require,module,exports){
21364module.exports = require('./lib/_stream_duplex.js');
21365
21366},{"./lib/_stream_duplex.js":291}],291:[function(require,module,exports){
21367// Copyright Joyent, Inc. and other Node contributors.
21368//
21369// Permission is hereby granted, free of charge, to any person obtaining a
21370// copy of this software and associated documentation files (the
21371// "Software"), to deal in the Software without restriction, including
21372// without limitation the rights to use, copy, modify, merge, publish,
21373// distribute, sublicense, and/or sell copies of the Software, and to permit
21374// persons to whom the Software is furnished to do so, subject to the
21375// following conditions:
21376//
21377// The above copyright notice and this permission notice shall be included
21378// in all copies or substantial portions of the Software.
21379//
21380// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21381// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21382// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
21383// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
21384// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21385// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21386// USE OR OTHER DEALINGS IN THE SOFTWARE.
21387
21388// a duplex stream is just a stream that is both readable and writable.
21389// Since JS doesn't have multiple prototypal inheritance, this class
21390// prototypally inherits from Readable, and then parasitically from
21391// Writable.
21392
21393'use strict';
21394
21395/*<replacement>*/
21396
21397var processNextTick = require('process-nextick-args');
21398/*</replacement>*/
21399
21400/*<replacement>*/
21401var objectKeys = Object.keys || function (obj) {
21402 var keys = [];
21403 for (var key in obj) {
21404 keys.push(key);
21405 }return keys;
21406};
21407/*</replacement>*/
21408
21409module.exports = Duplex;
21410
21411/*<replacement>*/
21412var util = require('core-util-is');
21413util.inherits = require('inherits');
21414/*</replacement>*/
21415
21416var Readable = require('./_stream_readable');
21417var Writable = require('./_stream_writable');
21418
21419util.inherits(Duplex, Readable);
21420
21421var keys = objectKeys(Writable.prototype);
21422for (var v = 0; v < keys.length; v++) {
21423 var method = keys[v];
21424 if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
21425}
21426
21427function Duplex(options) {
21428 if (!(this instanceof Duplex)) return new Duplex(options);
21429
21430 Readable.call(this, options);
21431 Writable.call(this, options);
21432
21433 if (options && options.readable === false) this.readable = false;
21434
21435 if (options && options.writable === false) this.writable = false;
21436
21437 this.allowHalfOpen = true;
21438 if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
21439
21440 this.once('end', onend);
21441}
21442
21443// the no-half-open enforcer
21444function onend() {
21445 // if we allow half-open state, or if the writable side ended,
21446 // then we're ok.
21447 if (this.allowHalfOpen || this._writableState.ended) return;
21448
21449 // no more data can be written.
21450 // But allow more writes to happen in this tick.
21451 processNextTick(onEndNT, this);
21452}
21453
21454function onEndNT(self) {
21455 self.end();
21456}
21457
21458Object.defineProperty(Duplex.prototype, 'destroyed', {
21459 get: function () {
21460 if (this._readableState === undefined || this._writableState === undefined) {
21461 return false;
21462 }
21463 return this._readableState.destroyed && this._writableState.destroyed;
21464 },
21465 set: function (value) {
21466 // we ignore the value if the stream
21467 // has not been initialized yet
21468 if (this._readableState === undefined || this._writableState === undefined) {
21469 return;
21470 }
21471
21472 // backward compatibility, the user is explicitly
21473 // managing destroyed
21474 this._readableState.destroyed = value;
21475 this._writableState.destroyed = value;
21476 }
21477});
21478
21479Duplex.prototype._destroy = function (err, cb) {
21480 this.push(null);
21481 this.end();
21482
21483 processNextTick(cb, err);
21484};
21485
21486function forEach(xs, f) {
21487 for (var i = 0, l = xs.length; i < l; i++) {
21488 f(xs[i], i);
21489 }
21490}
21491},{"./_stream_readable":293,"./_stream_writable":295,"core-util-is":208,"inherits":260,"process-nextick-args":280}],292:[function(require,module,exports){
21492// Copyright Joyent, Inc. and other Node contributors.
21493//
21494// Permission is hereby granted, free of charge, to any person obtaining a
21495// copy of this software and associated documentation files (the
21496// "Software"), to deal in the Software without restriction, including
21497// without limitation the rights to use, copy, modify, merge, publish,
21498// distribute, sublicense, and/or sell copies of the Software, and to permit
21499// persons to whom the Software is furnished to do so, subject to the
21500// following conditions:
21501//
21502// The above copyright notice and this permission notice shall be included
21503// in all copies or substantial portions of the Software.
21504//
21505// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21506// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21507// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
21508// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
21509// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21510// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21511// USE OR OTHER DEALINGS IN THE SOFTWARE.
21512
21513// a passthrough stream.
21514// basically just the most minimal sort of Transform stream.
21515// Every written chunk gets output as-is.
21516
21517'use strict';
21518
21519module.exports = PassThrough;
21520
21521var Transform = require('./_stream_transform');
21522
21523/*<replacement>*/
21524var util = require('core-util-is');
21525util.inherits = require('inherits');
21526/*</replacement>*/
21527
21528util.inherits(PassThrough, Transform);
21529
21530function PassThrough(options) {
21531 if (!(this instanceof PassThrough)) return new PassThrough(options);
21532
21533 Transform.call(this, options);
21534}
21535
21536PassThrough.prototype._transform = function (chunk, encoding, cb) {
21537 cb(null, chunk);
21538};
21539},{"./_stream_transform":294,"core-util-is":208,"inherits":260}],293:[function(require,module,exports){
21540(function (process,global){
21541// Copyright Joyent, Inc. and other Node contributors.
21542//
21543// Permission is hereby granted, free of charge, to any person obtaining a
21544// copy of this software and associated documentation files (the
21545// "Software"), to deal in the Software without restriction, including
21546// without limitation the rights to use, copy, modify, merge, publish,
21547// distribute, sublicense, and/or sell copies of the Software, and to permit
21548// persons to whom the Software is furnished to do so, subject to the
21549// following conditions:
21550//
21551// The above copyright notice and this permission notice shall be included
21552// in all copies or substantial portions of the Software.
21553//
21554// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21555// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21556// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
21557// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
21558// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21559// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21560// USE OR OTHER DEALINGS IN THE SOFTWARE.
21561
21562'use strict';
21563
21564/*<replacement>*/
21565
21566var processNextTick = require('process-nextick-args');
21567/*</replacement>*/
21568
21569module.exports = Readable;
21570
21571/*<replacement>*/
21572var isArray = require('isarray');
21573/*</replacement>*/
21574
21575/*<replacement>*/
21576var Duplex;
21577/*</replacement>*/
21578
21579Readable.ReadableState = ReadableState;
21580
21581/*<replacement>*/
21582var EE = require('events').EventEmitter;
21583
21584var EElistenerCount = function (emitter, type) {
21585 return emitter.listeners(type).length;
21586};
21587/*</replacement>*/
21588
21589/*<replacement>*/
21590var Stream = require('./internal/streams/stream');
21591/*</replacement>*/
21592
21593// TODO(bmeurer): Change this back to const once hole checks are
21594// properly optimized away early in Ignition+TurboFan.
21595/*<replacement>*/
21596var Buffer = require('safe-buffer').Buffer;
21597var OurUint8Array = global.Uint8Array || function () {};
21598function _uint8ArrayToBuffer(chunk) {
21599 return Buffer.from(chunk);
21600}
21601function _isUint8Array(obj) {
21602 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
21603}
21604/*</replacement>*/
21605
21606/*<replacement>*/
21607var util = require('core-util-is');
21608util.inherits = require('inherits');
21609/*</replacement>*/
21610
21611/*<replacement>*/
21612var debugUtil = require('util');
21613var debug = void 0;
21614if (debugUtil && debugUtil.debuglog) {
21615 debug = debugUtil.debuglog('stream');
21616} else {
21617 debug = function () {};
21618}
21619/*</replacement>*/
21620
21621var BufferList = require('./internal/streams/BufferList');
21622var destroyImpl = require('./internal/streams/destroy');
21623var StringDecoder;
21624
21625util.inherits(Readable, Stream);
21626
21627var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
21628
21629function prependListener(emitter, event, fn) {
21630 // Sadly this is not cacheable as some libraries bundle their own
21631 // event emitter implementation with them.
21632 if (typeof emitter.prependListener === 'function') {
21633 return emitter.prependListener(event, fn);
21634 } else {
21635 // This is a hack to make sure that our error handler is attached before any
21636 // userland ones. NEVER DO THIS. This is here only because this code needs
21637 // to continue to work with older versions of Node.js that do not include
21638 // the prependListener() method. The goal is to eventually remove this hack.
21639 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]];
21640 }
21641}
21642
21643function ReadableState(options, stream) {
21644 Duplex = Duplex || require('./_stream_duplex');
21645
21646 options = options || {};
21647
21648 // object stream flag. Used to make read(n) ignore n and to
21649 // make all the buffer merging and length checks go away
21650 this.objectMode = !!options.objectMode;
21651
21652 if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
21653
21654 // the point at which it stops calling _read() to fill the buffer
21655 // Note: 0 is a valid value, means "don't call _read preemptively ever"
21656 var hwm = options.highWaterMark;
21657 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
21658 this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
21659
21660 // cast to ints.
21661 this.highWaterMark = Math.floor(this.highWaterMark);
21662
21663 // A linked list is used to store data chunks instead of an array because the
21664 // linked list can remove elements from the beginning faster than
21665 // array.shift()
21666 this.buffer = new BufferList();
21667 this.length = 0;
21668 this.pipes = null;
21669 this.pipesCount = 0;
21670 this.flowing = null;
21671 this.ended = false;
21672 this.endEmitted = false;
21673 this.reading = false;
21674
21675 // a flag to be able to tell if the event 'readable'/'data' is emitted
21676 // immediately, or on a later tick. We set this to true at first, because
21677 // any actions that shouldn't happen until "later" should generally also
21678 // not happen before the first read call.
21679 this.sync = true;
21680
21681 // whenever we return null, then we set a flag to say
21682 // that we're awaiting a 'readable' event emission.
21683 this.needReadable = false;
21684 this.emittedReadable = false;
21685 this.readableListening = false;
21686 this.resumeScheduled = false;
21687
21688 // has it been destroyed
21689 this.destroyed = false;
21690
21691 // Crypto is kind of old and crusty. Historically, its default string
21692 // encoding is 'binary' so we have to make this configurable.
21693 // Everything else in the universe uses 'utf8', though.
21694 this.defaultEncoding = options.defaultEncoding || 'utf8';
21695
21696 // the number of writers that are awaiting a drain event in .pipe()s
21697 this.awaitDrain = 0;
21698
21699 // if true, a maybeReadMore has been scheduled
21700 this.readingMore = false;
21701
21702 this.decoder = null;
21703 this.encoding = null;
21704 if (options.encoding) {
21705 if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
21706 this.decoder = new StringDecoder(options.encoding);
21707 this.encoding = options.encoding;
21708 }
21709}
21710
21711function Readable(options) {
21712 Duplex = Duplex || require('./_stream_duplex');
21713
21714 if (!(this instanceof Readable)) return new Readable(options);
21715
21716 this._readableState = new ReadableState(options, this);
21717
21718 // legacy
21719 this.readable = true;
21720
21721 if (options) {
21722 if (typeof options.read === 'function') this._read = options.read;
21723
21724 if (typeof options.destroy === 'function') this._destroy = options.destroy;
21725 }
21726
21727 Stream.call(this);
21728}
21729
21730Object.defineProperty(Readable.prototype, 'destroyed', {
21731 get: function () {
21732 if (this._readableState === undefined) {
21733 return false;
21734 }
21735 return this._readableState.destroyed;
21736 },
21737 set: function (value) {
21738 // we ignore the value if the stream
21739 // has not been initialized yet
21740 if (!this._readableState) {
21741 return;
21742 }
21743
21744 // backward compatibility, the user is explicitly
21745 // managing destroyed
21746 this._readableState.destroyed = value;
21747 }
21748});
21749
21750Readable.prototype.destroy = destroyImpl.destroy;
21751Readable.prototype._undestroy = destroyImpl.undestroy;
21752Readable.prototype._destroy = function (err, cb) {
21753 this.push(null);
21754 cb(err);
21755};
21756
21757// Manually shove something into the read() buffer.
21758// This returns true if the highWaterMark has not been hit yet,
21759// similar to how Writable.write() returns true if you should
21760// write() some more.
21761Readable.prototype.push = function (chunk, encoding) {
21762 var state = this._readableState;
21763 var skipChunkCheck;
21764
21765 if (!state.objectMode) {
21766 if (typeof chunk === 'string') {
21767 encoding = encoding || state.defaultEncoding;
21768 if (encoding !== state.encoding) {
21769 chunk = Buffer.from(chunk, encoding);
21770 encoding = '';
21771 }
21772 skipChunkCheck = true;
21773 }
21774 } else {
21775 skipChunkCheck = true;
21776 }
21777
21778 return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
21779};
21780
21781// Unshift should *always* be something directly out of read()
21782Readable.prototype.unshift = function (chunk) {
21783 return readableAddChunk(this, chunk, null, true, false);
21784};
21785
21786function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
21787 var state = stream._readableState;
21788 if (chunk === null) {
21789 state.reading = false;
21790 onEofChunk(stream, state);
21791 } else {
21792 var er;
21793 if (!skipChunkCheck) er = chunkInvalid(state, chunk);
21794 if (er) {
21795 stream.emit('error', er);
21796 } else if (state.objectMode || chunk && chunk.length > 0) {
21797 if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
21798 chunk = _uint8ArrayToBuffer(chunk);
21799 }
21800
21801 if (addToFront) {
21802 if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
21803 } else if (state.ended) {
21804 stream.emit('error', new Error('stream.push() after EOF'));
21805 } else {
21806 state.reading = false;
21807 if (state.decoder && !encoding) {
21808 chunk = state.decoder.write(chunk);
21809 if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
21810 } else {
21811 addChunk(stream, state, chunk, false);
21812 }
21813 }
21814 } else if (!addToFront) {
21815 state.reading = false;
21816 }
21817 }
21818
21819 return needMoreData(state);
21820}
21821
21822function addChunk(stream, state, chunk, addToFront) {
21823 if (state.flowing && state.length === 0 && !state.sync) {
21824 stream.emit('data', chunk);
21825 stream.read(0);
21826 } else {
21827 // update the buffer info.
21828 state.length += state.objectMode ? 1 : chunk.length;
21829 if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
21830
21831 if (state.needReadable) emitReadable(stream);
21832 }
21833 maybeReadMore(stream, state);
21834}
21835
21836function chunkInvalid(state, chunk) {
21837 var er;
21838 if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
21839 er = new TypeError('Invalid non-string/buffer chunk');
21840 }
21841 return er;
21842}
21843
21844// if it's past the high water mark, we can push in some more.
21845// Also, if we have no data yet, we can stand some
21846// more bytes. This is to work around cases where hwm=0,
21847// such as the repl. Also, if the push() triggered a
21848// readable event, and the user called read(largeNumber) such that
21849// needReadable was set, then we ought to push more, so that another
21850// 'readable' event will be triggered.
21851function needMoreData(state) {
21852 return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
21853}
21854
21855Readable.prototype.isPaused = function () {
21856 return this._readableState.flowing === false;
21857};
21858
21859// backwards compatibility.
21860Readable.prototype.setEncoding = function (enc) {
21861 if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
21862 this._readableState.decoder = new StringDecoder(enc);
21863 this._readableState.encoding = enc;
21864 return this;
21865};
21866
21867// Don't raise the hwm > 8MB
21868var MAX_HWM = 0x800000;
21869function computeNewHighWaterMark(n) {
21870 if (n >= MAX_HWM) {
21871 n = MAX_HWM;
21872 } else {
21873 // Get the next highest power of 2 to prevent increasing hwm excessively in
21874 // tiny amounts
21875 n--;
21876 n |= n >>> 1;
21877 n |= n >>> 2;
21878 n |= n >>> 4;
21879 n |= n >>> 8;
21880 n |= n >>> 16;
21881 n++;
21882 }
21883 return n;
21884}
21885
21886// This function is designed to be inlinable, so please take care when making
21887// changes to the function body.
21888function howMuchToRead(n, state) {
21889 if (n <= 0 || state.length === 0 && state.ended) return 0;
21890 if (state.objectMode) return 1;
21891 if (n !== n) {
21892 // Only flow one buffer at a time
21893 if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
21894 }
21895 // If we're asking for more than the current hwm, then raise the hwm.
21896 if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
21897 if (n <= state.length) return n;
21898 // Don't have enough
21899 if (!state.ended) {
21900 state.needReadable = true;
21901 return 0;
21902 }
21903 return state.length;
21904}
21905
21906// you can override either this method, or the async _read(n) below.
21907Readable.prototype.read = function (n) {
21908 debug('read', n);
21909 n = parseInt(n, 10);
21910 var state = this._readableState;
21911 var nOrig = n;
21912
21913 if (n !== 0) state.emittedReadable = false;
21914
21915 // if we're doing read(0) to trigger a readable event, but we
21916 // already have a bunch of data in the buffer, then just trigger
21917 // the 'readable' event and move on.
21918 if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
21919 debug('read: emitReadable', state.length, state.ended);
21920 if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
21921 return null;
21922 }
21923
21924 n = howMuchToRead(n, state);
21925
21926 // if we've ended, and we're now clear, then finish it up.
21927 if (n === 0 && state.ended) {
21928 if (state.length === 0) endReadable(this);
21929 return null;
21930 }
21931
21932 // All the actual chunk generation logic needs to be
21933 // *below* the call to _read. The reason is that in certain
21934 // synthetic stream cases, such as passthrough streams, _read
21935 // may be a completely synchronous operation which may change
21936 // the state of the read buffer, providing enough data when
21937 // before there was *not* enough.
21938 //
21939 // So, the steps are:
21940 // 1. Figure out what the state of things will be after we do
21941 // a read from the buffer.
21942 //
21943 // 2. If that resulting state will trigger a _read, then call _read.
21944 // Note that this may be asynchronous, or synchronous. Yes, it is
21945 // deeply ugly to write APIs this way, but that still doesn't mean
21946 // that the Readable class should behave improperly, as streams are
21947 // designed to be sync/async agnostic.
21948 // Take note if the _read call is sync or async (ie, if the read call
21949 // has returned yet), so that we know whether or not it's safe to emit
21950 // 'readable' etc.
21951 //
21952 // 3. Actually pull the requested chunks out of the buffer and return.
21953
21954 // if we need a readable event, then we need to do some reading.
21955 var doRead = state.needReadable;
21956 debug('need readable', doRead);
21957
21958 // if we currently have less than the highWaterMark, then also read some
21959 if (state.length === 0 || state.length - n < state.highWaterMark) {
21960 doRead = true;
21961 debug('length less than watermark', doRead);
21962 }
21963
21964 // however, if we've ended, then there's no point, and if we're already
21965 // reading, then it's unnecessary.
21966 if (state.ended || state.reading) {
21967 doRead = false;
21968 debug('reading or ended', doRead);
21969 } else if (doRead) {
21970 debug('do read');
21971 state.reading = true;
21972 state.sync = true;
21973 // if the length is currently zero, then we *need* a readable event.
21974 if (state.length === 0) state.needReadable = true;
21975 // call internal read method
21976 this._read(state.highWaterMark);
21977 state.sync = false;
21978 // If _read pushed data synchronously, then `reading` will be false,
21979 // and we need to re-evaluate how much data we can return to the user.
21980 if (!state.reading) n = howMuchToRead(nOrig, state);
21981 }
21982
21983 var ret;
21984 if (n > 0) ret = fromList(n, state);else ret = null;
21985
21986 if (ret === null) {
21987 state.needReadable = true;
21988 n = 0;
21989 } else {
21990 state.length -= n;
21991 }
21992
21993 if (state.length === 0) {
21994 // If we have nothing in the buffer, then we want to know
21995 // as soon as we *do* get something into the buffer.
21996 if (!state.ended) state.needReadable = true;
21997
21998 // If we tried to read() past the EOF, then emit end on the next tick.
21999 if (nOrig !== n && state.ended) endReadable(this);
22000 }
22001
22002 if (ret !== null) this.emit('data', ret);
22003
22004 return ret;
22005};
22006
22007function onEofChunk(stream, state) {
22008 if (state.ended) return;
22009 if (state.decoder) {
22010 var chunk = state.decoder.end();
22011 if (chunk && chunk.length) {
22012 state.buffer.push(chunk);
22013 state.length += state.objectMode ? 1 : chunk.length;
22014 }
22015 }
22016 state.ended = true;
22017
22018 // emit 'readable' now to make sure it gets picked up.
22019 emitReadable(stream);
22020}
22021
22022// Don't emit readable right away in sync mode, because this can trigger
22023// another read() call => stack overflow. This way, it might trigger
22024// a nextTick recursion warning, but that's not so bad.
22025function emitReadable(stream) {
22026 var state = stream._readableState;
22027 state.needReadable = false;
22028 if (!state.emittedReadable) {
22029 debug('emitReadable', state.flowing);
22030 state.emittedReadable = true;
22031 if (state.sync) processNextTick(emitReadable_, stream);else emitReadable_(stream);
22032 }
22033}
22034
22035function emitReadable_(stream) {
22036 debug('emit readable');
22037 stream.emit('readable');
22038 flow(stream);
22039}
22040
22041// at this point, the user has presumably seen the 'readable' event,
22042// and called read() to consume some data. that may have triggered
22043// in turn another _read(n) call, in which case reading = true if
22044// it's in progress.
22045// However, if we're not ended, or reading, and the length < hwm,
22046// then go ahead and try to read some more preemptively.
22047function maybeReadMore(stream, state) {
22048 if (!state.readingMore) {
22049 state.readingMore = true;
22050 processNextTick(maybeReadMore_, stream, state);
22051 }
22052}
22053
22054function maybeReadMore_(stream, state) {
22055 var len = state.length;
22056 while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
22057 debug('maybeReadMore read 0');
22058 stream.read(0);
22059 if (len === state.length)
22060 // didn't get any data, stop spinning.
22061 break;else len = state.length;
22062 }
22063 state.readingMore = false;
22064}
22065
22066// abstract method. to be overridden in specific implementation classes.
22067// call cb(er, data) where data is <= n in length.
22068// for virtual (non-string, non-buffer) streams, "length" is somewhat
22069// arbitrary, and perhaps not very meaningful.
22070Readable.prototype._read = function (n) {
22071 this.emit('error', new Error('_read() is not implemented'));
22072};
22073
22074Readable.prototype.pipe = function (dest, pipeOpts) {
22075 var src = this;
22076 var state = this._readableState;
22077
22078 switch (state.pipesCount) {
22079 case 0:
22080 state.pipes = dest;
22081 break;
22082 case 1:
22083 state.pipes = [state.pipes, dest];
22084 break;
22085 default:
22086 state.pipes.push(dest);
22087 break;
22088 }
22089 state.pipesCount += 1;
22090 debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
22091
22092 var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
22093
22094 var endFn = doEnd ? onend : unpipe;
22095 if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn);
22096
22097 dest.on('unpipe', onunpipe);
22098 function onunpipe(readable, unpipeInfo) {
22099 debug('onunpipe');
22100 if (readable === src) {
22101 if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
22102 unpipeInfo.hasUnpiped = true;
22103 cleanup();
22104 }
22105 }
22106 }
22107
22108 function onend() {
22109 debug('onend');
22110 dest.end();
22111 }
22112
22113 // when the dest drains, it reduces the awaitDrain counter
22114 // on the source. This would be more elegant with a .once()
22115 // handler in flow(), but adding and removing repeatedly is
22116 // too slow.
22117 var ondrain = pipeOnDrain(src);
22118 dest.on('drain', ondrain);
22119
22120 var cleanedUp = false;
22121 function cleanup() {
22122 debug('cleanup');
22123 // cleanup event handlers once the pipe is broken
22124 dest.removeListener('close', onclose);
22125 dest.removeListener('finish', onfinish);
22126 dest.removeListener('drain', ondrain);
22127 dest.removeListener('error', onerror);
22128 dest.removeListener('unpipe', onunpipe);
22129 src.removeListener('end', onend);
22130 src.removeListener('end', unpipe);
22131 src.removeListener('data', ondata);
22132
22133 cleanedUp = true;
22134
22135 // if the reader is waiting for a drain event from this
22136 // specific writer, then it would cause it to never start
22137 // flowing again.
22138 // So, if this is awaiting a drain, then we just call it now.
22139 // If we don't know, then assume that we are waiting for one.
22140 if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
22141 }
22142
22143 // If the user pushes more data while we're writing to dest then we'll end up
22144 // in ondata again. However, we only want to increase awaitDrain once because
22145 // dest will only emit one 'drain' event for the multiple writes.
22146 // => Introduce a guard on increasing awaitDrain.
22147 var increasedAwaitDrain = false;
22148 src.on('data', ondata);
22149 function ondata(chunk) {
22150 debug('ondata');
22151 increasedAwaitDrain = false;
22152 var ret = dest.write(chunk);
22153 if (false === ret && !increasedAwaitDrain) {
22154 // If the user unpiped during `dest.write()`, it is possible
22155 // to get stuck in a permanently paused state if that write
22156 // also returned false.
22157 // => Check whether `dest` is still a piping destination.
22158 if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
22159 debug('false write response, pause', src._readableState.awaitDrain);
22160 src._readableState.awaitDrain++;
22161 increasedAwaitDrain = true;
22162 }
22163 src.pause();
22164 }
22165 }
22166
22167 // if the dest has an error, then stop piping into it.
22168 // however, don't suppress the throwing behavior for this.
22169 function onerror(er) {
22170 debug('onerror', er);
22171 unpipe();
22172 dest.removeListener('error', onerror);
22173 if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
22174 }
22175
22176 // Make sure our error handler is attached before userland ones.
22177 prependListener(dest, 'error', onerror);
22178
22179 // Both close and finish should trigger unpipe, but only once.
22180 function onclose() {
22181 dest.removeListener('finish', onfinish);
22182 unpipe();
22183 }
22184 dest.once('close', onclose);
22185 function onfinish() {
22186 debug('onfinish');
22187 dest.removeListener('close', onclose);
22188 unpipe();
22189 }
22190 dest.once('finish', onfinish);
22191
22192 function unpipe() {
22193 debug('unpipe');
22194 src.unpipe(dest);
22195 }
22196
22197 // tell the dest that it's being piped to
22198 dest.emit('pipe', src);
22199
22200 // start the flow if it hasn't been started already.
22201 if (!state.flowing) {
22202 debug('pipe resume');
22203 src.resume();
22204 }
22205
22206 return dest;
22207};
22208
22209function pipeOnDrain(src) {
22210 return function () {
22211 var state = src._readableState;
22212 debug('pipeOnDrain', state.awaitDrain);
22213 if (state.awaitDrain) state.awaitDrain--;
22214 if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
22215 state.flowing = true;
22216 flow(src);
22217 }
22218 };
22219}
22220
22221Readable.prototype.unpipe = function (dest) {
22222 var state = this._readableState;
22223 var unpipeInfo = { hasUnpiped: false };
22224
22225 // if we're not piping anywhere, then do nothing.
22226 if (state.pipesCount === 0) return this;
22227
22228 // just one destination. most common case.
22229 if (state.pipesCount === 1) {
22230 // passed in one, but it's not the right one.
22231 if (dest && dest !== state.pipes) return this;
22232
22233 if (!dest) dest = state.pipes;
22234
22235 // got a match.
22236 state.pipes = null;
22237 state.pipesCount = 0;
22238 state.flowing = false;
22239 if (dest) dest.emit('unpipe', this, unpipeInfo);
22240 return this;
22241 }
22242
22243 // slow case. multiple pipe destinations.
22244
22245 if (!dest) {
22246 // remove all.
22247 var dests = state.pipes;
22248 var len = state.pipesCount;
22249 state.pipes = null;
22250 state.pipesCount = 0;
22251 state.flowing = false;
22252
22253 for (var i = 0; i < len; i++) {
22254 dests[i].emit('unpipe', this, unpipeInfo);
22255 }return this;
22256 }
22257
22258 // try to find the right one.
22259 var index = indexOf(state.pipes, dest);
22260 if (index === -1) return this;
22261
22262 state.pipes.splice(index, 1);
22263 state.pipesCount -= 1;
22264 if (state.pipesCount === 1) state.pipes = state.pipes[0];
22265
22266 dest.emit('unpipe', this, unpipeInfo);
22267
22268 return this;
22269};
22270
22271// set up data events if they are asked for
22272// Ensure readable listeners eventually get something
22273Readable.prototype.on = function (ev, fn) {
22274 var res = Stream.prototype.on.call(this, ev, fn);
22275
22276 if (ev === 'data') {
22277 // Start flowing on next tick if stream isn't explicitly paused
22278 if (this._readableState.flowing !== false) this.resume();
22279 } else if (ev === 'readable') {
22280 var state = this._readableState;
22281 if (!state.endEmitted && !state.readableListening) {
22282 state.readableListening = state.needReadable = true;
22283 state.emittedReadable = false;
22284 if (!state.reading) {
22285 processNextTick(nReadingNextTick, this);
22286 } else if (state.length) {
22287 emitReadable(this);
22288 }
22289 }
22290 }
22291
22292 return res;
22293};
22294Readable.prototype.addListener = Readable.prototype.on;
22295
22296function nReadingNextTick(self) {
22297 debug('readable nexttick read 0');
22298 self.read(0);
22299}
22300
22301// pause() and resume() are remnants of the legacy readable stream API
22302// If the user uses them, then switch into old mode.
22303Readable.prototype.resume = function () {
22304 var state = this._readableState;
22305 if (!state.flowing) {
22306 debug('resume');
22307 state.flowing = true;
22308 resume(this, state);
22309 }
22310 return this;
22311};
22312
22313function resume(stream, state) {
22314 if (!state.resumeScheduled) {
22315 state.resumeScheduled = true;
22316 processNextTick(resume_, stream, state);
22317 }
22318}
22319
22320function resume_(stream, state) {
22321 if (!state.reading) {
22322 debug('resume read 0');
22323 stream.read(0);
22324 }
22325
22326 state.resumeScheduled = false;
22327 state.awaitDrain = 0;
22328 stream.emit('resume');
22329 flow(stream);
22330 if (state.flowing && !state.reading) stream.read(0);
22331}
22332
22333Readable.prototype.pause = function () {
22334 debug('call pause flowing=%j', this._readableState.flowing);
22335 if (false !== this._readableState.flowing) {
22336 debug('pause');
22337 this._readableState.flowing = false;
22338 this.emit('pause');
22339 }
22340 return this;
22341};
22342
22343function flow(stream) {
22344 var state = stream._readableState;
22345 debug('flow', state.flowing);
22346 while (state.flowing && stream.read() !== null) {}
22347}
22348
22349// wrap an old-style stream as the async data source.
22350// This is *not* part of the readable stream interface.
22351// It is an ugly unfortunate mess of history.
22352Readable.prototype.wrap = function (stream) {
22353 var state = this._readableState;
22354 var paused = false;
22355
22356 var self = this;
22357 stream.on('end', function () {
22358 debug('wrapped end');
22359 if (state.decoder && !state.ended) {
22360 var chunk = state.decoder.end();
22361 if (chunk && chunk.length) self.push(chunk);
22362 }
22363
22364 self.push(null);
22365 });
22366
22367 stream.on('data', function (chunk) {
22368 debug('wrapped data');
22369 if (state.decoder) chunk = state.decoder.write(chunk);
22370
22371 // don't skip over falsy values in objectMode
22372 if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
22373
22374 var ret = self.push(chunk);
22375 if (!ret) {
22376 paused = true;
22377 stream.pause();
22378 }
22379 });
22380
22381 // proxy all the other methods.
22382 // important when wrapping filters and duplexes.
22383 for (var i in stream) {
22384 if (this[i] === undefined && typeof stream[i] === 'function') {
22385 this[i] = function (method) {
22386 return function () {
22387 return stream[method].apply(stream, arguments);
22388 };
22389 }(i);
22390 }
22391 }
22392
22393 // proxy certain important events.
22394 for (var n = 0; n < kProxyEvents.length; n++) {
22395 stream.on(kProxyEvents[n], self.emit.bind(self, kProxyEvents[n]));
22396 }
22397
22398 // when we try to consume some more bytes, simply unpause the
22399 // underlying stream.
22400 self._read = function (n) {
22401 debug('wrapped _read', n);
22402 if (paused) {
22403 paused = false;
22404 stream.resume();
22405 }
22406 };
22407
22408 return self;
22409};
22410
22411// exposed for testing purposes only.
22412Readable._fromList = fromList;
22413
22414// Pluck off n bytes from an array of buffers.
22415// Length is the combined lengths of all the buffers in the list.
22416// This function is designed to be inlinable, so please take care when making
22417// changes to the function body.
22418function fromList(n, state) {
22419 // nothing buffered
22420 if (state.length === 0) return null;
22421
22422 var ret;
22423 if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
22424 // read it all, truncate the list
22425 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);
22426 state.buffer.clear();
22427 } else {
22428 // read part of list
22429 ret = fromListPartial(n, state.buffer, state.decoder);
22430 }
22431
22432 return ret;
22433}
22434
22435// Extracts only enough buffered data to satisfy the amount requested.
22436// This function is designed to be inlinable, so please take care when making
22437// changes to the function body.
22438function fromListPartial(n, list, hasStrings) {
22439 var ret;
22440 if (n < list.head.data.length) {
22441 // slice is the same for buffers and strings
22442 ret = list.head.data.slice(0, n);
22443 list.head.data = list.head.data.slice(n);
22444 } else if (n === list.head.data.length) {
22445 // first chunk is a perfect match
22446 ret = list.shift();
22447 } else {
22448 // result spans more than one buffer
22449 ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
22450 }
22451 return ret;
22452}
22453
22454// Copies a specified amount of characters from the list of buffered data
22455// chunks.
22456// This function is designed to be inlinable, so please take care when making
22457// changes to the function body.
22458function copyFromBufferString(n, list) {
22459 var p = list.head;
22460 var c = 1;
22461 var ret = p.data;
22462 n -= ret.length;
22463 while (p = p.next) {
22464 var str = p.data;
22465 var nb = n > str.length ? str.length : n;
22466 if (nb === str.length) ret += str;else ret += str.slice(0, n);
22467 n -= nb;
22468 if (n === 0) {
22469 if (nb === str.length) {
22470 ++c;
22471 if (p.next) list.head = p.next;else list.head = list.tail = null;
22472 } else {
22473 list.head = p;
22474 p.data = str.slice(nb);
22475 }
22476 break;
22477 }
22478 ++c;
22479 }
22480 list.length -= c;
22481 return ret;
22482}
22483
22484// Copies a specified amount of bytes from the list of buffered data chunks.
22485// This function is designed to be inlinable, so please take care when making
22486// changes to the function body.
22487function copyFromBuffer(n, list) {
22488 var ret = Buffer.allocUnsafe(n);
22489 var p = list.head;
22490 var c = 1;
22491 p.data.copy(ret);
22492 n -= p.data.length;
22493 while (p = p.next) {
22494 var buf = p.data;
22495 var nb = n > buf.length ? buf.length : n;
22496 buf.copy(ret, ret.length - n, 0, nb);
22497 n -= nb;
22498 if (n === 0) {
22499 if (nb === buf.length) {
22500 ++c;
22501 if (p.next) list.head = p.next;else list.head = list.tail = null;
22502 } else {
22503 list.head = p;
22504 p.data = buf.slice(nb);
22505 }
22506 break;
22507 }
22508 ++c;
22509 }
22510 list.length -= c;
22511 return ret;
22512}
22513
22514function endReadable(stream) {
22515 var state = stream._readableState;
22516
22517 // If we get here before consuming all the bytes, then that is a
22518 // bug in node. Should never happen.
22519 if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
22520
22521 if (!state.endEmitted) {
22522 state.ended = true;
22523 processNextTick(endReadableNT, state, stream);
22524 }
22525}
22526
22527function endReadableNT(state, stream) {
22528 // Check that we didn't get one last unshift.
22529 if (!state.endEmitted && state.length === 0) {
22530 state.endEmitted = true;
22531 stream.readable = false;
22532 stream.emit('end');
22533 }
22534}
22535
22536function forEach(xs, f) {
22537 for (var i = 0, l = xs.length; i < l; i++) {
22538 f(xs[i], i);
22539 }
22540}
22541
22542function indexOf(xs, x) {
22543 for (var i = 0, l = xs.length; i < l; i++) {
22544 if (xs[i] === x) return i;
22545 }
22546 return -1;
22547}
22548}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
22549},{"./_stream_duplex":291,"./internal/streams/BufferList":296,"./internal/streams/destroy":297,"./internal/streams/stream":298,"_process":281,"core-util-is":208,"events":242,"inherits":260,"isarray":262,"process-nextick-args":280,"safe-buffer":305,"string_decoder/":299,"util":45}],294:[function(require,module,exports){
22550// Copyright Joyent, Inc. and other Node contributors.
22551//
22552// Permission is hereby granted, free of charge, to any person obtaining a
22553// copy of this software and associated documentation files (the
22554// "Software"), to deal in the Software without restriction, including
22555// without limitation the rights to use, copy, modify, merge, publish,
22556// distribute, sublicense, and/or sell copies of the Software, and to permit
22557// persons to whom the Software is furnished to do so, subject to the
22558// following conditions:
22559//
22560// The above copyright notice and this permission notice shall be included
22561// in all copies or substantial portions of the Software.
22562//
22563// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22564// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22565// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
22566// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22567// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22568// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22569// USE OR OTHER DEALINGS IN THE SOFTWARE.
22570
22571// a transform stream is a readable/writable stream where you do
22572// something with the data. Sometimes it's called a "filter",
22573// but that's not a great name for it, since that implies a thing where
22574// some bits pass through, and others are simply ignored. (That would
22575// be a valid example of a transform, of course.)
22576//
22577// While the output is causally related to the input, it's not a
22578// necessarily symmetric or synchronous transformation. For example,
22579// a zlib stream might take multiple plain-text writes(), and then
22580// emit a single compressed chunk some time in the future.
22581//
22582// Here's how this works:
22583//
22584// The Transform stream has all the aspects of the readable and writable
22585// stream classes. When you write(chunk), that calls _write(chunk,cb)
22586// internally, and returns false if there's a lot of pending writes
22587// buffered up. When you call read(), that calls _read(n) until
22588// there's enough pending readable data buffered up.
22589//
22590// In a transform stream, the written data is placed in a buffer. When
22591// _read(n) is called, it transforms the queued up data, calling the
22592// buffered _write cb's as it consumes chunks. If consuming a single
22593// written chunk would result in multiple output chunks, then the first
22594// outputted bit calls the readcb, and subsequent chunks just go into
22595// the read buffer, and will cause it to emit 'readable' if necessary.
22596//
22597// This way, back-pressure is actually determined by the reading side,
22598// since _read has to be called to start processing a new chunk. However,
22599// a pathological inflate type of transform can cause excessive buffering
22600// here. For example, imagine a stream where every byte of input is
22601// interpreted as an integer from 0-255, and then results in that many
22602// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
22603// 1kb of data being output. In this case, you could write a very small
22604// amount of input, and end up with a very large amount of output. In
22605// such a pathological inflating mechanism, there'd be no way to tell
22606// the system to stop doing the transform. A single 4MB write could
22607// cause the system to run out of memory.
22608//
22609// However, even in such a pathological case, only a single written chunk
22610// would be consumed, and then the rest would wait (un-transformed) until
22611// the results of the previous transformed chunk were consumed.
22612
22613'use strict';
22614
22615module.exports = Transform;
22616
22617var Duplex = require('./_stream_duplex');
22618
22619/*<replacement>*/
22620var util = require('core-util-is');
22621util.inherits = require('inherits');
22622/*</replacement>*/
22623
22624util.inherits(Transform, Duplex);
22625
22626function TransformState(stream) {
22627 this.afterTransform = function (er, data) {
22628 return afterTransform(stream, er, data);
22629 };
22630
22631 this.needTransform = false;
22632 this.transforming = false;
22633 this.writecb = null;
22634 this.writechunk = null;
22635 this.writeencoding = null;
22636}
22637
22638function afterTransform(stream, er, data) {
22639 var ts = stream._transformState;
22640 ts.transforming = false;
22641
22642 var cb = ts.writecb;
22643
22644 if (!cb) {
22645 return stream.emit('error', new Error('write callback called multiple times'));
22646 }
22647
22648 ts.writechunk = null;
22649 ts.writecb = null;
22650
22651 if (data !== null && data !== undefined) stream.push(data);
22652
22653 cb(er);
22654
22655 var rs = stream._readableState;
22656 rs.reading = false;
22657 if (rs.needReadable || rs.length < rs.highWaterMark) {
22658 stream._read(rs.highWaterMark);
22659 }
22660}
22661
22662function Transform(options) {
22663 if (!(this instanceof Transform)) return new Transform(options);
22664
22665 Duplex.call(this, options);
22666
22667 this._transformState = new TransformState(this);
22668
22669 var stream = this;
22670
22671 // start out asking for a readable event once data is transformed.
22672 this._readableState.needReadable = true;
22673
22674 // we have implemented the _read method, and done the other things
22675 // that Readable wants before the first _read call, so unset the
22676 // sync guard flag.
22677 this._readableState.sync = false;
22678
22679 if (options) {
22680 if (typeof options.transform === 'function') this._transform = options.transform;
22681
22682 if (typeof options.flush === 'function') this._flush = options.flush;
22683 }
22684
22685 // When the writable side finishes, then flush out anything remaining.
22686 this.once('prefinish', function () {
22687 if (typeof this._flush === 'function') this._flush(function (er, data) {
22688 done(stream, er, data);
22689 });else done(stream);
22690 });
22691}
22692
22693Transform.prototype.push = function (chunk, encoding) {
22694 this._transformState.needTransform = false;
22695 return Duplex.prototype.push.call(this, chunk, encoding);
22696};
22697
22698// This is the part where you do stuff!
22699// override this function in implementation classes.
22700// 'chunk' is an input chunk.
22701//
22702// Call `push(newChunk)` to pass along transformed output
22703// to the readable side. You may call 'push' zero or more times.
22704//
22705// Call `cb(err)` when you are done with this chunk. If you pass
22706// an error, then that'll put the hurt on the whole operation. If you
22707// never call cb(), then you'll never get another chunk.
22708Transform.prototype._transform = function (chunk, encoding, cb) {
22709 throw new Error('_transform() is not implemented');
22710};
22711
22712Transform.prototype._write = function (chunk, encoding, cb) {
22713 var ts = this._transformState;
22714 ts.writecb = cb;
22715 ts.writechunk = chunk;
22716 ts.writeencoding = encoding;
22717 if (!ts.transforming) {
22718 var rs = this._readableState;
22719 if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
22720 }
22721};
22722
22723// Doesn't matter what the args are here.
22724// _transform does all the work.
22725// That we got here means that the readable side wants more data.
22726Transform.prototype._read = function (n) {
22727 var ts = this._transformState;
22728
22729 if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
22730 ts.transforming = true;
22731 this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
22732 } else {
22733 // mark that we need a transform, so that any data that comes in
22734 // will get processed, now that we've asked for it.
22735 ts.needTransform = true;
22736 }
22737};
22738
22739Transform.prototype._destroy = function (err, cb) {
22740 var _this = this;
22741
22742 Duplex.prototype._destroy.call(this, err, function (err2) {
22743 cb(err2);
22744 _this.emit('close');
22745 });
22746};
22747
22748function done(stream, er, data) {
22749 if (er) return stream.emit('error', er);
22750
22751 if (data !== null && data !== undefined) stream.push(data);
22752
22753 // if there's nothing in the write buffer, then that means
22754 // that nothing more will ever be provided
22755 var ws = stream._writableState;
22756 var ts = stream._transformState;
22757
22758 if (ws.length) throw new Error('Calling transform done when ws.length != 0');
22759
22760 if (ts.transforming) throw new Error('Calling transform done when still transforming');
22761
22762 return stream.push(null);
22763}
22764},{"./_stream_duplex":291,"core-util-is":208,"inherits":260}],295:[function(require,module,exports){
22765(function (process,global){
22766// Copyright Joyent, Inc. and other Node contributors.
22767//
22768// Permission is hereby granted, free of charge, to any person obtaining a
22769// copy of this software and associated documentation files (the
22770// "Software"), to deal in the Software without restriction, including
22771// without limitation the rights to use, copy, modify, merge, publish,
22772// distribute, sublicense, and/or sell copies of the Software, and to permit
22773// persons to whom the Software is furnished to do so, subject to the
22774// following conditions:
22775//
22776// The above copyright notice and this permission notice shall be included
22777// in all copies or substantial portions of the Software.
22778//
22779// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22780// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22781// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
22782// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22783// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22784// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22785// USE OR OTHER DEALINGS IN THE SOFTWARE.
22786
22787// A bit simpler than readable streams.
22788// Implement an async ._write(chunk, encoding, cb), and it'll handle all
22789// the drain event emission and buffering.
22790
22791'use strict';
22792
22793/*<replacement>*/
22794
22795var processNextTick = require('process-nextick-args');
22796/*</replacement>*/
22797
22798module.exports = Writable;
22799
22800/* <replacement> */
22801function WriteReq(chunk, encoding, cb) {
22802 this.chunk = chunk;
22803 this.encoding = encoding;
22804 this.callback = cb;
22805 this.next = null;
22806}
22807
22808// It seems a linked list but it is not
22809// there will be only 2 of these for each stream
22810function CorkedRequest(state) {
22811 var _this = this;
22812
22813 this.next = null;
22814 this.entry = null;
22815 this.finish = function () {
22816 onCorkedFinish(_this, state);
22817 };
22818}
22819/* </replacement> */
22820
22821/*<replacement>*/
22822var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick;
22823/*</replacement>*/
22824
22825/*<replacement>*/
22826var Duplex;
22827/*</replacement>*/
22828
22829Writable.WritableState = WritableState;
22830
22831/*<replacement>*/
22832var util = require('core-util-is');
22833util.inherits = require('inherits');
22834/*</replacement>*/
22835
22836/*<replacement>*/
22837var internalUtil = {
22838 deprecate: require('util-deprecate')
22839};
22840/*</replacement>*/
22841
22842/*<replacement>*/
22843var Stream = require('./internal/streams/stream');
22844/*</replacement>*/
22845
22846/*<replacement>*/
22847var Buffer = require('safe-buffer').Buffer;
22848var OurUint8Array = global.Uint8Array || function () {};
22849function _uint8ArrayToBuffer(chunk) {
22850 return Buffer.from(chunk);
22851}
22852function _isUint8Array(obj) {
22853 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
22854}
22855/*</replacement>*/
22856
22857var destroyImpl = require('./internal/streams/destroy');
22858
22859util.inherits(Writable, Stream);
22860
22861function nop() {}
22862
22863function WritableState(options, stream) {
22864 Duplex = Duplex || require('./_stream_duplex');
22865
22866 options = options || {};
22867
22868 // object stream flag to indicate whether or not this stream
22869 // contains buffers or objects.
22870 this.objectMode = !!options.objectMode;
22871
22872 if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
22873
22874 // the point at which write() starts returning false
22875 // Note: 0 is a valid value, means that we always return false if
22876 // the entire buffer is not flushed immediately on write()
22877 var hwm = options.highWaterMark;
22878 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
22879 this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
22880
22881 // cast to ints.
22882 this.highWaterMark = Math.floor(this.highWaterMark);
22883
22884 // if _final has been called
22885 this.finalCalled = false;
22886
22887 // drain event flag.
22888 this.needDrain = false;
22889 // at the start of calling end()
22890 this.ending = false;
22891 // when end() has been called, and returned
22892 this.ended = false;
22893 // when 'finish' is emitted
22894 this.finished = false;
22895
22896 // has it been destroyed
22897 this.destroyed = false;
22898
22899 // should we decode strings into buffers before passing to _write?
22900 // this is here so that some node-core streams can optimize string
22901 // handling at a lower level.
22902 var noDecode = options.decodeStrings === false;
22903 this.decodeStrings = !noDecode;
22904
22905 // Crypto is kind of old and crusty. Historically, its default string
22906 // encoding is 'binary' so we have to make this configurable.
22907 // Everything else in the universe uses 'utf8', though.
22908 this.defaultEncoding = options.defaultEncoding || 'utf8';
22909
22910 // not an actual buffer we keep track of, but a measurement
22911 // of how much we're waiting to get pushed to some underlying
22912 // socket or file.
22913 this.length = 0;
22914
22915 // a flag to see when we're in the middle of a write.
22916 this.writing = false;
22917
22918 // when true all writes will be buffered until .uncork() call
22919 this.corked = 0;
22920
22921 // a flag to be able to tell if the onwrite cb is called immediately,
22922 // or on a later tick. We set this to true at first, because any
22923 // actions that shouldn't happen until "later" should generally also
22924 // not happen before the first write call.
22925 this.sync = true;
22926
22927 // a flag to know if we're processing previously buffered items, which
22928 // may call the _write() callback in the same tick, so that we don't
22929 // end up in an overlapped onwrite situation.
22930 this.bufferProcessing = false;
22931
22932 // the callback that's passed to _write(chunk,cb)
22933 this.onwrite = function (er) {
22934 onwrite(stream, er);
22935 };
22936
22937 // the callback that the user supplies to write(chunk,encoding,cb)
22938 this.writecb = null;
22939
22940 // the amount that is being written when _write is called.
22941 this.writelen = 0;
22942
22943 this.bufferedRequest = null;
22944 this.lastBufferedRequest = null;
22945
22946 // number of pending user-supplied write callbacks
22947 // this must be 0 before 'finish' can be emitted
22948 this.pendingcb = 0;
22949
22950 // emit prefinish if the only thing we're waiting for is _write cbs
22951 // This is relevant for synchronous Transform streams
22952 this.prefinished = false;
22953
22954 // True if the error was already emitted and should not be thrown again
22955 this.errorEmitted = false;
22956
22957 // count buffered requests
22958 this.bufferedRequestCount = 0;
22959
22960 // allocate the first CorkedRequest, there is always
22961 // one allocated and free to use, and we maintain at most two
22962 this.corkedRequestsFree = new CorkedRequest(this);
22963}
22964
22965WritableState.prototype.getBuffer = function getBuffer() {
22966 var current = this.bufferedRequest;
22967 var out = [];
22968 while (current) {
22969 out.push(current);
22970 current = current.next;
22971 }
22972 return out;
22973};
22974
22975(function () {
22976 try {
22977 Object.defineProperty(WritableState.prototype, 'buffer', {
22978 get: internalUtil.deprecate(function () {
22979 return this.getBuffer();
22980 }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
22981 });
22982 } catch (_) {}
22983})();
22984
22985// Test _writableState for inheritance to account for Duplex streams,
22986// whose prototype chain only points to Readable.
22987var realHasInstance;
22988if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
22989 realHasInstance = Function.prototype[Symbol.hasInstance];
22990 Object.defineProperty(Writable, Symbol.hasInstance, {
22991 value: function (object) {
22992 if (realHasInstance.call(this, object)) return true;
22993
22994 return object && object._writableState instanceof WritableState;
22995 }
22996 });
22997} else {
22998 realHasInstance = function (object) {
22999 return object instanceof this;
23000 };
23001}
23002
23003function Writable(options) {
23004 Duplex = Duplex || require('./_stream_duplex');
23005
23006 // Writable ctor is applied to Duplexes, too.
23007 // `realHasInstance` is necessary because using plain `instanceof`
23008 // would return false, as no `_writableState` property is attached.
23009
23010 // Trying to use the custom `instanceof` for Writable here will also break the
23011 // Node.js LazyTransform implementation, which has a non-trivial getter for
23012 // `_writableState` that would lead to infinite recursion.
23013 if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
23014 return new Writable(options);
23015 }
23016
23017 this._writableState = new WritableState(options, this);
23018
23019 // legacy.
23020 this.writable = true;
23021
23022 if (options) {
23023 if (typeof options.write === 'function') this._write = options.write;
23024
23025 if (typeof options.writev === 'function') this._writev = options.writev;
23026
23027 if (typeof options.destroy === 'function') this._destroy = options.destroy;
23028
23029 if (typeof options.final === 'function') this._final = options.final;
23030 }
23031
23032 Stream.call(this);
23033}
23034
23035// Otherwise people can pipe Writable streams, which is just wrong.
23036Writable.prototype.pipe = function () {
23037 this.emit('error', new Error('Cannot pipe, not readable'));
23038};
23039
23040function writeAfterEnd(stream, cb) {
23041 var er = new Error('write after end');
23042 // TODO: defer error events consistently everywhere, not just the cb
23043 stream.emit('error', er);
23044 processNextTick(cb, er);
23045}
23046
23047// Checks that a user-supplied chunk is valid, especially for the particular
23048// mode the stream is in. Currently this means that `null` is never accepted
23049// and undefined/non-string values are only allowed in object mode.
23050function validChunk(stream, state, chunk, cb) {
23051 var valid = true;
23052 var er = false;
23053
23054 if (chunk === null) {
23055 er = new TypeError('May not write null values to stream');
23056 } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
23057 er = new TypeError('Invalid non-string/buffer chunk');
23058 }
23059 if (er) {
23060 stream.emit('error', er);
23061 processNextTick(cb, er);
23062 valid = false;
23063 }
23064 return valid;
23065}
23066
23067Writable.prototype.write = function (chunk, encoding, cb) {
23068 var state = this._writableState;
23069 var ret = false;
23070 var isBuf = _isUint8Array(chunk) && !state.objectMode;
23071
23072 if (isBuf && !Buffer.isBuffer(chunk)) {
23073 chunk = _uint8ArrayToBuffer(chunk);
23074 }
23075
23076 if (typeof encoding === 'function') {
23077 cb = encoding;
23078 encoding = null;
23079 }
23080
23081 if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
23082
23083 if (typeof cb !== 'function') cb = nop;
23084
23085 if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
23086 state.pendingcb++;
23087 ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
23088 }
23089
23090 return ret;
23091};
23092
23093Writable.prototype.cork = function () {
23094 var state = this._writableState;
23095
23096 state.corked++;
23097};
23098
23099Writable.prototype.uncork = function () {
23100 var state = this._writableState;
23101
23102 if (state.corked) {
23103 state.corked--;
23104
23105 if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
23106 }
23107};
23108
23109Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
23110 // node::ParseEncoding() requires lower case.
23111 if (typeof encoding === 'string') encoding = encoding.toLowerCase();
23112 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);
23113 this._writableState.defaultEncoding = encoding;
23114 return this;
23115};
23116
23117function decodeChunk(state, chunk, encoding) {
23118 if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
23119 chunk = Buffer.from(chunk, encoding);
23120 }
23121 return chunk;
23122}
23123
23124// if we're already writing something, then just put this
23125// in the queue, and wait our turn. Otherwise, call _write
23126// If we return false, then we need a drain event, so set that flag.
23127function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
23128 if (!isBuf) {
23129 var newChunk = decodeChunk(state, chunk, encoding);
23130 if (chunk !== newChunk) {
23131 isBuf = true;
23132 encoding = 'buffer';
23133 chunk = newChunk;
23134 }
23135 }
23136 var len = state.objectMode ? 1 : chunk.length;
23137
23138 state.length += len;
23139
23140 var ret = state.length < state.highWaterMark;
23141 // we must ensure that previous needDrain will not be reset to false.
23142 if (!ret) state.needDrain = true;
23143
23144 if (state.writing || state.corked) {
23145 var last = state.lastBufferedRequest;
23146 state.lastBufferedRequest = {
23147 chunk: chunk,
23148 encoding: encoding,
23149 isBuf: isBuf,
23150 callback: cb,
23151 next: null
23152 };
23153 if (last) {
23154 last.next = state.lastBufferedRequest;
23155 } else {
23156 state.bufferedRequest = state.lastBufferedRequest;
23157 }
23158 state.bufferedRequestCount += 1;
23159 } else {
23160 doWrite(stream, state, false, len, chunk, encoding, cb);
23161 }
23162
23163 return ret;
23164}
23165
23166function doWrite(stream, state, writev, len, chunk, encoding, cb) {
23167 state.writelen = len;
23168 state.writecb = cb;
23169 state.writing = true;
23170 state.sync = true;
23171 if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
23172 state.sync = false;
23173}
23174
23175function onwriteError(stream, state, sync, er, cb) {
23176 --state.pendingcb;
23177
23178 if (sync) {
23179 // defer the callback if we are being called synchronously
23180 // to avoid piling up things on the stack
23181 processNextTick(cb, er);
23182 // this can emit finish, and it will always happen
23183 // after error
23184 processNextTick(finishMaybe, stream, state);
23185 stream._writableState.errorEmitted = true;
23186 stream.emit('error', er);
23187 } else {
23188 // the caller expect this to happen before if
23189 // it is async
23190 cb(er);
23191 stream._writableState.errorEmitted = true;
23192 stream.emit('error', er);
23193 // this can emit finish, but finish must
23194 // always follow error
23195 finishMaybe(stream, state);
23196 }
23197}
23198
23199function onwriteStateUpdate(state) {
23200 state.writing = false;
23201 state.writecb = null;
23202 state.length -= state.writelen;
23203 state.writelen = 0;
23204}
23205
23206function onwrite(stream, er) {
23207 var state = stream._writableState;
23208 var sync = state.sync;
23209 var cb = state.writecb;
23210
23211 onwriteStateUpdate(state);
23212
23213 if (er) onwriteError(stream, state, sync, er, cb);else {
23214 // Check if we're actually ready to finish, but don't emit yet
23215 var finished = needFinish(state);
23216
23217 if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
23218 clearBuffer(stream, state);
23219 }
23220
23221 if (sync) {
23222 /*<replacement>*/
23223 asyncWrite(afterWrite, stream, state, finished, cb);
23224 /*</replacement>*/
23225 } else {
23226 afterWrite(stream, state, finished, cb);
23227 }
23228 }
23229}
23230
23231function afterWrite(stream, state, finished, cb) {
23232 if (!finished) onwriteDrain(stream, state);
23233 state.pendingcb--;
23234 cb();
23235 finishMaybe(stream, state);
23236}
23237
23238// Must force callback to be called on nextTick, so that we don't
23239// emit 'drain' before the write() consumer gets the 'false' return
23240// value, and has a chance to attach a 'drain' listener.
23241function onwriteDrain(stream, state) {
23242 if (state.length === 0 && state.needDrain) {
23243 state.needDrain = false;
23244 stream.emit('drain');
23245 }
23246}
23247
23248// if there's something in the buffer waiting, then process it
23249function clearBuffer(stream, state) {
23250 state.bufferProcessing = true;
23251 var entry = state.bufferedRequest;
23252
23253 if (stream._writev && entry && entry.next) {
23254 // Fast case, write everything using _writev()
23255 var l = state.bufferedRequestCount;
23256 var buffer = new Array(l);
23257 var holder = state.corkedRequestsFree;
23258 holder.entry = entry;
23259
23260 var count = 0;
23261 var allBuffers = true;
23262 while (entry) {
23263 buffer[count] = entry;
23264 if (!entry.isBuf) allBuffers = false;
23265 entry = entry.next;
23266 count += 1;
23267 }
23268 buffer.allBuffers = allBuffers;
23269
23270 doWrite(stream, state, true, state.length, buffer, '', holder.finish);
23271
23272 // doWrite is almost always async, defer these to save a bit of time
23273 // as the hot path ends with doWrite
23274 state.pendingcb++;
23275 state.lastBufferedRequest = null;
23276 if (holder.next) {
23277 state.corkedRequestsFree = holder.next;
23278 holder.next = null;
23279 } else {
23280 state.corkedRequestsFree = new CorkedRequest(state);
23281 }
23282 } else {
23283 // Slow case, write chunks one-by-one
23284 while (entry) {
23285 var chunk = entry.chunk;
23286 var encoding = entry.encoding;
23287 var cb = entry.callback;
23288 var len = state.objectMode ? 1 : chunk.length;
23289
23290 doWrite(stream, state, false, len, chunk, encoding, cb);
23291 entry = entry.next;
23292 // if we didn't call the onwrite immediately, then
23293 // it means that we need to wait until it does.
23294 // also, that means that the chunk and cb are currently
23295 // being processed, so move the buffer counter past them.
23296 if (state.writing) {
23297 break;
23298 }
23299 }
23300
23301 if (entry === null) state.lastBufferedRequest = null;
23302 }
23303
23304 state.bufferedRequestCount = 0;
23305 state.bufferedRequest = entry;
23306 state.bufferProcessing = false;
23307}
23308
23309Writable.prototype._write = function (chunk, encoding, cb) {
23310 cb(new Error('_write() is not implemented'));
23311};
23312
23313Writable.prototype._writev = null;
23314
23315Writable.prototype.end = function (chunk, encoding, cb) {
23316 var state = this._writableState;
23317
23318 if (typeof chunk === 'function') {
23319 cb = chunk;
23320 chunk = null;
23321 encoding = null;
23322 } else if (typeof encoding === 'function') {
23323 cb = encoding;
23324 encoding = null;
23325 }
23326
23327 if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
23328
23329 // .end() fully uncorks
23330 if (state.corked) {
23331 state.corked = 1;
23332 this.uncork();
23333 }
23334
23335 // ignore unnecessary end() calls.
23336 if (!state.ending && !state.finished) endWritable(this, state, cb);
23337};
23338
23339function needFinish(state) {
23340 return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
23341}
23342function callFinal(stream, state) {
23343 stream._final(function (err) {
23344 state.pendingcb--;
23345 if (err) {
23346 stream.emit('error', err);
23347 }
23348 state.prefinished = true;
23349 stream.emit('prefinish');
23350 finishMaybe(stream, state);
23351 });
23352}
23353function prefinish(stream, state) {
23354 if (!state.prefinished && !state.finalCalled) {
23355 if (typeof stream._final === 'function') {
23356 state.pendingcb++;
23357 state.finalCalled = true;
23358 processNextTick(callFinal, stream, state);
23359 } else {
23360 state.prefinished = true;
23361 stream.emit('prefinish');
23362 }
23363 }
23364}
23365
23366function finishMaybe(stream, state) {
23367 var need = needFinish(state);
23368 if (need) {
23369 prefinish(stream, state);
23370 if (state.pendingcb === 0) {
23371 state.finished = true;
23372 stream.emit('finish');
23373 }
23374 }
23375 return need;
23376}
23377
23378function endWritable(stream, state, cb) {
23379 state.ending = true;
23380 finishMaybe(stream, state);
23381 if (cb) {
23382 if (state.finished) processNextTick(cb);else stream.once('finish', cb);
23383 }
23384 state.ended = true;
23385 stream.writable = false;
23386}
23387
23388function onCorkedFinish(corkReq, state, err) {
23389 var entry = corkReq.entry;
23390 corkReq.entry = null;
23391 while (entry) {
23392 var cb = entry.callback;
23393 state.pendingcb--;
23394 cb(err);
23395 entry = entry.next;
23396 }
23397 if (state.corkedRequestsFree) {
23398 state.corkedRequestsFree.next = corkReq;
23399 } else {
23400 state.corkedRequestsFree = corkReq;
23401 }
23402}
23403
23404Object.defineProperty(Writable.prototype, 'destroyed', {
23405 get: function () {
23406 if (this._writableState === undefined) {
23407 return false;
23408 }
23409 return this._writableState.destroyed;
23410 },
23411 set: function (value) {
23412 // we ignore the value if the stream
23413 // has not been initialized yet
23414 if (!this._writableState) {
23415 return;
23416 }
23417
23418 // backward compatibility, the user is explicitly
23419 // managing destroyed
23420 this._writableState.destroyed = value;
23421 }
23422});
23423
23424Writable.prototype.destroy = destroyImpl.destroy;
23425Writable.prototype._undestroy = destroyImpl.undestroy;
23426Writable.prototype._destroy = function (err, cb) {
23427 this.end();
23428 cb(err);
23429};
23430}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
23431},{"./_stream_duplex":291,"./internal/streams/destroy":297,"./internal/streams/stream":298,"_process":281,"core-util-is":208,"inherits":260,"process-nextick-args":280,"safe-buffer":305,"util-deprecate":317}],296:[function(require,module,exports){
23432'use strict';
23433
23434/*<replacement>*/
23435
23436function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
23437
23438var Buffer = require('safe-buffer').Buffer;
23439/*</replacement>*/
23440
23441function copyBuffer(src, target, offset) {
23442 src.copy(target, offset);
23443}
23444
23445module.exports = function () {
23446 function BufferList() {
23447 _classCallCheck(this, BufferList);
23448
23449 this.head = null;
23450 this.tail = null;
23451 this.length = 0;
23452 }
23453
23454 BufferList.prototype.push = function push(v) {
23455 var entry = { data: v, next: null };
23456 if (this.length > 0) this.tail.next = entry;else this.head = entry;
23457 this.tail = entry;
23458 ++this.length;
23459 };
23460
23461 BufferList.prototype.unshift = function unshift(v) {
23462 var entry = { data: v, next: this.head };
23463 if (this.length === 0) this.tail = entry;
23464 this.head = entry;
23465 ++this.length;
23466 };
23467
23468 BufferList.prototype.shift = function shift() {
23469 if (this.length === 0) return;
23470 var ret = this.head.data;
23471 if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
23472 --this.length;
23473 return ret;
23474 };
23475
23476 BufferList.prototype.clear = function clear() {
23477 this.head = this.tail = null;
23478 this.length = 0;
23479 };
23480
23481 BufferList.prototype.join = function join(s) {
23482 if (this.length === 0) return '';
23483 var p = this.head;
23484 var ret = '' + p.data;
23485 while (p = p.next) {
23486 ret += s + p.data;
23487 }return ret;
23488 };
23489
23490 BufferList.prototype.concat = function concat(n) {
23491 if (this.length === 0) return Buffer.alloc(0);
23492 if (this.length === 1) return this.head.data;
23493 var ret = Buffer.allocUnsafe(n >>> 0);
23494 var p = this.head;
23495 var i = 0;
23496 while (p) {
23497 copyBuffer(p.data, ret, i);
23498 i += p.data.length;
23499 p = p.next;
23500 }
23501 return ret;
23502 };
23503
23504 return BufferList;
23505}();
23506},{"safe-buffer":305}],297:[function(require,module,exports){
23507'use strict';
23508
23509/*<replacement>*/
23510
23511var processNextTick = require('process-nextick-args');
23512/*</replacement>*/
23513
23514// undocumented cb() API, needed for core, not for public API
23515function destroy(err, cb) {
23516 var _this = this;
23517
23518 var readableDestroyed = this._readableState && this._readableState.destroyed;
23519 var writableDestroyed = this._writableState && this._writableState.destroyed;
23520
23521 if (readableDestroyed || writableDestroyed) {
23522 if (cb) {
23523 cb(err);
23524 } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
23525 processNextTick(emitErrorNT, this, err);
23526 }
23527 return;
23528 }
23529
23530 // we set destroyed to true before firing error callbacks in order
23531 // to make it re-entrance safe in case destroy() is called within callbacks
23532
23533 if (this._readableState) {
23534 this._readableState.destroyed = true;
23535 }
23536
23537 // if this is a duplex stream mark the writable part as destroyed as well
23538 if (this._writableState) {
23539 this._writableState.destroyed = true;
23540 }
23541
23542 this._destroy(err || null, function (err) {
23543 if (!cb && err) {
23544 processNextTick(emitErrorNT, _this, err);
23545 if (_this._writableState) {
23546 _this._writableState.errorEmitted = true;
23547 }
23548 } else if (cb) {
23549 cb(err);
23550 }
23551 });
23552}
23553
23554function undestroy() {
23555 if (this._readableState) {
23556 this._readableState.destroyed = false;
23557 this._readableState.reading = false;
23558 this._readableState.ended = false;
23559 this._readableState.endEmitted = false;
23560 }
23561
23562 if (this._writableState) {
23563 this._writableState.destroyed = false;
23564 this._writableState.ended = false;
23565 this._writableState.ending = false;
23566 this._writableState.finished = false;
23567 this._writableState.errorEmitted = false;
23568 }
23569}
23570
23571function emitErrorNT(self, err) {
23572 self.emit('error', err);
23573}
23574
23575module.exports = {
23576 destroy: destroy,
23577 undestroy: undestroy
23578};
23579},{"process-nextick-args":280}],298:[function(require,module,exports){
23580module.exports = require('events').EventEmitter;
23581
23582},{"events":242}],299:[function(require,module,exports){
23583'use strict';
23584
23585var Buffer = require('safe-buffer').Buffer;
23586
23587var isEncoding = Buffer.isEncoding || function (encoding) {
23588 encoding = '' + encoding;
23589 switch (encoding && encoding.toLowerCase()) {
23590 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':
23591 return true;
23592 default:
23593 return false;
23594 }
23595};
23596
23597function _normalizeEncoding(enc) {
23598 if (!enc) return 'utf8';
23599 var retried;
23600 while (true) {
23601 switch (enc) {
23602 case 'utf8':
23603 case 'utf-8':
23604 return 'utf8';
23605 case 'ucs2':
23606 case 'ucs-2':
23607 case 'utf16le':
23608 case 'utf-16le':
23609 return 'utf16le';
23610 case 'latin1':
23611 case 'binary':
23612 return 'latin1';
23613 case 'base64':
23614 case 'ascii':
23615 case 'hex':
23616 return enc;
23617 default:
23618 if (retried) return; // undefined
23619 enc = ('' + enc).toLowerCase();
23620 retried = true;
23621 }
23622 }
23623};
23624
23625// Do not cache `Buffer.isEncoding` when checking encoding names as some
23626// modules monkey-patch it to support additional encodings
23627function normalizeEncoding(enc) {
23628 var nenc = _normalizeEncoding(enc);
23629 if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
23630 return nenc || enc;
23631}
23632
23633// StringDecoder provides an interface for efficiently splitting a series of
23634// buffers into a series of JS strings without breaking apart multi-byte
23635// characters.
23636exports.StringDecoder = StringDecoder;
23637function StringDecoder(encoding) {
23638 this.encoding = normalizeEncoding(encoding);
23639 var nb;
23640 switch (this.encoding) {
23641 case 'utf16le':
23642 this.text = utf16Text;
23643 this.end = utf16End;
23644 nb = 4;
23645 break;
23646 case 'utf8':
23647 this.fillLast = utf8FillLast;
23648 nb = 4;
23649 break;
23650 case 'base64':
23651 this.text = base64Text;
23652 this.end = base64End;
23653 nb = 3;
23654 break;
23655 default:
23656 this.write = simpleWrite;
23657 this.end = simpleEnd;
23658 return;
23659 }
23660 this.lastNeed = 0;
23661 this.lastTotal = 0;
23662 this.lastChar = Buffer.allocUnsafe(nb);
23663}
23664
23665StringDecoder.prototype.write = function (buf) {
23666 if (buf.length === 0) return '';
23667 var r;
23668 var i;
23669 if (this.lastNeed) {
23670 r = this.fillLast(buf);
23671 if (r === undefined) return '';
23672 i = this.lastNeed;
23673 this.lastNeed = 0;
23674 } else {
23675 i = 0;
23676 }
23677 if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
23678 return r || '';
23679};
23680
23681StringDecoder.prototype.end = utf8End;
23682
23683// Returns only complete characters in a Buffer
23684StringDecoder.prototype.text = utf8Text;
23685
23686// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
23687StringDecoder.prototype.fillLast = function (buf) {
23688 if (this.lastNeed <= buf.length) {
23689 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
23690 return this.lastChar.toString(this.encoding, 0, this.lastTotal);
23691 }
23692 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
23693 this.lastNeed -= buf.length;
23694};
23695
23696// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
23697// continuation byte.
23698function utf8CheckByte(byte) {
23699 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;
23700 return -1;
23701}
23702
23703// Checks at most 3 bytes at the end of a Buffer in order to detect an
23704// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
23705// needed to complete the UTF-8 character (if applicable) are returned.
23706function utf8CheckIncomplete(self, buf, i) {
23707 var j = buf.length - 1;
23708 if (j < i) return 0;
23709 var nb = utf8CheckByte(buf[j]);
23710 if (nb >= 0) {
23711 if (nb > 0) self.lastNeed = nb - 1;
23712 return nb;
23713 }
23714 if (--j < i) return 0;
23715 nb = utf8CheckByte(buf[j]);
23716 if (nb >= 0) {
23717 if (nb > 0) self.lastNeed = nb - 2;
23718 return nb;
23719 }
23720 if (--j < i) return 0;
23721 nb = utf8CheckByte(buf[j]);
23722 if (nb >= 0) {
23723 if (nb > 0) {
23724 if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
23725 }
23726 return nb;
23727 }
23728 return 0;
23729}
23730
23731// Validates as many continuation bytes for a multi-byte UTF-8 character as
23732// needed or are available. If we see a non-continuation byte where we expect
23733// one, we "replace" the validated continuation bytes we've seen so far with
23734// UTF-8 replacement characters ('\ufffd'), to match v8's UTF-8 decoding
23735// behavior. The continuation byte check is included three times in the case
23736// where all of the continuation bytes for a character exist in the same buffer.
23737// It is also done this way as a slight performance increase instead of using a
23738// loop.
23739function utf8CheckExtraBytes(self, buf, p) {
23740 if ((buf[0] & 0xC0) !== 0x80) {
23741 self.lastNeed = 0;
23742 return '\ufffd'.repeat(p);
23743 }
23744 if (self.lastNeed > 1 && buf.length > 1) {
23745 if ((buf[1] & 0xC0) !== 0x80) {
23746 self.lastNeed = 1;
23747 return '\ufffd'.repeat(p + 1);
23748 }
23749 if (self.lastNeed > 2 && buf.length > 2) {
23750 if ((buf[2] & 0xC0) !== 0x80) {
23751 self.lastNeed = 2;
23752 return '\ufffd'.repeat(p + 2);
23753 }
23754 }
23755 }
23756}
23757
23758// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
23759function utf8FillLast(buf) {
23760 var p = this.lastTotal - this.lastNeed;
23761 var r = utf8CheckExtraBytes(this, buf, p);
23762 if (r !== undefined) return r;
23763 if (this.lastNeed <= buf.length) {
23764 buf.copy(this.lastChar, p, 0, this.lastNeed);
23765 return this.lastChar.toString(this.encoding, 0, this.lastTotal);
23766 }
23767 buf.copy(this.lastChar, p, 0, buf.length);
23768 this.lastNeed -= buf.length;
23769}
23770
23771// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
23772// partial character, the character's bytes are buffered until the required
23773// number of bytes are available.
23774function utf8Text(buf, i) {
23775 var total = utf8CheckIncomplete(this, buf, i);
23776 if (!this.lastNeed) return buf.toString('utf8', i);
23777 this.lastTotal = total;
23778 var end = buf.length - (total - this.lastNeed);
23779 buf.copy(this.lastChar, 0, end);
23780 return buf.toString('utf8', i, end);
23781}
23782
23783// For UTF-8, a replacement character for each buffered byte of a (partial)
23784// character needs to be added to the output.
23785function utf8End(buf) {
23786 var r = buf && buf.length ? this.write(buf) : '';
23787 if (this.lastNeed) return r + '\ufffd'.repeat(this.lastTotal - this.lastNeed);
23788 return r;
23789}
23790
23791// UTF-16LE typically needs two bytes per character, but even if we have an even
23792// number of bytes available, we need to check if we end on a leading/high
23793// surrogate. In that case, we need to wait for the next two bytes in order to
23794// decode the last character properly.
23795function utf16Text(buf, i) {
23796 if ((buf.length - i) % 2 === 0) {
23797 var r = buf.toString('utf16le', i);
23798 if (r) {
23799 var c = r.charCodeAt(r.length - 1);
23800 if (c >= 0xD800 && c <= 0xDBFF) {
23801 this.lastNeed = 2;
23802 this.lastTotal = 4;
23803 this.lastChar[0] = buf[buf.length - 2];
23804 this.lastChar[1] = buf[buf.length - 1];
23805 return r.slice(0, -1);
23806 }
23807 }
23808 return r;
23809 }
23810 this.lastNeed = 1;
23811 this.lastTotal = 2;
23812 this.lastChar[0] = buf[buf.length - 1];
23813 return buf.toString('utf16le', i, buf.length - 1);
23814}
23815
23816// For UTF-16LE we do not explicitly append special replacement characters if we
23817// end on a partial character, we simply let v8 handle that.
23818function utf16End(buf) {
23819 var r = buf && buf.length ? this.write(buf) : '';
23820 if (this.lastNeed) {
23821 var end = this.lastTotal - this.lastNeed;
23822 return r + this.lastChar.toString('utf16le', 0, end);
23823 }
23824 return r;
23825}
23826
23827function base64Text(buf, i) {
23828 var n = (buf.length - i) % 3;
23829 if (n === 0) return buf.toString('base64', i);
23830 this.lastNeed = 3 - n;
23831 this.lastTotal = 3;
23832 if (n === 1) {
23833 this.lastChar[0] = buf[buf.length - 1];
23834 } else {
23835 this.lastChar[0] = buf[buf.length - 2];
23836 this.lastChar[1] = buf[buf.length - 1];
23837 }
23838 return buf.toString('base64', i, buf.length - n);
23839}
23840
23841function base64End(buf) {
23842 var r = buf && buf.length ? this.write(buf) : '';
23843 if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
23844 return r;
23845}
23846
23847// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
23848function simpleWrite(buf) {
23849 return buf.toString(this.encoding);
23850}
23851
23852function simpleEnd(buf) {
23853 return buf && buf.length ? this.write(buf) : '';
23854}
23855},{"safe-buffer":305}],300:[function(require,module,exports){
23856module.exports = require('./readable').PassThrough
23857
23858},{"./readable":301}],301:[function(require,module,exports){
23859exports = module.exports = require('./lib/_stream_readable.js');
23860exports.Stream = exports;
23861exports.Readable = exports;
23862exports.Writable = require('./lib/_stream_writable.js');
23863exports.Duplex = require('./lib/_stream_duplex.js');
23864exports.Transform = require('./lib/_stream_transform.js');
23865exports.PassThrough = require('./lib/_stream_passthrough.js');
23866
23867},{"./lib/_stream_duplex.js":291,"./lib/_stream_passthrough.js":292,"./lib/_stream_readable.js":293,"./lib/_stream_transform.js":294,"./lib/_stream_writable.js":295}],302:[function(require,module,exports){
23868module.exports = require('./readable').Transform
23869
23870},{"./readable":301}],303:[function(require,module,exports){
23871module.exports = require('./lib/_stream_writable.js');
23872
23873},{"./lib/_stream_writable.js":295}],304:[function(require,module,exports){
23874(function (Buffer){
23875'use strict'
23876var inherits = require('inherits')
23877var HashBase = require('hash-base')
23878
23879function RIPEMD160 () {
23880 HashBase.call(this, 64)
23881
23882 // state
23883 this._a = 0x67452301
23884 this._b = 0xefcdab89
23885 this._c = 0x98badcfe
23886 this._d = 0x10325476
23887 this._e = 0xc3d2e1f0
23888}
23889
23890inherits(RIPEMD160, HashBase)
23891
23892RIPEMD160.prototype._update = function () {
23893 var m = new Array(16)
23894 for (var i = 0; i < 16; ++i) m[i] = this._block.readInt32LE(i * 4)
23895
23896 var al = this._a
23897 var bl = this._b
23898 var cl = this._c
23899 var dl = this._d
23900 var el = this._e
23901
23902 // Mj = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
23903 // K = 0x00000000
23904 // Sj = 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8
23905 al = fn1(al, bl, cl, dl, el, m[0], 0x00000000, 11); cl = rotl(cl, 10)
23906 el = fn1(el, al, bl, cl, dl, m[1], 0x00000000, 14); bl = rotl(bl, 10)
23907 dl = fn1(dl, el, al, bl, cl, m[2], 0x00000000, 15); al = rotl(al, 10)
23908 cl = fn1(cl, dl, el, al, bl, m[3], 0x00000000, 12); el = rotl(el, 10)
23909 bl = fn1(bl, cl, dl, el, al, m[4], 0x00000000, 5); dl = rotl(dl, 10)
23910 al = fn1(al, bl, cl, dl, el, m[5], 0x00000000, 8); cl = rotl(cl, 10)
23911 el = fn1(el, al, bl, cl, dl, m[6], 0x00000000, 7); bl = rotl(bl, 10)
23912 dl = fn1(dl, el, al, bl, cl, m[7], 0x00000000, 9); al = rotl(al, 10)
23913 cl = fn1(cl, dl, el, al, bl, m[8], 0x00000000, 11); el = rotl(el, 10)
23914 bl = fn1(bl, cl, dl, el, al, m[9], 0x00000000, 13); dl = rotl(dl, 10)
23915 al = fn1(al, bl, cl, dl, el, m[10], 0x00000000, 14); cl = rotl(cl, 10)
23916 el = fn1(el, al, bl, cl, dl, m[11], 0x00000000, 15); bl = rotl(bl, 10)
23917 dl = fn1(dl, el, al, bl, cl, m[12], 0x00000000, 6); al = rotl(al, 10)
23918 cl = fn1(cl, dl, el, al, bl, m[13], 0x00000000, 7); el = rotl(el, 10)
23919 bl = fn1(bl, cl, dl, el, al, m[14], 0x00000000, 9); dl = rotl(dl, 10)
23920 al = fn1(al, bl, cl, dl, el, m[15], 0x00000000, 8); cl = rotl(cl, 10)
23921
23922 // Mj = 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8
23923 // K = 0x5a827999
23924 // Sj = 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12
23925 el = fn2(el, al, bl, cl, dl, m[7], 0x5a827999, 7); bl = rotl(bl, 10)
23926 dl = fn2(dl, el, al, bl, cl, m[4], 0x5a827999, 6); al = rotl(al, 10)
23927 cl = fn2(cl, dl, el, al, bl, m[13], 0x5a827999, 8); el = rotl(el, 10)
23928 bl = fn2(bl, cl, dl, el, al, m[1], 0x5a827999, 13); dl = rotl(dl, 10)
23929 al = fn2(al, bl, cl, dl, el, m[10], 0x5a827999, 11); cl = rotl(cl, 10)
23930 el = fn2(el, al, bl, cl, dl, m[6], 0x5a827999, 9); bl = rotl(bl, 10)
23931 dl = fn2(dl, el, al, bl, cl, m[15], 0x5a827999, 7); al = rotl(al, 10)
23932 cl = fn2(cl, dl, el, al, bl, m[3], 0x5a827999, 15); el = rotl(el, 10)
23933 bl = fn2(bl, cl, dl, el, al, m[12], 0x5a827999, 7); dl = rotl(dl, 10)
23934 al = fn2(al, bl, cl, dl, el, m[0], 0x5a827999, 12); cl = rotl(cl, 10)
23935 el = fn2(el, al, bl, cl, dl, m[9], 0x5a827999, 15); bl = rotl(bl, 10)
23936 dl = fn2(dl, el, al, bl, cl, m[5], 0x5a827999, 9); al = rotl(al, 10)
23937 cl = fn2(cl, dl, el, al, bl, m[2], 0x5a827999, 11); el = rotl(el, 10)
23938 bl = fn2(bl, cl, dl, el, al, m[14], 0x5a827999, 7); dl = rotl(dl, 10)
23939 al = fn2(al, bl, cl, dl, el, m[11], 0x5a827999, 13); cl = rotl(cl, 10)
23940 el = fn2(el, al, bl, cl, dl, m[8], 0x5a827999, 12); bl = rotl(bl, 10)
23941
23942 // Mj = 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12
23943 // K = 0x6ed9eba1
23944 // Sj = 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5
23945 dl = fn3(dl, el, al, bl, cl, m[3], 0x6ed9eba1, 11); al = rotl(al, 10)
23946 cl = fn3(cl, dl, el, al, bl, m[10], 0x6ed9eba1, 13); el = rotl(el, 10)
23947 bl = fn3(bl, cl, dl, el, al, m[14], 0x6ed9eba1, 6); dl = rotl(dl, 10)
23948 al = fn3(al, bl, cl, dl, el, m[4], 0x6ed9eba1, 7); cl = rotl(cl, 10)
23949 el = fn3(el, al, bl, cl, dl, m[9], 0x6ed9eba1, 14); bl = rotl(bl, 10)
23950 dl = fn3(dl, el, al, bl, cl, m[15], 0x6ed9eba1, 9); al = rotl(al, 10)
23951 cl = fn3(cl, dl, el, al, bl, m[8], 0x6ed9eba1, 13); el = rotl(el, 10)
23952 bl = fn3(bl, cl, dl, el, al, m[1], 0x6ed9eba1, 15); dl = rotl(dl, 10)
23953 al = fn3(al, bl, cl, dl, el, m[2], 0x6ed9eba1, 14); cl = rotl(cl, 10)
23954 el = fn3(el, al, bl, cl, dl, m[7], 0x6ed9eba1, 8); bl = rotl(bl, 10)
23955 dl = fn3(dl, el, al, bl, cl, m[0], 0x6ed9eba1, 13); al = rotl(al, 10)
23956 cl = fn3(cl, dl, el, al, bl, m[6], 0x6ed9eba1, 6); el = rotl(el, 10)
23957 bl = fn3(bl, cl, dl, el, al, m[13], 0x6ed9eba1, 5); dl = rotl(dl, 10)
23958 al = fn3(al, bl, cl, dl, el, m[11], 0x6ed9eba1, 12); cl = rotl(cl, 10)
23959 el = fn3(el, al, bl, cl, dl, m[5], 0x6ed9eba1, 7); bl = rotl(bl, 10)
23960 dl = fn3(dl, el, al, bl, cl, m[12], 0x6ed9eba1, 5); al = rotl(al, 10)
23961
23962 // Mj = 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2
23963 // K = 0x8f1bbcdc
23964 // Sj = 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12
23965 cl = fn4(cl, dl, el, al, bl, m[1], 0x8f1bbcdc, 11); el = rotl(el, 10)
23966 bl = fn4(bl, cl, dl, el, al, m[9], 0x8f1bbcdc, 12); dl = rotl(dl, 10)
23967 al = fn4(al, bl, cl, dl, el, m[11], 0x8f1bbcdc, 14); cl = rotl(cl, 10)
23968 el = fn4(el, al, bl, cl, dl, m[10], 0x8f1bbcdc, 15); bl = rotl(bl, 10)
23969 dl = fn4(dl, el, al, bl, cl, m[0], 0x8f1bbcdc, 14); al = rotl(al, 10)
23970 cl = fn4(cl, dl, el, al, bl, m[8], 0x8f1bbcdc, 15); el = rotl(el, 10)
23971 bl = fn4(bl, cl, dl, el, al, m[12], 0x8f1bbcdc, 9); dl = rotl(dl, 10)
23972 al = fn4(al, bl, cl, dl, el, m[4], 0x8f1bbcdc, 8); cl = rotl(cl, 10)
23973 el = fn4(el, al, bl, cl, dl, m[13], 0x8f1bbcdc, 9); bl = rotl(bl, 10)
23974 dl = fn4(dl, el, al, bl, cl, m[3], 0x8f1bbcdc, 14); al = rotl(al, 10)
23975 cl = fn4(cl, dl, el, al, bl, m[7], 0x8f1bbcdc, 5); el = rotl(el, 10)
23976 bl = fn4(bl, cl, dl, el, al, m[15], 0x8f1bbcdc, 6); dl = rotl(dl, 10)
23977 al = fn4(al, bl, cl, dl, el, m[14], 0x8f1bbcdc, 8); cl = rotl(cl, 10)
23978 el = fn4(el, al, bl, cl, dl, m[5], 0x8f1bbcdc, 6); bl = rotl(bl, 10)
23979 dl = fn4(dl, el, al, bl, cl, m[6], 0x8f1bbcdc, 5); al = rotl(al, 10)
23980 cl = fn4(cl, dl, el, al, bl, m[2], 0x8f1bbcdc, 12); el = rotl(el, 10)
23981
23982 // Mj = 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
23983 // K = 0xa953fd4e
23984 // Sj = 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
23985 bl = fn5(bl, cl, dl, el, al, m[4], 0xa953fd4e, 9); dl = rotl(dl, 10)
23986 al = fn5(al, bl, cl, dl, el, m[0], 0xa953fd4e, 15); cl = rotl(cl, 10)
23987 el = fn5(el, al, bl, cl, dl, m[5], 0xa953fd4e, 5); bl = rotl(bl, 10)
23988 dl = fn5(dl, el, al, bl, cl, m[9], 0xa953fd4e, 11); al = rotl(al, 10)
23989 cl = fn5(cl, dl, el, al, bl, m[7], 0xa953fd4e, 6); el = rotl(el, 10)
23990 bl = fn5(bl, cl, dl, el, al, m[12], 0xa953fd4e, 8); dl = rotl(dl, 10)
23991 al = fn5(al, bl, cl, dl, el, m[2], 0xa953fd4e, 13); cl = rotl(cl, 10)
23992 el = fn5(el, al, bl, cl, dl, m[10], 0xa953fd4e, 12); bl = rotl(bl, 10)
23993 dl = fn5(dl, el, al, bl, cl, m[14], 0xa953fd4e, 5); al = rotl(al, 10)
23994 cl = fn5(cl, dl, el, al, bl, m[1], 0xa953fd4e, 12); el = rotl(el, 10)
23995 bl = fn5(bl, cl, dl, el, al, m[3], 0xa953fd4e, 13); dl = rotl(dl, 10)
23996 al = fn5(al, bl, cl, dl, el, m[8], 0xa953fd4e, 14); cl = rotl(cl, 10)
23997 el = fn5(el, al, bl, cl, dl, m[11], 0xa953fd4e, 11); bl = rotl(bl, 10)
23998 dl = fn5(dl, el, al, bl, cl, m[6], 0xa953fd4e, 8); al = rotl(al, 10)
23999 cl = fn5(cl, dl, el, al, bl, m[15], 0xa953fd4e, 5); el = rotl(el, 10)
24000 bl = fn5(bl, cl, dl, el, al, m[13], 0xa953fd4e, 6); dl = rotl(dl, 10)
24001
24002 var ar = this._a
24003 var br = this._b
24004 var cr = this._c
24005 var dr = this._d
24006 var er = this._e
24007
24008 // M'j = 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12
24009 // K' = 0x50a28be6
24010 // S'j = 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6
24011 ar = fn5(ar, br, cr, dr, er, m[5], 0x50a28be6, 8); cr = rotl(cr, 10)
24012 er = fn5(er, ar, br, cr, dr, m[14], 0x50a28be6, 9); br = rotl(br, 10)
24013 dr = fn5(dr, er, ar, br, cr, m[7], 0x50a28be6, 9); ar = rotl(ar, 10)
24014 cr = fn5(cr, dr, er, ar, br, m[0], 0x50a28be6, 11); er = rotl(er, 10)
24015 br = fn5(br, cr, dr, er, ar, m[9], 0x50a28be6, 13); dr = rotl(dr, 10)
24016 ar = fn5(ar, br, cr, dr, er, m[2], 0x50a28be6, 15); cr = rotl(cr, 10)
24017 er = fn5(er, ar, br, cr, dr, m[11], 0x50a28be6, 15); br = rotl(br, 10)
24018 dr = fn5(dr, er, ar, br, cr, m[4], 0x50a28be6, 5); ar = rotl(ar, 10)
24019 cr = fn5(cr, dr, er, ar, br, m[13], 0x50a28be6, 7); er = rotl(er, 10)
24020 br = fn5(br, cr, dr, er, ar, m[6], 0x50a28be6, 7); dr = rotl(dr, 10)
24021 ar = fn5(ar, br, cr, dr, er, m[15], 0x50a28be6, 8); cr = rotl(cr, 10)
24022 er = fn5(er, ar, br, cr, dr, m[8], 0x50a28be6, 11); br = rotl(br, 10)
24023 dr = fn5(dr, er, ar, br, cr, m[1], 0x50a28be6, 14); ar = rotl(ar, 10)
24024 cr = fn5(cr, dr, er, ar, br, m[10], 0x50a28be6, 14); er = rotl(er, 10)
24025 br = fn5(br, cr, dr, er, ar, m[3], 0x50a28be6, 12); dr = rotl(dr, 10)
24026 ar = fn5(ar, br, cr, dr, er, m[12], 0x50a28be6, 6); cr = rotl(cr, 10)
24027
24028 // M'j = 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2
24029 // K' = 0x5c4dd124
24030 // S'j = 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11
24031 er = fn4(er, ar, br, cr, dr, m[6], 0x5c4dd124, 9); br = rotl(br, 10)
24032 dr = fn4(dr, er, ar, br, cr, m[11], 0x5c4dd124, 13); ar = rotl(ar, 10)
24033 cr = fn4(cr, dr, er, ar, br, m[3], 0x5c4dd124, 15); er = rotl(er, 10)
24034 br = fn4(br, cr, dr, er, ar, m[7], 0x5c4dd124, 7); dr = rotl(dr, 10)
24035 ar = fn4(ar, br, cr, dr, er, m[0], 0x5c4dd124, 12); cr = rotl(cr, 10)
24036 er = fn4(er, ar, br, cr, dr, m[13], 0x5c4dd124, 8); br = rotl(br, 10)
24037 dr = fn4(dr, er, ar, br, cr, m[5], 0x5c4dd124, 9); ar = rotl(ar, 10)
24038 cr = fn4(cr, dr, er, ar, br, m[10], 0x5c4dd124, 11); er = rotl(er, 10)
24039 br = fn4(br, cr, dr, er, ar, m[14], 0x5c4dd124, 7); dr = rotl(dr, 10)
24040 ar = fn4(ar, br, cr, dr, er, m[15], 0x5c4dd124, 7); cr = rotl(cr, 10)
24041 er = fn4(er, ar, br, cr, dr, m[8], 0x5c4dd124, 12); br = rotl(br, 10)
24042 dr = fn4(dr, er, ar, br, cr, m[12], 0x5c4dd124, 7); ar = rotl(ar, 10)
24043 cr = fn4(cr, dr, er, ar, br, m[4], 0x5c4dd124, 6); er = rotl(er, 10)
24044 br = fn4(br, cr, dr, er, ar, m[9], 0x5c4dd124, 15); dr = rotl(dr, 10)
24045 ar = fn4(ar, br, cr, dr, er, m[1], 0x5c4dd124, 13); cr = rotl(cr, 10)
24046 er = fn4(er, ar, br, cr, dr, m[2], 0x5c4dd124, 11); br = rotl(br, 10)
24047
24048 // M'j = 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13
24049 // K' = 0x6d703ef3
24050 // S'j = 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5
24051 dr = fn3(dr, er, ar, br, cr, m[15], 0x6d703ef3, 9); ar = rotl(ar, 10)
24052 cr = fn3(cr, dr, er, ar, br, m[5], 0x6d703ef3, 7); er = rotl(er, 10)
24053 br = fn3(br, cr, dr, er, ar, m[1], 0x6d703ef3, 15); dr = rotl(dr, 10)
24054 ar = fn3(ar, br, cr, dr, er, m[3], 0x6d703ef3, 11); cr = rotl(cr, 10)
24055 er = fn3(er, ar, br, cr, dr, m[7], 0x6d703ef3, 8); br = rotl(br, 10)
24056 dr = fn3(dr, er, ar, br, cr, m[14], 0x6d703ef3, 6); ar = rotl(ar, 10)
24057 cr = fn3(cr, dr, er, ar, br, m[6], 0x6d703ef3, 6); er = rotl(er, 10)
24058 br = fn3(br, cr, dr, er, ar, m[9], 0x6d703ef3, 14); dr = rotl(dr, 10)
24059 ar = fn3(ar, br, cr, dr, er, m[11], 0x6d703ef3, 12); cr = rotl(cr, 10)
24060 er = fn3(er, ar, br, cr, dr, m[8], 0x6d703ef3, 13); br = rotl(br, 10)
24061 dr = fn3(dr, er, ar, br, cr, m[12], 0x6d703ef3, 5); ar = rotl(ar, 10)
24062 cr = fn3(cr, dr, er, ar, br, m[2], 0x6d703ef3, 14); er = rotl(er, 10)
24063 br = fn3(br, cr, dr, er, ar, m[10], 0x6d703ef3, 13); dr = rotl(dr, 10)
24064 ar = fn3(ar, br, cr, dr, er, m[0], 0x6d703ef3, 13); cr = rotl(cr, 10)
24065 er = fn3(er, ar, br, cr, dr, m[4], 0x6d703ef3, 7); br = rotl(br, 10)
24066 dr = fn3(dr, er, ar, br, cr, m[13], 0x6d703ef3, 5); ar = rotl(ar, 10)
24067
24068 // M'j = 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14
24069 // K' = 0x7a6d76e9
24070 // S'j = 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8
24071 cr = fn2(cr, dr, er, ar, br, m[8], 0x7a6d76e9, 15); er = rotl(er, 10)
24072 br = fn2(br, cr, dr, er, ar, m[6], 0x7a6d76e9, 5); dr = rotl(dr, 10)
24073 ar = fn2(ar, br, cr, dr, er, m[4], 0x7a6d76e9, 8); cr = rotl(cr, 10)
24074 er = fn2(er, ar, br, cr, dr, m[1], 0x7a6d76e9, 11); br = rotl(br, 10)
24075 dr = fn2(dr, er, ar, br, cr, m[3], 0x7a6d76e9, 14); ar = rotl(ar, 10)
24076 cr = fn2(cr, dr, er, ar, br, m[11], 0x7a6d76e9, 14); er = rotl(er, 10)
24077 br = fn2(br, cr, dr, er, ar, m[15], 0x7a6d76e9, 6); dr = rotl(dr, 10)
24078 ar = fn2(ar, br, cr, dr, er, m[0], 0x7a6d76e9, 14); cr = rotl(cr, 10)
24079 er = fn2(er, ar, br, cr, dr, m[5], 0x7a6d76e9, 6); br = rotl(br, 10)
24080 dr = fn2(dr, er, ar, br, cr, m[12], 0x7a6d76e9, 9); ar = rotl(ar, 10)
24081 cr = fn2(cr, dr, er, ar, br, m[2], 0x7a6d76e9, 12); er = rotl(er, 10)
24082 br = fn2(br, cr, dr, er, ar, m[13], 0x7a6d76e9, 9); dr = rotl(dr, 10)
24083 ar = fn2(ar, br, cr, dr, er, m[9], 0x7a6d76e9, 12); cr = rotl(cr, 10)
24084 er = fn2(er, ar, br, cr, dr, m[7], 0x7a6d76e9, 5); br = rotl(br, 10)
24085 dr = fn2(dr, er, ar, br, cr, m[10], 0x7a6d76e9, 15); ar = rotl(ar, 10)
24086 cr = fn2(cr, dr, er, ar, br, m[14], 0x7a6d76e9, 8); er = rotl(er, 10)
24087
24088 // M'j = 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
24089 // K' = 0x00000000
24090 // S'j = 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
24091 br = fn1(br, cr, dr, er, ar, m[12], 0x00000000, 8); dr = rotl(dr, 10)
24092 ar = fn1(ar, br, cr, dr, er, m[15], 0x00000000, 5); cr = rotl(cr, 10)
24093 er = fn1(er, ar, br, cr, dr, m[10], 0x00000000, 12); br = rotl(br, 10)
24094 dr = fn1(dr, er, ar, br, cr, m[4], 0x00000000, 9); ar = rotl(ar, 10)
24095 cr = fn1(cr, dr, er, ar, br, m[1], 0x00000000, 12); er = rotl(er, 10)
24096 br = fn1(br, cr, dr, er, ar, m[5], 0x00000000, 5); dr = rotl(dr, 10)
24097 ar = fn1(ar, br, cr, dr, er, m[8], 0x00000000, 14); cr = rotl(cr, 10)
24098 er = fn1(er, ar, br, cr, dr, m[7], 0x00000000, 6); br = rotl(br, 10)
24099 dr = fn1(dr, er, ar, br, cr, m[6], 0x00000000, 8); ar = rotl(ar, 10)
24100 cr = fn1(cr, dr, er, ar, br, m[2], 0x00000000, 13); er = rotl(er, 10)
24101 br = fn1(br, cr, dr, er, ar, m[13], 0x00000000, 6); dr = rotl(dr, 10)
24102 ar = fn1(ar, br, cr, dr, er, m[14], 0x00000000, 5); cr = rotl(cr, 10)
24103 er = fn1(er, ar, br, cr, dr, m[0], 0x00000000, 15); br = rotl(br, 10)
24104 dr = fn1(dr, er, ar, br, cr, m[3], 0x00000000, 13); ar = rotl(ar, 10)
24105 cr = fn1(cr, dr, er, ar, br, m[9], 0x00000000, 11); er = rotl(er, 10)
24106 br = fn1(br, cr, dr, er, ar, m[11], 0x00000000, 11); dr = rotl(dr, 10)
24107
24108 // change state
24109 var t = (this._b + cl + dr) | 0
24110 this._b = (this._c + dl + er) | 0
24111 this._c = (this._d + el + ar) | 0
24112 this._d = (this._e + al + br) | 0
24113 this._e = (this._a + bl + cr) | 0
24114 this._a = t
24115}
24116
24117RIPEMD160.prototype._digest = function () {
24118 // create padding and handle blocks
24119 this._block[this._blockOffset++] = 0x80
24120 if (this._blockOffset > 56) {
24121 this._block.fill(0, this._blockOffset, 64)
24122 this._update()
24123 this._blockOffset = 0
24124 }
24125
24126 this._block.fill(0, this._blockOffset, 56)
24127 this._block.writeUInt32LE(this._length[0], 56)
24128 this._block.writeUInt32LE(this._length[1], 60)
24129 this._update()
24130
24131 // produce result
24132 var buffer = new Buffer(20)
24133 buffer.writeInt32LE(this._a, 0)
24134 buffer.writeInt32LE(this._b, 4)
24135 buffer.writeInt32LE(this._c, 8)
24136 buffer.writeInt32LE(this._d, 12)
24137 buffer.writeInt32LE(this._e, 16)
24138 return buffer
24139}
24140
24141function rotl (x, n) {
24142 return (x << n) | (x >>> (32 - n))
24143}
24144
24145function fn1 (a, b, c, d, e, m, k, s) {
24146 return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + e) | 0
24147}
24148
24149function fn2 (a, b, c, d, e, m, k, s) {
24150 return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + e) | 0
24151}
24152
24153function fn3 (a, b, c, d, e, m, k, s) {
24154 return (rotl((a + ((b | (~c)) ^ d) + m + k) | 0, s) + e) | 0
24155}
24156
24157function fn4 (a, b, c, d, e, m, k, s) {
24158 return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + e) | 0
24159}
24160
24161function fn5 (a, b, c, d, e, m, k, s) {
24162 return (rotl((a + (b ^ (c | (~d))) + m + k) | 0, s) + e) | 0
24163}
24164
24165module.exports = RIPEMD160
24166
24167}).call(this,require("buffer").Buffer)
24168},{"buffer":75,"hash-base":244,"inherits":260}],305:[function(require,module,exports){
24169/* eslint-disable node/no-deprecated-api */
24170var buffer = require('buffer')
24171var Buffer = buffer.Buffer
24172
24173// alternative to using Object.keys for old browsers
24174function copyProps (src, dst) {
24175 for (var key in src) {
24176 dst[key] = src[key]
24177 }
24178}
24179if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
24180 module.exports = buffer
24181} else {
24182 // Copy properties from require('buffer')
24183 copyProps(buffer, exports)
24184 exports.Buffer = SafeBuffer
24185}
24186
24187function SafeBuffer (arg, encodingOrOffset, length) {
24188 return Buffer(arg, encodingOrOffset, length)
24189}
24190
24191// Copy static methods from Buffer
24192copyProps(Buffer, SafeBuffer)
24193
24194SafeBuffer.from = function (arg, encodingOrOffset, length) {
24195 if (typeof arg === 'number') {
24196 throw new TypeError('Argument must not be a number')
24197 }
24198 return Buffer(arg, encodingOrOffset, length)
24199}
24200
24201SafeBuffer.alloc = function (size, fill, encoding) {
24202 if (typeof size !== 'number') {
24203 throw new TypeError('Argument must be a number')
24204 }
24205 var buf = Buffer(size)
24206 if (fill !== undefined) {
24207 if (typeof encoding === 'string') {
24208 buf.fill(fill, encoding)
24209 } else {
24210 buf.fill(fill)
24211 }
24212 } else {
24213 buf.fill(0)
24214 }
24215 return buf
24216}
24217
24218SafeBuffer.allocUnsafe = function (size) {
24219 if (typeof size !== 'number') {
24220 throw new TypeError('Argument must be a number')
24221 }
24222 return Buffer(size)
24223}
24224
24225SafeBuffer.allocUnsafeSlow = function (size) {
24226 if (typeof size !== 'number') {
24227 throw new TypeError('Argument must be a number')
24228 }
24229 return buffer.SlowBuffer(size)
24230}
24231
24232},{"buffer":75}],306:[function(require,module,exports){
24233var Buffer = require('safe-buffer').Buffer
24234
24235// prototype class for hash functions
24236function Hash (blockSize, finalSize) {
24237 this._block = Buffer.alloc(blockSize)
24238 this._finalSize = finalSize
24239 this._blockSize = blockSize
24240 this._len = 0
24241}
24242
24243Hash.prototype.update = function (data, enc) {
24244 if (typeof data === 'string') {
24245 enc = enc || 'utf8'
24246 data = Buffer.from(data, enc)
24247 }
24248
24249 var block = this._block
24250 var blockSize = this._blockSize
24251 var length = data.length
24252 var accum = this._len
24253
24254 for (var offset = 0; offset < length;) {
24255 var assigned = accum % blockSize
24256 var remainder = Math.min(length - offset, blockSize - assigned)
24257
24258 for (var i = 0; i < remainder; i++) {
24259 block[assigned + i] = data[offset + i]
24260 }
24261
24262 accum += remainder
24263 offset += remainder
24264
24265 if ((accum % blockSize) === 0) {
24266 this._update(block)
24267 }
24268 }
24269
24270 this._len += length
24271 return this
24272}
24273
24274Hash.prototype.digest = function (enc) {
24275 var rem = this._len % this._blockSize
24276
24277 this._block[rem] = 0x80
24278
24279 // zero (rem + 1) trailing bits, where (rem + 1) is the smallest
24280 // non-negative solution to the equation (length + 1 + (rem + 1)) === finalSize mod blockSize
24281 this._block.fill(0, rem + 1)
24282
24283 if (rem >= this._finalSize) {
24284 this._update(this._block)
24285 this._block.fill(0)
24286 }
24287
24288 var bits = this._len * 8
24289
24290 // uint32
24291 if (bits <= 0xffffffff) {
24292 this._block.writeUInt32BE(bits, this._blockSize - 4)
24293
24294 // uint64
24295 } else {
24296 var lowBits = bits & 0xffffffff
24297 var highBits = (bits - lowBits) / 0x100000000
24298
24299 this._block.writeUInt32BE(highBits, this._blockSize - 8)
24300 this._block.writeUInt32BE(lowBits, this._blockSize - 4)
24301 }
24302
24303 this._update(this._block)
24304 var hash = this._hash()
24305
24306 return enc ? hash.toString(enc) : hash
24307}
24308
24309Hash.prototype._update = function () {
24310 throw new Error('_update must be implemented by subclass')
24311}
24312
24313module.exports = Hash
24314
24315},{"safe-buffer":305}],307:[function(require,module,exports){
24316var exports = module.exports = function SHA (algorithm) {
24317 algorithm = algorithm.toLowerCase()
24318
24319 var Algorithm = exports[algorithm]
24320 if (!Algorithm) throw new Error(algorithm + ' is not supported (we accept pull requests)')
24321
24322 return new Algorithm()
24323}
24324
24325exports.sha = require('./sha')
24326exports.sha1 = require('./sha1')
24327exports.sha224 = require('./sha224')
24328exports.sha256 = require('./sha256')
24329exports.sha384 = require('./sha384')
24330exports.sha512 = require('./sha512')
24331
24332},{"./sha":308,"./sha1":309,"./sha224":310,"./sha256":311,"./sha384":312,"./sha512":313}],308:[function(require,module,exports){
24333/*
24334 * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined
24335 * in FIPS PUB 180-1
24336 * This source code is derived from sha1.js of the same repository.
24337 * The difference between SHA-0 and SHA-1 is just a bitwise rotate left
24338 * operation was added.
24339 */
24340
24341var inherits = require('inherits')
24342var Hash = require('./hash')
24343var Buffer = require('safe-buffer').Buffer
24344
24345var K = [
24346 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
24347]
24348
24349var W = new Array(80)
24350
24351function Sha () {
24352 this.init()
24353 this._w = W
24354
24355 Hash.call(this, 64, 56)
24356}
24357
24358inherits(Sha, Hash)
24359
24360Sha.prototype.init = function () {
24361 this._a = 0x67452301
24362 this._b = 0xefcdab89
24363 this._c = 0x98badcfe
24364 this._d = 0x10325476
24365 this._e = 0xc3d2e1f0
24366
24367 return this
24368}
24369
24370function rotl5 (num) {
24371 return (num << 5) | (num >>> 27)
24372}
24373
24374function rotl30 (num) {
24375 return (num << 30) | (num >>> 2)
24376}
24377
24378function ft (s, b, c, d) {
24379 if (s === 0) return (b & c) | ((~b) & d)
24380 if (s === 2) return (b & c) | (b & d) | (c & d)
24381 return b ^ c ^ d
24382}
24383
24384Sha.prototype._update = function (M) {
24385 var W = this._w
24386
24387 var a = this._a | 0
24388 var b = this._b | 0
24389 var c = this._c | 0
24390 var d = this._d | 0
24391 var e = this._e | 0
24392
24393 for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
24394 for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]
24395
24396 for (var j = 0; j < 80; ++j) {
24397 var s = ~~(j / 20)
24398 var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
24399
24400 e = d
24401 d = c
24402 c = rotl30(b)
24403 b = a
24404 a = t
24405 }
24406
24407 this._a = (a + this._a) | 0
24408 this._b = (b + this._b) | 0
24409 this._c = (c + this._c) | 0
24410 this._d = (d + this._d) | 0
24411 this._e = (e + this._e) | 0
24412}
24413
24414Sha.prototype._hash = function () {
24415 var H = Buffer.allocUnsafe(20)
24416
24417 H.writeInt32BE(this._a | 0, 0)
24418 H.writeInt32BE(this._b | 0, 4)
24419 H.writeInt32BE(this._c | 0, 8)
24420 H.writeInt32BE(this._d | 0, 12)
24421 H.writeInt32BE(this._e | 0, 16)
24422
24423 return H
24424}
24425
24426module.exports = Sha
24427
24428},{"./hash":306,"inherits":260,"safe-buffer":305}],309:[function(require,module,exports){
24429/*
24430 * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
24431 * in FIPS PUB 180-1
24432 * Version 2.1a Copyright Paul Johnston 2000 - 2002.
24433 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
24434 * Distributed under the BSD License
24435 * See http://pajhome.org.uk/crypt/md5 for details.
24436 */
24437
24438var inherits = require('inherits')
24439var Hash = require('./hash')
24440var Buffer = require('safe-buffer').Buffer
24441
24442var K = [
24443 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
24444]
24445
24446var W = new Array(80)
24447
24448function Sha1 () {
24449 this.init()
24450 this._w = W
24451
24452 Hash.call(this, 64, 56)
24453}
24454
24455inherits(Sha1, Hash)
24456
24457Sha1.prototype.init = function () {
24458 this._a = 0x67452301
24459 this._b = 0xefcdab89
24460 this._c = 0x98badcfe
24461 this._d = 0x10325476
24462 this._e = 0xc3d2e1f0
24463
24464 return this
24465}
24466
24467function rotl1 (num) {
24468 return (num << 1) | (num >>> 31)
24469}
24470
24471function rotl5 (num) {
24472 return (num << 5) | (num >>> 27)
24473}
24474
24475function rotl30 (num) {
24476 return (num << 30) | (num >>> 2)
24477}
24478
24479function ft (s, b, c, d) {
24480 if (s === 0) return (b & c) | ((~b) & d)
24481 if (s === 2) return (b & c) | (b & d) | (c & d)
24482 return b ^ c ^ d
24483}
24484
24485Sha1.prototype._update = function (M) {
24486 var W = this._w
24487
24488 var a = this._a | 0
24489 var b = this._b | 0
24490 var c = this._c | 0
24491 var d = this._d | 0
24492 var e = this._e | 0
24493
24494 for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
24495 for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16])
24496
24497 for (var j = 0; j < 80; ++j) {
24498 var s = ~~(j / 20)
24499 var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
24500
24501 e = d
24502 d = c
24503 c = rotl30(b)
24504 b = a
24505 a = t
24506 }
24507
24508 this._a = (a + this._a) | 0
24509 this._b = (b + this._b) | 0
24510 this._c = (c + this._c) | 0
24511 this._d = (d + this._d) | 0
24512 this._e = (e + this._e) | 0
24513}
24514
24515Sha1.prototype._hash = function () {
24516 var H = Buffer.allocUnsafe(20)
24517
24518 H.writeInt32BE(this._a | 0, 0)
24519 H.writeInt32BE(this._b | 0, 4)
24520 H.writeInt32BE(this._c | 0, 8)
24521 H.writeInt32BE(this._d | 0, 12)
24522 H.writeInt32BE(this._e | 0, 16)
24523
24524 return H
24525}
24526
24527module.exports = Sha1
24528
24529},{"./hash":306,"inherits":260,"safe-buffer":305}],310:[function(require,module,exports){
24530/**
24531 * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
24532 * in FIPS 180-2
24533 * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
24534 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
24535 *
24536 */
24537
24538var inherits = require('inherits')
24539var Sha256 = require('./sha256')
24540var Hash = require('./hash')
24541var Buffer = require('safe-buffer').Buffer
24542
24543var W = new Array(64)
24544
24545function Sha224 () {
24546 this.init()
24547
24548 this._w = W // new Array(64)
24549
24550 Hash.call(this, 64, 56)
24551}
24552
24553inherits(Sha224, Sha256)
24554
24555Sha224.prototype.init = function () {
24556 this._a = 0xc1059ed8
24557 this._b = 0x367cd507
24558 this._c = 0x3070dd17
24559 this._d = 0xf70e5939
24560 this._e = 0xffc00b31
24561 this._f = 0x68581511
24562 this._g = 0x64f98fa7
24563 this._h = 0xbefa4fa4
24564
24565 return this
24566}
24567
24568Sha224.prototype._hash = function () {
24569 var H = Buffer.allocUnsafe(28)
24570
24571 H.writeInt32BE(this._a, 0)
24572 H.writeInt32BE(this._b, 4)
24573 H.writeInt32BE(this._c, 8)
24574 H.writeInt32BE(this._d, 12)
24575 H.writeInt32BE(this._e, 16)
24576 H.writeInt32BE(this._f, 20)
24577 H.writeInt32BE(this._g, 24)
24578
24579 return H
24580}
24581
24582module.exports = Sha224
24583
24584},{"./hash":306,"./sha256":311,"inherits":260,"safe-buffer":305}],311:[function(require,module,exports){
24585/**
24586 * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
24587 * in FIPS 180-2
24588 * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
24589 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
24590 *
24591 */
24592
24593var inherits = require('inherits')
24594var Hash = require('./hash')
24595var Buffer = require('safe-buffer').Buffer
24596
24597var K = [
24598 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
24599 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
24600 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
24601 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
24602 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
24603 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
24604 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
24605 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
24606 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
24607 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
24608 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
24609 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
24610 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
24611 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
24612 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
24613 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2
24614]
24615
24616var W = new Array(64)
24617
24618function Sha256 () {
24619 this.init()
24620
24621 this._w = W // new Array(64)
24622
24623 Hash.call(this, 64, 56)
24624}
24625
24626inherits(Sha256, Hash)
24627
24628Sha256.prototype.init = function () {
24629 this._a = 0x6a09e667
24630 this._b = 0xbb67ae85
24631 this._c = 0x3c6ef372
24632 this._d = 0xa54ff53a
24633 this._e = 0x510e527f
24634 this._f = 0x9b05688c
24635 this._g = 0x1f83d9ab
24636 this._h = 0x5be0cd19
24637
24638 return this
24639}
24640
24641function ch (x, y, z) {
24642 return z ^ (x & (y ^ z))
24643}
24644
24645function maj (x, y, z) {
24646 return (x & y) | (z & (x | y))
24647}
24648
24649function sigma0 (x) {
24650 return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10)
24651}
24652
24653function sigma1 (x) {
24654 return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7)
24655}
24656
24657function gamma0 (x) {
24658 return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ (x >>> 3)
24659}
24660
24661function gamma1 (x) {
24662 return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ (x >>> 10)
24663}
24664
24665Sha256.prototype._update = function (M) {
24666 var W = this._w
24667
24668 var a = this._a | 0
24669 var b = this._b | 0
24670 var c = this._c | 0
24671 var d = this._d | 0
24672 var e = this._e | 0
24673 var f = this._f | 0
24674 var g = this._g | 0
24675 var h = this._h | 0
24676
24677 for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
24678 for (; i < 64; ++i) W[i] = (gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16]) | 0
24679
24680 for (var j = 0; j < 64; ++j) {
24681 var T1 = (h + sigma1(e) + ch(e, f, g) + K[j] + W[j]) | 0
24682 var T2 = (sigma0(a) + maj(a, b, c)) | 0
24683
24684 h = g
24685 g = f
24686 f = e
24687 e = (d + T1) | 0
24688 d = c
24689 c = b
24690 b = a
24691 a = (T1 + T2) | 0
24692 }
24693
24694 this._a = (a + this._a) | 0
24695 this._b = (b + this._b) | 0
24696 this._c = (c + this._c) | 0
24697 this._d = (d + this._d) | 0
24698 this._e = (e + this._e) | 0
24699 this._f = (f + this._f) | 0
24700 this._g = (g + this._g) | 0
24701 this._h = (h + this._h) | 0
24702}
24703
24704Sha256.prototype._hash = function () {
24705 var H = Buffer.allocUnsafe(32)
24706
24707 H.writeInt32BE(this._a, 0)
24708 H.writeInt32BE(this._b, 4)
24709 H.writeInt32BE(this._c, 8)
24710 H.writeInt32BE(this._d, 12)
24711 H.writeInt32BE(this._e, 16)
24712 H.writeInt32BE(this._f, 20)
24713 H.writeInt32BE(this._g, 24)
24714 H.writeInt32BE(this._h, 28)
24715
24716 return H
24717}
24718
24719module.exports = Sha256
24720
24721},{"./hash":306,"inherits":260,"safe-buffer":305}],312:[function(require,module,exports){
24722var inherits = require('inherits')
24723var SHA512 = require('./sha512')
24724var Hash = require('./hash')
24725var Buffer = require('safe-buffer').Buffer
24726
24727var W = new Array(160)
24728
24729function Sha384 () {
24730 this.init()
24731 this._w = W
24732
24733 Hash.call(this, 128, 112)
24734}
24735
24736inherits(Sha384, SHA512)
24737
24738Sha384.prototype.init = function () {
24739 this._ah = 0xcbbb9d5d
24740 this._bh = 0x629a292a
24741 this._ch = 0x9159015a
24742 this._dh = 0x152fecd8
24743 this._eh = 0x67332667
24744 this._fh = 0x8eb44a87
24745 this._gh = 0xdb0c2e0d
24746 this._hh = 0x47b5481d
24747
24748 this._al = 0xc1059ed8
24749 this._bl = 0x367cd507
24750 this._cl = 0x3070dd17
24751 this._dl = 0xf70e5939
24752 this._el = 0xffc00b31
24753 this._fl = 0x68581511
24754 this._gl = 0x64f98fa7
24755 this._hl = 0xbefa4fa4
24756
24757 return this
24758}
24759
24760Sha384.prototype._hash = function () {
24761 var H = Buffer.allocUnsafe(48)
24762
24763 function writeInt64BE (h, l, offset) {
24764 H.writeInt32BE(h, offset)
24765 H.writeInt32BE(l, offset + 4)
24766 }
24767
24768 writeInt64BE(this._ah, this._al, 0)
24769 writeInt64BE(this._bh, this._bl, 8)
24770 writeInt64BE(this._ch, this._cl, 16)
24771 writeInt64BE(this._dh, this._dl, 24)
24772 writeInt64BE(this._eh, this._el, 32)
24773 writeInt64BE(this._fh, this._fl, 40)
24774
24775 return H
24776}
24777
24778module.exports = Sha384
24779
24780},{"./hash":306,"./sha512":313,"inherits":260,"safe-buffer":305}],313:[function(require,module,exports){
24781var inherits = require('inherits')
24782var Hash = require('./hash')
24783var Buffer = require('safe-buffer').Buffer
24784
24785var K = [
24786 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
24787 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
24788 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
24789 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
24790 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
24791 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
24792 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
24793 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
24794 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
24795 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
24796 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
24797 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
24798 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
24799 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
24800 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
24801 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
24802 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
24803 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
24804 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
24805 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
24806 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
24807 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
24808 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
24809 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
24810 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
24811 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
24812 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
24813 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
24814 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
24815 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
24816 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
24817 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
24818 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
24819 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
24820 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
24821 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
24822 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
24823 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
24824 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
24825 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
24826]
24827
24828var W = new Array(160)
24829
24830function Sha512 () {
24831 this.init()
24832 this._w = W
24833
24834 Hash.call(this, 128, 112)
24835}
24836
24837inherits(Sha512, Hash)
24838
24839Sha512.prototype.init = function () {
24840 this._ah = 0x6a09e667
24841 this._bh = 0xbb67ae85
24842 this._ch = 0x3c6ef372
24843 this._dh = 0xa54ff53a
24844 this._eh = 0x510e527f
24845 this._fh = 0x9b05688c
24846 this._gh = 0x1f83d9ab
24847 this._hh = 0x5be0cd19
24848
24849 this._al = 0xf3bcc908
24850 this._bl = 0x84caa73b
24851 this._cl = 0xfe94f82b
24852 this._dl = 0x5f1d36f1
24853 this._el = 0xade682d1
24854 this._fl = 0x2b3e6c1f
24855 this._gl = 0xfb41bd6b
24856 this._hl = 0x137e2179
24857
24858 return this
24859}
24860
24861function Ch (x, y, z) {
24862 return z ^ (x & (y ^ z))
24863}
24864
24865function maj (x, y, z) {
24866 return (x & y) | (z & (x | y))
24867}
24868
24869function sigma0 (x, xl) {
24870 return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25)
24871}
24872
24873function sigma1 (x, xl) {
24874 return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23)
24875}
24876
24877function Gamma0 (x, xl) {
24878 return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7)
24879}
24880
24881function Gamma0l (x, xl) {
24882 return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25)
24883}
24884
24885function Gamma1 (x, xl) {
24886 return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6)
24887}
24888
24889function Gamma1l (x, xl) {
24890 return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26)
24891}
24892
24893function getCarry (a, b) {
24894 return (a >>> 0) < (b >>> 0) ? 1 : 0
24895}
24896
24897Sha512.prototype._update = function (M) {
24898 var W = this._w
24899
24900 var ah = this._ah | 0
24901 var bh = this._bh | 0
24902 var ch = this._ch | 0
24903 var dh = this._dh | 0
24904 var eh = this._eh | 0
24905 var fh = this._fh | 0
24906 var gh = this._gh | 0
24907 var hh = this._hh | 0
24908
24909 var al = this._al | 0
24910 var bl = this._bl | 0
24911 var cl = this._cl | 0
24912 var dl = this._dl | 0
24913 var el = this._el | 0
24914 var fl = this._fl | 0
24915 var gl = this._gl | 0
24916 var hl = this._hl | 0
24917
24918 for (var i = 0; i < 32; i += 2) {
24919 W[i] = M.readInt32BE(i * 4)
24920 W[i + 1] = M.readInt32BE(i * 4 + 4)
24921 }
24922 for (; i < 160; i += 2) {
24923 var xh = W[i - 15 * 2]
24924 var xl = W[i - 15 * 2 + 1]
24925 var gamma0 = Gamma0(xh, xl)
24926 var gamma0l = Gamma0l(xl, xh)
24927
24928 xh = W[i - 2 * 2]
24929 xl = W[i - 2 * 2 + 1]
24930 var gamma1 = Gamma1(xh, xl)
24931 var gamma1l = Gamma1l(xl, xh)
24932
24933 // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
24934 var Wi7h = W[i - 7 * 2]
24935 var Wi7l = W[i - 7 * 2 + 1]
24936
24937 var Wi16h = W[i - 16 * 2]
24938 var Wi16l = W[i - 16 * 2 + 1]
24939
24940 var Wil = (gamma0l + Wi7l) | 0
24941 var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0
24942 Wil = (Wil + gamma1l) | 0
24943 Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 0
24944 Wil = (Wil + Wi16l) | 0
24945 Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 0
24946
24947 W[i] = Wih
24948 W[i + 1] = Wil
24949 }
24950
24951 for (var j = 0; j < 160; j += 2) {
24952 Wih = W[j]
24953 Wil = W[j + 1]
24954
24955 var majh = maj(ah, bh, ch)
24956 var majl = maj(al, bl, cl)
24957
24958 var sigma0h = sigma0(ah, al)
24959 var sigma0l = sigma0(al, ah)
24960 var sigma1h = sigma1(eh, el)
24961 var sigma1l = sigma1(el, eh)
24962
24963 // t1 = h + sigma1 + ch + K[j] + W[j]
24964 var Kih = K[j]
24965 var Kil = K[j + 1]
24966
24967 var chh = Ch(eh, fh, gh)
24968 var chl = Ch(el, fl, gl)
24969
24970 var t1l = (hl + sigma1l) | 0
24971 var t1h = (hh + sigma1h + getCarry(t1l, hl)) | 0
24972 t1l = (t1l + chl) | 0
24973 t1h = (t1h + chh + getCarry(t1l, chl)) | 0
24974 t1l = (t1l + Kil) | 0
24975 t1h = (t1h + Kih + getCarry(t1l, Kil)) | 0
24976 t1l = (t1l + Wil) | 0
24977 t1h = (t1h + Wih + getCarry(t1l, Wil)) | 0
24978
24979 // t2 = sigma0 + maj
24980 var t2l = (sigma0l + majl) | 0
24981 var t2h = (sigma0h + majh + getCarry(t2l, sigma0l)) | 0
24982
24983 hh = gh
24984 hl = gl
24985 gh = fh
24986 gl = fl
24987 fh = eh
24988 fl = el
24989 el = (dl + t1l) | 0
24990 eh = (dh + t1h + getCarry(el, dl)) | 0
24991 dh = ch
24992 dl = cl
24993 ch = bh
24994 cl = bl
24995 bh = ah
24996 bl = al
24997 al = (t1l + t2l) | 0
24998 ah = (t1h + t2h + getCarry(al, t1l)) | 0
24999 }
25000
25001 this._al = (this._al + al) | 0
25002 this._bl = (this._bl + bl) | 0
25003 this._cl = (this._cl + cl) | 0
25004 this._dl = (this._dl + dl) | 0
25005 this._el = (this._el + el) | 0
25006 this._fl = (this._fl + fl) | 0
25007 this._gl = (this._gl + gl) | 0
25008 this._hl = (this._hl + hl) | 0
25009
25010 this._ah = (this._ah + ah + getCarry(this._al, al)) | 0
25011 this._bh = (this._bh + bh + getCarry(this._bl, bl)) | 0
25012 this._ch = (this._ch + ch + getCarry(this._cl, cl)) | 0
25013 this._dh = (this._dh + dh + getCarry(this._dl, dl)) | 0
25014 this._eh = (this._eh + eh + getCarry(this._el, el)) | 0
25015 this._fh = (this._fh + fh + getCarry(this._fl, fl)) | 0
25016 this._gh = (this._gh + gh + getCarry(this._gl, gl)) | 0
25017 this._hh = (this._hh + hh + getCarry(this._hl, hl)) | 0
25018}
25019
25020Sha512.prototype._hash = function () {
25021 var H = Buffer.allocUnsafe(64)
25022
25023 function writeInt64BE (h, l, offset) {
25024 H.writeInt32BE(h, offset)
25025 H.writeInt32BE(l, offset + 4)
25026 }
25027
25028 writeInt64BE(this._ah, this._al, 0)
25029 writeInt64BE(this._bh, this._bl, 8)
25030 writeInt64BE(this._ch, this._cl, 16)
25031 writeInt64BE(this._dh, this._dl, 24)
25032 writeInt64BE(this._eh, this._el, 32)
25033 writeInt64BE(this._fh, this._fl, 40)
25034 writeInt64BE(this._gh, this._gl, 48)
25035 writeInt64BE(this._hh, this._hl, 56)
25036
25037 return H
25038}
25039
25040module.exports = Sha512
25041
25042},{"./hash":306,"inherits":260,"safe-buffer":305}],314:[function(require,module,exports){
25043// Copyright Joyent, Inc. and other Node contributors.
25044//
25045// Permission is hereby granted, free of charge, to any person obtaining a
25046// copy of this software and associated documentation files (the
25047// "Software"), to deal in the Software without restriction, including
25048// without limitation the rights to use, copy, modify, merge, publish,
25049// distribute, sublicense, and/or sell copies of the Software, and to permit
25050// persons to whom the Software is furnished to do so, subject to the
25051// following conditions:
25052//
25053// The above copyright notice and this permission notice shall be included
25054// in all copies or substantial portions of the Software.
25055//
25056// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25057// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25058// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
25059// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25060// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
25061// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
25062// USE OR OTHER DEALINGS IN THE SOFTWARE.
25063
25064module.exports = Stream;
25065
25066var EE = require('events').EventEmitter;
25067var inherits = require('inherits');
25068
25069inherits(Stream, EE);
25070Stream.Readable = require('readable-stream/readable.js');
25071Stream.Writable = require('readable-stream/writable.js');
25072Stream.Duplex = require('readable-stream/duplex.js');
25073Stream.Transform = require('readable-stream/transform.js');
25074Stream.PassThrough = require('readable-stream/passthrough.js');
25075
25076// Backwards-compat with node 0.4.x
25077Stream.Stream = Stream;
25078
25079
25080
25081// old-style streams. Note that the pipe method (the only relevant
25082// part of this class) is overridden in the Readable class.
25083
25084function Stream() {
25085 EE.call(this);
25086}
25087
25088Stream.prototype.pipe = function(dest, options) {
25089 var source = this;
25090
25091 function ondata(chunk) {
25092 if (dest.writable) {
25093 if (false === dest.write(chunk) && source.pause) {
25094 source.pause();
25095 }
25096 }
25097 }
25098
25099 source.on('data', ondata);
25100
25101 function ondrain() {
25102 if (source.readable && source.resume) {
25103 source.resume();
25104 }
25105 }
25106
25107 dest.on('drain', ondrain);
25108
25109 // If the 'end' option is not supplied, dest.end() will be called when
25110 // source gets the 'end' or 'close' events. Only dest.end() once.
25111 if (!dest._isStdio && (!options || options.end !== false)) {
25112 source.on('end', onend);
25113 source.on('close', onclose);
25114 }
25115
25116 var didOnEnd = false;
25117 function onend() {
25118 if (didOnEnd) return;
25119 didOnEnd = true;
25120
25121 dest.end();
25122 }
25123
25124
25125 function onclose() {
25126 if (didOnEnd) return;
25127 didOnEnd = true;
25128
25129 if (typeof dest.destroy === 'function') dest.destroy();
25130 }
25131
25132 // don't leave dangling pipes when there are errors.
25133 function onerror(er) {
25134 cleanup();
25135 if (EE.listenerCount(this, 'error') === 0) {
25136 throw er; // Unhandled stream error in pipe.
25137 }
25138 }
25139
25140 source.on('error', onerror);
25141 dest.on('error', onerror);
25142
25143 // remove all the event listeners that were added.
25144 function cleanup() {
25145 source.removeListener('data', ondata);
25146 dest.removeListener('drain', ondrain);
25147
25148 source.removeListener('end', onend);
25149 source.removeListener('close', onclose);
25150
25151 source.removeListener('error', onerror);
25152 dest.removeListener('error', onerror);
25153
25154 source.removeListener('end', cleanup);
25155 source.removeListener('close', cleanup);
25156
25157 dest.removeListener('close', cleanup);
25158 }
25159
25160 source.on('end', cleanup);
25161 source.on('close', cleanup);
25162
25163 dest.on('close', cleanup);
25164
25165 dest.emit('pipe', source);
25166
25167 // Allow for unix-like usage: A.pipe(B).pipe(C)
25168 return dest;
25169};
25170
25171},{"events":242,"inherits":260,"readable-stream/duplex.js":290,"readable-stream/passthrough.js":300,"readable-stream/readable.js":301,"readable-stream/transform.js":302,"readable-stream/writable.js":303}],315:[function(require,module,exports){
25172// Copyright Joyent, Inc. and other Node contributors.
25173//
25174// Permission is hereby granted, free of charge, to any person obtaining a
25175// copy of this software and associated documentation files (the
25176// "Software"), to deal in the Software without restriction, including
25177// without limitation the rights to use, copy, modify, merge, publish,
25178// distribute, sublicense, and/or sell copies of the Software, and to permit
25179// persons to whom the Software is furnished to do so, subject to the
25180// following conditions:
25181//
25182// The above copyright notice and this permission notice shall be included
25183// in all copies or substantial portions of the Software.
25184//
25185// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25186// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25187// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
25188// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25189// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
25190// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
25191// USE OR OTHER DEALINGS IN THE SOFTWARE.
25192
25193var Buffer = require('buffer').Buffer;
25194
25195var isBufferEncoding = Buffer.isEncoding
25196 || function(encoding) {
25197 switch (encoding && encoding.toLowerCase()) {
25198 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;
25199 default: return false;
25200 }
25201 }
25202
25203
25204function assertEncoding(encoding) {
25205 if (encoding && !isBufferEncoding(encoding)) {
25206 throw new Error('Unknown encoding: ' + encoding);
25207 }
25208}
25209
25210// StringDecoder provides an interface for efficiently splitting a series of
25211// buffers into a series of JS strings without breaking apart multi-byte
25212// characters. CESU-8 is handled as part of the UTF-8 encoding.
25213//
25214// @TODO Handling all encodings inside a single object makes it very difficult
25215// to reason about this code, so it should be split up in the future.
25216// @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code
25217// points as used by CESU-8.
25218var StringDecoder = exports.StringDecoder = function(encoding) {
25219 this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
25220 assertEncoding(encoding);
25221 switch (this.encoding) {
25222 case 'utf8':
25223 // CESU-8 represents each of Surrogate Pair by 3-bytes
25224 this.surrogateSize = 3;
25225 break;
25226 case 'ucs2':
25227 case 'utf16le':
25228 // UTF-16 represents each of Surrogate Pair by 2-bytes
25229 this.surrogateSize = 2;
25230 this.detectIncompleteChar = utf16DetectIncompleteChar;
25231 break;
25232 case 'base64':
25233 // Base-64 stores 3 bytes in 4 chars, and pads the remainder.
25234 this.surrogateSize = 3;
25235 this.detectIncompleteChar = base64DetectIncompleteChar;
25236 break;
25237 default:
25238 this.write = passThroughWrite;
25239 return;
25240 }
25241
25242 // Enough space to store all bytes of a single character. UTF-8 needs 4
25243 // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate).
25244 this.charBuffer = new Buffer(6);
25245 // Number of bytes received for the current incomplete multi-byte character.
25246 this.charReceived = 0;
25247 // Number of bytes expected for the current incomplete multi-byte character.
25248 this.charLength = 0;
25249};
25250
25251
25252// write decodes the given buffer and returns it as JS string that is
25253// guaranteed to not contain any partial multi-byte characters. Any partial
25254// character found at the end of the buffer is buffered up, and will be
25255// returned when calling write again with the remaining bytes.
25256//
25257// Note: Converting a Buffer containing an orphan surrogate to a String
25258// currently works, but converting a String to a Buffer (via `new Buffer`, or
25259// Buffer#write) will replace incomplete surrogates with the unicode
25260// replacement character. See https://codereview.chromium.org/121173009/ .
25261StringDecoder.prototype.write = function(buffer) {
25262 var charStr = '';
25263 // if our last write ended with an incomplete multibyte character
25264 while (this.charLength) {
25265 // determine how many remaining bytes this buffer has to offer for this char
25266 var available = (buffer.length >= this.charLength - this.charReceived) ?
25267 this.charLength - this.charReceived :
25268 buffer.length;
25269
25270 // add the new bytes to the char buffer
25271 buffer.copy(this.charBuffer, this.charReceived, 0, available);
25272 this.charReceived += available;
25273
25274 if (this.charReceived < this.charLength) {
25275 // still not enough chars in this buffer? wait for more ...
25276 return '';
25277 }
25278
25279 // remove bytes belonging to the current character from the buffer
25280 buffer = buffer.slice(available, buffer.length);
25281
25282 // get the character that was split
25283 charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
25284
25285 // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
25286 var charCode = charStr.charCodeAt(charStr.length - 1);
25287 if (charCode >= 0xD800 && charCode <= 0xDBFF) {
25288 this.charLength += this.surrogateSize;
25289 charStr = '';
25290 continue;
25291 }
25292 this.charReceived = this.charLength = 0;
25293
25294 // if there are no more bytes in this buffer, just emit our char
25295 if (buffer.length === 0) {
25296 return charStr;
25297 }
25298 break;
25299 }
25300
25301 // determine and set charLength / charReceived
25302 this.detectIncompleteChar(buffer);
25303
25304 var end = buffer.length;
25305 if (this.charLength) {
25306 // buffer the incomplete character bytes we got
25307 buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
25308 end -= this.charReceived;
25309 }
25310
25311 charStr += buffer.toString(this.encoding, 0, end);
25312
25313 var end = charStr.length - 1;
25314 var charCode = charStr.charCodeAt(end);
25315 // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
25316 if (charCode >= 0xD800 && charCode <= 0xDBFF) {
25317 var size = this.surrogateSize;
25318 this.charLength += size;
25319 this.charReceived += size;
25320 this.charBuffer.copy(this.charBuffer, size, 0, size);
25321 buffer.copy(this.charBuffer, 0, 0, size);
25322 return charStr.substring(0, end);
25323 }
25324
25325 // or just emit the charStr
25326 return charStr;
25327};
25328
25329// detectIncompleteChar determines if there is an incomplete UTF-8 character at
25330// the end of the given buffer. If so, it sets this.charLength to the byte
25331// length that character, and sets this.charReceived to the number of bytes
25332// that are available for this character.
25333StringDecoder.prototype.detectIncompleteChar = function(buffer) {
25334 // determine how many bytes we have to check at the end of this buffer
25335 var i = (buffer.length >= 3) ? 3 : buffer.length;
25336
25337 // Figure out if one of the last i bytes of our buffer announces an
25338 // incomplete char.
25339 for (; i > 0; i--) {
25340 var c = buffer[buffer.length - i];
25341
25342 // See http://en.wikipedia.org/wiki/UTF-8#Description
25343
25344 // 110XXXXX
25345 if (i == 1 && c >> 5 == 0x06) {
25346 this.charLength = 2;
25347 break;
25348 }
25349
25350 // 1110XXXX
25351 if (i <= 2 && c >> 4 == 0x0E) {
25352 this.charLength = 3;
25353 break;
25354 }
25355
25356 // 11110XXX
25357 if (i <= 3 && c >> 3 == 0x1E) {
25358 this.charLength = 4;
25359 break;
25360 }
25361 }
25362 this.charReceived = i;
25363};
25364
25365StringDecoder.prototype.end = function(buffer) {
25366 var res = '';
25367 if (buffer && buffer.length)
25368 res = this.write(buffer);
25369
25370 if (this.charReceived) {
25371 var cr = this.charReceived;
25372 var buf = this.charBuffer;
25373 var enc = this.encoding;
25374 res += buf.slice(0, cr).toString(enc);
25375 }
25376
25377 return res;
25378};
25379
25380function passThroughWrite(buffer) {
25381 return buffer.toString(this.encoding);
25382}
25383
25384function utf16DetectIncompleteChar(buffer) {
25385 this.charReceived = buffer.length % 2;
25386 this.charLength = this.charReceived ? 2 : 0;
25387}
25388
25389function base64DetectIncompleteChar(buffer) {
25390 this.charReceived = buffer.length % 3;
25391 this.charLength = this.charReceived ? 3 : 0;
25392}
25393
25394},{"buffer":75}],316:[function(require,module,exports){
25395/** @license URI.js v4.2.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
25396(function (global, factory) {
25397 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
25398 typeof define === 'function' && define.amd ? define(['exports'], factory) :
25399 (factory((global.URI = global.URI || {})));
25400}(this, (function (exports) { 'use strict';
25401
25402function merge() {
25403 for (var _len = arguments.length, sets = Array(_len), _key = 0; _key < _len; _key++) {
25404 sets[_key] = arguments[_key];
25405 }
25406
25407 if (sets.length > 1) {
25408 sets[0] = sets[0].slice(0, -1);
25409 var xl = sets.length - 1;
25410 for (var x = 1; x < xl; ++x) {
25411 sets[x] = sets[x].slice(1, -1);
25412 }
25413 sets[xl] = sets[xl].slice(1);
25414 return sets.join('');
25415 } else {
25416 return sets[0];
25417 }
25418}
25419function subexp(str) {
25420 return "(?:" + str + ")";
25421}
25422function typeOf(o) {
25423 return o === undefined ? "undefined" : o === null ? "null" : Object.prototype.toString.call(o).split(" ").pop().split("]").shift().toLowerCase();
25424}
25425function toUpperCase(str) {
25426 return str.toUpperCase();
25427}
25428function toArray(obj) {
25429 return obj !== undefined && obj !== null ? obj instanceof Array ? obj : typeof obj.length !== "number" || obj.split || obj.setInterval || obj.call ? [obj] : Array.prototype.slice.call(obj) : [];
25430}
25431function assign(target, source) {
25432 var obj = target;
25433 if (source) {
25434 for (var key in source) {
25435 obj[key] = source[key];
25436 }
25437 }
25438 return obj;
25439}
25440
25441function buildExps(isIRI) {
25442 var ALPHA$$ = "[A-Za-z]",
25443 CR$ = "[\\x0D]",
25444 DIGIT$$ = "[0-9]",
25445 DQUOTE$$ = "[\\x22]",
25446 HEXDIG$$ = merge(DIGIT$$, "[A-Fa-f]"),
25447 //case-insensitive
25448 LF$$ = "[\\x0A]",
25449 SP$$ = "[\\x20]",
25450 PCT_ENCODED$ = subexp(subexp("%[EFef]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%[89A-Fa-f]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%" + HEXDIG$$ + HEXDIG$$)),
25451 //expanded
25452 GEN_DELIMS$$ = "[\\:\\/\\?\\#\\[\\]\\@]",
25453 SUB_DELIMS$$ = "[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",
25454 RESERVED$$ = merge(GEN_DELIMS$$, SUB_DELIMS$$),
25455 UCSCHAR$$ = isIRI ? "[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]" : "[]",
25456 //subset, excludes bidi control characters
25457 IPRIVATE$$ = isIRI ? "[\\uE000-\\uF8FF]" : "[]",
25458 //subset
25459 UNRESERVED$$ = merge(ALPHA$$, DIGIT$$, "[\\-\\.\\_\\~]", UCSCHAR$$),
25460 SCHEME$ = subexp(ALPHA$$ + merge(ALPHA$$, DIGIT$$, "[\\+\\-\\.]") + "*"),
25461 USERINFO$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]")) + "*"),
25462 DEC_OCTET$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("[1-9]" + DIGIT$$) + "|" + DIGIT$$),
25463 DEC_OCTET_RELAXED$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("0?[1-9]" + DIGIT$$) + "|0?0?" + DIGIT$$),
25464 //relaxed parsing rules
25465 IPV4ADDRESS$ = subexp(DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$),
25466 H16$ = subexp(HEXDIG$$ + "{1,4}"),
25467 LS32$ = subexp(subexp(H16$ + "\\:" + H16$) + "|" + IPV4ADDRESS$),
25468 IPV6ADDRESS1$ = subexp(subexp(H16$ + "\\:") + "{6}" + LS32$),
25469 // 6( h16 ":" ) ls32
25470 IPV6ADDRESS2$ = subexp("\\:\\:" + subexp(H16$ + "\\:") + "{5}" + LS32$),
25471 // "::" 5( h16 ":" ) ls32
25472 IPV6ADDRESS3$ = subexp(subexp(H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{4}" + LS32$),
25473 //[ h16 ] "::" 4( h16 ":" ) ls32
25474 IPV6ADDRESS4$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,1}" + H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{3}" + LS32$),
25475 //[ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32
25476 IPV6ADDRESS5$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,2}" + H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{2}" + LS32$),
25477 //[ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32
25478 IPV6ADDRESS6$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,3}" + H16$) + "?\\:\\:" + H16$ + "\\:" + LS32$),
25479 //[ *3( h16 ":" ) h16 ] "::" h16 ":" ls32
25480 IPV6ADDRESS7$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,4}" + H16$) + "?\\:\\:" + LS32$),
25481 //[ *4( h16 ":" ) h16 ] "::" ls32
25482 IPV6ADDRESS8$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,5}" + H16$) + "?\\:\\:" + H16$),
25483 //[ *5( h16 ":" ) h16 ] "::" h16
25484 IPV6ADDRESS9$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,6}" + H16$) + "?\\:\\:"),
25485 //[ *6( h16 ":" ) h16 ] "::"
25486 IPV6ADDRESS$ = subexp([IPV6ADDRESS1$, IPV6ADDRESS2$, IPV6ADDRESS3$, IPV6ADDRESS4$, IPV6ADDRESS5$, IPV6ADDRESS6$, IPV6ADDRESS7$, IPV6ADDRESS8$, IPV6ADDRESS9$].join("|")),
25487 ZONEID$ = subexp(subexp(UNRESERVED$$ + "|" + PCT_ENCODED$) + "+"),
25488 //RFC 6874
25489 IPV6ADDRZ$ = subexp(IPV6ADDRESS$ + "\\%25" + ZONEID$),
25490 //RFC 6874
25491 IPV6ADDRZ_RELAXED$ = subexp(IPV6ADDRESS$ + subexp("\\%25|\\%(?!" + HEXDIG$$ + "{2})") + ZONEID$),
25492 //RFC 6874, with relaxed parsing rules
25493 IPVFUTURE$ = subexp("[vV]" + HEXDIG$$ + "+\\." + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]") + "+"),
25494 IP_LITERAL$ = subexp("\\[" + subexp(IPV6ADDRZ_RELAXED$ + "|" + IPV6ADDRESS$ + "|" + IPVFUTURE$) + "\\]"),
25495 //RFC 6874
25496 REG_NAME$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$)) + "*"),
25497 HOST$ = subexp(IP_LITERAL$ + "|" + IPV4ADDRESS$ + "(?!" + REG_NAME$ + ")" + "|" + REG_NAME$),
25498 PORT$ = subexp(DIGIT$$ + "*"),
25499 AUTHORITY$ = subexp(subexp(USERINFO$ + "@") + "?" + HOST$ + subexp("\\:" + PORT$) + "?"),
25500 PCHAR$ = subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@]")),
25501 SEGMENT$ = subexp(PCHAR$ + "*"),
25502 SEGMENT_NZ$ = subexp(PCHAR$ + "+"),
25503 SEGMENT_NZ_NC$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\@]")) + "+"),
25504 PATH_ABEMPTY$ = subexp(subexp("\\/" + SEGMENT$) + "*"),
25505 PATH_ABSOLUTE$ = subexp("\\/" + subexp(SEGMENT_NZ$ + PATH_ABEMPTY$) + "?"),
25506 //simplified
25507 PATH_NOSCHEME$ = subexp(SEGMENT_NZ_NC$ + PATH_ABEMPTY$),
25508 //simplified
25509 PATH_ROOTLESS$ = subexp(SEGMENT_NZ$ + PATH_ABEMPTY$),
25510 //simplified
25511 PATH_EMPTY$ = "(?!" + PCHAR$ + ")",
25512 PATH$ = subexp(PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$),
25513 QUERY$ = subexp(subexp(PCHAR$ + "|" + merge("[\\/\\?]", IPRIVATE$$)) + "*"),
25514 FRAGMENT$ = subexp(subexp(PCHAR$ + "|[\\/\\?]") + "*"),
25515 HIER_PART$ = subexp(subexp("\\/\\/" + AUTHORITY$ + PATH_ABEMPTY$) + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$),
25516 URI$ = subexp(SCHEME$ + "\\:" + HIER_PART$ + subexp("\\?" + QUERY$) + "?" + subexp("\\#" + FRAGMENT$) + "?"),
25517 RELATIVE_PART$ = subexp(subexp("\\/\\/" + AUTHORITY$ + PATH_ABEMPTY$) + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_EMPTY$),
25518 RELATIVE$ = subexp(RELATIVE_PART$ + subexp("\\?" + QUERY$) + "?" + subexp("\\#" + FRAGMENT$) + "?"),
25519 URI_REFERENCE$ = subexp(URI$ + "|" + RELATIVE$),
25520 ABSOLUTE_URI$ = subexp(SCHEME$ + "\\:" + HIER_PART$ + subexp("\\?" + QUERY$) + "?"),
25521 GENERIC_REF$ = "^(" + SCHEME$ + ")\\:" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?" + subexp("\\#(" + FRAGMENT$ + ")") + "?$",
25522 RELATIVE_REF$ = "^(){0}" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?" + subexp("\\#(" + FRAGMENT$ + ")") + "?$",
25523 ABSOLUTE_REF$ = "^(" + SCHEME$ + ")\\:" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?$",
25524 SAMEDOC_REF$ = "^" + subexp("\\#(" + FRAGMENT$ + ")") + "?$",
25525 AUTHORITY_REF$ = "^" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?$";
25526 return {
25527 NOT_SCHEME: new RegExp(merge("[^]", ALPHA$$, DIGIT$$, "[\\+\\-\\.]"), "g"),
25528 NOT_USERINFO: new RegExp(merge("[^\\%\\:]", UNRESERVED$$, SUB_DELIMS$$), "g"),
25529 NOT_HOST: new RegExp(merge("[^\\%\\[\\]\\:]", UNRESERVED$$, SUB_DELIMS$$), "g"),
25530 NOT_PATH: new RegExp(merge("[^\\%\\/\\:\\@]", UNRESERVED$$, SUB_DELIMS$$), "g"),
25531 NOT_PATH_NOSCHEME: new RegExp(merge("[^\\%\\/\\@]", UNRESERVED$$, SUB_DELIMS$$), "g"),
25532 NOT_QUERY: new RegExp(merge("[^\\%]", UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@\\/\\?]", IPRIVATE$$), "g"),
25533 NOT_FRAGMENT: new RegExp(merge("[^\\%]", UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@\\/\\?]"), "g"),
25534 ESCAPE: new RegExp(merge("[^]", UNRESERVED$$, SUB_DELIMS$$), "g"),
25535 UNRESERVED: new RegExp(UNRESERVED$$, "g"),
25536 OTHER_CHARS: new RegExp(merge("[^\\%]", UNRESERVED$$, RESERVED$$), "g"),
25537 PCT_ENCODED: new RegExp(PCT_ENCODED$, "g"),
25538 IPV4ADDRESS: new RegExp("^(" + IPV4ADDRESS$ + ")$"),
25539 IPV6ADDRESS: new RegExp("^\\[?(" + IPV6ADDRESS$ + ")" + subexp(subexp("\\%25|\\%(?!" + HEXDIG$$ + "{2})") + "(" + ZONEID$ + ")") + "?\\]?$") //RFC 6874, with relaxed parsing rules
25540 };
25541}
25542var URI_PROTOCOL = buildExps(false);
25543
25544var IRI_PROTOCOL = buildExps(true);
25545
25546var slicedToArray = function () {
25547 function sliceIterator(arr, i) {
25548 var _arr = [];
25549 var _n = true;
25550 var _d = false;
25551 var _e = undefined;
25552
25553 try {
25554 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
25555 _arr.push(_s.value);
25556
25557 if (i && _arr.length === i) break;
25558 }
25559 } catch (err) {
25560 _d = true;
25561 _e = err;
25562 } finally {
25563 try {
25564 if (!_n && _i["return"]) _i["return"]();
25565 } finally {
25566 if (_d) throw _e;
25567 }
25568 }
25569
25570 return _arr;
25571 }
25572
25573 return function (arr, i) {
25574 if (Array.isArray(arr)) {
25575 return arr;
25576 } else if (Symbol.iterator in Object(arr)) {
25577 return sliceIterator(arr, i);
25578 } else {
25579 throw new TypeError("Invalid attempt to destructure non-iterable instance");
25580 }
25581 };
25582}();
25583
25584
25585
25586
25587
25588
25589
25590
25591
25592
25593
25594
25595
25596var toConsumableArray = function (arr) {
25597 if (Array.isArray(arr)) {
25598 for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
25599
25600 return arr2;
25601 } else {
25602 return Array.from(arr);
25603 }
25604};
25605
25606/** Highest positive signed 32-bit float value */
25607
25608var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
25609
25610/** Bootstring parameters */
25611var base = 36;
25612var tMin = 1;
25613var tMax = 26;
25614var skew = 38;
25615var damp = 700;
25616var initialBias = 72;
25617var initialN = 128; // 0x80
25618var delimiter = '-'; // '\x2D'
25619
25620/** Regular expressions */
25621var regexPunycode = /^xn--/;
25622var regexNonASCII = /[^\0-\x7E]/; // non-ASCII chars
25623var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
25624
25625/** Error messages */
25626var errors = {
25627 'overflow': 'Overflow: input needs wider integers to process',
25628 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
25629 'invalid-input': 'Invalid input'
25630};
25631
25632/** Convenience shortcuts */
25633var baseMinusTMin = base - tMin;
25634var floor = Math.floor;
25635var stringFromCharCode = String.fromCharCode;
25636
25637/*--------------------------------------------------------------------------*/
25638
25639/**
25640 * A generic error utility function.
25641 * @private
25642 * @param {String} type The error type.
25643 * @returns {Error} Throws a `RangeError` with the applicable error message.
25644 */
25645function error$1(type) {
25646 throw new RangeError(errors[type]);
25647}
25648
25649/**
25650 * A generic `Array#map` utility function.
25651 * @private
25652 * @param {Array} array The array to iterate over.
25653 * @param {Function} callback The function that gets called for every array
25654 * item.
25655 * @returns {Array} A new array of values returned by the callback function.
25656 */
25657function map(array, fn) {
25658 var result = [];
25659 var length = array.length;
25660 while (length--) {
25661 result[length] = fn(array[length]);
25662 }
25663 return result;
25664}
25665
25666/**
25667 * A simple `Array#map`-like wrapper to work with domain name strings or email
25668 * addresses.
25669 * @private
25670 * @param {String} domain The domain name or email address.
25671 * @param {Function} callback The function that gets called for every
25672 * character.
25673 * @returns {Array} A new string of characters returned by the callback
25674 * function.
25675 */
25676function mapDomain(string, fn) {
25677 var parts = string.split('@');
25678 var result = '';
25679 if (parts.length > 1) {
25680 // In email addresses, only the domain name should be punycoded. Leave
25681 // the local part (i.e. everything up to `@`) intact.
25682 result = parts[0] + '@';
25683 string = parts[1];
25684 }
25685 // Avoid `split(regex)` for IE8 compatibility. See #17.
25686 string = string.replace(regexSeparators, '\x2E');
25687 var labels = string.split('.');
25688 var encoded = map(labels, fn).join('.');
25689 return result + encoded;
25690}
25691
25692/**
25693 * Creates an array containing the numeric code points of each Unicode
25694 * character in the string. While JavaScript uses UCS-2 internally,
25695 * this function will convert a pair of surrogate halves (each of which
25696 * UCS-2 exposes as separate characters) into a single code point,
25697 * matching UTF-16.
25698 * @see `punycode.ucs2.encode`
25699 * @see <https://mathiasbynens.be/notes/javascript-encoding>
25700 * @memberOf punycode.ucs2
25701 * @name decode
25702 * @param {String} string The Unicode input string (UCS-2).
25703 * @returns {Array} The new array of code points.
25704 */
25705function ucs2decode(string) {
25706 var output = [];
25707 var counter = 0;
25708 var length = string.length;
25709 while (counter < length) {
25710 var value = string.charCodeAt(counter++);
25711 if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
25712 // It's a high surrogate, and there is a next character.
25713 var extra = string.charCodeAt(counter++);
25714 if ((extra & 0xFC00) == 0xDC00) {
25715 // Low surrogate.
25716 output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
25717 } else {
25718 // It's an unmatched surrogate; only append this code unit, in case the
25719 // next code unit is the high surrogate of a surrogate pair.
25720 output.push(value);
25721 counter--;
25722 }
25723 } else {
25724 output.push(value);
25725 }
25726 }
25727 return output;
25728}
25729
25730/**
25731 * Creates a string based on an array of numeric code points.
25732 * @see `punycode.ucs2.decode`
25733 * @memberOf punycode.ucs2
25734 * @name encode
25735 * @param {Array} codePoints The array of numeric code points.
25736 * @returns {String} The new Unicode string (UCS-2).
25737 */
25738var ucs2encode = function ucs2encode(array) {
25739 return String.fromCodePoint.apply(String, toConsumableArray(array));
25740};
25741
25742/**
25743 * Converts a basic code point into a digit/integer.
25744 * @see `digitToBasic()`
25745 * @private
25746 * @param {Number} codePoint The basic numeric code point value.
25747 * @returns {Number} The numeric value of a basic code point (for use in
25748 * representing integers) in the range `0` to `base - 1`, or `base` if
25749 * the code point does not represent a value.
25750 */
25751var basicToDigit = function basicToDigit(codePoint) {
25752 if (codePoint - 0x30 < 0x0A) {
25753 return codePoint - 0x16;
25754 }
25755 if (codePoint - 0x41 < 0x1A) {
25756 return codePoint - 0x41;
25757 }
25758 if (codePoint - 0x61 < 0x1A) {
25759 return codePoint - 0x61;
25760 }
25761 return base;
25762};
25763
25764/**
25765 * Converts a digit/integer into a basic code point.
25766 * @see `basicToDigit()`
25767 * @private
25768 * @param {Number} digit The numeric value of a basic code point.
25769 * @returns {Number} The basic code point whose value (when used for
25770 * representing integers) is `digit`, which needs to be in the range
25771 * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
25772 * used; else, the lowercase form is used. The behavior is undefined
25773 * if `flag` is non-zero and `digit` has no uppercase form.
25774 */
25775var digitToBasic = function digitToBasic(digit, flag) {
25776 // 0..25 map to ASCII a..z or A..Z
25777 // 26..35 map to ASCII 0..9
25778 return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
25779};
25780
25781/**
25782 * Bias adaptation function as per section 3.4 of RFC 3492.
25783 * https://tools.ietf.org/html/rfc3492#section-3.4
25784 * @private
25785 */
25786var adapt = function adapt(delta, numPoints, firstTime) {
25787 var k = 0;
25788 delta = firstTime ? floor(delta / damp) : delta >> 1;
25789 delta += floor(delta / numPoints);
25790 for (; /* no initialization */delta > baseMinusTMin * tMax >> 1; k += base) {
25791 delta = floor(delta / baseMinusTMin);
25792 }
25793 return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
25794};
25795
25796/**
25797 * Converts a Punycode string of ASCII-only symbols to a string of Unicode
25798 * symbols.
25799 * @memberOf punycode
25800 * @param {String} input The Punycode string of ASCII-only symbols.
25801 * @returns {String} The resulting string of Unicode symbols.
25802 */
25803var decode = function decode(input) {
25804 // Don't use UCS-2.
25805 var output = [];
25806 var inputLength = input.length;
25807 var i = 0;
25808 var n = initialN;
25809 var bias = initialBias;
25810
25811 // Handle the basic code points: let `basic` be the number of input code
25812 // points before the last delimiter, or `0` if there is none, then copy
25813 // the first basic code points to the output.
25814
25815 var basic = input.lastIndexOf(delimiter);
25816 if (basic < 0) {
25817 basic = 0;
25818 }
25819
25820 for (var j = 0; j < basic; ++j) {
25821 // if it's not a basic code point
25822 if (input.charCodeAt(j) >= 0x80) {
25823 error$1('not-basic');
25824 }
25825 output.push(input.charCodeAt(j));
25826 }
25827
25828 // Main decoding loop: start just after the last delimiter if any basic code
25829 // points were copied; start at the beginning otherwise.
25830
25831 for (var index = basic > 0 ? basic + 1 : 0; index < inputLength;) /* no final expression */{
25832
25833 // `index` is the index of the next character to be consumed.
25834 // Decode a generalized variable-length integer into `delta`,
25835 // which gets added to `i`. The overflow checking is easier
25836 // if we increase `i` as we go, then subtract off its starting
25837 // value at the end to obtain `delta`.
25838 var oldi = i;
25839 for (var w = 1, k = base;; /* no condition */k += base) {
25840
25841 if (index >= inputLength) {
25842 error$1('invalid-input');
25843 }
25844
25845 var digit = basicToDigit(input.charCodeAt(index++));
25846
25847 if (digit >= base || digit > floor((maxInt - i) / w)) {
25848 error$1('overflow');
25849 }
25850
25851 i += digit * w;
25852 var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
25853
25854 if (digit < t) {
25855 break;
25856 }
25857
25858 var baseMinusT = base - t;
25859 if (w > floor(maxInt / baseMinusT)) {
25860 error$1('overflow');
25861 }
25862
25863 w *= baseMinusT;
25864 }
25865
25866 var out = output.length + 1;
25867 bias = adapt(i - oldi, out, oldi == 0);
25868
25869 // `i` was supposed to wrap around from `out` to `0`,
25870 // incrementing `n` each time, so we'll fix that now:
25871 if (floor(i / out) > maxInt - n) {
25872 error$1('overflow');
25873 }
25874
25875 n += floor(i / out);
25876 i %= out;
25877
25878 // Insert `n` at position `i` of the output.
25879 output.splice(i++, 0, n);
25880 }
25881
25882 return String.fromCodePoint.apply(String, output);
25883};
25884
25885/**
25886 * Converts a string of Unicode symbols (e.g. a domain name label) to a
25887 * Punycode string of ASCII-only symbols.
25888 * @memberOf punycode
25889 * @param {String} input The string of Unicode symbols.
25890 * @returns {String} The resulting Punycode string of ASCII-only symbols.
25891 */
25892var encode = function encode(input) {
25893 var output = [];
25894
25895 // Convert the input in UCS-2 to an array of Unicode code points.
25896 input = ucs2decode(input);
25897
25898 // Cache the length.
25899 var inputLength = input.length;
25900
25901 // Initialize the state.
25902 var n = initialN;
25903 var delta = 0;
25904 var bias = initialBias;
25905
25906 // Handle the basic code points.
25907 var _iteratorNormalCompletion = true;
25908 var _didIteratorError = false;
25909 var _iteratorError = undefined;
25910
25911 try {
25912 for (var _iterator = input[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
25913 var _currentValue2 = _step.value;
25914
25915 if (_currentValue2 < 0x80) {
25916 output.push(stringFromCharCode(_currentValue2));
25917 }
25918 }
25919 } catch (err) {
25920 _didIteratorError = true;
25921 _iteratorError = err;
25922 } finally {
25923 try {
25924 if (!_iteratorNormalCompletion && _iterator.return) {
25925 _iterator.return();
25926 }
25927 } finally {
25928 if (_didIteratorError) {
25929 throw _iteratorError;
25930 }
25931 }
25932 }
25933
25934 var basicLength = output.length;
25935 var handledCPCount = basicLength;
25936
25937 // `handledCPCount` is the number of code points that have been handled;
25938 // `basicLength` is the number of basic code points.
25939
25940 // Finish the basic string with a delimiter unless it's empty.
25941 if (basicLength) {
25942 output.push(delimiter);
25943 }
25944
25945 // Main encoding loop:
25946 while (handledCPCount < inputLength) {
25947
25948 // All non-basic code points < n have been handled already. Find the next
25949 // larger one:
25950 var m = maxInt;
25951 var _iteratorNormalCompletion2 = true;
25952 var _didIteratorError2 = false;
25953 var _iteratorError2 = undefined;
25954
25955 try {
25956 for (var _iterator2 = input[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
25957 var currentValue = _step2.value;
25958
25959 if (currentValue >= n && currentValue < m) {
25960 m = currentValue;
25961 }
25962 }
25963
25964 // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
25965 // but guard against overflow.
25966 } catch (err) {
25967 _didIteratorError2 = true;
25968 _iteratorError2 = err;
25969 } finally {
25970 try {
25971 if (!_iteratorNormalCompletion2 && _iterator2.return) {
25972 _iterator2.return();
25973 }
25974 } finally {
25975 if (_didIteratorError2) {
25976 throw _iteratorError2;
25977 }
25978 }
25979 }
25980
25981 var handledCPCountPlusOne = handledCPCount + 1;
25982 if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
25983 error$1('overflow');
25984 }
25985
25986 delta += (m - n) * handledCPCountPlusOne;
25987 n = m;
25988
25989 var _iteratorNormalCompletion3 = true;
25990 var _didIteratorError3 = false;
25991 var _iteratorError3 = undefined;
25992
25993 try {
25994 for (var _iterator3 = input[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
25995 var _currentValue = _step3.value;
25996
25997 if (_currentValue < n && ++delta > maxInt) {
25998 error$1('overflow');
25999 }
26000 if (_currentValue == n) {
26001 // Represent delta as a generalized variable-length integer.
26002 var q = delta;
26003 for (var k = base;; /* no condition */k += base) {
26004 var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
26005 if (q < t) {
26006 break;
26007 }
26008 var qMinusT = q - t;
26009 var baseMinusT = base - t;
26010 output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)));
26011 q = floor(qMinusT / baseMinusT);
26012 }
26013
26014 output.push(stringFromCharCode(digitToBasic(q, 0)));
26015 bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
26016 delta = 0;
26017 ++handledCPCount;
26018 }
26019 }
26020 } catch (err) {
26021 _didIteratorError3 = true;
26022 _iteratorError3 = err;
26023 } finally {
26024 try {
26025 if (!_iteratorNormalCompletion3 && _iterator3.return) {
26026 _iterator3.return();
26027 }
26028 } finally {
26029 if (_didIteratorError3) {
26030 throw _iteratorError3;
26031 }
26032 }
26033 }
26034
26035 ++delta;
26036 ++n;
26037 }
26038 return output.join('');
26039};
26040
26041/**
26042 * Converts a Punycode string representing a domain name or an email address
26043 * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
26044 * it doesn't matter if you call it on a string that has already been
26045 * converted to Unicode.
26046 * @memberOf punycode
26047 * @param {String} input The Punycoded domain name or email address to
26048 * convert to Unicode.
26049 * @returns {String} The Unicode representation of the given Punycode
26050 * string.
26051 */
26052var toUnicode = function toUnicode(input) {
26053 return mapDomain(input, function (string) {
26054 return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
26055 });
26056};
26057
26058/**
26059 * Converts a Unicode string representing a domain name or an email address to
26060 * Punycode. Only the non-ASCII parts of the domain name will be converted,
26061 * i.e. it doesn't matter if you call it with a domain that's already in
26062 * ASCII.
26063 * @memberOf punycode
26064 * @param {String} input The domain name or email address to convert, as a
26065 * Unicode string.
26066 * @returns {String} The Punycode representation of the given domain name or
26067 * email address.
26068 */
26069var toASCII = function toASCII(input) {
26070 return mapDomain(input, function (string) {
26071 return regexNonASCII.test(string) ? 'xn--' + encode(string) : string;
26072 });
26073};
26074
26075/*--------------------------------------------------------------------------*/
26076
26077/** Define the public API */
26078var punycode = {
26079 /**
26080 * A string representing the current Punycode.js version number.
26081 * @memberOf punycode
26082 * @type String
26083 */
26084 'version': '2.1.0',
26085 /**
26086 * An object of methods to convert from JavaScript's internal character
26087 * representation (UCS-2) to Unicode code points, and back.
26088 * @see <https://mathiasbynens.be/notes/javascript-encoding>
26089 * @memberOf punycode
26090 * @type Object
26091 */
26092 'ucs2': {
26093 'decode': ucs2decode,
26094 'encode': ucs2encode
26095 },
26096 'decode': decode,
26097 'encode': encode,
26098 'toASCII': toASCII,
26099 'toUnicode': toUnicode
26100};
26101
26102/**
26103 * URI.js
26104 *
26105 * @fileoverview An RFC 3986 compliant, scheme extendable URI parsing/validating/resolving library for JavaScript.
26106 * @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
26107 * @see http://github.com/garycourt/uri-js
26108 */
26109/**
26110 * Copyright 2011 Gary Court. All rights reserved.
26111 *
26112 * Redistribution and use in source and binary forms, with or without modification, are
26113 * permitted provided that the following conditions are met:
26114 *
26115 * 1. Redistributions of source code must retain the above copyright notice, this list of
26116 * conditions and the following disclaimer.
26117 *
26118 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
26119 * of conditions and the following disclaimer in the documentation and/or other materials
26120 * provided with the distribution.
26121 *
26122 * THIS SOFTWARE IS PROVIDED BY GARY COURT ``AS IS'' AND ANY EXPRESS OR IMPLIED
26123 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
26124 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GARY COURT OR
26125 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26126 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26127 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26128 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26129 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26130 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26131 *
26132 * The views and conclusions contained in the software and documentation are those of the
26133 * authors and should not be interpreted as representing official policies, either expressed
26134 * or implied, of Gary Court.
26135 */
26136var SCHEMES = {};
26137function pctEncChar(chr) {
26138 var c = chr.charCodeAt(0);
26139 var e = void 0;
26140 if (c < 16) e = "%0" + c.toString(16).toUpperCase();else if (c < 128) e = "%" + c.toString(16).toUpperCase();else if (c < 2048) e = "%" + (c >> 6 | 192).toString(16).toUpperCase() + "%" + (c & 63 | 128).toString(16).toUpperCase();else e = "%" + (c >> 12 | 224).toString(16).toUpperCase() + "%" + (c >> 6 & 63 | 128).toString(16).toUpperCase() + "%" + (c & 63 | 128).toString(16).toUpperCase();
26141 return e;
26142}
26143function pctDecChars(str) {
26144 var newStr = "";
26145 var i = 0;
26146 var il = str.length;
26147 while (i < il) {
26148 var c = parseInt(str.substr(i + 1, 2), 16);
26149 if (c < 128) {
26150 newStr += String.fromCharCode(c);
26151 i += 3;
26152 } else if (c >= 194 && c < 224) {
26153 if (il - i >= 6) {
26154 var c2 = parseInt(str.substr(i + 4, 2), 16);
26155 newStr += String.fromCharCode((c & 31) << 6 | c2 & 63);
26156 } else {
26157 newStr += str.substr(i, 6);
26158 }
26159 i += 6;
26160 } else if (c >= 224) {
26161 if (il - i >= 9) {
26162 var _c = parseInt(str.substr(i + 4, 2), 16);
26163 var c3 = parseInt(str.substr(i + 7, 2), 16);
26164 newStr += String.fromCharCode((c & 15) << 12 | (_c & 63) << 6 | c3 & 63);
26165 } else {
26166 newStr += str.substr(i, 9);
26167 }
26168 i += 9;
26169 } else {
26170 newStr += str.substr(i, 3);
26171 i += 3;
26172 }
26173 }
26174 return newStr;
26175}
26176function _normalizeComponentEncoding(components, protocol) {
26177 function decodeUnreserved(str) {
26178 var decStr = pctDecChars(str);
26179 return !decStr.match(protocol.UNRESERVED) ? str : decStr;
26180 }
26181 if (components.scheme) components.scheme = String(components.scheme).replace(protocol.PCT_ENCODED, decodeUnreserved).toLowerCase().replace(protocol.NOT_SCHEME, "");
26182 if (components.userinfo !== undefined) components.userinfo = String(components.userinfo).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_USERINFO, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
26183 if (components.host !== undefined) components.host = String(components.host).replace(protocol.PCT_ENCODED, decodeUnreserved).toLowerCase().replace(protocol.NOT_HOST, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
26184 if (components.path !== undefined) components.path = String(components.path).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(components.scheme ? protocol.NOT_PATH : protocol.NOT_PATH_NOSCHEME, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
26185 if (components.query !== undefined) components.query = String(components.query).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_QUERY, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
26186 if (components.fragment !== undefined) components.fragment = String(components.fragment).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_FRAGMENT, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
26187 return components;
26188}
26189
26190function _stripLeadingZeros(str) {
26191 return str.replace(/^0*(.*)/, "$1") || "0";
26192}
26193function _normalizeIPv4(host, protocol) {
26194 var matches = host.match(protocol.IPV4ADDRESS) || [];
26195
26196 var _matches = slicedToArray(matches, 2),
26197 address = _matches[1];
26198
26199 if (address) {
26200 return address.split(".").map(_stripLeadingZeros).join(".");
26201 } else {
26202 return host;
26203 }
26204}
26205function _normalizeIPv6(host, protocol) {
26206 var matches = host.match(protocol.IPV6ADDRESS) || [];
26207
26208 var _matches2 = slicedToArray(matches, 3),
26209 address = _matches2[1],
26210 zone = _matches2[2];
26211
26212 if (address) {
26213 var _address$toLowerCase$ = address.toLowerCase().split('::').reverse(),
26214 _address$toLowerCase$2 = slicedToArray(_address$toLowerCase$, 2),
26215 last = _address$toLowerCase$2[0],
26216 first = _address$toLowerCase$2[1];
26217
26218 var firstFields = first ? first.split(":").map(_stripLeadingZeros) : [];
26219 var lastFields = last.split(":").map(_stripLeadingZeros);
26220 var isLastFieldIPv4Address = protocol.IPV4ADDRESS.test(lastFields[lastFields.length - 1]);
26221 var fieldCount = isLastFieldIPv4Address ? 7 : 8;
26222 var lastFieldsStart = lastFields.length - fieldCount;
26223 var fields = Array(fieldCount);
26224 for (var x = 0; x < fieldCount; ++x) {
26225 fields[x] = firstFields[x] || lastFields[lastFieldsStart + x] || '';
26226 }
26227 if (isLastFieldIPv4Address) {
26228 fields[fieldCount - 1] = _normalizeIPv4(fields[fieldCount - 1], protocol);
26229 }
26230 var allZeroFields = fields.reduce(function (acc, field, index) {
26231 if (!field || field === "0") {
26232 var lastLongest = acc[acc.length - 1];
26233 if (lastLongest && lastLongest.index + lastLongest.length === index) {
26234 lastLongest.length++;
26235 } else {
26236 acc.push({ index: index, length: 1 });
26237 }
26238 }
26239 return acc;
26240 }, []);
26241 var longestZeroFields = allZeroFields.sort(function (a, b) {
26242 return b.length - a.length;
26243 })[0];
26244 var newHost = void 0;
26245 if (longestZeroFields && longestZeroFields.length > 1) {
26246 var newFirst = fields.slice(0, longestZeroFields.index);
26247 var newLast = fields.slice(longestZeroFields.index + longestZeroFields.length);
26248 newHost = newFirst.join(":") + "::" + newLast.join(":");
26249 } else {
26250 newHost = fields.join(":");
26251 }
26252 if (zone) {
26253 newHost += "%" + zone;
26254 }
26255 return newHost;
26256 } else {
26257 return host;
26258 }
26259}
26260var URI_PARSE = /^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i;
26261var NO_MATCH_IS_UNDEFINED = "".match(/(){0}/)[1] === undefined;
26262function parse(uriString) {
26263 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
26264
26265 var components = {};
26266 var protocol = options.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL;
26267 if (options.reference === "suffix") uriString = (options.scheme ? options.scheme + ":" : "") + "//" + uriString;
26268 var matches = uriString.match(URI_PARSE);
26269 if (matches) {
26270 if (NO_MATCH_IS_UNDEFINED) {
26271 //store each component
26272 components.scheme = matches[1];
26273 components.userinfo = matches[3];
26274 components.host = matches[4];
26275 components.port = parseInt(matches[5], 10);
26276 components.path = matches[6] || "";
26277 components.query = matches[7];
26278 components.fragment = matches[8];
26279 //fix port number
26280 if (isNaN(components.port)) {
26281 components.port = matches[5];
26282 }
26283 } else {
26284 //IE FIX for improper RegExp matching
26285 //store each component
26286 components.scheme = matches[1] || undefined;
26287 components.userinfo = uriString.indexOf("@") !== -1 ? matches[3] : undefined;
26288 components.host = uriString.indexOf("//") !== -1 ? matches[4] : undefined;
26289 components.port = parseInt(matches[5], 10);
26290 components.path = matches[6] || "";
26291 components.query = uriString.indexOf("?") !== -1 ? matches[7] : undefined;
26292 components.fragment = uriString.indexOf("#") !== -1 ? matches[8] : undefined;
26293 //fix port number
26294 if (isNaN(components.port)) {
26295 components.port = uriString.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/) ? matches[4] : undefined;
26296 }
26297 }
26298 if (components.host) {
26299 //normalize IP hosts
26300 components.host = _normalizeIPv6(_normalizeIPv4(components.host, protocol), protocol);
26301 }
26302 //determine reference type
26303 if (components.scheme === undefined && components.userinfo === undefined && components.host === undefined && components.port === undefined && !components.path && components.query === undefined) {
26304 components.reference = "same-document";
26305 } else if (components.scheme === undefined) {
26306 components.reference = "relative";
26307 } else if (components.fragment === undefined) {
26308 components.reference = "absolute";
26309 } else {
26310 components.reference = "uri";
26311 }
26312 //check for reference errors
26313 if (options.reference && options.reference !== "suffix" && options.reference !== components.reference) {
26314 components.error = components.error || "URI is not a " + options.reference + " reference.";
26315 }
26316 //find scheme handler
26317 var schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()];
26318 //check if scheme can't handle IRIs
26319 if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
26320 //if host component is a domain name
26321 if (components.host && (options.domainHost || schemeHandler && schemeHandler.domainHost)) {
26322 //convert Unicode IDN -> ASCII IDN
26323 try {
26324 components.host = punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase());
26325 } catch (e) {
26326 components.error = components.error || "Host's domain name can not be converted to ASCII via punycode: " + e;
26327 }
26328 }
26329 //convert IRI -> URI
26330 _normalizeComponentEncoding(components, URI_PROTOCOL);
26331 } else {
26332 //normalize encodings
26333 _normalizeComponentEncoding(components, protocol);
26334 }
26335 //perform scheme specific parsing
26336 if (schemeHandler && schemeHandler.parse) {
26337 schemeHandler.parse(components, options);
26338 }
26339 } else {
26340 components.error = components.error || "URI can not be parsed.";
26341 }
26342 return components;
26343}
26344
26345function _recomposeAuthority(components, options) {
26346 var protocol = options.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL;
26347 var uriTokens = [];
26348 if (components.userinfo !== undefined) {
26349 uriTokens.push(components.userinfo);
26350 uriTokens.push("@");
26351 }
26352 if (components.host !== undefined) {
26353 //normalize IP hosts, add brackets and escape zone separator for IPv6
26354 uriTokens.push(_normalizeIPv6(_normalizeIPv4(String(components.host), protocol), protocol).replace(protocol.IPV6ADDRESS, function (_, $1, $2) {
26355 return "[" + $1 + ($2 ? "%25" + $2 : "") + "]";
26356 }));
26357 }
26358 if (typeof components.port === "number") {
26359 uriTokens.push(":");
26360 uriTokens.push(components.port.toString(10));
26361 }
26362 return uriTokens.length ? uriTokens.join("") : undefined;
26363}
26364
26365var RDS1 = /^\.\.?\//;
26366var RDS2 = /^\/\.(\/|$)/;
26367var RDS3 = /^\/\.\.(\/|$)/;
26368var RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/;
26369function removeDotSegments(input) {
26370 var output = [];
26371 while (input.length) {
26372 if (input.match(RDS1)) {
26373 input = input.replace(RDS1, "");
26374 } else if (input.match(RDS2)) {
26375 input = input.replace(RDS2, "/");
26376 } else if (input.match(RDS3)) {
26377 input = input.replace(RDS3, "/");
26378 output.pop();
26379 } else if (input === "." || input === "..") {
26380 input = "";
26381 } else {
26382 var im = input.match(RDS5);
26383 if (im) {
26384 var s = im[0];
26385 input = input.slice(s.length);
26386 output.push(s);
26387 } else {
26388 throw new Error("Unexpected dot segment condition");
26389 }
26390 }
26391 }
26392 return output.join("");
26393}
26394
26395function serialize(components) {
26396 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
26397
26398 var protocol = options.iri ? IRI_PROTOCOL : URI_PROTOCOL;
26399 var uriTokens = [];
26400 //find scheme handler
26401 var schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()];
26402 //perform scheme specific serialization
26403 if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(components, options);
26404 if (components.host) {
26405 //if host component is an IPv6 address
26406 if (protocol.IPV6ADDRESS.test(components.host)) {}
26407 //TODO: normalize IPv6 address as per RFC 5952
26408
26409 //if host component is a domain name
26410 else if (options.domainHost || schemeHandler && schemeHandler.domainHost) {
26411 //convert IDN via punycode
26412 try {
26413 components.host = !options.iri ? punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase()) : punycode.toUnicode(components.host);
26414 } catch (e) {
26415 components.error = components.error || "Host's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e;
26416 }
26417 }
26418 }
26419 //normalize encoding
26420 _normalizeComponentEncoding(components, protocol);
26421 if (options.reference !== "suffix" && components.scheme) {
26422 uriTokens.push(components.scheme);
26423 uriTokens.push(":");
26424 }
26425 var authority = _recomposeAuthority(components, options);
26426 if (authority !== undefined) {
26427 if (options.reference !== "suffix") {
26428 uriTokens.push("//");
26429 }
26430 uriTokens.push(authority);
26431 if (components.path && components.path.charAt(0) !== "/") {
26432 uriTokens.push("/");
26433 }
26434 }
26435 if (components.path !== undefined) {
26436 var s = components.path;
26437 if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
26438 s = removeDotSegments(s);
26439 }
26440 if (authority === undefined) {
26441 s = s.replace(/^\/\//, "/%2F"); //don't allow the path to start with "//"
26442 }
26443 uriTokens.push(s);
26444 }
26445 if (components.query !== undefined) {
26446 uriTokens.push("?");
26447 uriTokens.push(components.query);
26448 }
26449 if (components.fragment !== undefined) {
26450 uriTokens.push("#");
26451 uriTokens.push(components.fragment);
26452 }
26453 return uriTokens.join(""); //merge tokens into a string
26454}
26455
26456function resolveComponents(base, relative) {
26457 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
26458 var skipNormalization = arguments[3];
26459
26460 var target = {};
26461 if (!skipNormalization) {
26462 base = parse(serialize(base, options), options); //normalize base components
26463 relative = parse(serialize(relative, options), options); //normalize relative components
26464 }
26465 options = options || {};
26466 if (!options.tolerant && relative.scheme) {
26467 target.scheme = relative.scheme;
26468 //target.authority = relative.authority;
26469 target.userinfo = relative.userinfo;
26470 target.host = relative.host;
26471 target.port = relative.port;
26472 target.path = removeDotSegments(relative.path || "");
26473 target.query = relative.query;
26474 } else {
26475 if (relative.userinfo !== undefined || relative.host !== undefined || relative.port !== undefined) {
26476 //target.authority = relative.authority;
26477 target.userinfo = relative.userinfo;
26478 target.host = relative.host;
26479 target.port = relative.port;
26480 target.path = removeDotSegments(relative.path || "");
26481 target.query = relative.query;
26482 } else {
26483 if (!relative.path) {
26484 target.path = base.path;
26485 if (relative.query !== undefined) {
26486 target.query = relative.query;
26487 } else {
26488 target.query = base.query;
26489 }
26490 } else {
26491 if (relative.path.charAt(0) === "/") {
26492 target.path = removeDotSegments(relative.path);
26493 } else {
26494 if ((base.userinfo !== undefined || base.host !== undefined || base.port !== undefined) && !base.path) {
26495 target.path = "/" + relative.path;
26496 } else if (!base.path) {
26497 target.path = relative.path;
26498 } else {
26499 target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
26500 }
26501 target.path = removeDotSegments(target.path);
26502 }
26503 target.query = relative.query;
26504 }
26505 //target.authority = base.authority;
26506 target.userinfo = base.userinfo;
26507 target.host = base.host;
26508 target.port = base.port;
26509 }
26510 target.scheme = base.scheme;
26511 }
26512 target.fragment = relative.fragment;
26513 return target;
26514}
26515
26516function resolve(baseURI, relativeURI, options) {
26517 var schemelessOptions = assign({ scheme: 'null' }, options);
26518 return serialize(resolveComponents(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
26519}
26520
26521function normalize(uri, options) {
26522 if (typeof uri === "string") {
26523 uri = serialize(parse(uri, options), options);
26524 } else if (typeOf(uri) === "object") {
26525 uri = parse(serialize(uri, options), options);
26526 }
26527 return uri;
26528}
26529
26530function equal(uriA, uriB, options) {
26531 if (typeof uriA === "string") {
26532 uriA = serialize(parse(uriA, options), options);
26533 } else if (typeOf(uriA) === "object") {
26534 uriA = serialize(uriA, options);
26535 }
26536 if (typeof uriB === "string") {
26537 uriB = serialize(parse(uriB, options), options);
26538 } else if (typeOf(uriB) === "object") {
26539 uriB = serialize(uriB, options);
26540 }
26541 return uriA === uriB;
26542}
26543
26544function escapeComponent(str, options) {
26545 return str && str.toString().replace(!options || !options.iri ? URI_PROTOCOL.ESCAPE : IRI_PROTOCOL.ESCAPE, pctEncChar);
26546}
26547
26548function unescapeComponent(str, options) {
26549 return str && str.toString().replace(!options || !options.iri ? URI_PROTOCOL.PCT_ENCODED : IRI_PROTOCOL.PCT_ENCODED, pctDecChars);
26550}
26551
26552var handler = {
26553 scheme: "http",
26554 domainHost: true,
26555 parse: function parse(components, options) {
26556 //report missing host
26557 if (!components.host) {
26558 components.error = components.error || "HTTP URIs must have a host.";
26559 }
26560 return components;
26561 },
26562 serialize: function serialize(components, options) {
26563 //normalize the default port
26564 if (components.port === (String(components.scheme).toLowerCase() !== "https" ? 80 : 443) || components.port === "") {
26565 components.port = undefined;
26566 }
26567 //normalize the empty path
26568 if (!components.path) {
26569 components.path = "/";
26570 }
26571 //NOTE: We do not parse query strings for HTTP URIs
26572 //as WWW Form Url Encoded query strings are part of the HTML4+ spec,
26573 //and not the HTTP spec.
26574 return components;
26575 }
26576};
26577
26578var handler$1 = {
26579 scheme: "https",
26580 domainHost: handler.domainHost,
26581 parse: handler.parse,
26582 serialize: handler.serialize
26583};
26584
26585var O = {};
26586var isIRI = true;
26587//RFC 3986
26588var UNRESERVED$$ = "[A-Za-z0-9\\-\\.\\_\\~" + (isIRI ? "\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF" : "") + "]";
26589var HEXDIG$$ = "[0-9A-Fa-f]"; //case-insensitive
26590var PCT_ENCODED$ = subexp(subexp("%[EFef]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%[89A-Fa-f]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%" + HEXDIG$$ + HEXDIG$$)); //expanded
26591//RFC 5322, except these symbols as per RFC 6068: @ : / ? # [ ] & ; =
26592//const ATEXT$$ = "[A-Za-z0-9\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\|\\}\\~]";
26593//const WSP$$ = "[\\x20\\x09]";
26594//const OBS_QTEXT$$ = "[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x7F]"; //(%d1-8 / %d11-12 / %d14-31 / %d127)
26595//const QTEXT$$ = merge("[\\x21\\x23-\\x5B\\x5D-\\x7E]", OBS_QTEXT$$); //%d33 / %d35-91 / %d93-126 / obs-qtext
26596//const VCHAR$$ = "[\\x21-\\x7E]";
26597//const WSP$$ = "[\\x20\\x09]";
26598//const OBS_QP$ = subexp("\\\\" + merge("[\\x00\\x0D\\x0A]", OBS_QTEXT$$)); //%d0 / CR / LF / obs-qtext
26599//const FWS$ = subexp(subexp(WSP$$ + "*" + "\\x0D\\x0A") + "?" + WSP$$ + "+");
26600//const QUOTED_PAIR$ = subexp(subexp("\\\\" + subexp(VCHAR$$ + "|" + WSP$$)) + "|" + OBS_QP$);
26601//const QUOTED_STRING$ = subexp('\\"' + subexp(FWS$ + "?" + QCONTENT$) + "*" + FWS$ + "?" + '\\"');
26602var ATEXT$$ = "[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]";
26603var QTEXT$$ = "[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]";
26604var VCHAR$$ = merge(QTEXT$$, "[\\\"\\\\]");
26605var SOME_DELIMS$$ = "[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]";
26606var UNRESERVED = new RegExp(UNRESERVED$$, "g");
26607var PCT_ENCODED = new RegExp(PCT_ENCODED$, "g");
26608var NOT_LOCAL_PART = new RegExp(merge("[^]", ATEXT$$, "[\\.]", '[\\"]', VCHAR$$), "g");
26609var NOT_HFNAME = new RegExp(merge("[^]", UNRESERVED$$, SOME_DELIMS$$), "g");
26610var NOT_HFVALUE = NOT_HFNAME;
26611function decodeUnreserved(str) {
26612 var decStr = pctDecChars(str);
26613 return !decStr.match(UNRESERVED) ? str : decStr;
26614}
26615var handler$2 = {
26616 scheme: "mailto",
26617 parse: function parse$$1(components, options) {
26618 var mailtoComponents = components;
26619 var to = mailtoComponents.to = mailtoComponents.path ? mailtoComponents.path.split(",") : [];
26620 mailtoComponents.path = undefined;
26621 if (mailtoComponents.query) {
26622 var unknownHeaders = false;
26623 var headers = {};
26624 var hfields = mailtoComponents.query.split("&");
26625 for (var x = 0, xl = hfields.length; x < xl; ++x) {
26626 var hfield = hfields[x].split("=");
26627 switch (hfield[0]) {
26628 case "to":
26629 var toAddrs = hfield[1].split(",");
26630 for (var _x = 0, _xl = toAddrs.length; _x < _xl; ++_x) {
26631 to.push(toAddrs[_x]);
26632 }
26633 break;
26634 case "subject":
26635 mailtoComponents.subject = unescapeComponent(hfield[1], options);
26636 break;
26637 case "body":
26638 mailtoComponents.body = unescapeComponent(hfield[1], options);
26639 break;
26640 default:
26641 unknownHeaders = true;
26642 headers[unescapeComponent(hfield[0], options)] = unescapeComponent(hfield[1], options);
26643 break;
26644 }
26645 }
26646 if (unknownHeaders) mailtoComponents.headers = headers;
26647 }
26648 mailtoComponents.query = undefined;
26649 for (var _x2 = 0, _xl2 = to.length; _x2 < _xl2; ++_x2) {
26650 var addr = to[_x2].split("@");
26651 addr[0] = unescapeComponent(addr[0]);
26652 if (!options.unicodeSupport) {
26653 //convert Unicode IDN -> ASCII IDN
26654 try {
26655 addr[1] = punycode.toASCII(unescapeComponent(addr[1], options).toLowerCase());
26656 } catch (e) {
26657 mailtoComponents.error = mailtoComponents.error || "Email address's domain name can not be converted to ASCII via punycode: " + e;
26658 }
26659 } else {
26660 addr[1] = unescapeComponent(addr[1], options).toLowerCase();
26661 }
26662 to[_x2] = addr.join("@");
26663 }
26664 return mailtoComponents;
26665 },
26666 serialize: function serialize$$1(mailtoComponents, options) {
26667 var components = mailtoComponents;
26668 var to = toArray(mailtoComponents.to);
26669 if (to) {
26670 for (var x = 0, xl = to.length; x < xl; ++x) {
26671 var toAddr = String(to[x]);
26672 var atIdx = toAddr.lastIndexOf("@");
26673 var localPart = toAddr.slice(0, atIdx).replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_LOCAL_PART, pctEncChar);
26674 var domain = toAddr.slice(atIdx + 1);
26675 //convert IDN via punycode
26676 try {
26677 domain = !options.iri ? punycode.toASCII(unescapeComponent(domain, options).toLowerCase()) : punycode.toUnicode(domain);
26678 } catch (e) {
26679 components.error = components.error || "Email address's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e;
26680 }
26681 to[x] = localPart + "@" + domain;
26682 }
26683 components.path = to.join(",");
26684 }
26685 var headers = mailtoComponents.headers = mailtoComponents.headers || {};
26686 if (mailtoComponents.subject) headers["subject"] = mailtoComponents.subject;
26687 if (mailtoComponents.body) headers["body"] = mailtoComponents.body;
26688 var fields = [];
26689 for (var name in headers) {
26690 if (headers[name] !== O[name]) {
26691 fields.push(name.replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_HFNAME, pctEncChar) + "=" + headers[name].replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_HFVALUE, pctEncChar));
26692 }
26693 }
26694 if (fields.length) {
26695 components.query = fields.join("&");
26696 }
26697 return components;
26698 }
26699};
26700
26701var URN_PARSE = /^([^\:]+)\:(.*)/;
26702//RFC 2141
26703var handler$3 = {
26704 scheme: "urn",
26705 parse: function parse$$1(components, options) {
26706 var matches = components.path && components.path.match(URN_PARSE);
26707 var urnComponents = components;
26708 if (matches) {
26709 var scheme = options.scheme || urnComponents.scheme || "urn";
26710 var nid = matches[1].toLowerCase();
26711 var nss = matches[2];
26712 var urnScheme = scheme + ":" + (options.nid || nid);
26713 var schemeHandler = SCHEMES[urnScheme];
26714 urnComponents.nid = nid;
26715 urnComponents.nss = nss;
26716 urnComponents.path = undefined;
26717 if (schemeHandler) {
26718 urnComponents = schemeHandler.parse(urnComponents, options);
26719 }
26720 } else {
26721 urnComponents.error = urnComponents.error || "URN can not be parsed.";
26722 }
26723 return urnComponents;
26724 },
26725 serialize: function serialize$$1(urnComponents, options) {
26726 var scheme = options.scheme || urnComponents.scheme || "urn";
26727 var nid = urnComponents.nid;
26728 var urnScheme = scheme + ":" + (options.nid || nid);
26729 var schemeHandler = SCHEMES[urnScheme];
26730 if (schemeHandler) {
26731 urnComponents = schemeHandler.serialize(urnComponents, options);
26732 }
26733 var uriComponents = urnComponents;
26734 var nss = urnComponents.nss;
26735 uriComponents.path = (nid || options.nid) + ":" + nss;
26736 return uriComponents;
26737 }
26738};
26739
26740var UUID = /^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/;
26741//RFC 4122
26742var handler$4 = {
26743 scheme: "urn:uuid",
26744 parse: function parse(urnComponents, options) {
26745 var uuidComponents = urnComponents;
26746 uuidComponents.uuid = uuidComponents.nss;
26747 uuidComponents.nss = undefined;
26748 if (!options.tolerant && (!uuidComponents.uuid || !uuidComponents.uuid.match(UUID))) {
26749 uuidComponents.error = uuidComponents.error || "UUID is not valid.";
26750 }
26751 return uuidComponents;
26752 },
26753 serialize: function serialize(uuidComponents, options) {
26754 var urnComponents = uuidComponents;
26755 //normalize UUID
26756 urnComponents.nss = (uuidComponents.uuid || "").toLowerCase();
26757 return urnComponents;
26758 }
26759};
26760
26761SCHEMES[handler.scheme] = handler;
26762SCHEMES[handler$1.scheme] = handler$1;
26763SCHEMES[handler$2.scheme] = handler$2;
26764SCHEMES[handler$3.scheme] = handler$3;
26765SCHEMES[handler$4.scheme] = handler$4;
26766
26767exports.SCHEMES = SCHEMES;
26768exports.pctEncChar = pctEncChar;
26769exports.pctDecChars = pctDecChars;
26770exports.parse = parse;
26771exports.removeDotSegments = removeDotSegments;
26772exports.serialize = serialize;
26773exports.resolveComponents = resolveComponents;
26774exports.resolve = resolve;
26775exports.normalize = normalize;
26776exports.equal = equal;
26777exports.escapeComponent = escapeComponent;
26778exports.unescapeComponent = unescapeComponent;
26779
26780Object.defineProperty(exports, '__esModule', { value: true });
26781
26782})));
26783
26784
26785},{}],317:[function(require,module,exports){
26786(function (global){
26787
26788/**
26789 * Module exports.
26790 */
26791
26792module.exports = deprecate;
26793
26794/**
26795 * Mark that a method should not be used.
26796 * Returns a modified function which warns once by default.
26797 *
26798 * If `localStorage.noDeprecation = true` is set, then it is a no-op.
26799 *
26800 * If `localStorage.throwDeprecation = true` is set, then deprecated functions
26801 * will throw an Error when invoked.
26802 *
26803 * If `localStorage.traceDeprecation = true` is set, then deprecated functions
26804 * will invoke `console.trace()` instead of `console.error()`.
26805 *
26806 * @param {Function} fn - the function to deprecate
26807 * @param {String} msg - the string to print to the console when `fn` is invoked
26808 * @returns {Function} a new "deprecated" version of `fn`
26809 * @api public
26810 */
26811
26812function deprecate (fn, msg) {
26813 if (config('noDeprecation')) {
26814 return fn;
26815 }
26816
26817 var warned = false;
26818 function deprecated() {
26819 if (!warned) {
26820 if (config('throwDeprecation')) {
26821 throw new Error(msg);
26822 } else if (config('traceDeprecation')) {
26823 console.trace(msg);
26824 } else {
26825 console.warn(msg);
26826 }
26827 warned = true;
26828 }
26829 return fn.apply(this, arguments);
26830 }
26831
26832 return deprecated;
26833}
26834
26835/**
26836 * Checks `localStorage` for boolean values for the given `name`.
26837 *
26838 * @param {String} name
26839 * @returns {Boolean}
26840 * @api private
26841 */
26842
26843function config (name) {
26844 // accessing global.localStorage can trigger a DOMException in sandboxed iframes
26845 try {
26846 if (!global.localStorage) return false;
26847 } catch (_) {
26848 return false;
26849 }
26850 var val = global.localStorage[name];
26851 if (null == val) return false;
26852 return String(val).toLowerCase() === 'true';
26853}
26854
26855}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
26856},{}],318:[function(require,module,exports){
26857var indexOf = require('indexof');
26858
26859var Object_keys = function (obj) {
26860 if (Object.keys) return Object.keys(obj)
26861 else {
26862 var res = [];
26863 for (var key in obj) res.push(key)
26864 return res;
26865 }
26866};
26867
26868var forEach = function (xs, fn) {
26869 if (xs.forEach) return xs.forEach(fn)
26870 else for (var i = 0; i < xs.length; i++) {
26871 fn(xs[i], i, xs);
26872 }
26873};
26874
26875var defineProp = (function() {
26876 try {
26877 Object.defineProperty({}, '_', {});
26878 return function(obj, name, value) {
26879 Object.defineProperty(obj, name, {
26880 writable: true,
26881 enumerable: false,
26882 configurable: true,
26883 value: value
26884 })
26885 };
26886 } catch(e) {
26887 return function(obj, name, value) {
26888 obj[name] = value;
26889 };
26890 }
26891}());
26892
26893var globals = ['Array', 'Boolean', 'Date', 'Error', 'EvalError', 'Function',
26894'Infinity', 'JSON', 'Math', 'NaN', 'Number', 'Object', 'RangeError',
26895'ReferenceError', 'RegExp', 'String', 'SyntaxError', 'TypeError', 'URIError',
26896'decodeURI', 'decodeURIComponent', 'encodeURI', 'encodeURIComponent', 'escape',
26897'eval', 'isFinite', 'isNaN', 'parseFloat', 'parseInt', 'undefined', 'unescape'];
26898
26899function Context() {}
26900Context.prototype = {};
26901
26902var Script = exports.Script = function NodeScript (code) {
26903 if (!(this instanceof Script)) return new Script(code);
26904 this.code = code;
26905};
26906
26907Script.prototype.runInContext = function (context) {
26908 if (!(context instanceof Context)) {
26909 throw new TypeError("needs a 'context' argument.");
26910 }
26911
26912 var iframe = document.createElement('iframe');
26913 if (!iframe.style) iframe.style = {};
26914 iframe.style.display = 'none';
26915
26916 document.body.appendChild(iframe);
26917
26918 var win = iframe.contentWindow;
26919 var wEval = win.eval, wExecScript = win.execScript;
26920
26921 if (!wEval && wExecScript) {
26922 // win.eval() magically appears when this is called in IE:
26923 wExecScript.call(win, 'null');
26924 wEval = win.eval;
26925 }
26926
26927 forEach(Object_keys(context), function (key) {
26928 win[key] = context[key];
26929 });
26930 forEach(globals, function (key) {
26931 if (context[key]) {
26932 win[key] = context[key];
26933 }
26934 });
26935
26936 var winKeys = Object_keys(win);
26937
26938 var res = wEval.call(win, this.code);
26939
26940 forEach(Object_keys(win), function (key) {
26941 // Avoid copying circular objects like `top` and `window` by only
26942 // updating existing context properties or new properties in the `win`
26943 // that was only introduced after the eval.
26944 if (key in context || indexOf(winKeys, key) === -1) {
26945 context[key] = win[key];
26946 }
26947 });
26948
26949 forEach(globals, function (key) {
26950 if (!(key in context)) {
26951 defineProp(context, key, win[key]);
26952 }
26953 });
26954
26955 document.body.removeChild(iframe);
26956
26957 return res;
26958};
26959
26960Script.prototype.runInThisContext = function () {
26961 return eval(this.code); // maybe...
26962};
26963
26964Script.prototype.runInNewContext = function (context) {
26965 var ctx = Script.createContext(context);
26966 var res = this.runInContext(ctx);
26967
26968 forEach(Object_keys(ctx), function (key) {
26969 context[key] = ctx[key];
26970 });
26971
26972 return res;
26973};
26974
26975forEach(Object_keys(Script.prototype), function (name) {
26976 exports[name] = Script[name] = function (code) {
26977 var s = Script(code);
26978 return s[name].apply(s, [].slice.call(arguments, 1));
26979 };
26980});
26981
26982exports.createScript = function (code) {
26983 return exports.Script(code);
26984};
26985
26986exports.createContext = Script.createContext = function (context) {
26987 var copy = new Context();
26988 if(typeof context === 'object') {
26989 forEach(Object_keys(context), function (key) {
26990 copy[key] = context[key];
26991 });
26992 }
26993 return copy;
26994};
26995
26996},{"indexof":259}],319:[function(require,module,exports){
26997// This is free and unencumbered software released into the public domain.
26998// See LICENSE.md for more information.
26999
27000var encoding = require("./lib/encoding.js");
27001
27002module.exports = {
27003 TextEncoder: encoding.TextEncoder,
27004 TextDecoder: encoding.TextDecoder,
27005};
27006
27007},{"./lib/encoding.js":321}],320:[function(require,module,exports){
27008(function(global) {
27009 'use strict';
27010 global["encoding-indexes"] = {
27011 "big5":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,17392,19506,17923,17830,17784,160359,19831,17843,162993,19682,163013,15253,18230,18244,19527,19520,148159,144919,160594,159371,159954,19543,172881,18255,17882,19589,162924,19719,19108,18081,158499,29221,154196,137827,146950,147297,26189,22267,null,32149,22813,166841,15860,38708,162799,23515,138590,23204,13861,171696,23249,23479,23804,26478,34195,170309,29793,29853,14453,138579,145054,155681,16108,153822,15093,31484,40855,147809,166157,143850,133770,143966,17162,33924,40854,37935,18736,34323,22678,38730,37400,31184,31282,26208,27177,34973,29772,31685,26498,31276,21071,36934,13542,29636,155065,29894,40903,22451,18735,21580,16689,145038,22552,31346,162661,35727,18094,159368,16769,155033,31662,140476,40904,140481,140489,140492,40905,34052,144827,16564,40906,17633,175615,25281,28782,40907,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,12736,12737,12738,12739,12740,131340,12741,131281,131277,12742,12743,131275,139240,12744,131274,12745,12746,12747,12748,131342,12749,12750,256,193,461,192,274,201,282,200,332,211,465,210,null,7870,null,7872,202,257,225,462,224,593,275,233,283,232,299,237,464,236,333,243,466,242,363,250,468,249,470,472,474,476,252,null,7871,null,7873,234,609,9178,9179,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,172969,135493,null,25866,null,null,20029,28381,40270,37343,null,null,161589,25745,20250,20264,20392,20822,20852,20892,20964,21153,21160,21307,21326,21457,21464,22242,22768,22788,22791,22834,22836,23398,23454,23455,23706,24198,24635,25993,26622,26628,26725,27982,28860,30005,32420,32428,32442,32455,32463,32479,32518,32567,33402,33487,33647,35270,35774,35810,36710,36711,36718,29713,31996,32205,26950,31433,21031,null,null,null,null,37260,30904,37214,32956,null,36107,33014,133607,null,null,32927,40647,19661,40393,40460,19518,171510,159758,40458,172339,13761,null,28314,33342,29977,null,18705,39532,39567,40857,31111,164972,138698,132560,142054,20004,20097,20096,20103,20159,20203,20279,13388,20413,15944,20483,20616,13437,13459,13477,20870,22789,20955,20988,20997,20105,21113,21136,21287,13767,21417,13649,21424,13651,21442,21539,13677,13682,13953,21651,21667,21684,21689,21712,21743,21784,21795,21800,13720,21823,13733,13759,21975,13765,163204,21797,null,134210,134421,151851,21904,142534,14828,131905,36422,150968,169189,16467,164030,30586,142392,14900,18389,164189,158194,151018,25821,134524,135092,134357,135412,25741,36478,134806,134155,135012,142505,164438,148691,null,134470,170573,164073,18420,151207,142530,39602,14951,169460,16365,13574,152263,169940,161992,142660,40302,38933,null,17369,155813,25780,21731,142668,142282,135287,14843,135279,157402,157462,162208,25834,151634,134211,36456,139681,166732,132913,null,18443,131497,16378,22643,142733,null,148936,132348,155799,134988,134550,21881,16571,17338,null,19124,141926,135325,33194,39157,134556,25465,14846,141173,36288,22177,25724,15939,null,173569,134665,142031,142537,null,135368,145858,14738,14854,164507,13688,155209,139463,22098,134961,142514,169760,13500,27709,151099,null,null,161140,142987,139784,173659,167117,134778,134196,157724,32659,135375,141315,141625,13819,152035,134796,135053,134826,16275,134960,134471,135503,134732,null,134827,134057,134472,135360,135485,16377,140950,25650,135085,144372,161337,142286,134526,134527,142417,142421,14872,134808,135367,134958,173618,158544,167122,167321,167114,38314,21708,33476,21945,null,171715,39974,39606,161630,142830,28992,33133,33004,23580,157042,33076,14231,21343,164029,37302,134906,134671,134775,134907,13789,151019,13833,134358,22191,141237,135369,134672,134776,135288,135496,164359,136277,134777,151120,142756,23124,135197,135198,135413,135414,22428,134673,161428,164557,135093,134779,151934,14083,135094,135552,152280,172733,149978,137274,147831,164476,22681,21096,13850,153405,31666,23400,18432,19244,40743,18919,39967,39821,154484,143677,22011,13810,22153,20008,22786,138177,194680,38737,131206,20059,20155,13630,23587,24401,24516,14586,25164,25909,27514,27701,27706,28780,29227,20012,29357,149737,32594,31035,31993,32595,156266,13505,null,156491,32770,32896,157202,158033,21341,34916,35265,161970,35744,36125,38021,38264,38271,38376,167439,38886,39029,39118,39134,39267,170000,40060,40479,40644,27503,63751,20023,131207,38429,25143,38050,null,20539,28158,171123,40870,15817,34959,147790,28791,23797,19232,152013,13657,154928,24866,166450,36775,37366,29073,26393,29626,144001,172295,15499,137600,19216,30948,29698,20910,165647,16393,27235,172730,16931,34319,133743,31274,170311,166634,38741,28749,21284,139390,37876,30425,166371,40871,30685,20131,20464,20668,20015,20247,40872,21556,32139,22674,22736,138678,24210,24217,24514,141074,25995,144377,26905,27203,146531,27903,null,29184,148741,29580,16091,150035,23317,29881,35715,154788,153237,31379,31724,31939,32364,33528,34199,40873,34960,40874,36537,40875,36815,34143,39392,37409,40876,167353,136255,16497,17058,23066,null,null,null,39016,26475,17014,22333,null,34262,149883,33471,160013,19585,159092,23931,158485,159678,40877,40878,23446,40879,26343,32347,28247,31178,15752,17603,143958,141206,17306,17718,null,23765,146202,35577,23672,15634,144721,23928,40882,29015,17752,147692,138787,19575,14712,13386,131492,158785,35532,20404,131641,22975,33132,38998,170234,24379,134047,null,139713,166253,16642,18107,168057,16135,40883,172469,16632,14294,18167,158790,16764,165554,160767,17773,14548,152730,17761,17691,19849,19579,19830,17898,16328,150287,13921,17630,17597,16877,23870,23880,23894,15868,14351,23972,23993,14368,14392,24130,24253,24357,24451,14600,14612,14655,14669,24791,24893,23781,14729,25015,25017,25039,14776,25132,25232,25317,25368,14840,22193,14851,25570,25595,25607,25690,14923,25792,23829,22049,40863,14999,25990,15037,26111,26195,15090,26258,15138,26390,15170,26532,26624,15192,26698,26756,15218,15217,15227,26889,26947,29276,26980,27039,27013,15292,27094,15325,27237,27252,27249,27266,15340,27289,15346,27307,27317,27348,27382,27521,27585,27626,27765,27818,15563,27906,27910,27942,28033,15599,28068,28081,28181,28184,28201,28294,166336,28347,28386,28378,40831,28392,28393,28452,28468,15686,147265,28545,28606,15722,15733,29111,23705,15754,28716,15761,28752,28756,28783,28799,28809,131877,17345,13809,134872,147159,22462,159443,28990,153568,13902,27042,166889,23412,31305,153825,169177,31333,31357,154028,31419,31408,31426,31427,29137,156813,16842,31450,31453,31466,16879,21682,154625,31499,31573,31529,152334,154878,31650,31599,33692,154548,158847,31696,33825,31634,31672,154912,15789,154725,33938,31738,31750,31797,154817,31812,31875,149634,31910,26237,148856,31945,31943,31974,31860,31987,31989,31950,32359,17693,159300,32093,159446,29837,32137,32171,28981,32179,32210,147543,155689,32228,15635,32245,137209,32229,164717,32285,155937,155994,32366,32402,17195,37996,32295,32576,32577,32583,31030,156368,39393,32663,156497,32675,136801,131176,17756,145254,17667,164666,32762,156809,32773,32776,32797,32808,32815,172167,158915,32827,32828,32865,141076,18825,157222,146915,157416,26405,32935,166472,33031,33050,22704,141046,27775,156824,151480,25831,136330,33304,137310,27219,150117,150165,17530,33321,133901,158290,146814,20473,136445,34018,33634,158474,149927,144688,137075,146936,33450,26907,194964,16859,34123,33488,33562,134678,137140,14017,143741,144730,33403,33506,33560,147083,159139,158469,158615,144846,15807,33565,21996,33669,17675,159141,33708,33729,33747,13438,159444,27223,34138,13462,159298,143087,33880,154596,33905,15827,17636,27303,33866,146613,31064,33960,158614,159351,159299,34014,33807,33681,17568,33939,34020,154769,16960,154816,17731,34100,23282,159385,17703,34163,17686,26559,34326,165413,165435,34241,159880,34306,136578,159949,194994,17770,34344,13896,137378,21495,160666,34430,34673,172280,34798,142375,34737,34778,34831,22113,34412,26710,17935,34885,34886,161248,146873,161252,34910,34972,18011,34996,34997,25537,35013,30583,161551,35207,35210,35238,35241,35239,35260,166437,35303,162084,162493,35484,30611,37374,35472,162393,31465,162618,147343,18195,162616,29052,35596,35615,152624,152933,35647,35660,35661,35497,150138,35728,35739,35503,136927,17941,34895,35995,163156,163215,195028,14117,163155,36054,163224,163261,36114,36099,137488,36059,28764,36113,150729,16080,36215,36265,163842,135188,149898,15228,164284,160012,31463,36525,36534,36547,37588,36633,36653,164709,164882,36773,37635,172703,133712,36787,18730,166366,165181,146875,24312,143970,36857,172052,165564,165121,140069,14720,159447,36919,165180,162494,36961,165228,165387,37032,165651,37060,165606,37038,37117,37223,15088,37289,37316,31916,166195,138889,37390,27807,37441,37474,153017,37561,166598,146587,166668,153051,134449,37676,37739,166625,166891,28815,23235,166626,166629,18789,37444,166892,166969,166911,37747,37979,36540,38277,38310,37926,38304,28662,17081,140922,165592,135804,146990,18911,27676,38523,38550,16748,38563,159445,25050,38582,30965,166624,38589,21452,18849,158904,131700,156688,168111,168165,150225,137493,144138,38705,34370,38710,18959,17725,17797,150249,28789,23361,38683,38748,168405,38743,23370,168427,38751,37925,20688,143543,143548,38793,38815,38833,38846,38848,38866,38880,152684,38894,29724,169011,38911,38901,168989,162170,19153,38964,38963,38987,39014,15118,160117,15697,132656,147804,153350,39114,39095,39112,39111,19199,159015,136915,21936,39137,39142,39148,37752,39225,150057,19314,170071,170245,39413,39436,39483,39440,39512,153381,14020,168113,170965,39648,39650,170757,39668,19470,39700,39725,165376,20532,39732,158120,14531,143485,39760,39744,171326,23109,137315,39822,148043,39938,39935,39948,171624,40404,171959,172434,172459,172257,172323,172511,40318,40323,172340,40462,26760,40388,139611,172435,172576,137531,172595,40249,172217,172724,40592,40597,40606,40610,19764,40618,40623,148324,40641,15200,14821,15645,20274,14270,166955,40706,40712,19350,37924,159138,40727,40726,40761,22175,22154,40773,39352,168075,38898,33919,40802,40809,31452,40846,29206,19390,149877,149947,29047,150008,148296,150097,29598,166874,137466,31135,166270,167478,37737,37875,166468,37612,37761,37835,166252,148665,29207,16107,30578,31299,28880,148595,148472,29054,137199,28835,137406,144793,16071,137349,152623,137208,14114,136955,137273,14049,137076,137425,155467,14115,136896,22363,150053,136190,135848,136134,136374,34051,145062,34051,33877,149908,160101,146993,152924,147195,159826,17652,145134,170397,159526,26617,14131,15381,15847,22636,137506,26640,16471,145215,147681,147595,147727,158753,21707,22174,157361,22162,135135,134056,134669,37830,166675,37788,20216,20779,14361,148534,20156,132197,131967,20299,20362,153169,23144,131499,132043,14745,131850,132116,13365,20265,131776,167603,131701,35546,131596,20120,20685,20749,20386,20227,150030,147082,20290,20526,20588,20609,20428,20453,20568,20732,20825,20827,20829,20830,28278,144789,147001,147135,28018,137348,147081,20904,20931,132576,17629,132259,132242,132241,36218,166556,132878,21081,21156,133235,21217,37742,18042,29068,148364,134176,149932,135396,27089,134685,29817,16094,29849,29716,29782,29592,19342,150204,147597,21456,13700,29199,147657,21940,131909,21709,134086,22301,37469,38644,37734,22493,22413,22399,13886,22731,23193,166470,136954,137071,136976,23084,22968,37519,23166,23247,23058,153926,137715,137313,148117,14069,27909,29763,23073,155267,23169,166871,132115,37856,29836,135939,28933,18802,37896,166395,37821,14240,23582,23710,24158,24136,137622,137596,146158,24269,23375,137475,137476,14081,137376,14045,136958,14035,33066,166471,138682,144498,166312,24332,24334,137511,137131,23147,137019,23364,34324,161277,34912,24702,141408,140843,24539,16056,140719,140734,168072,159603,25024,131134,131142,140827,24985,24984,24693,142491,142599,149204,168269,25713,149093,142186,14889,142114,144464,170218,142968,25399,173147,25782,25393,25553,149987,142695,25252,142497,25659,25963,26994,15348,143502,144045,149897,144043,21773,144096,137433,169023,26318,144009,143795,15072,16784,152964,166690,152975,136956,152923,152613,30958,143619,137258,143924,13412,143887,143746,148169,26254,159012,26219,19347,26160,161904,138731,26211,144082,144097,26142,153714,14545,145466,145340,15257,145314,144382,29904,15254,26511,149034,26806,26654,15300,27326,14435,145365,148615,27187,27218,27337,27397,137490,25873,26776,27212,15319,27258,27479,147392,146586,37792,37618,166890,166603,37513,163870,166364,37991,28069,28427,149996,28007,147327,15759,28164,147516,23101,28170,22599,27940,30786,28987,148250,148086,28913,29264,29319,29332,149391,149285,20857,150180,132587,29818,147192,144991,150090,149783,155617,16134,16049,150239,166947,147253,24743,16115,29900,29756,37767,29751,17567,159210,17745,30083,16227,150745,150790,16216,30037,30323,173510,15129,29800,166604,149931,149902,15099,15821,150094,16127,149957,149747,37370,22322,37698,166627,137316,20703,152097,152039,30584,143922,30478,30479,30587,149143,145281,14942,149744,29752,29851,16063,150202,150215,16584,150166,156078,37639,152961,30750,30861,30856,30930,29648,31065,161601,153315,16654,31131,33942,31141,27181,147194,31290,31220,16750,136934,16690,37429,31217,134476,149900,131737,146874,137070,13719,21867,13680,13994,131540,134157,31458,23129,141045,154287,154268,23053,131675,30960,23082,154566,31486,16889,31837,31853,16913,154547,155324,155302,31949,150009,137136,31886,31868,31918,27314,32220,32263,32211,32590,156257,155996,162632,32151,155266,17002,158581,133398,26582,131150,144847,22468,156690,156664,149858,32733,31527,133164,154345,154947,31500,155150,39398,34373,39523,27164,144447,14818,150007,157101,39455,157088,33920,160039,158929,17642,33079,17410,32966,33033,33090,157620,39107,158274,33378,33381,158289,33875,159143,34320,160283,23174,16767,137280,23339,137377,23268,137432,34464,195004,146831,34861,160802,23042,34926,20293,34951,35007,35046,35173,35149,153219,35156,161669,161668,166901,166873,166812,166393,16045,33955,18165,18127,14322,35389,35356,169032,24397,37419,148100,26068,28969,28868,137285,40301,35999,36073,163292,22938,30659,23024,17262,14036,36394,36519,150537,36656,36682,17140,27736,28603,140065,18587,28537,28299,137178,39913,14005,149807,37051,37015,21873,18694,37307,37892,166475,16482,166652,37927,166941,166971,34021,35371,38297,38311,38295,38294,167220,29765,16066,149759,150082,148458,16103,143909,38543,167655,167526,167525,16076,149997,150136,147438,29714,29803,16124,38721,168112,26695,18973,168083,153567,38749,37736,166281,166950,166703,156606,37562,23313,35689,18748,29689,147995,38811,38769,39224,134950,24001,166853,150194,38943,169178,37622,169431,37349,17600,166736,150119,166756,39132,166469,16128,37418,18725,33812,39227,39245,162566,15869,39323,19311,39338,39516,166757,153800,27279,39457,23294,39471,170225,19344,170312,39356,19389,19351,37757,22642,135938,22562,149944,136424,30788,141087,146872,26821,15741,37976,14631,24912,141185,141675,24839,40015,40019,40059,39989,39952,39807,39887,171565,39839,172533,172286,40225,19630,147716,40472,19632,40204,172468,172269,172275,170287,40357,33981,159250,159711,158594,34300,17715,159140,159364,159216,33824,34286,159232,145367,155748,31202,144796,144960,18733,149982,15714,37851,37566,37704,131775,30905,37495,37965,20452,13376,36964,152925,30781,30804,30902,30795,137047,143817,149825,13978,20338,28634,28633,28702,28702,21524,147893,22459,22771,22410,40214,22487,28980,13487,147884,29163,158784,151447,23336,137141,166473,24844,23246,23051,17084,148616,14124,19323,166396,37819,37816,137430,134941,33906,158912,136211,148218,142374,148417,22932,146871,157505,32168,155995,155812,149945,149899,166394,37605,29666,16105,29876,166755,137375,16097,150195,27352,29683,29691,16086,150078,150164,137177,150118,132007,136228,149989,29768,149782,28837,149878,37508,29670,37727,132350,37681,166606,166422,37766,166887,153045,18741,166530,29035,149827,134399,22180,132634,134123,134328,21762,31172,137210,32254,136898,150096,137298,17710,37889,14090,166592,149933,22960,137407,137347,160900,23201,14050,146779,14000,37471,23161,166529,137314,37748,15565,133812,19094,14730,20724,15721,15692,136092,29045,17147,164376,28175,168164,17643,27991,163407,28775,27823,15574,147437,146989,28162,28428,15727,132085,30033,14012,13512,18048,16090,18545,22980,37486,18750,36673,166940,158656,22546,22472,14038,136274,28926,148322,150129,143331,135856,140221,26809,26983,136088,144613,162804,145119,166531,145366,144378,150687,27162,145069,158903,33854,17631,17614,159014,159057,158850,159710,28439,160009,33597,137018,33773,158848,159827,137179,22921,23170,137139,23137,23153,137477,147964,14125,23023,137020,14023,29070,37776,26266,148133,23150,23083,148115,27179,147193,161590,148571,148170,28957,148057,166369,20400,159016,23746,148686,163405,148413,27148,148054,135940,28838,28979,148457,15781,27871,194597,150095,32357,23019,23855,15859,24412,150109,137183,32164,33830,21637,146170,144128,131604,22398,133333,132633,16357,139166,172726,28675,168283,23920,29583,31955,166489,168992,20424,32743,29389,29456,162548,29496,29497,153334,29505,29512,16041,162584,36972,29173,149746,29665,33270,16074,30476,16081,27810,22269,29721,29726,29727,16098,16112,16116,16122,29907,16142,16211,30018,30061,30066,30093,16252,30152,30172,16320,30285,16343,30324,16348,30330,151388,29064,22051,35200,22633,16413,30531,16441,26465,16453,13787,30616,16490,16495,23646,30654,30667,22770,30744,28857,30748,16552,30777,30791,30801,30822,33864,152885,31027,26627,31026,16643,16649,31121,31129,36795,31238,36796,16743,31377,16818,31420,33401,16836,31439,31451,16847,20001,31586,31596,31611,31762,31771,16992,17018,31867,31900,17036,31928,17044,31981,36755,28864,134351,32207,32212,32208,32253,32686,32692,29343,17303,32800,32805,31545,32814,32817,32852,15820,22452,28832,32951,33001,17389,33036,29482,33038,33042,30048,33044,17409,15161,33110,33113,33114,17427,22586,33148,33156,17445,33171,17453,33189,22511,33217,33252,33364,17551,33446,33398,33482,33496,33535,17584,33623,38505,27018,33797,28917,33892,24803,33928,17668,33982,34017,34040,34064,34104,34130,17723,34159,34160,34272,17783,34418,34450,34482,34543,38469,34699,17926,17943,34990,35071,35108,35143,35217,162151,35369,35384,35476,35508,35921,36052,36082,36124,18328,22623,36291,18413,20206,36410,21976,22356,36465,22005,36528,18487,36558,36578,36580,36589,36594,36791,36801,36810,36812,36915,39364,18605,39136,37395,18718,37416,37464,37483,37553,37550,37567,37603,37611,37619,37620,37629,37699,37764,37805,18757,18769,40639,37911,21249,37917,37933,37950,18794,37972,38009,38189,38306,18855,38388,38451,18917,26528,18980,38720,18997,38834,38850,22100,19172,24808,39097,19225,39153,22596,39182,39193,20916,39196,39223,39234,39261,39266,19312,39365,19357,39484,39695,31363,39785,39809,39901,39921,39924,19565,39968,14191,138178,40265,39994,40702,22096,40339,40381,40384,40444,38134,36790,40571,40620,40625,40637,40646,38108,40674,40689,40696,31432,40772,131220,131767,132000,26906,38083,22956,132311,22592,38081,14265,132565,132629,132726,136890,22359,29043,133826,133837,134079,21610,194619,134091,21662,134139,134203,134227,134245,134268,24807,134285,22138,134325,134365,134381,134511,134578,134600,26965,39983,34725,134660,134670,134871,135056,134957,134771,23584,135100,24075,135260,135247,135286,26398,135291,135304,135318,13895,135359,135379,135471,135483,21348,33965,135907,136053,135990,35713,136567,136729,137155,137159,20088,28859,137261,137578,137773,137797,138282,138352,138412,138952,25283,138965,139029,29080,26709,139333,27113,14024,139900,140247,140282,141098,141425,141647,33533,141671,141715,142037,35237,142056,36768,142094,38840,142143,38983,39613,142412,null,142472,142519,154600,142600,142610,142775,142741,142914,143220,143308,143411,143462,144159,144350,24497,26184,26303,162425,144743,144883,29185,149946,30679,144922,145174,32391,131910,22709,26382,26904,146087,161367,155618,146961,147129,161278,139418,18640,19128,147737,166554,148206,148237,147515,148276,148374,150085,132554,20946,132625,22943,138920,15294,146687,148484,148694,22408,149108,14747,149295,165352,170441,14178,139715,35678,166734,39382,149522,149755,150037,29193,150208,134264,22885,151205,151430,132985,36570,151596,21135,22335,29041,152217,152601,147274,150183,21948,152646,152686,158546,37332,13427,152895,161330,152926,18200,152930,152934,153543,149823,153693,20582,13563,144332,24798,153859,18300,166216,154286,154505,154630,138640,22433,29009,28598,155906,162834,36950,156082,151450,35682,156674,156746,23899,158711,36662,156804,137500,35562,150006,156808,147439,156946,19392,157119,157365,141083,37989,153569,24981,23079,194765,20411,22201,148769,157436,20074,149812,38486,28047,158909,13848,35191,157593,157806,156689,157790,29151,157895,31554,168128,133649,157990,37124,158009,31301,40432,158202,39462,158253,13919,156777,131105,31107,158260,158555,23852,144665,33743,158621,18128,158884,30011,34917,159150,22710,14108,140685,159819,160205,15444,160384,160389,37505,139642,160395,37680,160486,149968,27705,38047,160848,134904,34855,35061,141606,164979,137137,28344,150058,137248,14756,14009,23568,31203,17727,26294,171181,170148,35139,161740,161880,22230,16607,136714,14753,145199,164072,136133,29101,33638,162269,168360,23143,19639,159919,166315,162301,162314,162571,163174,147834,31555,31102,163849,28597,172767,27139,164632,21410,159239,37823,26678,38749,164207,163875,158133,136173,143919,163912,23941,166960,163971,22293,38947,166217,23979,149896,26046,27093,21458,150181,147329,15377,26422,163984,164084,164142,139169,164175,164233,164271,164378,164614,164655,164746,13770,164968,165546,18682,25574,166230,30728,37461,166328,17394,166375,17375,166376,166726,166868,23032,166921,36619,167877,168172,31569,168208,168252,15863,168286,150218,36816,29327,22155,169191,169449,169392,169400,169778,170193,170313,170346,170435,170536,170766,171354,171419,32415,171768,171811,19620,38215,172691,29090,172799,19857,36882,173515,19868,134300,36798,21953,36794,140464,36793,150163,17673,32383,28502,27313,20202,13540,166700,161949,14138,36480,137205,163876,166764,166809,162366,157359,15851,161365,146615,153141,153942,20122,155265,156248,22207,134765,36366,23405,147080,150686,25566,25296,137206,137339,25904,22061,154698,21530,152337,15814,171416,19581,22050,22046,32585,155352,22901,146752,34672,19996,135146,134473,145082,33047,40286,36120,30267,40005,30286,30649,37701,21554,33096,33527,22053,33074,33816,32957,21994,31074,22083,21526,134813,13774,22021,22001,26353,164578,13869,30004,22000,21946,21655,21874,134209,134294,24272,151880,134774,142434,134818,40619,32090,21982,135285,25245,38765,21652,36045,29174,37238,25596,25529,25598,21865,142147,40050,143027,20890,13535,134567,20903,21581,21790,21779,30310,36397,157834,30129,32950,34820,34694,35015,33206,33820,135361,17644,29444,149254,23440,33547,157843,22139,141044,163119,147875,163187,159440,160438,37232,135641,37384,146684,173737,134828,134905,29286,138402,18254,151490,163833,135147,16634,40029,25887,142752,18675,149472,171388,135148,134666,24674,161187,135149,null,155720,135559,29091,32398,40272,19994,19972,13687,23309,27826,21351,13996,14812,21373,13989,149016,22682,150382,33325,21579,22442,154261,133497,null,14930,140389,29556,171692,19721,39917,146686,171824,19547,151465,169374,171998,33884,146870,160434,157619,145184,25390,32037,147191,146988,14890,36872,21196,15988,13946,17897,132238,30272,23280,134838,30842,163630,22695,16575,22140,39819,23924,30292,173108,40581,19681,30201,14331,24857,143578,148466,null,22109,135849,22439,149859,171526,21044,159918,13741,27722,40316,31830,39737,22494,137068,23635,25811,169168,156469,160100,34477,134440,159010,150242,134513,null,20990,139023,23950,38659,138705,40577,36940,31519,39682,23761,31651,25192,25397,39679,31695,39722,31870,39726,31810,31878,39957,31740,39689,40727,39963,149822,40794,21875,23491,20477,40600,20466,21088,15878,21201,22375,20566,22967,24082,38856,40363,36700,21609,38836,39232,38842,21292,24880,26924,21466,39946,40194,19515,38465,27008,20646,30022,137069,39386,21107,null,37209,38529,37212,null,37201,167575,25471,159011,27338,22033,37262,30074,25221,132092,29519,31856,154657,146685,null,149785,30422,39837,20010,134356,33726,34882,null,23626,27072,20717,22394,21023,24053,20174,27697,131570,20281,21660,21722,21146,36226,13822,24332,13811,null,27474,37244,40869,39831,38958,39092,39610,40616,40580,29050,31508,null,27642,34840,32632,null,22048,173642,36471,40787,null,36308,36431,40476,36353,25218,164733,36392,36469,31443,150135,31294,30936,27882,35431,30215,166490,40742,27854,34774,30147,172722,30803,194624,36108,29410,29553,35629,29442,29937,36075,150203,34351,24506,34976,17591,null,137275,159237,null,35454,140571,null,24829,30311,39639,40260,37742,39823,34805,null,34831,36087,29484,38689,39856,13782,29362,19463,31825,39242,155993,24921,19460,40598,24957,null,22367,24943,25254,25145,25294,14940,25058,21418,144373,25444,26626,13778,23895,166850,36826,167481,null,20697,138566,30982,21298,38456,134971,16485,null,30718,null,31938,155418,31962,31277,32870,32867,32077,29957,29938,35220,33306,26380,32866,160902,32859,29936,33027,30500,35209,157644,30035,159441,34729,34766,33224,34700,35401,36013,35651,30507,29944,34010,13877,27058,36262,null,35241,29800,28089,34753,147473,29927,15835,29046,24740,24988,15569,29026,24695,null,32625,166701,29264,24809,19326,21024,15384,146631,155351,161366,152881,137540,135934,170243,159196,159917,23745,156077,166415,145015,131310,157766,151310,17762,23327,156492,40784,40614,156267,12288,65292,12289,12290,65294,8231,65307,65306,65311,65281,65072,8230,8229,65104,65105,65106,183,65108,65109,65110,65111,65372,8211,65073,8212,65075,9588,65076,65103,65288,65289,65077,65078,65371,65373,65079,65080,12308,12309,65081,65082,12304,12305,65083,65084,12298,12299,65085,65086,12296,12297,65087,65088,12300,12301,65089,65090,12302,12303,65091,65092,65113,65114,65115,65116,65117,65118,8216,8217,8220,8221,12317,12318,8245,8242,65283,65286,65290,8251,167,12291,9675,9679,9651,9650,9678,9734,9733,9671,9670,9633,9632,9661,9660,12963,8453,175,65507,65343,717,65097,65098,65101,65102,65099,65100,65119,65120,65121,65291,65293,215,247,177,8730,65308,65310,65309,8806,8807,8800,8734,8786,8801,65122,65123,65124,65125,65126,65374,8745,8746,8869,8736,8735,8895,13266,13265,8747,8750,8757,8756,9792,9794,8853,8857,8593,8595,8592,8594,8598,8599,8601,8600,8741,8739,65295,65340,8725,65128,65284,65509,12306,65504,65505,65285,65312,8451,8457,65129,65130,65131,13269,13212,13213,13214,13262,13217,13198,13199,13252,176,20825,20827,20830,20829,20833,20835,21991,29929,31950,9601,9602,9603,9604,9605,9606,9607,9608,9615,9614,9613,9612,9611,9610,9609,9532,9524,9516,9508,9500,9620,9472,9474,9621,9484,9488,9492,9496,9581,9582,9584,9583,9552,9566,9578,9569,9698,9699,9701,9700,9585,9586,9587,65296,65297,65298,65299,65300,65301,65302,65303,65304,65305,8544,8545,8546,8547,8548,8549,8550,8551,8552,8553,12321,12322,12323,12324,12325,12326,12327,12328,12329,21313,21316,21317,65313,65314,65315,65316,65317,65318,65319,65320,65321,65322,65323,65324,65325,65326,65327,65328,65329,65330,65331,65332,65333,65334,65335,65336,65337,65338,65345,65346,65347,65348,65349,65350,65351,65352,65353,65354,65355,65356,65357,65358,65359,65360,65361,65362,65363,65364,65365,65366,65367,65368,65369,65370,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,931,932,933,934,935,936,937,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960,961,963,964,965,966,967,968,969,12549,12550,12551,12552,12553,12554,12555,12556,12557,12558,12559,12560,12561,12562,12563,12564,12565,12566,12567,12568,12569,12570,12571,12572,12573,12574,12575,12576,12577,12578,12579,12580,12581,12582,12583,12584,12585,729,713,714,711,715,9216,9217,9218,9219,9220,9221,9222,9223,9224,9225,9226,9227,9228,9229,9230,9231,9232,9233,9234,9235,9236,9237,9238,9239,9240,9241,9242,9243,9244,9245,9246,9247,9249,8364,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,19968,20057,19969,19971,20035,20061,20102,20108,20154,20799,20837,20843,20960,20992,20993,21147,21269,21313,21340,21448,19977,19979,19976,19978,20011,20024,20961,20037,20040,20063,20062,20110,20129,20800,20995,21242,21315,21449,21475,22303,22763,22805,22823,22899,23376,23377,23379,23544,23567,23586,23608,23665,24029,24037,24049,24050,24051,24062,24178,24318,24331,24339,25165,19985,19984,19981,20013,20016,20025,20043,23609,20104,20113,20117,20114,20116,20130,20161,20160,20163,20166,20167,20173,20170,20171,20164,20803,20801,20839,20845,20846,20844,20887,20982,20998,20999,21000,21243,21246,21247,21270,21305,21320,21319,21317,21342,21380,21451,21450,21453,22764,22825,22827,22826,22829,23380,23569,23588,23610,23663,24052,24187,24319,24340,24341,24515,25096,25142,25163,25166,25903,25991,26007,26020,26041,26085,26352,26376,26408,27424,27490,27513,27595,27604,27611,27663,27700,28779,29226,29238,29243,29255,29273,29275,29356,29579,19993,19990,19989,19988,19992,20027,20045,20047,20046,20197,20184,20180,20181,20182,20183,20195,20196,20185,20190,20805,20804,20873,20874,20908,20985,20986,20984,21002,21152,21151,21253,21254,21271,21277,20191,21322,21321,21345,21344,21359,21358,21435,21487,21476,21491,21484,21486,21481,21480,21500,21496,21493,21483,21478,21482,21490,21489,21488,21477,21485,21499,22235,22234,22806,22830,22833,22900,22902,23381,23427,23612,24040,24039,24038,24066,24067,24179,24188,24321,24344,24343,24517,25098,25171,25172,25170,25169,26021,26086,26414,26412,26410,26411,26413,27491,27597,27665,27664,27704,27713,27712,27710,29359,29572,29577,29916,29926,29976,29983,29992,29993,30000,30001,30002,30003,30091,30333,30382,30399,30446,30683,30690,30707,31034,31166,31348,31435,19998,19999,20050,20051,20073,20121,20132,20134,20133,20223,20233,20249,20234,20245,20237,20240,20241,20239,20210,20214,20219,20208,20211,20221,20225,20235,20809,20807,20806,20808,20840,20849,20877,20912,21015,21009,21010,21006,21014,21155,21256,21281,21280,21360,21361,21513,21519,21516,21514,21520,21505,21515,21508,21521,21517,21512,21507,21518,21510,21522,22240,22238,22237,22323,22320,22312,22317,22316,22319,22313,22809,22810,22839,22840,22916,22904,22915,22909,22905,22914,22913,23383,23384,23431,23432,23429,23433,23546,23574,23673,24030,24070,24182,24180,24335,24347,24537,24534,25102,25100,25101,25104,25187,25179,25176,25910,26089,26088,26092,26093,26354,26355,26377,26429,26420,26417,26421,27425,27492,27515,27670,27741,27735,27737,27743,27744,27728,27733,27745,27739,27725,27726,28784,29279,29277,30334,31481,31859,31992,32566,32650,32701,32769,32771,32780,32786,32819,32895,32905,32907,32908,33251,33258,33267,33276,33292,33307,33311,33390,33394,33406,34411,34880,34892,34915,35199,38433,20018,20136,20301,20303,20295,20311,20318,20276,20315,20309,20272,20304,20305,20285,20282,20280,20291,20308,20284,20294,20323,20316,20320,20271,20302,20278,20313,20317,20296,20314,20812,20811,20813,20853,20918,20919,21029,21028,21033,21034,21032,21163,21161,21162,21164,21283,21363,21365,21533,21549,21534,21566,21542,21582,21543,21574,21571,21555,21576,21570,21531,21545,21578,21561,21563,21560,21550,21557,21558,21536,21564,21568,21553,21547,21535,21548,22250,22256,22244,22251,22346,22353,22336,22349,22343,22350,22334,22352,22351,22331,22767,22846,22941,22930,22952,22942,22947,22937,22934,22925,22948,22931,22922,22949,23389,23388,23386,23387,23436,23435,23439,23596,23616,23617,23615,23614,23696,23697,23700,23692,24043,24076,24207,24199,24202,24311,24324,24351,24420,24418,24439,24441,24536,24524,24535,24525,24561,24555,24568,24554,25106,25105,25220,25239,25238,25216,25206,25225,25197,25226,25212,25214,25209,25203,25234,25199,25240,25198,25237,25235,25233,25222,25913,25915,25912,26097,26356,26463,26446,26447,26448,26449,26460,26454,26462,26441,26438,26464,26451,26455,27493,27599,27714,27742,27801,27777,27784,27785,27781,27803,27754,27770,27792,27760,27788,27752,27798,27794,27773,27779,27762,27774,27764,27782,27766,27789,27796,27800,27778,28790,28796,28797,28792,29282,29281,29280,29380,29378,29590,29996,29995,30007,30008,30338,30447,30691,31169,31168,31167,31350,31995,32597,32918,32915,32925,32920,32923,32922,32946,33391,33426,33419,33421,35211,35282,35328,35895,35910,35925,35997,36196,36208,36275,36523,36554,36763,36784,36802,36806,36805,36804,24033,37009,37026,37034,37030,37027,37193,37318,37324,38450,38446,38449,38442,38444,20006,20054,20083,20107,20123,20126,20139,20140,20335,20381,20365,20339,20351,20332,20379,20363,20358,20355,20336,20341,20360,20329,20347,20374,20350,20367,20369,20346,20820,20818,20821,20841,20855,20854,20856,20925,20989,21051,21048,21047,21050,21040,21038,21046,21057,21182,21179,21330,21332,21331,21329,21350,21367,21368,21369,21462,21460,21463,21619,21621,21654,21624,21653,21632,21627,21623,21636,21650,21638,21628,21648,21617,21622,21644,21658,21602,21608,21643,21629,21646,22266,22403,22391,22378,22377,22369,22374,22372,22396,22812,22857,22855,22856,22852,22868,22974,22971,22996,22969,22958,22993,22982,22992,22989,22987,22995,22986,22959,22963,22994,22981,23391,23396,23395,23447,23450,23448,23452,23449,23451,23578,23624,23621,23622,23735,23713,23736,23721,23723,23729,23731,24088,24090,24086,24085,24091,24081,24184,24218,24215,24220,24213,24214,24310,24358,24359,24361,24448,24449,24447,24444,24541,24544,24573,24565,24575,24591,24596,24623,24629,24598,24618,24597,24609,24615,24617,24619,24603,25110,25109,25151,25150,25152,25215,25289,25292,25284,25279,25282,25273,25298,25307,25259,25299,25300,25291,25288,25256,25277,25276,25296,25305,25287,25293,25269,25306,25265,25304,25302,25303,25286,25260,25294,25918,26023,26044,26106,26132,26131,26124,26118,26114,26126,26112,26127,26133,26122,26119,26381,26379,26477,26507,26517,26481,26524,26483,26487,26503,26525,26519,26479,26480,26495,26505,26494,26512,26485,26522,26515,26492,26474,26482,27427,27494,27495,27519,27667,27675,27875,27880,27891,27825,27852,27877,27827,27837,27838,27836,27874,27819,27861,27859,27832,27844,27833,27841,27822,27863,27845,27889,27839,27835,27873,27867,27850,27820,27887,27868,27862,27872,28821,28814,28818,28810,28825,29228,29229,29240,29256,29287,29289,29376,29390,29401,29399,29392,29609,29608,29599,29611,29605,30013,30109,30105,30106,30340,30402,30450,30452,30693,30717,31038,31040,31041,31177,31176,31354,31353,31482,31998,32596,32652,32651,32773,32954,32933,32930,32945,32929,32939,32937,32948,32938,32943,33253,33278,33293,33459,33437,33433,33453,33469,33439,33465,33457,33452,33445,33455,33464,33443,33456,33470,33463,34382,34417,21021,34920,36555,36814,36820,36817,37045,37048,37041,37046,37319,37329,38263,38272,38428,38464,38463,38459,38468,38466,38585,38632,38738,38750,20127,20141,20142,20449,20405,20399,20415,20448,20433,20431,20445,20419,20406,20440,20447,20426,20439,20398,20432,20420,20418,20442,20430,20446,20407,20823,20882,20881,20896,21070,21059,21066,21069,21068,21067,21063,21191,21193,21187,21185,21261,21335,21371,21402,21467,21676,21696,21672,21710,21705,21688,21670,21683,21703,21698,21693,21674,21697,21700,21704,21679,21675,21681,21691,21673,21671,21695,22271,22402,22411,22432,22435,22434,22478,22446,22419,22869,22865,22863,22862,22864,23004,23000,23039,23011,23016,23043,23013,23018,23002,23014,23041,23035,23401,23459,23462,23460,23458,23461,23553,23630,23631,23629,23627,23769,23762,24055,24093,24101,24095,24189,24224,24230,24314,24328,24365,24421,24456,24453,24458,24459,24455,24460,24457,24594,24605,24608,24613,24590,24616,24653,24688,24680,24674,24646,24643,24684,24683,24682,24676,25153,25308,25366,25353,25340,25325,25345,25326,25341,25351,25329,25335,25327,25324,25342,25332,25361,25346,25919,25925,26027,26045,26082,26149,26157,26144,26151,26159,26143,26152,26161,26148,26359,26623,26579,26609,26580,26576,26604,26550,26543,26613,26601,26607,26564,26577,26548,26586,26597,26552,26575,26590,26611,26544,26585,26594,26589,26578,27498,27523,27526,27573,27602,27607,27679,27849,27915,27954,27946,27969,27941,27916,27953,27934,27927,27963,27965,27966,27958,27931,27893,27961,27943,27960,27945,27950,27957,27918,27947,28843,28858,28851,28844,28847,28845,28856,28846,28836,29232,29298,29295,29300,29417,29408,29409,29623,29642,29627,29618,29645,29632,29619,29978,29997,30031,30028,30030,30027,30123,30116,30117,30114,30115,30328,30342,30343,30344,30408,30406,30403,30405,30465,30457,30456,30473,30475,30462,30460,30471,30684,30722,30740,30732,30733,31046,31049,31048,31047,31161,31162,31185,31186,31179,31359,31361,31487,31485,31869,32002,32005,32000,32009,32007,32004,32006,32568,32654,32703,32772,32784,32781,32785,32822,32982,32997,32986,32963,32964,32972,32993,32987,32974,32990,32996,32989,33268,33314,33511,33539,33541,33507,33499,33510,33540,33509,33538,33545,33490,33495,33521,33537,33500,33492,33489,33502,33491,33503,33519,33542,34384,34425,34427,34426,34893,34923,35201,35284,35336,35330,35331,35998,36000,36212,36211,36276,36557,36556,36848,36838,36834,36842,36837,36845,36843,36836,36840,37066,37070,37057,37059,37195,37194,37325,38274,38480,38475,38476,38477,38754,38761,38859,38893,38899,38913,39080,39131,39135,39318,39321,20056,20147,20492,20493,20515,20463,20518,20517,20472,20521,20502,20486,20540,20511,20506,20498,20497,20474,20480,20500,20520,20465,20513,20491,20505,20504,20467,20462,20525,20522,20478,20523,20489,20860,20900,20901,20898,20941,20940,20934,20939,21078,21084,21076,21083,21085,21290,21375,21407,21405,21471,21736,21776,21761,21815,21756,21733,21746,21766,21754,21780,21737,21741,21729,21769,21742,21738,21734,21799,21767,21757,21775,22275,22276,22466,22484,22475,22467,22537,22799,22871,22872,22874,23057,23064,23068,23071,23067,23059,23020,23072,23075,23081,23077,23052,23049,23403,23640,23472,23475,23478,23476,23470,23477,23481,23480,23556,23633,23637,23632,23789,23805,23803,23786,23784,23792,23798,23809,23796,24046,24109,24107,24235,24237,24231,24369,24466,24465,24464,24665,24675,24677,24656,24661,24685,24681,24687,24708,24735,24730,24717,24724,24716,24709,24726,25159,25331,25352,25343,25422,25406,25391,25429,25410,25414,25423,25417,25402,25424,25405,25386,25387,25384,25421,25420,25928,25929,26009,26049,26053,26178,26185,26191,26179,26194,26188,26181,26177,26360,26388,26389,26391,26657,26680,26696,26694,26707,26681,26690,26708,26665,26803,26647,26700,26705,26685,26612,26704,26688,26684,26691,26666,26693,26643,26648,26689,27530,27529,27575,27683,27687,27688,27686,27684,27888,28010,28053,28040,28039,28006,28024,28023,27993,28051,28012,28041,28014,27994,28020,28009,28044,28042,28025,28037,28005,28052,28874,28888,28900,28889,28872,28879,29241,29305,29436,29433,29437,29432,29431,29574,29677,29705,29678,29664,29674,29662,30036,30045,30044,30042,30041,30142,30149,30151,30130,30131,30141,30140,30137,30146,30136,30347,30384,30410,30413,30414,30505,30495,30496,30504,30697,30768,30759,30776,30749,30772,30775,30757,30765,30752,30751,30770,31061,31056,31072,31071,31062,31070,31069,31063,31066,31204,31203,31207,31199,31206,31209,31192,31364,31368,31449,31494,31505,31881,32033,32023,32011,32010,32032,32034,32020,32016,32021,32026,32028,32013,32025,32027,32570,32607,32660,32709,32705,32774,32792,32789,32793,32791,32829,32831,33009,33026,33008,33029,33005,33012,33030,33016,33011,33032,33021,33034,33020,33007,33261,33260,33280,33296,33322,33323,33320,33324,33467,33579,33618,33620,33610,33592,33616,33609,33589,33588,33615,33586,33593,33590,33559,33600,33585,33576,33603,34388,34442,34474,34451,34468,34473,34444,34467,34460,34928,34935,34945,34946,34941,34937,35352,35344,35342,35340,35349,35338,35351,35347,35350,35343,35345,35912,35962,35961,36001,36002,36215,36524,36562,36564,36559,36785,36865,36870,36855,36864,36858,36852,36867,36861,36869,36856,37013,37089,37085,37090,37202,37197,37196,37336,37341,37335,37340,37337,38275,38498,38499,38497,38491,38493,38500,38488,38494,38587,39138,39340,39592,39640,39717,39730,39740,20094,20602,20605,20572,20551,20547,20556,20570,20553,20581,20598,20558,20565,20597,20596,20599,20559,20495,20591,20589,20828,20885,20976,21098,21103,21202,21209,21208,21205,21264,21263,21273,21311,21312,21310,21443,26364,21830,21866,21862,21828,21854,21857,21827,21834,21809,21846,21839,21845,21807,21860,21816,21806,21852,21804,21859,21811,21825,21847,22280,22283,22281,22495,22533,22538,22534,22496,22500,22522,22530,22581,22519,22521,22816,22882,23094,23105,23113,23142,23146,23104,23100,23138,23130,23110,23114,23408,23495,23493,23492,23490,23487,23494,23561,23560,23559,23648,23644,23645,23815,23814,23822,23835,23830,23842,23825,23849,23828,23833,23844,23847,23831,24034,24120,24118,24115,24119,24247,24248,24246,24245,24254,24373,24375,24407,24428,24425,24427,24471,24473,24478,24472,24481,24480,24476,24703,24739,24713,24736,24744,24779,24756,24806,24765,24773,24763,24757,24796,24764,24792,24789,24774,24799,24760,24794,24775,25114,25115,25160,25504,25511,25458,25494,25506,25509,25463,25447,25496,25514,25457,25513,25481,25475,25499,25451,25512,25476,25480,25497,25505,25516,25490,25487,25472,25467,25449,25448,25466,25949,25942,25937,25945,25943,21855,25935,25944,25941,25940,26012,26011,26028,26063,26059,26060,26062,26205,26202,26212,26216,26214,26206,26361,21207,26395,26753,26799,26786,26771,26805,26751,26742,26801,26791,26775,26800,26755,26820,26797,26758,26757,26772,26781,26792,26783,26785,26754,27442,27578,27627,27628,27691,28046,28092,28147,28121,28082,28129,28108,28132,28155,28154,28165,28103,28107,28079,28113,28078,28126,28153,28088,28151,28149,28101,28114,28186,28085,28122,28139,28120,28138,28145,28142,28136,28102,28100,28074,28140,28095,28134,28921,28937,28938,28925,28911,29245,29309,29313,29468,29467,29462,29459,29465,29575,29701,29706,29699,29702,29694,29709,29920,29942,29943,29980,29986,30053,30054,30050,30064,30095,30164,30165,30133,30154,30157,30350,30420,30418,30427,30519,30526,30524,30518,30520,30522,30827,30787,30798,31077,31080,31085,31227,31378,31381,31520,31528,31515,31532,31526,31513,31518,31534,31890,31895,31893,32070,32067,32113,32046,32057,32060,32064,32048,32051,32068,32047,32066,32050,32049,32573,32670,32666,32716,32718,32722,32796,32842,32838,33071,33046,33059,33067,33065,33072,33060,33282,33333,33335,33334,33337,33678,33694,33688,33656,33698,33686,33725,33707,33682,33674,33683,33673,33696,33655,33659,33660,33670,33703,34389,24426,34503,34496,34486,34500,34485,34502,34507,34481,34479,34505,34899,34974,34952,34987,34962,34966,34957,34955,35219,35215,35370,35357,35363,35365,35377,35373,35359,35355,35362,35913,35930,36009,36012,36011,36008,36010,36007,36199,36198,36286,36282,36571,36575,36889,36877,36890,36887,36899,36895,36893,36880,36885,36894,36896,36879,36898,36886,36891,36884,37096,37101,37117,37207,37326,37365,37350,37347,37351,37357,37353,38281,38506,38517,38515,38520,38512,38516,38518,38519,38508,38592,38634,38633,31456,31455,38914,38915,39770,40165,40565,40575,40613,40635,20642,20621,20613,20633,20625,20608,20630,20632,20634,26368,20977,21106,21108,21109,21097,21214,21213,21211,21338,21413,21883,21888,21927,21884,21898,21917,21912,21890,21916,21930,21908,21895,21899,21891,21939,21934,21919,21822,21938,21914,21947,21932,21937,21886,21897,21931,21913,22285,22575,22570,22580,22564,22576,22577,22561,22557,22560,22777,22778,22880,23159,23194,23167,23186,23195,23207,23411,23409,23506,23500,23507,23504,23562,23563,23601,23884,23888,23860,23879,24061,24133,24125,24128,24131,24190,24266,24257,24258,24260,24380,24429,24489,24490,24488,24785,24801,24754,24758,24800,24860,24867,24826,24853,24816,24827,24820,24936,24817,24846,24822,24841,24832,24850,25119,25161,25507,25484,25551,25536,25577,25545,25542,25549,25554,25571,25552,25569,25558,25581,25582,25462,25588,25578,25563,25682,25562,25593,25950,25958,25954,25955,26001,26000,26031,26222,26224,26228,26230,26223,26257,26234,26238,26231,26366,26367,26399,26397,26874,26837,26848,26840,26839,26885,26847,26869,26862,26855,26873,26834,26866,26851,26827,26829,26893,26898,26894,26825,26842,26990,26875,27454,27450,27453,27544,27542,27580,27631,27694,27695,27692,28207,28216,28244,28193,28210,28263,28234,28192,28197,28195,28187,28251,28248,28196,28246,28270,28205,28198,28271,28212,28237,28218,28204,28227,28189,28222,28363,28297,28185,28238,28259,28228,28274,28265,28255,28953,28954,28966,28976,28961,28982,29038,28956,29260,29316,29312,29494,29477,29492,29481,29754,29738,29747,29730,29733,29749,29750,29748,29743,29723,29734,29736,29989,29990,30059,30058,30178,30171,30179,30169,30168,30174,30176,30331,30332,30358,30355,30388,30428,30543,30701,30813,30828,30831,31245,31240,31243,31237,31232,31384,31383,31382,31461,31459,31561,31574,31558,31568,31570,31572,31565,31563,31567,31569,31903,31909,32094,32080,32104,32085,32043,32110,32114,32097,32102,32098,32112,32115,21892,32724,32725,32779,32850,32901,33109,33108,33099,33105,33102,33081,33094,33086,33100,33107,33140,33298,33308,33769,33795,33784,33805,33760,33733,33803,33729,33775,33777,33780,33879,33802,33776,33804,33740,33789,33778,33738,33848,33806,33796,33756,33799,33748,33759,34395,34527,34521,34541,34516,34523,34532,34512,34526,34903,35009,35010,34993,35203,35222,35387,35424,35413,35422,35388,35393,35412,35419,35408,35398,35380,35386,35382,35414,35937,35970,36015,36028,36019,36029,36033,36027,36032,36020,36023,36022,36031,36024,36234,36229,36225,36302,36317,36299,36314,36305,36300,36315,36294,36603,36600,36604,36764,36910,36917,36913,36920,36914,36918,37122,37109,37129,37118,37219,37221,37327,37396,37397,37411,37385,37406,37389,37392,37383,37393,38292,38287,38283,38289,38291,38290,38286,38538,38542,38539,38525,38533,38534,38541,38514,38532,38593,38597,38596,38598,38599,38639,38642,38860,38917,38918,38920,39143,39146,39151,39145,39154,39149,39342,39341,40643,40653,40657,20098,20653,20661,20658,20659,20677,20670,20652,20663,20667,20655,20679,21119,21111,21117,21215,21222,21220,21218,21219,21295,21983,21992,21971,21990,21966,21980,21959,21969,21987,21988,21999,21978,21985,21957,21958,21989,21961,22290,22291,22622,22609,22616,22615,22618,22612,22635,22604,22637,22602,22626,22610,22603,22887,23233,23241,23244,23230,23229,23228,23219,23234,23218,23913,23919,24140,24185,24265,24264,24338,24409,24492,24494,24858,24847,24904,24863,24819,24859,24825,24833,24840,24910,24908,24900,24909,24894,24884,24871,24845,24838,24887,25121,25122,25619,25662,25630,25642,25645,25661,25644,25615,25628,25620,25613,25654,25622,25623,25606,25964,26015,26032,26263,26249,26247,26248,26262,26244,26264,26253,26371,27028,26989,26970,26999,26976,26964,26997,26928,27010,26954,26984,26987,26974,26963,27001,27014,26973,26979,26971,27463,27506,27584,27583,27603,27645,28322,28335,28371,28342,28354,28304,28317,28359,28357,28325,28312,28348,28346,28331,28369,28310,28316,28356,28372,28330,28327,28340,29006,29017,29033,29028,29001,29031,29020,29036,29030,29004,29029,29022,28998,29032,29014,29242,29266,29495,29509,29503,29502,29807,29786,29781,29791,29790,29761,29759,29785,29787,29788,30070,30072,30208,30192,30209,30194,30193,30202,30207,30196,30195,30430,30431,30555,30571,30566,30558,30563,30585,30570,30572,30556,30565,30568,30562,30702,30862,30896,30871,30872,30860,30857,30844,30865,30867,30847,31098,31103,31105,33836,31165,31260,31258,31264,31252,31263,31262,31391,31392,31607,31680,31584,31598,31591,31921,31923,31925,32147,32121,32145,32129,32143,32091,32622,32617,32618,32626,32681,32680,32676,32854,32856,32902,32900,33137,33136,33144,33125,33134,33139,33131,33145,33146,33126,33285,33351,33922,33911,33853,33841,33909,33894,33899,33865,33900,33883,33852,33845,33889,33891,33897,33901,33862,34398,34396,34399,34553,34579,34568,34567,34560,34558,34555,34562,34563,34566,34570,34905,35039,35028,35033,35036,35032,35037,35041,35018,35029,35026,35228,35299,35435,35442,35443,35430,35433,35440,35463,35452,35427,35488,35441,35461,35437,35426,35438,35436,35449,35451,35390,35432,35938,35978,35977,36042,36039,36040,36036,36018,36035,36034,36037,36321,36319,36328,36335,36339,36346,36330,36324,36326,36530,36611,36617,36606,36618,36767,36786,36939,36938,36947,36930,36948,36924,36949,36944,36935,36943,36942,36941,36945,36926,36929,37138,37143,37228,37226,37225,37321,37431,37463,37432,37437,37440,37438,37467,37451,37476,37457,37428,37449,37453,37445,37433,37439,37466,38296,38552,38548,38549,38605,38603,38601,38602,38647,38651,38649,38646,38742,38772,38774,38928,38929,38931,38922,38930,38924,39164,39156,39165,39166,39347,39345,39348,39649,40169,40578,40718,40723,40736,20711,20718,20709,20694,20717,20698,20693,20687,20689,20721,20686,20713,20834,20979,21123,21122,21297,21421,22014,22016,22043,22039,22013,22036,22022,22025,22029,22030,22007,22038,22047,22024,22032,22006,22296,22294,22645,22654,22659,22675,22666,22649,22661,22653,22781,22821,22818,22820,22890,22889,23265,23270,23273,23255,23254,23256,23267,23413,23518,23527,23521,23525,23526,23528,23522,23524,23519,23565,23650,23940,23943,24155,24163,24149,24151,24148,24275,24278,24330,24390,24432,24505,24903,24895,24907,24951,24930,24931,24927,24922,24920,24949,25130,25735,25688,25684,25764,25720,25695,25722,25681,25703,25652,25709,25723,25970,26017,26071,26070,26274,26280,26269,27036,27048,27029,27073,27054,27091,27083,27035,27063,27067,27051,27060,27088,27085,27053,27084,27046,27075,27043,27465,27468,27699,28467,28436,28414,28435,28404,28457,28478,28448,28460,28431,28418,28450,28415,28399,28422,28465,28472,28466,28451,28437,28459,28463,28552,28458,28396,28417,28402,28364,28407,29076,29081,29053,29066,29060,29074,29246,29330,29334,29508,29520,29796,29795,29802,29808,29805,29956,30097,30247,30221,30219,30217,30227,30433,30435,30596,30589,30591,30561,30913,30879,30887,30899,30889,30883,31118,31119,31117,31278,31281,31402,31401,31469,31471,31649,31637,31627,31605,31639,31645,31636,31631,31672,31623,31620,31929,31933,31934,32187,32176,32156,32189,32190,32160,32202,32180,32178,32177,32186,32162,32191,32181,32184,32173,32210,32199,32172,32624,32736,32737,32735,32862,32858,32903,33104,33152,33167,33160,33162,33151,33154,33255,33274,33287,33300,33310,33355,33993,33983,33990,33988,33945,33950,33970,33948,33995,33976,33984,34003,33936,33980,34001,33994,34623,34588,34619,34594,34597,34612,34584,34645,34615,34601,35059,35074,35060,35065,35064,35069,35048,35098,35055,35494,35468,35486,35491,35469,35489,35475,35492,35498,35493,35496,35480,35473,35482,35495,35946,35981,35980,36051,36049,36050,36203,36249,36245,36348,36628,36626,36629,36627,36771,36960,36952,36956,36963,36953,36958,36962,36957,36955,37145,37144,37150,37237,37240,37239,37236,37496,37504,37509,37528,37526,37499,37523,37532,37544,37500,37521,38305,38312,38313,38307,38309,38308,38553,38556,38555,38604,38610,38656,38780,38789,38902,38935,38936,39087,39089,39171,39173,39180,39177,39361,39599,39600,39654,39745,39746,40180,40182,40179,40636,40763,40778,20740,20736,20731,20725,20729,20738,20744,20745,20741,20956,21127,21128,21129,21133,21130,21232,21426,22062,22075,22073,22066,22079,22068,22057,22099,22094,22103,22132,22070,22063,22064,22656,22687,22686,22707,22684,22702,22697,22694,22893,23305,23291,23307,23285,23308,23304,23534,23532,23529,23531,23652,23653,23965,23956,24162,24159,24161,24290,24282,24287,24285,24291,24288,24392,24433,24503,24501,24950,24935,24942,24925,24917,24962,24956,24944,24939,24958,24999,24976,25003,24974,25004,24986,24996,24980,25006,25134,25705,25711,25721,25758,25778,25736,25744,25776,25765,25747,25749,25769,25746,25774,25773,25771,25754,25772,25753,25762,25779,25973,25975,25976,26286,26283,26292,26289,27171,27167,27112,27137,27166,27161,27133,27169,27155,27146,27123,27138,27141,27117,27153,27472,27470,27556,27589,27590,28479,28540,28548,28497,28518,28500,28550,28525,28507,28536,28526,28558,28538,28528,28516,28567,28504,28373,28527,28512,28511,29087,29100,29105,29096,29270,29339,29518,29527,29801,29835,29827,29822,29824,30079,30240,30249,30239,30244,30246,30241,30242,30362,30394,30436,30606,30599,30604,30609,30603,30923,30917,30906,30922,30910,30933,30908,30928,31295,31292,31296,31293,31287,31291,31407,31406,31661,31665,31684,31668,31686,31687,31681,31648,31692,31946,32224,32244,32239,32251,32216,32236,32221,32232,32227,32218,32222,32233,32158,32217,32242,32249,32629,32631,32687,32745,32806,33179,33180,33181,33184,33178,33176,34071,34109,34074,34030,34092,34093,34067,34065,34083,34081,34068,34028,34085,34047,34054,34690,34676,34678,34656,34662,34680,34664,34649,34647,34636,34643,34907,34909,35088,35079,35090,35091,35093,35082,35516,35538,35527,35524,35477,35531,35576,35506,35529,35522,35519,35504,35542,35533,35510,35513,35547,35916,35918,35948,36064,36062,36070,36068,36076,36077,36066,36067,36060,36074,36065,36205,36255,36259,36395,36368,36381,36386,36367,36393,36383,36385,36382,36538,36637,36635,36639,36649,36646,36650,36636,36638,36645,36969,36974,36968,36973,36983,37168,37165,37159,37169,37255,37257,37259,37251,37573,37563,37559,37610,37548,37604,37569,37555,37564,37586,37575,37616,37554,38317,38321,38660,38662,38663,38665,38752,38797,38795,38799,38945,38955,38940,39091,39178,39187,39186,39192,39389,39376,39391,39387,39377,39381,39378,39385,39607,39662,39663,39719,39749,39748,39799,39791,40198,40201,40195,40617,40638,40654,22696,40786,20754,20760,20756,20752,20757,20864,20906,20957,21137,21139,21235,22105,22123,22137,22121,22116,22136,22122,22120,22117,22129,22127,22124,22114,22134,22721,22718,22727,22725,22894,23325,23348,23416,23536,23566,24394,25010,24977,25001,24970,25037,25014,25022,25034,25032,25136,25797,25793,25803,25787,25788,25818,25796,25799,25794,25805,25791,25810,25812,25790,25972,26310,26313,26297,26308,26311,26296,27197,27192,27194,27225,27243,27224,27193,27204,27234,27233,27211,27207,27189,27231,27208,27481,27511,27653,28610,28593,28577,28611,28580,28609,28583,28595,28608,28601,28598,28582,28576,28596,29118,29129,29136,29138,29128,29141,29113,29134,29145,29148,29123,29124,29544,29852,29859,29848,29855,29854,29922,29964,29965,30260,30264,30266,30439,30437,30624,30622,30623,30629,30952,30938,30956,30951,31142,31309,31310,31302,31308,31307,31418,31705,31761,31689,31716,31707,31713,31721,31718,31957,31958,32266,32273,32264,32283,32291,32286,32285,32265,32272,32633,32690,32752,32753,32750,32808,33203,33193,33192,33275,33288,33368,33369,34122,34137,34120,34152,34153,34115,34121,34157,34154,34142,34691,34719,34718,34722,34701,34913,35114,35122,35109,35115,35105,35242,35238,35558,35578,35563,35569,35584,35548,35559,35566,35582,35585,35586,35575,35565,35571,35574,35580,35947,35949,35987,36084,36420,36401,36404,36418,36409,36405,36667,36655,36664,36659,36776,36774,36981,36980,36984,36978,36988,36986,37172,37266,37664,37686,37624,37683,37679,37666,37628,37675,37636,37658,37648,37670,37665,37653,37678,37657,38331,38567,38568,38570,38613,38670,38673,38678,38669,38675,38671,38747,38748,38758,38808,38960,38968,38971,38967,38957,38969,38948,39184,39208,39198,39195,39201,39194,39405,39394,39409,39608,39612,39675,39661,39720,39825,40213,40227,40230,40232,40210,40219,40664,40660,40845,40860,20778,20767,20769,20786,21237,22158,22144,22160,22149,22151,22159,22741,22739,22737,22734,23344,23338,23332,23418,23607,23656,23996,23994,23997,23992,24171,24396,24509,25033,25026,25031,25062,25035,25138,25140,25806,25802,25816,25824,25840,25830,25836,25841,25826,25837,25986,25987,26329,26326,27264,27284,27268,27298,27292,27355,27299,27262,27287,27280,27296,27484,27566,27610,27656,28632,28657,28639,28640,28635,28644,28651,28655,28544,28652,28641,28649,28629,28654,28656,29159,29151,29166,29158,29157,29165,29164,29172,29152,29237,29254,29552,29554,29865,29872,29862,29864,30278,30274,30284,30442,30643,30634,30640,30636,30631,30637,30703,30967,30970,30964,30959,30977,31143,31146,31319,31423,31751,31757,31742,31735,31756,31712,31968,31964,31966,31970,31967,31961,31965,32302,32318,32326,32311,32306,32323,32299,32317,32305,32325,32321,32308,32313,32328,32309,32319,32303,32580,32755,32764,32881,32882,32880,32879,32883,33222,33219,33210,33218,33216,33215,33213,33225,33214,33256,33289,33393,34218,34180,34174,34204,34193,34196,34223,34203,34183,34216,34186,34407,34752,34769,34739,34770,34758,34731,34747,34746,34760,34763,35131,35126,35140,35128,35133,35244,35598,35607,35609,35611,35594,35616,35613,35588,35600,35905,35903,35955,36090,36093,36092,36088,36091,36264,36425,36427,36424,36426,36676,36670,36674,36677,36671,36991,36989,36996,36993,36994,36992,37177,37283,37278,37276,37709,37762,37672,37749,37706,37733,37707,37656,37758,37740,37723,37744,37722,37716,38346,38347,38348,38344,38342,38577,38584,38614,38684,38686,38816,38867,38982,39094,39221,39425,39423,39854,39851,39850,39853,40251,40255,40587,40655,40670,40668,40669,40667,40766,40779,21474,22165,22190,22745,22744,23352,24413,25059,25139,25844,25842,25854,25862,25850,25851,25847,26039,26332,26406,27315,27308,27331,27323,27320,27330,27310,27311,27487,27512,27567,28681,28683,28670,28678,28666,28689,28687,29179,29180,29182,29176,29559,29557,29863,29887,29973,30294,30296,30290,30653,30655,30651,30652,30990,31150,31329,31330,31328,31428,31429,31787,31783,31786,31774,31779,31777,31975,32340,32341,32350,32346,32353,32338,32345,32584,32761,32763,32887,32886,33229,33231,33290,34255,34217,34253,34256,34249,34224,34234,34233,34214,34799,34796,34802,34784,35206,35250,35316,35624,35641,35628,35627,35920,36101,36441,36451,36454,36452,36447,36437,36544,36681,36685,36999,36995,37000,37291,37292,37328,37780,37770,37782,37794,37811,37806,37804,37808,37784,37786,37783,38356,38358,38352,38357,38626,38620,38617,38619,38622,38692,38819,38822,38829,38905,38989,38991,38988,38990,38995,39098,39230,39231,39229,39214,39333,39438,39617,39683,39686,39759,39758,39757,39882,39881,39933,39880,39872,40273,40285,40288,40672,40725,40748,20787,22181,22750,22751,22754,23541,40848,24300,25074,25079,25078,25077,25856,25871,26336,26333,27365,27357,27354,27347,28699,28703,28712,28698,28701,28693,28696,29190,29197,29272,29346,29560,29562,29885,29898,29923,30087,30086,30303,30305,30663,31001,31153,31339,31337,31806,31807,31800,31805,31799,31808,32363,32365,32377,32361,32362,32645,32371,32694,32697,32696,33240,34281,34269,34282,34261,34276,34277,34295,34811,34821,34829,34809,34814,35168,35167,35158,35166,35649,35676,35672,35657,35674,35662,35663,35654,35673,36104,36106,36476,36466,36487,36470,36460,36474,36468,36692,36686,36781,37002,37003,37297,37294,37857,37841,37855,37827,37832,37852,37853,37846,37858,37837,37848,37860,37847,37864,38364,38580,38627,38698,38695,38753,38876,38907,39006,39000,39003,39100,39237,39241,39446,39449,39693,39912,39911,39894,39899,40329,40289,40306,40298,40300,40594,40599,40595,40628,21240,22184,22199,22198,22196,22204,22756,23360,23363,23421,23542,24009,25080,25082,25880,25876,25881,26342,26407,27372,28734,28720,28722,29200,29563,29903,30306,30309,31014,31018,31020,31019,31431,31478,31820,31811,31821,31983,31984,36782,32381,32380,32386,32588,32768,33242,33382,34299,34297,34321,34298,34310,34315,34311,34314,34836,34837,35172,35258,35320,35696,35692,35686,35695,35679,35691,36111,36109,36489,36481,36485,36482,37300,37323,37912,37891,37885,38369,38704,39108,39250,39249,39336,39467,39472,39479,39477,39955,39949,40569,40629,40680,40751,40799,40803,40801,20791,20792,22209,22208,22210,22804,23660,24013,25084,25086,25885,25884,26005,26345,27387,27396,27386,27570,28748,29211,29351,29910,29908,30313,30675,31824,32399,32396,32700,34327,34349,34330,34851,34850,34849,34847,35178,35180,35261,35700,35703,35709,36115,36490,36493,36491,36703,36783,37306,37934,37939,37941,37946,37944,37938,37931,38370,38712,38713,38706,38911,39015,39013,39255,39493,39491,39488,39486,39631,39764,39761,39981,39973,40367,40372,40386,40376,40605,40687,40729,40796,40806,40807,20796,20795,22216,22218,22217,23423,24020,24018,24398,25087,25892,27402,27489,28753,28760,29568,29924,30090,30318,30316,31155,31840,31839,32894,32893,33247,35186,35183,35324,35712,36118,36119,36497,36499,36705,37192,37956,37969,37970,38717,38718,38851,38849,39019,39253,39509,39501,39634,39706,40009,39985,39998,39995,40403,40407,40756,40812,40810,40852,22220,24022,25088,25891,25899,25898,26348,27408,29914,31434,31844,31843,31845,32403,32406,32404,33250,34360,34367,34865,35722,37008,37007,37987,37984,37988,38760,39023,39260,39514,39515,39511,39635,39636,39633,40020,40023,40022,40421,40607,40692,22225,22761,25900,28766,30321,30322,30679,32592,32648,34870,34873,34914,35731,35730,35734,33399,36123,37312,37994,38722,38728,38724,38854,39024,39519,39714,39768,40031,40441,40442,40572,40573,40711,40823,40818,24307,27414,28771,31852,31854,34875,35264,36513,37313,38002,38000,39025,39262,39638,39715,40652,28772,30682,35738,38007,38857,39522,39525,32412,35740,36522,37317,38013,38014,38012,40055,40056,40695,35924,38015,40474,29224,39530,39729,40475,40478,31858,9312,9313,9314,9315,9316,9317,9318,9319,9320,9321,9332,9333,9334,9335,9336,9337,9338,9339,9340,9341,8560,8561,8562,8563,8564,8565,8566,8567,8568,8569,20022,20031,20101,20128,20866,20886,20907,21241,21304,21353,21430,22794,23424,24027,12083,24191,24308,24400,24417,25908,26080,30098,30326,36789,38582,168,710,12541,12542,12445,12446,12291,20189,12293,12294,12295,12540,65339,65341,10045,12353,12354,12355,12356,12357,12358,12359,12360,12361,12362,12363,12364,12365,12366,12367,12368,12369,12370,12371,12372,12373,12374,12375,12376,12377,12378,12379,12380,12381,12382,12383,12384,12385,12386,12387,12388,12389,12390,12391,12392,12393,12394,12395,12396,12397,12398,12399,12400,12401,12402,12403,12404,12405,12406,12407,12408,12409,12410,12411,12412,12413,12414,12415,12416,12417,12418,12419,12420,12421,12422,12423,12424,12425,12426,12427,12428,12429,12430,12431,12432,12433,12434,12435,12449,12450,12451,12452,12453,12454,12455,12456,12457,12458,12459,12460,12461,12462,12463,12464,12465,12466,12467,12468,12469,12470,12471,12472,12473,12474,12475,12476,12477,12478,12479,12480,12481,12482,12483,12484,12485,12486,12487,12488,12489,12490,12491,12492,12493,12494,12495,12496,12497,12498,12499,12500,12501,12502,12503,12504,12505,12506,12507,12508,12509,12510,12511,12512,12513,12514,12515,12516,12517,12518,12519,12520,12521,12522,12523,12524,12525,12526,12527,12528,12529,12530,12531,12532,12533,12534,1040,1041,1042,1043,1044,1045,1025,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,1072,1073,1074,1075,1076,1077,1105,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103,8679,8632,8633,12751,131276,20058,131210,20994,17553,40880,20872,40881,161287,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,65506,65508,65287,65282,12849,8470,8481,12443,12444,11904,11908,11910,11911,11912,11914,11916,11917,11925,11932,11933,11941,11943,11946,11948,11950,11958,11964,11966,11974,11978,11980,11981,11983,11990,11991,11998,12003,null,null,null,643,592,603,596,629,339,248,331,650,618,20034,20060,20981,21274,21378,19975,19980,20039,20109,22231,64012,23662,24435,19983,20871,19982,20014,20115,20162,20169,20168,20888,21244,21356,21433,22304,22787,22828,23568,24063,26081,27571,27596,27668,29247,20017,20028,20200,20188,20201,20193,20189,20186,21004,21276,21324,22306,22307,22807,22831,23425,23428,23570,23611,23668,23667,24068,24192,24194,24521,25097,25168,27669,27702,27715,27711,27707,29358,29360,29578,31160,32906,38430,20238,20248,20268,20213,20244,20209,20224,20215,20232,20253,20226,20229,20258,20243,20228,20212,20242,20913,21011,21001,21008,21158,21282,21279,21325,21386,21511,22241,22239,22318,22314,22324,22844,22912,22908,22917,22907,22910,22903,22911,23382,23573,23589,23676,23674,23675,23678,24031,24181,24196,24322,24346,24436,24533,24532,24527,25180,25182,25188,25185,25190,25186,25177,25184,25178,25189,26095,26094,26430,26425,26424,26427,26426,26431,26428,26419,27672,27718,27730,27740,27727,27722,27732,27723,27724,28785,29278,29364,29365,29582,29994,30335,31349,32593,33400,33404,33408,33405,33407,34381,35198,37017,37015,37016,37019,37012,38434,38436,38432,38435,20310,20283,20322,20297,20307,20324,20286,20327,20306,20319,20289,20312,20269,20275,20287,20321,20879,20921,21020,21022,21025,21165,21166,21257,21347,21362,21390,21391,21552,21559,21546,21588,21573,21529,21532,21541,21528,21565,21583,21569,21544,21540,21575,22254,22247,22245,22337,22341,22348,22345,22347,22354,22790,22848,22950,22936,22944,22935,22926,22946,22928,22927,22951,22945,23438,23442,23592,23594,23693,23695,23688,23691,23689,23698,23690,23686,23699,23701,24032,24074,24078,24203,24201,24204,24200,24205,24325,24349,24440,24438,24530,24529,24528,24557,24552,24558,24563,24545,24548,24547,24570,24559,24567,24571,24576,24564,25146,25219,25228,25230,25231,25236,25223,25201,25211,25210,25200,25217,25224,25207,25213,25202,25204,25911,26096,26100,26099,26098,26101,26437,26439,26457,26453,26444,26440,26461,26445,26458,26443,27600,27673,27674,27768,27751,27755,27780,27787,27791,27761,27759,27753,27802,27757,27783,27797,27804,27750,27763,27749,27771,27790,28788,28794,29283,29375,29373,29379,29382,29377,29370,29381,29589,29591,29587,29588,29586,30010,30009,30100,30101,30337,31037,32820,32917,32921,32912,32914,32924,33424,33423,33413,33422,33425,33427,33418,33411,33412,35960,36809,36799,37023,37025,37029,37022,37031,37024,38448,38440,38447,38445,20019,20376,20348,20357,20349,20352,20359,20342,20340,20361,20356,20343,20300,20375,20330,20378,20345,20353,20344,20368,20380,20372,20382,20370,20354,20373,20331,20334,20894,20924,20926,21045,21042,21043,21062,21041,21180,21258,21259,21308,21394,21396,21639,21631,21633,21649,21634,21640,21611,21626,21630,21605,21612,21620,21606,21645,21615,21601,21600,21656,21603,21607,21604,22263,22265,22383,22386,22381,22379,22385,22384,22390,22400,22389,22395,22387,22388,22370,22376,22397,22796,22853,22965,22970,22991,22990,22962,22988,22977,22966,22972,22979,22998,22961,22973,22976,22984,22964,22983,23394,23397,23443,23445,23620,23623,23726,23716,23712,23733,23727,23720,23724,23711,23715,23725,23714,23722,23719,23709,23717,23734,23728,23718,24087,24084,24089,24360,24354,24355,24356,24404,24450,24446,24445,24542,24549,24621,24614,24601,24626,24587,24628,24586,24599,24627,24602,24606,24620,24610,24589,24592,24622,24595,24593,24588,24585,24604,25108,25149,25261,25268,25297,25278,25258,25270,25290,25262,25267,25263,25275,25257,25264,25272,25917,26024,26043,26121,26108,26116,26130,26120,26107,26115,26123,26125,26117,26109,26129,26128,26358,26378,26501,26476,26510,26514,26486,26491,26520,26502,26500,26484,26509,26508,26490,26527,26513,26521,26499,26493,26497,26488,26489,26516,27429,27520,27518,27614,27677,27795,27884,27883,27886,27865,27830,27860,27821,27879,27831,27856,27842,27834,27843,27846,27885,27890,27858,27869,27828,27786,27805,27776,27870,27840,27952,27853,27847,27824,27897,27855,27881,27857,28820,28824,28805,28819,28806,28804,28817,28822,28802,28826,28803,29290,29398,29387,29400,29385,29404,29394,29396,29402,29388,29393,29604,29601,29613,29606,29602,29600,29612,29597,29917,29928,30015,30016,30014,30092,30104,30383,30451,30449,30448,30453,30712,30716,30713,30715,30714,30711,31042,31039,31173,31352,31355,31483,31861,31997,32821,32911,32942,32931,32952,32949,32941,33312,33440,33472,33451,33434,33432,33435,33461,33447,33454,33468,33438,33466,33460,33448,33441,33449,33474,33444,33475,33462,33442,34416,34415,34413,34414,35926,36818,36811,36819,36813,36822,36821,36823,37042,37044,37039,37043,37040,38457,38461,38460,38458,38467,20429,20421,20435,20402,20425,20427,20417,20436,20444,20441,20411,20403,20443,20423,20438,20410,20416,20409,20460,21060,21065,21184,21186,21309,21372,21399,21398,21401,21400,21690,21665,21677,21669,21711,21699,33549,21687,21678,21718,21686,21701,21702,21664,21616,21692,21666,21694,21618,21726,21680,22453,22430,22431,22436,22412,22423,22429,22427,22420,22424,22415,22425,22437,22426,22421,22772,22797,22867,23009,23006,23022,23040,23025,23005,23034,23037,23036,23030,23012,23026,23031,23003,23017,23027,23029,23008,23038,23028,23021,23464,23628,23760,23768,23756,23767,23755,23771,23774,23770,23753,23751,23754,23766,23763,23764,23759,23752,23750,23758,23775,23800,24057,24097,24098,24099,24096,24100,24240,24228,24226,24219,24227,24229,24327,24366,24406,24454,24631,24633,24660,24690,24670,24645,24659,24647,24649,24667,24652,24640,24642,24671,24612,24644,24664,24678,24686,25154,25155,25295,25357,25355,25333,25358,25347,25323,25337,25359,25356,25336,25334,25344,25363,25364,25338,25365,25339,25328,25921,25923,26026,26047,26166,26145,26162,26165,26140,26150,26146,26163,26155,26170,26141,26164,26169,26158,26383,26384,26561,26610,26568,26554,26588,26555,26616,26584,26560,26551,26565,26603,26596,26591,26549,26573,26547,26615,26614,26606,26595,26562,26553,26574,26599,26608,26546,26620,26566,26605,26572,26542,26598,26587,26618,26569,26570,26563,26602,26571,27432,27522,27524,27574,27606,27608,27616,27680,27681,27944,27956,27949,27935,27964,27967,27922,27914,27866,27955,27908,27929,27962,27930,27921,27904,27933,27970,27905,27928,27959,27907,27919,27968,27911,27936,27948,27912,27938,27913,27920,28855,28831,28862,28849,28848,28833,28852,28853,28841,29249,29257,29258,29292,29296,29299,29294,29386,29412,29416,29419,29407,29418,29414,29411,29573,29644,29634,29640,29637,29625,29622,29621,29620,29675,29631,29639,29630,29635,29638,29624,29643,29932,29934,29998,30023,30024,30119,30122,30329,30404,30472,30467,30468,30469,30474,30455,30459,30458,30695,30696,30726,30737,30738,30725,30736,30735,30734,30729,30723,30739,31050,31052,31051,31045,31044,31189,31181,31183,31190,31182,31360,31358,31441,31488,31489,31866,31864,31865,31871,31872,31873,32003,32008,32001,32600,32657,32653,32702,32775,32782,32783,32788,32823,32984,32967,32992,32977,32968,32962,32976,32965,32995,32985,32988,32970,32981,32969,32975,32983,32998,32973,33279,33313,33428,33497,33534,33529,33543,33512,33536,33493,33594,33515,33494,33524,33516,33505,33522,33525,33548,33531,33526,33520,33514,33508,33504,33530,33523,33517,34423,34420,34428,34419,34881,34894,34919,34922,34921,35283,35332,35335,36210,36835,36833,36846,36832,37105,37053,37055,37077,37061,37054,37063,37067,37064,37332,37331,38484,38479,38481,38483,38474,38478,20510,20485,20487,20499,20514,20528,20507,20469,20468,20531,20535,20524,20470,20471,20503,20508,20512,20519,20533,20527,20529,20494,20826,20884,20883,20938,20932,20933,20936,20942,21089,21082,21074,21086,21087,21077,21090,21197,21262,21406,21798,21730,21783,21778,21735,21747,21732,21786,21759,21764,21768,21739,21777,21765,21745,21770,21755,21751,21752,21728,21774,21763,21771,22273,22274,22476,22578,22485,22482,22458,22470,22461,22460,22456,22454,22463,22471,22480,22457,22465,22798,22858,23065,23062,23085,23086,23061,23055,23063,23050,23070,23091,23404,23463,23469,23468,23555,23638,23636,23788,23807,23790,23793,23799,23808,23801,24105,24104,24232,24238,24234,24236,24371,24368,24423,24669,24666,24679,24641,24738,24712,24704,24722,24705,24733,24707,24725,24731,24727,24711,24732,24718,25113,25158,25330,25360,25430,25388,25412,25413,25398,25411,25572,25401,25419,25418,25404,25385,25409,25396,25432,25428,25433,25389,25415,25395,25434,25425,25400,25431,25408,25416,25930,25926,26054,26051,26052,26050,26186,26207,26183,26193,26386,26387,26655,26650,26697,26674,26675,26683,26699,26703,26646,26673,26652,26677,26667,26669,26671,26702,26692,26676,26653,26642,26644,26662,26664,26670,26701,26682,26661,26656,27436,27439,27437,27441,27444,27501,32898,27528,27622,27620,27624,27619,27618,27623,27685,28026,28003,28004,28022,27917,28001,28050,27992,28002,28013,28015,28049,28045,28143,28031,28038,27998,28007,28000,28055,28016,28028,27999,28034,28056,27951,28008,28043,28030,28032,28036,27926,28035,28027,28029,28021,28048,28892,28883,28881,28893,28875,32569,28898,28887,28882,28894,28896,28884,28877,28869,28870,28871,28890,28878,28897,29250,29304,29303,29302,29440,29434,29428,29438,29430,29427,29435,29441,29651,29657,29669,29654,29628,29671,29667,29673,29660,29650,29659,29652,29661,29658,29655,29656,29672,29918,29919,29940,29941,29985,30043,30047,30128,30145,30139,30148,30144,30143,30134,30138,30346,30409,30493,30491,30480,30483,30482,30499,30481,30485,30489,30490,30498,30503,30755,30764,30754,30773,30767,30760,30766,30763,30753,30761,30771,30762,30769,31060,31067,31055,31068,31059,31058,31057,31211,31212,31200,31214,31213,31210,31196,31198,31197,31366,31369,31365,31371,31372,31370,31367,31448,31504,31492,31507,31493,31503,31496,31498,31502,31497,31506,31876,31889,31882,31884,31880,31885,31877,32030,32029,32017,32014,32024,32022,32019,32031,32018,32015,32012,32604,32609,32606,32608,32605,32603,32662,32658,32707,32706,32704,32790,32830,32825,33018,33010,33017,33013,33025,33019,33024,33281,33327,33317,33587,33581,33604,33561,33617,33573,33622,33599,33601,33574,33564,33570,33602,33614,33563,33578,33544,33596,33613,33558,33572,33568,33591,33583,33577,33607,33605,33612,33619,33566,33580,33611,33575,33608,34387,34386,34466,34472,34454,34445,34449,34462,34439,34455,34438,34443,34458,34437,34469,34457,34465,34471,34453,34456,34446,34461,34448,34452,34883,34884,34925,34933,34934,34930,34944,34929,34943,34927,34947,34942,34932,34940,35346,35911,35927,35963,36004,36003,36214,36216,36277,36279,36278,36561,36563,36862,36853,36866,36863,36859,36868,36860,36854,37078,37088,37081,37082,37091,37087,37093,37080,37083,37079,37084,37092,37200,37198,37199,37333,37346,37338,38492,38495,38588,39139,39647,39727,20095,20592,20586,20577,20574,20576,20563,20555,20573,20594,20552,20557,20545,20571,20554,20578,20501,20549,20575,20585,20587,20579,20580,20550,20544,20590,20595,20567,20561,20944,21099,21101,21100,21102,21206,21203,21293,21404,21877,21878,21820,21837,21840,21812,21802,21841,21858,21814,21813,21808,21842,21829,21772,21810,21861,21838,21817,21832,21805,21819,21824,21835,22282,22279,22523,22548,22498,22518,22492,22516,22528,22509,22525,22536,22520,22539,22515,22479,22535,22510,22499,22514,22501,22508,22497,22542,22524,22544,22503,22529,22540,22513,22505,22512,22541,22532,22876,23136,23128,23125,23143,23134,23096,23093,23149,23120,23135,23141,23148,23123,23140,23127,23107,23133,23122,23108,23131,23112,23182,23102,23117,23097,23116,23152,23145,23111,23121,23126,23106,23132,23410,23406,23489,23488,23641,23838,23819,23837,23834,23840,23820,23848,23821,23846,23845,23823,23856,23826,23843,23839,23854,24126,24116,24241,24244,24249,24242,24243,24374,24376,24475,24470,24479,24714,24720,24710,24766,24752,24762,24787,24788,24783,24804,24793,24797,24776,24753,24795,24759,24778,24767,24771,24781,24768,25394,25445,25482,25474,25469,25533,25502,25517,25501,25495,25515,25486,25455,25479,25488,25454,25519,25461,25500,25453,25518,25468,25508,25403,25503,25464,25477,25473,25489,25485,25456,25939,26061,26213,26209,26203,26201,26204,26210,26392,26745,26759,26768,26780,26733,26734,26798,26795,26966,26735,26787,26796,26793,26741,26740,26802,26767,26743,26770,26748,26731,26738,26794,26752,26737,26750,26779,26774,26763,26784,26761,26788,26744,26747,26769,26764,26762,26749,27446,27443,27447,27448,27537,27535,27533,27534,27532,27690,28096,28075,28084,28083,28276,28076,28137,28130,28087,28150,28116,28160,28104,28128,28127,28118,28094,28133,28124,28125,28123,28148,28106,28093,28141,28144,28090,28117,28098,28111,28105,28112,28146,28115,28157,28119,28109,28131,28091,28922,28941,28919,28951,28916,28940,28912,28932,28915,28944,28924,28927,28934,28947,28928,28920,28918,28939,28930,28942,29310,29307,29308,29311,29469,29463,29447,29457,29464,29450,29448,29439,29455,29470,29576,29686,29688,29685,29700,29697,29693,29703,29696,29690,29692,29695,29708,29707,29684,29704,30052,30051,30158,30162,30159,30155,30156,30161,30160,30351,30345,30419,30521,30511,30509,30513,30514,30516,30515,30525,30501,30523,30517,30792,30802,30793,30797,30794,30796,30758,30789,30800,31076,31079,31081,31082,31075,31083,31073,31163,31226,31224,31222,31223,31375,31380,31376,31541,31559,31540,31525,31536,31522,31524,31539,31512,31530,31517,31537,31531,31533,31535,31538,31544,31514,31523,31892,31896,31894,31907,32053,32061,32056,32054,32058,32069,32044,32041,32065,32071,32062,32063,32074,32059,32040,32611,32661,32668,32669,32667,32714,32715,32717,32720,32721,32711,32719,32713,32799,32798,32795,32839,32835,32840,33048,33061,33049,33051,33069,33055,33068,33054,33057,33045,33063,33053,33058,33297,33336,33331,33338,33332,33330,33396,33680,33699,33704,33677,33658,33651,33700,33652,33679,33665,33685,33689,33653,33684,33705,33661,33667,33676,33693,33691,33706,33675,33662,33701,33711,33672,33687,33712,33663,33702,33671,33710,33654,33690,34393,34390,34495,34487,34498,34497,34501,34490,34480,34504,34489,34483,34488,34508,34484,34491,34492,34499,34493,34494,34898,34953,34965,34984,34978,34986,34970,34961,34977,34975,34968,34983,34969,34971,34967,34980,34988,34956,34963,34958,35202,35286,35289,35285,35376,35367,35372,35358,35897,35899,35932,35933,35965,36005,36221,36219,36217,36284,36290,36281,36287,36289,36568,36574,36573,36572,36567,36576,36577,36900,36875,36881,36892,36876,36897,37103,37098,37104,37108,37106,37107,37076,37099,37100,37097,37206,37208,37210,37203,37205,37356,37364,37361,37363,37368,37348,37369,37354,37355,37367,37352,37358,38266,38278,38280,38524,38509,38507,38513,38511,38591,38762,38916,39141,39319,20635,20629,20628,20638,20619,20643,20611,20620,20622,20637,20584,20636,20626,20610,20615,20831,20948,21266,21265,21412,21415,21905,21928,21925,21933,21879,22085,21922,21907,21896,21903,21941,21889,21923,21906,21924,21885,21900,21926,21887,21909,21921,21902,22284,22569,22583,22553,22558,22567,22563,22568,22517,22600,22565,22556,22555,22579,22591,22582,22574,22585,22584,22573,22572,22587,22881,23215,23188,23199,23162,23202,23198,23160,23206,23164,23205,23212,23189,23214,23095,23172,23178,23191,23171,23179,23209,23163,23165,23180,23196,23183,23187,23197,23530,23501,23499,23508,23505,23498,23502,23564,23600,23863,23875,23915,23873,23883,23871,23861,23889,23886,23893,23859,23866,23890,23869,23857,23897,23874,23865,23881,23864,23868,23858,23862,23872,23877,24132,24129,24408,24486,24485,24491,24777,24761,24780,24802,24782,24772,24852,24818,24842,24854,24837,24821,24851,24824,24828,24830,24769,24835,24856,24861,24848,24831,24836,24843,25162,25492,25521,25520,25550,25573,25576,25583,25539,25757,25587,25546,25568,25590,25557,25586,25589,25697,25567,25534,25565,25564,25540,25560,25555,25538,25543,25548,25547,25544,25584,25559,25561,25906,25959,25962,25956,25948,25960,25957,25996,26013,26014,26030,26064,26066,26236,26220,26235,26240,26225,26233,26218,26226,26369,26892,26835,26884,26844,26922,26860,26858,26865,26895,26838,26871,26859,26852,26870,26899,26896,26867,26849,26887,26828,26888,26992,26804,26897,26863,26822,26900,26872,26832,26877,26876,26856,26891,26890,26903,26830,26824,26845,26846,26854,26868,26833,26886,26836,26857,26901,26917,26823,27449,27451,27455,27452,27540,27543,27545,27541,27581,27632,27634,27635,27696,28156,28230,28231,28191,28233,28296,28220,28221,28229,28258,28203,28223,28225,28253,28275,28188,28211,28235,28224,28241,28219,28163,28206,28254,28264,28252,28257,28209,28200,28256,28273,28267,28217,28194,28208,28243,28261,28199,28280,28260,28279,28245,28281,28242,28262,28213,28214,28250,28960,28958,28975,28923,28974,28977,28963,28965,28962,28978,28959,28968,28986,28955,29259,29274,29320,29321,29318,29317,29323,29458,29451,29488,29474,29489,29491,29479,29490,29485,29478,29475,29493,29452,29742,29740,29744,29739,29718,29722,29729,29741,29745,29732,29731,29725,29737,29728,29746,29947,29999,30063,30060,30183,30170,30177,30182,30173,30175,30180,30167,30357,30354,30426,30534,30535,30532,30541,30533,30538,30542,30539,30540,30686,30700,30816,30820,30821,30812,30829,30833,30826,30830,30832,30825,30824,30814,30818,31092,31091,31090,31088,31234,31242,31235,31244,31236,31385,31462,31460,31562,31547,31556,31560,31564,31566,31552,31576,31557,31906,31902,31912,31905,32088,32111,32099,32083,32086,32103,32106,32079,32109,32092,32107,32082,32084,32105,32081,32095,32078,32574,32575,32613,32614,32674,32672,32673,32727,32849,32847,32848,33022,32980,33091,33098,33106,33103,33095,33085,33101,33082,33254,33262,33271,33272,33273,33284,33340,33341,33343,33397,33595,33743,33785,33827,33728,33768,33810,33767,33764,33788,33782,33808,33734,33736,33771,33763,33727,33793,33757,33765,33752,33791,33761,33739,33742,33750,33781,33737,33801,33807,33758,33809,33798,33730,33779,33749,33786,33735,33745,33770,33811,33731,33772,33774,33732,33787,33751,33762,33819,33755,33790,34520,34530,34534,34515,34531,34522,34538,34525,34539,34524,34540,34537,34519,34536,34513,34888,34902,34901,35002,35031,35001,35000,35008,35006,34998,35004,34999,35005,34994,35073,35017,35221,35224,35223,35293,35290,35291,35406,35405,35385,35417,35392,35415,35416,35396,35397,35410,35400,35409,35402,35404,35407,35935,35969,35968,36026,36030,36016,36025,36021,36228,36224,36233,36312,36307,36301,36295,36310,36316,36303,36309,36313,36296,36311,36293,36591,36599,36602,36601,36582,36590,36581,36597,36583,36584,36598,36587,36593,36588,36596,36585,36909,36916,36911,37126,37164,37124,37119,37116,37128,37113,37115,37121,37120,37127,37125,37123,37217,37220,37215,37218,37216,37377,37386,37413,37379,37402,37414,37391,37388,37376,37394,37375,37373,37382,37380,37415,37378,37404,37412,37401,37399,37381,37398,38267,38285,38284,38288,38535,38526,38536,38537,38531,38528,38594,38600,38595,38641,38640,38764,38768,38766,38919,39081,39147,40166,40697,20099,20100,20150,20669,20671,20678,20654,20676,20682,20660,20680,20674,20656,20673,20666,20657,20683,20681,20662,20664,20951,21114,21112,21115,21116,21955,21979,21964,21968,21963,21962,21981,21952,21972,21956,21993,21951,21970,21901,21967,21973,21986,21974,21960,22002,21965,21977,21954,22292,22611,22632,22628,22607,22605,22601,22639,22613,22606,22621,22617,22629,22619,22589,22627,22641,22780,23239,23236,23243,23226,23224,23217,23221,23216,23231,23240,23227,23238,23223,23232,23242,23220,23222,23245,23225,23184,23510,23512,23513,23583,23603,23921,23907,23882,23909,23922,23916,23902,23912,23911,23906,24048,24143,24142,24138,24141,24139,24261,24268,24262,24267,24263,24384,24495,24493,24823,24905,24906,24875,24901,24886,24882,24878,24902,24879,24911,24873,24896,25120,37224,25123,25125,25124,25541,25585,25579,25616,25618,25609,25632,25636,25651,25667,25631,25621,25624,25657,25655,25634,25635,25612,25638,25648,25640,25665,25653,25647,25610,25626,25664,25637,25639,25611,25575,25627,25646,25633,25614,25967,26002,26067,26246,26252,26261,26256,26251,26250,26265,26260,26232,26400,26982,26975,26936,26958,26978,26993,26943,26949,26986,26937,26946,26967,26969,27002,26952,26953,26933,26988,26931,26941,26981,26864,27000,26932,26985,26944,26991,26948,26998,26968,26945,26996,26956,26939,26955,26935,26972,26959,26961,26930,26962,26927,27003,26940,27462,27461,27459,27458,27464,27457,27547,64013,27643,27644,27641,27639,27640,28315,28374,28360,28303,28352,28319,28307,28308,28320,28337,28345,28358,28370,28349,28353,28318,28361,28343,28336,28365,28326,28367,28338,28350,28355,28380,28376,28313,28306,28302,28301,28324,28321,28351,28339,28368,28362,28311,28334,28323,28999,29012,29010,29027,29024,28993,29021,29026,29042,29048,29034,29025,28994,29016,28995,29003,29040,29023,29008,29011,28996,29005,29018,29263,29325,29324,29329,29328,29326,29500,29506,29499,29498,29504,29514,29513,29764,29770,29771,29778,29777,29783,29760,29775,29776,29774,29762,29766,29773,29780,29921,29951,29950,29949,29981,30073,30071,27011,30191,30223,30211,30199,30206,30204,30201,30200,30224,30203,30198,30189,30197,30205,30361,30389,30429,30549,30559,30560,30546,30550,30554,30569,30567,30548,30553,30573,30688,30855,30874,30868,30863,30852,30869,30853,30854,30881,30851,30841,30873,30848,30870,30843,31100,31106,31101,31097,31249,31256,31257,31250,31255,31253,31266,31251,31259,31248,31395,31394,31390,31467,31590,31588,31597,31604,31593,31602,31589,31603,31601,31600,31585,31608,31606,31587,31922,31924,31919,32136,32134,32128,32141,32127,32133,32122,32142,32123,32131,32124,32140,32148,32132,32125,32146,32621,32619,32615,32616,32620,32678,32677,32679,32731,32732,32801,33124,33120,33143,33116,33129,33115,33122,33138,26401,33118,33142,33127,33135,33092,33121,33309,33353,33348,33344,33346,33349,34033,33855,33878,33910,33913,33935,33933,33893,33873,33856,33926,33895,33840,33869,33917,33882,33881,33908,33907,33885,34055,33886,33847,33850,33844,33914,33859,33912,33842,33861,33833,33753,33867,33839,33858,33837,33887,33904,33849,33870,33868,33874,33903,33989,33934,33851,33863,33846,33843,33896,33918,33860,33835,33888,33876,33902,33872,34571,34564,34551,34572,34554,34518,34549,34637,34552,34574,34569,34561,34550,34573,34565,35030,35019,35021,35022,35038,35035,35034,35020,35024,35205,35227,35295,35301,35300,35297,35296,35298,35292,35302,35446,35462,35455,35425,35391,35447,35458,35460,35445,35459,35457,35444,35450,35900,35915,35914,35941,35940,35942,35974,35972,35973,36044,36200,36201,36241,36236,36238,36239,36237,36243,36244,36240,36242,36336,36320,36332,36337,36334,36304,36329,36323,36322,36327,36338,36331,36340,36614,36607,36609,36608,36613,36615,36616,36610,36619,36946,36927,36932,36937,36925,37136,37133,37135,37137,37142,37140,37131,37134,37230,37231,37448,37458,37424,37434,37478,37427,37477,37470,37507,37422,37450,37446,37485,37484,37455,37472,37479,37487,37430,37473,37488,37425,37460,37475,37456,37490,37454,37459,37452,37462,37426,38303,38300,38302,38299,38546,38547,38545,38551,38606,38650,38653,38648,38645,38771,38775,38776,38770,38927,38925,38926,39084,39158,39161,39343,39346,39344,39349,39597,39595,39771,40170,40173,40167,40576,40701,20710,20692,20695,20712,20723,20699,20714,20701,20708,20691,20716,20720,20719,20707,20704,20952,21120,21121,21225,21227,21296,21420,22055,22037,22028,22034,22012,22031,22044,22017,22035,22018,22010,22045,22020,22015,22009,22665,22652,22672,22680,22662,22657,22655,22644,22667,22650,22663,22673,22670,22646,22658,22664,22651,22676,22671,22782,22891,23260,23278,23269,23253,23274,23258,23277,23275,23283,23266,23264,23259,23276,23262,23261,23257,23272,23263,23415,23520,23523,23651,23938,23936,23933,23942,23930,23937,23927,23946,23945,23944,23934,23932,23949,23929,23935,24152,24153,24147,24280,24273,24279,24270,24284,24277,24281,24274,24276,24388,24387,24431,24502,24876,24872,24897,24926,24945,24947,24914,24915,24946,24940,24960,24948,24916,24954,24923,24933,24891,24938,24929,24918,25129,25127,25131,25643,25677,25691,25693,25716,25718,25714,25715,25725,25717,25702,25766,25678,25730,25694,25692,25675,25683,25696,25680,25727,25663,25708,25707,25689,25701,25719,25971,26016,26273,26272,26271,26373,26372,26402,27057,27062,27081,27040,27086,27030,27056,27052,27068,27025,27033,27022,27047,27021,27049,27070,27055,27071,27076,27069,27044,27092,27065,27082,27034,27087,27059,27027,27050,27041,27038,27097,27031,27024,27074,27061,27045,27078,27466,27469,27467,27550,27551,27552,27587,27588,27646,28366,28405,28401,28419,28453,28408,28471,28411,28462,28425,28494,28441,28442,28455,28440,28475,28434,28397,28426,28470,28531,28409,28398,28461,28480,28464,28476,28469,28395,28423,28430,28483,28421,28413,28406,28473,28444,28412,28474,28447,28429,28446,28424,28449,29063,29072,29065,29056,29061,29058,29071,29051,29062,29057,29079,29252,29267,29335,29333,29331,29507,29517,29521,29516,29794,29811,29809,29813,29810,29799,29806,29952,29954,29955,30077,30096,30230,30216,30220,30229,30225,30218,30228,30392,30593,30588,30597,30594,30574,30592,30575,30590,30595,30898,30890,30900,30893,30888,30846,30891,30878,30885,30880,30892,30882,30884,31128,31114,31115,31126,31125,31124,31123,31127,31112,31122,31120,31275,31306,31280,31279,31272,31270,31400,31403,31404,31470,31624,31644,31626,31633,31632,31638,31629,31628,31643,31630,31621,31640,21124,31641,31652,31618,31931,31935,31932,31930,32167,32183,32194,32163,32170,32193,32192,32197,32157,32206,32196,32198,32203,32204,32175,32185,32150,32188,32159,32166,32174,32169,32161,32201,32627,32738,32739,32741,32734,32804,32861,32860,33161,33158,33155,33159,33165,33164,33163,33301,33943,33956,33953,33951,33978,33998,33986,33964,33966,33963,33977,33972,33985,33997,33962,33946,33969,34000,33949,33959,33979,33954,33940,33991,33996,33947,33961,33967,33960,34006,33944,33974,33999,33952,34007,34004,34002,34011,33968,33937,34401,34611,34595,34600,34667,34624,34606,34590,34593,34585,34587,34627,34604,34625,34622,34630,34592,34610,34602,34605,34620,34578,34618,34609,34613,34626,34598,34599,34616,34596,34586,34608,34577,35063,35047,35057,35058,35066,35070,35054,35068,35062,35067,35056,35052,35051,35229,35233,35231,35230,35305,35307,35304,35499,35481,35467,35474,35471,35478,35901,35944,35945,36053,36047,36055,36246,36361,36354,36351,36365,36349,36362,36355,36359,36358,36357,36350,36352,36356,36624,36625,36622,36621,37155,37148,37152,37154,37151,37149,37146,37156,37153,37147,37242,37234,37241,37235,37541,37540,37494,37531,37498,37536,37524,37546,37517,37542,37530,37547,37497,37527,37503,37539,37614,37518,37506,37525,37538,37501,37512,37537,37514,37510,37516,37529,37543,37502,37511,37545,37533,37515,37421,38558,38561,38655,38744,38781,38778,38782,38787,38784,38786,38779,38788,38785,38783,38862,38861,38934,39085,39086,39170,39168,39175,39325,39324,39363,39353,39355,39354,39362,39357,39367,39601,39651,39655,39742,39743,39776,39777,39775,40177,40178,40181,40615,20735,20739,20784,20728,20742,20743,20726,20734,20747,20748,20733,20746,21131,21132,21233,21231,22088,22082,22092,22069,22081,22090,22089,22086,22104,22106,22080,22067,22077,22060,22078,22072,22058,22074,22298,22699,22685,22705,22688,22691,22703,22700,22693,22689,22783,23295,23284,23293,23287,23286,23299,23288,23298,23289,23297,23303,23301,23311,23655,23961,23959,23967,23954,23970,23955,23957,23968,23964,23969,23962,23966,24169,24157,24160,24156,32243,24283,24286,24289,24393,24498,24971,24963,24953,25009,25008,24994,24969,24987,24979,25007,25005,24991,24978,25002,24993,24973,24934,25011,25133,25710,25712,25750,25760,25733,25751,25756,25743,25739,25738,25740,25763,25759,25704,25777,25752,25974,25978,25977,25979,26034,26035,26293,26288,26281,26290,26295,26282,26287,27136,27142,27159,27109,27128,27157,27121,27108,27168,27135,27116,27106,27163,27165,27134,27175,27122,27118,27156,27127,27111,27200,27144,27110,27131,27149,27132,27115,27145,27140,27160,27173,27151,27126,27174,27143,27124,27158,27473,27557,27555,27554,27558,27649,27648,27647,27650,28481,28454,28542,28551,28614,28562,28557,28553,28556,28514,28495,28549,28506,28566,28534,28524,28546,28501,28530,28498,28496,28503,28564,28563,28509,28416,28513,28523,28541,28519,28560,28499,28555,28521,28543,28565,28515,28535,28522,28539,29106,29103,29083,29104,29088,29082,29097,29109,29085,29093,29086,29092,29089,29098,29084,29095,29107,29336,29338,29528,29522,29534,29535,29536,29533,29531,29537,29530,29529,29538,29831,29833,29834,29830,29825,29821,29829,29832,29820,29817,29960,29959,30078,30245,30238,30233,30237,30236,30243,30234,30248,30235,30364,30365,30366,30363,30605,30607,30601,30600,30925,30907,30927,30924,30929,30926,30932,30920,30915,30916,30921,31130,31137,31136,31132,31138,31131,27510,31289,31410,31412,31411,31671,31691,31678,31660,31694,31663,31673,31690,31669,31941,31944,31948,31947,32247,32219,32234,32231,32215,32225,32259,32250,32230,32246,32241,32240,32238,32223,32630,32684,32688,32685,32749,32747,32746,32748,32742,32744,32868,32871,33187,33183,33182,33173,33186,33177,33175,33302,33359,33363,33362,33360,33358,33361,34084,34107,34063,34048,34089,34062,34057,34061,34079,34058,34087,34076,34043,34091,34042,34056,34060,34036,34090,34034,34069,34039,34027,34035,34044,34066,34026,34025,34070,34046,34088,34077,34094,34050,34045,34078,34038,34097,34086,34023,34024,34032,34031,34041,34072,34080,34096,34059,34073,34095,34402,34646,34659,34660,34679,34785,34675,34648,34644,34651,34642,34657,34650,34641,34654,34669,34666,34640,34638,34655,34653,34671,34668,34682,34670,34652,34661,34639,34683,34677,34658,34663,34665,34906,35077,35084,35092,35083,35095,35096,35097,35078,35094,35089,35086,35081,35234,35236,35235,35309,35312,35308,35535,35526,35512,35539,35537,35540,35541,35515,35543,35518,35520,35525,35544,35523,35514,35517,35545,35902,35917,35983,36069,36063,36057,36072,36058,36061,36071,36256,36252,36257,36251,36384,36387,36389,36388,36398,36373,36379,36374,36369,36377,36390,36391,36372,36370,36376,36371,36380,36375,36378,36652,36644,36632,36634,36640,36643,36630,36631,36979,36976,36975,36967,36971,37167,37163,37161,37162,37170,37158,37166,37253,37254,37258,37249,37250,37252,37248,37584,37571,37572,37568,37593,37558,37583,37617,37599,37592,37609,37591,37597,37580,37615,37570,37608,37578,37576,37582,37606,37581,37589,37577,37600,37598,37607,37585,37587,37557,37601,37574,37556,38268,38316,38315,38318,38320,38564,38562,38611,38661,38664,38658,38746,38794,38798,38792,38864,38863,38942,38941,38950,38953,38952,38944,38939,38951,39090,39176,39162,39185,39188,39190,39191,39189,39388,39373,39375,39379,39380,39374,39369,39382,39384,39371,39383,39372,39603,39660,39659,39667,39666,39665,39750,39747,39783,39796,39793,39782,39798,39797,39792,39784,39780,39788,40188,40186,40189,40191,40183,40199,40192,40185,40187,40200,40197,40196,40579,40659,40719,40720,20764,20755,20759,20762,20753,20958,21300,21473,22128,22112,22126,22131,22118,22115,22125,22130,22110,22135,22300,22299,22728,22717,22729,22719,22714,22722,22716,22726,23319,23321,23323,23329,23316,23315,23312,23318,23336,23322,23328,23326,23535,23980,23985,23977,23975,23989,23984,23982,23978,23976,23986,23981,23983,23988,24167,24168,24166,24175,24297,24295,24294,24296,24293,24395,24508,24989,25000,24982,25029,25012,25030,25025,25036,25018,25023,25016,24972,25815,25814,25808,25807,25801,25789,25737,25795,25819,25843,25817,25907,25983,25980,26018,26312,26302,26304,26314,26315,26319,26301,26299,26298,26316,26403,27188,27238,27209,27239,27186,27240,27198,27229,27245,27254,27227,27217,27176,27226,27195,27199,27201,27242,27236,27216,27215,27220,27247,27241,27232,27196,27230,27222,27221,27213,27214,27206,27477,27476,27478,27559,27562,27563,27592,27591,27652,27651,27654,28589,28619,28579,28615,28604,28622,28616,28510,28612,28605,28574,28618,28584,28676,28581,28590,28602,28588,28586,28623,28607,28600,28578,28617,28587,28621,28591,28594,28592,29125,29122,29119,29112,29142,29120,29121,29131,29140,29130,29127,29135,29117,29144,29116,29126,29146,29147,29341,29342,29545,29542,29543,29548,29541,29547,29546,29823,29850,29856,29844,29842,29845,29857,29963,30080,30255,30253,30257,30269,30259,30268,30261,30258,30256,30395,30438,30618,30621,30625,30620,30619,30626,30627,30613,30617,30615,30941,30953,30949,30954,30942,30947,30939,30945,30946,30957,30943,30944,31140,31300,31304,31303,31414,31416,31413,31409,31415,31710,31715,31719,31709,31701,31717,31706,31720,31737,31700,31722,31714,31708,31723,31704,31711,31954,31956,31959,31952,31953,32274,32289,32279,32268,32287,32288,32275,32270,32284,32277,32282,32290,32267,32271,32278,32269,32276,32293,32292,32579,32635,32636,32634,32689,32751,32810,32809,32876,33201,33190,33198,33209,33205,33195,33200,33196,33204,33202,33207,33191,33266,33365,33366,33367,34134,34117,34155,34125,34131,34145,34136,34112,34118,34148,34113,34146,34116,34129,34119,34147,34110,34139,34161,34126,34158,34165,34133,34151,34144,34188,34150,34141,34132,34149,34156,34403,34405,34404,34715,34703,34711,34707,34706,34696,34689,34710,34712,34681,34695,34723,34693,34704,34705,34717,34692,34708,34716,34714,34697,35102,35110,35120,35117,35118,35111,35121,35106,35113,35107,35119,35116,35103,35313,35552,35554,35570,35572,35573,35549,35604,35556,35551,35568,35528,35550,35553,35560,35583,35567,35579,35985,35986,35984,36085,36078,36081,36080,36083,36204,36206,36261,36263,36403,36414,36408,36416,36421,36406,36412,36413,36417,36400,36415,36541,36662,36654,36661,36658,36665,36663,36660,36982,36985,36987,36998,37114,37171,37173,37174,37267,37264,37265,37261,37263,37671,37662,37640,37663,37638,37647,37754,37688,37692,37659,37667,37650,37633,37702,37677,37646,37645,37579,37661,37626,37669,37651,37625,37623,37684,37634,37668,37631,37673,37689,37685,37674,37652,37644,37643,37630,37641,37632,37627,37654,38332,38349,38334,38329,38330,38326,38335,38325,38333,38569,38612,38667,38674,38672,38809,38807,38804,38896,38904,38965,38959,38962,39204,39199,39207,39209,39326,39406,39404,39397,39396,39408,39395,39402,39401,39399,39609,39615,39604,39611,39670,39674,39673,39671,39731,39808,39813,39815,39804,39806,39803,39810,39827,39826,39824,39802,39829,39805,39816,40229,40215,40224,40222,40212,40233,40221,40216,40226,40208,40217,40223,40584,40582,40583,40622,40621,40661,40662,40698,40722,40765,20774,20773,20770,20772,20768,20777,21236,22163,22156,22157,22150,22148,22147,22142,22146,22143,22145,22742,22740,22735,22738,23341,23333,23346,23331,23340,23335,23334,23343,23342,23419,23537,23538,23991,24172,24170,24510,24507,25027,25013,25020,25063,25056,25061,25060,25064,25054,25839,25833,25827,25835,25828,25832,25985,25984,26038,26074,26322,27277,27286,27265,27301,27273,27295,27291,27297,27294,27271,27283,27278,27285,27267,27304,27300,27281,27263,27302,27290,27269,27276,27282,27483,27565,27657,28620,28585,28660,28628,28643,28636,28653,28647,28646,28638,28658,28637,28642,28648,29153,29169,29160,29170,29156,29168,29154,29555,29550,29551,29847,29874,29867,29840,29866,29869,29873,29861,29871,29968,29969,29970,29967,30084,30275,30280,30281,30279,30372,30441,30645,30635,30642,30647,30646,30644,30641,30632,30704,30963,30973,30978,30971,30972,30962,30981,30969,30974,30980,31147,31144,31324,31323,31318,31320,31316,31322,31422,31424,31425,31749,31759,31730,31744,31743,31739,31758,31732,31755,31731,31746,31753,31747,31745,31736,31741,31750,31728,31729,31760,31754,31976,32301,32316,32322,32307,38984,32312,32298,32329,32320,32327,32297,32332,32304,32315,32310,32324,32314,32581,32639,32638,32637,32756,32754,32812,33211,33220,33228,33226,33221,33223,33212,33257,33371,33370,33372,34179,34176,34191,34215,34197,34208,34187,34211,34171,34212,34202,34206,34167,34172,34185,34209,34170,34168,34135,34190,34198,34182,34189,34201,34205,34177,34210,34178,34184,34181,34169,34166,34200,34192,34207,34408,34750,34730,34733,34757,34736,34732,34745,34741,34748,34734,34761,34755,34754,34764,34743,34735,34756,34762,34740,34742,34751,34744,34749,34782,34738,35125,35123,35132,35134,35137,35154,35127,35138,35245,35247,35246,35314,35315,35614,35608,35606,35601,35589,35595,35618,35599,35602,35605,35591,35597,35592,35590,35612,35603,35610,35919,35952,35954,35953,35951,35989,35988,36089,36207,36430,36429,36435,36432,36428,36423,36675,36672,36997,36990,37176,37274,37282,37275,37273,37279,37281,37277,37280,37793,37763,37807,37732,37718,37703,37756,37720,37724,37750,37705,37712,37713,37728,37741,37775,37708,37738,37753,37719,37717,37714,37711,37745,37751,37755,37729,37726,37731,37735,37760,37710,37721,38343,38336,38345,38339,38341,38327,38574,38576,38572,38688,38687,38680,38685,38681,38810,38817,38812,38814,38813,38869,38868,38897,38977,38980,38986,38985,38981,38979,39205,39211,39212,39210,39219,39218,39215,39213,39217,39216,39320,39331,39329,39426,39418,39412,39415,39417,39416,39414,39419,39421,39422,39420,39427,39614,39678,39677,39681,39676,39752,39834,39848,39838,39835,39846,39841,39845,39844,39814,39842,39840,39855,40243,40257,40295,40246,40238,40239,40241,40248,40240,40261,40258,40259,40254,40247,40256,40253,32757,40237,40586,40585,40589,40624,40648,40666,40699,40703,40740,40739,40738,40788,40864,20785,20781,20782,22168,22172,22167,22170,22173,22169,22896,23356,23657,23658,24000,24173,24174,25048,25055,25069,25070,25073,25066,25072,25067,25046,25065,25855,25860,25853,25848,25857,25859,25852,26004,26075,26330,26331,26328,27333,27321,27325,27361,27334,27322,27318,27319,27335,27316,27309,27486,27593,27659,28679,28684,28685,28673,28677,28692,28686,28671,28672,28667,28710,28668,28663,28682,29185,29183,29177,29187,29181,29558,29880,29888,29877,29889,29886,29878,29883,29890,29972,29971,30300,30308,30297,30288,30291,30295,30298,30374,30397,30444,30658,30650,30975,30988,30995,30996,30985,30992,30994,30993,31149,31148,31327,31772,31785,31769,31776,31775,31789,31773,31782,31784,31778,31781,31792,32348,32336,32342,32355,32344,32354,32351,32337,32352,32343,32339,32693,32691,32759,32760,32885,33233,33234,33232,33375,33374,34228,34246,34240,34243,34242,34227,34229,34237,34247,34244,34239,34251,34254,34248,34245,34225,34230,34258,34340,34232,34231,34238,34409,34791,34790,34786,34779,34795,34794,34789,34783,34803,34788,34772,34780,34771,34797,34776,34787,34724,34775,34777,34817,34804,34792,34781,35155,35147,35151,35148,35142,35152,35153,35145,35626,35623,35619,35635,35632,35637,35655,35631,35644,35646,35633,35621,35639,35622,35638,35630,35620,35643,35645,35642,35906,35957,35993,35992,35991,36094,36100,36098,36096,36444,36450,36448,36439,36438,36446,36453,36455,36443,36442,36449,36445,36457,36436,36678,36679,36680,36683,37160,37178,37179,37182,37288,37285,37287,37295,37290,37813,37772,37778,37815,37787,37789,37769,37799,37774,37802,37790,37798,37781,37768,37785,37791,37773,37809,37777,37810,37796,37800,37812,37795,37797,38354,38355,38353,38579,38615,38618,24002,38623,38616,38621,38691,38690,38693,38828,38830,38824,38827,38820,38826,38818,38821,38871,38873,38870,38872,38906,38992,38993,38994,39096,39233,39228,39226,39439,39435,39433,39437,39428,39441,39434,39429,39431,39430,39616,39644,39688,39684,39685,39721,39733,39754,39756,39755,39879,39878,39875,39871,39873,39861,39864,39891,39862,39876,39865,39869,40284,40275,40271,40266,40283,40267,40281,40278,40268,40279,40274,40276,40287,40280,40282,40590,40588,40671,40705,40704,40726,40741,40747,40746,40745,40744,40780,40789,20788,20789,21142,21239,21428,22187,22189,22182,22183,22186,22188,22746,22749,22747,22802,23357,23358,23359,24003,24176,24511,25083,25863,25872,25869,25865,25868,25870,25988,26078,26077,26334,27367,27360,27340,27345,27353,27339,27359,27356,27344,27371,27343,27341,27358,27488,27568,27660,28697,28711,28704,28694,28715,28705,28706,28707,28713,28695,28708,28700,28714,29196,29194,29191,29186,29189,29349,29350,29348,29347,29345,29899,29893,29879,29891,29974,30304,30665,30666,30660,30705,31005,31003,31009,31004,30999,31006,31152,31335,31336,31795,31804,31801,31788,31803,31980,31978,32374,32373,32376,32368,32375,32367,32378,32370,32372,32360,32587,32586,32643,32646,32695,32765,32766,32888,33239,33237,33380,33377,33379,34283,34289,34285,34265,34273,34280,34266,34263,34284,34290,34296,34264,34271,34275,34268,34257,34288,34278,34287,34270,34274,34816,34810,34819,34806,34807,34825,34828,34827,34822,34812,34824,34815,34826,34818,35170,35162,35163,35159,35169,35164,35160,35165,35161,35208,35255,35254,35318,35664,35656,35658,35648,35667,35670,35668,35659,35669,35665,35650,35666,35671,35907,35959,35958,35994,36102,36103,36105,36268,36266,36269,36267,36461,36472,36467,36458,36463,36475,36546,36690,36689,36687,36688,36691,36788,37184,37183,37296,37293,37854,37831,37839,37826,37850,37840,37881,37868,37836,37849,37801,37862,37834,37844,37870,37859,37845,37828,37838,37824,37842,37863,38269,38362,38363,38625,38697,38699,38700,38696,38694,38835,38839,38838,38877,38878,38879,39004,39001,39005,38999,39103,39101,39099,39102,39240,39239,39235,39334,39335,39450,39445,39461,39453,39460,39451,39458,39456,39463,39459,39454,39452,39444,39618,39691,39690,39694,39692,39735,39914,39915,39904,39902,39908,39910,39906,39920,39892,39895,39916,39900,39897,39909,39893,39905,39898,40311,40321,40330,40324,40328,40305,40320,40312,40326,40331,40332,40317,40299,40308,40309,40304,40297,40325,40307,40315,40322,40303,40313,40319,40327,40296,40596,40593,40640,40700,40749,40768,40769,40781,40790,40791,40792,21303,22194,22197,22195,22755,23365,24006,24007,24302,24303,24512,24513,25081,25879,25878,25877,25875,26079,26344,26339,26340,27379,27376,27370,27368,27385,27377,27374,27375,28732,28725,28719,28727,28724,28721,28738,28728,28735,28730,28729,28736,28731,28723,28737,29203,29204,29352,29565,29564,29882,30379,30378,30398,30445,30668,30670,30671,30669,30706,31013,31011,31015,31016,31012,31017,31154,31342,31340,31341,31479,31817,31816,31818,31815,31813,31982,32379,32382,32385,32384,32698,32767,32889,33243,33241,33291,33384,33385,34338,34303,34305,34302,34331,34304,34294,34308,34313,34309,34316,34301,34841,34832,34833,34839,34835,34838,35171,35174,35257,35319,35680,35690,35677,35688,35683,35685,35687,35693,36270,36486,36488,36484,36697,36694,36695,36693,36696,36698,37005,37187,37185,37303,37301,37298,37299,37899,37907,37883,37920,37903,37908,37886,37909,37904,37928,37913,37901,37877,37888,37879,37895,37902,37910,37906,37882,37897,37880,37898,37887,37884,37900,37878,37905,37894,38366,38368,38367,38702,38703,38841,38843,38909,38910,39008,39010,39011,39007,39105,39106,39248,39246,39257,39244,39243,39251,39474,39476,39473,39468,39466,39478,39465,39470,39480,39469,39623,39626,39622,39696,39698,39697,39947,39944,39927,39941,39954,39928,40000,39943,39950,39942,39959,39956,39945,40351,40345,40356,40349,40338,40344,40336,40347,40352,40340,40348,40362,40343,40353,40346,40354,40360,40350,40355,40383,40361,40342,40358,40359,40601,40603,40602,40677,40676,40679,40678,40752,40750,40795,40800,40798,40797,40793,40849,20794,20793,21144,21143,22211,22205,22206,23368,23367,24011,24015,24305,25085,25883,27394,27388,27395,27384,27392,28739,28740,28746,28744,28745,28741,28742,29213,29210,29209,29566,29975,30314,30672,31021,31025,31023,31828,31827,31986,32394,32391,32392,32395,32390,32397,32589,32699,32816,33245,34328,34346,34342,34335,34339,34332,34329,34343,34350,34337,34336,34345,34334,34341,34857,34845,34843,34848,34852,34844,34859,34890,35181,35177,35182,35179,35322,35705,35704,35653,35706,35707,36112,36116,36271,36494,36492,36702,36699,36701,37190,37188,37189,37305,37951,37947,37942,37929,37949,37948,37936,37945,37930,37943,37932,37952,37937,38373,38372,38371,38709,38714,38847,38881,39012,39113,39110,39104,39256,39254,39481,39485,39494,39492,39490,39489,39482,39487,39629,39701,39703,39704,39702,39738,39762,39979,39965,39964,39980,39971,39976,39977,39972,39969,40375,40374,40380,40385,40391,40394,40399,40382,40389,40387,40379,40373,40398,40377,40378,40364,40392,40369,40365,40396,40371,40397,40370,40570,40604,40683,40686,40685,40731,40728,40730,40753,40782,40805,40804,40850,20153,22214,22213,22219,22897,23371,23372,24021,24017,24306,25889,25888,25894,25890,27403,27400,27401,27661,28757,28758,28759,28754,29214,29215,29353,29567,29912,29909,29913,29911,30317,30381,31029,31156,31344,31345,31831,31836,31833,31835,31834,31988,31985,32401,32591,32647,33246,33387,34356,34357,34355,34348,34354,34358,34860,34856,34854,34858,34853,35185,35263,35262,35323,35710,35716,35714,35718,35717,35711,36117,36501,36500,36506,36498,36496,36502,36503,36704,36706,37191,37964,37968,37962,37963,37967,37959,37957,37960,37961,37958,38719,38883,39018,39017,39115,39252,39259,39502,39507,39508,39500,39503,39496,39498,39497,39506,39504,39632,39705,39723,39739,39766,39765,40006,40008,39999,40004,39993,39987,40001,39996,39991,39988,39986,39997,39990,40411,40402,40414,40410,40395,40400,40412,40401,40415,40425,40409,40408,40406,40437,40405,40413,40630,40688,40757,40755,40754,40770,40811,40853,40866,20797,21145,22760,22759,22898,23373,24024,34863,24399,25089,25091,25092,25897,25893,26006,26347,27409,27410,27407,27594,28763,28762,29218,29570,29569,29571,30320,30676,31847,31846,32405,33388,34362,34368,34361,34364,34353,34363,34366,34864,34866,34862,34867,35190,35188,35187,35326,35724,35726,35723,35720,35909,36121,36504,36708,36707,37308,37986,37973,37981,37975,37982,38852,38853,38912,39510,39513,39710,39711,39712,40018,40024,40016,40010,40013,40011,40021,40025,40012,40014,40443,40439,40431,40419,40427,40440,40420,40438,40417,40430,40422,40434,40432,40418,40428,40436,40435,40424,40429,40642,40656,40690,40691,40710,40732,40760,40759,40758,40771,40783,40817,40816,40814,40815,22227,22221,23374,23661,25901,26349,26350,27411,28767,28769,28765,28768,29219,29915,29925,30677,31032,31159,31158,31850,32407,32649,33389,34371,34872,34871,34869,34891,35732,35733,36510,36511,36512,36509,37310,37309,37314,37995,37992,37993,38629,38726,38723,38727,38855,38885,39518,39637,39769,40035,40039,40038,40034,40030,40032,40450,40446,40455,40451,40454,40453,40448,40449,40457,40447,40445,40452,40608,40734,40774,40820,40821,40822,22228,25902,26040,27416,27417,27415,27418,28770,29222,29354,30680,30681,31033,31849,31851,31990,32410,32408,32411,32409,33248,33249,34374,34375,34376,35193,35194,35196,35195,35327,35736,35737,36517,36516,36515,37998,37997,37999,38001,38003,38729,39026,39263,40040,40046,40045,40459,40461,40464,40463,40466,40465,40609,40693,40713,40775,40824,40827,40826,40825,22302,28774,31855,34876,36274,36518,37315,38004,38008,38006,38005,39520,40052,40051,40049,40053,40468,40467,40694,40714,40868,28776,28773,31991,34410,34878,34877,34879,35742,35996,36521,36553,38731,39027,39028,39116,39265,39339,39524,39526,39527,39716,40469,40471,40776,25095,27422,29223,34380,36520,38018,38016,38017,39529,39528,39726,40473,29225,34379,35743,38019,40057,40631,30325,39531,40058,40477,28777,28778,40612,40830,40777,40856,30849,37561,35023,22715,24658,31911,23290,9556,9574,9559,9568,9580,9571,9562,9577,9565,9554,9572,9557,9566,9578,9569,9560,9575,9563,9555,9573,9558,9567,9579,9570,9561,9576,9564,9553,9552,9581,9582,9584,9583,65517,132423,37595,132575,147397,34124,17077,29679,20917,13897,149826,166372,37700,137691,33518,146632,30780,26436,25311,149811,166314,131744,158643,135941,20395,140525,20488,159017,162436,144896,150193,140563,20521,131966,24484,131968,131911,28379,132127,20605,20737,13434,20750,39020,14147,33814,149924,132231,20832,144308,20842,134143,139516,131813,140592,132494,143923,137603,23426,34685,132531,146585,20914,20920,40244,20937,20943,20945,15580,20947,150182,20915,20962,21314,20973,33741,26942,145197,24443,21003,21030,21052,21173,21079,21140,21177,21189,31765,34114,21216,34317,158483,21253,166622,21833,28377,147328,133460,147436,21299,21316,134114,27851,136998,26651,29653,24650,16042,14540,136936,29149,17570,21357,21364,165547,21374,21375,136598,136723,30694,21395,166555,21408,21419,21422,29607,153458,16217,29596,21441,21445,27721,20041,22526,21465,15019,134031,21472,147435,142755,21494,134263,21523,28793,21803,26199,27995,21613,158547,134516,21853,21647,21668,18342,136973,134877,15796,134477,166332,140952,21831,19693,21551,29719,21894,21929,22021,137431,147514,17746,148533,26291,135348,22071,26317,144010,26276,26285,22093,22095,30961,22257,38791,21502,22272,22255,22253,166758,13859,135759,22342,147877,27758,28811,22338,14001,158846,22502,136214,22531,136276,148323,22566,150517,22620,22698,13665,22752,22748,135740,22779,23551,22339,172368,148088,37843,13729,22815,26790,14019,28249,136766,23076,21843,136850,34053,22985,134478,158849,159018,137180,23001,137211,137138,159142,28017,137256,136917,23033,159301,23211,23139,14054,149929,23159,14088,23190,29797,23251,159649,140628,15749,137489,14130,136888,24195,21200,23414,25992,23420,162318,16388,18525,131588,23509,24928,137780,154060,132517,23539,23453,19728,23557,138052,23571,29646,23572,138405,158504,23625,18653,23685,23785,23791,23947,138745,138807,23824,23832,23878,138916,23738,24023,33532,14381,149761,139337,139635,33415,14390,15298,24110,27274,24181,24186,148668,134355,21414,20151,24272,21416,137073,24073,24308,164994,24313,24315,14496,24316,26686,37915,24333,131521,194708,15070,18606,135994,24378,157832,140240,24408,140401,24419,38845,159342,24434,37696,166454,24487,23990,15711,152144,139114,159992,140904,37334,131742,166441,24625,26245,137335,14691,15815,13881,22416,141236,31089,15936,24734,24740,24755,149890,149903,162387,29860,20705,23200,24932,33828,24898,194726,159442,24961,20980,132694,24967,23466,147383,141407,25043,166813,170333,25040,14642,141696,141505,24611,24924,25886,25483,131352,25285,137072,25301,142861,25452,149983,14871,25656,25592,136078,137212,25744,28554,142902,38932,147596,153373,25825,25829,38011,14950,25658,14935,25933,28438,150056,150051,25989,25965,25951,143486,26037,149824,19255,26065,16600,137257,26080,26083,24543,144384,26136,143863,143864,26180,143780,143781,26187,134773,26215,152038,26227,26228,138813,143921,165364,143816,152339,30661,141559,39332,26370,148380,150049,15147,27130,145346,26462,26471,26466,147917,168173,26583,17641,26658,28240,37436,26625,144358,159136,26717,144495,27105,27147,166623,26995,26819,144845,26881,26880,15666,14849,144956,15232,26540,26977,166474,17148,26934,27032,15265,132041,33635,20624,27129,144985,139562,27205,145155,27293,15347,26545,27336,168348,15373,27421,133411,24798,27445,27508,141261,28341,146139,132021,137560,14144,21537,146266,27617,147196,27612,27703,140427,149745,158545,27738,33318,27769,146876,17605,146877,147876,149772,149760,146633,14053,15595,134450,39811,143865,140433,32655,26679,159013,159137,159211,28054,27996,28284,28420,149887,147589,159346,34099,159604,20935,27804,28189,33838,166689,28207,146991,29779,147330,31180,28239,23185,143435,28664,14093,28573,146992,28410,136343,147517,17749,37872,28484,28508,15694,28532,168304,15675,28575,147780,28627,147601,147797,147513,147440,147380,147775,20959,147798,147799,147776,156125,28747,28798,28839,28801,28876,28885,28886,28895,16644,15848,29108,29078,148087,28971,28997,23176,29002,29038,23708,148325,29007,37730,148161,28972,148570,150055,150050,29114,166888,28861,29198,37954,29205,22801,37955,29220,37697,153093,29230,29248,149876,26813,29269,29271,15957,143428,26637,28477,29314,29482,29483,149539,165931,18669,165892,29480,29486,29647,29610,134202,158254,29641,29769,147938,136935,150052,26147,14021,149943,149901,150011,29687,29717,26883,150054,29753,132547,16087,29788,141485,29792,167602,29767,29668,29814,33721,29804,14128,29812,37873,27180,29826,18771,150156,147807,150137,166799,23366,166915,137374,29896,137608,29966,29929,29982,167641,137803,23511,167596,37765,30029,30026,30055,30062,151426,16132,150803,30094,29789,30110,30132,30210,30252,30289,30287,30319,30326,156661,30352,33263,14328,157969,157966,30369,30373,30391,30412,159647,33890,151709,151933,138780,30494,30502,30528,25775,152096,30552,144044,30639,166244,166248,136897,30708,30729,136054,150034,26826,30895,30919,30931,38565,31022,153056,30935,31028,30897,161292,36792,34948,166699,155779,140828,31110,35072,26882,31104,153687,31133,162617,31036,31145,28202,160038,16040,31174,168205,31188],
27012 "euc-kr":[44034,44035,44037,44038,44043,44044,44045,44046,44047,44056,44062,44063,44065,44066,44067,44069,44070,44071,44072,44073,44074,44075,44078,44082,44083,44084,null,null,null,null,null,null,44085,44086,44087,44090,44091,44093,44094,44095,44097,44098,44099,44100,44101,44102,44103,44104,44105,44106,44108,44110,44111,44112,44113,44114,44115,44117,null,null,null,null,null,null,44118,44119,44121,44122,44123,44125,44126,44127,44128,44129,44130,44131,44132,44133,44134,44135,44136,44137,44138,44139,44140,44141,44142,44143,44146,44147,44149,44150,44153,44155,44156,44157,44158,44159,44162,44167,44168,44173,44174,44175,44177,44178,44179,44181,44182,44183,44184,44185,44186,44187,44190,44194,44195,44196,44197,44198,44199,44203,44205,44206,44209,44210,44211,44212,44213,44214,44215,44218,44222,44223,44224,44226,44227,44229,44230,44231,44233,44234,44235,44237,44238,44239,44240,44241,44242,44243,44244,44246,44248,44249,44250,44251,44252,44253,44254,44255,44258,44259,44261,44262,44265,44267,44269,44270,44274,44276,44279,44280,44281,44282,44283,44286,44287,44289,44290,44291,44293,44295,44296,44297,44298,44299,44302,44304,44306,44307,44308,44309,44310,44311,44313,44314,44315,44317,44318,44319,44321,44322,44323,44324,44325,44326,44327,44328,44330,44331,44334,44335,44336,44337,44338,44339,null,null,null,null,null,null,44342,44343,44345,44346,44347,44349,44350,44351,44352,44353,44354,44355,44358,44360,44362,44363,44364,44365,44366,44367,44369,44370,44371,44373,44374,44375,null,null,null,null,null,null,44377,44378,44379,44380,44381,44382,44383,44384,44386,44388,44389,44390,44391,44392,44393,44394,44395,44398,44399,44401,44402,44407,44408,44409,44410,44414,44416,44419,44420,44421,44422,44423,44426,44427,44429,44430,44431,44433,44434,44435,44436,44437,44438,44439,44440,44441,44442,44443,44446,44447,44448,44449,44450,44451,44453,44454,44455,44456,44457,44458,44459,44460,44461,44462,44463,44464,44465,44466,44467,44468,44469,44470,44472,44473,44474,44475,44476,44477,44478,44479,44482,44483,44485,44486,44487,44489,44490,44491,44492,44493,44494,44495,44498,44500,44501,44502,44503,44504,44505,44506,44507,44509,44510,44511,44513,44514,44515,44517,44518,44519,44520,44521,44522,44523,44524,44525,44526,44527,44528,44529,44530,44531,44532,44533,44534,44535,44538,44539,44541,44542,44546,44547,44548,44549,44550,44551,44554,44556,44558,44559,44560,44561,44562,44563,44565,44566,44567,44568,44569,44570,44571,44572,null,null,null,null,null,null,44573,44574,44575,44576,44577,44578,44579,44580,44581,44582,44583,44584,44585,44586,44587,44588,44589,44590,44591,44594,44595,44597,44598,44601,44603,44604,null,null,null,null,null,null,44605,44606,44607,44610,44612,44615,44616,44617,44619,44623,44625,44626,44627,44629,44631,44632,44633,44634,44635,44638,44642,44643,44644,44646,44647,44650,44651,44653,44654,44655,44657,44658,44659,44660,44661,44662,44663,44666,44670,44671,44672,44673,44674,44675,44678,44679,44680,44681,44682,44683,44685,44686,44687,44688,44689,44690,44691,44692,44693,44694,44695,44696,44697,44698,44699,44700,44701,44702,44703,44704,44705,44706,44707,44708,44709,44710,44711,44712,44713,44714,44715,44716,44717,44718,44719,44720,44721,44722,44723,44724,44725,44726,44727,44728,44729,44730,44731,44735,44737,44738,44739,44741,44742,44743,44744,44745,44746,44747,44750,44754,44755,44756,44757,44758,44759,44762,44763,44765,44766,44767,44768,44769,44770,44771,44772,44773,44774,44775,44777,44778,44780,44782,44783,44784,44785,44786,44787,44789,44790,44791,44793,44794,44795,44797,44798,44799,44800,44801,44802,44803,44804,44805,null,null,null,null,null,null,44806,44809,44810,44811,44812,44814,44815,44817,44818,44819,44820,44821,44822,44823,44824,44825,44826,44827,44828,44829,44830,44831,44832,44833,44834,44835,null,null,null,null,null,null,44836,44837,44838,44839,44840,44841,44842,44843,44846,44847,44849,44851,44853,44854,44855,44856,44857,44858,44859,44862,44864,44868,44869,44870,44871,44874,44875,44876,44877,44878,44879,44881,44882,44883,44884,44885,44886,44887,44888,44889,44890,44891,44894,44895,44896,44897,44898,44899,44902,44903,44904,44905,44906,44907,44908,44909,44910,44911,44912,44913,44914,44915,44916,44917,44918,44919,44920,44922,44923,44924,44925,44926,44927,44929,44930,44931,44933,44934,44935,44937,44938,44939,44940,44941,44942,44943,44946,44947,44948,44950,44951,44952,44953,44954,44955,44957,44958,44959,44960,44961,44962,44963,44964,44965,44966,44967,44968,44969,44970,44971,44972,44973,44974,44975,44976,44977,44978,44979,44980,44981,44982,44983,44986,44987,44989,44990,44991,44993,44994,44995,44996,44997,44998,45002,45004,45007,45008,45009,45010,45011,45013,45014,45015,45016,45017,45018,45019,45021,45022,45023,45024,45025,null,null,null,null,null,null,45026,45027,45028,45029,45030,45031,45034,45035,45036,45037,45038,45039,45042,45043,45045,45046,45047,45049,45050,45051,45052,45053,45054,45055,45058,45059,null,null,null,null,null,null,45061,45062,45063,45064,45065,45066,45067,45069,45070,45071,45073,45074,45075,45077,45078,45079,45080,45081,45082,45083,45086,45087,45088,45089,45090,45091,45092,45093,45094,45095,45097,45098,45099,45100,45101,45102,45103,45104,45105,45106,45107,45108,45109,45110,45111,45112,45113,45114,45115,45116,45117,45118,45119,45120,45121,45122,45123,45126,45127,45129,45131,45133,45135,45136,45137,45138,45142,45144,45146,45147,45148,45150,45151,45152,45153,45154,45155,45156,45157,45158,45159,45160,45161,45162,45163,45164,45165,45166,45167,45168,45169,45170,45171,45172,45173,45174,45175,45176,45177,45178,45179,45182,45183,45185,45186,45187,45189,45190,45191,45192,45193,45194,45195,45198,45200,45202,45203,45204,45205,45206,45207,45211,45213,45214,45219,45220,45221,45222,45223,45226,45232,45234,45238,45239,45241,45242,45243,45245,45246,45247,45248,45249,45250,45251,45254,45258,45259,45260,45261,45262,45263,45266,null,null,null,null,null,null,45267,45269,45270,45271,45273,45274,45275,45276,45277,45278,45279,45281,45282,45283,45284,45286,45287,45288,45289,45290,45291,45292,45293,45294,45295,45296,null,null,null,null,null,null,45297,45298,45299,45300,45301,45302,45303,45304,45305,45306,45307,45308,45309,45310,45311,45312,45313,45314,45315,45316,45317,45318,45319,45322,45325,45326,45327,45329,45332,45333,45334,45335,45338,45342,45343,45344,45345,45346,45350,45351,45353,45354,45355,45357,45358,45359,45360,45361,45362,45363,45366,45370,45371,45372,45373,45374,45375,45378,45379,45381,45382,45383,45385,45386,45387,45388,45389,45390,45391,45394,45395,45398,45399,45401,45402,45403,45405,45406,45407,45409,45410,45411,45412,45413,45414,45415,45416,45417,45418,45419,45420,45421,45422,45423,45424,45425,45426,45427,45428,45429,45430,45431,45434,45435,45437,45438,45439,45441,45443,45444,45445,45446,45447,45450,45452,45454,45455,45456,45457,45461,45462,45463,45465,45466,45467,45469,45470,45471,45472,45473,45474,45475,45476,45477,45478,45479,45481,45482,45483,45484,45485,45486,45487,45488,45489,45490,45491,45492,45493,45494,45495,45496,null,null,null,null,null,null,45497,45498,45499,45500,45501,45502,45503,45504,45505,45506,45507,45508,45509,45510,45511,45512,45513,45514,45515,45517,45518,45519,45521,45522,45523,45525,null,null,null,null,null,null,45526,45527,45528,45529,45530,45531,45534,45536,45537,45538,45539,45540,45541,45542,45543,45546,45547,45549,45550,45551,45553,45554,45555,45556,45557,45558,45559,45560,45562,45564,45566,45567,45568,45569,45570,45571,45574,45575,45577,45578,45581,45582,45583,45584,45585,45586,45587,45590,45592,45594,45595,45596,45597,45598,45599,45601,45602,45603,45604,45605,45606,45607,45608,45609,45610,45611,45612,45613,45614,45615,45616,45617,45618,45619,45621,45622,45623,45624,45625,45626,45627,45629,45630,45631,45632,45633,45634,45635,45636,45637,45638,45639,45640,45641,45642,45643,45644,45645,45646,45647,45648,45649,45650,45651,45652,45653,45654,45655,45657,45658,45659,45661,45662,45663,45665,45666,45667,45668,45669,45670,45671,45674,45675,45676,45677,45678,45679,45680,45681,45682,45683,45686,45687,45688,45689,45690,45691,45693,45694,45695,45696,45697,45698,45699,45702,45703,45704,45706,45707,45708,45709,45710,null,null,null,null,null,null,45711,45714,45715,45717,45718,45719,45723,45724,45725,45726,45727,45730,45732,45735,45736,45737,45739,45741,45742,45743,45745,45746,45747,45749,45750,45751,null,null,null,null,null,null,45752,45753,45754,45755,45756,45757,45758,45759,45760,45761,45762,45763,45764,45765,45766,45767,45770,45771,45773,45774,45775,45777,45779,45780,45781,45782,45783,45786,45788,45790,45791,45792,45793,45795,45799,45801,45802,45808,45809,45810,45814,45820,45821,45822,45826,45827,45829,45830,45831,45833,45834,45835,45836,45837,45838,45839,45842,45846,45847,45848,45849,45850,45851,45853,45854,45855,45856,45857,45858,45859,45860,45861,45862,45863,45864,45865,45866,45867,45868,45869,45870,45871,45872,45873,45874,45875,45876,45877,45878,45879,45880,45881,45882,45883,45884,45885,45886,45887,45888,45889,45890,45891,45892,45893,45894,45895,45896,45897,45898,45899,45900,45901,45902,45903,45904,45905,45906,45907,45911,45913,45914,45917,45920,45921,45922,45923,45926,45928,45930,45932,45933,45935,45938,45939,45941,45942,45943,45945,45946,45947,45948,45949,45950,45951,45954,45958,45959,45960,45961,45962,45963,45965,null,null,null,null,null,null,45966,45967,45969,45970,45971,45973,45974,45975,45976,45977,45978,45979,45980,45981,45982,45983,45986,45987,45988,45989,45990,45991,45993,45994,45995,45997,null,null,null,null,null,null,45998,45999,46000,46001,46002,46003,46004,46005,46006,46007,46008,46009,46010,46011,46012,46013,46014,46015,46016,46017,46018,46019,46022,46023,46025,46026,46029,46031,46033,46034,46035,46038,46040,46042,46044,46046,46047,46049,46050,46051,46053,46054,46055,46057,46058,46059,46060,46061,46062,46063,46064,46065,46066,46067,46068,46069,46070,46071,46072,46073,46074,46075,46077,46078,46079,46080,46081,46082,46083,46084,46085,46086,46087,46088,46089,46090,46091,46092,46093,46094,46095,46097,46098,46099,46100,46101,46102,46103,46105,46106,46107,46109,46110,46111,46113,46114,46115,46116,46117,46118,46119,46122,46124,46125,46126,46127,46128,46129,46130,46131,46133,46134,46135,46136,46137,46138,46139,46140,46141,46142,46143,46144,46145,46146,46147,46148,46149,46150,46151,46152,46153,46154,46155,46156,46157,46158,46159,46162,46163,46165,46166,46167,46169,46170,46171,46172,46173,46174,46175,46178,46180,46182,null,null,null,null,null,null,46183,46184,46185,46186,46187,46189,46190,46191,46192,46193,46194,46195,46196,46197,46198,46199,46200,46201,46202,46203,46204,46205,46206,46207,46209,46210,null,null,null,null,null,null,46211,46212,46213,46214,46215,46217,46218,46219,46220,46221,46222,46223,46224,46225,46226,46227,46228,46229,46230,46231,46232,46233,46234,46235,46236,46238,46239,46240,46241,46242,46243,46245,46246,46247,46249,46250,46251,46253,46254,46255,46256,46257,46258,46259,46260,46262,46264,46266,46267,46268,46269,46270,46271,46273,46274,46275,46277,46278,46279,46281,46282,46283,46284,46285,46286,46287,46289,46290,46291,46292,46294,46295,46296,46297,46298,46299,46302,46303,46305,46306,46309,46311,46312,46313,46314,46315,46318,46320,46322,46323,46324,46325,46326,46327,46329,46330,46331,46332,46333,46334,46335,46336,46337,46338,46339,46340,46341,46342,46343,46344,46345,46346,46347,46348,46349,46350,46351,46352,46353,46354,46355,46358,46359,46361,46362,46365,46366,46367,46368,46369,46370,46371,46374,46379,46380,46381,46382,46383,46386,46387,46389,46390,46391,46393,46394,46395,46396,46397,46398,46399,46402,46406,null,null,null,null,null,null,46407,46408,46409,46410,46414,46415,46417,46418,46419,46421,46422,46423,46424,46425,46426,46427,46430,46434,46435,46436,46437,46438,46439,46440,46441,46442,null,null,null,null,null,null,46443,46444,46445,46446,46447,46448,46449,46450,46451,46452,46453,46454,46455,46456,46457,46458,46459,46460,46461,46462,46463,46464,46465,46466,46467,46468,46469,46470,46471,46472,46473,46474,46475,46476,46477,46478,46479,46480,46481,46482,46483,46484,46485,46486,46487,46488,46489,46490,46491,46492,46493,46494,46495,46498,46499,46501,46502,46503,46505,46508,46509,46510,46511,46514,46518,46519,46520,46521,46522,46526,46527,46529,46530,46531,46533,46534,46535,46536,46537,46538,46539,46542,46546,46547,46548,46549,46550,46551,46553,46554,46555,46556,46557,46558,46559,46560,46561,46562,46563,46564,46565,46566,46567,46568,46569,46570,46571,46573,46574,46575,46576,46577,46578,46579,46580,46581,46582,46583,46584,46585,46586,46587,46588,46589,46590,46591,46592,46593,46594,46595,46596,46597,46598,46599,46600,46601,46602,46603,46604,46605,46606,46607,46610,46611,46613,46614,46615,46617,46618,46619,46620,46621,null,null,null,null,null,null,46622,46623,46624,46625,46626,46627,46628,46630,46631,46632,46633,46634,46635,46637,46638,46639,46640,46641,46642,46643,46645,46646,46647,46648,46649,46650,null,null,null,null,null,null,46651,46652,46653,46654,46655,46656,46657,46658,46659,46660,46661,46662,46663,46665,46666,46667,46668,46669,46670,46671,46672,46673,46674,46675,46676,46677,46678,46679,46680,46681,46682,46683,46684,46685,46686,46687,46688,46689,46690,46691,46693,46694,46695,46697,46698,46699,46700,46701,46702,46703,46704,46705,46706,46707,46708,46709,46710,46711,46712,46713,46714,46715,46716,46717,46718,46719,46720,46721,46722,46723,46724,46725,46726,46727,46728,46729,46730,46731,46732,46733,46734,46735,46736,46737,46738,46739,46740,46741,46742,46743,46744,46745,46746,46747,46750,46751,46753,46754,46755,46757,46758,46759,46760,46761,46762,46765,46766,46767,46768,46770,46771,46772,46773,46774,46775,46776,46777,46778,46779,46780,46781,46782,46783,46784,46785,46786,46787,46788,46789,46790,46791,46792,46793,46794,46795,46796,46797,46798,46799,46800,46801,46802,46803,46805,46806,46807,46808,46809,46810,46811,46812,46813,null,null,null,null,null,null,46814,46815,46816,46817,46818,46819,46820,46821,46822,46823,46824,46825,46826,46827,46828,46829,46830,46831,46833,46834,46835,46837,46838,46839,46841,46842,null,null,null,null,null,null,46843,46844,46845,46846,46847,46850,46851,46852,46854,46855,46856,46857,46858,46859,46860,46861,46862,46863,46864,46865,46866,46867,46868,46869,46870,46871,46872,46873,46874,46875,46876,46877,46878,46879,46880,46881,46882,46883,46884,46885,46886,46887,46890,46891,46893,46894,46897,46898,46899,46900,46901,46902,46903,46906,46908,46909,46910,46911,46912,46913,46914,46915,46917,46918,46919,46921,46922,46923,46925,46926,46927,46928,46929,46930,46931,46934,46935,46936,46937,46938,46939,46940,46941,46942,46943,46945,46946,46947,46949,46950,46951,46953,46954,46955,46956,46957,46958,46959,46962,46964,46966,46967,46968,46969,46970,46971,46974,46975,46977,46978,46979,46981,46982,46983,46984,46985,46986,46987,46990,46995,46996,46997,47002,47003,47005,47006,47007,47009,47010,47011,47012,47013,47014,47015,47018,47022,47023,47024,47025,47026,47027,47030,47031,47033,47034,47035,47036,47037,47038,47039,47040,47041,null,null,null,null,null,null,47042,47043,47044,47045,47046,47048,47050,47051,47052,47053,47054,47055,47056,47057,47058,47059,47060,47061,47062,47063,47064,47065,47066,47067,47068,47069,null,null,null,null,null,null,47070,47071,47072,47073,47074,47075,47076,47077,47078,47079,47080,47081,47082,47083,47086,47087,47089,47090,47091,47093,47094,47095,47096,47097,47098,47099,47102,47106,47107,47108,47109,47110,47114,47115,47117,47118,47119,47121,47122,47123,47124,47125,47126,47127,47130,47132,47134,47135,47136,47137,47138,47139,47142,47143,47145,47146,47147,47149,47150,47151,47152,47153,47154,47155,47158,47162,47163,47164,47165,47166,47167,47169,47170,47171,47173,47174,47175,47176,47177,47178,47179,47180,47181,47182,47183,47184,47186,47188,47189,47190,47191,47192,47193,47194,47195,47198,47199,47201,47202,47203,47205,47206,47207,47208,47209,47210,47211,47214,47216,47218,47219,47220,47221,47222,47223,47225,47226,47227,47229,47230,47231,47232,47233,47234,47235,47236,47237,47238,47239,47240,47241,47242,47243,47244,47246,47247,47248,47249,47250,47251,47252,47253,47254,47255,47256,47257,47258,47259,47260,47261,47262,47263,null,null,null,null,null,null,47264,47265,47266,47267,47268,47269,47270,47271,47273,47274,47275,47276,47277,47278,47279,47281,47282,47283,47285,47286,47287,47289,47290,47291,47292,47293,null,null,null,null,null,null,47294,47295,47298,47300,47302,47303,47304,47305,47306,47307,47309,47310,47311,47313,47314,47315,47317,47318,47319,47320,47321,47322,47323,47324,47326,47328,47330,47331,47332,47333,47334,47335,47338,47339,47341,47342,47343,47345,47346,47347,47348,47349,47350,47351,47354,47356,47358,47359,47360,47361,47362,47363,47365,47366,47367,47368,47369,47370,47371,47372,47373,47374,47375,47376,47377,47378,47379,47380,47381,47382,47383,47385,47386,47387,47388,47389,47390,47391,47393,47394,47395,47396,47397,47398,47399,47400,47401,47402,47403,47404,47405,47406,47407,47408,47409,47410,47411,47412,47413,47414,47415,47416,47417,47418,47419,47422,47423,47425,47426,47427,47429,47430,47431,47432,47433,47434,47435,47437,47438,47440,47442,47443,47444,47445,47446,47447,47450,47451,47453,47454,47455,47457,47458,47459,47460,47461,47462,47463,47466,47468,47470,47471,47472,47473,47474,47475,47478,47479,47481,47482,47483,47485,null,null,null,null,null,null,47486,47487,47488,47489,47490,47491,47494,47496,47499,47500,47503,47504,47505,47506,47507,47508,47509,47510,47511,47512,47513,47514,47515,47516,47517,47518,null,null,null,null,null,null,47519,47520,47521,47522,47523,47524,47525,47526,47527,47528,47529,47530,47531,47534,47535,47537,47538,47539,47541,47542,47543,47544,47545,47546,47547,47550,47552,47554,47555,47556,47557,47558,47559,47562,47563,47565,47571,47572,47573,47574,47575,47578,47580,47583,47584,47586,47590,47591,47593,47594,47595,47597,47598,47599,47600,47601,47602,47603,47606,47611,47612,47613,47614,47615,47618,47619,47620,47621,47622,47623,47625,47626,47627,47628,47629,47630,47631,47632,47633,47634,47635,47636,47638,47639,47640,47641,47642,47643,47644,47645,47646,47647,47648,47649,47650,47651,47652,47653,47654,47655,47656,47657,47658,47659,47660,47661,47662,47663,47664,47665,47666,47667,47668,47669,47670,47671,47674,47675,47677,47678,47679,47681,47683,47684,47685,47686,47687,47690,47692,47695,47696,47697,47698,47702,47703,47705,47706,47707,47709,47710,47711,47712,47713,47714,47715,47718,47722,47723,47724,47725,47726,47727,null,null,null,null,null,null,47730,47731,47733,47734,47735,47737,47738,47739,47740,47741,47742,47743,47744,47745,47746,47750,47752,47753,47754,47755,47757,47758,47759,47760,47761,47762,null,null,null,null,null,null,47763,47764,47765,47766,47767,47768,47769,47770,47771,47772,47773,47774,47775,47776,47777,47778,47779,47780,47781,47782,47783,47786,47789,47790,47791,47793,47795,47796,47797,47798,47799,47802,47804,47806,47807,47808,47809,47810,47811,47813,47814,47815,47817,47818,47819,47820,47821,47822,47823,47824,47825,47826,47827,47828,47829,47830,47831,47834,47835,47836,47837,47838,47839,47840,47841,47842,47843,47844,47845,47846,47847,47848,47849,47850,47851,47852,47853,47854,47855,47856,47857,47858,47859,47860,47861,47862,47863,47864,47865,47866,47867,47869,47870,47871,47873,47874,47875,47877,47878,47879,47880,47881,47882,47883,47884,47886,47888,47890,47891,47892,47893,47894,47895,47897,47898,47899,47901,47902,47903,47905,47906,47907,47908,47909,47910,47911,47912,47914,47916,47917,47918,47919,47920,47921,47922,47923,47927,47929,47930,47935,47936,47937,47938,47939,47942,47944,47946,47947,47948,47950,47953,47954,null,null,null,null,null,null,47955,47957,47958,47959,47961,47962,47963,47964,47965,47966,47967,47968,47970,47972,47973,47974,47975,47976,47977,47978,47979,47981,47982,47983,47984,47985,null,null,null,null,null,null,47986,47987,47988,47989,47990,47991,47992,47993,47994,47995,47996,47997,47998,47999,48000,48001,48002,48003,48004,48005,48006,48007,48009,48010,48011,48013,48014,48015,48017,48018,48019,48020,48021,48022,48023,48024,48025,48026,48027,48028,48029,48030,48031,48032,48033,48034,48035,48037,48038,48039,48041,48042,48043,48045,48046,48047,48048,48049,48050,48051,48053,48054,48056,48057,48058,48059,48060,48061,48062,48063,48065,48066,48067,48069,48070,48071,48073,48074,48075,48076,48077,48078,48079,48081,48082,48084,48085,48086,48087,48088,48089,48090,48091,48092,48093,48094,48095,48096,48097,48098,48099,48100,48101,48102,48103,48104,48105,48106,48107,48108,48109,48110,48111,48112,48113,48114,48115,48116,48117,48118,48119,48122,48123,48125,48126,48129,48131,48132,48133,48134,48135,48138,48142,48144,48146,48147,48153,48154,48160,48161,48162,48163,48166,48168,48170,48171,48172,48174,48175,48178,48179,48181,null,null,null,null,null,null,48182,48183,48185,48186,48187,48188,48189,48190,48191,48194,48198,48199,48200,48202,48203,48206,48207,48209,48210,48211,48212,48213,48214,48215,48216,48217,null,null,null,null,null,null,48218,48219,48220,48222,48223,48224,48225,48226,48227,48228,48229,48230,48231,48232,48233,48234,48235,48236,48237,48238,48239,48240,48241,48242,48243,48244,48245,48246,48247,48248,48249,48250,48251,48252,48253,48254,48255,48256,48257,48258,48259,48262,48263,48265,48266,48269,48271,48272,48273,48274,48275,48278,48280,48283,48284,48285,48286,48287,48290,48291,48293,48294,48297,48298,48299,48300,48301,48302,48303,48306,48310,48311,48312,48313,48314,48315,48318,48319,48321,48322,48323,48325,48326,48327,48328,48329,48330,48331,48332,48334,48338,48339,48340,48342,48343,48345,48346,48347,48349,48350,48351,48352,48353,48354,48355,48356,48357,48358,48359,48360,48361,48362,48363,48364,48365,48366,48367,48368,48369,48370,48371,48375,48377,48378,48379,48381,48382,48383,48384,48385,48386,48387,48390,48392,48394,48395,48396,48397,48398,48399,48401,48402,48403,48405,48406,48407,48408,48409,48410,48411,48412,48413,null,null,null,null,null,null,48414,48415,48416,48417,48418,48419,48421,48422,48423,48424,48425,48426,48427,48429,48430,48431,48432,48433,48434,48435,48436,48437,48438,48439,48440,48441,null,null,null,null,null,null,48442,48443,48444,48445,48446,48447,48449,48450,48451,48452,48453,48454,48455,48458,48459,48461,48462,48463,48465,48466,48467,48468,48469,48470,48471,48474,48475,48476,48477,48478,48479,48480,48481,48482,48483,48485,48486,48487,48489,48490,48491,48492,48493,48494,48495,48496,48497,48498,48499,48500,48501,48502,48503,48504,48505,48506,48507,48508,48509,48510,48511,48514,48515,48517,48518,48523,48524,48525,48526,48527,48530,48532,48534,48535,48536,48539,48541,48542,48543,48544,48545,48546,48547,48549,48550,48551,48552,48553,48554,48555,48556,48557,48558,48559,48561,48562,48563,48564,48565,48566,48567,48569,48570,48571,48572,48573,48574,48575,48576,48577,48578,48579,48580,48581,48582,48583,48584,48585,48586,48587,48588,48589,48590,48591,48592,48593,48594,48595,48598,48599,48601,48602,48603,48605,48606,48607,48608,48609,48610,48611,48612,48613,48614,48615,48616,48618,48619,48620,48621,48622,48623,48625,null,null,null,null,null,null,48626,48627,48629,48630,48631,48633,48634,48635,48636,48637,48638,48639,48641,48642,48644,48646,48647,48648,48649,48650,48651,48654,48655,48657,48658,48659,null,null,null,null,null,null,48661,48662,48663,48664,48665,48666,48667,48670,48672,48673,48674,48675,48676,48677,48678,48679,48680,48681,48682,48683,48684,48685,48686,48687,48688,48689,48690,48691,48692,48693,48694,48695,48696,48697,48698,48699,48700,48701,48702,48703,48704,48705,48706,48707,48710,48711,48713,48714,48715,48717,48719,48720,48721,48722,48723,48726,48728,48732,48733,48734,48735,48738,48739,48741,48742,48743,48745,48747,48748,48749,48750,48751,48754,48758,48759,48760,48761,48762,48766,48767,48769,48770,48771,48773,48774,48775,48776,48777,48778,48779,48782,48786,48787,48788,48789,48790,48791,48794,48795,48796,48797,48798,48799,48800,48801,48802,48803,48804,48805,48806,48807,48809,48810,48811,48812,48813,48814,48815,48816,48817,48818,48819,48820,48821,48822,48823,48824,48825,48826,48827,48828,48829,48830,48831,48832,48833,48834,48835,48836,48837,48838,48839,48840,48841,48842,48843,48844,48845,48846,48847,48850,48851,null,null,null,null,null,null,48853,48854,48857,48858,48859,48860,48861,48862,48863,48865,48866,48870,48871,48872,48873,48874,48875,48877,48878,48879,48880,48881,48882,48883,48884,48885,null,null,null,null,null,null,48886,48887,48888,48889,48890,48891,48892,48893,48894,48895,48896,48898,48899,48900,48901,48902,48903,48906,48907,48908,48909,48910,48911,48912,48913,48914,48915,48916,48917,48918,48919,48922,48926,48927,48928,48929,48930,48931,48932,48933,48934,48935,48936,48937,48938,48939,48940,48941,48942,48943,48944,48945,48946,48947,48948,48949,48950,48951,48952,48953,48954,48955,48956,48957,48958,48959,48962,48963,48965,48966,48967,48969,48970,48971,48972,48973,48974,48975,48978,48979,48980,48982,48983,48984,48985,48986,48987,48988,48989,48990,48991,48992,48993,48994,48995,48996,48997,48998,48999,49000,49001,49002,49003,49004,49005,49006,49007,49008,49009,49010,49011,49012,49013,49014,49015,49016,49017,49018,49019,49020,49021,49022,49023,49024,49025,49026,49027,49028,49029,49030,49031,49032,49033,49034,49035,49036,49037,49038,49039,49040,49041,49042,49043,49045,49046,49047,49048,49049,49050,49051,49052,49053,null,null,null,null,null,null,49054,49055,49056,49057,49058,49059,49060,49061,49062,49063,49064,49065,49066,49067,49068,49069,49070,49071,49073,49074,49075,49076,49077,49078,49079,49080,null,null,null,null,null,null,49081,49082,49083,49084,49085,49086,49087,49088,49089,49090,49091,49092,49094,49095,49096,49097,49098,49099,49102,49103,49105,49106,49107,49109,49110,49111,49112,49113,49114,49115,49117,49118,49120,49122,49123,49124,49125,49126,49127,49128,49129,49130,49131,49132,49133,49134,49135,49136,49137,49138,49139,49140,49141,49142,49143,49144,49145,49146,49147,49148,49149,49150,49151,49152,49153,49154,49155,49156,49157,49158,49159,49160,49161,49162,49163,49164,49165,49166,49167,49168,49169,49170,49171,49172,49173,49174,49175,49176,49177,49178,49179,49180,49181,49182,49183,49184,49185,49186,49187,49188,49189,49190,49191,49192,49193,49194,49195,49196,49197,49198,49199,49200,49201,49202,49203,49204,49205,49206,49207,49208,49209,49210,49211,49213,49214,49215,49216,49217,49218,49219,49220,49221,49222,49223,49224,49225,49226,49227,49228,49229,49230,49231,49232,49234,49235,49236,49237,49238,49239,49241,49242,49243,null,null,null,null,null,null,49245,49246,49247,49249,49250,49251,49252,49253,49254,49255,49258,49259,49260,49261,49262,49263,49264,49265,49266,49267,49268,49269,49270,49271,49272,49273,null,null,null,null,null,null,49274,49275,49276,49277,49278,49279,49280,49281,49282,49283,49284,49285,49286,49287,49288,49289,49290,49291,49292,49293,49294,49295,49298,49299,49301,49302,49303,49305,49306,49307,49308,49309,49310,49311,49314,49316,49318,49319,49320,49321,49322,49323,49326,49329,49330,49335,49336,49337,49338,49339,49342,49346,49347,49348,49350,49351,49354,49355,49357,49358,49359,49361,49362,49363,49364,49365,49366,49367,49370,49374,49375,49376,49377,49378,49379,49382,49383,49385,49386,49387,49389,49390,49391,49392,49393,49394,49395,49398,49400,49402,49403,49404,49405,49406,49407,49409,49410,49411,49413,49414,49415,49417,49418,49419,49420,49421,49422,49423,49425,49426,49427,49428,49430,49431,49432,49433,49434,49435,49441,49442,49445,49448,49449,49450,49451,49454,49458,49459,49460,49461,49463,49466,49467,49469,49470,49471,49473,49474,49475,49476,49477,49478,49479,49482,49486,49487,49488,49489,49490,49491,49494,49495,null,null,null,null,null,null,49497,49498,49499,49501,49502,49503,49504,49505,49506,49507,49510,49514,49515,49516,49517,49518,49519,49521,49522,49523,49525,49526,49527,49529,49530,49531,null,null,null,null,null,null,49532,49533,49534,49535,49536,49537,49538,49539,49540,49542,49543,49544,49545,49546,49547,49551,49553,49554,49555,49557,49559,49560,49561,49562,49563,49566,49568,49570,49571,49572,49574,49575,49578,49579,49581,49582,49583,49585,49586,49587,49588,49589,49590,49591,49592,49593,49594,49595,49596,49598,49599,49600,49601,49602,49603,49605,49606,49607,49609,49610,49611,49613,49614,49615,49616,49617,49618,49619,49621,49622,49625,49626,49627,49628,49629,49630,49631,49633,49634,49635,49637,49638,49639,49641,49642,49643,49644,49645,49646,49647,49650,49652,49653,49654,49655,49656,49657,49658,49659,49662,49663,49665,49666,49667,49669,49670,49671,49672,49673,49674,49675,49678,49680,49682,49683,49684,49685,49686,49687,49690,49691,49693,49694,49697,49698,49699,49700,49701,49702,49703,49706,49708,49710,49712,49715,49717,49718,49719,49720,49721,49722,49723,49724,49725,49726,49727,49728,49729,49730,49731,49732,49733,null,null,null,null,null,null,49734,49735,49737,49738,49739,49740,49741,49742,49743,49746,49747,49749,49750,49751,49753,49754,49755,49756,49757,49758,49759,49761,49762,49763,49764,49766,null,null,null,null,null,null,49767,49768,49769,49770,49771,49774,49775,49777,49778,49779,49781,49782,49783,49784,49785,49786,49787,49790,49792,49794,49795,49796,49797,49798,49799,49802,49803,49804,49805,49806,49807,49809,49810,49811,49812,49813,49814,49815,49817,49818,49820,49822,49823,49824,49825,49826,49827,49830,49831,49833,49834,49835,49838,49839,49840,49841,49842,49843,49846,49848,49850,49851,49852,49853,49854,49855,49856,49857,49858,49859,49860,49861,49862,49863,49864,49865,49866,49867,49868,49869,49870,49871,49872,49873,49874,49875,49876,49877,49878,49879,49880,49881,49882,49883,49886,49887,49889,49890,49893,49894,49895,49896,49897,49898,49902,49904,49906,49907,49908,49909,49911,49914,49917,49918,49919,49921,49922,49923,49924,49925,49926,49927,49930,49931,49934,49935,49936,49937,49938,49942,49943,49945,49946,49947,49949,49950,49951,49952,49953,49954,49955,49958,49959,49962,49963,49964,49965,49966,49967,49968,49969,49970,null,null,null,null,null,null,49971,49972,49973,49974,49975,49976,49977,49978,49979,49980,49981,49982,49983,49984,49985,49986,49987,49988,49990,49991,49992,49993,49994,49995,49996,49997,null,null,null,null,null,null,49998,49999,50000,50001,50002,50003,50004,50005,50006,50007,50008,50009,50010,50011,50012,50013,50014,50015,50016,50017,50018,50019,50020,50021,50022,50023,50026,50027,50029,50030,50031,50033,50035,50036,50037,50038,50039,50042,50043,50046,50047,50048,50049,50050,50051,50053,50054,50055,50057,50058,50059,50061,50062,50063,50064,50065,50066,50067,50068,50069,50070,50071,50072,50073,50074,50075,50076,50077,50078,50079,50080,50081,50082,50083,50084,50085,50086,50087,50088,50089,50090,50091,50092,50093,50094,50095,50096,50097,50098,50099,50100,50101,50102,50103,50104,50105,50106,50107,50108,50109,50110,50111,50113,50114,50115,50116,50117,50118,50119,50120,50121,50122,50123,50124,50125,50126,50127,50128,50129,50130,50131,50132,50133,50134,50135,50138,50139,50141,50142,50145,50147,50148,50149,50150,50151,50154,50155,50156,50158,50159,50160,50161,50162,50163,50166,50167,50169,50170,50171,50172,50173,50174,null,null,null,null,null,null,50175,50176,50177,50178,50179,50180,50181,50182,50183,50185,50186,50187,50188,50189,50190,50191,50193,50194,50195,50196,50197,50198,50199,50200,50201,50202,null,null,null,null,null,null,50203,50204,50205,50206,50207,50208,50209,50210,50211,50213,50214,50215,50216,50217,50218,50219,50221,50222,50223,50225,50226,50227,50229,50230,50231,50232,50233,50234,50235,50238,50239,50240,50241,50242,50243,50244,50245,50246,50247,50249,50250,50251,50252,50253,50254,50255,50256,50257,50258,50259,50260,50261,50262,50263,50264,50265,50266,50267,50268,50269,50270,50271,50272,50273,50274,50275,50278,50279,50281,50282,50283,50285,50286,50287,50288,50289,50290,50291,50294,50295,50296,50298,50299,50300,50301,50302,50303,50305,50306,50307,50308,50309,50310,50311,50312,50313,50314,50315,50316,50317,50318,50319,50320,50321,50322,50323,50325,50326,50327,50328,50329,50330,50331,50333,50334,50335,50336,50337,50338,50339,50340,50341,50342,50343,50344,50345,50346,50347,50348,50349,50350,50351,50352,50353,50354,50355,50356,50357,50358,50359,50361,50362,50363,50365,50366,50367,50368,50369,50370,50371,50372,50373,null,null,null,null,null,null,50374,50375,50376,50377,50378,50379,50380,50381,50382,50383,50384,50385,50386,50387,50388,50389,50390,50391,50392,50393,50394,50395,50396,50397,50398,50399,null,null,null,null,null,null,50400,50401,50402,50403,50404,50405,50406,50407,50408,50410,50411,50412,50413,50414,50415,50418,50419,50421,50422,50423,50425,50427,50428,50429,50430,50434,50435,50436,50437,50438,50439,50440,50441,50442,50443,50445,50446,50447,50449,50450,50451,50453,50454,50455,50456,50457,50458,50459,50461,50462,50463,50464,50465,50466,50467,50468,50469,50470,50471,50474,50475,50477,50478,50479,50481,50482,50483,50484,50485,50486,50487,50490,50492,50494,50495,50496,50497,50498,50499,50502,50503,50507,50511,50512,50513,50514,50518,50522,50523,50524,50527,50530,50531,50533,50534,50535,50537,50538,50539,50540,50541,50542,50543,50546,50550,50551,50552,50553,50554,50555,50558,50559,50561,50562,50563,50565,50566,50568,50569,50570,50571,50574,50576,50578,50579,50580,50582,50585,50586,50587,50589,50590,50591,50593,50594,50595,50596,50597,50598,50599,50600,50602,50603,50604,50605,50606,50607,50608,50609,50610,50611,50614,null,null,null,null,null,null,50615,50618,50623,50624,50625,50626,50627,50635,50637,50639,50642,50643,50645,50646,50647,50649,50650,50651,50652,50653,50654,50655,50658,50660,50662,50663,null,null,null,null,null,null,50664,50665,50666,50667,50671,50673,50674,50675,50677,50680,50681,50682,50683,50690,50691,50692,50697,50698,50699,50701,50702,50703,50705,50706,50707,50708,50709,50710,50711,50714,50717,50718,50719,50720,50721,50722,50723,50726,50727,50729,50730,50731,50735,50737,50738,50742,50744,50746,50748,50749,50750,50751,50754,50755,50757,50758,50759,50761,50762,50763,50764,50765,50766,50767,50770,50774,50775,50776,50777,50778,50779,50782,50783,50785,50786,50787,50788,50789,50790,50791,50792,50793,50794,50795,50797,50798,50800,50802,50803,50804,50805,50806,50807,50810,50811,50813,50814,50815,50817,50818,50819,50820,50821,50822,50823,50826,50828,50830,50831,50832,50833,50834,50835,50838,50839,50841,50842,50843,50845,50846,50847,50848,50849,50850,50851,50854,50856,50858,50859,50860,50861,50862,50863,50866,50867,50869,50870,50871,50875,50876,50877,50878,50879,50882,50884,50886,50887,50888,50889,50890,50891,50894,null,null,null,null,null,null,50895,50897,50898,50899,50901,50902,50903,50904,50905,50906,50907,50910,50911,50914,50915,50916,50917,50918,50919,50922,50923,50925,50926,50927,50929,50930,null,null,null,null,null,null,50931,50932,50933,50934,50935,50938,50939,50940,50942,50943,50944,50945,50946,50947,50950,50951,50953,50954,50955,50957,50958,50959,50960,50961,50962,50963,50966,50968,50970,50971,50972,50973,50974,50975,50978,50979,50981,50982,50983,50985,50986,50987,50988,50989,50990,50991,50994,50996,50998,51000,51001,51002,51003,51006,51007,51009,51010,51011,51013,51014,51015,51016,51017,51019,51022,51024,51033,51034,51035,51037,51038,51039,51041,51042,51043,51044,51045,51046,51047,51049,51050,51052,51053,51054,51055,51056,51057,51058,51059,51062,51063,51065,51066,51067,51071,51072,51073,51074,51078,51083,51084,51085,51087,51090,51091,51093,51097,51099,51100,51101,51102,51103,51106,51111,51112,51113,51114,51115,51118,51119,51121,51122,51123,51125,51126,51127,51128,51129,51130,51131,51134,51138,51139,51140,51141,51142,51143,51146,51147,51149,51151,51153,51154,51155,51156,51157,51158,51159,51161,51162,51163,51164,null,null,null,null,null,null,51166,51167,51168,51169,51170,51171,51173,51174,51175,51177,51178,51179,51181,51182,51183,51184,51185,51186,51187,51188,51189,51190,51191,51192,51193,51194,null,null,null,null,null,null,51195,51196,51197,51198,51199,51202,51203,51205,51206,51207,51209,51211,51212,51213,51214,51215,51218,51220,51223,51224,51225,51226,51227,51230,51231,51233,51234,51235,51237,51238,51239,51240,51241,51242,51243,51246,51248,51250,51251,51252,51253,51254,51255,51257,51258,51259,51261,51262,51263,51265,51266,51267,51268,51269,51270,51271,51274,51275,51278,51279,51280,51281,51282,51283,51285,51286,51287,51288,51289,51290,51291,51292,51293,51294,51295,51296,51297,51298,51299,51300,51301,51302,51303,51304,51305,51306,51307,51308,51309,51310,51311,51314,51315,51317,51318,51319,51321,51323,51324,51325,51326,51327,51330,51332,51336,51337,51338,51342,51343,51344,51345,51346,51347,51349,51350,51351,51352,51353,51354,51355,51356,51358,51360,51362,51363,51364,51365,51366,51367,51369,51370,51371,51372,51373,51374,51375,51376,51377,51378,51379,51380,51381,51382,51383,51384,51385,51386,51387,51390,51391,51392,51393,null,null,null,null,null,null,51394,51395,51397,51398,51399,51401,51402,51403,51405,51406,51407,51408,51409,51410,51411,51414,51416,51418,51419,51420,51421,51422,51423,51426,51427,51429,null,null,null,null,null,null,51430,51431,51432,51433,51434,51435,51436,51437,51438,51439,51440,51441,51442,51443,51444,51446,51447,51448,51449,51450,51451,51454,51455,51457,51458,51459,51463,51464,51465,51466,51467,51470,12288,12289,12290,183,8229,8230,168,12291,173,8213,8741,65340,8764,8216,8217,8220,8221,12308,12309,12296,12297,12298,12299,12300,12301,12302,12303,12304,12305,177,215,247,8800,8804,8805,8734,8756,176,8242,8243,8451,8491,65504,65505,65509,9794,9792,8736,8869,8978,8706,8711,8801,8786,167,8251,9734,9733,9675,9679,9678,9671,9670,9633,9632,9651,9650,9661,9660,8594,8592,8593,8595,8596,12307,8810,8811,8730,8765,8733,8757,8747,8748,8712,8715,8838,8839,8834,8835,8746,8745,8743,8744,65506,51472,51474,51475,51476,51477,51478,51479,51481,51482,51483,51484,51485,51486,51487,51488,51489,51490,51491,51492,51493,51494,51495,51496,51497,51498,51499,null,null,null,null,null,null,51501,51502,51503,51504,51505,51506,51507,51509,51510,51511,51512,51513,51514,51515,51516,51517,51518,51519,51520,51521,51522,51523,51524,51525,51526,51527,null,null,null,null,null,null,51528,51529,51530,51531,51532,51533,51534,51535,51538,51539,51541,51542,51543,51545,51546,51547,51548,51549,51550,51551,51554,51556,51557,51558,51559,51560,51561,51562,51563,51565,51566,51567,8658,8660,8704,8707,180,65374,711,728,733,730,729,184,731,161,191,720,8750,8721,8719,164,8457,8240,9665,9664,9655,9654,9828,9824,9825,9829,9831,9827,8857,9672,9635,9680,9681,9618,9636,9637,9640,9639,9638,9641,9832,9743,9742,9756,9758,182,8224,8225,8597,8599,8601,8598,8600,9837,9833,9834,9836,12927,12828,8470,13255,8482,13250,13272,8481,8364,174,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,51569,51570,51571,51573,51574,51575,51576,51577,51578,51579,51581,51582,51583,51584,51585,51586,51587,51588,51589,51590,51591,51594,51595,51597,51598,51599,null,null,null,null,null,null,51601,51602,51603,51604,51605,51606,51607,51610,51612,51614,51615,51616,51617,51618,51619,51620,51621,51622,51623,51624,51625,51626,51627,51628,51629,51630,null,null,null,null,null,null,51631,51632,51633,51634,51635,51636,51637,51638,51639,51640,51641,51642,51643,51644,51645,51646,51647,51650,51651,51653,51654,51657,51659,51660,51661,51662,51663,51666,51668,51671,51672,51675,65281,65282,65283,65284,65285,65286,65287,65288,65289,65290,65291,65292,65293,65294,65295,65296,65297,65298,65299,65300,65301,65302,65303,65304,65305,65306,65307,65308,65309,65310,65311,65312,65313,65314,65315,65316,65317,65318,65319,65320,65321,65322,65323,65324,65325,65326,65327,65328,65329,65330,65331,65332,65333,65334,65335,65336,65337,65338,65339,65510,65341,65342,65343,65344,65345,65346,65347,65348,65349,65350,65351,65352,65353,65354,65355,65356,65357,65358,65359,65360,65361,65362,65363,65364,65365,65366,65367,65368,65369,65370,65371,65372,65373,65507,51678,51679,51681,51683,51685,51686,51688,51689,51690,51691,51694,51698,51699,51700,51701,51702,51703,51706,51707,51709,51710,51711,51713,51714,51715,51716,null,null,null,null,null,null,51717,51718,51719,51722,51726,51727,51728,51729,51730,51731,51733,51734,51735,51737,51738,51739,51740,51741,51742,51743,51744,51745,51746,51747,51748,51749,null,null,null,null,null,null,51750,51751,51752,51754,51755,51756,51757,51758,51759,51760,51761,51762,51763,51764,51765,51766,51767,51768,51769,51770,51771,51772,51773,51774,51775,51776,51777,51778,51779,51780,51781,51782,12593,12594,12595,12596,12597,12598,12599,12600,12601,12602,12603,12604,12605,12606,12607,12608,12609,12610,12611,12612,12613,12614,12615,12616,12617,12618,12619,12620,12621,12622,12623,12624,12625,12626,12627,12628,12629,12630,12631,12632,12633,12634,12635,12636,12637,12638,12639,12640,12641,12642,12643,12644,12645,12646,12647,12648,12649,12650,12651,12652,12653,12654,12655,12656,12657,12658,12659,12660,12661,12662,12663,12664,12665,12666,12667,12668,12669,12670,12671,12672,12673,12674,12675,12676,12677,12678,12679,12680,12681,12682,12683,12684,12685,12686,51783,51784,51785,51786,51787,51790,51791,51793,51794,51795,51797,51798,51799,51800,51801,51802,51803,51806,51810,51811,51812,51813,51814,51815,51817,51818,null,null,null,null,null,null,51819,51820,51821,51822,51823,51824,51825,51826,51827,51828,51829,51830,51831,51832,51833,51834,51835,51836,51838,51839,51840,51841,51842,51843,51845,51846,null,null,null,null,null,null,51847,51848,51849,51850,51851,51852,51853,51854,51855,51856,51857,51858,51859,51860,51861,51862,51863,51865,51866,51867,51868,51869,51870,51871,51872,51873,51874,51875,51876,51877,51878,51879,8560,8561,8562,8563,8564,8565,8566,8567,8568,8569,null,null,null,null,null,8544,8545,8546,8547,8548,8549,8550,8551,8552,8553,null,null,null,null,null,null,null,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,931,932,933,934,935,936,937,null,null,null,null,null,null,null,null,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960,961,963,964,965,966,967,968,969,null,null,null,null,null,null,51880,51881,51882,51883,51884,51885,51886,51887,51888,51889,51890,51891,51892,51893,51894,51895,51896,51897,51898,51899,51902,51903,51905,51906,51907,51909,null,null,null,null,null,null,51910,51911,51912,51913,51914,51915,51918,51920,51922,51924,51925,51926,51927,51930,51931,51932,51933,51934,51935,51937,51938,51939,51940,51941,51942,51943,null,null,null,null,null,null,51944,51945,51946,51947,51949,51950,51951,51952,51953,51954,51955,51957,51958,51959,51960,51961,51962,51963,51964,51965,51966,51967,51968,51969,51970,51971,51972,51973,51974,51975,51977,51978,9472,9474,9484,9488,9496,9492,9500,9516,9508,9524,9532,9473,9475,9487,9491,9499,9495,9507,9523,9515,9531,9547,9504,9519,9512,9527,9535,9501,9520,9509,9528,9538,9490,9489,9498,9497,9494,9493,9486,9485,9502,9503,9505,9506,9510,9511,9513,9514,9517,9518,9521,9522,9525,9526,9529,9530,9533,9534,9536,9537,9539,9540,9541,9542,9543,9544,9545,9546,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,51979,51980,51981,51982,51983,51985,51986,51987,51989,51990,51991,51993,51994,51995,51996,51997,51998,51999,52002,52003,52004,52005,52006,52007,52008,52009,null,null,null,null,null,null,52010,52011,52012,52013,52014,52015,52016,52017,52018,52019,52020,52021,52022,52023,52024,52025,52026,52027,52028,52029,52030,52031,52032,52034,52035,52036,null,null,null,null,null,null,52037,52038,52039,52042,52043,52045,52046,52047,52049,52050,52051,52052,52053,52054,52055,52058,52059,52060,52062,52063,52064,52065,52066,52067,52069,52070,52071,52072,52073,52074,52075,52076,13205,13206,13207,8467,13208,13252,13219,13220,13221,13222,13209,13210,13211,13212,13213,13214,13215,13216,13217,13218,13258,13197,13198,13199,13263,13192,13193,13256,13223,13224,13232,13233,13234,13235,13236,13237,13238,13239,13240,13241,13184,13185,13186,13187,13188,13242,13243,13244,13245,13246,13247,13200,13201,13202,13203,13204,8486,13248,13249,13194,13195,13196,13270,13253,13229,13230,13231,13275,13225,13226,13227,13228,13277,13264,13267,13251,13257,13276,13254,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,52077,52078,52079,52080,52081,52082,52083,52084,52085,52086,52087,52090,52091,52092,52093,52094,52095,52096,52097,52098,52099,52100,52101,52102,52103,52104,null,null,null,null,null,null,52105,52106,52107,52108,52109,52110,52111,52112,52113,52114,52115,52116,52117,52118,52119,52120,52121,52122,52123,52125,52126,52127,52128,52129,52130,52131,null,null,null,null,null,null,52132,52133,52134,52135,52136,52137,52138,52139,52140,52141,52142,52143,52144,52145,52146,52147,52148,52149,52150,52151,52153,52154,52155,52156,52157,52158,52159,52160,52161,52162,52163,52164,198,208,170,294,null,306,null,319,321,216,338,186,222,358,330,null,12896,12897,12898,12899,12900,12901,12902,12903,12904,12905,12906,12907,12908,12909,12910,12911,12912,12913,12914,12915,12916,12917,12918,12919,12920,12921,12922,12923,9424,9425,9426,9427,9428,9429,9430,9431,9432,9433,9434,9435,9436,9437,9438,9439,9440,9441,9442,9443,9444,9445,9446,9447,9448,9449,9312,9313,9314,9315,9316,9317,9318,9319,9320,9321,9322,9323,9324,9325,9326,189,8531,8532,188,190,8539,8540,8541,8542,52165,52166,52167,52168,52169,52170,52171,52172,52173,52174,52175,52176,52177,52178,52179,52181,52182,52183,52184,52185,52186,52187,52188,52189,52190,52191,null,null,null,null,null,null,52192,52193,52194,52195,52197,52198,52200,52202,52203,52204,52205,52206,52207,52208,52209,52210,52211,52212,52213,52214,52215,52216,52217,52218,52219,52220,null,null,null,null,null,null,52221,52222,52223,52224,52225,52226,52227,52228,52229,52230,52231,52232,52233,52234,52235,52238,52239,52241,52242,52243,52245,52246,52247,52248,52249,52250,52251,52254,52255,52256,52259,52260,230,273,240,295,305,307,312,320,322,248,339,223,254,359,331,329,12800,12801,12802,12803,12804,12805,12806,12807,12808,12809,12810,12811,12812,12813,12814,12815,12816,12817,12818,12819,12820,12821,12822,12823,12824,12825,12826,12827,9372,9373,9374,9375,9376,9377,9378,9379,9380,9381,9382,9383,9384,9385,9386,9387,9388,9389,9390,9391,9392,9393,9394,9395,9396,9397,9332,9333,9334,9335,9336,9337,9338,9339,9340,9341,9342,9343,9344,9345,9346,185,178,179,8308,8319,8321,8322,8323,8324,52261,52262,52266,52267,52269,52271,52273,52274,52275,52276,52277,52278,52279,52282,52287,52288,52289,52290,52291,52294,52295,52297,52298,52299,52301,52302,null,null,null,null,null,null,52303,52304,52305,52306,52307,52310,52314,52315,52316,52317,52318,52319,52321,52322,52323,52325,52327,52329,52330,52331,52332,52333,52334,52335,52337,52338,null,null,null,null,null,null,52339,52340,52342,52343,52344,52345,52346,52347,52348,52349,52350,52351,52352,52353,52354,52355,52356,52357,52358,52359,52360,52361,52362,52363,52364,52365,52366,52367,52368,52369,52370,52371,12353,12354,12355,12356,12357,12358,12359,12360,12361,12362,12363,12364,12365,12366,12367,12368,12369,12370,12371,12372,12373,12374,12375,12376,12377,12378,12379,12380,12381,12382,12383,12384,12385,12386,12387,12388,12389,12390,12391,12392,12393,12394,12395,12396,12397,12398,12399,12400,12401,12402,12403,12404,12405,12406,12407,12408,12409,12410,12411,12412,12413,12414,12415,12416,12417,12418,12419,12420,12421,12422,12423,12424,12425,12426,12427,12428,12429,12430,12431,12432,12433,12434,12435,null,null,null,null,null,null,null,null,null,null,null,52372,52373,52374,52375,52378,52379,52381,52382,52383,52385,52386,52387,52388,52389,52390,52391,52394,52398,52399,52400,52401,52402,52403,52406,52407,52409,null,null,null,null,null,null,52410,52411,52413,52414,52415,52416,52417,52418,52419,52422,52424,52426,52427,52428,52429,52430,52431,52433,52434,52435,52437,52438,52439,52440,52441,52442,null,null,null,null,null,null,52443,52444,52445,52446,52447,52448,52449,52450,52451,52453,52454,52455,52456,52457,52458,52459,52461,52462,52463,52465,52466,52467,52468,52469,52470,52471,52472,52473,52474,52475,52476,52477,12449,12450,12451,12452,12453,12454,12455,12456,12457,12458,12459,12460,12461,12462,12463,12464,12465,12466,12467,12468,12469,12470,12471,12472,12473,12474,12475,12476,12477,12478,12479,12480,12481,12482,12483,12484,12485,12486,12487,12488,12489,12490,12491,12492,12493,12494,12495,12496,12497,12498,12499,12500,12501,12502,12503,12504,12505,12506,12507,12508,12509,12510,12511,12512,12513,12514,12515,12516,12517,12518,12519,12520,12521,12522,12523,12524,12525,12526,12527,12528,12529,12530,12531,12532,12533,12534,null,null,null,null,null,null,null,null,52478,52479,52480,52482,52483,52484,52485,52486,52487,52490,52491,52493,52494,52495,52497,52498,52499,52500,52501,52502,52503,52506,52508,52510,52511,52512,null,null,null,null,null,null,52513,52514,52515,52517,52518,52519,52521,52522,52523,52525,52526,52527,52528,52529,52530,52531,52532,52533,52534,52535,52536,52538,52539,52540,52541,52542,null,null,null,null,null,null,52543,52544,52545,52546,52547,52548,52549,52550,52551,52552,52553,52554,52555,52556,52557,52558,52559,52560,52561,52562,52563,52564,52565,52566,52567,52568,52569,52570,52571,52573,52574,52575,1040,1041,1042,1043,1044,1045,1025,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1072,1073,1074,1075,1076,1077,1105,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103,null,null,null,null,null,null,null,null,null,null,null,null,null,52577,52578,52579,52581,52582,52583,52584,52585,52586,52587,52590,52592,52594,52595,52596,52597,52598,52599,52601,52602,52603,52604,52605,52606,52607,52608,null,null,null,null,null,null,52609,52610,52611,52612,52613,52614,52615,52617,52618,52619,52620,52621,52622,52623,52624,52625,52626,52627,52630,52631,52633,52634,52635,52637,52638,52639,null,null,null,null,null,null,52640,52641,52642,52643,52646,52648,52650,52651,52652,52653,52654,52655,52657,52658,52659,52660,52661,52662,52663,52664,52665,52666,52667,52668,52669,52670,52671,52672,52673,52674,52675,52677,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,52678,52679,52680,52681,52682,52683,52685,52686,52687,52689,52690,52691,52692,52693,52694,52695,52696,52697,52698,52699,52700,52701,52702,52703,52704,52705,null,null,null,null,null,null,52706,52707,52708,52709,52710,52711,52713,52714,52715,52717,52718,52719,52721,52722,52723,52724,52725,52726,52727,52730,52732,52734,52735,52736,52737,52738,null,null,null,null,null,null,52739,52741,52742,52743,52745,52746,52747,52749,52750,52751,52752,52753,52754,52755,52757,52758,52759,52760,52762,52763,52764,52765,52766,52767,52770,52771,52773,52774,52775,52777,52778,52779,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,52780,52781,52782,52783,52786,52788,52790,52791,52792,52793,52794,52795,52796,52797,52798,52799,52800,52801,52802,52803,52804,52805,52806,52807,52808,52809,null,null,null,null,null,null,52810,52811,52812,52813,52814,52815,52816,52817,52818,52819,52820,52821,52822,52823,52826,52827,52829,52830,52834,52835,52836,52837,52838,52839,52842,52844,null,null,null,null,null,null,52846,52847,52848,52849,52850,52851,52854,52855,52857,52858,52859,52861,52862,52863,52864,52865,52866,52867,52870,52872,52874,52875,52876,52877,52878,52879,52882,52883,52885,52886,52887,52889,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,52890,52891,52892,52893,52894,52895,52898,52902,52903,52904,52905,52906,52907,52910,52911,52912,52913,52914,52915,52916,52917,52918,52919,52920,52921,52922,null,null,null,null,null,null,52923,52924,52925,52926,52927,52928,52930,52931,52932,52933,52934,52935,52936,52937,52938,52939,52940,52941,52942,52943,52944,52945,52946,52947,52948,52949,null,null,null,null,null,null,52950,52951,52952,52953,52954,52955,52956,52957,52958,52959,52960,52961,52962,52963,52966,52967,52969,52970,52973,52974,52975,52976,52977,52978,52979,52982,52986,52987,52988,52989,52990,52991,44032,44033,44036,44039,44040,44041,44042,44048,44049,44050,44051,44052,44053,44054,44055,44057,44058,44059,44060,44061,44064,44068,44076,44077,44079,44080,44081,44088,44089,44092,44096,44107,44109,44116,44120,44124,44144,44145,44148,44151,44152,44154,44160,44161,44163,44164,44165,44166,44169,44170,44171,44172,44176,44180,44188,44189,44191,44192,44193,44200,44201,44202,44204,44207,44208,44216,44217,44219,44220,44221,44225,44228,44232,44236,44245,44247,44256,44257,44260,44263,44264,44266,44268,44271,44272,44273,44275,44277,44278,44284,44285,44288,44292,44294,52994,52995,52997,52998,52999,53001,53002,53003,53004,53005,53006,53007,53010,53012,53014,53015,53016,53017,53018,53019,53021,53022,53023,53025,53026,53027,null,null,null,null,null,null,53029,53030,53031,53032,53033,53034,53035,53038,53042,53043,53044,53045,53046,53047,53049,53050,53051,53052,53053,53054,53055,53056,53057,53058,53059,53060,null,null,null,null,null,null,53061,53062,53063,53064,53065,53066,53067,53068,53069,53070,53071,53072,53073,53074,53075,53078,53079,53081,53082,53083,53085,53086,53087,53088,53089,53090,53091,53094,53096,53098,53099,53100,44300,44301,44303,44305,44312,44316,44320,44329,44332,44333,44340,44341,44344,44348,44356,44357,44359,44361,44368,44372,44376,44385,44387,44396,44397,44400,44403,44404,44405,44406,44411,44412,44413,44415,44417,44418,44424,44425,44428,44432,44444,44445,44452,44471,44480,44481,44484,44488,44496,44497,44499,44508,44512,44516,44536,44537,44540,44543,44544,44545,44552,44553,44555,44557,44564,44592,44593,44596,44599,44600,44602,44608,44609,44611,44613,44614,44618,44620,44621,44622,44624,44628,44630,44636,44637,44639,44640,44641,44645,44648,44649,44652,44656,44664,53101,53102,53103,53106,53107,53109,53110,53111,53113,53114,53115,53116,53117,53118,53119,53121,53122,53123,53124,53126,53127,53128,53129,53130,53131,53133,null,null,null,null,null,null,53134,53135,53136,53137,53138,53139,53140,53141,53142,53143,53144,53145,53146,53147,53148,53149,53150,53151,53152,53154,53155,53156,53157,53158,53159,53161,null,null,null,null,null,null,53162,53163,53164,53165,53166,53167,53169,53170,53171,53172,53173,53174,53175,53176,53177,53178,53179,53180,53181,53182,53183,53184,53185,53186,53187,53189,53190,53191,53192,53193,53194,53195,44665,44667,44668,44669,44676,44677,44684,44732,44733,44734,44736,44740,44748,44749,44751,44752,44753,44760,44761,44764,44776,44779,44781,44788,44792,44796,44807,44808,44813,44816,44844,44845,44848,44850,44852,44860,44861,44863,44865,44866,44867,44872,44873,44880,44892,44893,44900,44901,44921,44928,44932,44936,44944,44945,44949,44956,44984,44985,44988,44992,44999,45000,45001,45003,45005,45006,45012,45020,45032,45033,45040,45041,45044,45048,45056,45057,45060,45068,45072,45076,45084,45085,45096,45124,45125,45128,45130,45132,45134,45139,45140,45141,45143,45145,53196,53197,53198,53199,53200,53201,53202,53203,53204,53205,53206,53207,53208,53209,53210,53211,53212,53213,53214,53215,53218,53219,53221,53222,53223,53225,null,null,null,null,null,null,53226,53227,53228,53229,53230,53231,53234,53236,53238,53239,53240,53241,53242,53243,53245,53246,53247,53249,53250,53251,53253,53254,53255,53256,53257,53258,null,null,null,null,null,null,53259,53260,53261,53262,53263,53264,53266,53267,53268,53269,53270,53271,53273,53274,53275,53276,53277,53278,53279,53280,53281,53282,53283,53284,53285,53286,53287,53288,53289,53290,53291,53292,45149,45180,45181,45184,45188,45196,45197,45199,45201,45208,45209,45210,45212,45215,45216,45217,45218,45224,45225,45227,45228,45229,45230,45231,45233,45235,45236,45237,45240,45244,45252,45253,45255,45256,45257,45264,45265,45268,45272,45280,45285,45320,45321,45323,45324,45328,45330,45331,45336,45337,45339,45340,45341,45347,45348,45349,45352,45356,45364,45365,45367,45368,45369,45376,45377,45380,45384,45392,45393,45396,45397,45400,45404,45408,45432,45433,45436,45440,45442,45448,45449,45451,45453,45458,45459,45460,45464,45468,45480,45516,45520,45524,45532,45533,53294,53295,53296,53297,53298,53299,53302,53303,53305,53306,53307,53309,53310,53311,53312,53313,53314,53315,53318,53320,53322,53323,53324,53325,53326,53327,null,null,null,null,null,null,53329,53330,53331,53333,53334,53335,53337,53338,53339,53340,53341,53342,53343,53345,53346,53347,53348,53349,53350,53351,53352,53353,53354,53355,53358,53359,null,null,null,null,null,null,53361,53362,53363,53365,53366,53367,53368,53369,53370,53371,53374,53375,53376,53378,53379,53380,53381,53382,53383,53384,53385,53386,53387,53388,53389,53390,53391,53392,53393,53394,53395,53396,45535,45544,45545,45548,45552,45561,45563,45565,45572,45573,45576,45579,45580,45588,45589,45591,45593,45600,45620,45628,45656,45660,45664,45672,45673,45684,45685,45692,45700,45701,45705,45712,45713,45716,45720,45721,45722,45728,45729,45731,45733,45734,45738,45740,45744,45748,45768,45769,45772,45776,45778,45784,45785,45787,45789,45794,45796,45797,45798,45800,45803,45804,45805,45806,45807,45811,45812,45813,45815,45816,45817,45818,45819,45823,45824,45825,45828,45832,45840,45841,45843,45844,45845,45852,45908,45909,45910,45912,45915,45916,45918,45919,45924,45925,53397,53398,53399,53400,53401,53402,53403,53404,53405,53406,53407,53408,53409,53410,53411,53414,53415,53417,53418,53419,53421,53422,53423,53424,53425,53426,null,null,null,null,null,null,53427,53430,53432,53434,53435,53436,53437,53438,53439,53442,53443,53445,53446,53447,53450,53451,53452,53453,53454,53455,53458,53462,53463,53464,53465,53466,null,null,null,null,null,null,53467,53470,53471,53473,53474,53475,53477,53478,53479,53480,53481,53482,53483,53486,53490,53491,53492,53493,53494,53495,53497,53498,53499,53500,53501,53502,53503,53504,53505,53506,53507,53508,45927,45929,45931,45934,45936,45937,45940,45944,45952,45953,45955,45956,45957,45964,45968,45972,45984,45985,45992,45996,46020,46021,46024,46027,46028,46030,46032,46036,46037,46039,46041,46043,46045,46048,46052,46056,46076,46096,46104,46108,46112,46120,46121,46123,46132,46160,46161,46164,46168,46176,46177,46179,46181,46188,46208,46216,46237,46244,46248,46252,46261,46263,46265,46272,46276,46280,46288,46293,46300,46301,46304,46307,46308,46310,46316,46317,46319,46321,46328,46356,46357,46360,46363,46364,46372,46373,46375,46376,46377,46378,46384,46385,46388,46392,53509,53510,53511,53512,53513,53514,53515,53516,53518,53519,53520,53521,53522,53523,53524,53525,53526,53527,53528,53529,53530,53531,53532,53533,53534,53535,null,null,null,null,null,null,53536,53537,53538,53539,53540,53541,53542,53543,53544,53545,53546,53547,53548,53549,53550,53551,53554,53555,53557,53558,53559,53561,53563,53564,53565,53566,null,null,null,null,null,null,53567,53570,53574,53575,53576,53577,53578,53579,53582,53583,53585,53586,53587,53589,53590,53591,53592,53593,53594,53595,53598,53600,53602,53603,53604,53605,53606,53607,53609,53610,53611,53613,46400,46401,46403,46404,46405,46411,46412,46413,46416,46420,46428,46429,46431,46432,46433,46496,46497,46500,46504,46506,46507,46512,46513,46515,46516,46517,46523,46524,46525,46528,46532,46540,46541,46543,46544,46545,46552,46572,46608,46609,46612,46616,46629,46636,46644,46664,46692,46696,46748,46749,46752,46756,46763,46764,46769,46804,46832,46836,46840,46848,46849,46853,46888,46889,46892,46895,46896,46904,46905,46907,46916,46920,46924,46932,46933,46944,46948,46952,46960,46961,46963,46965,46972,46973,46976,46980,46988,46989,46991,46992,46993,46994,46998,46999,53614,53615,53616,53617,53618,53619,53620,53621,53622,53623,53624,53625,53626,53627,53629,53630,53631,53632,53633,53634,53635,53637,53638,53639,53641,53642,null,null,null,null,null,null,53643,53644,53645,53646,53647,53648,53649,53650,53651,53652,53653,53654,53655,53656,53657,53658,53659,53660,53661,53662,53663,53666,53667,53669,53670,53671,null,null,null,null,null,null,53673,53674,53675,53676,53677,53678,53679,53682,53684,53686,53687,53688,53689,53691,53693,53694,53695,53697,53698,53699,53700,53701,53702,53703,53704,53705,53706,53707,53708,53709,53710,53711,47000,47001,47004,47008,47016,47017,47019,47020,47021,47028,47029,47032,47047,47049,47084,47085,47088,47092,47100,47101,47103,47104,47105,47111,47112,47113,47116,47120,47128,47129,47131,47133,47140,47141,47144,47148,47156,47157,47159,47160,47161,47168,47172,47185,47187,47196,47197,47200,47204,47212,47213,47215,47217,47224,47228,47245,47272,47280,47284,47288,47296,47297,47299,47301,47308,47312,47316,47325,47327,47329,47336,47337,47340,47344,47352,47353,47355,47357,47364,47384,47392,47420,47421,47424,47428,47436,47439,47441,47448,47449,47452,47456,47464,47465,53712,53713,53714,53715,53716,53717,53718,53719,53721,53722,53723,53724,53725,53726,53727,53728,53729,53730,53731,53732,53733,53734,53735,53736,53737,53738,null,null,null,null,null,null,53739,53740,53741,53742,53743,53744,53745,53746,53747,53749,53750,53751,53753,53754,53755,53756,53757,53758,53759,53760,53761,53762,53763,53764,53765,53766,null,null,null,null,null,null,53768,53770,53771,53772,53773,53774,53775,53777,53778,53779,53780,53781,53782,53783,53784,53785,53786,53787,53788,53789,53790,53791,53792,53793,53794,53795,53796,53797,53798,53799,53800,53801,47467,47469,47476,47477,47480,47484,47492,47493,47495,47497,47498,47501,47502,47532,47533,47536,47540,47548,47549,47551,47553,47560,47561,47564,47566,47567,47568,47569,47570,47576,47577,47579,47581,47582,47585,47587,47588,47589,47592,47596,47604,47605,47607,47608,47609,47610,47616,47617,47624,47637,47672,47673,47676,47680,47682,47688,47689,47691,47693,47694,47699,47700,47701,47704,47708,47716,47717,47719,47720,47721,47728,47729,47732,47736,47747,47748,47749,47751,47756,47784,47785,47787,47788,47792,47794,47800,47801,47803,47805,47812,47816,47832,47833,47868,53802,53803,53806,53807,53809,53810,53811,53813,53814,53815,53816,53817,53818,53819,53822,53824,53826,53827,53828,53829,53830,53831,53833,53834,53835,53836,null,null,null,null,null,null,53837,53838,53839,53840,53841,53842,53843,53844,53845,53846,53847,53848,53849,53850,53851,53853,53854,53855,53856,53857,53858,53859,53861,53862,53863,53864,null,null,null,null,null,null,53865,53866,53867,53868,53869,53870,53871,53872,53873,53874,53875,53876,53877,53878,53879,53880,53881,53882,53883,53884,53885,53886,53887,53890,53891,53893,53894,53895,53897,53898,53899,53900,47872,47876,47885,47887,47889,47896,47900,47904,47913,47915,47924,47925,47926,47928,47931,47932,47933,47934,47940,47941,47943,47945,47949,47951,47952,47956,47960,47969,47971,47980,48008,48012,48016,48036,48040,48044,48052,48055,48064,48068,48072,48080,48083,48120,48121,48124,48127,48128,48130,48136,48137,48139,48140,48141,48143,48145,48148,48149,48150,48151,48152,48155,48156,48157,48158,48159,48164,48165,48167,48169,48173,48176,48177,48180,48184,48192,48193,48195,48196,48197,48201,48204,48205,48208,48221,48260,48261,48264,48267,48268,48270,48276,48277,48279,53901,53902,53903,53906,53907,53908,53910,53911,53912,53913,53914,53915,53917,53918,53919,53921,53922,53923,53925,53926,53927,53928,53929,53930,53931,53933,null,null,null,null,null,null,53934,53935,53936,53938,53939,53940,53941,53942,53943,53946,53947,53949,53950,53953,53955,53956,53957,53958,53959,53962,53964,53965,53966,53967,53968,53969,null,null,null,null,null,null,53970,53971,53973,53974,53975,53977,53978,53979,53981,53982,53983,53984,53985,53986,53987,53990,53991,53992,53993,53994,53995,53996,53997,53998,53999,54002,54003,54005,54006,54007,54009,54010,48281,48282,48288,48289,48292,48295,48296,48304,48305,48307,48308,48309,48316,48317,48320,48324,48333,48335,48336,48337,48341,48344,48348,48372,48373,48374,48376,48380,48388,48389,48391,48393,48400,48404,48420,48428,48448,48456,48457,48460,48464,48472,48473,48484,48488,48512,48513,48516,48519,48520,48521,48522,48528,48529,48531,48533,48537,48538,48540,48548,48560,48568,48596,48597,48600,48604,48617,48624,48628,48632,48640,48643,48645,48652,48653,48656,48660,48668,48669,48671,48708,48709,48712,48716,48718,48724,48725,48727,48729,48730,48731,48736,48737,48740,54011,54012,54013,54014,54015,54018,54020,54022,54023,54024,54025,54026,54027,54031,54033,54034,54035,54037,54039,54040,54041,54042,54043,54046,54050,54051,null,null,null,null,null,null,54052,54054,54055,54058,54059,54061,54062,54063,54065,54066,54067,54068,54069,54070,54071,54074,54078,54079,54080,54081,54082,54083,54086,54087,54088,54089,null,null,null,null,null,null,54090,54091,54092,54093,54094,54095,54096,54097,54098,54099,54100,54101,54102,54103,54104,54105,54106,54107,54108,54109,54110,54111,54112,54113,54114,54115,54116,54117,54118,54119,54120,54121,48744,48746,48752,48753,48755,48756,48757,48763,48764,48765,48768,48772,48780,48781,48783,48784,48785,48792,48793,48808,48848,48849,48852,48855,48856,48864,48867,48868,48869,48876,48897,48904,48905,48920,48921,48923,48924,48925,48960,48961,48964,48968,48976,48977,48981,49044,49072,49093,49100,49101,49104,49108,49116,49119,49121,49212,49233,49240,49244,49248,49256,49257,49296,49297,49300,49304,49312,49313,49315,49317,49324,49325,49327,49328,49331,49332,49333,49334,49340,49341,49343,49344,49345,49349,49352,49353,49356,49360,49368,49369,49371,49372,49373,49380,54122,54123,54124,54125,54126,54127,54128,54129,54130,54131,54132,54133,54134,54135,54136,54137,54138,54139,54142,54143,54145,54146,54147,54149,54150,54151,null,null,null,null,null,null,54152,54153,54154,54155,54158,54162,54163,54164,54165,54166,54167,54170,54171,54173,54174,54175,54177,54178,54179,54180,54181,54182,54183,54186,54188,54190,null,null,null,null,null,null,54191,54192,54193,54194,54195,54197,54198,54199,54201,54202,54203,54205,54206,54207,54208,54209,54210,54211,54214,54215,54218,54219,54220,54221,54222,54223,54225,54226,54227,54228,54229,54230,49381,49384,49388,49396,49397,49399,49401,49408,49412,49416,49424,49429,49436,49437,49438,49439,49440,49443,49444,49446,49447,49452,49453,49455,49456,49457,49462,49464,49465,49468,49472,49480,49481,49483,49484,49485,49492,49493,49496,49500,49508,49509,49511,49512,49513,49520,49524,49528,49541,49548,49549,49550,49552,49556,49558,49564,49565,49567,49569,49573,49576,49577,49580,49584,49597,49604,49608,49612,49620,49623,49624,49632,49636,49640,49648,49649,49651,49660,49661,49664,49668,49676,49677,49679,49681,49688,49689,49692,49695,49696,49704,49705,49707,49709,54231,54233,54234,54235,54236,54237,54238,54239,54240,54242,54244,54245,54246,54247,54248,54249,54250,54251,54254,54255,54257,54258,54259,54261,54262,54263,null,null,null,null,null,null,54264,54265,54266,54267,54270,54272,54274,54275,54276,54277,54278,54279,54281,54282,54283,54284,54285,54286,54287,54288,54289,54290,54291,54292,54293,54294,null,null,null,null,null,null,54295,54296,54297,54298,54299,54300,54302,54303,54304,54305,54306,54307,54308,54309,54310,54311,54312,54313,54314,54315,54316,54317,54318,54319,54320,54321,54322,54323,54324,54325,54326,54327,49711,49713,49714,49716,49736,49744,49745,49748,49752,49760,49765,49772,49773,49776,49780,49788,49789,49791,49793,49800,49801,49808,49816,49819,49821,49828,49829,49832,49836,49837,49844,49845,49847,49849,49884,49885,49888,49891,49892,49899,49900,49901,49903,49905,49910,49912,49913,49915,49916,49920,49928,49929,49932,49933,49939,49940,49941,49944,49948,49956,49957,49960,49961,49989,50024,50025,50028,50032,50034,50040,50041,50044,50045,50052,50056,50060,50112,50136,50137,50140,50143,50144,50146,50152,50153,50157,50164,50165,50168,50184,50192,50212,50220,50224,54328,54329,54330,54331,54332,54333,54334,54335,54337,54338,54339,54341,54342,54343,54344,54345,54346,54347,54348,54349,54350,54351,54352,54353,54354,54355,null,null,null,null,null,null,54356,54357,54358,54359,54360,54361,54362,54363,54365,54366,54367,54369,54370,54371,54373,54374,54375,54376,54377,54378,54379,54380,54382,54384,54385,54386,null,null,null,null,null,null,54387,54388,54389,54390,54391,54394,54395,54397,54398,54401,54403,54404,54405,54406,54407,54410,54412,54414,54415,54416,54417,54418,54419,54421,54422,54423,54424,54425,54426,54427,54428,54429,50228,50236,50237,50248,50276,50277,50280,50284,50292,50293,50297,50304,50324,50332,50360,50364,50409,50416,50417,50420,50424,50426,50431,50432,50433,50444,50448,50452,50460,50472,50473,50476,50480,50488,50489,50491,50493,50500,50501,50504,50505,50506,50508,50509,50510,50515,50516,50517,50519,50520,50521,50525,50526,50528,50529,50532,50536,50544,50545,50547,50548,50549,50556,50557,50560,50564,50567,50572,50573,50575,50577,50581,50583,50584,50588,50592,50601,50612,50613,50616,50617,50619,50620,50621,50622,50628,50629,50630,50631,50632,50633,50634,50636,50638,54430,54431,54432,54433,54434,54435,54436,54437,54438,54439,54440,54442,54443,54444,54445,54446,54447,54448,54449,54450,54451,54452,54453,54454,54455,54456,null,null,null,null,null,null,54457,54458,54459,54460,54461,54462,54463,54464,54465,54466,54467,54468,54469,54470,54471,54472,54473,54474,54475,54477,54478,54479,54481,54482,54483,54485,null,null,null,null,null,null,54486,54487,54488,54489,54490,54491,54493,54494,54496,54497,54498,54499,54500,54501,54502,54503,54505,54506,54507,54509,54510,54511,54513,54514,54515,54516,54517,54518,54519,54521,54522,54524,50640,50641,50644,50648,50656,50657,50659,50661,50668,50669,50670,50672,50676,50678,50679,50684,50685,50686,50687,50688,50689,50693,50694,50695,50696,50700,50704,50712,50713,50715,50716,50724,50725,50728,50732,50733,50734,50736,50739,50740,50741,50743,50745,50747,50752,50753,50756,50760,50768,50769,50771,50772,50773,50780,50781,50784,50796,50799,50801,50808,50809,50812,50816,50824,50825,50827,50829,50836,50837,50840,50844,50852,50853,50855,50857,50864,50865,50868,50872,50873,50874,50880,50881,50883,50885,50892,50893,50896,50900,50908,50909,50912,50913,50920,54526,54527,54528,54529,54530,54531,54533,54534,54535,54537,54538,54539,54541,54542,54543,54544,54545,54546,54547,54550,54552,54553,54554,54555,54556,54557,null,null,null,null,null,null,54558,54559,54560,54561,54562,54563,54564,54565,54566,54567,54568,54569,54570,54571,54572,54573,54574,54575,54576,54577,54578,54579,54580,54581,54582,54583,null,null,null,null,null,null,54584,54585,54586,54587,54590,54591,54593,54594,54595,54597,54598,54599,54600,54601,54602,54603,54606,54608,54610,54611,54612,54613,54614,54615,54618,54619,54621,54622,54623,54625,54626,54627,50921,50924,50928,50936,50937,50941,50948,50949,50952,50956,50964,50965,50967,50969,50976,50977,50980,50984,50992,50993,50995,50997,50999,51004,51005,51008,51012,51018,51020,51021,51023,51025,51026,51027,51028,51029,51030,51031,51032,51036,51040,51048,51051,51060,51061,51064,51068,51069,51070,51075,51076,51077,51079,51080,51081,51082,51086,51088,51089,51092,51094,51095,51096,51098,51104,51105,51107,51108,51109,51110,51116,51117,51120,51124,51132,51133,51135,51136,51137,51144,51145,51148,51150,51152,51160,51165,51172,51176,51180,51200,51201,51204,51208,51210,54628,54630,54631,54634,54636,54638,54639,54640,54641,54642,54643,54646,54647,54649,54650,54651,54653,54654,54655,54656,54657,54658,54659,54662,54666,54667,null,null,null,null,null,null,54668,54669,54670,54671,54673,54674,54675,54676,54677,54678,54679,54680,54681,54682,54683,54684,54685,54686,54687,54688,54689,54690,54691,54692,54694,54695,null,null,null,null,null,null,54696,54697,54698,54699,54700,54701,54702,54703,54704,54705,54706,54707,54708,54709,54710,54711,54712,54713,54714,54715,54716,54717,54718,54719,54720,54721,54722,54723,54724,54725,54726,54727,51216,51217,51219,51221,51222,51228,51229,51232,51236,51244,51245,51247,51249,51256,51260,51264,51272,51273,51276,51277,51284,51312,51313,51316,51320,51322,51328,51329,51331,51333,51334,51335,51339,51340,51341,51348,51357,51359,51361,51368,51388,51389,51396,51400,51404,51412,51413,51415,51417,51424,51425,51428,51445,51452,51453,51456,51460,51461,51462,51468,51469,51471,51473,51480,51500,51508,51536,51537,51540,51544,51552,51553,51555,51564,51568,51572,51580,51592,51593,51596,51600,51608,51609,51611,51613,51648,51649,51652,51655,51656,51658,51664,51665,51667,54730,54731,54733,54734,54735,54737,54739,54740,54741,54742,54743,54746,54748,54750,54751,54752,54753,54754,54755,54758,54759,54761,54762,54763,54765,54766,null,null,null,null,null,null,54767,54768,54769,54770,54771,54774,54776,54778,54779,54780,54781,54782,54783,54786,54787,54789,54790,54791,54793,54794,54795,54796,54797,54798,54799,54802,null,null,null,null,null,null,54806,54807,54808,54809,54810,54811,54813,54814,54815,54817,54818,54819,54821,54822,54823,54824,54825,54826,54827,54828,54830,54831,54832,54833,54834,54835,54836,54837,54838,54839,54842,54843,51669,51670,51673,51674,51676,51677,51680,51682,51684,51687,51692,51693,51695,51696,51697,51704,51705,51708,51712,51720,51721,51723,51724,51725,51732,51736,51753,51788,51789,51792,51796,51804,51805,51807,51808,51809,51816,51837,51844,51864,51900,51901,51904,51908,51916,51917,51919,51921,51923,51928,51929,51936,51948,51956,51976,51984,51988,51992,52000,52001,52033,52040,52041,52044,52048,52056,52057,52061,52068,52088,52089,52124,52152,52180,52196,52199,52201,52236,52237,52240,52244,52252,52253,52257,52258,52263,52264,52265,52268,52270,52272,52280,52281,52283,54845,54846,54847,54849,54850,54851,54852,54854,54855,54858,54860,54862,54863,54864,54866,54867,54870,54871,54873,54874,54875,54877,54878,54879,54880,54881,null,null,null,null,null,null,54882,54883,54884,54885,54886,54888,54890,54891,54892,54893,54894,54895,54898,54899,54901,54902,54903,54904,54905,54906,54907,54908,54909,54910,54911,54912,null,null,null,null,null,null,54913,54914,54916,54918,54919,54920,54921,54922,54923,54926,54927,54929,54930,54931,54933,54934,54935,54936,54937,54938,54939,54940,54942,54944,54946,54947,54948,54949,54950,54951,54953,54954,52284,52285,52286,52292,52293,52296,52300,52308,52309,52311,52312,52313,52320,52324,52326,52328,52336,52341,52376,52377,52380,52384,52392,52393,52395,52396,52397,52404,52405,52408,52412,52420,52421,52423,52425,52432,52436,52452,52460,52464,52481,52488,52489,52492,52496,52504,52505,52507,52509,52516,52520,52524,52537,52572,52576,52580,52588,52589,52591,52593,52600,52616,52628,52629,52632,52636,52644,52645,52647,52649,52656,52676,52684,52688,52712,52716,52720,52728,52729,52731,52733,52740,52744,52748,52756,52761,52768,52769,52772,52776,52784,52785,52787,52789,54955,54957,54958,54959,54961,54962,54963,54964,54965,54966,54967,54968,54970,54972,54973,54974,54975,54976,54977,54978,54979,54982,54983,54985,54986,54987,null,null,null,null,null,null,54989,54990,54991,54992,54994,54995,54997,54998,55000,55002,55003,55004,55005,55006,55007,55009,55010,55011,55013,55014,55015,55017,55018,55019,55020,55021,null,null,null,null,null,null,55022,55023,55025,55026,55027,55028,55030,55031,55032,55033,55034,55035,55038,55039,55041,55042,55043,55045,55046,55047,55048,55049,55050,55051,55052,55053,55054,55055,55056,55058,55059,55060,52824,52825,52828,52831,52832,52833,52840,52841,52843,52845,52852,52853,52856,52860,52868,52869,52871,52873,52880,52881,52884,52888,52896,52897,52899,52900,52901,52908,52909,52929,52964,52965,52968,52971,52972,52980,52981,52983,52984,52985,52992,52993,52996,53000,53008,53009,53011,53013,53020,53024,53028,53036,53037,53039,53040,53041,53048,53076,53077,53080,53084,53092,53093,53095,53097,53104,53105,53108,53112,53120,53125,53132,53153,53160,53168,53188,53216,53217,53220,53224,53232,53233,53235,53237,53244,53248,53252,53265,53272,53293,53300,53301,53304,53308,55061,55062,55063,55066,55067,55069,55070,55071,55073,55074,55075,55076,55077,55078,55079,55082,55084,55086,55087,55088,55089,55090,55091,55094,55095,55097,null,null,null,null,null,null,55098,55099,55101,55102,55103,55104,55105,55106,55107,55109,55110,55112,55114,55115,55116,55117,55118,55119,55122,55123,55125,55130,55131,55132,55133,55134,null,null,null,null,null,null,55135,55138,55140,55142,55143,55144,55146,55147,55149,55150,55151,55153,55154,55155,55157,55158,55159,55160,55161,55162,55163,55166,55167,55168,55170,55171,55172,55173,55174,55175,55178,55179,53316,53317,53319,53321,53328,53332,53336,53344,53356,53357,53360,53364,53372,53373,53377,53412,53413,53416,53420,53428,53429,53431,53433,53440,53441,53444,53448,53449,53456,53457,53459,53460,53461,53468,53469,53472,53476,53484,53485,53487,53488,53489,53496,53517,53552,53553,53556,53560,53562,53568,53569,53571,53572,53573,53580,53581,53584,53588,53596,53597,53599,53601,53608,53612,53628,53636,53640,53664,53665,53668,53672,53680,53681,53683,53685,53690,53692,53696,53720,53748,53752,53767,53769,53776,53804,53805,53808,53812,53820,53821,53823,53825,53832,53852,55181,55182,55183,55185,55186,55187,55188,55189,55190,55191,55194,55196,55198,55199,55200,55201,55202,55203,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,53860,53888,53889,53892,53896,53904,53905,53909,53916,53920,53924,53932,53937,53944,53945,53948,53951,53952,53954,53960,53961,53963,53972,53976,53980,53988,53989,54000,54001,54004,54008,54016,54017,54019,54021,54028,54029,54030,54032,54036,54038,54044,54045,54047,54048,54049,54053,54056,54057,54060,54064,54072,54073,54075,54076,54077,54084,54085,54140,54141,54144,54148,54156,54157,54159,54160,54161,54168,54169,54172,54176,54184,54185,54187,54189,54196,54200,54204,54212,54213,54216,54217,54224,54232,54241,54243,54252,54253,54256,54260,54268,54269,54271,54273,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,54280,54301,54336,54340,54364,54368,54372,54381,54383,54392,54393,54396,54399,54400,54402,54408,54409,54411,54413,54420,54441,54476,54480,54484,54492,54495,54504,54508,54512,54520,54523,54525,54532,54536,54540,54548,54549,54551,54588,54589,54592,54596,54604,54605,54607,54609,54616,54617,54620,54624,54629,54632,54633,54635,54637,54644,54645,54648,54652,54660,54661,54663,54664,54665,54672,54693,54728,54729,54732,54736,54738,54744,54745,54747,54749,54756,54757,54760,54764,54772,54773,54775,54777,54784,54785,54788,54792,54800,54801,54803,54804,54805,54812,54816,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,54820,54829,54840,54841,54844,54848,54853,54856,54857,54859,54861,54865,54868,54869,54872,54876,54887,54889,54896,54897,54900,54915,54917,54924,54925,54928,54932,54941,54943,54945,54952,54956,54960,54969,54971,54980,54981,54984,54988,54993,54996,54999,55001,55008,55012,55016,55024,55029,55036,55037,55040,55044,55057,55064,55065,55068,55072,55080,55081,55083,55085,55092,55093,55096,55100,55108,55111,55113,55120,55121,55124,55126,55127,55128,55129,55136,55137,55139,55141,55145,55148,55152,55156,55164,55165,55169,55176,55177,55180,55184,55192,55193,55195,55197,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,20285,20339,20551,20729,21152,21487,21621,21733,22025,23233,23478,26247,26550,26551,26607,27468,29634,30146,31292,33499,33540,34903,34952,35382,36040,36303,36603,36838,39381,21051,21364,21508,24682,24932,27580,29647,33050,35258,35282,38307,20355,21002,22718,22904,23014,24178,24185,25031,25536,26438,26604,26751,28567,30286,30475,30965,31240,31487,31777,32925,33390,33393,35563,38291,20075,21917,26359,28212,30883,31469,33883,35088,34638,38824,21208,22350,22570,23884,24863,25022,25121,25954,26577,27204,28187,29976,30131,30435,30640,32058,37039,37969,37970,40853,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,21283,23724,30002,32987,37440,38296,21083,22536,23004,23713,23831,24247,24378,24394,24951,27743,30074,30086,31968,32115,32177,32652,33108,33313,34193,35137,35611,37628,38477,40007,20171,20215,20491,20977,22607,24887,24894,24936,25913,27114,28433,30117,30342,30422,31623,33445,33995,63744,37799,38283,21888,23458,22353,63745,31923,32697,37301,20520,21435,23621,24040,25298,25454,25818,25831,28192,28844,31067,36317,36382,63746,36989,37445,37624,20094,20214,20581,24062,24314,24838,26967,33137,34388,36423,37749,39467,20062,20625,26480,26688,20745,21133,21138,27298,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,30652,37392,40660,21163,24623,36850,20552,25001,25581,25802,26684,27268,28608,33160,35233,38548,22533,29309,29356,29956,32121,32365,32937,35211,35700,36963,40273,25225,27770,28500,32080,32570,35363,20860,24906,31645,35609,37463,37772,20140,20435,20510,20670,20742,21185,21197,21375,22384,22659,24218,24465,24950,25004,25806,25964,26223,26299,26356,26775,28039,28805,28913,29855,29861,29898,30169,30828,30956,31455,31478,32069,32147,32789,32831,33051,33686,35686,36629,36885,37857,38915,38968,39514,39912,20418,21843,22586,22865,23395,23622,24760,25106,26690,26800,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,26856,28330,30028,30328,30926,31293,31995,32363,32380,35336,35489,35903,38542,40388,21476,21481,21578,21617,22266,22993,23396,23611,24235,25335,25911,25925,25970,26272,26543,27073,27837,30204,30352,30590,31295,32660,32771,32929,33167,33510,33533,33776,34241,34865,34996,35493,63747,36764,37678,38599,39015,39640,40723,21741,26011,26354,26767,31296,35895,40288,22256,22372,23825,26118,26801,26829,28414,29736,34974,39908,27752,63748,39592,20379,20844,20849,21151,23380,24037,24656,24685,25329,25511,25915,29657,31354,34467,36002,38799,20018,23521,25096,26524,29916,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,31185,33747,35463,35506,36328,36942,37707,38982,24275,27112,34303,37101,63749,20896,23448,23532,24931,26874,27454,28748,29743,29912,31649,32592,33733,35264,36011,38364,39208,21038,24669,25324,36866,20362,20809,21281,22745,24291,26336,27960,28826,29378,29654,31568,33009,37979,21350,25499,32619,20054,20608,22602,22750,24618,24871,25296,27088,39745,23439,32024,32945,36703,20132,20689,21676,21932,23308,23968,24039,25898,25934,26657,27211,29409,30350,30703,32094,32761,33184,34126,34527,36611,36686,37066,39171,39509,39851,19992,20037,20061,20167,20465,20855,21246,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,21312,21475,21477,21646,22036,22389,22434,23495,23943,24272,25084,25304,25937,26552,26601,27083,27472,27590,27628,27714,28317,28792,29399,29590,29699,30655,30697,31350,32127,32777,33276,33285,33290,33503,34914,35635,36092,36544,36881,37041,37476,37558,39378,39493,40169,40407,40860,22283,23616,33738,38816,38827,40628,21531,31384,32676,35033,36557,37089,22528,23624,25496,31391,23470,24339,31353,31406,33422,36524,20518,21048,21240,21367,22280,25331,25458,27402,28099,30519,21413,29527,34152,36470,38357,26426,27331,28528,35437,36556,39243,63750,26231,27512,36020,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,39740,63751,21483,22317,22862,25542,27131,29674,30789,31418,31429,31998,33909,35215,36211,36917,38312,21243,22343,30023,31584,33740,37406,63752,27224,20811,21067,21127,25119,26840,26997,38553,20677,21156,21220,25027,26020,26681,27135,29822,31563,33465,33771,35250,35641,36817,39241,63753,20170,22935,25810,26129,27278,29748,31105,31165,33449,34942,34943,35167,63754,37670,20235,21450,24613,25201,27762,32026,32102,20120,20834,30684,32943,20225,20238,20854,20864,21980,22120,22331,22522,22524,22804,22855,22931,23492,23696,23822,24049,24190,24524,25216,26071,26083,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,26398,26399,26462,26827,26820,27231,27450,27683,27773,27778,28103,29592,29734,29738,29826,29859,30072,30079,30849,30959,31041,31047,31048,31098,31637,32000,32186,32648,32774,32813,32908,35352,35663,35912,36215,37665,37668,39138,39249,39438,39439,39525,40594,32202,20342,21513,25326,26708,37329,21931,20794,63755,63756,23068,25062,63757,25295,25343,63758,63759,63760,63761,63762,63763,37027,63764,63765,63766,63767,63768,35582,63769,63770,63771,63772,26262,63773,29014,63774,63775,38627,63776,25423,25466,21335,63777,26511,26976,28275,63778,30007,63779,63780,63781,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,32013,63782,63783,34930,22218,23064,63784,63785,63786,63787,63788,20035,63789,20839,22856,26608,32784,63790,22899,24180,25754,31178,24565,24684,25288,25467,23527,23511,21162,63791,22900,24361,24594,63792,63793,63794,29785,63795,63796,63797,63798,63799,63800,39377,63801,63802,63803,63804,63805,63806,63807,63808,63809,63810,63811,28611,63812,63813,33215,36786,24817,63814,63815,33126,63816,63817,23615,63818,63819,63820,63821,63822,63823,63824,63825,23273,35365,26491,32016,63826,63827,63828,63829,63830,63831,33021,63832,63833,23612,27877,21311,28346,22810,33590,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,20025,20150,20294,21934,22296,22727,24406,26039,26086,27264,27573,28237,30701,31471,31774,32222,34507,34962,37170,37723,25787,28606,29562,30136,36948,21846,22349,25018,25812,26311,28129,28251,28525,28601,30192,32835,33213,34113,35203,35527,35674,37663,27795,30035,31572,36367,36957,21776,22530,22616,24162,25095,25758,26848,30070,31958,34739,40680,20195,22408,22382,22823,23565,23729,24118,24453,25140,25825,29619,33274,34955,36024,38538,40667,23429,24503,24755,20498,20992,21040,22294,22581,22615,23566,23648,23798,23947,24230,24466,24764,25361,25481,25623,26691,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,26873,27330,28120,28193,28372,28644,29182,30428,30585,31153,31291,33796,35241,36077,36339,36424,36867,36884,36947,37117,37709,38518,38876,27602,28678,29272,29346,29544,30563,31167,31716,32411,35712,22697,24775,25958,26109,26302,27788,28958,29129,35930,38931,20077,31361,20189,20908,20941,21205,21516,24999,26481,26704,26847,27934,28540,30140,30643,31461,33012,33891,37509,20828,26007,26460,26515,30168,31431,33651,63834,35910,36887,38957,23663,33216,33434,36929,36975,37389,24471,23965,27225,29128,30331,31561,34276,35588,37159,39472,21895,25078,63835,30313,32645,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,34367,34746,35064,37007,63836,27931,28889,29662,32097,33853,63837,37226,39409,63838,20098,21365,27396,27410,28734,29211,34349,40478,21068,36771,23888,25829,25900,27414,28651,31811,32412,34253,35172,35261,25289,33240,34847,24266,26391,28010,29436,29701,29807,34690,37086,20358,23821,24480,33802,20919,25504,30053,20142,20486,20841,20937,26753,27153,31918,31921,31975,33391,35538,36635,37327,20406,20791,21237,21570,24300,24942,25150,26053,27354,28670,31018,34268,34851,38317,39522,39530,40599,40654,21147,26310,27511,28701,31019,36706,38722,24976,25088,25891,28451,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,29001,29833,32244,32879,34030,36646,36899,37706,20925,21015,21155,27916,28872,35010,24265,25986,27566,28610,31806,29557,20196,20278,22265,63839,23738,23994,24604,29618,31533,32666,32718,32838,36894,37428,38646,38728,38936,40801,20363,28583,31150,37300,38583,21214,63840,25736,25796,27347,28510,28696,29200,30439,32769,34310,34396,36335,36613,38706,39791,40442,40565,30860,31103,32160,33737,37636,40575,40595,35542,22751,24324,26407,28711,29903,31840,32894,20769,28712,29282,30922,36034,36058,36084,38647,20102,20698,23534,24278,26009,29134,30274,30637,32842,34044,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,36988,39719,40845,22744,23105,23650,27155,28122,28431,30267,32047,32311,34078,35128,37860,38475,21129,26066,26611,27060,27969,28316,28687,29705,29792,30041,30244,30827,35628,39006,20845,25134,38520,20374,20523,23833,28138,32184,36650,24459,24900,26647,63841,38534,21202,32907,20956,20940,26974,31260,32190,33777,38517,20442,21033,21400,21519,21774,23653,24743,26446,26792,28012,29313,29432,29702,29827,63842,30178,31852,32633,32696,33673,35023,35041,37324,37328,38626,39881,21533,28542,29136,29848,34298,36522,38563,40023,40607,26519,28107,29747,33256,38678,30764,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,31435,31520,31890,25705,29802,30194,30908,30952,39340,39764,40635,23518,24149,28448,33180,33707,37000,19975,21325,23081,24018,24398,24930,25405,26217,26364,28415,28459,28771,30622,33836,34067,34875,36627,39237,39995,21788,25273,26411,27819,33545,35178,38778,20129,22916,24536,24537,26395,32178,32596,33426,33579,33725,36638,37017,22475,22969,23186,23504,26151,26522,26757,27599,29028,32629,36023,36067,36993,39749,33032,35978,38476,39488,40613,23391,27667,29467,30450,30431,33804,20906,35219,20813,20885,21193,26825,27796,30468,30496,32191,32236,38754,40629,28357,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,34065,20901,21517,21629,26126,26269,26919,28319,30399,30609,33559,33986,34719,37225,37528,40180,34946,20398,20882,21215,22982,24125,24917,25720,25721,26286,26576,27169,27597,27611,29279,29281,29761,30520,30683,32791,33468,33541,35584,35624,35980,26408,27792,29287,30446,30566,31302,40361,27519,27794,22818,26406,33945,21359,22675,22937,24287,25551,26164,26483,28218,29483,31447,33495,37672,21209,24043,25006,25035,25098,25287,25771,26080,26969,27494,27595,28961,29687,30045,32326,33310,33538,34154,35491,36031,38695,40289,22696,40664,20497,21006,21563,21839,25991,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,27766,32010,32011,32862,34442,38272,38639,21247,27797,29289,21619,23194,23614,23883,24396,24494,26410,26806,26979,28220,28228,30473,31859,32654,34183,35598,36855,38753,40692,23735,24758,24845,25003,25935,26107,26108,27665,27887,29599,29641,32225,38292,23494,34588,35600,21085,21338,25293,25615,25778,26420,27192,27850,29632,29854,31636,31893,32283,33162,33334,34180,36843,38649,39361,20276,21322,21453,21467,25292,25644,25856,26001,27075,27886,28504,29677,30036,30242,30436,30460,30928,30971,31020,32070,33324,34784,36820,38930,39151,21187,25300,25765,28196,28497,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,30332,36299,37297,37474,39662,39747,20515,20621,22346,22952,23592,24135,24439,25151,25918,26041,26049,26121,26507,27036,28354,30917,32033,32938,33152,33323,33459,33953,34444,35370,35607,37030,38450,40848,20493,20467,63843,22521,24472,25308,25490,26479,28227,28953,30403,32972,32986,35060,35061,35097,36064,36649,37197,38506,20271,20336,24091,26575,26658,30333,30334,39748,24161,27146,29033,29140,30058,63844,32321,34115,34281,39132,20240,31567,32624,38309,20961,24070,26805,27710,27726,27867,29359,31684,33539,27861,29754,20731,21128,22721,25816,27287,29863,30294,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,30887,34327,38370,38713,63845,21342,24321,35722,36776,36783,37002,21029,30629,40009,40712,19993,20482,20853,23643,24183,26142,26170,26564,26821,28851,29953,30149,31177,31453,36647,39200,39432,20445,22561,22577,23542,26222,27493,27921,28282,28541,29668,29995,33769,35036,35091,35676,36628,20239,20693,21264,21340,23443,24489,26381,31119,33145,33583,34068,35079,35206,36665,36667,39333,39954,26412,20086,20472,22857,23553,23791,23792,25447,26834,28925,29090,29739,32299,34028,34562,36898,37586,40179,19981,20184,20463,20613,21078,21103,21542,21648,22496,22827,23142,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,23386,23413,23500,24220,63846,25206,25975,26023,28014,28325,29238,31526,31807,32566,33104,33105,33178,33344,33433,33705,35331,36000,36070,36091,36212,36282,37096,37340,38428,38468,39385,40167,21271,20998,21545,22132,22707,22868,22894,24575,24996,25198,26128,27774,28954,30406,31881,31966,32027,33452,36033,38640,63847,20315,24343,24447,25282,23849,26379,26842,30844,32323,40300,19989,20633,21269,21290,21329,22915,23138,24199,24754,24970,25161,25209,26000,26503,27047,27604,27606,27607,27608,27832,63848,29749,30202,30738,30865,31189,31192,31875,32203,32737,32933,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,33086,33218,33778,34586,35048,35513,35692,36027,37145,38750,39131,40763,22188,23338,24428,25996,27315,27567,27996,28657,28693,29277,29613,36007,36051,38971,24977,27703,32856,39425,20045,20107,20123,20181,20282,20284,20351,20447,20735,21490,21496,21766,21987,22235,22763,22882,23057,23531,23546,23556,24051,24107,24473,24605,25448,26012,26031,26614,26619,26797,27515,27801,27863,28195,28681,29509,30722,31038,31040,31072,31169,31721,32023,32114,32902,33293,33678,34001,34503,35039,35408,35422,35613,36060,36198,36781,37034,39164,39391,40605,21066,63849,26388,63850,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,20632,21034,23665,25955,27733,29642,29987,30109,31639,33948,37240,38704,20087,25746,27578,29022,34217,19977,63851,26441,26862,28183,33439,34072,34923,25591,28545,37394,39087,19978,20663,20687,20767,21830,21930,22039,23360,23577,23776,24120,24202,24224,24258,24819,26705,27233,28248,29245,29248,29376,30456,31077,31665,32724,35059,35316,35443,35937,36062,38684,22622,29885,36093,21959,63852,31329,32034,33394,29298,29983,29989,63853,31513,22661,22779,23996,24207,24246,24464,24661,25234,25471,25933,26257,26329,26360,26646,26866,29312,29790,31598,32110,32214,32626,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,32997,33298,34223,35199,35475,36893,37604,40653,40736,22805,22893,24109,24796,26132,26227,26512,27728,28101,28511,30707,30889,33990,37323,37675,20185,20682,20808,21892,23307,23459,25159,25982,26059,28210,29053,29697,29764,29831,29887,30316,31146,32218,32341,32680,33146,33203,33337,34330,34796,35445,36323,36984,37521,37925,39245,39854,21352,23633,26964,27844,27945,28203,33292,34203,35131,35373,35498,38634,40807,21089,26297,27570,32406,34814,36109,38275,38493,25885,28041,29166,63854,22478,22995,23468,24615,24826,25104,26143,26207,29481,29689,30427,30465,31596,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,32854,32882,33125,35488,37266,19990,21218,27506,27927,31237,31545,32048,63855,36016,21484,22063,22609,23477,23567,23569,24034,25152,25475,25620,26157,26803,27836,28040,28335,28703,28836,29138,29990,30095,30094,30233,31505,31712,31787,32032,32057,34092,34157,34311,35380,36877,36961,37045,37559,38902,39479,20439,23660,26463,28049,31903,32396,35606,36118,36895,23403,24061,25613,33984,36956,39137,29575,23435,24730,26494,28126,35359,35494,36865,38924,21047,63856,28753,30862,37782,34928,37335,20462,21463,22013,22234,22402,22781,23234,23432,23723,23744,24101,24833,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,25101,25163,25480,25628,25910,25976,27193,27530,27700,27929,28465,29159,29417,29560,29703,29874,30246,30561,31168,31319,31466,31929,32143,32172,32353,32670,33065,33585,33936,34010,34282,34966,35504,35728,36664,36930,36995,37228,37526,37561,38539,38567,38568,38614,38656,38920,39318,39635,39706,21460,22654,22809,23408,23487,28113,28506,29087,29729,29881,32901,33789,24033,24455,24490,24642,26092,26642,26991,27219,27529,27957,28147,29667,30462,30636,31565,32020,33059,33308,33600,34036,34147,35426,35524,37255,37662,38918,39348,25100,34899,36848,37477,23815,23847,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,23913,29791,33181,34664,28629,25342,32722,35126,35186,19998,20056,20711,21213,21319,25215,26119,32361,34821,38494,20365,21273,22070,22987,23204,23608,23630,23629,24066,24337,24643,26045,26159,26178,26558,26612,29468,30690,31034,32709,33940,33997,35222,35430,35433,35553,35925,35962,22516,23508,24335,24687,25325,26893,27542,28252,29060,31698,34645,35672,36606,39135,39166,20280,20353,20449,21627,23072,23480,24892,26032,26216,29180,30003,31070,32051,33102,33251,33688,34218,34254,34563,35338,36523,36763,63857,36805,22833,23460,23526,24713,23529,23563,24515,27777,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,63858,28145,28683,29978,33455,35574,20160,21313,63859,38617,27663,20126,20420,20818,21854,23077,23784,25105,29273,33469,33706,34558,34905,35357,38463,38597,39187,40201,40285,22538,23731,23997,24132,24801,24853,25569,27138,28197,37122,37716,38990,39952,40823,23433,23736,25353,26191,26696,30524,38593,38797,38996,39839,26017,35585,36555,38332,21813,23721,24022,24245,26263,30284,33780,38343,22739,25276,29390,40232,20208,22830,24591,26171,27523,31207,40230,21395,21696,22467,23830,24859,26326,28079,30861,33406,38552,38724,21380,25212,25494,28082,32266,33099,38989,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,27387,32588,40367,40474,20063,20539,20918,22812,24825,25590,26928,29242,32822,63860,37326,24369,63861,63862,32004,33509,33903,33979,34277,36493,63863,20335,63864,63865,22756,23363,24665,25562,25880,25965,26264,63866,26954,27171,27915,28673,29036,30162,30221,31155,31344,63867,32650,63868,35140,63869,35731,37312,38525,63870,39178,22276,24481,26044,28417,30208,31142,35486,39341,39770,40812,20740,25014,25233,27277,33222,20547,22576,24422,28937,35328,35578,23420,34326,20474,20796,22196,22852,25513,28153,23978,26989,20870,20104,20313,63871,63872,63873,22914,63874,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,63875,27487,27741,63876,29877,30998,63877,33287,33349,33593,36671,36701,63878,39192,63879,63880,63881,20134,63882,22495,24441,26131,63883,63884,30123,32377,35695,63885,36870,39515,22181,22567,23032,23071,23476,63886,24310,63887,63888,25424,25403,63889,26941,27783,27839,28046,28051,28149,28436,63890,28895,28982,29017,63891,29123,29141,63892,30799,30831,63893,31605,32227,63894,32303,63895,34893,36575,63896,63897,63898,37467,63899,40182,63900,63901,63902,24709,28037,63903,29105,63904,63905,38321,21421,63906,63907,63908,26579,63909,28814,28976,29744,33398,33490,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,63910,38331,39653,40573,26308,63911,29121,33865,63912,63913,22603,63914,63915,23992,24433,63916,26144,26254,27001,27054,27704,27891,28214,28481,28634,28699,28719,29008,29151,29552,63917,29787,63918,29908,30408,31310,32403,63919,63920,33521,35424,36814,63921,37704,63922,38681,63923,63924,20034,20522,63925,21000,21473,26355,27757,28618,29450,30591,31330,33454,34269,34306,63926,35028,35427,35709,35947,63927,37555,63928,38675,38928,20116,20237,20425,20658,21320,21566,21555,21978,22626,22714,22887,23067,23524,24735,63929,25034,25942,26111,26212,26791,27738,28595,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,28879,29100,29522,31613,34568,35492,39986,40711,23627,27779,29508,29577,37434,28331,29797,30239,31337,32277,34314,20800,22725,25793,29934,29973,30320,32705,37013,38605,39252,28198,29926,31401,31402,33253,34521,34680,35355,23113,23436,23451,26785,26880,28003,29609,29715,29740,30871,32233,32747,33048,33109,33694,35916,38446,38929,26352,24448,26106,26505,27754,29579,20525,23043,27498,30702,22806,23916,24013,29477,30031,63930,63931,20709,20985,22575,22829,22934,23002,23525,63932,63933,23970,25303,25622,25747,25854,63934,26332,63935,27208,63936,29183,29796,63937,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,31368,31407,32327,32350,32768,33136,63938,34799,35201,35616,36953,63939,36992,39250,24958,27442,28020,32287,35109,36785,20433,20653,20887,21191,22471,22665,23481,24248,24898,27029,28044,28263,28342,29076,29794,29992,29996,32883,33592,33993,36362,37780,37854,63940,20110,20305,20598,20778,21448,21451,21491,23431,23507,23588,24858,24962,26100,29275,29591,29760,30402,31056,31121,31161,32006,32701,33419,34261,34398,36802,36935,37109,37354,38533,38632,38633,21206,24423,26093,26161,26671,29020,31286,37057,38922,20113,63941,27218,27550,28560,29065,32792,33464,34131,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,36939,38549,38642,38907,34074,39729,20112,29066,38596,20803,21407,21729,22291,22290,22435,23195,23236,23491,24616,24895,25588,27781,27961,28274,28304,29232,29503,29783,33489,34945,36677,36960,63942,38498,39000,40219,26376,36234,37470,20301,20553,20702,21361,22285,22996,23041,23561,24944,26256,28205,29234,29771,32239,32963,33806,33894,34111,34655,34907,35096,35586,36949,38859,39759,20083,20369,20754,20842,63943,21807,21929,23418,23461,24188,24189,24254,24736,24799,24840,24841,25540,25912,26377,63944,26580,26586,63945,26977,26978,27833,27943,63946,28216,63947,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,28641,29494,29495,63948,29788,30001,63949,30290,63950,63951,32173,33278,33848,35029,35480,35547,35565,36400,36418,36938,36926,36986,37193,37321,37742,63952,63953,22537,63954,27603,32905,32946,63955,63956,20801,22891,23609,63957,63958,28516,29607,32996,36103,63959,37399,38287,63960,63961,63962,63963,32895,25102,28700,32104,34701,63964,22432,24681,24903,27575,35518,37504,38577,20057,21535,28139,34093,38512,38899,39150,25558,27875,37009,20957,25033,33210,40441,20381,20506,20736,23452,24847,25087,25836,26885,27589,30097,30691,32681,33380,34191,34811,34915,35516,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,35696,37291,20108,20197,20234,63965,63966,22839,23016,63967,24050,24347,24411,24609,63968,63969,63970,63971,29246,29669,63972,30064,30157,63973,31227,63974,32780,32819,32900,33505,33617,63975,63976,36029,36019,36999,63977,63978,39156,39180,63979,63980,28727,30410,32714,32716,32764,35610,20154,20161,20995,21360,63981,21693,22240,23035,23493,24341,24525,28270,63982,63983,32106,33589,63984,34451,35469,63985,38765,38775,63986,63987,19968,20314,20350,22777,26085,28322,36920,37808,39353,20219,22764,22922,23001,24641,63988,63989,31252,63990,33615,36035,20837,21316,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,63991,63992,63993,20173,21097,23381,33471,20180,21050,21672,22985,23039,23376,23383,23388,24675,24904,28363,28825,29038,29574,29943,30133,30913,32043,32773,33258,33576,34071,34249,35566,36039,38604,20316,21242,22204,26027,26152,28796,28856,29237,32189,33421,37196,38592,40306,23409,26855,27544,28538,30430,23697,26283,28507,31668,31786,34870,38620,19976,20183,21280,22580,22715,22767,22892,23559,24115,24196,24373,25484,26290,26454,27167,27299,27404,28479,29254,63994,29520,29835,31456,31911,33144,33247,33255,33674,33900,34083,34196,34255,35037,36115,37292,38263,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,38556,20877,21705,22312,23472,25165,26448,26685,26771,28221,28371,28797,32289,35009,36001,36617,40779,40782,29229,31631,35533,37658,20295,20302,20786,21632,22992,24213,25269,26485,26990,27159,27822,28186,29401,29482,30141,31672,32053,33511,33785,33879,34295,35419,36015,36487,36889,37048,38606,40799,21219,21514,23265,23490,25688,25973,28404,29380,63995,30340,31309,31515,31821,32318,32735,33659,35627,36042,36196,36321,36447,36842,36857,36969,37841,20291,20346,20659,20840,20856,21069,21098,22625,22652,22880,23560,23637,24283,24731,25136,26643,27583,27656,28593,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,29006,29728,30000,30008,30033,30322,31564,31627,31661,31686,32399,35438,36670,36681,37439,37523,37666,37931,38651,39002,39019,39198,20999,25130,25240,27993,30308,31434,31680,32118,21344,23742,24215,28472,28857,31896,38673,39822,40670,25509,25722,34678,19969,20117,20141,20572,20597,21576,22979,23450,24128,24237,24311,24449,24773,25402,25919,25972,26060,26230,26232,26622,26984,27273,27491,27712,28096,28136,28191,28254,28702,28833,29582,29693,30010,30555,30855,31118,31243,31357,31934,32142,33351,35330,35562,35998,37165,37194,37336,37478,37580,37664,38662,38742,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,38748,38914,40718,21046,21137,21884,22564,24093,24351,24716,25552,26799,28639,31085,31532,33229,34234,35069,35576,36420,37261,38500,38555,38717,38988,40778,20430,20806,20939,21161,22066,24340,24427,25514,25805,26089,26177,26362,26361,26397,26781,26839,27133,28437,28526,29031,29157,29226,29866,30522,31062,31066,31199,31264,31381,31895,31967,32068,32368,32903,34299,34468,35412,35519,36249,36481,36896,36973,37347,38459,38613,40165,26063,31751,36275,37827,23384,23562,21330,25305,29469,20519,23447,24478,24752,24939,26837,28121,29742,31278,32066,32156,32305,33131,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,36394,36405,37758,37912,20304,22352,24038,24231,25387,32618,20027,20303,20367,20570,23005,32964,21610,21608,22014,22863,23449,24030,24282,26205,26417,26609,26666,27880,27954,28234,28557,28855,29664,30087,31820,32002,32044,32162,33311,34523,35387,35461,36208,36490,36659,36913,37198,37202,37956,39376,31481,31909,20426,20737,20934,22472,23535,23803,26201,27197,27994,28310,28652,28940,30063,31459,34850,36897,36981,38603,39423,33537,20013,20210,34886,37325,21373,27355,26987,27713,33914,22686,24974,26366,25327,28893,29969,30151,32338,33976,35657,36104,20043,21482,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,21675,22320,22336,24535,25345,25351,25711,25903,26088,26234,26525,26547,27490,27744,27802,28460,30693,30757,31049,31063,32025,32930,33026,33267,33437,33463,34584,35468,63996,36100,36286,36978,30452,31257,31287,32340,32887,21767,21972,22645,25391,25634,26185,26187,26733,27035,27524,27941,28337,29645,29800,29857,30043,30137,30433,30494,30603,31206,32265,32285,33275,34095,34967,35386,36049,36587,36784,36914,37805,38499,38515,38663,20356,21489,23018,23241,24089,26702,29894,30142,31209,31378,33187,34541,36074,36300,36845,26015,26389,63997,22519,28503,32221,36655,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,37878,38598,24501,25074,28548,19988,20376,20511,21449,21983,23919,24046,27425,27492,30923,31642,63998,36425,36554,36974,25417,25662,30528,31364,37679,38015,40810,25776,28591,29158,29864,29914,31428,31762,32386,31922,32408,35738,36106,38013,39184,39244,21049,23519,25830,26413,32046,20717,21443,22649,24920,24921,25082,26028,31449,35730,35734,20489,20513,21109,21809,23100,24288,24432,24884,25950,26124,26166,26274,27085,28356,28466,29462,30241,31379,33081,33369,33750,33980,20661,22512,23488,23528,24425,25505,30758,32181,33756,34081,37319,37365,20874,26613,31574,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,36012,20932,22971,24765,34389,20508,63999,21076,23610,24957,25114,25299,25842,26021,28364,30240,33034,36448,38495,38587,20191,21315,21912,22825,24029,25797,27849,28154,29588,31359,33307,34214,36068,36368,36983,37351,38369,38433,38854,20984,21746,21894,24505,25764,28552,32180,36639,36685,37941,20681,23574,27838,28155,29979,30651,31805,31844,35449,35522,22558,22974,24086,25463,29266,30090,30571,35548,36028,36626,24307,26228,28152,32893,33729,35531,38737,39894,64000,21059,26367,28053,28399,32224,35558,36910,36958,39636,21021,21119,21736,24980,25220,25307,26786,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,26898,26970,27189,28818,28966,30813,30977,30990,31186,31245,32918,33400,33493,33609,34121,35970,36229,37218,37259,37294,20419,22225,29165,30679,34560,35320,23544,24534,26449,37032,21474,22618,23541,24740,24961,25696,32317,32880,34085,37507,25774,20652,23828,26368,22684,25277,25512,26894,27000,27166,28267,30394,31179,33467,33833,35535,36264,36861,37138,37195,37276,37648,37656,37786,38619,39478,39949,19985,30044,31069,31482,31569,31689,32302,33988,36441,36468,36600,36880,26149,26943,29763,20986,26414,40668,20805,24544,27798,34802,34909,34935,24756,33205,33795,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,36101,21462,21561,22068,23094,23601,28810,32736,32858,33030,33261,36259,37257,39519,40434,20596,20164,21408,24827,28204,23652,20360,20516,21988,23769,24159,24677,26772,27835,28100,29118,30164,30196,30305,31258,31305,32199,32251,32622,33268,34473,36636,38601,39347,40786,21063,21189,39149,35242,19971,26578,28422,20405,23522,26517,27784,28024,29723,30759,37341,37756,34756,31204,31281,24555,20182,21668,21822,22702,22949,24816,25171,25302,26422,26965,33333,38464,39345,39389,20524,21331,21828,22396,64001,25176,64002,25826,26219,26589,28609,28655,29730,29752,35351,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,37944,21585,22022,22374,24392,24986,27470,28760,28845,32187,35477,22890,33067,25506,30472,32829,36010,22612,25645,27067,23445,24081,28271,64003,34153,20812,21488,22826,24608,24907,27526,27760,27888,31518,32974,33492,36294,37040,39089,64004,25799,28580,25745,25860,20814,21520,22303,35342,24927,26742,64005,30171,31570,32113,36890,22534,27084,33151,35114,36864,38969,20600,22871,22956,25237,36879,39722,24925,29305,38358,22369,23110,24052,25226,25773,25850,26487,27874,27966,29228,29750,30772,32631,33453,36315,38935,21028,22338,26495,29256,29923,36009,36774,37393,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,38442,20843,21485,25420,20329,21764,24726,25943,27803,28031,29260,29437,31255,35207,35997,24429,28558,28921,33192,24846,20415,20559,25153,29255,31687,32232,32745,36941,38829,39449,36022,22378,24179,26544,33805,35413,21536,23318,24163,24290,24330,25987,32954,34109,38281,38491,20296,21253,21261,21263,21638,21754,22275,24067,24598,25243,25265,25429,64006,27873,28006,30129,30770,32990,33071,33502,33889,33970,34957,35090,36875,37610,39165,39825,24133,26292,26333,28689,29190,64007,20469,21117,24426,24915,26451,27161,28418,29922,31080,34920,35961,39111,39108,39491,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,21697,31263,26963,35575,35914,39080,39342,24444,25259,30130,30382,34987,36991,38466,21305,24380,24517,27852,29644,30050,30091,31558,33534,39325,20047,36924,19979,20309,21414,22799,24264,26160,27827,29781,33655,34662,36032,36944,38686,39957,22737,23416,34384,35604,40372,23506,24680,24717,26097,27735,28450,28579,28698,32597,32752,38289,38290,38480,38867,21106,36676,20989,21547,21688,21859,21898,27323,28085,32216,33382,37532,38519,40569,21512,21704,30418,34532,38308,38356,38492,20130,20233,23022,23270,24055,24658,25239,26477,26689,27782,28207,32568,32923,33322,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,64008,64009,38917,20133,20565,21683,22419,22874,23401,23475,25032,26999,28023,28707,34809,35299,35442,35559,36994,39405,39608,21182,26680,20502,24184,26447,33607,34892,20139,21521,22190,29670,37141,38911,39177,39255,39321,22099,22687,34395,35377,25010,27382,29563,36562,27463,38570,39511,22869,29184,36203,38761,20436,23796,24358,25080,26203,27883,28843,29572,29625,29694,30505,30541,32067,32098,32291,33335,34898,64010,36066,37449,39023,23377,31348,34880,38913,23244,20448,21332,22846,23805,25406,28025,29433,33029,33031,33698,37583,38960,20136,20804,21009,22411,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,24418,27842,28366,28677,28752,28847,29074,29673,29801,33610,34722,34913,36872,37026,37795,39336,20846,24407,24800,24935,26291,34137,36426,37295,38795,20046,20114,21628,22741,22778,22909,23733,24359,25142,25160,26122,26215,27627,28009,28111,28246,28408,28564,28640,28649,28765,29392,29733,29786,29920,30355,31068,31946,32286,32993,33446,33899,33983,34382,34399,34676,35703,35946,37804,38912,39013,24785,25110,37239,23130,26127,28151,28222,29759,39746,24573,24794,31503,21700,24344,27742,27859,27946,28888,32005,34425,35340,40251,21270,21644,23301,27194,28779,30069,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,31117,31166,33457,33775,35441,35649,36008,38772,64011,25844,25899,30906,30907,31339,20024,21914,22864,23462,24187,24739,25563,27489,26213,26707,28185,29029,29872,32008,36996,39529,39973,27963,28369,29502,35905,38346,20976,24140,24488,24653,24822,24880,24908,26179,26180,27045,27841,28255,28361,28514,29004,29852,30343,31681,31783,33618,34647,36945,38541,40643,21295,22238,24315,24458,24674,24724,25079,26214,26371,27292,28142,28590,28784,29546,32362,33214,33588,34516,35496,36036,21123,29554,23446,27243,37892,21742,22150,23389,25928,25989,26313,26783,28045,28102,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,29243,32948,37237,39501,20399,20505,21402,21518,21564,21897,21957,24127,24460,26429,29030,29661,36869,21211,21235,22628,22734,28932,29071,29179,34224,35347,26248,34216,21927,26244,29002,33841,21321,21913,27585,24409,24509,25582,26249,28999,35569,36637,40638,20241,25658,28875,30054,34407,24676,35662,40440,20807,20982,21256,27958,33016,40657,26133,27427,28824,30165,21507,23673,32007,35350,27424,27453,27462,21560,24688,27965,32725,33288,20694,20958,21916,22123,22221,23020,23305,24076,24985,24984,25137,26206,26342,29081,29113,29114,29351,31143,31232,32690,35440,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],
27013 "gb18030":[19970,19972,19973,19974,19983,19986,19991,19999,20000,20001,20003,20006,20009,20014,20015,20017,20019,20021,20023,20028,20032,20033,20034,20036,20038,20042,20049,20053,20055,20058,20059,20066,20067,20068,20069,20071,20072,20074,20075,20076,20077,20078,20079,20082,20084,20085,20086,20087,20088,20089,20090,20091,20092,20093,20095,20096,20097,20098,20099,20100,20101,20103,20106,20112,20118,20119,20121,20124,20125,20126,20131,20138,20143,20144,20145,20148,20150,20151,20152,20153,20156,20157,20158,20168,20172,20175,20176,20178,20186,20187,20188,20192,20194,20198,20199,20201,20205,20206,20207,20209,20212,20216,20217,20218,20220,20222,20224,20226,20227,20228,20229,20230,20231,20232,20235,20236,20242,20243,20244,20245,20246,20252,20253,20257,20259,20264,20265,20268,20269,20270,20273,20275,20277,20279,20281,20283,20286,20287,20288,20289,20290,20292,20293,20295,20296,20297,20298,20299,20300,20306,20308,20310,20321,20322,20326,20328,20330,20331,20333,20334,20337,20338,20341,20343,20344,20345,20346,20349,20352,20353,20354,20357,20358,20359,20362,20364,20366,20368,20370,20371,20373,20374,20376,20377,20378,20380,20382,20383,20385,20386,20388,20395,20397,20400,20401,20402,20403,20404,20406,20407,20408,20409,20410,20411,20412,20413,20414,20416,20417,20418,20422,20423,20424,20425,20427,20428,20429,20434,20435,20436,20437,20438,20441,20443,20448,20450,20452,20453,20455,20459,20460,20464,20466,20468,20469,20470,20471,20473,20475,20476,20477,20479,20480,20481,20482,20483,20484,20485,20486,20487,20488,20489,20490,20491,20494,20496,20497,20499,20501,20502,20503,20507,20509,20510,20512,20514,20515,20516,20519,20523,20527,20528,20529,20530,20531,20532,20533,20534,20535,20536,20537,20539,20541,20543,20544,20545,20546,20548,20549,20550,20553,20554,20555,20557,20560,20561,20562,20563,20564,20566,20567,20568,20569,20571,20573,20574,20575,20576,20577,20578,20579,20580,20582,20583,20584,20585,20586,20587,20589,20590,20591,20592,20593,20594,20595,20596,20597,20600,20601,20602,20604,20605,20609,20610,20611,20612,20614,20615,20617,20618,20619,20620,20622,20623,20624,20625,20626,20627,20628,20629,20630,20631,20632,20633,20634,20635,20636,20637,20638,20639,20640,20641,20642,20644,20646,20650,20651,20653,20654,20655,20656,20657,20659,20660,20661,20662,20663,20664,20665,20668,20669,20670,20671,20672,20673,20674,20675,20676,20677,20678,20679,20680,20681,20682,20683,20684,20685,20686,20688,20689,20690,20691,20692,20693,20695,20696,20697,20699,20700,20701,20702,20703,20704,20705,20706,20707,20708,20709,20712,20713,20714,20715,20719,20720,20721,20722,20724,20726,20727,20728,20729,20730,20732,20733,20734,20735,20736,20737,20738,20739,20740,20741,20744,20745,20746,20748,20749,20750,20751,20752,20753,20755,20756,20757,20758,20759,20760,20761,20762,20763,20764,20765,20766,20767,20768,20770,20771,20772,20773,20774,20775,20776,20777,20778,20779,20780,20781,20782,20783,20784,20785,20786,20787,20788,20789,20790,20791,20792,20793,20794,20795,20796,20797,20798,20802,20807,20810,20812,20814,20815,20816,20818,20819,20823,20824,20825,20827,20829,20830,20831,20832,20833,20835,20836,20838,20839,20841,20842,20847,20850,20858,20862,20863,20867,20868,20870,20871,20874,20875,20878,20879,20880,20881,20883,20884,20888,20890,20893,20894,20895,20897,20899,20902,20903,20904,20905,20906,20909,20910,20916,20920,20921,20922,20926,20927,20929,20930,20931,20933,20936,20938,20941,20942,20944,20946,20947,20948,20949,20950,20951,20952,20953,20954,20956,20958,20959,20962,20963,20965,20966,20967,20968,20969,20970,20972,20974,20977,20978,20980,20983,20990,20996,20997,21001,21003,21004,21007,21008,21011,21012,21013,21020,21022,21023,21025,21026,21027,21029,21030,21031,21034,21036,21039,21041,21042,21044,21045,21052,21054,21060,21061,21062,21063,21064,21065,21067,21070,21071,21074,21075,21077,21079,21080,21081,21082,21083,21085,21087,21088,21090,21091,21092,21094,21096,21099,21100,21101,21102,21104,21105,21107,21108,21109,21110,21111,21112,21113,21114,21115,21116,21118,21120,21123,21124,21125,21126,21127,21129,21130,21131,21132,21133,21134,21135,21137,21138,21140,21141,21142,21143,21144,21145,21146,21148,21156,21157,21158,21159,21166,21167,21168,21172,21173,21174,21175,21176,21177,21178,21179,21180,21181,21184,21185,21186,21188,21189,21190,21192,21194,21196,21197,21198,21199,21201,21203,21204,21205,21207,21209,21210,21211,21212,21213,21214,21216,21217,21218,21219,21221,21222,21223,21224,21225,21226,21227,21228,21229,21230,21231,21233,21234,21235,21236,21237,21238,21239,21240,21243,21244,21245,21249,21250,21251,21252,21255,21257,21258,21259,21260,21262,21265,21266,21267,21268,21272,21275,21276,21278,21279,21282,21284,21285,21287,21288,21289,21291,21292,21293,21295,21296,21297,21298,21299,21300,21301,21302,21303,21304,21308,21309,21312,21314,21316,21318,21323,21324,21325,21328,21332,21336,21337,21339,21341,21349,21352,21354,21356,21357,21362,21366,21369,21371,21372,21373,21374,21376,21377,21379,21383,21384,21386,21390,21391,21392,21393,21394,21395,21396,21398,21399,21401,21403,21404,21406,21408,21409,21412,21415,21418,21419,21420,21421,21423,21424,21425,21426,21427,21428,21429,21431,21432,21433,21434,21436,21437,21438,21440,21443,21444,21445,21446,21447,21454,21455,21456,21458,21459,21461,21466,21468,21469,21470,21473,21474,21479,21492,21498,21502,21503,21504,21506,21509,21511,21515,21524,21528,21529,21530,21532,21538,21540,21541,21546,21552,21555,21558,21559,21562,21565,21567,21569,21570,21572,21573,21575,21577,21580,21581,21582,21583,21585,21594,21597,21598,21599,21600,21601,21603,21605,21607,21609,21610,21611,21612,21613,21614,21615,21616,21620,21625,21626,21630,21631,21633,21635,21637,21639,21640,21641,21642,21645,21649,21651,21655,21656,21660,21662,21663,21664,21665,21666,21669,21678,21680,21682,21685,21686,21687,21689,21690,21692,21694,21699,21701,21706,21707,21718,21720,21723,21728,21729,21730,21731,21732,21739,21740,21743,21744,21745,21748,21749,21750,21751,21752,21753,21755,21758,21760,21762,21763,21764,21765,21768,21770,21771,21772,21773,21774,21778,21779,21781,21782,21783,21784,21785,21786,21788,21789,21790,21791,21793,21797,21798,21800,21801,21803,21805,21810,21812,21813,21814,21816,21817,21818,21819,21821,21824,21826,21829,21831,21832,21835,21836,21837,21838,21839,21841,21842,21843,21844,21847,21848,21849,21850,21851,21853,21854,21855,21856,21858,21859,21864,21865,21867,21871,21872,21873,21874,21875,21876,21881,21882,21885,21887,21893,21894,21900,21901,21902,21904,21906,21907,21909,21910,21911,21914,21915,21918,21920,21921,21922,21923,21924,21925,21926,21928,21929,21930,21931,21932,21933,21934,21935,21936,21938,21940,21942,21944,21946,21948,21951,21952,21953,21954,21955,21958,21959,21960,21962,21963,21966,21967,21968,21973,21975,21976,21977,21978,21979,21982,21984,21986,21991,21993,21997,21998,22000,22001,22004,22006,22008,22009,22010,22011,22012,22015,22018,22019,22020,22021,22022,22023,22026,22027,22029,22032,22033,22034,22035,22036,22037,22038,22039,22041,22042,22044,22045,22048,22049,22050,22053,22054,22056,22057,22058,22059,22062,22063,22064,22067,22069,22071,22072,22074,22076,22077,22078,22080,22081,22082,22083,22084,22085,22086,22087,22088,22089,22090,22091,22095,22096,22097,22098,22099,22101,22102,22106,22107,22109,22110,22111,22112,22113,22115,22117,22118,22119,22125,22126,22127,22128,22130,22131,22132,22133,22135,22136,22137,22138,22141,22142,22143,22144,22145,22146,22147,22148,22151,22152,22153,22154,22155,22156,22157,22160,22161,22162,22164,22165,22166,22167,22168,22169,22170,22171,22172,22173,22174,22175,22176,22177,22178,22180,22181,22182,22183,22184,22185,22186,22187,22188,22189,22190,22192,22193,22194,22195,22196,22197,22198,22200,22201,22202,22203,22205,22206,22207,22208,22209,22210,22211,22212,22213,22214,22215,22216,22217,22219,22220,22221,22222,22223,22224,22225,22226,22227,22229,22230,22232,22233,22236,22243,22245,22246,22247,22248,22249,22250,22252,22254,22255,22258,22259,22262,22263,22264,22267,22268,22272,22273,22274,22277,22279,22283,22284,22285,22286,22287,22288,22289,22290,22291,22292,22293,22294,22295,22296,22297,22298,22299,22301,22302,22304,22305,22306,22308,22309,22310,22311,22315,22321,22322,22324,22325,22326,22327,22328,22332,22333,22335,22337,22339,22340,22341,22342,22344,22345,22347,22354,22355,22356,22357,22358,22360,22361,22370,22371,22373,22375,22380,22382,22384,22385,22386,22388,22389,22392,22393,22394,22397,22398,22399,22400,22401,22407,22408,22409,22410,22413,22414,22415,22416,22417,22420,22421,22422,22423,22424,22425,22426,22428,22429,22430,22431,22437,22440,22442,22444,22447,22448,22449,22451,22453,22454,22455,22457,22458,22459,22460,22461,22462,22463,22464,22465,22468,22469,22470,22471,22472,22473,22474,22476,22477,22480,22481,22483,22486,22487,22491,22492,22494,22497,22498,22499,22501,22502,22503,22504,22505,22506,22507,22508,22510,22512,22513,22514,22515,22517,22518,22519,22523,22524,22526,22527,22529,22531,22532,22533,22536,22537,22538,22540,22542,22543,22544,22546,22547,22548,22550,22551,22552,22554,22555,22556,22557,22559,22562,22563,22565,22566,22567,22568,22569,22571,22572,22573,22574,22575,22577,22578,22579,22580,22582,22583,22584,22585,22586,22587,22588,22589,22590,22591,22592,22593,22594,22595,22597,22598,22599,22600,22601,22602,22603,22606,22607,22608,22610,22611,22613,22614,22615,22617,22618,22619,22620,22621,22623,22624,22625,22626,22627,22628,22630,22631,22632,22633,22634,22637,22638,22639,22640,22641,22642,22643,22644,22645,22646,22647,22648,22649,22650,22651,22652,22653,22655,22658,22660,22662,22663,22664,22666,22667,22668,22669,22670,22671,22672,22673,22676,22677,22678,22679,22680,22683,22684,22685,22688,22689,22690,22691,22692,22693,22694,22695,22698,22699,22700,22701,22702,22703,22704,22705,22706,22707,22708,22709,22710,22711,22712,22713,22714,22715,22717,22718,22719,22720,22722,22723,22724,22726,22727,22728,22729,22730,22731,22732,22733,22734,22735,22736,22738,22739,22740,22742,22743,22744,22745,22746,22747,22748,22749,22750,22751,22752,22753,22754,22755,22757,22758,22759,22760,22761,22762,22765,22767,22769,22770,22772,22773,22775,22776,22778,22779,22780,22781,22782,22783,22784,22785,22787,22789,22790,22792,22793,22794,22795,22796,22798,22800,22801,22802,22803,22807,22808,22811,22813,22814,22816,22817,22818,22819,22822,22824,22828,22832,22834,22835,22837,22838,22843,22845,22846,22847,22848,22851,22853,22854,22858,22860,22861,22864,22866,22867,22873,22875,22876,22877,22878,22879,22881,22883,22884,22886,22887,22888,22889,22890,22891,22892,22893,22894,22895,22896,22897,22898,22901,22903,22906,22907,22908,22910,22911,22912,22917,22921,22923,22924,22926,22927,22928,22929,22932,22933,22936,22938,22939,22940,22941,22943,22944,22945,22946,22950,22951,22956,22957,22960,22961,22963,22964,22965,22966,22967,22968,22970,22972,22973,22975,22976,22977,22978,22979,22980,22981,22983,22984,22985,22988,22989,22990,22991,22997,22998,23001,23003,23006,23007,23008,23009,23010,23012,23014,23015,23017,23018,23019,23021,23022,23023,23024,23025,23026,23027,23028,23029,23030,23031,23032,23034,23036,23037,23038,23040,23042,23050,23051,23053,23054,23055,23056,23058,23060,23061,23062,23063,23065,23066,23067,23069,23070,23073,23074,23076,23078,23079,23080,23082,23083,23084,23085,23086,23087,23088,23091,23093,23095,23096,23097,23098,23099,23101,23102,23103,23105,23106,23107,23108,23109,23111,23112,23115,23116,23117,23118,23119,23120,23121,23122,23123,23124,23126,23127,23128,23129,23131,23132,23133,23134,23135,23136,23137,23139,23140,23141,23142,23144,23145,23147,23148,23149,23150,23151,23152,23153,23154,23155,23160,23161,23163,23164,23165,23166,23168,23169,23170,23171,23172,23173,23174,23175,23176,23177,23178,23179,23180,23181,23182,23183,23184,23185,23187,23188,23189,23190,23191,23192,23193,23196,23197,23198,23199,23200,23201,23202,23203,23204,23205,23206,23207,23208,23209,23211,23212,23213,23214,23215,23216,23217,23220,23222,23223,23225,23226,23227,23228,23229,23231,23232,23235,23236,23237,23238,23239,23240,23242,23243,23245,23246,23247,23248,23249,23251,23253,23255,23257,23258,23259,23261,23262,23263,23266,23268,23269,23271,23272,23274,23276,23277,23278,23279,23280,23282,23283,23284,23285,23286,23287,23288,23289,23290,23291,23292,23293,23294,23295,23296,23297,23298,23299,23300,23301,23302,23303,23304,23306,23307,23308,23309,23310,23311,23312,23313,23314,23315,23316,23317,23320,23321,23322,23323,23324,23325,23326,23327,23328,23329,23330,23331,23332,23333,23334,23335,23336,23337,23338,23339,23340,23341,23342,23343,23344,23345,23347,23349,23350,23352,23353,23354,23355,23356,23357,23358,23359,23361,23362,23363,23364,23365,23366,23367,23368,23369,23370,23371,23372,23373,23374,23375,23378,23382,23390,23392,23393,23399,23400,23403,23405,23406,23407,23410,23412,23414,23415,23416,23417,23419,23420,23422,23423,23426,23430,23434,23437,23438,23440,23441,23442,23444,23446,23455,23463,23464,23465,23468,23469,23470,23471,23473,23474,23479,23482,23483,23484,23488,23489,23491,23496,23497,23498,23499,23501,23502,23503,23505,23508,23509,23510,23511,23512,23513,23514,23515,23516,23520,23522,23523,23526,23527,23529,23530,23531,23532,23533,23535,23537,23538,23539,23540,23541,23542,23543,23549,23550,23552,23554,23555,23557,23559,23560,23563,23564,23565,23566,23568,23570,23571,23575,23577,23579,23582,23583,23584,23585,23587,23590,23592,23593,23594,23595,23597,23598,23599,23600,23602,23603,23605,23606,23607,23619,23620,23622,23623,23628,23629,23634,23635,23636,23638,23639,23640,23642,23643,23644,23645,23647,23650,23652,23655,23656,23657,23658,23659,23660,23661,23664,23666,23667,23668,23669,23670,23671,23672,23675,23676,23677,23678,23680,23683,23684,23685,23686,23687,23689,23690,23691,23694,23695,23698,23699,23701,23709,23710,23711,23712,23713,23716,23717,23718,23719,23720,23722,23726,23727,23728,23730,23732,23734,23737,23738,23739,23740,23742,23744,23746,23747,23749,23750,23751,23752,23753,23754,23756,23757,23758,23759,23760,23761,23763,23764,23765,23766,23767,23768,23770,23771,23772,23773,23774,23775,23776,23778,23779,23783,23785,23787,23788,23790,23791,23793,23794,23795,23796,23797,23798,23799,23800,23801,23802,23804,23805,23806,23807,23808,23809,23812,23813,23816,23817,23818,23819,23820,23821,23823,23824,23825,23826,23827,23829,23831,23832,23833,23834,23836,23837,23839,23840,23841,23842,23843,23845,23848,23850,23851,23852,23855,23856,23857,23858,23859,23861,23862,23863,23864,23865,23866,23867,23868,23871,23872,23873,23874,23875,23876,23877,23878,23880,23881,23885,23886,23887,23888,23889,23890,23891,23892,23893,23894,23895,23897,23898,23900,23902,23903,23904,23905,23906,23907,23908,23909,23910,23911,23912,23914,23917,23918,23920,23921,23922,23923,23925,23926,23927,23928,23929,23930,23931,23932,23933,23934,23935,23936,23937,23939,23940,23941,23942,23943,23944,23945,23946,23947,23948,23949,23950,23951,23952,23953,23954,23955,23956,23957,23958,23959,23960,23962,23963,23964,23966,23967,23968,23969,23970,23971,23972,23973,23974,23975,23976,23977,23978,23979,23980,23981,23982,23983,23984,23985,23986,23987,23988,23989,23990,23992,23993,23994,23995,23996,23997,23998,23999,24000,24001,24002,24003,24004,24006,24007,24008,24009,24010,24011,24012,24014,24015,24016,24017,24018,24019,24020,24021,24022,24023,24024,24025,24026,24028,24031,24032,24035,24036,24042,24044,24045,24048,24053,24054,24056,24057,24058,24059,24060,24063,24064,24068,24071,24073,24074,24075,24077,24078,24082,24083,24087,24094,24095,24096,24097,24098,24099,24100,24101,24104,24105,24106,24107,24108,24111,24112,24114,24115,24116,24117,24118,24121,24122,24126,24127,24128,24129,24131,24134,24135,24136,24137,24138,24139,24141,24142,24143,24144,24145,24146,24147,24150,24151,24152,24153,24154,24156,24157,24159,24160,24163,24164,24165,24166,24167,24168,24169,24170,24171,24172,24173,24174,24175,24176,24177,24181,24183,24185,24190,24193,24194,24195,24197,24200,24201,24204,24205,24206,24210,24216,24219,24221,24225,24226,24227,24228,24232,24233,24234,24235,24236,24238,24239,24240,24241,24242,24244,24250,24251,24252,24253,24255,24256,24257,24258,24259,24260,24261,24262,24263,24264,24267,24268,24269,24270,24271,24272,24276,24277,24279,24280,24281,24282,24284,24285,24286,24287,24288,24289,24290,24291,24292,24293,24294,24295,24297,24299,24300,24301,24302,24303,24304,24305,24306,24307,24309,24312,24313,24315,24316,24317,24325,24326,24327,24329,24332,24333,24334,24336,24338,24340,24342,24345,24346,24348,24349,24350,24353,24354,24355,24356,24360,24363,24364,24366,24368,24370,24371,24372,24373,24374,24375,24376,24379,24381,24382,24383,24385,24386,24387,24388,24389,24390,24391,24392,24393,24394,24395,24396,24397,24398,24399,24401,24404,24409,24410,24411,24412,24414,24415,24416,24419,24421,24423,24424,24427,24430,24431,24434,24436,24437,24438,24440,24442,24445,24446,24447,24451,24454,24461,24462,24463,24465,24467,24468,24470,24474,24475,24477,24478,24479,24480,24482,24483,24484,24485,24486,24487,24489,24491,24492,24495,24496,24497,24498,24499,24500,24502,24504,24505,24506,24507,24510,24511,24512,24513,24514,24519,24520,24522,24523,24526,24531,24532,24533,24538,24539,24540,24542,24543,24546,24547,24549,24550,24552,24553,24556,24559,24560,24562,24563,24564,24566,24567,24569,24570,24572,24583,24584,24585,24587,24588,24592,24593,24595,24599,24600,24602,24606,24607,24610,24611,24612,24620,24621,24622,24624,24625,24626,24627,24628,24630,24631,24632,24633,24634,24637,24638,24640,24644,24645,24646,24647,24648,24649,24650,24652,24654,24655,24657,24659,24660,24662,24663,24664,24667,24668,24670,24671,24672,24673,24677,24678,24686,24689,24690,24692,24693,24695,24702,24704,24705,24706,24709,24710,24711,24712,24714,24715,24718,24719,24720,24721,24723,24725,24727,24728,24729,24732,24734,24737,24738,24740,24741,24743,24745,24746,24750,24752,24755,24757,24758,24759,24761,24762,24765,24766,24767,24768,24769,24770,24771,24772,24775,24776,24777,24780,24781,24782,24783,24784,24786,24787,24788,24790,24791,24793,24795,24798,24801,24802,24803,24804,24805,24810,24817,24818,24821,24823,24824,24827,24828,24829,24830,24831,24834,24835,24836,24837,24839,24842,24843,24844,24848,24849,24850,24851,24852,24854,24855,24856,24857,24859,24860,24861,24862,24865,24866,24869,24872,24873,24874,24876,24877,24878,24879,24880,24881,24882,24883,24884,24885,24886,24887,24888,24889,24890,24891,24892,24893,24894,24896,24897,24898,24899,24900,24901,24902,24903,24905,24907,24909,24911,24912,24914,24915,24916,24918,24919,24920,24921,24922,24923,24924,24926,24927,24928,24929,24931,24932,24933,24934,24937,24938,24939,24940,24941,24942,24943,24945,24946,24947,24948,24950,24952,24953,24954,24955,24956,24957,24958,24959,24960,24961,24962,24963,24964,24965,24966,24967,24968,24969,24970,24972,24973,24975,24976,24977,24978,24979,24981,24982,24983,24984,24985,24986,24987,24988,24990,24991,24992,24993,24994,24995,24996,24997,24998,25002,25003,25005,25006,25007,25008,25009,25010,25011,25012,25013,25014,25016,25017,25018,25019,25020,25021,25023,25024,25025,25027,25028,25029,25030,25031,25033,25036,25037,25038,25039,25040,25043,25045,25046,25047,25048,25049,25050,25051,25052,25053,25054,25055,25056,25057,25058,25059,25060,25061,25063,25064,25065,25066,25067,25068,25069,25070,25071,25072,25073,25074,25075,25076,25078,25079,25080,25081,25082,25083,25084,25085,25086,25088,25089,25090,25091,25092,25093,25095,25097,25107,25108,25113,25116,25117,25118,25120,25123,25126,25127,25128,25129,25131,25133,25135,25136,25137,25138,25141,25142,25144,25145,25146,25147,25148,25154,25156,25157,25158,25162,25167,25168,25173,25174,25175,25177,25178,25180,25181,25182,25183,25184,25185,25186,25188,25189,25192,25201,25202,25204,25205,25207,25208,25210,25211,25213,25217,25218,25219,25221,25222,25223,25224,25227,25228,25229,25230,25231,25232,25236,25241,25244,25245,25246,25251,25254,25255,25257,25258,25261,25262,25263,25264,25266,25267,25268,25270,25271,25272,25274,25278,25280,25281,25283,25291,25295,25297,25301,25309,25310,25312,25313,25316,25322,25323,25328,25330,25333,25336,25337,25338,25339,25344,25347,25348,25349,25350,25354,25355,25356,25357,25359,25360,25362,25363,25364,25365,25367,25368,25369,25372,25382,25383,25385,25388,25389,25390,25392,25393,25395,25396,25397,25398,25399,25400,25403,25404,25406,25407,25408,25409,25412,25415,25416,25418,25425,25426,25427,25428,25430,25431,25432,25433,25434,25435,25436,25437,25440,25444,25445,25446,25448,25450,25451,25452,25455,25456,25458,25459,25460,25461,25464,25465,25468,25469,25470,25471,25473,25475,25476,25477,25478,25483,25485,25489,25491,25492,25493,25495,25497,25498,25499,25500,25501,25502,25503,25505,25508,25510,25515,25519,25521,25522,25525,25526,25529,25531,25533,25535,25536,25537,25538,25539,25541,25543,25544,25546,25547,25548,25553,25555,25556,25557,25559,25560,25561,25562,25563,25564,25565,25567,25570,25572,25573,25574,25575,25576,25579,25580,25582,25583,25584,25585,25587,25589,25591,25593,25594,25595,25596,25598,25603,25604,25606,25607,25608,25609,25610,25613,25614,25617,25618,25621,25622,25623,25624,25625,25626,25629,25631,25634,25635,25636,25637,25639,25640,25641,25643,25646,25647,25648,25649,25650,25651,25653,25654,25655,25656,25657,25659,25660,25662,25664,25666,25667,25673,25675,25676,25677,25678,25679,25680,25681,25683,25685,25686,25687,25689,25690,25691,25692,25693,25695,25696,25697,25698,25699,25700,25701,25702,25704,25706,25707,25708,25710,25711,25712,25713,25714,25715,25716,25717,25718,25719,25723,25724,25725,25726,25727,25728,25729,25731,25734,25736,25737,25738,25739,25740,25741,25742,25743,25744,25747,25748,25751,25752,25754,25755,25756,25757,25759,25760,25761,25762,25763,25765,25766,25767,25768,25770,25771,25775,25777,25778,25779,25780,25782,25785,25787,25789,25790,25791,25793,25795,25796,25798,25799,25800,25801,25802,25803,25804,25807,25809,25811,25812,25813,25814,25817,25818,25819,25820,25821,25823,25824,25825,25827,25829,25831,25832,25833,25834,25835,25836,25837,25838,25839,25840,25841,25842,25843,25844,25845,25846,25847,25848,25849,25850,25851,25852,25853,25854,25855,25857,25858,25859,25860,25861,25862,25863,25864,25866,25867,25868,25869,25870,25871,25872,25873,25875,25876,25877,25878,25879,25881,25882,25883,25884,25885,25886,25887,25888,25889,25890,25891,25892,25894,25895,25896,25897,25898,25900,25901,25904,25905,25906,25907,25911,25914,25916,25917,25920,25921,25922,25923,25924,25926,25927,25930,25931,25933,25934,25936,25938,25939,25940,25943,25944,25946,25948,25951,25952,25953,25956,25957,25959,25960,25961,25962,25965,25966,25967,25969,25971,25973,25974,25976,25977,25978,25979,25980,25981,25982,25983,25984,25985,25986,25987,25988,25989,25990,25992,25993,25994,25997,25998,25999,26002,26004,26005,26006,26008,26010,26013,26014,26016,26018,26019,26022,26024,26026,26028,26030,26033,26034,26035,26036,26037,26038,26039,26040,26042,26043,26046,26047,26048,26050,26055,26056,26057,26058,26061,26064,26065,26067,26068,26069,26072,26073,26074,26075,26076,26077,26078,26079,26081,26083,26084,26090,26091,26098,26099,26100,26101,26104,26105,26107,26108,26109,26110,26111,26113,26116,26117,26119,26120,26121,26123,26125,26128,26129,26130,26134,26135,26136,26138,26139,26140,26142,26145,26146,26147,26148,26150,26153,26154,26155,26156,26158,26160,26162,26163,26167,26168,26169,26170,26171,26173,26175,26176,26178,26180,26181,26182,26183,26184,26185,26186,26189,26190,26192,26193,26200,26201,26203,26204,26205,26206,26208,26210,26211,26213,26215,26217,26218,26219,26220,26221,26225,26226,26227,26229,26232,26233,26235,26236,26237,26239,26240,26241,26243,26245,26246,26248,26249,26250,26251,26253,26254,26255,26256,26258,26259,26260,26261,26264,26265,26266,26267,26268,26270,26271,26272,26273,26274,26275,26276,26277,26278,26281,26282,26283,26284,26285,26287,26288,26289,26290,26291,26293,26294,26295,26296,26298,26299,26300,26301,26303,26304,26305,26306,26307,26308,26309,26310,26311,26312,26313,26314,26315,26316,26317,26318,26319,26320,26321,26322,26323,26324,26325,26326,26327,26328,26330,26334,26335,26336,26337,26338,26339,26340,26341,26343,26344,26346,26347,26348,26349,26350,26351,26353,26357,26358,26360,26362,26363,26365,26369,26370,26371,26372,26373,26374,26375,26380,26382,26383,26385,26386,26387,26390,26392,26393,26394,26396,26398,26400,26401,26402,26403,26404,26405,26407,26409,26414,26416,26418,26419,26422,26423,26424,26425,26427,26428,26430,26431,26433,26436,26437,26439,26442,26443,26445,26450,26452,26453,26455,26456,26457,26458,26459,26461,26466,26467,26468,26470,26471,26475,26476,26478,26481,26484,26486,26488,26489,26490,26491,26493,26496,26498,26499,26501,26502,26504,26506,26508,26509,26510,26511,26513,26514,26515,26516,26518,26521,26523,26527,26528,26529,26532,26534,26537,26540,26542,26545,26546,26548,26553,26554,26555,26556,26557,26558,26559,26560,26562,26565,26566,26567,26568,26569,26570,26571,26572,26573,26574,26581,26582,26583,26587,26591,26593,26595,26596,26598,26599,26600,26602,26603,26605,26606,26610,26613,26614,26615,26616,26617,26618,26619,26620,26622,26625,26626,26627,26628,26630,26637,26640,26642,26644,26645,26648,26649,26650,26651,26652,26654,26655,26656,26658,26659,26660,26661,26662,26663,26664,26667,26668,26669,26670,26671,26672,26673,26676,26677,26678,26682,26683,26687,26695,26699,26701,26703,26706,26710,26711,26712,26713,26714,26715,26716,26717,26718,26719,26730,26732,26733,26734,26735,26736,26737,26738,26739,26741,26744,26745,26746,26747,26748,26749,26750,26751,26752,26754,26756,26759,26760,26761,26762,26763,26764,26765,26766,26768,26769,26770,26772,26773,26774,26776,26777,26778,26779,26780,26781,26782,26783,26784,26785,26787,26788,26789,26793,26794,26795,26796,26798,26801,26802,26804,26806,26807,26808,26809,26810,26811,26812,26813,26814,26815,26817,26819,26820,26821,26822,26823,26824,26826,26828,26830,26831,26832,26833,26835,26836,26838,26839,26841,26843,26844,26845,26846,26847,26849,26850,26852,26853,26854,26855,26856,26857,26858,26859,26860,26861,26863,26866,26867,26868,26870,26871,26872,26875,26877,26878,26879,26880,26882,26883,26884,26886,26887,26888,26889,26890,26892,26895,26897,26899,26900,26901,26902,26903,26904,26905,26906,26907,26908,26909,26910,26913,26914,26915,26917,26918,26919,26920,26921,26922,26923,26924,26926,26927,26929,26930,26931,26933,26934,26935,26936,26938,26939,26940,26942,26944,26945,26947,26948,26949,26950,26951,26952,26953,26954,26955,26956,26957,26958,26959,26960,26961,26962,26963,26965,26966,26968,26969,26971,26972,26975,26977,26978,26980,26981,26983,26984,26985,26986,26988,26989,26991,26992,26994,26995,26996,26997,26998,27002,27003,27005,27006,27007,27009,27011,27013,27018,27019,27020,27022,27023,27024,27025,27026,27027,27030,27031,27033,27034,27037,27038,27039,27040,27041,27042,27043,27044,27045,27046,27049,27050,27052,27054,27055,27056,27058,27059,27061,27062,27064,27065,27066,27068,27069,27070,27071,27072,27074,27075,27076,27077,27078,27079,27080,27081,27083,27085,27087,27089,27090,27091,27093,27094,27095,27096,27097,27098,27100,27101,27102,27105,27106,27107,27108,27109,27110,27111,27112,27113,27114,27115,27116,27118,27119,27120,27121,27123,27124,27125,27126,27127,27128,27129,27130,27131,27132,27134,27136,27137,27138,27139,27140,27141,27142,27143,27144,27145,27147,27148,27149,27150,27151,27152,27153,27154,27155,27156,27157,27158,27161,27162,27163,27164,27165,27166,27168,27170,27171,27172,27173,27174,27175,27177,27179,27180,27181,27182,27184,27186,27187,27188,27190,27191,27192,27193,27194,27195,27196,27199,27200,27201,27202,27203,27205,27206,27208,27209,27210,27211,27212,27213,27214,27215,27217,27218,27219,27220,27221,27222,27223,27226,27228,27229,27230,27231,27232,27234,27235,27236,27238,27239,27240,27241,27242,27243,27244,27245,27246,27247,27248,27250,27251,27252,27253,27254,27255,27256,27258,27259,27261,27262,27263,27265,27266,27267,27269,27270,27271,27272,27273,27274,27275,27276,27277,27279,27282,27283,27284,27285,27286,27288,27289,27290,27291,27292,27293,27294,27295,27297,27298,27299,27300,27301,27302,27303,27304,27306,27309,27310,27311,27312,27313,27314,27315,27316,27317,27318,27319,27320,27321,27322,27323,27324,27325,27326,27327,27328,27329,27330,27331,27332,27333,27334,27335,27336,27337,27338,27339,27340,27341,27342,27343,27344,27345,27346,27347,27348,27349,27350,27351,27352,27353,27354,27355,27356,27357,27358,27359,27360,27361,27362,27363,27364,27365,27366,27367,27368,27369,27370,27371,27372,27373,27374,27375,27376,27377,27378,27379,27380,27381,27382,27383,27384,27385,27386,27387,27388,27389,27390,27391,27392,27393,27394,27395,27396,27397,27398,27399,27400,27401,27402,27403,27404,27405,27406,27407,27408,27409,27410,27411,27412,27413,27414,27415,27416,27417,27418,27419,27420,27421,27422,27423,27429,27430,27432,27433,27434,27435,27436,27437,27438,27439,27440,27441,27443,27444,27445,27446,27448,27451,27452,27453,27455,27456,27457,27458,27460,27461,27464,27466,27467,27469,27470,27471,27472,27473,27474,27475,27476,27477,27478,27479,27480,27482,27483,27484,27485,27486,27487,27488,27489,27496,27497,27499,27500,27501,27502,27503,27504,27505,27506,27507,27508,27509,27510,27511,27512,27514,27517,27518,27519,27520,27525,27528,27532,27534,27535,27536,27537,27540,27541,27543,27544,27545,27548,27549,27550,27551,27552,27554,27555,27556,27557,27558,27559,27560,27561,27563,27564,27565,27566,27567,27568,27569,27570,27574,27576,27577,27578,27579,27580,27581,27582,27584,27587,27588,27590,27591,27592,27593,27594,27596,27598,27600,27601,27608,27610,27612,27613,27614,27615,27616,27618,27619,27620,27621,27622,27623,27624,27625,27628,27629,27630,27632,27633,27634,27636,27638,27639,27640,27642,27643,27644,27646,27647,27648,27649,27650,27651,27652,27656,27657,27658,27659,27660,27662,27666,27671,27676,27677,27678,27680,27683,27685,27691,27692,27693,27697,27699,27702,27703,27705,27706,27707,27708,27710,27711,27715,27716,27717,27720,27723,27724,27725,27726,27727,27729,27730,27731,27734,27736,27737,27738,27746,27747,27749,27750,27751,27755,27756,27757,27758,27759,27761,27763,27765,27767,27768,27770,27771,27772,27775,27776,27780,27783,27786,27787,27789,27790,27793,27794,27797,27798,27799,27800,27802,27804,27805,27806,27808,27810,27816,27820,27823,27824,27828,27829,27830,27831,27834,27840,27841,27842,27843,27846,27847,27848,27851,27853,27854,27855,27857,27858,27864,27865,27866,27868,27869,27871,27876,27878,27879,27881,27884,27885,27890,27892,27897,27903,27904,27906,27907,27909,27910,27912,27913,27914,27917,27919,27920,27921,27923,27924,27925,27926,27928,27932,27933,27935,27936,27937,27938,27939,27940,27942,27944,27945,27948,27949,27951,27952,27956,27958,27959,27960,27962,27967,27968,27970,27972,27977,27980,27984,27989,27990,27991,27992,27995,27997,27999,28001,28002,28004,28005,28007,28008,28011,28012,28013,28016,28017,28018,28019,28021,28022,28025,28026,28027,28029,28030,28031,28032,28033,28035,28036,28038,28039,28042,28043,28045,28047,28048,28050,28054,28055,28056,28057,28058,28060,28066,28069,28076,28077,28080,28081,28083,28084,28086,28087,28089,28090,28091,28092,28093,28094,28097,28098,28099,28104,28105,28106,28109,28110,28111,28112,28114,28115,28116,28117,28119,28122,28123,28124,28127,28130,28131,28133,28135,28136,28137,28138,28141,28143,28144,28146,28148,28149,28150,28152,28154,28157,28158,28159,28160,28161,28162,28163,28164,28166,28167,28168,28169,28171,28175,28178,28179,28181,28184,28185,28187,28188,28190,28191,28194,28198,28199,28200,28202,28204,28206,28208,28209,28211,28213,28214,28215,28217,28219,28220,28221,28222,28223,28224,28225,28226,28229,28230,28231,28232,28233,28234,28235,28236,28239,28240,28241,28242,28245,28247,28249,28250,28252,28253,28254,28256,28257,28258,28259,28260,28261,28262,28263,28264,28265,28266,28268,28269,28271,28272,28273,28274,28275,28276,28277,28278,28279,28280,28281,28282,28283,28284,28285,28288,28289,28290,28292,28295,28296,28298,28299,28300,28301,28302,28305,28306,28307,28308,28309,28310,28311,28313,28314,28315,28317,28318,28320,28321,28323,28324,28326,28328,28329,28331,28332,28333,28334,28336,28339,28341,28344,28345,28348,28350,28351,28352,28355,28356,28357,28358,28360,28361,28362,28364,28365,28366,28368,28370,28374,28376,28377,28379,28380,28381,28387,28391,28394,28395,28396,28397,28398,28399,28400,28401,28402,28403,28405,28406,28407,28408,28410,28411,28412,28413,28414,28415,28416,28417,28419,28420,28421,28423,28424,28426,28427,28428,28429,28430,28432,28433,28434,28438,28439,28440,28441,28442,28443,28444,28445,28446,28447,28449,28450,28451,28453,28454,28455,28456,28460,28462,28464,28466,28468,28469,28471,28472,28473,28474,28475,28476,28477,28479,28480,28481,28482,28483,28484,28485,28488,28489,28490,28492,28494,28495,28496,28497,28498,28499,28500,28501,28502,28503,28505,28506,28507,28509,28511,28512,28513,28515,28516,28517,28519,28520,28521,28522,28523,28524,28527,28528,28529,28531,28533,28534,28535,28537,28539,28541,28542,28543,28544,28545,28546,28547,28549,28550,28551,28554,28555,28559,28560,28561,28562,28563,28564,28565,28566,28567,28568,28569,28570,28571,28573,28574,28575,28576,28578,28579,28580,28581,28582,28584,28585,28586,28587,28588,28589,28590,28591,28592,28593,28594,28596,28597,28599,28600,28602,28603,28604,28605,28606,28607,28609,28611,28612,28613,28614,28615,28616,28618,28619,28620,28621,28622,28623,28624,28627,28628,28629,28630,28631,28632,28633,28634,28635,28636,28637,28639,28642,28643,28644,28645,28646,28647,28648,28649,28650,28651,28652,28653,28656,28657,28658,28659,28660,28661,28662,28663,28664,28665,28666,28667,28668,28669,28670,28671,28672,28673,28674,28675,28676,28677,28678,28679,28680,28681,28682,28683,28684,28685,28686,28687,28688,28690,28691,28692,28693,28694,28695,28696,28697,28700,28701,28702,28703,28704,28705,28706,28708,28709,28710,28711,28712,28713,28714,28715,28716,28717,28718,28719,28720,28721,28722,28723,28724,28726,28727,28728,28730,28731,28732,28733,28734,28735,28736,28737,28738,28739,28740,28741,28742,28743,28744,28745,28746,28747,28749,28750,28752,28753,28754,28755,28756,28757,28758,28759,28760,28761,28762,28763,28764,28765,28767,28768,28769,28770,28771,28772,28773,28774,28775,28776,28777,28778,28782,28785,28786,28787,28788,28791,28793,28794,28795,28797,28801,28802,28803,28804,28806,28807,28808,28811,28812,28813,28815,28816,28817,28819,28823,28824,28826,28827,28830,28831,28832,28833,28834,28835,28836,28837,28838,28839,28840,28841,28842,28848,28850,28852,28853,28854,28858,28862,28863,28868,28869,28870,28871,28873,28875,28876,28877,28878,28879,28880,28881,28882,28883,28884,28885,28886,28887,28890,28892,28893,28894,28896,28897,28898,28899,28901,28906,28910,28912,28913,28914,28915,28916,28917,28918,28920,28922,28923,28924,28926,28927,28928,28929,28930,28931,28932,28933,28934,28935,28936,28939,28940,28941,28942,28943,28945,28946,28948,28951,28955,28956,28957,28958,28959,28960,28961,28962,28963,28964,28965,28967,28968,28969,28970,28971,28972,28973,28974,28978,28979,28980,28981,28983,28984,28985,28986,28987,28988,28989,28990,28991,28992,28993,28994,28995,28996,28998,28999,29000,29001,29003,29005,29007,29008,29009,29010,29011,29012,29013,29014,29015,29016,29017,29018,29019,29021,29023,29024,29025,29026,29027,29029,29033,29034,29035,29036,29037,29039,29040,29041,29044,29045,29046,29047,29049,29051,29052,29054,29055,29056,29057,29058,29059,29061,29062,29063,29064,29065,29067,29068,29069,29070,29072,29073,29074,29075,29077,29078,29079,29082,29083,29084,29085,29086,29089,29090,29091,29092,29093,29094,29095,29097,29098,29099,29101,29102,29103,29104,29105,29106,29108,29110,29111,29112,29114,29115,29116,29117,29118,29119,29120,29121,29122,29124,29125,29126,29127,29128,29129,29130,29131,29132,29133,29135,29136,29137,29138,29139,29142,29143,29144,29145,29146,29147,29148,29149,29150,29151,29153,29154,29155,29156,29158,29160,29161,29162,29163,29164,29165,29167,29168,29169,29170,29171,29172,29173,29174,29175,29176,29178,29179,29180,29181,29182,29183,29184,29185,29186,29187,29188,29189,29191,29192,29193,29194,29195,29196,29197,29198,29199,29200,29201,29202,29203,29204,29205,29206,29207,29208,29209,29210,29211,29212,29214,29215,29216,29217,29218,29219,29220,29221,29222,29223,29225,29227,29229,29230,29231,29234,29235,29236,29242,29244,29246,29248,29249,29250,29251,29252,29253,29254,29257,29258,29259,29262,29263,29264,29265,29267,29268,29269,29271,29272,29274,29276,29278,29280,29283,29284,29285,29288,29290,29291,29292,29293,29296,29297,29299,29300,29302,29303,29304,29307,29308,29309,29314,29315,29317,29318,29319,29320,29321,29324,29326,29328,29329,29331,29332,29333,29334,29335,29336,29337,29338,29339,29340,29341,29342,29344,29345,29346,29347,29348,29349,29350,29351,29352,29353,29354,29355,29358,29361,29362,29363,29365,29370,29371,29372,29373,29374,29375,29376,29381,29382,29383,29385,29386,29387,29388,29391,29393,29395,29396,29397,29398,29400,29402,29403,58566,58567,58568,58569,58570,58571,58572,58573,58574,58575,58576,58577,58578,58579,58580,58581,58582,58583,58584,58585,58586,58587,58588,58589,58590,58591,58592,58593,58594,58595,58596,58597,58598,58599,58600,58601,58602,58603,58604,58605,58606,58607,58608,58609,58610,58611,58612,58613,58614,58615,58616,58617,58618,58619,58620,58621,58622,58623,58624,58625,58626,58627,58628,58629,58630,58631,58632,58633,58634,58635,58636,58637,58638,58639,58640,58641,58642,58643,58644,58645,58646,58647,58648,58649,58650,58651,58652,58653,58654,58655,58656,58657,58658,58659,58660,58661,12288,12289,12290,183,713,711,168,12291,12293,8212,65374,8214,8230,8216,8217,8220,8221,12308,12309,12296,12297,12298,12299,12300,12301,12302,12303,12310,12311,12304,12305,177,215,247,8758,8743,8744,8721,8719,8746,8745,8712,8759,8730,8869,8741,8736,8978,8857,8747,8750,8801,8780,8776,8765,8733,8800,8814,8815,8804,8805,8734,8757,8756,9794,9792,176,8242,8243,8451,65284,164,65504,65505,8240,167,8470,9734,9733,9675,9679,9678,9671,9670,9633,9632,9651,9650,8251,8594,8592,8593,8595,12307,58662,58663,58664,58665,58666,58667,58668,58669,58670,58671,58672,58673,58674,58675,58676,58677,58678,58679,58680,58681,58682,58683,58684,58685,58686,58687,58688,58689,58690,58691,58692,58693,58694,58695,58696,58697,58698,58699,58700,58701,58702,58703,58704,58705,58706,58707,58708,58709,58710,58711,58712,58713,58714,58715,58716,58717,58718,58719,58720,58721,58722,58723,58724,58725,58726,58727,58728,58729,58730,58731,58732,58733,58734,58735,58736,58737,58738,58739,58740,58741,58742,58743,58744,58745,58746,58747,58748,58749,58750,58751,58752,58753,58754,58755,58756,58757,8560,8561,8562,8563,8564,8565,8566,8567,8568,8569,59238,59239,59240,59241,59242,59243,9352,9353,9354,9355,9356,9357,9358,9359,9360,9361,9362,9363,9364,9365,9366,9367,9368,9369,9370,9371,9332,9333,9334,9335,9336,9337,9338,9339,9340,9341,9342,9343,9344,9345,9346,9347,9348,9349,9350,9351,9312,9313,9314,9315,9316,9317,9318,9319,9320,9321,8364,59245,12832,12833,12834,12835,12836,12837,12838,12839,12840,12841,59246,59247,8544,8545,8546,8547,8548,8549,8550,8551,8552,8553,8554,8555,59248,59249,58758,58759,58760,58761,58762,58763,58764,58765,58766,58767,58768,58769,58770,58771,58772,58773,58774,58775,58776,58777,58778,58779,58780,58781,58782,58783,58784,58785,58786,58787,58788,58789,58790,58791,58792,58793,58794,58795,58796,58797,58798,58799,58800,58801,58802,58803,58804,58805,58806,58807,58808,58809,58810,58811,58812,58813,58814,58815,58816,58817,58818,58819,58820,58821,58822,58823,58824,58825,58826,58827,58828,58829,58830,58831,58832,58833,58834,58835,58836,58837,58838,58839,58840,58841,58842,58843,58844,58845,58846,58847,58848,58849,58850,58851,58852,12288,65281,65282,65283,65509,65285,65286,65287,65288,65289,65290,65291,65292,65293,65294,65295,65296,65297,65298,65299,65300,65301,65302,65303,65304,65305,65306,65307,65308,65309,65310,65311,65312,65313,65314,65315,65316,65317,65318,65319,65320,65321,65322,65323,65324,65325,65326,65327,65328,65329,65330,65331,65332,65333,65334,65335,65336,65337,65338,65339,65340,65341,65342,65343,65344,65345,65346,65347,65348,65349,65350,65351,65352,65353,65354,65355,65356,65357,65358,65359,65360,65361,65362,65363,65364,65365,65366,65367,65368,65369,65370,65371,65372,65373,65507,58854,58855,58856,58857,58858,58859,58860,58861,58862,58863,58864,58865,58866,58867,58868,58869,58870,58871,58872,58873,58874,58875,58876,58877,58878,58879,58880,58881,58882,58883,58884,58885,58886,58887,58888,58889,58890,58891,58892,58893,58894,58895,58896,58897,58898,58899,58900,58901,58902,58903,58904,58905,58906,58907,58908,58909,58910,58911,58912,58913,58914,58915,58916,58917,58918,58919,58920,58921,58922,58923,58924,58925,58926,58927,58928,58929,58930,58931,58932,58933,58934,58935,58936,58937,58938,58939,58940,58941,58942,58943,58944,58945,58946,58947,58948,58949,12353,12354,12355,12356,12357,12358,12359,12360,12361,12362,12363,12364,12365,12366,12367,12368,12369,12370,12371,12372,12373,12374,12375,12376,12377,12378,12379,12380,12381,12382,12383,12384,12385,12386,12387,12388,12389,12390,12391,12392,12393,12394,12395,12396,12397,12398,12399,12400,12401,12402,12403,12404,12405,12406,12407,12408,12409,12410,12411,12412,12413,12414,12415,12416,12417,12418,12419,12420,12421,12422,12423,12424,12425,12426,12427,12428,12429,12430,12431,12432,12433,12434,12435,59250,59251,59252,59253,59254,59255,59256,59257,59258,59259,59260,58950,58951,58952,58953,58954,58955,58956,58957,58958,58959,58960,58961,58962,58963,58964,58965,58966,58967,58968,58969,58970,58971,58972,58973,58974,58975,58976,58977,58978,58979,58980,58981,58982,58983,58984,58985,58986,58987,58988,58989,58990,58991,58992,58993,58994,58995,58996,58997,58998,58999,59000,59001,59002,59003,59004,59005,59006,59007,59008,59009,59010,59011,59012,59013,59014,59015,59016,59017,59018,59019,59020,59021,59022,59023,59024,59025,59026,59027,59028,59029,59030,59031,59032,59033,59034,59035,59036,59037,59038,59039,59040,59041,59042,59043,59044,59045,12449,12450,12451,12452,12453,12454,12455,12456,12457,12458,12459,12460,12461,12462,12463,12464,12465,12466,12467,12468,12469,12470,12471,12472,12473,12474,12475,12476,12477,12478,12479,12480,12481,12482,12483,12484,12485,12486,12487,12488,12489,12490,12491,12492,12493,12494,12495,12496,12497,12498,12499,12500,12501,12502,12503,12504,12505,12506,12507,12508,12509,12510,12511,12512,12513,12514,12515,12516,12517,12518,12519,12520,12521,12522,12523,12524,12525,12526,12527,12528,12529,12530,12531,12532,12533,12534,59261,59262,59263,59264,59265,59266,59267,59268,59046,59047,59048,59049,59050,59051,59052,59053,59054,59055,59056,59057,59058,59059,59060,59061,59062,59063,59064,59065,59066,59067,59068,59069,59070,59071,59072,59073,59074,59075,59076,59077,59078,59079,59080,59081,59082,59083,59084,59085,59086,59087,59088,59089,59090,59091,59092,59093,59094,59095,59096,59097,59098,59099,59100,59101,59102,59103,59104,59105,59106,59107,59108,59109,59110,59111,59112,59113,59114,59115,59116,59117,59118,59119,59120,59121,59122,59123,59124,59125,59126,59127,59128,59129,59130,59131,59132,59133,59134,59135,59136,59137,59138,59139,59140,59141,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,931,932,933,934,935,936,937,59269,59270,59271,59272,59273,59274,59275,59276,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960,961,963,964,965,966,967,968,969,59277,59278,59279,59280,59281,59282,59283,65077,65078,65081,65082,65087,65088,65085,65086,65089,65090,65091,65092,59284,59285,65083,65084,65079,65080,65073,59286,65075,65076,59287,59288,59289,59290,59291,59292,59293,59294,59295,59142,59143,59144,59145,59146,59147,59148,59149,59150,59151,59152,59153,59154,59155,59156,59157,59158,59159,59160,59161,59162,59163,59164,59165,59166,59167,59168,59169,59170,59171,59172,59173,59174,59175,59176,59177,59178,59179,59180,59181,59182,59183,59184,59185,59186,59187,59188,59189,59190,59191,59192,59193,59194,59195,59196,59197,59198,59199,59200,59201,59202,59203,59204,59205,59206,59207,59208,59209,59210,59211,59212,59213,59214,59215,59216,59217,59218,59219,59220,59221,59222,59223,59224,59225,59226,59227,59228,59229,59230,59231,59232,59233,59234,59235,59236,59237,1040,1041,1042,1043,1044,1045,1025,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,59296,59297,59298,59299,59300,59301,59302,59303,59304,59305,59306,59307,59308,59309,59310,1072,1073,1074,1075,1076,1077,1105,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103,59311,59312,59313,59314,59315,59316,59317,59318,59319,59320,59321,59322,59323,714,715,729,8211,8213,8229,8245,8453,8457,8598,8599,8600,8601,8725,8735,8739,8786,8806,8807,8895,9552,9553,9554,9555,9556,9557,9558,9559,9560,9561,9562,9563,9564,9565,9566,9567,9568,9569,9570,9571,9572,9573,9574,9575,9576,9577,9578,9579,9580,9581,9582,9583,9584,9585,9586,9587,9601,9602,9603,9604,9605,9606,9607,9608,9609,9610,9611,9612,9613,9614,9615,9619,9620,9621,9660,9661,9698,9699,9700,9701,9737,8853,12306,12317,12318,59324,59325,59326,59327,59328,59329,59330,59331,59332,59333,59334,257,225,462,224,275,233,283,232,299,237,464,236,333,243,466,242,363,250,468,249,470,472,474,476,252,234,593,59335,324,328,505,609,59337,59338,59339,59340,12549,12550,12551,12552,12553,12554,12555,12556,12557,12558,12559,12560,12561,12562,12563,12564,12565,12566,12567,12568,12569,12570,12571,12572,12573,12574,12575,12576,12577,12578,12579,12580,12581,12582,12583,12584,12585,59341,59342,59343,59344,59345,59346,59347,59348,59349,59350,59351,59352,59353,59354,59355,59356,59357,59358,59359,59360,59361,12321,12322,12323,12324,12325,12326,12327,12328,12329,12963,13198,13199,13212,13213,13214,13217,13252,13262,13265,13266,13269,65072,65506,65508,59362,8481,12849,59363,8208,59364,59365,59366,12540,12443,12444,12541,12542,12294,12445,12446,65097,65098,65099,65100,65101,65102,65103,65104,65105,65106,65108,65109,65110,65111,65113,65114,65115,65116,65117,65118,65119,65120,65121,65122,65123,65124,65125,65126,65128,65129,65130,65131,12350,12272,12273,12274,12275,12276,12277,12278,12279,12280,12281,12282,12283,12295,59380,59381,59382,59383,59384,59385,59386,59387,59388,59389,59390,59391,59392,9472,9473,9474,9475,9476,9477,9478,9479,9480,9481,9482,9483,9484,9485,9486,9487,9488,9489,9490,9491,9492,9493,9494,9495,9496,9497,9498,9499,9500,9501,9502,9503,9504,9505,9506,9507,9508,9509,9510,9511,9512,9513,9514,9515,9516,9517,9518,9519,9520,9521,9522,9523,9524,9525,9526,9527,9528,9529,9530,9531,9532,9533,9534,9535,9536,9537,9538,9539,9540,9541,9542,9543,9544,9545,9546,9547,59393,59394,59395,59396,59397,59398,59399,59400,59401,59402,59403,59404,59405,59406,59407,29404,29405,29407,29410,29411,29412,29413,29414,29415,29418,29419,29429,29430,29433,29437,29438,29439,29440,29442,29444,29445,29446,29447,29448,29449,29451,29452,29453,29455,29456,29457,29458,29460,29464,29465,29466,29471,29472,29475,29476,29478,29479,29480,29485,29487,29488,29490,29491,29493,29494,29498,29499,29500,29501,29504,29505,29506,29507,29508,29509,29510,29511,29512,29513,29514,29515,29516,29518,29519,29521,29523,29524,29525,29526,29528,29529,29530,29531,29532,29533,29534,29535,29537,29538,29539,29540,29541,29542,29543,29544,29545,29546,29547,29550,29552,29553,57344,57345,57346,57347,57348,57349,57350,57351,57352,57353,57354,57355,57356,57357,57358,57359,57360,57361,57362,57363,57364,57365,57366,57367,57368,57369,57370,57371,57372,57373,57374,57375,57376,57377,57378,57379,57380,57381,57382,57383,57384,57385,57386,57387,57388,57389,57390,57391,57392,57393,57394,57395,57396,57397,57398,57399,57400,57401,57402,57403,57404,57405,57406,57407,57408,57409,57410,57411,57412,57413,57414,57415,57416,57417,57418,57419,57420,57421,57422,57423,57424,57425,57426,57427,57428,57429,57430,57431,57432,57433,57434,57435,57436,57437,29554,29555,29556,29557,29558,29559,29560,29561,29562,29563,29564,29565,29567,29568,29569,29570,29571,29573,29574,29576,29578,29580,29581,29583,29584,29586,29587,29588,29589,29591,29592,29593,29594,29596,29597,29598,29600,29601,29603,29604,29605,29606,29607,29608,29610,29612,29613,29617,29620,29621,29622,29624,29625,29628,29629,29630,29631,29633,29635,29636,29637,29638,29639,29643,29644,29646,29650,29651,29652,29653,29654,29655,29656,29658,29659,29660,29661,29663,29665,29666,29667,29668,29670,29672,29674,29675,29676,29678,29679,29680,29681,29683,29684,29685,29686,29687,57438,57439,57440,57441,57442,57443,57444,57445,57446,57447,57448,57449,57450,57451,57452,57453,57454,57455,57456,57457,57458,57459,57460,57461,57462,57463,57464,57465,57466,57467,57468,57469,57470,57471,57472,57473,57474,57475,57476,57477,57478,57479,57480,57481,57482,57483,57484,57485,57486,57487,57488,57489,57490,57491,57492,57493,57494,57495,57496,57497,57498,57499,57500,57501,57502,57503,57504,57505,57506,57507,57508,57509,57510,57511,57512,57513,57514,57515,57516,57517,57518,57519,57520,57521,57522,57523,57524,57525,57526,57527,57528,57529,57530,57531,29688,29689,29690,29691,29692,29693,29694,29695,29696,29697,29698,29700,29703,29704,29707,29708,29709,29710,29713,29714,29715,29716,29717,29718,29719,29720,29721,29724,29725,29726,29727,29728,29729,29731,29732,29735,29737,29739,29741,29743,29745,29746,29751,29752,29753,29754,29755,29757,29758,29759,29760,29762,29763,29764,29765,29766,29767,29768,29769,29770,29771,29772,29773,29774,29775,29776,29777,29778,29779,29780,29782,29784,29789,29792,29793,29794,29795,29796,29797,29798,29799,29800,29801,29802,29803,29804,29806,29807,29809,29810,29811,29812,29813,29816,29817,29818,57532,57533,57534,57535,57536,57537,57538,57539,57540,57541,57542,57543,57544,57545,57546,57547,57548,57549,57550,57551,57552,57553,57554,57555,57556,57557,57558,57559,57560,57561,57562,57563,57564,57565,57566,57567,57568,57569,57570,57571,57572,57573,57574,57575,57576,57577,57578,57579,57580,57581,57582,57583,57584,57585,57586,57587,57588,57589,57590,57591,57592,57593,57594,57595,57596,57597,57598,57599,57600,57601,57602,57603,57604,57605,57606,57607,57608,57609,57610,57611,57612,57613,57614,57615,57616,57617,57618,57619,57620,57621,57622,57623,57624,57625,29819,29820,29821,29823,29826,29828,29829,29830,29832,29833,29834,29836,29837,29839,29841,29842,29843,29844,29845,29846,29847,29848,29849,29850,29851,29853,29855,29856,29857,29858,29859,29860,29861,29862,29866,29867,29868,29869,29870,29871,29872,29873,29874,29875,29876,29877,29878,29879,29880,29881,29883,29884,29885,29886,29887,29888,29889,29890,29891,29892,29893,29894,29895,29896,29897,29898,29899,29900,29901,29902,29903,29904,29905,29907,29908,29909,29910,29911,29912,29913,29914,29915,29917,29919,29921,29925,29927,29928,29929,29930,29931,29932,29933,29936,29937,29938,57626,57627,57628,57629,57630,57631,57632,57633,57634,57635,57636,57637,57638,57639,57640,57641,57642,57643,57644,57645,57646,57647,57648,57649,57650,57651,57652,57653,57654,57655,57656,57657,57658,57659,57660,57661,57662,57663,57664,57665,57666,57667,57668,57669,57670,57671,57672,57673,57674,57675,57676,57677,57678,57679,57680,57681,57682,57683,57684,57685,57686,57687,57688,57689,57690,57691,57692,57693,57694,57695,57696,57697,57698,57699,57700,57701,57702,57703,57704,57705,57706,57707,57708,57709,57710,57711,57712,57713,57714,57715,57716,57717,57718,57719,29939,29941,29944,29945,29946,29947,29948,29949,29950,29952,29953,29954,29955,29957,29958,29959,29960,29961,29962,29963,29964,29966,29968,29970,29972,29973,29974,29975,29979,29981,29982,29984,29985,29986,29987,29988,29990,29991,29994,29998,30004,30006,30009,30012,30013,30015,30017,30018,30019,30020,30022,30023,30025,30026,30029,30032,30033,30034,30035,30037,30038,30039,30040,30045,30046,30047,30048,30049,30050,30051,30052,30055,30056,30057,30059,30060,30061,30062,30063,30064,30065,30067,30069,30070,30071,30074,30075,30076,30077,30078,30080,30081,30082,30084,30085,30087,57720,57721,57722,57723,57724,57725,57726,57727,57728,57729,57730,57731,57732,57733,57734,57735,57736,57737,57738,57739,57740,57741,57742,57743,57744,57745,57746,57747,57748,57749,57750,57751,57752,57753,57754,57755,57756,57757,57758,57759,57760,57761,57762,57763,57764,57765,57766,57767,57768,57769,57770,57771,57772,57773,57774,57775,57776,57777,57778,57779,57780,57781,57782,57783,57784,57785,57786,57787,57788,57789,57790,57791,57792,57793,57794,57795,57796,57797,57798,57799,57800,57801,57802,57803,57804,57805,57806,57807,57808,57809,57810,57811,57812,57813,30088,30089,30090,30092,30093,30094,30096,30099,30101,30104,30107,30108,30110,30114,30118,30119,30120,30121,30122,30125,30134,30135,30138,30139,30143,30144,30145,30150,30155,30156,30158,30159,30160,30161,30163,30167,30169,30170,30172,30173,30175,30176,30177,30181,30185,30188,30189,30190,30191,30194,30195,30197,30198,30199,30200,30202,30203,30205,30206,30210,30212,30214,30215,30216,30217,30219,30221,30222,30223,30225,30226,30227,30228,30230,30234,30236,30237,30238,30241,30243,30247,30248,30252,30254,30255,30257,30258,30262,30263,30265,30266,30267,30269,30273,30274,30276,57814,57815,57816,57817,57818,57819,57820,57821,57822,57823,57824,57825,57826,57827,57828,57829,57830,57831,57832,57833,57834,57835,57836,57837,57838,57839,57840,57841,57842,57843,57844,57845,57846,57847,57848,57849,57850,57851,57852,57853,57854,57855,57856,57857,57858,57859,57860,57861,57862,57863,57864,57865,57866,57867,57868,57869,57870,57871,57872,57873,57874,57875,57876,57877,57878,57879,57880,57881,57882,57883,57884,57885,57886,57887,57888,57889,57890,57891,57892,57893,57894,57895,57896,57897,57898,57899,57900,57901,57902,57903,57904,57905,57906,57907,30277,30278,30279,30280,30281,30282,30283,30286,30287,30288,30289,30290,30291,30293,30295,30296,30297,30298,30299,30301,30303,30304,30305,30306,30308,30309,30310,30311,30312,30313,30314,30316,30317,30318,30320,30321,30322,30323,30324,30325,30326,30327,30329,30330,30332,30335,30336,30337,30339,30341,30345,30346,30348,30349,30351,30352,30354,30356,30357,30359,30360,30362,30363,30364,30365,30366,30367,30368,30369,30370,30371,30373,30374,30375,30376,30377,30378,30379,30380,30381,30383,30384,30387,30389,30390,30391,30392,30393,30394,30395,30396,30397,30398,30400,30401,30403,21834,38463,22467,25384,21710,21769,21696,30353,30284,34108,30702,33406,30861,29233,38552,38797,27688,23433,20474,25353,26263,23736,33018,26696,32942,26114,30414,20985,25942,29100,32753,34948,20658,22885,25034,28595,33453,25420,25170,21485,21543,31494,20843,30116,24052,25300,36299,38774,25226,32793,22365,38712,32610,29240,30333,26575,30334,25670,20336,36133,25308,31255,26001,29677,25644,25203,33324,39041,26495,29256,25198,25292,20276,29923,21322,21150,32458,37030,24110,26758,27036,33152,32465,26834,30917,34444,38225,20621,35876,33502,32990,21253,35090,21093,30404,30407,30409,30411,30412,30419,30421,30425,30426,30428,30429,30430,30432,30433,30434,30435,30436,30438,30439,30440,30441,30442,30443,30444,30445,30448,30451,30453,30454,30455,30458,30459,30461,30463,30464,30466,30467,30469,30470,30474,30476,30478,30479,30480,30481,30482,30483,30484,30485,30486,30487,30488,30491,30492,30493,30494,30497,30499,30500,30501,30503,30506,30507,30508,30510,30512,30513,30514,30515,30516,30521,30523,30525,30526,30527,30530,30532,30533,30534,30536,30537,30538,30539,30540,30541,30542,30543,30546,30547,30548,30549,30550,30551,30552,30553,30556,34180,38649,20445,22561,39281,23453,25265,25253,26292,35961,40077,29190,26479,30865,24754,21329,21271,36744,32972,36125,38049,20493,29384,22791,24811,28953,34987,22868,33519,26412,31528,23849,32503,29997,27893,36454,36856,36924,40763,27604,37145,31508,24444,30887,34006,34109,27605,27609,27606,24065,24199,30201,38381,25949,24330,24517,36767,22721,33218,36991,38491,38829,36793,32534,36140,25153,20415,21464,21342,36776,36777,36779,36941,26631,24426,33176,34920,40150,24971,21035,30250,24428,25996,28626,28392,23486,25672,20853,20912,26564,19993,31177,39292,28851,30557,30558,30559,30560,30564,30567,30569,30570,30573,30574,30575,30576,30577,30578,30579,30580,30581,30582,30583,30584,30586,30587,30588,30593,30594,30595,30598,30599,30600,30601,30602,30603,30607,30608,30611,30612,30613,30614,30615,30616,30617,30618,30619,30620,30621,30622,30625,30627,30628,30630,30632,30635,30637,30638,30639,30641,30642,30644,30646,30647,30648,30649,30650,30652,30654,30656,30657,30658,30659,30660,30661,30662,30663,30664,30665,30666,30667,30668,30670,30671,30672,30673,30674,30675,30676,30677,30678,30680,30681,30682,30685,30686,30687,30688,30689,30692,30149,24182,29627,33760,25773,25320,38069,27874,21338,21187,25615,38082,31636,20271,24091,33334,33046,33162,28196,27850,39539,25429,21340,21754,34917,22496,19981,24067,27493,31807,37096,24598,25830,29468,35009,26448,25165,36130,30572,36393,37319,24425,33756,34081,39184,21442,34453,27531,24813,24808,28799,33485,33329,20179,27815,34255,25805,31961,27133,26361,33609,21397,31574,20391,20876,27979,23618,36461,25554,21449,33580,33590,26597,30900,25661,23519,23700,24046,35815,25286,26612,35962,25600,25530,34633,39307,35863,32544,38130,20135,38416,39076,26124,29462,30694,30696,30698,30703,30704,30705,30706,30708,30709,30711,30713,30714,30715,30716,30723,30724,30725,30726,30727,30728,30730,30731,30734,30735,30736,30739,30741,30745,30747,30750,30752,30753,30754,30756,30760,30762,30763,30766,30767,30769,30770,30771,30773,30774,30781,30783,30785,30786,30787,30788,30790,30792,30793,30794,30795,30797,30799,30801,30803,30804,30808,30809,30810,30811,30812,30814,30815,30816,30817,30818,30819,30820,30821,30822,30823,30824,30825,30831,30832,30833,30834,30835,30836,30837,30838,30840,30841,30842,30843,30845,30846,30847,30848,30849,30850,30851,22330,23581,24120,38271,20607,32928,21378,25950,30021,21809,20513,36229,25220,38046,26397,22066,28526,24034,21557,28818,36710,25199,25764,25507,24443,28552,37108,33251,36784,23576,26216,24561,27785,38472,36225,34924,25745,31216,22478,27225,25104,21576,20056,31243,24809,28548,35802,25215,36894,39563,31204,21507,30196,25345,21273,27744,36831,24347,39536,32827,40831,20360,23610,36196,32709,26021,28861,20805,20914,34411,23815,23456,25277,37228,30068,36364,31264,24833,31609,20167,32504,30597,19985,33261,21021,20986,27249,21416,36487,38148,38607,28353,38500,26970,30852,30853,30854,30856,30858,30859,30863,30864,30866,30868,30869,30870,30873,30877,30878,30880,30882,30884,30886,30888,30889,30890,30891,30892,30893,30894,30895,30901,30902,30903,30904,30906,30907,30908,30909,30911,30912,30914,30915,30916,30918,30919,30920,30924,30925,30926,30927,30929,30930,30931,30934,30935,30936,30938,30939,30940,30941,30942,30943,30944,30945,30946,30947,30948,30949,30950,30951,30953,30954,30955,30957,30958,30959,30960,30961,30963,30965,30966,30968,30969,30971,30972,30973,30974,30975,30976,30978,30979,30980,30982,30983,30984,30985,30986,30987,30988,30784,20648,30679,25616,35302,22788,25571,24029,31359,26941,20256,33337,21912,20018,30126,31383,24162,24202,38383,21019,21561,28810,25462,38180,22402,26149,26943,37255,21767,28147,32431,34850,25139,32496,30133,33576,30913,38604,36766,24904,29943,35789,27492,21050,36176,27425,32874,33905,22257,21254,20174,19995,20945,31895,37259,31751,20419,36479,31713,31388,25703,23828,20652,33030,30209,31929,28140,32736,26449,23384,23544,30923,25774,25619,25514,25387,38169,25645,36798,31572,30249,25171,22823,21574,27513,20643,25140,24102,27526,20195,36151,34955,24453,36910,30989,30990,30991,30992,30993,30994,30996,30997,30998,30999,31000,31001,31002,31003,31004,31005,31007,31008,31009,31010,31011,31013,31014,31015,31016,31017,31018,31019,31020,31021,31022,31023,31024,31025,31026,31027,31029,31030,31031,31032,31033,31037,31039,31042,31043,31044,31045,31047,31050,31051,31052,31053,31054,31055,31056,31057,31058,31060,31061,31064,31065,31073,31075,31076,31078,31081,31082,31083,31084,31086,31088,31089,31090,31091,31092,31093,31094,31097,31099,31100,31101,31102,31103,31106,31107,31110,31111,31112,31113,31115,31116,31117,31118,31120,31121,31122,24608,32829,25285,20025,21333,37112,25528,32966,26086,27694,20294,24814,28129,35806,24377,34507,24403,25377,20826,33633,26723,20992,25443,36424,20498,23707,31095,23548,21040,31291,24764,36947,30423,24503,24471,30340,36460,28783,30331,31561,30634,20979,37011,22564,20302,28404,36842,25932,31515,29380,28068,32735,23265,25269,24213,22320,33922,31532,24093,24351,36882,32532,39072,25474,28359,30872,28857,20856,38747,22443,30005,20291,30008,24215,24806,22880,28096,27583,30857,21500,38613,20939,20993,25481,21514,38035,35843,36300,29241,30879,34678,36845,35853,21472,31123,31124,31125,31126,31127,31128,31129,31131,31132,31133,31134,31135,31136,31137,31138,31139,31140,31141,31142,31144,31145,31146,31147,31148,31149,31150,31151,31152,31153,31154,31156,31157,31158,31159,31160,31164,31167,31170,31172,31173,31175,31176,31178,31180,31182,31183,31184,31187,31188,31190,31191,31193,31194,31195,31196,31197,31198,31200,31201,31202,31205,31208,31210,31212,31214,31217,31218,31219,31220,31221,31222,31223,31225,31226,31228,31230,31231,31233,31236,31237,31239,31240,31241,31242,31244,31247,31248,31249,31250,31251,31253,31254,31256,31257,31259,31260,19969,30447,21486,38025,39030,40718,38189,23450,35746,20002,19996,20908,33891,25026,21160,26635,20375,24683,20923,27934,20828,25238,26007,38497,35910,36887,30168,37117,30563,27602,29322,29420,35835,22581,30585,36172,26460,38208,32922,24230,28193,22930,31471,30701,38203,27573,26029,32526,22534,20817,38431,23545,22697,21544,36466,25958,39039,22244,38045,30462,36929,25479,21702,22810,22842,22427,36530,26421,36346,33333,21057,24816,22549,34558,23784,40517,20420,39069,35769,23077,24694,21380,25212,36943,37122,39295,24681,32780,20799,32819,23572,39285,27953,20108,31261,31263,31265,31266,31268,31269,31270,31271,31272,31273,31274,31275,31276,31277,31278,31279,31280,31281,31282,31284,31285,31286,31288,31290,31294,31296,31297,31298,31299,31300,31301,31303,31304,31305,31306,31307,31308,31309,31310,31311,31312,31314,31315,31316,31317,31318,31320,31321,31322,31323,31324,31325,31326,31327,31328,31329,31330,31331,31332,31333,31334,31335,31336,31337,31338,31339,31340,31341,31342,31343,31345,31346,31347,31349,31355,31356,31357,31358,31362,31365,31367,31369,31370,31371,31372,31374,31375,31376,31379,31380,31385,31386,31387,31390,31393,31394,36144,21457,32602,31567,20240,20047,38400,27861,29648,34281,24070,30058,32763,27146,30718,38034,32321,20961,28902,21453,36820,33539,36137,29359,39277,27867,22346,33459,26041,32938,25151,38450,22952,20223,35775,32442,25918,33778,38750,21857,39134,32933,21290,35837,21536,32954,24223,27832,36153,33452,37210,21545,27675,20998,32439,22367,28954,27774,31881,22859,20221,24575,24868,31914,20016,23553,26539,34562,23792,38155,39118,30127,28925,36898,20911,32541,35773,22857,20964,20315,21542,22827,25975,32932,23413,25206,25282,36752,24133,27679,31526,20239,20440,26381,31395,31396,31399,31401,31402,31403,31406,31407,31408,31409,31410,31412,31413,31414,31415,31416,31417,31418,31419,31420,31421,31422,31424,31425,31426,31427,31428,31429,31430,31431,31432,31433,31434,31436,31437,31438,31439,31440,31441,31442,31443,31444,31445,31447,31448,31450,31451,31452,31453,31457,31458,31460,31463,31464,31465,31466,31467,31468,31470,31472,31473,31474,31475,31476,31477,31478,31479,31480,31483,31484,31486,31488,31489,31490,31493,31495,31497,31500,31501,31502,31504,31506,31507,31510,31511,31512,31514,31516,31517,31519,31521,31522,31523,31527,31529,31533,28014,28074,31119,34993,24343,29995,25242,36741,20463,37340,26023,33071,33105,24220,33104,36212,21103,35206,36171,22797,20613,20184,38428,29238,33145,36127,23500,35747,38468,22919,32538,21648,22134,22030,35813,25913,27010,38041,30422,28297,24178,29976,26438,26577,31487,32925,36214,24863,31174,25954,36195,20872,21018,38050,32568,32923,32434,23703,28207,26464,31705,30347,39640,33167,32660,31957,25630,38224,31295,21578,21733,27468,25601,25096,40509,33011,30105,21106,38761,33883,26684,34532,38401,38548,38124,20010,21508,32473,26681,36319,32789,26356,24218,32697,31535,31536,31538,31540,31541,31542,31543,31545,31547,31549,31551,31552,31553,31554,31555,31556,31558,31560,31562,31565,31566,31571,31573,31575,31577,31580,31582,31583,31585,31587,31588,31589,31590,31591,31592,31593,31594,31595,31596,31597,31599,31600,31603,31604,31606,31608,31610,31612,31613,31615,31617,31618,31619,31620,31622,31623,31624,31625,31626,31627,31628,31630,31631,31633,31634,31635,31638,31640,31641,31642,31643,31646,31647,31648,31651,31652,31653,31662,31663,31664,31666,31667,31669,31670,31671,31673,31674,31675,31676,31677,31678,31679,31680,31682,31683,31684,22466,32831,26775,24037,25915,21151,24685,40858,20379,36524,20844,23467,24339,24041,27742,25329,36129,20849,38057,21246,27807,33503,29399,22434,26500,36141,22815,36764,33735,21653,31629,20272,27837,23396,22993,40723,21476,34506,39592,35895,32929,25925,39038,22266,38599,21038,29916,21072,23521,25346,35074,20054,25296,24618,26874,20851,23448,20896,35266,31649,39302,32592,24815,28748,36143,20809,24191,36891,29808,35268,22317,30789,24402,40863,38394,36712,39740,35809,30328,26690,26588,36330,36149,21053,36746,28378,26829,38149,37101,22269,26524,35065,36807,21704,31685,31688,31689,31690,31691,31693,31694,31695,31696,31698,31700,31701,31702,31703,31704,31707,31708,31710,31711,31712,31714,31715,31716,31719,31720,31721,31723,31724,31725,31727,31728,31730,31731,31732,31733,31734,31736,31737,31738,31739,31741,31743,31744,31745,31746,31747,31748,31749,31750,31752,31753,31754,31757,31758,31760,31761,31762,31763,31764,31765,31767,31768,31769,31770,31771,31772,31773,31774,31776,31777,31778,31779,31780,31781,31784,31785,31787,31788,31789,31790,31791,31792,31793,31794,31795,31796,31797,31798,31799,31801,31802,31803,31804,31805,31806,31810,39608,23401,28023,27686,20133,23475,39559,37219,25000,37039,38889,21547,28085,23506,20989,21898,32597,32752,25788,25421,26097,25022,24717,28938,27735,27721,22831,26477,33322,22741,22158,35946,27627,37085,22909,32791,21495,28009,21621,21917,33655,33743,26680,31166,21644,20309,21512,30418,35977,38402,27827,28088,36203,35088,40548,36154,22079,40657,30165,24456,29408,24680,21756,20136,27178,34913,24658,36720,21700,28888,34425,40511,27946,23439,24344,32418,21897,20399,29492,21564,21402,20505,21518,21628,20046,24573,29786,22774,33899,32993,34676,29392,31946,28246,31811,31812,31813,31814,31815,31816,31817,31818,31819,31820,31822,31823,31824,31825,31826,31827,31828,31829,31830,31831,31832,31833,31834,31835,31836,31837,31838,31839,31840,31841,31842,31843,31844,31845,31846,31847,31848,31849,31850,31851,31852,31853,31854,31855,31856,31857,31858,31861,31862,31863,31864,31865,31866,31870,31871,31872,31873,31874,31875,31876,31877,31878,31879,31880,31882,31883,31884,31885,31886,31887,31888,31891,31892,31894,31897,31898,31899,31904,31905,31907,31910,31911,31912,31913,31915,31916,31917,31919,31920,31924,31925,31926,31927,31928,31930,31931,24359,34382,21804,25252,20114,27818,25143,33457,21719,21326,29502,28369,30011,21010,21270,35805,27088,24458,24576,28142,22351,27426,29615,26707,36824,32531,25442,24739,21796,30186,35938,28949,28067,23462,24187,33618,24908,40644,30970,34647,31783,30343,20976,24822,29004,26179,24140,24653,35854,28784,25381,36745,24509,24674,34516,22238,27585,24724,24935,21321,24800,26214,36159,31229,20250,28905,27719,35763,35826,32472,33636,26127,23130,39746,27985,28151,35905,27963,20249,28779,33719,25110,24785,38669,36135,31096,20987,22334,22522,26426,30072,31293,31215,31637,31935,31936,31938,31939,31940,31942,31945,31947,31950,31951,31952,31953,31954,31955,31956,31960,31962,31963,31965,31966,31969,31970,31971,31972,31973,31974,31975,31977,31978,31979,31980,31981,31982,31984,31985,31986,31987,31988,31989,31990,31991,31993,31994,31996,31997,31998,31999,32000,32001,32002,32003,32004,32005,32006,32007,32008,32009,32011,32012,32013,32014,32015,32016,32017,32018,32019,32020,32021,32022,32023,32024,32025,32026,32027,32028,32029,32030,32031,32033,32035,32036,32037,32038,32040,32041,32042,32044,32045,32046,32048,32049,32050,32051,32052,32053,32054,32908,39269,36857,28608,35749,40481,23020,32489,32521,21513,26497,26840,36753,31821,38598,21450,24613,30142,27762,21363,23241,32423,25380,20960,33034,24049,34015,25216,20864,23395,20238,31085,21058,24760,27982,23492,23490,35745,35760,26082,24524,38469,22931,32487,32426,22025,26551,22841,20339,23478,21152,33626,39050,36158,30002,38078,20551,31292,20215,26550,39550,23233,27516,30417,22362,23574,31546,38388,29006,20860,32937,33392,22904,32516,33575,26816,26604,30897,30839,25315,25441,31616,20461,21098,20943,33616,27099,37492,36341,36145,35265,38190,31661,20214,32055,32056,32057,32058,32059,32060,32061,32062,32063,32064,32065,32066,32067,32068,32069,32070,32071,32072,32073,32074,32075,32076,32077,32078,32079,32080,32081,32082,32083,32084,32085,32086,32087,32088,32089,32090,32091,32092,32093,32094,32095,32096,32097,32098,32099,32100,32101,32102,32103,32104,32105,32106,32107,32108,32109,32111,32112,32113,32114,32115,32116,32117,32118,32120,32121,32122,32123,32124,32125,32126,32127,32128,32129,32130,32131,32132,32133,32134,32135,32136,32137,32138,32139,32140,32141,32142,32143,32144,32145,32146,32147,32148,32149,32150,32151,32152,20581,33328,21073,39279,28176,28293,28071,24314,20725,23004,23558,27974,27743,30086,33931,26728,22870,35762,21280,37233,38477,34121,26898,30977,28966,33014,20132,37066,27975,39556,23047,22204,25605,38128,30699,20389,33050,29409,35282,39290,32564,32478,21119,25945,37237,36735,36739,21483,31382,25581,25509,30342,31224,34903,38454,25130,21163,33410,26708,26480,25463,30571,31469,27905,32467,35299,22992,25106,34249,33445,30028,20511,20171,30117,35819,23626,24062,31563,26020,37329,20170,27941,35167,32039,38182,20165,35880,36827,38771,26187,31105,36817,28908,28024,32153,32154,32155,32156,32157,32158,32159,32160,32161,32162,32163,32164,32165,32167,32168,32169,32170,32171,32172,32173,32175,32176,32177,32178,32179,32180,32181,32182,32183,32184,32185,32186,32187,32188,32189,32190,32191,32192,32193,32194,32195,32196,32197,32198,32199,32200,32201,32202,32203,32204,32205,32206,32207,32208,32209,32210,32211,32212,32213,32214,32215,32216,32217,32218,32219,32220,32221,32222,32223,32224,32225,32226,32227,32228,32229,32230,32231,32232,32233,32234,32235,32236,32237,32238,32239,32240,32241,32242,32243,32244,32245,32246,32247,32248,32249,32250,23613,21170,33606,20834,33550,30555,26230,40120,20140,24778,31934,31923,32463,20117,35686,26223,39048,38745,22659,25964,38236,24452,30153,38742,31455,31454,20928,28847,31384,25578,31350,32416,29590,38893,20037,28792,20061,37202,21417,25937,26087,33276,33285,21646,23601,30106,38816,25304,29401,30141,23621,39545,33738,23616,21632,30697,20030,27822,32858,25298,25454,24040,20855,36317,36382,38191,20465,21477,24807,28844,21095,25424,40515,23071,20518,30519,21367,32482,25733,25899,25225,25496,20500,29237,35273,20915,35776,32477,22343,33740,38055,20891,21531,23803,32251,32252,32253,32254,32255,32256,32257,32258,32259,32260,32261,32262,32263,32264,32265,32266,32267,32268,32269,32270,32271,32272,32273,32274,32275,32276,32277,32278,32279,32280,32281,32282,32283,32284,32285,32286,32287,32288,32289,32290,32291,32292,32293,32294,32295,32296,32297,32298,32299,32300,32301,32302,32303,32304,32305,32306,32307,32308,32309,32310,32311,32312,32313,32314,32316,32317,32318,32319,32320,32322,32323,32324,32325,32326,32328,32329,32330,32331,32332,32333,32334,32335,32336,32337,32338,32339,32340,32341,32342,32343,32344,32345,32346,32347,32348,32349,20426,31459,27994,37089,39567,21888,21654,21345,21679,24320,25577,26999,20975,24936,21002,22570,21208,22350,30733,30475,24247,24951,31968,25179,25239,20130,28821,32771,25335,28900,38752,22391,33499,26607,26869,30933,39063,31185,22771,21683,21487,28212,20811,21051,23458,35838,32943,21827,22438,24691,22353,21549,31354,24656,23380,25511,25248,21475,25187,23495,26543,21741,31391,33510,37239,24211,35044,22840,22446,25358,36328,33007,22359,31607,20393,24555,23485,27454,21281,31568,29378,26694,30719,30518,26103,20917,20111,30420,23743,31397,33909,22862,39745,20608,32350,32351,32352,32353,32354,32355,32356,32357,32358,32359,32360,32361,32362,32363,32364,32365,32366,32367,32368,32369,32370,32371,32372,32373,32374,32375,32376,32377,32378,32379,32380,32381,32382,32383,32384,32385,32387,32388,32389,32390,32391,32392,32393,32394,32395,32396,32397,32398,32399,32400,32401,32402,32403,32404,32405,32406,32407,32408,32409,32410,32412,32413,32414,32430,32436,32443,32444,32470,32484,32492,32505,32522,32528,32542,32567,32569,32571,32572,32573,32574,32575,32576,32577,32579,32582,32583,32584,32585,32586,32587,32588,32589,32590,32591,32594,32595,39304,24871,28291,22372,26118,25414,22256,25324,25193,24275,38420,22403,25289,21895,34593,33098,36771,21862,33713,26469,36182,34013,23146,26639,25318,31726,38417,20848,28572,35888,25597,35272,25042,32518,28866,28389,29701,27028,29436,24266,37070,26391,28010,25438,21171,29282,32769,20332,23013,37226,28889,28061,21202,20048,38647,38253,34174,30922,32047,20769,22418,25794,32907,31867,27882,26865,26974,20919,21400,26792,29313,40654,31729,29432,31163,28435,29702,26446,37324,40100,31036,33673,33620,21519,26647,20029,21385,21169,30782,21382,21033,20616,20363,20432,32598,32601,32603,32604,32605,32606,32608,32611,32612,32613,32614,32615,32619,32620,32621,32623,32624,32627,32629,32630,32631,32632,32634,32635,32636,32637,32639,32640,32642,32643,32644,32645,32646,32647,32648,32649,32651,32653,32655,32656,32657,32658,32659,32661,32662,32663,32664,32665,32667,32668,32672,32674,32675,32677,32678,32680,32681,32682,32683,32684,32685,32686,32689,32691,32692,32693,32694,32695,32698,32699,32702,32704,32706,32707,32708,32710,32711,32712,32713,32715,32717,32719,32720,32721,32722,32723,32726,32727,32729,32730,32731,32732,32733,32734,32738,32739,30178,31435,31890,27813,38582,21147,29827,21737,20457,32852,33714,36830,38256,24265,24604,28063,24088,25947,33080,38142,24651,28860,32451,31918,20937,26753,31921,33391,20004,36742,37327,26238,20142,35845,25769,32842,20698,30103,29134,23525,36797,28518,20102,25730,38243,24278,26009,21015,35010,28872,21155,29454,29747,26519,30967,38678,20020,37051,40158,28107,20955,36161,21533,25294,29618,33777,38646,40836,38083,20278,32666,20940,28789,38517,23725,39046,21478,20196,28316,29705,27060,30827,39311,30041,21016,30244,27969,26611,20845,40857,32843,21657,31548,31423,32740,32743,32744,32746,32747,32748,32749,32751,32754,32756,32757,32758,32759,32760,32761,32762,32765,32766,32767,32770,32775,32776,32777,32778,32782,32783,32785,32787,32794,32795,32797,32798,32799,32801,32803,32804,32811,32812,32813,32814,32815,32816,32818,32820,32825,32826,32828,32830,32832,32833,32836,32837,32839,32840,32841,32846,32847,32848,32849,32851,32853,32854,32855,32857,32859,32860,32861,32862,32863,32864,32865,32866,32867,32868,32869,32870,32871,32872,32875,32876,32877,32878,32879,32880,32882,32883,32884,32885,32886,32887,32888,32889,32890,32891,32892,32893,38534,22404,25314,38471,27004,23044,25602,31699,28431,38475,33446,21346,39045,24208,28809,25523,21348,34383,40065,40595,30860,38706,36335,36162,40575,28510,31108,24405,38470,25134,39540,21525,38109,20387,26053,23653,23649,32533,34385,27695,24459,29575,28388,32511,23782,25371,23402,28390,21365,20081,25504,30053,25249,36718,20262,20177,27814,32438,35770,33821,34746,32599,36923,38179,31657,39585,35064,33853,27931,39558,32476,22920,40635,29595,30721,34434,39532,39554,22043,21527,22475,20080,40614,21334,36808,33033,30610,39314,34542,28385,34067,26364,24930,28459,32894,32897,32898,32901,32904,32906,32909,32910,32911,32912,32913,32914,32916,32917,32919,32921,32926,32931,32934,32935,32936,32940,32944,32947,32949,32950,32952,32953,32955,32965,32967,32968,32969,32970,32971,32975,32976,32977,32978,32979,32980,32981,32984,32991,32992,32994,32995,32998,33006,33013,33015,33017,33019,33022,33023,33024,33025,33027,33028,33029,33031,33032,33035,33036,33045,33047,33049,33051,33052,33053,33055,33056,33057,33058,33059,33060,33061,33062,33063,33064,33065,33066,33067,33069,33070,33072,33075,33076,33077,33079,33081,33082,33083,33084,33085,33087,35881,33426,33579,30450,27667,24537,33725,29483,33541,38170,27611,30683,38086,21359,33538,20882,24125,35980,36152,20040,29611,26522,26757,37238,38665,29028,27809,30473,23186,38209,27599,32654,26151,23504,22969,23194,38376,38391,20204,33804,33945,27308,30431,38192,29467,26790,23391,30511,37274,38753,31964,36855,35868,24357,31859,31192,35269,27852,34588,23494,24130,26825,30496,32501,20885,20813,21193,23081,32517,38754,33495,25551,30596,34256,31186,28218,24217,22937,34065,28781,27665,25279,30399,25935,24751,38397,26126,34719,40483,38125,21517,21629,35884,25720,33088,33089,33090,33091,33092,33093,33095,33097,33101,33102,33103,33106,33110,33111,33112,33115,33116,33117,33118,33119,33121,33122,33123,33124,33126,33128,33130,33131,33132,33135,33138,33139,33141,33142,33143,33144,33153,33155,33156,33157,33158,33159,33161,33163,33164,33165,33166,33168,33170,33171,33172,33173,33174,33175,33177,33178,33182,33183,33184,33185,33186,33188,33189,33191,33193,33195,33196,33197,33198,33199,33200,33201,33202,33204,33205,33206,33207,33208,33209,33212,33213,33214,33215,33220,33221,33223,33224,33225,33227,33229,33230,33231,33232,33233,33234,33235,25721,34321,27169,33180,30952,25705,39764,25273,26411,33707,22696,40664,27819,28448,23518,38476,35851,29279,26576,25287,29281,20137,22982,27597,22675,26286,24149,21215,24917,26408,30446,30566,29287,31302,25343,21738,21584,38048,37027,23068,32435,27670,20035,22902,32784,22856,21335,30007,38590,22218,25376,33041,24700,38393,28118,21602,39297,20869,23273,33021,22958,38675,20522,27877,23612,25311,20320,21311,33147,36870,28346,34091,25288,24180,30910,25781,25467,24565,23064,37247,40479,23615,25423,32834,23421,21870,38218,38221,28037,24744,26592,29406,20957,23425,33236,33237,33238,33239,33240,33241,33242,33243,33244,33245,33246,33247,33248,33249,33250,33252,33253,33254,33256,33257,33259,33262,33263,33264,33265,33266,33269,33270,33271,33272,33273,33274,33277,33279,33283,33287,33288,33289,33290,33291,33294,33295,33297,33299,33301,33302,33303,33304,33305,33306,33309,33312,33316,33317,33318,33319,33321,33326,33330,33338,33340,33341,33343,33344,33345,33346,33347,33349,33350,33352,33354,33356,33357,33358,33360,33361,33362,33363,33364,33365,33366,33367,33369,33371,33372,33373,33374,33376,33377,33378,33379,33380,33381,33382,33383,33385,25319,27870,29275,25197,38062,32445,33043,27987,20892,24324,22900,21162,24594,22899,26262,34384,30111,25386,25062,31983,35834,21734,27431,40485,27572,34261,21589,20598,27812,21866,36276,29228,24085,24597,29750,25293,25490,29260,24472,28227,27966,25856,28504,30424,30928,30460,30036,21028,21467,20051,24222,26049,32810,32982,25243,21638,21032,28846,34957,36305,27873,21624,32986,22521,35060,36180,38506,37197,20329,27803,21943,30406,30768,25256,28921,28558,24429,34028,26842,30844,31735,33192,26379,40527,25447,30896,22383,30738,38713,25209,25259,21128,29749,27607,33386,33387,33388,33389,33393,33397,33398,33399,33400,33403,33404,33408,33409,33411,33413,33414,33415,33417,33420,33424,33427,33428,33429,33430,33434,33435,33438,33440,33442,33443,33447,33458,33461,33462,33466,33467,33468,33471,33472,33474,33475,33477,33478,33481,33488,33494,33497,33498,33501,33506,33511,33512,33513,33514,33516,33517,33518,33520,33522,33523,33525,33526,33528,33530,33532,33533,33534,33535,33536,33546,33547,33549,33552,33554,33555,33558,33560,33561,33565,33566,33567,33568,33569,33570,33571,33572,33573,33574,33577,33578,33582,33584,33586,33591,33595,33597,21860,33086,30130,30382,21305,30174,20731,23617,35692,31687,20559,29255,39575,39128,28418,29922,31080,25735,30629,25340,39057,36139,21697,32856,20050,22378,33529,33805,24179,20973,29942,35780,23631,22369,27900,39047,23110,30772,39748,36843,31893,21078,25169,38138,20166,33670,33889,33769,33970,22484,26420,22275,26222,28006,35889,26333,28689,26399,27450,26646,25114,22971,19971,20932,28422,26578,27791,20854,26827,22855,27495,30054,23822,33040,40784,26071,31048,31041,39569,36215,23682,20062,20225,21551,22865,30732,22120,27668,36804,24323,27773,27875,35755,25488,33598,33599,33601,33602,33604,33605,33608,33610,33611,33612,33613,33614,33619,33621,33622,33623,33624,33625,33629,33634,33648,33649,33650,33651,33652,33653,33654,33657,33658,33662,33663,33664,33665,33666,33667,33668,33671,33672,33674,33675,33676,33677,33679,33680,33681,33684,33685,33686,33687,33689,33690,33693,33695,33697,33698,33699,33700,33701,33702,33703,33708,33709,33710,33711,33717,33723,33726,33727,33730,33731,33732,33734,33736,33737,33739,33741,33742,33744,33745,33746,33747,33749,33751,33753,33754,33755,33758,33762,33763,33764,33766,33767,33768,33771,33772,33773,24688,27965,29301,25190,38030,38085,21315,36801,31614,20191,35878,20094,40660,38065,38067,21069,28508,36963,27973,35892,22545,23884,27424,27465,26538,21595,33108,32652,22681,34103,24378,25250,27207,38201,25970,24708,26725,30631,20052,20392,24039,38808,25772,32728,23789,20431,31373,20999,33540,19988,24623,31363,38054,20405,20146,31206,29748,21220,33465,25810,31165,23517,27777,38738,36731,27682,20542,21375,28165,25806,26228,27696,24773,39031,35831,24198,29756,31351,31179,19992,37041,29699,27714,22234,37195,27845,36235,21306,34502,26354,36527,23624,39537,28192,33774,33775,33779,33780,33781,33782,33783,33786,33787,33788,33790,33791,33792,33794,33797,33799,33800,33801,33802,33808,33810,33811,33812,33813,33814,33815,33817,33818,33819,33822,33823,33824,33825,33826,33827,33833,33834,33835,33836,33837,33838,33839,33840,33842,33843,33844,33845,33846,33847,33849,33850,33851,33854,33855,33856,33857,33858,33859,33860,33861,33863,33864,33865,33866,33867,33868,33869,33870,33871,33872,33874,33875,33876,33877,33878,33880,33885,33886,33887,33888,33890,33892,33893,33894,33895,33896,33898,33902,33903,33904,33906,33908,33911,33913,33915,33916,21462,23094,40843,36259,21435,22280,39079,26435,37275,27849,20840,30154,25331,29356,21048,21149,32570,28820,30264,21364,40522,27063,30830,38592,35033,32676,28982,29123,20873,26579,29924,22756,25880,22199,35753,39286,25200,32469,24825,28909,22764,20161,20154,24525,38887,20219,35748,20995,22922,32427,25172,20173,26085,25102,33592,33993,33635,34701,29076,28342,23481,32466,20887,25545,26580,32905,33593,34837,20754,23418,22914,36785,20083,27741,20837,35109,36719,38446,34122,29790,38160,38384,28070,33509,24369,25746,27922,33832,33134,40131,22622,36187,19977,21441,33917,33918,33919,33920,33921,33923,33924,33925,33926,33930,33933,33935,33936,33937,33938,33939,33940,33941,33942,33944,33946,33947,33949,33950,33951,33952,33954,33955,33956,33957,33958,33959,33960,33961,33962,33963,33964,33965,33966,33968,33969,33971,33973,33974,33975,33979,33980,33982,33984,33986,33987,33989,33990,33991,33992,33995,33996,33998,33999,34002,34004,34005,34007,34008,34009,34010,34011,34012,34014,34017,34018,34020,34023,34024,34025,34026,34027,34029,34030,34031,34033,34034,34035,34036,34037,34038,34039,34040,34041,34042,34043,34045,34046,34048,34049,34050,20254,25955,26705,21971,20007,25620,39578,25195,23234,29791,33394,28073,26862,20711,33678,30722,26432,21049,27801,32433,20667,21861,29022,31579,26194,29642,33515,26441,23665,21024,29053,34923,38378,38485,25797,36193,33203,21892,27733,25159,32558,22674,20260,21830,36175,26188,19978,23578,35059,26786,25422,31245,28903,33421,21242,38902,23569,21736,37045,32461,22882,36170,34503,33292,33293,36198,25668,23556,24913,28041,31038,35774,30775,30003,21627,20280,36523,28145,23072,32453,31070,27784,23457,23158,29978,32958,24910,28183,22768,29983,29989,29298,21319,32499,34051,34052,34053,34054,34055,34056,34057,34058,34059,34061,34062,34063,34064,34066,34068,34069,34070,34072,34073,34075,34076,34077,34078,34080,34082,34083,34084,34085,34086,34087,34088,34089,34090,34093,34094,34095,34096,34097,34098,34099,34100,34101,34102,34110,34111,34112,34113,34114,34116,34117,34118,34119,34123,34124,34125,34126,34127,34128,34129,34130,34131,34132,34133,34135,34136,34138,34139,34140,34141,34143,34144,34145,34146,34147,34149,34150,34151,34153,34154,34155,34156,34157,34158,34159,34160,34161,34163,34165,34166,34167,34168,34172,34173,34175,34176,34177,30465,30427,21097,32988,22307,24072,22833,29422,26045,28287,35799,23608,34417,21313,30707,25342,26102,20160,39135,34432,23454,35782,21490,30690,20351,23630,39542,22987,24335,31034,22763,19990,26623,20107,25325,35475,36893,21183,26159,21980,22124,36866,20181,20365,37322,39280,27663,24066,24643,23460,35270,35797,25910,25163,39318,23432,23551,25480,21806,21463,30246,20861,34092,26530,26803,27530,25234,36755,21460,33298,28113,30095,20070,36174,23408,29087,34223,26257,26329,32626,34560,40653,40736,23646,26415,36848,26641,26463,25101,31446,22661,24246,25968,28465,34178,34179,34182,34184,34185,34186,34187,34188,34189,34190,34192,34193,34194,34195,34196,34197,34198,34199,34200,34201,34202,34205,34206,34207,34208,34209,34210,34211,34213,34214,34215,34217,34219,34220,34221,34225,34226,34227,34228,34229,34230,34232,34234,34235,34236,34237,34238,34239,34240,34242,34243,34244,34245,34246,34247,34248,34250,34251,34252,34253,34254,34257,34258,34260,34262,34263,34264,34265,34266,34267,34269,34270,34271,34272,34273,34274,34275,34277,34278,34279,34280,34282,34283,34284,34285,34286,34287,34288,34289,34290,34291,34292,34293,34294,34295,34296,24661,21047,32781,25684,34928,29993,24069,26643,25332,38684,21452,29245,35841,27700,30561,31246,21550,30636,39034,33308,35828,30805,26388,28865,26031,25749,22070,24605,31169,21496,19997,27515,32902,23546,21987,22235,20282,20284,39282,24051,26494,32824,24578,39042,36865,23435,35772,35829,25628,33368,25822,22013,33487,37221,20439,32032,36895,31903,20723,22609,28335,23487,35785,32899,37240,33948,31639,34429,38539,38543,32485,39635,30862,23681,31319,36930,38567,31071,23385,25439,31499,34001,26797,21766,32553,29712,32034,38145,25152,22604,20182,23427,22905,22612,34297,34298,34300,34301,34302,34304,34305,34306,34307,34308,34310,34311,34312,34313,34314,34315,34316,34317,34318,34319,34320,34322,34323,34324,34325,34327,34328,34329,34330,34331,34332,34333,34334,34335,34336,34337,34338,34339,34340,34341,34342,34344,34346,34347,34348,34349,34350,34351,34352,34353,34354,34355,34356,34357,34358,34359,34361,34362,34363,34365,34366,34367,34368,34369,34370,34371,34372,34373,34374,34375,34376,34377,34378,34379,34380,34386,34387,34389,34390,34391,34392,34393,34395,34396,34397,34399,34400,34401,34403,34404,34405,34406,34407,34408,34409,34410,29549,25374,36427,36367,32974,33492,25260,21488,27888,37214,22826,24577,27760,22349,25674,36138,30251,28393,22363,27264,30192,28525,35885,35848,22374,27631,34962,30899,25506,21497,28845,27748,22616,25642,22530,26848,33179,21776,31958,20504,36538,28108,36255,28907,25487,28059,28372,32486,33796,26691,36867,28120,38518,35752,22871,29305,34276,33150,30140,35466,26799,21076,36386,38161,25552,39064,36420,21884,20307,26367,22159,24789,28053,21059,23625,22825,28155,22635,30000,29980,24684,33300,33094,25361,26465,36834,30522,36339,36148,38081,24086,21381,21548,28867,34413,34415,34416,34418,34419,34420,34421,34422,34423,34424,34435,34436,34437,34438,34439,34440,34441,34446,34447,34448,34449,34450,34452,34454,34455,34456,34457,34458,34459,34462,34463,34464,34465,34466,34469,34470,34475,34477,34478,34482,34483,34487,34488,34489,34491,34492,34493,34494,34495,34497,34498,34499,34501,34504,34508,34509,34514,34515,34517,34518,34519,34522,34524,34525,34528,34529,34530,34531,34533,34534,34535,34536,34538,34539,34540,34543,34549,34550,34551,34554,34555,34556,34557,34559,34561,34564,34565,34566,34571,34572,34574,34575,34576,34577,34580,34582,27712,24311,20572,20141,24237,25402,33351,36890,26704,37230,30643,21516,38108,24420,31461,26742,25413,31570,32479,30171,20599,25237,22836,36879,20984,31171,31361,22270,24466,36884,28034,23648,22303,21520,20820,28237,22242,25512,39059,33151,34581,35114,36864,21534,23663,33216,25302,25176,33073,40501,38464,39534,39548,26925,22949,25299,21822,25366,21703,34521,27964,23043,29926,34972,27498,22806,35916,24367,28286,29609,39037,20024,28919,23436,30871,25405,26202,30358,24779,23451,23113,19975,33109,27754,29579,20129,26505,32593,24448,26106,26395,24536,22916,23041,34585,34587,34589,34591,34592,34596,34598,34599,34600,34602,34603,34604,34605,34607,34608,34610,34611,34613,34614,34616,34617,34618,34620,34621,34624,34625,34626,34627,34628,34629,34630,34634,34635,34637,34639,34640,34641,34642,34644,34645,34646,34648,34650,34651,34652,34653,34654,34655,34657,34658,34662,34663,34664,34665,34666,34667,34668,34669,34671,34673,34674,34675,34677,34679,34680,34681,34682,34687,34688,34689,34692,34694,34695,34697,34698,34700,34702,34703,34704,34705,34706,34708,34709,34710,34712,34713,34714,34715,34716,34717,34718,34720,34721,34722,34723,34724,24013,24494,21361,38886,36829,26693,22260,21807,24799,20026,28493,32500,33479,33806,22996,20255,20266,23614,32428,26410,34074,21619,30031,32963,21890,39759,20301,28205,35859,23561,24944,21355,30239,28201,34442,25991,38395,32441,21563,31283,32010,38382,21985,32705,29934,25373,34583,28065,31389,25105,26017,21351,25569,27779,24043,21596,38056,20044,27745,35820,23627,26080,33436,26791,21566,21556,27595,27494,20116,25410,21320,33310,20237,20398,22366,25098,38654,26212,29289,21247,21153,24735,35823,26132,29081,26512,35199,30802,30717,26224,22075,21560,38177,29306,34725,34726,34727,34729,34730,34734,34736,34737,34738,34740,34742,34743,34744,34745,34747,34748,34750,34751,34753,34754,34755,34756,34757,34759,34760,34761,34764,34765,34766,34767,34768,34772,34773,34774,34775,34776,34777,34778,34780,34781,34782,34783,34785,34786,34787,34788,34790,34791,34792,34793,34795,34796,34797,34799,34800,34801,34802,34803,34804,34805,34806,34807,34808,34810,34811,34812,34813,34815,34816,34817,34818,34820,34821,34822,34823,34824,34825,34827,34828,34829,34830,34831,34832,34833,34834,34836,34839,34840,34841,34842,34844,34845,34846,34847,34848,34851,31232,24687,24076,24713,33181,22805,24796,29060,28911,28330,27728,29312,27268,34989,24109,20064,23219,21916,38115,27927,31995,38553,25103,32454,30606,34430,21283,38686,36758,26247,23777,20384,29421,19979,21414,22799,21523,25472,38184,20808,20185,40092,32420,21688,36132,34900,33335,38386,28046,24358,23244,26174,38505,29616,29486,21439,33146,39301,32673,23466,38519,38480,32447,30456,21410,38262,39321,31665,35140,28248,20065,32724,31077,35814,24819,21709,20139,39033,24055,27233,20687,21521,35937,33831,30813,38660,21066,21742,22179,38144,28040,23477,28102,26195,34852,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34867,34868,34869,34870,34871,34872,34874,34875,34877,34878,34879,34881,34882,34883,34886,34887,34888,34889,34890,34891,34894,34895,34896,34897,34898,34899,34901,34902,34904,34906,34907,34908,34909,34910,34911,34912,34918,34919,34922,34925,34927,34929,34931,34932,34933,34934,34936,34937,34938,34939,34940,34944,34947,34950,34951,34953,34954,34956,34958,34959,34960,34961,34963,34964,34965,34967,34968,34969,34970,34971,34973,34974,34975,34976,34977,34979,34981,34982,34983,34984,34985,34986,23567,23389,26657,32918,21880,31505,25928,26964,20123,27463,34638,38795,21327,25375,25658,37034,26012,32961,35856,20889,26800,21368,34809,25032,27844,27899,35874,23633,34218,33455,38156,27427,36763,26032,24571,24515,20449,34885,26143,33125,29481,24826,20852,21009,22411,24418,37026,34892,37266,24184,26447,24615,22995,20804,20982,33016,21256,27769,38596,29066,20241,20462,32670,26429,21957,38152,31168,34966,32483,22687,25100,38656,34394,22040,39035,24464,35768,33988,37207,21465,26093,24207,30044,24676,32110,23167,32490,32493,36713,21927,23459,24748,26059,29572,34988,34990,34991,34992,34994,34995,34996,34997,34998,35000,35001,35002,35003,35005,35006,35007,35008,35011,35012,35015,35016,35018,35019,35020,35021,35023,35024,35025,35027,35030,35031,35034,35035,35036,35037,35038,35040,35041,35046,35047,35049,35050,35051,35052,35053,35054,35055,35058,35061,35062,35063,35066,35067,35069,35071,35072,35073,35075,35076,35077,35078,35079,35080,35081,35083,35084,35085,35086,35087,35089,35092,35093,35094,35095,35096,35100,35101,35102,35103,35104,35106,35107,35108,35110,35111,35112,35113,35116,35117,35118,35119,35121,35122,35123,35125,35127,36873,30307,30505,32474,38772,34203,23398,31348,38634,34880,21195,29071,24490,26092,35810,23547,39535,24033,27529,27739,35757,35759,36874,36805,21387,25276,40486,40493,21568,20011,33469,29273,34460,23830,34905,28079,38597,21713,20122,35766,28937,21693,38409,28895,28153,30416,20005,30740,34578,23721,24310,35328,39068,38414,28814,27839,22852,25513,30524,34893,28436,33395,22576,29141,21388,30746,38593,21761,24422,28976,23476,35866,39564,27523,22830,40495,31207,26472,25196,20335,30113,32650,27915,38451,27687,20208,30162,20859,26679,28478,36992,33136,22934,29814,35128,35129,35130,35131,35132,35133,35134,35135,35136,35138,35139,35141,35142,35143,35144,35145,35146,35147,35148,35149,35150,35151,35152,35153,35154,35155,35156,35157,35158,35159,35160,35161,35162,35163,35164,35165,35168,35169,35170,35171,35172,35173,35175,35176,35177,35178,35179,35180,35181,35182,35183,35184,35185,35186,35187,35188,35189,35190,35191,35192,35193,35194,35196,35197,35198,35200,35202,35204,35205,35207,35208,35209,35210,35211,35212,35213,35214,35215,35216,35217,35218,35219,35220,35221,35222,35223,35224,35225,35226,35227,35228,35229,35230,35231,35232,35233,25671,23591,36965,31377,35875,23002,21676,33280,33647,35201,32768,26928,22094,32822,29239,37326,20918,20063,39029,25494,19994,21494,26355,33099,22812,28082,19968,22777,21307,25558,38129,20381,20234,34915,39056,22839,36951,31227,20202,33008,30097,27778,23452,23016,24413,26885,34433,20506,24050,20057,30691,20197,33402,25233,26131,37009,23673,20159,24441,33222,36920,32900,30123,20134,35028,24847,27589,24518,20041,30410,28322,35811,35758,35850,35793,24322,32764,32716,32462,33589,33643,22240,27575,38899,38452,23035,21535,38134,28139,23493,39278,23609,24341,38544,35234,35235,35236,35237,35238,35239,35240,35241,35242,35243,35244,35245,35246,35247,35248,35249,35250,35251,35252,35253,35254,35255,35256,35257,35258,35259,35260,35261,35262,35263,35264,35267,35277,35283,35284,35285,35287,35288,35289,35291,35293,35295,35296,35297,35298,35300,35303,35304,35305,35306,35308,35309,35310,35312,35313,35314,35316,35317,35318,35319,35320,35321,35322,35323,35324,35325,35326,35327,35329,35330,35331,35332,35333,35334,35336,35337,35338,35339,35340,35341,35342,35343,35344,35345,35346,35347,35348,35349,35350,35351,35352,35353,35354,35355,35356,35357,21360,33521,27185,23156,40560,24212,32552,33721,33828,33829,33639,34631,36814,36194,30408,24433,39062,30828,26144,21727,25317,20323,33219,30152,24248,38605,36362,34553,21647,27891,28044,27704,24703,21191,29992,24189,20248,24736,24551,23588,30001,37038,38080,29369,27833,28216,37193,26377,21451,21491,20305,37321,35825,21448,24188,36802,28132,20110,30402,27014,34398,24858,33286,20313,20446,36926,40060,24841,28189,28180,38533,20104,23089,38632,19982,23679,31161,23431,35821,32701,29577,22495,33419,37057,21505,36935,21947,23786,24481,24840,27442,29425,32946,35465,35358,35359,35360,35361,35362,35363,35364,35365,35366,35367,35368,35369,35370,35371,35372,35373,35374,35375,35376,35377,35378,35379,35380,35381,35382,35383,35384,35385,35386,35387,35388,35389,35391,35392,35393,35394,35395,35396,35397,35398,35399,35401,35402,35403,35404,35405,35406,35407,35408,35409,35410,35411,35412,35413,35414,35415,35416,35417,35418,35419,35420,35421,35422,35423,35424,35425,35426,35427,35428,35429,35430,35431,35432,35433,35434,35435,35436,35437,35438,35439,35440,35441,35442,35443,35444,35445,35446,35447,35448,35450,35451,35452,35453,35454,35455,35456,28020,23507,35029,39044,35947,39533,40499,28170,20900,20803,22435,34945,21407,25588,36757,22253,21592,22278,29503,28304,32536,36828,33489,24895,24616,38498,26352,32422,36234,36291,38053,23731,31908,26376,24742,38405,32792,20113,37095,21248,38504,20801,36816,34164,37213,26197,38901,23381,21277,30776,26434,26685,21705,28798,23472,36733,20877,22312,21681,25874,26242,36190,36163,33039,33900,36973,31967,20991,34299,26531,26089,28577,34468,36481,22122,36896,30338,28790,29157,36131,25321,21017,27901,36156,24590,22686,24974,26366,36192,25166,21939,28195,26413,36711,35457,35458,35459,35460,35461,35462,35463,35464,35467,35468,35469,35470,35471,35472,35473,35474,35476,35477,35478,35479,35480,35481,35482,35483,35484,35485,35486,35487,35488,35489,35490,35491,35492,35493,35494,35495,35496,35497,35498,35499,35500,35501,35502,35503,35504,35505,35506,35507,35508,35509,35510,35511,35512,35513,35514,35515,35516,35517,35518,35519,35520,35521,35522,35523,35524,35525,35526,35527,35528,35529,35530,35531,35532,35533,35534,35535,35536,35537,35538,35539,35540,35541,35542,35543,35544,35545,35546,35547,35548,35549,35550,35551,35552,35553,35554,35555,38113,38392,30504,26629,27048,21643,20045,28856,35784,25688,25995,23429,31364,20538,23528,30651,27617,35449,31896,27838,30415,26025,36759,23853,23637,34360,26632,21344,25112,31449,28251,32509,27167,31456,24432,28467,24352,25484,28072,26454,19976,24080,36134,20183,32960,30260,38556,25307,26157,25214,27836,36213,29031,32617,20806,32903,21484,36974,25240,21746,34544,36761,32773,38167,34071,36825,27993,29645,26015,30495,29956,30759,33275,36126,38024,20390,26517,30137,35786,38663,25391,38215,38453,33976,25379,30529,24449,29424,20105,24596,25972,25327,27491,25919,35556,35557,35558,35559,35560,35561,35562,35563,35564,35565,35566,35567,35568,35569,35570,35571,35572,35573,35574,35575,35576,35577,35578,35579,35580,35581,35582,35583,35584,35585,35586,35587,35588,35589,35590,35592,35593,35594,35595,35596,35597,35598,35599,35600,35601,35602,35603,35604,35605,35606,35607,35608,35609,35610,35611,35612,35613,35614,35615,35616,35617,35618,35619,35620,35621,35623,35624,35625,35626,35627,35628,35629,35630,35631,35632,35633,35634,35635,35636,35637,35638,35639,35640,35641,35642,35643,35644,35645,35646,35647,35648,35649,35650,35651,35652,35653,24103,30151,37073,35777,33437,26525,25903,21553,34584,30693,32930,33026,27713,20043,32455,32844,30452,26893,27542,25191,20540,20356,22336,25351,27490,36286,21482,26088,32440,24535,25370,25527,33267,33268,32622,24092,23769,21046,26234,31209,31258,36136,28825,30164,28382,27835,31378,20013,30405,24544,38047,34935,32456,31181,32959,37325,20210,20247,33311,21608,24030,27954,35788,31909,36724,32920,24090,21650,30385,23449,26172,39588,29664,26666,34523,26417,29482,35832,35803,36880,31481,28891,29038,25284,30633,22065,20027,33879,26609,21161,34496,36142,38136,31569,35654,35655,35656,35657,35658,35659,35660,35661,35662,35663,35664,35665,35666,35667,35668,35669,35670,35671,35672,35673,35674,35675,35676,35677,35678,35679,35680,35681,35682,35683,35684,35685,35687,35688,35689,35690,35691,35693,35694,35695,35696,35697,35698,35699,35700,35701,35702,35703,35704,35705,35706,35707,35708,35709,35710,35711,35712,35713,35714,35715,35716,35717,35718,35719,35720,35721,35722,35723,35724,35725,35726,35727,35728,35729,35730,35731,35732,35733,35734,35735,35736,35737,35738,35739,35740,35741,35742,35743,35756,35761,35771,35783,35792,35818,35849,35870,20303,27880,31069,39547,25235,29226,25341,19987,30742,36716,25776,36186,31686,26729,24196,35013,22918,25758,22766,29366,26894,38181,36861,36184,22368,32512,35846,20934,25417,25305,21331,26700,29730,33537,37196,21828,30528,28796,27978,20857,21672,36164,23039,28363,28100,23388,32043,20180,31869,28371,23376,33258,28173,23383,39683,26837,36394,23447,32508,24635,32437,37049,36208,22863,25549,31199,36275,21330,26063,31062,35781,38459,32452,38075,32386,22068,37257,26368,32618,23562,36981,26152,24038,20304,26590,20570,20316,22352,24231,59408,59409,59410,59411,59412,35896,35897,35898,35899,35900,35901,35902,35903,35904,35906,35907,35908,35909,35912,35914,35915,35917,35918,35919,35920,35921,35922,35923,35924,35926,35927,35928,35929,35931,35932,35933,35934,35935,35936,35939,35940,35941,35942,35943,35944,35945,35948,35949,35950,35951,35952,35953,35954,35956,35957,35958,35959,35963,35964,35965,35966,35967,35968,35969,35971,35972,35974,35975,35976,35979,35981,35982,35983,35984,35985,35986,35987,35989,35990,35991,35993,35994,35995,35996,35997,35998,35999,36000,36001,36002,36003,36004,36005,36006,36007,36008,36009,36010,36011,36012,36013,20109,19980,20800,19984,24319,21317,19989,20120,19998,39730,23404,22121,20008,31162,20031,21269,20039,22829,29243,21358,27664,22239,32996,39319,27603,30590,40727,20022,20127,40720,20060,20073,20115,33416,23387,21868,22031,20164,21389,21405,21411,21413,21422,38757,36189,21274,21493,21286,21294,21310,36188,21350,21347,20994,21000,21006,21037,21043,21055,21056,21068,21086,21089,21084,33967,21117,21122,21121,21136,21139,20866,32596,20155,20163,20169,20162,20200,20193,20203,20190,20251,20211,20258,20324,20213,20261,20263,20233,20267,20318,20327,25912,20314,20317,36014,36015,36016,36017,36018,36019,36020,36021,36022,36023,36024,36025,36026,36027,36028,36029,36030,36031,36032,36033,36034,36035,36036,36037,36038,36039,36040,36041,36042,36043,36044,36045,36046,36047,36048,36049,36050,36051,36052,36053,36054,36055,36056,36057,36058,36059,36060,36061,36062,36063,36064,36065,36066,36067,36068,36069,36070,36071,36072,36073,36074,36075,36076,36077,36078,36079,36080,36081,36082,36083,36084,36085,36086,36087,36088,36089,36090,36091,36092,36093,36094,36095,36096,36097,36098,36099,36100,36101,36102,36103,36104,36105,36106,36107,36108,36109,20319,20311,20274,20285,20342,20340,20369,20361,20355,20367,20350,20347,20394,20348,20396,20372,20454,20456,20458,20421,20442,20451,20444,20433,20447,20472,20521,20556,20467,20524,20495,20526,20525,20478,20508,20492,20517,20520,20606,20547,20565,20552,20558,20588,20603,20645,20647,20649,20666,20694,20742,20717,20716,20710,20718,20743,20747,20189,27709,20312,20325,20430,40864,27718,31860,20846,24061,40649,39320,20865,22804,21241,21261,35335,21264,20971,22809,20821,20128,20822,20147,34926,34980,20149,33044,35026,31104,23348,34819,32696,20907,20913,20925,20924,36110,36111,36112,36113,36114,36115,36116,36117,36118,36119,36120,36121,36122,36123,36124,36128,36177,36178,36183,36191,36197,36200,36201,36202,36204,36206,36207,36209,36210,36216,36217,36218,36219,36220,36221,36222,36223,36224,36226,36227,36230,36231,36232,36233,36236,36237,36238,36239,36240,36242,36243,36245,36246,36247,36248,36249,36250,36251,36252,36253,36254,36256,36257,36258,36260,36261,36262,36263,36264,36265,36266,36267,36268,36269,36270,36271,36272,36274,36278,36279,36281,36283,36285,36288,36289,36290,36293,36295,36296,36297,36298,36301,36304,36306,36307,36308,20935,20886,20898,20901,35744,35750,35751,35754,35764,35765,35767,35778,35779,35787,35791,35790,35794,35795,35796,35798,35800,35801,35804,35807,35808,35812,35816,35817,35822,35824,35827,35830,35833,35836,35839,35840,35842,35844,35847,35852,35855,35857,35858,35860,35861,35862,35865,35867,35864,35869,35871,35872,35873,35877,35879,35882,35883,35886,35887,35890,35891,35893,35894,21353,21370,38429,38434,38433,38449,38442,38461,38460,38466,38473,38484,38495,38503,38508,38514,38516,38536,38541,38551,38576,37015,37019,37021,37017,37036,37025,37044,37043,37046,37050,36309,36312,36313,36316,36320,36321,36322,36325,36326,36327,36329,36333,36334,36336,36337,36338,36340,36342,36348,36350,36351,36352,36353,36354,36355,36356,36358,36359,36360,36363,36365,36366,36368,36369,36370,36371,36373,36374,36375,36376,36377,36378,36379,36380,36384,36385,36388,36389,36390,36391,36392,36395,36397,36400,36402,36403,36404,36406,36407,36408,36411,36412,36414,36415,36419,36421,36422,36428,36429,36430,36431,36432,36435,36436,36437,36438,36439,36440,36442,36443,36444,36445,36446,36447,36448,36449,36450,36451,36452,36453,36455,36456,36458,36459,36462,36465,37048,37040,37071,37061,37054,37072,37060,37063,37075,37094,37090,37084,37079,37083,37099,37103,37118,37124,37154,37150,37155,37169,37167,37177,37187,37190,21005,22850,21154,21164,21165,21182,21759,21200,21206,21232,21471,29166,30669,24308,20981,20988,39727,21430,24321,30042,24047,22348,22441,22433,22654,22716,22725,22737,22313,22316,22314,22323,22329,22318,22319,22364,22331,22338,22377,22405,22379,22406,22396,22395,22376,22381,22390,22387,22445,22436,22412,22450,22479,22439,22452,22419,22432,22485,22488,22490,22489,22482,22456,22516,22511,22520,22500,22493,36467,36469,36471,36472,36473,36474,36475,36477,36478,36480,36482,36483,36484,36486,36488,36489,36490,36491,36492,36493,36494,36497,36498,36499,36501,36502,36503,36504,36505,36506,36507,36509,36511,36512,36513,36514,36515,36516,36517,36518,36519,36520,36521,36522,36525,36526,36528,36529,36531,36532,36533,36534,36535,36536,36537,36539,36540,36541,36542,36543,36544,36545,36546,36547,36548,36549,36550,36551,36552,36553,36554,36555,36556,36557,36559,36560,36561,36562,36563,36564,36565,36566,36567,36568,36569,36570,36571,36572,36573,36574,36575,36576,36577,36578,36579,36580,22539,22541,22525,22509,22528,22558,22553,22596,22560,22629,22636,22657,22665,22682,22656,39336,40729,25087,33401,33405,33407,33423,33418,33448,33412,33422,33425,33431,33433,33451,33464,33470,33456,33480,33482,33507,33432,33463,33454,33483,33484,33473,33449,33460,33441,33450,33439,33476,33486,33444,33505,33545,33527,33508,33551,33543,33500,33524,33490,33496,33548,33531,33491,33553,33562,33542,33556,33557,33504,33493,33564,33617,33627,33628,33544,33682,33596,33588,33585,33691,33630,33583,33615,33607,33603,33631,33600,33559,33632,33581,33594,33587,33638,33637,36581,36582,36583,36584,36585,36586,36587,36588,36589,36590,36591,36592,36593,36594,36595,36596,36597,36598,36599,36600,36601,36602,36603,36604,36605,36606,36607,36608,36609,36610,36611,36612,36613,36614,36615,36616,36617,36618,36619,36620,36621,36622,36623,36624,36625,36626,36627,36628,36629,36630,36631,36632,36633,36634,36635,36636,36637,36638,36639,36640,36641,36642,36643,36644,36645,36646,36647,36648,36649,36650,36651,36652,36653,36654,36655,36656,36657,36658,36659,36660,36661,36662,36663,36664,36665,36666,36667,36668,36669,36670,36671,36672,36673,36674,36675,36676,33640,33563,33641,33644,33642,33645,33646,33712,33656,33715,33716,33696,33706,33683,33692,33669,33660,33718,33705,33661,33720,33659,33688,33694,33704,33722,33724,33729,33793,33765,33752,22535,33816,33803,33757,33789,33750,33820,33848,33809,33798,33748,33759,33807,33795,33784,33785,33770,33733,33728,33830,33776,33761,33884,33873,33882,33881,33907,33927,33928,33914,33929,33912,33852,33862,33897,33910,33932,33934,33841,33901,33985,33997,34000,34022,33981,34003,33994,33983,33978,34016,33953,33977,33972,33943,34021,34019,34060,29965,34104,34032,34105,34079,34106,36677,36678,36679,36680,36681,36682,36683,36684,36685,36686,36687,36688,36689,36690,36691,36692,36693,36694,36695,36696,36697,36698,36699,36700,36701,36702,36703,36704,36705,36706,36707,36708,36709,36714,36736,36748,36754,36765,36768,36769,36770,36772,36773,36774,36775,36778,36780,36781,36782,36783,36786,36787,36788,36789,36791,36792,36794,36795,36796,36799,36800,36803,36806,36809,36810,36811,36812,36813,36815,36818,36822,36823,36826,36832,36833,36835,36839,36844,36847,36849,36850,36852,36853,36854,36858,36859,36860,36862,36863,36871,36872,36876,36878,36883,36885,36888,34134,34107,34047,34044,34137,34120,34152,34148,34142,34170,30626,34115,34162,34171,34212,34216,34183,34191,34169,34222,34204,34181,34233,34231,34224,34259,34241,34268,34303,34343,34309,34345,34326,34364,24318,24328,22844,22849,32823,22869,22874,22872,21263,23586,23589,23596,23604,25164,25194,25247,25275,25290,25306,25303,25326,25378,25334,25401,25419,25411,25517,25590,25457,25466,25486,25524,25453,25516,25482,25449,25518,25532,25586,25592,25568,25599,25540,25566,25550,25682,25542,25534,25669,25665,25611,25627,25632,25612,25638,25633,25694,25732,25709,25750,36889,36892,36899,36900,36901,36903,36904,36905,36906,36907,36908,36912,36913,36914,36915,36916,36919,36921,36922,36925,36927,36928,36931,36933,36934,36936,36937,36938,36939,36940,36942,36948,36949,36950,36953,36954,36956,36957,36958,36959,36960,36961,36964,36966,36967,36969,36970,36971,36972,36975,36976,36977,36978,36979,36982,36983,36984,36985,36986,36987,36988,36990,36993,36996,36997,36998,36999,37001,37002,37004,37005,37006,37007,37008,37010,37012,37014,37016,37018,37020,37022,37023,37024,37028,37029,37031,37032,37033,37035,37037,37042,37047,37052,37053,37055,37056,25722,25783,25784,25753,25786,25792,25808,25815,25828,25826,25865,25893,25902,24331,24530,29977,24337,21343,21489,21501,21481,21480,21499,21522,21526,21510,21579,21586,21587,21588,21590,21571,21537,21591,21593,21539,21554,21634,21652,21623,21617,21604,21658,21659,21636,21622,21606,21661,21712,21677,21698,21684,21714,21671,21670,21715,21716,21618,21667,21717,21691,21695,21708,21721,21722,21724,21673,21674,21668,21725,21711,21726,21787,21735,21792,21757,21780,21747,21794,21795,21775,21777,21799,21802,21863,21903,21941,21833,21869,21825,21845,21823,21840,21820,37058,37059,37062,37064,37065,37067,37068,37069,37074,37076,37077,37078,37080,37081,37082,37086,37087,37088,37091,37092,37093,37097,37098,37100,37102,37104,37105,37106,37107,37109,37110,37111,37113,37114,37115,37116,37119,37120,37121,37123,37125,37126,37127,37128,37129,37130,37131,37132,37133,37134,37135,37136,37137,37138,37139,37140,37141,37142,37143,37144,37146,37147,37148,37149,37151,37152,37153,37156,37157,37158,37159,37160,37161,37162,37163,37164,37165,37166,37168,37170,37171,37172,37173,37174,37175,37176,37178,37179,37180,37181,37182,37183,37184,37185,37186,37188,21815,21846,21877,21878,21879,21811,21808,21852,21899,21970,21891,21937,21945,21896,21889,21919,21886,21974,21905,21883,21983,21949,21950,21908,21913,21994,22007,21961,22047,21969,21995,21996,21972,21990,21981,21956,21999,21989,22002,22003,21964,21965,21992,22005,21988,36756,22046,22024,22028,22017,22052,22051,22014,22016,22055,22061,22104,22073,22103,22060,22093,22114,22105,22108,22092,22100,22150,22116,22129,22123,22139,22140,22149,22163,22191,22228,22231,22237,22241,22261,22251,22265,22271,22276,22282,22281,22300,24079,24089,24084,24081,24113,24123,24124,37189,37191,37192,37201,37203,37204,37205,37206,37208,37209,37211,37212,37215,37216,37222,37223,37224,37227,37229,37235,37242,37243,37244,37248,37249,37250,37251,37252,37254,37256,37258,37262,37263,37267,37268,37269,37270,37271,37272,37273,37276,37277,37278,37279,37280,37281,37284,37285,37286,37287,37288,37289,37291,37292,37296,37297,37298,37299,37302,37303,37304,37305,37307,37308,37309,37310,37311,37312,37313,37314,37315,37316,37317,37318,37320,37323,37328,37330,37331,37332,37333,37334,37335,37336,37337,37338,37339,37341,37342,37343,37344,37345,37346,37347,37348,37349,24119,24132,24148,24155,24158,24161,23692,23674,23693,23696,23702,23688,23704,23705,23697,23706,23708,23733,23714,23741,23724,23723,23729,23715,23745,23735,23748,23762,23780,23755,23781,23810,23811,23847,23846,23854,23844,23838,23814,23835,23896,23870,23860,23869,23916,23899,23919,23901,23915,23883,23882,23913,23924,23938,23961,23965,35955,23991,24005,24435,24439,24450,24455,24457,24460,24469,24473,24476,24488,24493,24501,24508,34914,24417,29357,29360,29364,29367,29368,29379,29377,29390,29389,29394,29416,29423,29417,29426,29428,29431,29441,29427,29443,29434,37350,37351,37352,37353,37354,37355,37356,37357,37358,37359,37360,37361,37362,37363,37364,37365,37366,37367,37368,37369,37370,37371,37372,37373,37374,37375,37376,37377,37378,37379,37380,37381,37382,37383,37384,37385,37386,37387,37388,37389,37390,37391,37392,37393,37394,37395,37396,37397,37398,37399,37400,37401,37402,37403,37404,37405,37406,37407,37408,37409,37410,37411,37412,37413,37414,37415,37416,37417,37418,37419,37420,37421,37422,37423,37424,37425,37426,37427,37428,37429,37430,37431,37432,37433,37434,37435,37436,37437,37438,37439,37440,37441,37442,37443,37444,37445,29435,29463,29459,29473,29450,29470,29469,29461,29474,29497,29477,29484,29496,29489,29520,29517,29527,29536,29548,29551,29566,33307,22821,39143,22820,22786,39267,39271,39272,39273,39274,39275,39276,39284,39287,39293,39296,39300,39303,39306,39309,39312,39313,39315,39316,39317,24192,24209,24203,24214,24229,24224,24249,24245,24254,24243,36179,24274,24273,24283,24296,24298,33210,24516,24521,24534,24527,24579,24558,24580,24545,24548,24574,24581,24582,24554,24557,24568,24601,24629,24614,24603,24591,24589,24617,24619,24586,24639,24609,24696,24697,24699,24698,24642,37446,37447,37448,37449,37450,37451,37452,37453,37454,37455,37456,37457,37458,37459,37460,37461,37462,37463,37464,37465,37466,37467,37468,37469,37470,37471,37472,37473,37474,37475,37476,37477,37478,37479,37480,37481,37482,37483,37484,37485,37486,37487,37488,37489,37490,37491,37493,37494,37495,37496,37497,37498,37499,37500,37501,37502,37503,37504,37505,37506,37507,37508,37509,37510,37511,37512,37513,37514,37515,37516,37517,37519,37520,37521,37522,37523,37524,37525,37526,37527,37528,37529,37530,37531,37532,37533,37534,37535,37536,37537,37538,37539,37540,37541,37542,37543,24682,24701,24726,24730,24749,24733,24707,24722,24716,24731,24812,24763,24753,24797,24792,24774,24794,24756,24864,24870,24853,24867,24820,24832,24846,24875,24906,24949,25004,24980,24999,25015,25044,25077,24541,38579,38377,38379,38385,38387,38389,38390,38396,38398,38403,38404,38406,38408,38410,38411,38412,38413,38415,38418,38421,38422,38423,38425,38426,20012,29247,25109,27701,27732,27740,27722,27811,27781,27792,27796,27788,27752,27753,27764,27766,27782,27817,27856,27860,27821,27895,27896,27889,27863,27826,27872,27862,27898,27883,27886,27825,27859,27887,27902,37544,37545,37546,37547,37548,37549,37551,37552,37553,37554,37555,37556,37557,37558,37559,37560,37561,37562,37563,37564,37565,37566,37567,37568,37569,37570,37571,37572,37573,37574,37575,37577,37578,37579,37580,37581,37582,37583,37584,37585,37586,37587,37588,37589,37590,37591,37592,37593,37594,37595,37596,37597,37598,37599,37600,37601,37602,37603,37604,37605,37606,37607,37608,37609,37610,37611,37612,37613,37614,37615,37616,37617,37618,37619,37620,37621,37622,37623,37624,37625,37626,37627,37628,37629,37630,37631,37632,37633,37634,37635,37636,37637,37638,37639,37640,37641,27961,27943,27916,27971,27976,27911,27908,27929,27918,27947,27981,27950,27957,27930,27983,27986,27988,27955,28049,28015,28062,28064,27998,28051,28052,27996,28000,28028,28003,28186,28103,28101,28126,28174,28095,28128,28177,28134,28125,28121,28182,28075,28172,28078,28203,28270,28238,28267,28338,28255,28294,28243,28244,28210,28197,28228,28383,28337,28312,28384,28461,28386,28325,28327,28349,28347,28343,28375,28340,28367,28303,28354,28319,28514,28486,28487,28452,28437,28409,28463,28470,28491,28532,28458,28425,28457,28553,28557,28556,28536,28530,28540,28538,28625,37642,37643,37644,37645,37646,37647,37648,37649,37650,37651,37652,37653,37654,37655,37656,37657,37658,37659,37660,37661,37662,37663,37664,37665,37666,37667,37668,37669,37670,37671,37672,37673,37674,37675,37676,37677,37678,37679,37680,37681,37682,37683,37684,37685,37686,37687,37688,37689,37690,37691,37692,37693,37695,37696,37697,37698,37699,37700,37701,37702,37703,37704,37705,37706,37707,37708,37709,37710,37711,37712,37713,37714,37715,37716,37717,37718,37719,37720,37721,37722,37723,37724,37725,37726,37727,37728,37729,37730,37731,37732,37733,37734,37735,37736,37737,37739,28617,28583,28601,28598,28610,28641,28654,28638,28640,28655,28698,28707,28699,28729,28725,28751,28766,23424,23428,23445,23443,23461,23480,29999,39582,25652,23524,23534,35120,23536,36423,35591,36790,36819,36821,36837,36846,36836,36841,36838,36851,36840,36869,36868,36875,36902,36881,36877,36886,36897,36917,36918,36909,36911,36932,36945,36946,36944,36968,36952,36962,36955,26297,36980,36989,36994,37000,36995,37003,24400,24407,24406,24408,23611,21675,23632,23641,23409,23651,23654,32700,24362,24361,24365,33396,24380,39739,23662,22913,22915,22925,22953,22954,22947,37740,37741,37742,37743,37744,37745,37746,37747,37748,37749,37750,37751,37752,37753,37754,37755,37756,37757,37758,37759,37760,37761,37762,37763,37764,37765,37766,37767,37768,37769,37770,37771,37772,37773,37774,37776,37777,37778,37779,37780,37781,37782,37783,37784,37785,37786,37787,37788,37789,37790,37791,37792,37793,37794,37795,37796,37797,37798,37799,37800,37801,37802,37803,37804,37805,37806,37807,37808,37809,37810,37811,37812,37813,37814,37815,37816,37817,37818,37819,37820,37821,37822,37823,37824,37825,37826,37827,37828,37829,37830,37831,37832,37833,37835,37836,37837,22935,22986,22955,22942,22948,22994,22962,22959,22999,22974,23045,23046,23005,23048,23011,23000,23033,23052,23049,23090,23092,23057,23075,23059,23104,23143,23114,23125,23100,23138,23157,33004,23210,23195,23159,23162,23230,23275,23218,23250,23252,23224,23264,23267,23281,23254,23270,23256,23260,23305,23319,23318,23346,23351,23360,23573,23580,23386,23397,23411,23377,23379,23394,39541,39543,39544,39546,39551,39549,39552,39553,39557,39560,39562,39568,39570,39571,39574,39576,39579,39580,39581,39583,39584,39586,39587,39589,39591,32415,32417,32419,32421,32424,32425,37838,37839,37840,37841,37842,37843,37844,37845,37847,37848,37849,37850,37851,37852,37853,37854,37855,37856,37857,37858,37859,37860,37861,37862,37863,37864,37865,37866,37867,37868,37869,37870,37871,37872,37873,37874,37875,37876,37877,37878,37879,37880,37881,37882,37883,37884,37885,37886,37887,37888,37889,37890,37891,37892,37893,37894,37895,37896,37897,37898,37899,37900,37901,37902,37903,37904,37905,37906,37907,37908,37909,37910,37911,37912,37913,37914,37915,37916,37917,37918,37919,37920,37921,37922,37923,37924,37925,37926,37927,37928,37929,37930,37931,37932,37933,37934,32429,32432,32446,32448,32449,32450,32457,32459,32460,32464,32468,32471,32475,32480,32481,32488,32491,32494,32495,32497,32498,32525,32502,32506,32507,32510,32513,32514,32515,32519,32520,32523,32524,32527,32529,32530,32535,32537,32540,32539,32543,32545,32546,32547,32548,32549,32550,32551,32554,32555,32556,32557,32559,32560,32561,32562,32563,32565,24186,30079,24027,30014,37013,29582,29585,29614,29602,29599,29647,29634,29649,29623,29619,29632,29641,29640,29669,29657,39036,29706,29673,29671,29662,29626,29682,29711,29738,29787,29734,29733,29736,29744,29742,29740,37935,37936,37937,37938,37939,37940,37941,37942,37943,37944,37945,37946,37947,37948,37949,37951,37952,37953,37954,37955,37956,37957,37958,37959,37960,37961,37962,37963,37964,37965,37966,37967,37968,37969,37970,37971,37972,37973,37974,37975,37976,37977,37978,37979,37980,37981,37982,37983,37984,37985,37986,37987,37988,37989,37990,37991,37992,37993,37994,37996,37997,37998,37999,38000,38001,38002,38003,38004,38005,38006,38007,38008,38009,38010,38011,38012,38013,38014,38015,38016,38017,38018,38019,38020,38033,38038,38040,38087,38095,38099,38100,38106,38118,38139,38172,38176,29723,29722,29761,29788,29783,29781,29785,29815,29805,29822,29852,29838,29824,29825,29831,29835,29854,29864,29865,29840,29863,29906,29882,38890,38891,38892,26444,26451,26462,26440,26473,26533,26503,26474,26483,26520,26535,26485,26536,26526,26541,26507,26487,26492,26608,26633,26584,26634,26601,26544,26636,26585,26549,26586,26547,26589,26624,26563,26552,26594,26638,26561,26621,26674,26675,26720,26721,26702,26722,26692,26724,26755,26653,26709,26726,26689,26727,26688,26686,26698,26697,26665,26805,26767,26740,26743,26771,26731,26818,26990,26876,26911,26912,26873,38183,38195,38205,38211,38216,38219,38229,38234,38240,38254,38260,38261,38263,38264,38265,38266,38267,38268,38269,38270,38272,38273,38274,38275,38276,38277,38278,38279,38280,38281,38282,38283,38284,38285,38286,38287,38288,38289,38290,38291,38292,38293,38294,38295,38296,38297,38298,38299,38300,38301,38302,38303,38304,38305,38306,38307,38308,38309,38310,38311,38312,38313,38314,38315,38316,38317,38318,38319,38320,38321,38322,38323,38324,38325,38326,38327,38328,38329,38330,38331,38332,38333,38334,38335,38336,38337,38338,38339,38340,38341,38342,38343,38344,38345,38346,38347,26916,26864,26891,26881,26967,26851,26896,26993,26937,26976,26946,26973,27012,26987,27008,27032,27000,26932,27084,27015,27016,27086,27017,26982,26979,27001,27035,27047,27067,27051,27053,27092,27057,27073,27082,27103,27029,27104,27021,27135,27183,27117,27159,27160,27237,27122,27204,27198,27296,27216,27227,27189,27278,27257,27197,27176,27224,27260,27281,27280,27305,27287,27307,29495,29522,27521,27522,27527,27524,27538,27539,27533,27546,27547,27553,27562,36715,36717,36721,36722,36723,36725,36726,36728,36727,36729,36730,36732,36734,36737,36738,36740,36743,36747,38348,38349,38350,38351,38352,38353,38354,38355,38356,38357,38358,38359,38360,38361,38362,38363,38364,38365,38366,38367,38368,38369,38370,38371,38372,38373,38374,38375,38380,38399,38407,38419,38424,38427,38430,38432,38435,38436,38437,38438,38439,38440,38441,38443,38444,38445,38447,38448,38455,38456,38457,38458,38462,38465,38467,38474,38478,38479,38481,38482,38483,38486,38487,38488,38489,38490,38492,38493,38494,38496,38499,38501,38502,38507,38509,38510,38511,38512,38513,38515,38520,38521,38522,38523,38524,38525,38526,38527,38528,38529,38530,38531,38532,38535,38537,38538,36749,36750,36751,36760,36762,36558,25099,25111,25115,25119,25122,25121,25125,25124,25132,33255,29935,29940,29951,29967,29969,29971,25908,26094,26095,26096,26122,26137,26482,26115,26133,26112,28805,26359,26141,26164,26161,26166,26165,32774,26207,26196,26177,26191,26198,26209,26199,26231,26244,26252,26279,26269,26302,26331,26332,26342,26345,36146,36147,36150,36155,36157,36160,36165,36166,36168,36169,36167,36173,36181,36185,35271,35274,35275,35276,35278,35279,35280,35281,29294,29343,29277,29286,29295,29310,29311,29316,29323,29325,29327,29330,25352,25394,25520,38540,38542,38545,38546,38547,38549,38550,38554,38555,38557,38558,38559,38560,38561,38562,38563,38564,38565,38566,38568,38569,38570,38571,38572,38573,38574,38575,38577,38578,38580,38581,38583,38584,38586,38587,38591,38594,38595,38600,38602,38603,38608,38609,38611,38612,38614,38615,38616,38617,38618,38619,38620,38621,38622,38623,38625,38626,38627,38628,38629,38630,38631,38635,38636,38637,38638,38640,38641,38642,38644,38645,38648,38650,38651,38652,38653,38655,38658,38659,38661,38666,38667,38668,38672,38673,38674,38676,38677,38679,38680,38681,38682,38683,38685,38687,38688,25663,25816,32772,27626,27635,27645,27637,27641,27653,27655,27654,27661,27669,27672,27673,27674,27681,27689,27684,27690,27698,25909,25941,25963,29261,29266,29270,29232,34402,21014,32927,32924,32915,32956,26378,32957,32945,32939,32941,32948,32951,32999,33000,33001,33002,32987,32962,32964,32985,32973,32983,26384,32989,33003,33009,33012,33005,33037,33038,33010,33020,26389,33042,35930,33078,33054,33068,33048,33074,33096,33100,33107,33140,33113,33114,33137,33120,33129,33148,33149,33133,33127,22605,23221,33160,33154,33169,28373,33187,33194,33228,26406,33226,33211,38689,38690,38691,38692,38693,38694,38695,38696,38697,38699,38700,38702,38703,38705,38707,38708,38709,38710,38711,38714,38715,38716,38717,38719,38720,38721,38722,38723,38724,38725,38726,38727,38728,38729,38730,38731,38732,38733,38734,38735,38736,38737,38740,38741,38743,38744,38746,38748,38749,38751,38755,38756,38758,38759,38760,38762,38763,38764,38765,38766,38767,38768,38769,38770,38773,38775,38776,38777,38778,38779,38781,38782,38783,38784,38785,38786,38787,38788,38790,38791,38792,38793,38794,38796,38798,38799,38800,38803,38805,38806,38807,38809,38810,38811,38812,38813,33217,33190,27428,27447,27449,27459,27462,27481,39121,39122,39123,39125,39129,39130,27571,24384,27586,35315,26000,40785,26003,26044,26054,26052,26051,26060,26062,26066,26070,28800,28828,28822,28829,28859,28864,28855,28843,28849,28904,28874,28944,28947,28950,28975,28977,29043,29020,29032,28997,29042,29002,29048,29050,29080,29107,29109,29096,29088,29152,29140,29159,29177,29213,29224,28780,28952,29030,29113,25150,25149,25155,25160,25161,31035,31040,31046,31049,31067,31068,31059,31066,31074,31063,31072,31087,31079,31098,31109,31114,31130,31143,31155,24529,24528,38814,38815,38817,38818,38820,38821,38822,38823,38824,38825,38826,38828,38830,38832,38833,38835,38837,38838,38839,38840,38841,38842,38843,38844,38845,38846,38847,38848,38849,38850,38851,38852,38853,38854,38855,38856,38857,38858,38859,38860,38861,38862,38863,38864,38865,38866,38867,38868,38869,38870,38871,38872,38873,38874,38875,38876,38877,38878,38879,38880,38881,38882,38883,38884,38885,38888,38894,38895,38896,38897,38898,38900,38903,38904,38905,38906,38907,38908,38909,38910,38911,38912,38913,38914,38915,38916,38917,38918,38919,38920,38921,38922,38923,38924,38925,38926,24636,24669,24666,24679,24641,24665,24675,24747,24838,24845,24925,25001,24989,25035,25041,25094,32896,32895,27795,27894,28156,30710,30712,30720,30729,30743,30744,30737,26027,30765,30748,30749,30777,30778,30779,30751,30780,30757,30764,30755,30761,30798,30829,30806,30807,30758,30800,30791,30796,30826,30875,30867,30874,30855,30876,30881,30883,30898,30905,30885,30932,30937,30921,30956,30962,30981,30964,30995,31012,31006,31028,40859,40697,40699,40700,30449,30468,30477,30457,30471,30472,30490,30498,30489,30509,30502,30517,30520,30544,30545,30535,30531,30554,30568,38927,38928,38929,38930,38931,38932,38933,38934,38935,38936,38937,38938,38939,38940,38941,38942,38943,38944,38945,38946,38947,38948,38949,38950,38951,38952,38953,38954,38955,38956,38957,38958,38959,38960,38961,38962,38963,38964,38965,38966,38967,38968,38969,38970,38971,38972,38973,38974,38975,38976,38977,38978,38979,38980,38981,38982,38983,38984,38985,38986,38987,38988,38989,38990,38991,38992,38993,38994,38995,38996,38997,38998,38999,39000,39001,39002,39003,39004,39005,39006,39007,39008,39009,39010,39011,39012,39013,39014,39015,39016,39017,39018,39019,39020,39021,39022,30562,30565,30591,30605,30589,30592,30604,30609,30623,30624,30640,30645,30653,30010,30016,30030,30027,30024,30043,30066,30073,30083,32600,32609,32607,35400,32616,32628,32625,32633,32641,32638,30413,30437,34866,38021,38022,38023,38027,38026,38028,38029,38031,38032,38036,38039,38037,38042,38043,38044,38051,38052,38059,38058,38061,38060,38063,38064,38066,38068,38070,38071,38072,38073,38074,38076,38077,38079,38084,38088,38089,38090,38091,38092,38093,38094,38096,38097,38098,38101,38102,38103,38105,38104,38107,38110,38111,38112,38114,38116,38117,38119,38120,38122,39023,39024,39025,39026,39027,39028,39051,39054,39058,39061,39065,39075,39080,39081,39082,39083,39084,39085,39086,39087,39088,39089,39090,39091,39092,39093,39094,39095,39096,39097,39098,39099,39100,39101,39102,39103,39104,39105,39106,39107,39108,39109,39110,39111,39112,39113,39114,39115,39116,39117,39119,39120,39124,39126,39127,39131,39132,39133,39136,39137,39138,39139,39140,39141,39142,39145,39146,39147,39148,39149,39150,39151,39152,39153,39154,39155,39156,39157,39158,39159,39160,39161,39162,39163,39164,39165,39166,39167,39168,39169,39170,39171,39172,39173,39174,39175,38121,38123,38126,38127,38131,38132,38133,38135,38137,38140,38141,38143,38147,38146,38150,38151,38153,38154,38157,38158,38159,38162,38163,38164,38165,38166,38168,38171,38173,38174,38175,38178,38186,38187,38185,38188,38193,38194,38196,38198,38199,38200,38204,38206,38207,38210,38197,38212,38213,38214,38217,38220,38222,38223,38226,38227,38228,38230,38231,38232,38233,38235,38238,38239,38237,38241,38242,38244,38245,38246,38247,38248,38249,38250,38251,38252,38255,38257,38258,38259,38202,30695,30700,38601,31189,31213,31203,31211,31238,23879,31235,31234,31262,31252,39176,39177,39178,39179,39180,39182,39183,39185,39186,39187,39188,39189,39190,39191,39192,39193,39194,39195,39196,39197,39198,39199,39200,39201,39202,39203,39204,39205,39206,39207,39208,39209,39210,39211,39212,39213,39215,39216,39217,39218,39219,39220,39221,39222,39223,39224,39225,39226,39227,39228,39229,39230,39231,39232,39233,39234,39235,39236,39237,39238,39239,39240,39241,39242,39243,39244,39245,39246,39247,39248,39249,39250,39251,39254,39255,39256,39257,39258,39259,39260,39261,39262,39263,39264,39265,39266,39268,39270,39283,39288,39289,39291,39294,39298,39299,39305,31289,31287,31313,40655,39333,31344,30344,30350,30355,30361,30372,29918,29920,29996,40480,40482,40488,40489,40490,40491,40492,40498,40497,40502,40504,40503,40505,40506,40510,40513,40514,40516,40518,40519,40520,40521,40523,40524,40526,40529,40533,40535,40538,40539,40540,40542,40547,40550,40551,40552,40553,40554,40555,40556,40561,40557,40563,30098,30100,30102,30112,30109,30124,30115,30131,30132,30136,30148,30129,30128,30147,30146,30166,30157,30179,30184,30182,30180,30187,30183,30211,30193,30204,30207,30224,30208,30213,30220,30231,30218,30245,30232,30229,30233,39308,39310,39322,39323,39324,39325,39326,39327,39328,39329,39330,39331,39332,39334,39335,39337,39338,39339,39340,39341,39342,39343,39344,39345,39346,39347,39348,39349,39350,39351,39352,39353,39354,39355,39356,39357,39358,39359,39360,39361,39362,39363,39364,39365,39366,39367,39368,39369,39370,39371,39372,39373,39374,39375,39376,39377,39378,39379,39380,39381,39382,39383,39384,39385,39386,39387,39388,39389,39390,39391,39392,39393,39394,39395,39396,39397,39398,39399,39400,39401,39402,39403,39404,39405,39406,39407,39408,39409,39410,39411,39412,39413,39414,39415,39416,39417,30235,30268,30242,30240,30272,30253,30256,30271,30261,30275,30270,30259,30285,30302,30292,30300,30294,30315,30319,32714,31462,31352,31353,31360,31366,31368,31381,31398,31392,31404,31400,31405,31411,34916,34921,34930,34941,34943,34946,34978,35014,34999,35004,35017,35042,35022,35043,35045,35057,35098,35068,35048,35070,35056,35105,35097,35091,35099,35082,35124,35115,35126,35137,35174,35195,30091,32997,30386,30388,30684,32786,32788,32790,32796,32800,32802,32805,32806,32807,32809,32808,32817,32779,32821,32835,32838,32845,32850,32873,32881,35203,39032,39040,39043,39418,39419,39420,39421,39422,39423,39424,39425,39426,39427,39428,39429,39430,39431,39432,39433,39434,39435,39436,39437,39438,39439,39440,39441,39442,39443,39444,39445,39446,39447,39448,39449,39450,39451,39452,39453,39454,39455,39456,39457,39458,39459,39460,39461,39462,39463,39464,39465,39466,39467,39468,39469,39470,39471,39472,39473,39474,39475,39476,39477,39478,39479,39480,39481,39482,39483,39484,39485,39486,39487,39488,39489,39490,39491,39492,39493,39494,39495,39496,39497,39498,39499,39500,39501,39502,39503,39504,39505,39506,39507,39508,39509,39510,39511,39512,39513,39049,39052,39053,39055,39060,39066,39067,39070,39071,39073,39074,39077,39078,34381,34388,34412,34414,34431,34426,34428,34427,34472,34445,34443,34476,34461,34471,34467,34474,34451,34473,34486,34500,34485,34510,34480,34490,34481,34479,34505,34511,34484,34537,34545,34546,34541,34547,34512,34579,34526,34548,34527,34520,34513,34563,34567,34552,34568,34570,34573,34569,34595,34619,34590,34597,34606,34586,34622,34632,34612,34609,34601,34615,34623,34690,34594,34685,34686,34683,34656,34672,34636,34670,34699,34643,34659,34684,34660,34649,34661,34707,34735,34728,34770,39514,39515,39516,39517,39518,39519,39520,39521,39522,39523,39524,39525,39526,39527,39528,39529,39530,39531,39538,39555,39561,39565,39566,39572,39573,39577,39590,39593,39594,39595,39596,39597,39598,39599,39602,39603,39604,39605,39609,39611,39613,39614,39615,39619,39620,39622,39623,39624,39625,39626,39629,39630,39631,39632,39634,39636,39637,39638,39639,39641,39642,39643,39644,39645,39646,39648,39650,39651,39652,39653,39655,39656,39657,39658,39660,39662,39664,39665,39666,39667,39668,39669,39670,39671,39672,39674,39676,39677,39678,39679,39680,39681,39682,39684,39685,39686,34758,34696,34693,34733,34711,34691,34731,34789,34732,34741,34739,34763,34771,34749,34769,34752,34762,34779,34794,34784,34798,34838,34835,34814,34826,34843,34849,34873,34876,32566,32578,32580,32581,33296,31482,31485,31496,31491,31492,31509,31498,31531,31503,31559,31544,31530,31513,31534,31537,31520,31525,31524,31539,31550,31518,31576,31578,31557,31605,31564,31581,31584,31598,31611,31586,31602,31601,31632,31654,31655,31672,31660,31645,31656,31621,31658,31644,31650,31659,31668,31697,31681,31692,31709,31706,31717,31718,31722,31756,31742,31740,31759,31766,31755,39687,39689,39690,39691,39692,39693,39694,39696,39697,39698,39700,39701,39702,39703,39704,39705,39706,39707,39708,39709,39710,39712,39713,39714,39716,39717,39718,39719,39720,39721,39722,39723,39724,39725,39726,39728,39729,39731,39732,39733,39734,39735,39736,39737,39738,39741,39742,39743,39744,39750,39754,39755,39756,39758,39760,39762,39763,39765,39766,39767,39768,39769,39770,39771,39772,39773,39774,39775,39776,39777,39778,39779,39780,39781,39782,39783,39784,39785,39786,39787,39788,39789,39790,39791,39792,39793,39794,39795,39796,39797,39798,39799,39800,39801,39802,39803,31775,31786,31782,31800,31809,31808,33278,33281,33282,33284,33260,34884,33313,33314,33315,33325,33327,33320,33323,33336,33339,33331,33332,33342,33348,33353,33355,33359,33370,33375,33384,34942,34949,34952,35032,35039,35166,32669,32671,32679,32687,32688,32690,31868,25929,31889,31901,31900,31902,31906,31922,31932,31933,31937,31943,31948,31949,31944,31941,31959,31976,33390,26280,32703,32718,32725,32741,32737,32742,32745,32750,32755,31992,32119,32166,32174,32327,32411,40632,40628,36211,36228,36244,36241,36273,36199,36205,35911,35913,37194,37200,37198,37199,37220,39804,39805,39806,39807,39808,39809,39810,39811,39812,39813,39814,39815,39816,39817,39818,39819,39820,39821,39822,39823,39824,39825,39826,39827,39828,39829,39830,39831,39832,39833,39834,39835,39836,39837,39838,39839,39840,39841,39842,39843,39844,39845,39846,39847,39848,39849,39850,39851,39852,39853,39854,39855,39856,39857,39858,39859,39860,39861,39862,39863,39864,39865,39866,39867,39868,39869,39870,39871,39872,39873,39874,39875,39876,39877,39878,39879,39880,39881,39882,39883,39884,39885,39886,39887,39888,39889,39890,39891,39892,39893,39894,39895,39896,39897,39898,39899,37218,37217,37232,37225,37231,37245,37246,37234,37236,37241,37260,37253,37264,37261,37265,37282,37283,37290,37293,37294,37295,37301,37300,37306,35925,40574,36280,36331,36357,36441,36457,36277,36287,36284,36282,36292,36310,36311,36314,36318,36302,36303,36315,36294,36332,36343,36344,36323,36345,36347,36324,36361,36349,36372,36381,36383,36396,36398,36387,36399,36410,36416,36409,36405,36413,36401,36425,36417,36418,36433,36434,36426,36464,36470,36476,36463,36468,36485,36495,36500,36496,36508,36510,35960,35970,35978,35973,35992,35988,26011,35286,35294,35290,35292,39900,39901,39902,39903,39904,39905,39906,39907,39908,39909,39910,39911,39912,39913,39914,39915,39916,39917,39918,39919,39920,39921,39922,39923,39924,39925,39926,39927,39928,39929,39930,39931,39932,39933,39934,39935,39936,39937,39938,39939,39940,39941,39942,39943,39944,39945,39946,39947,39948,39949,39950,39951,39952,39953,39954,39955,39956,39957,39958,39959,39960,39961,39962,39963,39964,39965,39966,39967,39968,39969,39970,39971,39972,39973,39974,39975,39976,39977,39978,39979,39980,39981,39982,39983,39984,39985,39986,39987,39988,39989,39990,39991,39992,39993,39994,39995,35301,35307,35311,35390,35622,38739,38633,38643,38639,38662,38657,38664,38671,38670,38698,38701,38704,38718,40832,40835,40837,40838,40839,40840,40841,40842,40844,40702,40715,40717,38585,38588,38589,38606,38610,30655,38624,37518,37550,37576,37694,37738,37834,37775,37950,37995,40063,40066,40069,40070,40071,40072,31267,40075,40078,40080,40081,40082,40084,40085,40090,40091,40094,40095,40096,40097,40098,40099,40101,40102,40103,40104,40105,40107,40109,40110,40112,40113,40114,40115,40116,40117,40118,40119,40122,40123,40124,40125,40132,40133,40134,40135,40138,40139,39996,39997,39998,39999,40000,40001,40002,40003,40004,40005,40006,40007,40008,40009,40010,40011,40012,40013,40014,40015,40016,40017,40018,40019,40020,40021,40022,40023,40024,40025,40026,40027,40028,40029,40030,40031,40032,40033,40034,40035,40036,40037,40038,40039,40040,40041,40042,40043,40044,40045,40046,40047,40048,40049,40050,40051,40052,40053,40054,40055,40056,40057,40058,40059,40061,40062,40064,40067,40068,40073,40074,40076,40079,40083,40086,40087,40088,40089,40093,40106,40108,40111,40121,40126,40127,40128,40129,40130,40136,40137,40145,40146,40154,40155,40160,40161,40140,40141,40142,40143,40144,40147,40148,40149,40151,40152,40153,40156,40157,40159,40162,38780,38789,38801,38802,38804,38831,38827,38819,38834,38836,39601,39600,39607,40536,39606,39610,39612,39617,39616,39621,39618,39627,39628,39633,39749,39747,39751,39753,39752,39757,39761,39144,39181,39214,39253,39252,39647,39649,39654,39663,39659,39675,39661,39673,39688,39695,39699,39711,39715,40637,40638,32315,40578,40583,40584,40587,40594,37846,40605,40607,40667,40668,40669,40672,40671,40674,40681,40679,40677,40682,40687,40738,40748,40751,40761,40759,40765,40766,40772,40163,40164,40165,40166,40167,40168,40169,40170,40171,40172,40173,40174,40175,40176,40177,40178,40179,40180,40181,40182,40183,40184,40185,40186,40187,40188,40189,40190,40191,40192,40193,40194,40195,40196,40197,40198,40199,40200,40201,40202,40203,40204,40205,40206,40207,40208,40209,40210,40211,40212,40213,40214,40215,40216,40217,40218,40219,40220,40221,40222,40223,40224,40225,40226,40227,40228,40229,40230,40231,40232,40233,40234,40235,40236,40237,40238,40239,40240,40241,40242,40243,40244,40245,40246,40247,40248,40249,40250,40251,40252,40253,40254,40255,40256,40257,40258,57908,57909,57910,57911,57912,57913,57914,57915,57916,57917,57918,57919,57920,57921,57922,57923,57924,57925,57926,57927,57928,57929,57930,57931,57932,57933,57934,57935,57936,57937,57938,57939,57940,57941,57942,57943,57944,57945,57946,57947,57948,57949,57950,57951,57952,57953,57954,57955,57956,57957,57958,57959,57960,57961,57962,57963,57964,57965,57966,57967,57968,57969,57970,57971,57972,57973,57974,57975,57976,57977,57978,57979,57980,57981,57982,57983,57984,57985,57986,57987,57988,57989,57990,57991,57992,57993,57994,57995,57996,57997,57998,57999,58000,58001,40259,40260,40261,40262,40263,40264,40265,40266,40267,40268,40269,40270,40271,40272,40273,40274,40275,40276,40277,40278,40279,40280,40281,40282,40283,40284,40285,40286,40287,40288,40289,40290,40291,40292,40293,40294,40295,40296,40297,40298,40299,40300,40301,40302,40303,40304,40305,40306,40307,40308,40309,40310,40311,40312,40313,40314,40315,40316,40317,40318,40319,40320,40321,40322,40323,40324,40325,40326,40327,40328,40329,40330,40331,40332,40333,40334,40335,40336,40337,40338,40339,40340,40341,40342,40343,40344,40345,40346,40347,40348,40349,40350,40351,40352,40353,40354,58002,58003,58004,58005,58006,58007,58008,58009,58010,58011,58012,58013,58014,58015,58016,58017,58018,58019,58020,58021,58022,58023,58024,58025,58026,58027,58028,58029,58030,58031,58032,58033,58034,58035,58036,58037,58038,58039,58040,58041,58042,58043,58044,58045,58046,58047,58048,58049,58050,58051,58052,58053,58054,58055,58056,58057,58058,58059,58060,58061,58062,58063,58064,58065,58066,58067,58068,58069,58070,58071,58072,58073,58074,58075,58076,58077,58078,58079,58080,58081,58082,58083,58084,58085,58086,58087,58088,58089,58090,58091,58092,58093,58094,58095,40355,40356,40357,40358,40359,40360,40361,40362,40363,40364,40365,40366,40367,40368,40369,40370,40371,40372,40373,40374,40375,40376,40377,40378,40379,40380,40381,40382,40383,40384,40385,40386,40387,40388,40389,40390,40391,40392,40393,40394,40395,40396,40397,40398,40399,40400,40401,40402,40403,40404,40405,40406,40407,40408,40409,40410,40411,40412,40413,40414,40415,40416,40417,40418,40419,40420,40421,40422,40423,40424,40425,40426,40427,40428,40429,40430,40431,40432,40433,40434,40435,40436,40437,40438,40439,40440,40441,40442,40443,40444,40445,40446,40447,40448,40449,40450,58096,58097,58098,58099,58100,58101,58102,58103,58104,58105,58106,58107,58108,58109,58110,58111,58112,58113,58114,58115,58116,58117,58118,58119,58120,58121,58122,58123,58124,58125,58126,58127,58128,58129,58130,58131,58132,58133,58134,58135,58136,58137,58138,58139,58140,58141,58142,58143,58144,58145,58146,58147,58148,58149,58150,58151,58152,58153,58154,58155,58156,58157,58158,58159,58160,58161,58162,58163,58164,58165,58166,58167,58168,58169,58170,58171,58172,58173,58174,58175,58176,58177,58178,58179,58180,58181,58182,58183,58184,58185,58186,58187,58188,58189,40451,40452,40453,40454,40455,40456,40457,40458,40459,40460,40461,40462,40463,40464,40465,40466,40467,40468,40469,40470,40471,40472,40473,40474,40475,40476,40477,40478,40484,40487,40494,40496,40500,40507,40508,40512,40525,40528,40530,40531,40532,40534,40537,40541,40543,40544,40545,40546,40549,40558,40559,40562,40564,40565,40566,40567,40568,40569,40570,40571,40572,40573,40576,40577,40579,40580,40581,40582,40585,40586,40588,40589,40590,40591,40592,40593,40596,40597,40598,40599,40600,40601,40602,40603,40604,40606,40608,40609,40610,40611,40612,40613,40615,40616,40617,40618,58190,58191,58192,58193,58194,58195,58196,58197,58198,58199,58200,58201,58202,58203,58204,58205,58206,58207,58208,58209,58210,58211,58212,58213,58214,58215,58216,58217,58218,58219,58220,58221,58222,58223,58224,58225,58226,58227,58228,58229,58230,58231,58232,58233,58234,58235,58236,58237,58238,58239,58240,58241,58242,58243,58244,58245,58246,58247,58248,58249,58250,58251,58252,58253,58254,58255,58256,58257,58258,58259,58260,58261,58262,58263,58264,58265,58266,58267,58268,58269,58270,58271,58272,58273,58274,58275,58276,58277,58278,58279,58280,58281,58282,58283,40619,40620,40621,40622,40623,40624,40625,40626,40627,40629,40630,40631,40633,40634,40636,40639,40640,40641,40642,40643,40645,40646,40647,40648,40650,40651,40652,40656,40658,40659,40661,40662,40663,40665,40666,40670,40673,40675,40676,40678,40680,40683,40684,40685,40686,40688,40689,40690,40691,40692,40693,40694,40695,40696,40698,40701,40703,40704,40705,40706,40707,40708,40709,40710,40711,40712,40713,40714,40716,40719,40721,40722,40724,40725,40726,40728,40730,40731,40732,40733,40734,40735,40737,40739,40740,40741,40742,40743,40744,40745,40746,40747,40749,40750,40752,40753,58284,58285,58286,58287,58288,58289,58290,58291,58292,58293,58294,58295,58296,58297,58298,58299,58300,58301,58302,58303,58304,58305,58306,58307,58308,58309,58310,58311,58312,58313,58314,58315,58316,58317,58318,58319,58320,58321,58322,58323,58324,58325,58326,58327,58328,58329,58330,58331,58332,58333,58334,58335,58336,58337,58338,58339,58340,58341,58342,58343,58344,58345,58346,58347,58348,58349,58350,58351,58352,58353,58354,58355,58356,58357,58358,58359,58360,58361,58362,58363,58364,58365,58366,58367,58368,58369,58370,58371,58372,58373,58374,58375,58376,58377,40754,40755,40756,40757,40758,40760,40762,40764,40767,40768,40769,40770,40771,40773,40774,40775,40776,40777,40778,40779,40780,40781,40782,40783,40786,40787,40788,40789,40790,40791,40792,40793,40794,40795,40796,40797,40798,40799,40800,40801,40802,40803,40804,40805,40806,40807,40808,40809,40810,40811,40812,40813,40814,40815,40816,40817,40818,40819,40820,40821,40822,40823,40824,40825,40826,40827,40828,40829,40830,40833,40834,40845,40846,40847,40848,40849,40850,40851,40852,40853,40854,40855,40856,40860,40861,40862,40865,40866,40867,40868,40869,63788,63865,63893,63975,63985,58378,58379,58380,58381,58382,58383,58384,58385,58386,58387,58388,58389,58390,58391,58392,58393,58394,58395,58396,58397,58398,58399,58400,58401,58402,58403,58404,58405,58406,58407,58408,58409,58410,58411,58412,58413,58414,58415,58416,58417,58418,58419,58420,58421,58422,58423,58424,58425,58426,58427,58428,58429,58430,58431,58432,58433,58434,58435,58436,58437,58438,58439,58440,58441,58442,58443,58444,58445,58446,58447,58448,58449,58450,58451,58452,58453,58454,58455,58456,58457,58458,58459,58460,58461,58462,58463,58464,58465,58466,58467,58468,58469,58470,58471,64012,64013,64014,64015,64017,64019,64020,64024,64031,64032,64033,64035,64036,64039,64040,64041,11905,59414,59415,59416,11908,13427,13383,11912,11915,59422,13726,13850,13838,11916,11927,14702,14616,59430,14799,14815,14963,14800,59435,59436,15182,15470,15584,11943,59441,59442,11946,16470,16735,11950,17207,11955,11958,11959,59451,17329,17324,11963,17373,17622,18017,17996,59459,18211,18217,18300,18317,11978,18759,18810,18813,18818,18819,18821,18822,18847,18843,18871,18870,59476,59477,19619,19615,19616,19617,19575,19618,19731,19732,19733,19734,19735,19736,19737,19886,59492,58472,58473,58474,58475,58476,58477,58478,58479,58480,58481,58482,58483,58484,58485,58486,58487,58488,58489,58490,58491,58492,58493,58494,58495,58496,58497,58498,58499,58500,58501,58502,58503,58504,58505,58506,58507,58508,58509,58510,58511,58512,58513,58514,58515,58516,58517,58518,58519,58520,58521,58522,58523,58524,58525,58526,58527,58528,58529,58530,58531,58532,58533,58534,58535,58536,58537,58538,58539,58540,58541,58542,58543,58544,58545,58546,58547,58548,58549,58550,58551,58552,58553,58554,58555,58556,58557,58558,58559,58560,58561,58562,58563,58564,58565],
27014 "gb18030-ranges":[[0,128],[36,165],[38,169],[45,178],[50,184],[81,216],[89,226],[95,235],[96,238],[100,244],[103,248],[104,251],[105,253],[109,258],[126,276],[133,284],[148,300],[172,325],[175,329],[179,334],[208,364],[306,463],[307,465],[308,467],[309,469],[310,471],[311,473],[312,475],[313,477],[341,506],[428,594],[443,610],[544,712],[545,716],[558,730],[741,930],[742,938],[749,962],[750,970],[805,1026],[819,1104],[820,1106],[7922,8209],[7924,8215],[7925,8218],[7927,8222],[7934,8231],[7943,8241],[7944,8244],[7945,8246],[7950,8252],[8062,8365],[8148,8452],[8149,8454],[8152,8458],[8164,8471],[8174,8482],[8236,8556],[8240,8570],[8262,8596],[8264,8602],[8374,8713],[8380,8720],[8381,8722],[8384,8726],[8388,8731],[8390,8737],[8392,8740],[8393,8742],[8394,8748],[8396,8751],[8401,8760],[8406,8766],[8416,8777],[8419,8781],[8424,8787],[8437,8802],[8439,8808],[8445,8816],[8482,8854],[8485,8858],[8496,8870],[8521,8896],[8603,8979],[8936,9322],[8946,9372],[9046,9548],[9050,9588],[9063,9616],[9066,9622],[9076,9634],[9092,9652],[9100,9662],[9108,9672],[9111,9676],[9113,9680],[9131,9702],[9162,9735],[9164,9738],[9218,9793],[9219,9795],[11329,11906],[11331,11909],[11334,11913],[11336,11917],[11346,11928],[11361,11944],[11363,11947],[11366,11951],[11370,11956],[11372,11960],[11375,11964],[11389,11979],[11682,12284],[11686,12292],[11687,12312],[11692,12319],[11694,12330],[11714,12351],[11716,12436],[11723,12447],[11725,12535],[11730,12543],[11736,12586],[11982,12842],[11989,12850],[12102,12964],[12336,13200],[12348,13215],[12350,13218],[12384,13253],[12393,13263],[12395,13267],[12397,13270],[12510,13384],[12553,13428],[12851,13727],[12962,13839],[12973,13851],[13738,14617],[13823,14703],[13919,14801],[13933,14816],[14080,14964],[14298,15183],[14585,15471],[14698,15585],[15583,16471],[15847,16736],[16318,17208],[16434,17325],[16438,17330],[16481,17374],[16729,17623],[17102,17997],[17122,18018],[17315,18212],[17320,18218],[17402,18301],[17418,18318],[17859,18760],[17909,18811],[17911,18814],[17915,18820],[17916,18823],[17936,18844],[17939,18848],[17961,18872],[18664,19576],[18703,19620],[18814,19738],[18962,19887],[19043,40870],[33469,59244],[33470,59336],[33471,59367],[33484,59413],[33485,59417],[33490,59423],[33497,59431],[33501,59437],[33505,59443],[33513,59452],[33520,59460],[33536,59478],[33550,59493],[37845,63789],[37921,63866],[37948,63894],[38029,63976],[38038,63986],[38064,64016],[38065,64018],[38066,64021],[38069,64025],[38075,64034],[38076,64037],[38078,64042],[39108,65074],[39109,65093],[39113,65107],[39114,65112],[39115,65127],[39116,65132],[39265,65375],[39394,65510],[189000,65536]],
27015 "jis0208":[12288,12289,12290,65292,65294,12539,65306,65307,65311,65281,12443,12444,180,65344,168,65342,65507,65343,12541,12542,12445,12446,12291,20189,12293,12294,12295,12540,8213,8208,65295,65340,65374,8741,65372,8230,8229,8216,8217,8220,8221,65288,65289,12308,12309,65339,65341,65371,65373,12296,12297,12298,12299,12300,12301,12302,12303,12304,12305,65291,65293,177,215,247,65309,8800,65308,65310,8806,8807,8734,8756,9794,9792,176,8242,8243,8451,65509,65284,65504,65505,65285,65283,65286,65290,65312,167,9734,9733,9675,9679,9678,9671,9670,9633,9632,9651,9650,9661,9660,8251,12306,8594,8592,8593,8595,12307,null,null,null,null,null,null,null,null,null,null,null,8712,8715,8838,8839,8834,8835,8746,8745,null,null,null,null,null,null,null,null,8743,8744,65506,8658,8660,8704,8707,null,null,null,null,null,null,null,null,null,null,null,8736,8869,8978,8706,8711,8801,8786,8810,8811,8730,8765,8733,8757,8747,8748,null,null,null,null,null,null,null,8491,8240,9839,9837,9834,8224,8225,182,null,null,null,null,9711,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,65296,65297,65298,65299,65300,65301,65302,65303,65304,65305,null,null,null,null,null,null,null,65313,65314,65315,65316,65317,65318,65319,65320,65321,65322,65323,65324,65325,65326,65327,65328,65329,65330,65331,65332,65333,65334,65335,65336,65337,65338,null,null,null,null,null,null,65345,65346,65347,65348,65349,65350,65351,65352,65353,65354,65355,65356,65357,65358,65359,65360,65361,65362,65363,65364,65365,65366,65367,65368,65369,65370,null,null,null,null,12353,12354,12355,12356,12357,12358,12359,12360,12361,12362,12363,12364,12365,12366,12367,12368,12369,12370,12371,12372,12373,12374,12375,12376,12377,12378,12379,12380,12381,12382,12383,12384,12385,12386,12387,12388,12389,12390,12391,12392,12393,12394,12395,12396,12397,12398,12399,12400,12401,12402,12403,12404,12405,12406,12407,12408,12409,12410,12411,12412,12413,12414,12415,12416,12417,12418,12419,12420,12421,12422,12423,12424,12425,12426,12427,12428,12429,12430,12431,12432,12433,12434,12435,null,null,null,null,null,null,null,null,null,null,null,12449,12450,12451,12452,12453,12454,12455,12456,12457,12458,12459,12460,12461,12462,12463,12464,12465,12466,12467,12468,12469,12470,12471,12472,12473,12474,12475,12476,12477,12478,12479,12480,12481,12482,12483,12484,12485,12486,12487,12488,12489,12490,12491,12492,12493,12494,12495,12496,12497,12498,12499,12500,12501,12502,12503,12504,12505,12506,12507,12508,12509,12510,12511,12512,12513,12514,12515,12516,12517,12518,12519,12520,12521,12522,12523,12524,12525,12526,12527,12528,12529,12530,12531,12532,12533,12534,null,null,null,null,null,null,null,null,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,931,932,933,934,935,936,937,null,null,null,null,null,null,null,null,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960,961,963,964,965,966,967,968,969,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1040,1041,1042,1043,1044,1045,1025,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1072,1073,1074,1075,1076,1077,1105,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103,null,null,null,null,null,null,null,null,null,null,null,null,null,9472,9474,9484,9488,9496,9492,9500,9516,9508,9524,9532,9473,9475,9487,9491,9499,9495,9507,9523,9515,9531,9547,9504,9519,9512,9527,9535,9501,9520,9509,9528,9538,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,9312,9313,9314,9315,9316,9317,9318,9319,9320,9321,9322,9323,9324,9325,9326,9327,9328,9329,9330,9331,8544,8545,8546,8547,8548,8549,8550,8551,8552,8553,null,13129,13076,13090,13133,13080,13095,13059,13110,13137,13143,13069,13094,13091,13099,13130,13115,13212,13213,13214,13198,13199,13252,13217,null,null,null,null,null,null,null,null,13179,12317,12319,8470,13261,8481,12964,12965,12966,12967,12968,12849,12850,12857,13182,13181,13180,8786,8801,8747,8750,8721,8730,8869,8736,8735,8895,8757,8745,8746,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,20124,21782,23043,38463,21696,24859,25384,23030,36898,33909,33564,31312,24746,25569,28197,26093,33894,33446,39925,26771,22311,26017,25201,23451,22992,34427,39156,32098,32190,39822,25110,31903,34999,23433,24245,25353,26263,26696,38343,38797,26447,20197,20234,20301,20381,20553,22258,22839,22996,23041,23561,24799,24847,24944,26131,26885,28858,30031,30064,31227,32173,32239,32963,33806,34915,35586,36949,36986,21307,20117,20133,22495,32946,37057,30959,19968,22769,28322,36920,31282,33576,33419,39983,20801,21360,21693,21729,22240,23035,24341,39154,28139,32996,34093,38498,38512,38560,38907,21515,21491,23431,28879,32701,36802,38632,21359,40284,31418,19985,30867,33276,28198,22040,21764,27421,34074,39995,23013,21417,28006,29916,38287,22082,20113,36939,38642,33615,39180,21473,21942,23344,24433,26144,26355,26628,27704,27891,27945,29787,30408,31310,38964,33521,34907,35424,37613,28082,30123,30410,39365,24742,35585,36234,38322,27022,21421,20870,22290,22576,22852,23476,24310,24616,25513,25588,27839,28436,28814,28948,29017,29141,29503,32257,33398,33489,34199,36960,37467,40219,22633,26044,27738,29989,20985,22830,22885,24448,24540,25276,26106,27178,27431,27572,29579,32705,35158,40236,40206,40644,23713,27798,33659,20740,23627,25014,33222,26742,29281,20057,20474,21368,24681,28201,31311,38899,19979,21270,20206,20309,20285,20385,20339,21152,21487,22025,22799,23233,23478,23521,31185,26247,26524,26550,27468,27827,28779,29634,31117,31166,31292,31623,33457,33499,33540,33655,33775,33747,34662,35506,22057,36008,36838,36942,38686,34442,20420,23784,25105,29273,30011,33253,33469,34558,36032,38597,39187,39381,20171,20250,35299,22238,22602,22730,24315,24555,24618,24724,24674,25040,25106,25296,25913,39745,26214,26800,28023,28784,30028,30342,32117,33445,34809,38283,38542,35997,20977,21182,22806,21683,23475,23830,24936,27010,28079,30861,33995,34903,35442,37799,39608,28012,39336,34521,22435,26623,34510,37390,21123,22151,21508,24275,25313,25785,26684,26680,27579,29554,30906,31339,35226,35282,36203,36611,37101,38307,38548,38761,23398,23731,27005,38989,38990,25499,31520,27179,27263,26806,39949,28511,21106,21917,24688,25324,27963,28167,28369,33883,35088,36676,19988,39993,21494,26907,27194,38788,26666,20828,31427,33970,37340,37772,22107,40232,26658,33541,33841,31909,21000,33477,29926,20094,20355,20896,23506,21002,21208,21223,24059,21914,22570,23014,23436,23448,23515,24178,24185,24739,24863,24931,25022,25563,25954,26577,26707,26874,27454,27475,27735,28450,28567,28485,29872,29976,30435,30475,31487,31649,31777,32233,32566,32752,32925,33382,33694,35251,35532,36011,36996,37969,38291,38289,38306,38501,38867,39208,33304,20024,21547,23736,24012,29609,30284,30524,23721,32747,36107,38593,38929,38996,39000,20225,20238,21361,21916,22120,22522,22855,23305,23492,23696,24076,24190,24524,25582,26426,26071,26082,26399,26827,26820,27231,24112,27589,27671,27773,30079,31048,23395,31232,32000,24509,35215,35352,36020,36215,36556,36637,39138,39438,39740,20096,20605,20736,22931,23452,25135,25216,25836,27450,29344,30097,31047,32681,34811,35516,35696,25516,33738,38816,21513,21507,21931,26708,27224,35440,30759,26485,40653,21364,23458,33050,34384,36870,19992,20037,20167,20241,21450,21560,23470,24339,24613,25937,26429,27714,27762,27875,28792,29699,31350,31406,31496,32026,31998,32102,26087,29275,21435,23621,24040,25298,25312,25369,28192,34394,35377,36317,37624,28417,31142,39770,20136,20139,20140,20379,20384,20689,20807,31478,20849,20982,21332,21281,21375,21483,21932,22659,23777,24375,24394,24623,24656,24685,25375,25945,27211,27841,29378,29421,30703,33016,33029,33288,34126,37111,37857,38911,39255,39514,20208,20957,23597,26241,26989,23616,26354,26997,29577,26704,31873,20677,21220,22343,24062,37670,26020,27427,27453,29748,31105,31165,31563,32202,33465,33740,34943,35167,35641,36817,37329,21535,37504,20061,20534,21477,21306,29399,29590,30697,33510,36527,39366,39368,39378,20855,24858,34398,21936,31354,20598,23507,36935,38533,20018,27355,37351,23633,23624,25496,31391,27795,38772,36705,31402,29066,38536,31874,26647,32368,26705,37740,21234,21531,34219,35347,32676,36557,37089,21350,34952,31041,20418,20670,21009,20804,21843,22317,29674,22411,22865,24418,24452,24693,24950,24935,25001,25522,25658,25964,26223,26690,28179,30054,31293,31995,32076,32153,32331,32619,33550,33610,34509,35336,35427,35686,36605,38938,40335,33464,36814,39912,21127,25119,25731,28608,38553,26689,20625,27424,27770,28500,31348,32080,34880,35363,26376,20214,20537,20518,20581,20860,21048,21091,21927,22287,22533,23244,24314,25010,25080,25331,25458,26908,27177,29309,29356,29486,30740,30831,32121,30476,32937,35211,35609,36066,36562,36963,37749,38522,38997,39443,40568,20803,21407,21427,24187,24358,28187,28304,29572,29694,32067,33335,35328,35578,38480,20046,20491,21476,21628,22266,22993,23396,24049,24235,24359,25144,25925,26543,28246,29392,31946,34996,32929,32993,33776,34382,35463,36328,37431,38599,39015,40723,20116,20114,20237,21320,21577,21566,23087,24460,24481,24735,26791,27278,29786,30849,35486,35492,35703,37264,20062,39881,20132,20348,20399,20505,20502,20809,20844,21151,21177,21246,21402,21475,21521,21518,21897,22353,22434,22909,23380,23389,23439,24037,24039,24055,24184,24195,24218,24247,24344,24658,24908,25239,25304,25511,25915,26114,26179,26356,26477,26657,26775,27083,27743,27946,28009,28207,28317,30002,30343,30828,31295,31968,32005,32024,32094,32177,32789,32771,32943,32945,33108,33167,33322,33618,34892,34913,35611,36002,36092,37066,37237,37489,30783,37628,38308,38477,38917,39321,39640,40251,21083,21163,21495,21512,22741,25335,28640,35946,36703,40633,20811,21051,21578,22269,31296,37239,40288,40658,29508,28425,33136,29969,24573,24794,39592,29403,36796,27492,38915,20170,22256,22372,22718,23130,24680,25031,26127,26118,26681,26801,28151,30165,32058,33390,39746,20123,20304,21449,21766,23919,24038,24046,26619,27801,29811,30722,35408,37782,35039,22352,24231,25387,20661,20652,20877,26368,21705,22622,22971,23472,24425,25165,25505,26685,27507,28168,28797,37319,29312,30741,30758,31085,25998,32048,33756,35009,36617,38555,21092,22312,26448,32618,36001,20916,22338,38442,22586,27018,32948,21682,23822,22524,30869,40442,20316,21066,21643,25662,26152,26388,26613,31364,31574,32034,37679,26716,39853,31545,21273,20874,21047,23519,25334,25774,25830,26413,27578,34217,38609,30352,39894,25420,37638,39851,30399,26194,19977,20632,21442,23665,24808,25746,25955,26719,29158,29642,29987,31639,32386,34453,35715,36059,37240,39184,26028,26283,27531,20181,20180,20282,20351,21050,21496,21490,21987,22235,22763,22987,22985,23039,23376,23629,24066,24107,24535,24605,25351,25903,23388,26031,26045,26088,26525,27490,27515,27663,29509,31049,31169,31992,32025,32043,32930,33026,33267,35222,35422,35433,35430,35468,35566,36039,36060,38604,39164,27503,20107,20284,20365,20816,23383,23546,24904,25345,26178,27425,28363,27835,29246,29885,30164,30913,31034,32780,32819,33258,33940,36766,27728,40575,24335,35672,40235,31482,36600,23437,38635,19971,21489,22519,22833,23241,23460,24713,28287,28422,30142,36074,23455,34048,31712,20594,26612,33437,23649,34122,32286,33294,20889,23556,25448,36198,26012,29038,31038,32023,32773,35613,36554,36974,34503,37034,20511,21242,23610,26451,28796,29237,37196,37320,37675,33509,23490,24369,24825,20027,21462,23432,25163,26417,27530,29417,29664,31278,33131,36259,37202,39318,20754,21463,21610,23551,25480,27193,32172,38656,22234,21454,21608,23447,23601,24030,20462,24833,25342,27954,31168,31179,32066,32333,32722,33261,33311,33936,34886,35186,35728,36468,36655,36913,37195,37228,38598,37276,20160,20303,20805,21313,24467,25102,26580,27713,28171,29539,32294,37325,37507,21460,22809,23487,28113,31069,32302,31899,22654,29087,20986,34899,36848,20426,23803,26149,30636,31459,33308,39423,20934,24490,26092,26991,27529,28147,28310,28516,30462,32020,24033,36981,37255,38918,20966,21021,25152,26257,26329,28186,24246,32210,32626,26360,34223,34295,35576,21161,21465,22899,24207,24464,24661,37604,38500,20663,20767,21213,21280,21319,21484,21736,21830,21809,22039,22888,22974,23100,23477,23558,23567,23569,23578,24196,24202,24288,24432,25215,25220,25307,25484,25463,26119,26124,26157,26230,26494,26786,27167,27189,27836,28040,28169,28248,28988,28966,29031,30151,30465,30813,30977,31077,31216,31456,31505,31911,32057,32918,33750,33931,34121,34909,35059,35359,35388,35412,35443,35937,36062,37284,37478,37758,37912,38556,38808,19978,19976,19998,20055,20887,21104,22478,22580,22732,23330,24120,24773,25854,26465,26454,27972,29366,30067,31331,33976,35698,37304,37664,22065,22516,39166,25325,26893,27542,29165,32340,32887,33394,35302,39135,34645,36785,23611,20280,20449,20405,21767,23072,23517,23529,24515,24910,25391,26032,26187,26862,27035,28024,28145,30003,30137,30495,31070,31206,32051,33251,33455,34218,35242,35386,36523,36763,36914,37341,38663,20154,20161,20995,22645,22764,23563,29978,23613,33102,35338,36805,38499,38765,31525,35535,38920,37218,22259,21416,36887,21561,22402,24101,25512,27700,28810,30561,31883,32736,34928,36930,37204,37648,37656,38543,29790,39620,23815,23913,25968,26530,36264,38619,25454,26441,26905,33733,38935,38592,35070,28548,25722,23544,19990,28716,30045,26159,20932,21046,21218,22995,24449,24615,25104,25919,25972,26143,26228,26866,26646,27491,28165,29298,29983,30427,31934,32854,22768,35069,35199,35488,35475,35531,36893,37266,38738,38745,25993,31246,33030,38587,24109,24796,25114,26021,26132,26512,30707,31309,31821,32318,33034,36012,36196,36321,36447,30889,20999,25305,25509,25666,25240,35373,31363,31680,35500,38634,32118,33292,34633,20185,20808,21315,21344,23459,23554,23574,24029,25126,25159,25776,26643,26676,27849,27973,27927,26579,28508,29006,29053,26059,31359,31661,32218,32330,32680,33146,33307,33337,34214,35438,36046,36341,36984,36983,37549,37521,38275,39854,21069,21892,28472,28982,20840,31109,32341,33203,31950,22092,22609,23720,25514,26366,26365,26970,29401,30095,30094,30990,31062,31199,31895,32032,32068,34311,35380,38459,36961,40736,20711,21109,21452,21474,20489,21930,22766,22863,29245,23435,23652,21277,24803,24819,25436,25475,25407,25531,25805,26089,26361,24035,27085,27133,28437,29157,20105,30185,30456,31379,31967,32207,32156,32865,33609,33624,33900,33980,34299,35013,36208,36865,36973,37783,38684,39442,20687,22679,24974,33235,34101,36104,36896,20419,20596,21063,21363,24687,25417,26463,28204,36275,36895,20439,23646,36042,26063,32154,21330,34966,20854,25539,23384,23403,23562,25613,26449,36956,20182,22810,22826,27760,35409,21822,22549,22949,24816,25171,26561,33333,26965,38464,39364,39464,20307,22534,23550,32784,23729,24111,24453,24608,24907,25140,26367,27888,28382,32974,33151,33492,34955,36024,36864,36910,38538,40667,39899,20195,21488,22823,31532,37261,38988,40441,28381,28711,21331,21828,23429,25176,25246,25299,27810,28655,29730,35351,37944,28609,35582,33592,20967,34552,21482,21481,20294,36948,36784,22890,33073,24061,31466,36799,26842,35895,29432,40008,27197,35504,20025,21336,22022,22374,25285,25506,26086,27470,28129,28251,28845,30701,31471,31658,32187,32829,32966,34507,35477,37723,22243,22727,24382,26029,26262,27264,27573,30007,35527,20516,30693,22320,24347,24677,26234,27744,30196,31258,32622,33268,34584,36933,39347,31689,30044,31481,31569,33988,36880,31209,31378,33590,23265,30528,20013,20210,23449,24544,25277,26172,26609,27880,34411,34935,35387,37198,37619,39376,27159,28710,29482,33511,33879,36015,19969,20806,20939,21899,23541,24086,24115,24193,24340,24373,24427,24500,25074,25361,26274,26397,28526,29266,30010,30522,32884,33081,33144,34678,35519,35548,36229,36339,37530,38263,38914,40165,21189,25431,30452,26389,27784,29645,36035,37806,38515,27941,22684,26894,27084,36861,37786,30171,36890,22618,26626,25524,27131,20291,28460,26584,36795,34086,32180,37716,26943,28528,22378,22775,23340,32044,29226,21514,37347,40372,20141,20302,20572,20597,21059,35998,21576,22564,23450,24093,24213,24237,24311,24351,24716,25269,25402,25552,26799,27712,30855,31118,31243,32224,33351,35330,35558,36420,36883,37048,37165,37336,40718,27877,25688,25826,25973,28404,30340,31515,36969,37841,28346,21746,24505,25764,36685,36845,37444,20856,22635,22825,23637,24215,28155,32399,29980,36028,36578,39003,28857,20253,27583,28593,30000,38651,20814,21520,22581,22615,22956,23648,24466,26007,26460,28193,30331,33759,36077,36884,37117,37709,30757,30778,21162,24230,22303,22900,24594,20498,20826,20908,20941,20992,21776,22612,22616,22871,23445,23798,23947,24764,25237,25645,26481,26691,26812,26847,30423,28120,28271,28059,28783,29128,24403,30168,31095,31561,31572,31570,31958,32113,21040,33891,34153,34276,35342,35588,35910,36367,36867,36879,37913,38518,38957,39472,38360,20685,21205,21516,22530,23566,24999,25758,27934,30643,31461,33012,33796,36947,37509,23776,40199,21311,24471,24499,28060,29305,30563,31167,31716,27602,29420,35501,26627,27233,20984,31361,26932,23626,40182,33515,23493,37193,28702,22136,23663,24775,25958,27788,35930,36929,38931,21585,26311,37389,22856,37027,20869,20045,20970,34201,35598,28760,25466,37707,26978,39348,32260,30071,21335,26976,36575,38627,27741,20108,23612,24336,36841,21250,36049,32905,34425,24319,26085,20083,20837,22914,23615,38894,20219,22922,24525,35469,28641,31152,31074,23527,33905,29483,29105,24180,24565,25467,25754,29123,31896,20035,24316,20043,22492,22178,24745,28611,32013,33021,33075,33215,36786,35223,34468,24052,25226,25773,35207,26487,27874,27966,29750,30772,23110,32629,33453,39340,20467,24259,25309,25490,25943,26479,30403,29260,32972,32954,36649,37197,20493,22521,23186,26757,26995,29028,29437,36023,22770,36064,38506,36889,34687,31204,30695,33833,20271,21093,21338,25293,26575,27850,30333,31636,31893,33334,34180,36843,26333,28448,29190,32283,33707,39361,40614,20989,31665,30834,31672,32903,31560,27368,24161,32908,30033,30048,20843,37474,28300,30330,37271,39658,20240,32624,25244,31567,38309,40169,22138,22617,34532,38588,20276,21028,21322,21453,21467,24070,25644,26001,26495,27710,27726,29256,29359,29677,30036,32321,33324,34281,36009,31684,37318,29033,38930,39151,25405,26217,30058,30436,30928,34115,34542,21290,21329,21542,22915,24199,24444,24754,25161,25209,25259,26000,27604,27852,30130,30382,30865,31192,32203,32631,32933,34987,35513,36027,36991,38750,39131,27147,31800,20633,23614,24494,26503,27608,29749,30473,32654,40763,26570,31255,21305,30091,39661,24422,33181,33777,32920,24380,24517,30050,31558,36924,26727,23019,23195,32016,30334,35628,20469,24426,27161,27703,28418,29922,31080,34920,35413,35961,24287,25551,30149,31186,33495,37672,37618,33948,34541,39981,21697,24428,25996,27996,28693,36007,36051,38971,25935,29942,19981,20184,22496,22827,23142,23500,20904,24067,24220,24598,25206,25975,26023,26222,28014,29238,31526,33104,33178,33433,35676,36000,36070,36212,38428,38468,20398,25771,27494,33310,33889,34154,37096,23553,26963,39080,33914,34135,20239,21103,24489,24133,26381,31119,33145,35079,35206,28149,24343,25173,27832,20175,29289,39826,20998,21563,22132,22707,24996,25198,28954,22894,31881,31966,32027,38640,25991,32862,19993,20341,20853,22592,24163,24179,24330,26564,20006,34109,38281,38491,31859,38913,20731,22721,30294,30887,21029,30629,34065,31622,20559,22793,29255,31687,32232,36794,36820,36941,20415,21193,23081,24321,38829,20445,33303,37610,22275,25429,27497,29995,35036,36628,31298,21215,22675,24917,25098,26286,27597,31807,33769,20515,20472,21253,21574,22577,22857,23453,23792,23791,23849,24214,25265,25447,25918,26041,26379,27861,27873,28921,30770,32299,32990,33459,33804,34028,34562,35090,35370,35914,37030,37586,39165,40179,40300,20047,20129,20621,21078,22346,22952,24125,24536,24537,25151,26292,26395,26576,26834,20882,32033,32938,33192,35584,35980,36031,37502,38450,21536,38956,21271,20693,21340,22696,25778,26420,29287,30566,31302,37350,21187,27809,27526,22528,24140,22868,26412,32763,20961,30406,25705,30952,39764,40635,22475,22969,26151,26522,27598,21737,27097,24149,33180,26517,39850,26622,40018,26717,20134,20451,21448,25273,26411,27819,36804,20397,32365,40639,19975,24930,28288,28459,34067,21619,26410,39749,24051,31637,23724,23494,34588,28234,34001,31252,33032,22937,31885,27665,30496,21209,22818,28961,29279,30683,38695,40289,26891,23167,23064,20901,21517,21629,26126,30431,36855,37528,40180,23018,29277,28357,20813,26825,32191,32236,38754,40634,25720,27169,33538,22916,23391,27611,29467,30450,32178,32791,33945,20786,26408,40665,30446,26466,21247,39173,23588,25147,31870,36016,21839,24758,32011,38272,21249,20063,20918,22812,29242,32822,37326,24357,30690,21380,24441,32004,34220,35379,36493,38742,26611,34222,37971,24841,24840,27833,30290,35565,36664,21807,20305,20778,21191,21451,23461,24189,24736,24962,25558,26377,26586,28263,28044,29494,29495,30001,31056,35029,35480,36938,37009,37109,38596,34701,22805,20104,20313,19982,35465,36671,38928,20653,24188,22934,23481,24248,25562,25594,25793,26332,26954,27096,27915,28342,29076,29992,31407,32650,32768,33865,33993,35201,35617,36362,36965,38525,39178,24958,25233,27442,27779,28020,32716,32764,28096,32645,34746,35064,26469,33713,38972,38647,27931,32097,33853,37226,20081,21365,23888,27396,28651,34253,34349,35239,21033,21519,23653,26446,26792,29702,29827,30178,35023,35041,37324,38626,38520,24459,29575,31435,33870,25504,30053,21129,27969,28316,29705,30041,30827,31890,38534,31452,40845,20406,24942,26053,34396,20102,20142,20698,20001,20940,23534,26009,26753,28092,29471,30274,30637,31260,31975,33391,35538,36988,37327,38517,38936,21147,32209,20523,21400,26519,28107,29136,29747,33256,36650,38563,40023,40607,29792,22593,28057,32047,39006,20196,20278,20363,20919,21169,23994,24604,29618,31036,33491,37428,38583,38646,38666,40599,40802,26278,27508,21015,21155,28872,35010,24265,24651,24976,28451,29001,31806,32244,32879,34030,36899,37676,21570,39791,27347,28809,36034,36335,38706,21172,23105,24266,24324,26391,27004,27028,28010,28431,29282,29436,31725,32769,32894,34635,37070,20845,40595,31108,32907,37682,35542,20525,21644,35441,27498,36036,33031,24785,26528,40434,20121,20120,39952,35435,34241,34152,26880,28286,30871,33109,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,24332,19984,19989,20010,20017,20022,20028,20031,20034,20054,20056,20098,20101,35947,20106,33298,24333,20110,20126,20127,20128,20130,20144,20147,20150,20174,20173,20164,20166,20162,20183,20190,20205,20191,20215,20233,20314,20272,20315,20317,20311,20295,20342,20360,20367,20376,20347,20329,20336,20369,20335,20358,20374,20760,20436,20447,20430,20440,20443,20433,20442,20432,20452,20453,20506,20520,20500,20522,20517,20485,20252,20470,20513,20521,20524,20478,20463,20497,20486,20547,20551,26371,20565,20560,20552,20570,20566,20588,20600,20608,20634,20613,20660,20658,20681,20682,20659,20674,20694,20702,20709,20717,20707,20718,20729,20725,20745,20737,20738,20758,20757,20756,20762,20769,20794,20791,20796,20795,20799,20800,20818,20812,20820,20834,31480,20841,20842,20846,20864,20866,22232,20876,20873,20879,20881,20883,20885,20886,20900,20902,20898,20905,20906,20907,20915,20913,20914,20912,20917,20925,20933,20937,20955,20960,34389,20969,20973,20976,20981,20990,20996,21003,21012,21006,21031,21034,21038,21043,21049,21071,21060,21067,21068,21086,21076,21098,21108,21097,21107,21119,21117,21133,21140,21138,21105,21128,21137,36776,36775,21164,21165,21180,21173,21185,21197,21207,21214,21219,21222,39149,21216,21235,21237,21240,21241,21254,21256,30008,21261,21264,21263,21269,21274,21283,21295,21297,21299,21304,21312,21318,21317,19991,21321,21325,20950,21342,21353,21358,22808,21371,21367,21378,21398,21408,21414,21413,21422,21424,21430,21443,31762,38617,21471,26364,29166,21486,21480,21485,21498,21505,21565,21568,21548,21549,21564,21550,21558,21545,21533,21582,21647,21621,21646,21599,21617,21623,21616,21650,21627,21632,21622,21636,21648,21638,21703,21666,21688,21669,21676,21700,21704,21672,21675,21698,21668,21694,21692,21720,21733,21734,21775,21780,21757,21742,21741,21754,21730,21817,21824,21859,21836,21806,21852,21829,21846,21847,21816,21811,21853,21913,21888,21679,21898,21919,21883,21886,21912,21918,21934,21884,21891,21929,21895,21928,21978,21957,21983,21956,21980,21988,21972,22036,22007,22038,22014,22013,22043,22009,22094,22096,29151,22068,22070,22066,22072,22123,22116,22063,22124,22122,22150,22144,22154,22176,22164,22159,22181,22190,22198,22196,22210,22204,22209,22211,22208,22216,22222,22225,22227,22231,22254,22265,22272,22271,22276,22281,22280,22283,22285,22291,22296,22294,21959,22300,22310,22327,22328,22350,22331,22336,22351,22377,22464,22408,22369,22399,22409,22419,22432,22451,22436,22442,22448,22467,22470,22484,22482,22483,22538,22486,22499,22539,22553,22557,22642,22561,22626,22603,22640,27584,22610,22589,22649,22661,22713,22687,22699,22714,22750,22715,22712,22702,22725,22739,22737,22743,22745,22744,22757,22748,22756,22751,22767,22778,22777,22779,22780,22781,22786,22794,22800,22811,26790,22821,22828,22829,22834,22840,22846,31442,22869,22864,22862,22874,22872,22882,22880,22887,22892,22889,22904,22913,22941,20318,20395,22947,22962,22982,23016,23004,22925,23001,23002,23077,23071,23057,23068,23049,23066,23104,23148,23113,23093,23094,23138,23146,23194,23228,23230,23243,23234,23229,23267,23255,23270,23273,23254,23290,23291,23308,23307,23318,23346,23248,23338,23350,23358,23363,23365,23360,23377,23381,23386,23387,23397,23401,23408,23411,23413,23416,25992,23418,23424,23427,23462,23480,23491,23495,23497,23508,23504,23524,23526,23522,23518,23525,23531,23536,23542,23539,23557,23559,23560,23565,23571,23584,23586,23592,23608,23609,23617,23622,23630,23635,23632,23631,23409,23660,23662,20066,23670,23673,23692,23697,23700,22939,23723,23739,23734,23740,23735,23749,23742,23751,23769,23785,23805,23802,23789,23948,23786,23819,23829,23831,23900,23839,23835,23825,23828,23842,23834,23833,23832,23884,23890,23886,23883,23916,23923,23926,23943,23940,23938,23970,23965,23980,23982,23997,23952,23991,23996,24009,24013,24019,24018,24022,24027,24043,24050,24053,24075,24090,24089,24081,24091,24118,24119,24132,24131,24128,24142,24151,24148,24159,24162,24164,24135,24181,24182,24186,40636,24191,24224,24257,24258,24264,24272,24271,24278,24291,24285,24282,24283,24290,24289,24296,24297,24300,24305,24307,24304,24308,24312,24318,24323,24329,24413,24412,24331,24337,24342,24361,24365,24376,24385,24392,24396,24398,24367,24401,24406,24407,24409,24417,24429,24435,24439,24451,24450,24447,24458,24456,24465,24455,24478,24473,24472,24480,24488,24493,24508,24534,24571,24548,24568,24561,24541,24755,24575,24609,24672,24601,24592,24617,24590,24625,24603,24597,24619,24614,24591,24634,24666,24641,24682,24695,24671,24650,24646,24653,24675,24643,24676,24642,24684,24683,24665,24705,24717,24807,24707,24730,24708,24731,24726,24727,24722,24743,24715,24801,24760,24800,24787,24756,24560,24765,24774,24757,24792,24909,24853,24838,24822,24823,24832,24820,24826,24835,24865,24827,24817,24845,24846,24903,24894,24872,24871,24906,24895,24892,24876,24884,24893,24898,24900,24947,24951,24920,24921,24922,24939,24948,24943,24933,24945,24927,24925,24915,24949,24985,24982,24967,25004,24980,24986,24970,24977,25003,25006,25036,25034,25033,25079,25032,25027,25030,25018,25035,32633,25037,25062,25059,25078,25082,25076,25087,25085,25084,25086,25088,25096,25097,25101,25100,25108,25115,25118,25121,25130,25134,25136,25138,25139,25153,25166,25182,25187,25179,25184,25192,25212,25218,25225,25214,25234,25235,25238,25300,25219,25236,25303,25297,25275,25295,25343,25286,25812,25288,25308,25292,25290,25282,25287,25243,25289,25356,25326,25329,25383,25346,25352,25327,25333,25424,25406,25421,25628,25423,25494,25486,25472,25515,25462,25507,25487,25481,25503,25525,25451,25449,25534,25577,25536,25542,25571,25545,25554,25590,25540,25622,25652,25606,25619,25638,25654,25885,25623,25640,25615,25703,25711,25718,25678,25898,25749,25747,25765,25769,25736,25788,25818,25810,25797,25799,25787,25816,25794,25841,25831,33289,25824,25825,25260,25827,25839,25900,25846,25844,25842,25850,25856,25853,25880,25884,25861,25892,25891,25899,25908,25909,25911,25910,25912,30027,25928,25942,25941,25933,25944,25950,25949,25970,25976,25986,25987,35722,26011,26015,26027,26039,26051,26054,26049,26052,26060,26066,26075,26073,26080,26081,26097,26482,26122,26115,26107,26483,26165,26166,26164,26140,26191,26180,26185,26177,26206,26205,26212,26215,26216,26207,26210,26224,26243,26248,26254,26249,26244,26264,26269,26305,26297,26313,26302,26300,26308,26296,26326,26330,26336,26175,26342,26345,26352,26357,26359,26383,26390,26398,26406,26407,38712,26414,26431,26422,26433,26424,26423,26438,26462,26464,26457,26467,26468,26505,26480,26537,26492,26474,26508,26507,26534,26529,26501,26551,26607,26548,26604,26547,26601,26552,26596,26590,26589,26594,26606,26553,26574,26566,26599,27292,26654,26694,26665,26688,26701,26674,26702,26803,26667,26713,26723,26743,26751,26783,26767,26797,26772,26781,26779,26755,27310,26809,26740,26805,26784,26810,26895,26765,26750,26881,26826,26888,26840,26914,26918,26849,26892,26829,26836,26855,26837,26934,26898,26884,26839,26851,26917,26873,26848,26863,26920,26922,26906,26915,26913,26822,27001,26999,26972,27000,26987,26964,27006,26990,26937,26996,26941,26969,26928,26977,26974,26973,27009,26986,27058,27054,27088,27071,27073,27091,27070,27086,23528,27082,27101,27067,27075,27047,27182,27025,27040,27036,27029,27060,27102,27112,27138,27163,27135,27402,27129,27122,27111,27141,27057,27166,27117,27156,27115,27146,27154,27329,27171,27155,27204,27148,27250,27190,27256,27207,27234,27225,27238,27208,27192,27170,27280,27277,27296,27268,27298,27299,27287,34327,27323,27331,27330,27320,27315,27308,27358,27345,27359,27306,27354,27370,27387,27397,34326,27386,27410,27414,39729,27423,27448,27447,30428,27449,39150,27463,27459,27465,27472,27481,27476,27483,27487,27489,27512,27513,27519,27520,27524,27523,27533,27544,27541,27550,27556,27562,27563,27567,27570,27569,27571,27575,27580,27590,27595,27603,27615,27628,27627,27635,27631,40638,27656,27667,27668,27675,27684,27683,27742,27733,27746,27754,27778,27789,27802,27777,27803,27774,27752,27763,27794,27792,27844,27889,27859,27837,27863,27845,27869,27822,27825,27838,27834,27867,27887,27865,27882,27935,34893,27958,27947,27965,27960,27929,27957,27955,27922,27916,28003,28051,28004,27994,28025,27993,28046,28053,28644,28037,28153,28181,28170,28085,28103,28134,28088,28102,28140,28126,28108,28136,28114,28101,28154,28121,28132,28117,28138,28142,28205,28270,28206,28185,28274,28255,28222,28195,28267,28203,28278,28237,28191,28227,28218,28238,28196,28415,28189,28216,28290,28330,28312,28361,28343,28371,28349,28335,28356,28338,28372,28373,28303,28325,28354,28319,28481,28433,28748,28396,28408,28414,28479,28402,28465,28399,28466,28364,28478,28435,28407,28550,28538,28536,28545,28544,28527,28507,28659,28525,28546,28540,28504,28558,28561,28610,28518,28595,28579,28577,28580,28601,28614,28586,28639,28629,28652,28628,28632,28657,28654,28635,28681,28683,28666,28689,28673,28687,28670,28699,28698,28532,28701,28696,28703,28720,28734,28722,28753,28771,28825,28818,28847,28913,28844,28856,28851,28846,28895,28875,28893,28889,28937,28925,28956,28953,29029,29013,29064,29030,29026,29004,29014,29036,29071,29179,29060,29077,29096,29100,29143,29113,29118,29138,29129,29140,29134,29152,29164,29159,29173,29180,29177,29183,29197,29200,29211,29224,29229,29228,29232,29234,29243,29244,29247,29248,29254,29259,29272,29300,29310,29314,29313,29319,29330,29334,29346,29351,29369,29362,29379,29382,29380,29390,29394,29410,29408,29409,29433,29431,20495,29463,29450,29468,29462,29469,29492,29487,29481,29477,29502,29518,29519,40664,29527,29546,29544,29552,29560,29557,29563,29562,29640,29619,29646,29627,29632,29669,29678,29662,29858,29701,29807,29733,29688,29746,29754,29781,29759,29791,29785,29761,29788,29801,29808,29795,29802,29814,29822,29835,29854,29863,29898,29903,29908,29681,29920,29923,29927,29929,29934,29938,29936,29937,29944,29943,29956,29955,29957,29964,29966,29965,29973,29971,29982,29990,29996,30012,30020,30029,30026,30025,30043,30022,30042,30057,30052,30055,30059,30061,30072,30070,30086,30087,30068,30090,30089,30082,30100,30106,30109,30117,30115,30146,30131,30147,30133,30141,30136,30140,30129,30157,30154,30162,30169,30179,30174,30206,30207,30204,30209,30192,30202,30194,30195,30219,30221,30217,30239,30247,30240,30241,30242,30244,30260,30256,30267,30279,30280,30278,30300,30296,30305,30306,30312,30313,30314,30311,30316,30320,30322,30326,30328,30332,30336,30339,30344,30347,30350,30358,30355,30361,30362,30384,30388,30392,30393,30394,30402,30413,30422,30418,30430,30433,30437,30439,30442,34351,30459,30472,30471,30468,30505,30500,30494,30501,30502,30491,30519,30520,30535,30554,30568,30571,30555,30565,30591,30590,30585,30606,30603,30609,30624,30622,30640,30646,30649,30655,30652,30653,30651,30663,30669,30679,30682,30684,30691,30702,30716,30732,30738,31014,30752,31018,30789,30862,30836,30854,30844,30874,30860,30883,30901,30890,30895,30929,30918,30923,30932,30910,30908,30917,30922,30956,30951,30938,30973,30964,30983,30994,30993,31001,31020,31019,31040,31072,31063,31071,31066,31061,31059,31098,31103,31114,31133,31143,40779,31146,31150,31155,31161,31162,31177,31189,31207,31212,31201,31203,31240,31245,31256,31257,31264,31263,31104,31281,31291,31294,31287,31299,31319,31305,31329,31330,31337,40861,31344,31353,31357,31368,31383,31381,31384,31382,31401,31432,31408,31414,31429,31428,31423,36995,31431,31434,31437,31439,31445,31443,31449,31450,31453,31457,31458,31462,31469,31472,31490,31503,31498,31494,31539,31512,31513,31518,31541,31528,31542,31568,31610,31492,31565,31499,31564,31557,31605,31589,31604,31591,31600,31601,31596,31598,31645,31640,31647,31629,31644,31642,31627,31634,31631,31581,31641,31691,31681,31692,31695,31668,31686,31709,31721,31761,31764,31718,31717,31840,31744,31751,31763,31731,31735,31767,31757,31734,31779,31783,31786,31775,31799,31787,31805,31820,31811,31828,31823,31808,31824,31832,31839,31844,31830,31845,31852,31861,31875,31888,31908,31917,31906,31915,31905,31912,31923,31922,31921,31918,31929,31933,31936,31941,31938,31960,31954,31964,31970,39739,31983,31986,31988,31990,31994,32006,32002,32028,32021,32010,32069,32075,32046,32050,32063,32053,32070,32115,32086,32078,32114,32104,32110,32079,32099,32147,32137,32091,32143,32125,32155,32186,32174,32163,32181,32199,32189,32171,32317,32162,32175,32220,32184,32159,32176,32216,32221,32228,32222,32251,32242,32225,32261,32266,32291,32289,32274,32305,32287,32265,32267,32290,32326,32358,32315,32309,32313,32323,32311,32306,32314,32359,32349,32342,32350,32345,32346,32377,32362,32361,32380,32379,32387,32213,32381,36782,32383,32392,32393,32396,32402,32400,32403,32404,32406,32398,32411,32412,32568,32570,32581,32588,32589,32590,32592,32593,32597,32596,32600,32607,32608,32616,32617,32615,32632,32642,32646,32643,32648,32647,32652,32660,32670,32669,32666,32675,32687,32690,32697,32686,32694,32696,35697,32709,32710,32714,32725,32724,32737,32742,32745,32755,32761,39132,32774,32772,32779,32786,32792,32793,32796,32801,32808,32831,32827,32842,32838,32850,32856,32858,32863,32866,32872,32883,32882,32880,32886,32889,32893,32895,32900,32902,32901,32923,32915,32922,32941,20880,32940,32987,32997,32985,32989,32964,32986,32982,33033,33007,33009,33051,33065,33059,33071,33099,38539,33094,33086,33107,33105,33020,33137,33134,33125,33126,33140,33155,33160,33162,33152,33154,33184,33173,33188,33187,33119,33171,33193,33200,33205,33214,33208,33213,33216,33218,33210,33225,33229,33233,33241,33240,33224,33242,33247,33248,33255,33274,33275,33278,33281,33282,33285,33287,33290,33293,33296,33302,33321,33323,33336,33331,33344,33369,33368,33373,33370,33375,33380,33378,33384,33386,33387,33326,33393,33399,33400,33406,33421,33426,33451,33439,33467,33452,33505,33507,33503,33490,33524,33523,33530,33683,33539,33531,33529,33502,33542,33500,33545,33497,33589,33588,33558,33586,33585,33600,33593,33616,33605,33583,33579,33559,33560,33669,33690,33706,33695,33698,33686,33571,33678,33671,33674,33660,33717,33651,33653,33696,33673,33704,33780,33811,33771,33742,33789,33795,33752,33803,33729,33783,33799,33760,33778,33805,33826,33824,33725,33848,34054,33787,33901,33834,33852,34138,33924,33911,33899,33965,33902,33922,33897,33862,33836,33903,33913,33845,33994,33890,33977,33983,33951,34009,33997,33979,34010,34000,33985,33990,34006,33953,34081,34047,34036,34071,34072,34092,34079,34069,34068,34044,34112,34147,34136,34120,34113,34306,34123,34133,34176,34212,34184,34193,34186,34216,34157,34196,34203,34282,34183,34204,34167,34174,34192,34249,34234,34255,34233,34256,34261,34269,34277,34268,34297,34314,34323,34315,34302,34298,34310,34338,34330,34352,34367,34381,20053,34388,34399,34407,34417,34451,34467,34473,34474,34443,34444,34486,34479,34500,34502,34480,34505,34851,34475,34516,34526,34537,34540,34527,34523,34543,34578,34566,34568,34560,34563,34555,34577,34569,34573,34553,34570,34612,34623,34615,34619,34597,34601,34586,34656,34655,34680,34636,34638,34676,34647,34664,34670,34649,34643,34659,34666,34821,34722,34719,34690,34735,34763,34749,34752,34768,38614,34731,34756,34739,34759,34758,34747,34799,34802,34784,34831,34829,34814,34806,34807,34830,34770,34833,34838,34837,34850,34849,34865,34870,34873,34855,34875,34884,34882,34898,34905,34910,34914,34923,34945,34942,34974,34933,34941,34997,34930,34946,34967,34962,34990,34969,34978,34957,34980,34992,35007,34993,35011,35012,35028,35032,35033,35037,35065,35074,35068,35060,35048,35058,35076,35084,35082,35091,35139,35102,35109,35114,35115,35137,35140,35131,35126,35128,35148,35101,35168,35166,35174,35172,35181,35178,35183,35188,35191,35198,35203,35208,35210,35219,35224,35233,35241,35238,35244,35247,35250,35258,35261,35263,35264,35290,35292,35293,35303,35316,35320,35331,35350,35344,35340,35355,35357,35365,35382,35393,35419,35410,35398,35400,35452,35437,35436,35426,35461,35458,35460,35496,35489,35473,35493,35494,35482,35491,35524,35533,35522,35546,35563,35571,35559,35556,35569,35604,35552,35554,35575,35550,35547,35596,35591,35610,35553,35606,35600,35607,35616,35635,38827,35622,35627,35646,35624,35649,35660,35663,35662,35657,35670,35675,35674,35691,35679,35692,35695,35700,35709,35712,35724,35726,35730,35731,35734,35737,35738,35898,35905,35903,35912,35916,35918,35920,35925,35938,35948,35960,35962,35970,35977,35973,35978,35981,35982,35988,35964,35992,25117,36013,36010,36029,36018,36019,36014,36022,36040,36033,36068,36067,36058,36093,36090,36091,36100,36101,36106,36103,36111,36109,36112,40782,36115,36045,36116,36118,36199,36205,36209,36211,36225,36249,36290,36286,36282,36303,36314,36310,36300,36315,36299,36330,36331,36319,36323,36348,36360,36361,36351,36381,36382,36368,36383,36418,36405,36400,36404,36426,36423,36425,36428,36432,36424,36441,36452,36448,36394,36451,36437,36470,36466,36476,36481,36487,36485,36484,36491,36490,36499,36497,36500,36505,36522,36513,36524,36528,36550,36529,36542,36549,36552,36555,36571,36579,36604,36603,36587,36606,36618,36613,36629,36626,36633,36627,36636,36639,36635,36620,36646,36659,36667,36665,36677,36674,36670,36684,36681,36678,36686,36695,36700,36706,36707,36708,36764,36767,36771,36781,36783,36791,36826,36837,36834,36842,36847,36999,36852,36869,36857,36858,36881,36885,36897,36877,36894,36886,36875,36903,36918,36917,36921,36856,36943,36944,36945,36946,36878,36937,36926,36950,36952,36958,36968,36975,36982,38568,36978,36994,36989,36993,36992,37002,37001,37007,37032,37039,37041,37045,37090,37092,25160,37083,37122,37138,37145,37170,37168,37194,37206,37208,37219,37221,37225,37235,37234,37259,37257,37250,37282,37291,37295,37290,37301,37300,37306,37312,37313,37321,37323,37328,37334,37343,37345,37339,37372,37365,37366,37406,37375,37396,37420,37397,37393,37470,37463,37445,37449,37476,37448,37525,37439,37451,37456,37532,37526,37523,37531,37466,37583,37561,37559,37609,37647,37626,37700,37678,37657,37666,37658,37667,37690,37685,37691,37724,37728,37756,37742,37718,37808,37804,37805,37780,37817,37846,37847,37864,37861,37848,37827,37853,37840,37832,37860,37914,37908,37907,37891,37895,37904,37942,37931,37941,37921,37946,37953,37970,37956,37979,37984,37986,37982,37994,37417,38000,38005,38007,38013,37978,38012,38014,38017,38015,38274,38279,38282,38292,38294,38296,38297,38304,38312,38311,38317,38332,38331,38329,38334,38346,28662,38339,38349,38348,38357,38356,38358,38364,38369,38373,38370,38433,38440,38446,38447,38466,38476,38479,38475,38519,38492,38494,38493,38495,38502,38514,38508,38541,38552,38549,38551,38570,38567,38577,38578,38576,38580,38582,38584,38585,38606,38603,38601,38605,35149,38620,38669,38613,38649,38660,38662,38664,38675,38670,38673,38671,38678,38681,38692,38698,38704,38713,38717,38718,38724,38726,38728,38722,38729,38748,38752,38756,38758,38760,21202,38763,38769,38777,38789,38780,38785,38778,38790,38795,38799,38800,38812,38824,38822,38819,38835,38836,38851,38854,38856,38859,38876,38893,40783,38898,31455,38902,38901,38927,38924,38968,38948,38945,38967,38973,38982,38991,38987,39019,39023,39024,39025,39028,39027,39082,39087,39089,39094,39108,39107,39110,39145,39147,39171,39177,39186,39188,39192,39201,39197,39198,39204,39200,39212,39214,39229,39230,39234,39241,39237,39248,39243,39249,39250,39244,39253,39319,39320,39333,39341,39342,39356,39391,39387,39389,39384,39377,39405,39406,39409,39410,39419,39416,39425,39439,39429,39394,39449,39467,39479,39493,39490,39488,39491,39486,39509,39501,39515,39511,39519,39522,39525,39524,39529,39531,39530,39597,39600,39612,39616,39631,39633,39635,39636,39646,39647,39650,39651,39654,39663,39659,39662,39668,39665,39671,39675,39686,39704,39706,39711,39714,39715,39717,39719,39720,39721,39722,39726,39727,39730,39748,39747,39759,39757,39758,39761,39768,39796,39827,39811,39825,39830,39831,39839,39840,39848,39860,39872,39882,39865,39878,39887,39889,39890,39907,39906,39908,39892,39905,39994,39922,39921,39920,39957,39956,39945,39955,39948,39942,39944,39954,39946,39940,39982,39963,39973,39972,39969,39984,40007,39986,40006,39998,40026,40032,40039,40054,40056,40167,40172,40176,40201,40200,40171,40195,40198,40234,40230,40367,40227,40223,40260,40213,40210,40257,40255,40254,40262,40264,40285,40286,40292,40273,40272,40281,40306,40329,40327,40363,40303,40314,40346,40356,40361,40370,40388,40385,40379,40376,40378,40390,40399,40386,40409,40403,40440,40422,40429,40431,40445,40474,40475,40478,40565,40569,40573,40577,40584,40587,40588,40594,40597,40593,40605,40613,40617,40632,40618,40621,38753,40652,40654,40655,40656,40660,40668,40670,40669,40672,40677,40680,40687,40692,40694,40695,40697,40699,40700,40701,40711,40712,30391,40725,40737,40748,40766,40778,40786,40788,40803,40799,40800,40801,40806,40807,40812,40810,40823,40818,40822,40853,40860,40864,22575,27079,36953,29796,20956,29081,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,32394,35100,37704,37512,34012,20425,28859,26161,26824,37625,26363,24389,20008,20193,20220,20224,20227,20281,20310,20370,20362,20378,20372,20429,20544,20514,20479,20510,20550,20592,20546,20628,20724,20696,20810,20836,20893,20926,20972,21013,21148,21158,21184,21211,21248,21255,21284,21362,21395,21426,21469,64014,21660,21642,21673,21759,21894,22361,22373,22444,22472,22471,64015,64016,22686,22706,22795,22867,22875,22877,22883,22948,22970,23382,23488,29999,23512,23532,23582,23718,23738,23797,23847,23891,64017,23874,23917,23992,23993,24016,24353,24372,24423,24503,24542,24669,24709,24714,24798,24789,24864,24818,24849,24887,24880,24984,25107,25254,25589,25696,25757,25806,25934,26112,26133,26171,26121,26158,26142,26148,26213,26199,26201,64018,26227,26265,26272,26290,26303,26362,26382,63785,26470,26555,26706,26560,26625,26692,26831,64019,26984,64020,27032,27106,27184,27243,27206,27251,27262,27362,27364,27606,27711,27740,27782,27759,27866,27908,28039,28015,28054,28076,28111,28152,28146,28156,28217,28252,28199,28220,28351,28552,28597,28661,28677,28679,28712,28805,28843,28943,28932,29020,28998,28999,64021,29121,29182,29361,29374,29476,64022,29559,29629,29641,29654,29667,29650,29703,29685,29734,29738,29737,29742,29794,29833,29855,29953,30063,30338,30364,30366,30363,30374,64023,30534,21167,30753,30798,30820,30842,31024,64024,64025,64026,31124,64027,31131,31441,31463,64028,31467,31646,64029,32072,32092,32183,32160,32214,32338,32583,32673,64030,33537,33634,33663,33735,33782,33864,33972,34131,34137,34155,64031,34224,64032,64033,34823,35061,35346,35383,35449,35495,35518,35551,64034,35574,35667,35711,36080,36084,36114,36214,64035,36559,64036,64037,36967,37086,64038,37141,37159,37338,37335,37342,37357,37358,37348,37349,37382,37392,37386,37434,37440,37436,37454,37465,37457,37433,37479,37543,37495,37496,37607,37591,37593,37584,64039,37589,37600,37587,37669,37665,37627,64040,37662,37631,37661,37634,37744,37719,37796,37830,37854,37880,37937,37957,37960,38290,63964,64041,38557,38575,38707,38715,38723,38733,38735,38737,38741,38999,39013,64042,64043,39207,64044,39326,39502,39641,39644,39797,39794,39823,39857,39867,39936,40304,40299,64045,40473,40657,null,null,8560,8561,8562,8563,8564,8565,8566,8567,8568,8569,65506,65508,65287,65282,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,8560,8561,8562,8563,8564,8565,8566,8567,8568,8569,8544,8545,8546,8547,8548,8549,8550,8551,8552,8553,65506,65508,65287,65282,12849,8470,8481,8757,32394,35100,37704,37512,34012,20425,28859,26161,26824,37625,26363,24389,20008,20193,20220,20224,20227,20281,20310,20370,20362,20378,20372,20429,20544,20514,20479,20510,20550,20592,20546,20628,20724,20696,20810,20836,20893,20926,20972,21013,21148,21158,21184,21211,21248,21255,21284,21362,21395,21426,21469,64014,21660,21642,21673,21759,21894,22361,22373,22444,22472,22471,64015,64016,22686,22706,22795,22867,22875,22877,22883,22948,22970,23382,23488,29999,23512,23532,23582,23718,23738,23797,23847,23891,64017,23874,23917,23992,23993,24016,24353,24372,24423,24503,24542,24669,24709,24714,24798,24789,24864,24818,24849,24887,24880,24984,25107,25254,25589,25696,25757,25806,25934,26112,26133,26171,26121,26158,26142,26148,26213,26199,26201,64018,26227,26265,26272,26290,26303,26362,26382,63785,26470,26555,26706,26560,26625,26692,26831,64019,26984,64020,27032,27106,27184,27243,27206,27251,27262,27362,27364,27606,27711,27740,27782,27759,27866,27908,28039,28015,28054,28076,28111,28152,28146,28156,28217,28252,28199,28220,28351,28552,28597,28661,28677,28679,28712,28805,28843,28943,28932,29020,28998,28999,64021,29121,29182,29361,29374,29476,64022,29559,29629,29641,29654,29667,29650,29703,29685,29734,29738,29737,29742,29794,29833,29855,29953,30063,30338,30364,30366,30363,30374,64023,30534,21167,30753,30798,30820,30842,31024,64024,64025,64026,31124,64027,31131,31441,31463,64028,31467,31646,64029,32072,32092,32183,32160,32214,32338,32583,32673,64030,33537,33634,33663,33735,33782,33864,33972,34131,34137,34155,64031,34224,64032,64033,34823,35061,35346,35383,35449,35495,35518,35551,64034,35574,35667,35711,36080,36084,36114,36214,64035,36559,64036,64037,36967,37086,64038,37141,37159,37338,37335,37342,37357,37358,37348,37349,37382,37392,37386,37434,37440,37436,37454,37465,37457,37433,37479,37543,37495,37496,37607,37591,37593,37584,64039,37589,37600,37587,37669,37665,37627,64040,37662,37631,37661,37634,37744,37719,37796,37830,37854,37880,37937,37957,37960,38290,63964,64041,38557,38575,38707,38715,38723,38733,38735,38737,38741,38999,39013,64042,64043,39207,64044,39326,39502,39641,39644,39797,39794,39823,39857,39867,39936,40304,40299,64045,40473,40657,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],
27016 "jis0212":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,728,711,184,729,733,175,731,730,65374,900,901,null,null,null,null,null,null,null,null,161,166,191,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,186,170,169,174,8482,164,8470,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,902,904,905,906,938,null,908,null,910,939,null,911,null,null,null,null,940,941,942,943,970,912,972,962,973,971,944,974,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1026,1027,1028,1029,1030,1031,1032,1033,1034,1035,1036,1038,1039,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1106,1107,1108,1109,1110,1111,1112,1113,1114,1115,1116,1118,1119,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,198,272,null,294,null,306,null,321,319,null,330,216,338,null,358,222,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,230,273,240,295,305,307,312,322,320,329,331,248,339,223,359,254,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,193,192,196,194,258,461,256,260,197,195,262,264,268,199,266,270,201,200,203,202,282,278,274,280,null,284,286,290,288,292,205,204,207,206,463,304,298,302,296,308,310,313,317,315,323,327,325,209,211,210,214,212,465,336,332,213,340,344,342,346,348,352,350,356,354,218,217,220,219,364,467,368,362,370,366,360,471,475,473,469,372,221,376,374,377,381,379,null,null,null,null,null,null,null,225,224,228,226,259,462,257,261,229,227,263,265,269,231,267,271,233,232,235,234,283,279,275,281,501,285,287,null,289,293,237,236,239,238,464,null,299,303,297,309,311,314,318,316,324,328,326,241,243,242,246,244,466,337,333,245,341,345,343,347,349,353,351,357,355,250,249,252,251,365,468,369,363,371,367,361,472,476,474,470,373,253,255,375,378,382,380,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,19970,19972,19973,19980,19986,19999,20003,20004,20008,20011,20014,20015,20016,20021,20032,20033,20036,20039,20049,20058,20060,20067,20072,20073,20084,20085,20089,20095,20109,20118,20119,20125,20143,20153,20163,20176,20186,20187,20192,20193,20194,20200,20207,20209,20211,20213,20221,20222,20223,20224,20226,20227,20232,20235,20236,20242,20245,20246,20247,20249,20270,20273,20320,20275,20277,20279,20281,20283,20286,20288,20290,20296,20297,20299,20300,20306,20308,20310,20312,20319,20323,20330,20332,20334,20337,20343,20344,20345,20346,20349,20350,20353,20354,20356,20357,20361,20362,20364,20366,20368,20370,20371,20372,20375,20377,20378,20382,20383,20402,20407,20409,20411,20412,20413,20414,20416,20417,20421,20422,20424,20425,20427,20428,20429,20431,20434,20444,20448,20450,20464,20466,20476,20477,20479,20480,20481,20484,20487,20490,20492,20494,20496,20499,20503,20504,20507,20508,20509,20510,20514,20519,20526,20528,20530,20531,20533,20544,20545,20546,20549,20550,20554,20556,20558,20561,20562,20563,20567,20569,20575,20576,20578,20579,20582,20583,20586,20589,20592,20593,20539,20609,20611,20612,20614,20618,20622,20623,20624,20626,20627,20628,20630,20635,20636,20638,20639,20640,20641,20642,20650,20655,20656,20665,20666,20669,20672,20675,20676,20679,20684,20686,20688,20691,20692,20696,20700,20701,20703,20706,20708,20710,20712,20713,20719,20721,20726,20730,20734,20739,20742,20743,20744,20747,20748,20749,20750,20722,20752,20759,20761,20763,20764,20765,20766,20771,20775,20776,20780,20781,20783,20785,20787,20788,20789,20792,20793,20802,20810,20815,20819,20821,20823,20824,20831,20836,20838,20862,20867,20868,20875,20878,20888,20893,20897,20899,20909,20920,20922,20924,20926,20927,20930,20936,20943,20945,20946,20947,20949,20952,20958,20962,20965,20974,20978,20979,20980,20983,20993,20994,20997,21010,21011,21013,21014,21016,21026,21032,21041,21042,21045,21052,21061,21065,21077,21079,21080,21082,21084,21087,21088,21089,21094,21102,21111,21112,21113,21120,21122,21125,21130,21132,21139,21141,21142,21143,21144,21146,21148,21156,21157,21158,21159,21167,21168,21174,21175,21176,21178,21179,21181,21184,21188,21190,21192,21196,21199,21201,21204,21206,21211,21212,21217,21221,21224,21225,21226,21228,21232,21233,21236,21238,21239,21248,21251,21258,21259,21260,21265,21267,21272,21275,21276,21278,21279,21285,21287,21288,21289,21291,21292,21293,21296,21298,21301,21308,21309,21310,21314,21324,21323,21337,21339,21345,21347,21349,21356,21357,21362,21369,21374,21379,21383,21384,21390,21395,21396,21401,21405,21409,21412,21418,21419,21423,21426,21428,21429,21431,21432,21434,21437,21440,21445,21455,21458,21459,21461,21466,21469,21470,21472,21478,21479,21493,21506,21523,21530,21537,21543,21544,21546,21551,21553,21556,21557,21571,21572,21575,21581,21583,21598,21602,21604,21606,21607,21609,21611,21613,21614,21620,21631,21633,21635,21637,21640,21641,21645,21649,21653,21654,21660,21663,21665,21670,21671,21673,21674,21677,21678,21681,21687,21689,21690,21691,21695,21702,21706,21709,21710,21728,21738,21740,21743,21750,21756,21758,21759,21760,21761,21765,21768,21769,21772,21773,21774,21781,21802,21803,21810,21813,21814,21819,21820,21821,21825,21831,21833,21834,21837,21840,21841,21848,21850,21851,21854,21856,21857,21860,21862,21887,21889,21890,21894,21896,21902,21903,21905,21906,21907,21908,21911,21923,21924,21933,21938,21951,21953,21955,21958,21961,21963,21964,21966,21969,21970,21971,21975,21976,21979,21982,21986,21993,22006,22015,22021,22024,22026,22029,22030,22031,22032,22033,22034,22041,22060,22064,22067,22069,22071,22073,22075,22076,22077,22079,22080,22081,22083,22084,22086,22089,22091,22093,22095,22100,22110,22112,22113,22114,22115,22118,22121,22125,22127,22129,22130,22133,22148,22149,22152,22155,22156,22165,22169,22170,22173,22174,22175,22182,22183,22184,22185,22187,22188,22189,22193,22195,22199,22206,22213,22217,22218,22219,22223,22224,22220,22221,22233,22236,22237,22239,22241,22244,22245,22246,22247,22248,22257,22251,22253,22262,22263,22273,22274,22279,22282,22284,22289,22293,22298,22299,22301,22304,22306,22307,22308,22309,22313,22314,22316,22318,22319,22323,22324,22333,22334,22335,22341,22342,22348,22349,22354,22370,22373,22375,22376,22379,22381,22382,22383,22384,22385,22387,22388,22389,22391,22393,22394,22395,22396,22398,22401,22403,22412,22420,22423,22425,22426,22428,22429,22430,22431,22433,22421,22439,22440,22441,22444,22456,22461,22471,22472,22476,22479,22485,22493,22494,22500,22502,22503,22505,22509,22512,22517,22518,22520,22525,22526,22527,22531,22532,22536,22537,22497,22540,22541,22555,22558,22559,22560,22566,22567,22573,22578,22585,22591,22601,22604,22605,22607,22608,22613,22623,22625,22628,22631,22632,22648,22652,22655,22656,22657,22663,22664,22665,22666,22668,22669,22671,22672,22676,22678,22685,22688,22689,22690,22694,22697,22705,22706,22724,22716,22722,22728,22733,22734,22736,22738,22740,22742,22746,22749,22753,22754,22761,22771,22789,22790,22795,22796,22802,22803,22804,34369,22813,22817,22819,22820,22824,22831,22832,22835,22837,22838,22847,22851,22854,22866,22867,22873,22875,22877,22878,22879,22881,22883,22891,22893,22895,22898,22901,22902,22905,22907,22908,22923,22924,22926,22930,22933,22935,22943,22948,22951,22957,22958,22959,22960,22963,22967,22970,22972,22977,22979,22980,22984,22986,22989,22994,23005,23006,23007,23011,23012,23015,23022,23023,23025,23026,23028,23031,23040,23044,23052,23053,23054,23058,23059,23070,23075,23076,23079,23080,23082,23085,23088,23108,23109,23111,23112,23116,23120,23125,23134,23139,23141,23143,23149,23159,23162,23163,23166,23179,23184,23187,23190,23193,23196,23198,23199,23200,23202,23207,23212,23217,23218,23219,23221,23224,23226,23227,23231,23236,23238,23240,23247,23258,23260,23264,23269,23274,23278,23285,23286,23293,23296,23297,23304,23319,23348,23321,23323,23325,23329,23333,23341,23352,23361,23371,23372,23378,23382,23390,23400,23406,23407,23420,23421,23422,23423,23425,23428,23430,23434,23438,23440,23441,23443,23444,23446,23464,23465,23468,23469,23471,23473,23474,23479,23482,23484,23488,23489,23501,23503,23510,23511,23512,23513,23514,23520,23535,23537,23540,23549,23564,23575,23582,23583,23587,23590,23593,23595,23596,23598,23600,23602,23605,23606,23641,23642,23644,23650,23651,23655,23656,23657,23661,23664,23668,23669,23674,23675,23676,23677,23687,23688,23690,23695,23698,23709,23711,23712,23714,23715,23718,23722,23730,23732,23733,23738,23753,23755,23762,23773,23767,23790,23793,23794,23796,23809,23814,23821,23826,23851,23843,23844,23846,23847,23857,23860,23865,23869,23871,23874,23875,23878,23880,23893,23889,23897,23882,23903,23904,23905,23906,23908,23914,23917,23920,23929,23930,23934,23935,23937,23939,23944,23946,23954,23955,23956,23957,23961,23963,23967,23968,23975,23979,23984,23988,23992,23993,24003,24007,24011,24016,24014,24024,24025,24032,24036,24041,24056,24057,24064,24071,24077,24082,24084,24085,24088,24095,24096,24110,24104,24114,24117,24126,24139,24144,24137,24145,24150,24152,24155,24156,24158,24168,24170,24171,24172,24173,24174,24176,24192,24203,24206,24226,24228,24229,24232,24234,24236,24241,24243,24253,24254,24255,24262,24268,24267,24270,24273,24274,24276,24277,24284,24286,24293,24299,24322,24326,24327,24328,24334,24345,24348,24349,24353,24354,24355,24356,24360,24363,24364,24366,24368,24372,24374,24379,24381,24383,24384,24388,24389,24391,24397,24400,24404,24408,24411,24416,24419,24420,24423,24431,24434,24436,24437,24440,24442,24445,24446,24457,24461,24463,24470,24476,24477,24482,24487,24491,24484,24492,24495,24496,24497,24504,24516,24519,24520,24521,24523,24528,24529,24530,24531,24532,24542,24545,24546,24552,24553,24554,24556,24557,24558,24559,24562,24563,24566,24570,24572,24583,24586,24589,24595,24596,24599,24600,24602,24607,24612,24621,24627,24629,24640,24647,24648,24649,24652,24657,24660,24662,24663,24669,24673,24679,24689,24702,24703,24706,24710,24712,24714,24718,24721,24723,24725,24728,24733,24734,24738,24740,24741,24744,24752,24753,24759,24763,24766,24770,24772,24776,24777,24778,24779,24782,24783,24788,24789,24793,24795,24797,24798,24802,24805,24818,24821,24824,24828,24829,24834,24839,24842,24844,24848,24849,24850,24851,24852,24854,24855,24857,24860,24862,24866,24874,24875,24880,24881,24885,24886,24887,24889,24897,24901,24902,24905,24926,24928,24940,24946,24952,24955,24956,24959,24960,24961,24963,24964,24971,24973,24978,24979,24983,24984,24988,24989,24991,24992,24997,25000,25002,25005,25016,25017,25020,25024,25025,25026,25038,25039,25045,25052,25053,25054,25055,25057,25058,25063,25065,25061,25068,25069,25071,25089,25091,25092,25095,25107,25109,25116,25120,25122,25123,25127,25129,25131,25145,25149,25154,25155,25156,25158,25164,25168,25169,25170,25172,25174,25178,25180,25188,25197,25199,25203,25210,25213,25229,25230,25231,25232,25254,25256,25267,25270,25271,25274,25278,25279,25284,25294,25301,25302,25306,25322,25330,25332,25340,25341,25347,25348,25354,25355,25357,25360,25363,25366,25368,25385,25386,25389,25397,25398,25401,25404,25409,25410,25411,25412,25414,25418,25419,25422,25426,25427,25428,25432,25435,25445,25446,25452,25453,25457,25460,25461,25464,25468,25469,25471,25474,25476,25479,25482,25488,25492,25493,25497,25498,25502,25508,25510,25517,25518,25519,25533,25537,25541,25544,25550,25553,25555,25556,25557,25564,25568,25573,25578,25580,25586,25587,25589,25592,25593,25609,25610,25616,25618,25620,25624,25630,25632,25634,25636,25637,25641,25642,25647,25648,25653,25661,25663,25675,25679,25681,25682,25683,25684,25690,25691,25692,25693,25695,25696,25697,25699,25709,25715,25716,25723,25725,25733,25735,25743,25744,25745,25752,25753,25755,25757,25759,25761,25763,25766,25768,25772,25779,25789,25790,25791,25796,25801,25802,25803,25804,25806,25808,25809,25813,25815,25828,25829,25833,25834,25837,25840,25845,25847,25851,25855,25857,25860,25864,25865,25866,25871,25875,25876,25878,25881,25883,25886,25887,25890,25894,25897,25902,25905,25914,25916,25917,25923,25927,25929,25936,25938,25940,25951,25952,25959,25963,25978,25981,25985,25989,25994,26002,26005,26008,26013,26016,26019,26022,26030,26034,26035,26036,26047,26050,26056,26057,26062,26064,26068,26070,26072,26079,26096,26098,26100,26101,26105,26110,26111,26112,26116,26120,26121,26125,26129,26130,26133,26134,26141,26142,26145,26146,26147,26148,26150,26153,26154,26155,26156,26158,26160,26161,26163,26169,26167,26176,26181,26182,26186,26188,26193,26190,26199,26200,26201,26203,26204,26208,26209,26363,26218,26219,26220,26238,26227,26229,26239,26231,26232,26233,26235,26240,26236,26251,26252,26253,26256,26258,26265,26266,26267,26268,26271,26272,26276,26285,26289,26290,26293,26299,26303,26304,26306,26307,26312,26316,26318,26319,26324,26331,26335,26344,26347,26348,26350,26362,26373,26375,26382,26387,26393,26396,26400,26402,26419,26430,26437,26439,26440,26444,26452,26453,26461,26470,26476,26478,26484,26486,26491,26497,26500,26510,26511,26513,26515,26518,26520,26521,26523,26544,26545,26546,26549,26555,26556,26557,26617,26560,26562,26563,26565,26568,26569,26578,26583,26585,26588,26593,26598,26608,26610,26614,26615,26706,26644,26649,26653,26655,26664,26663,26668,26669,26671,26672,26673,26675,26683,26687,26692,26693,26698,26700,26709,26711,26712,26715,26731,26734,26735,26736,26737,26738,26741,26745,26746,26747,26748,26754,26756,26758,26760,26774,26776,26778,26780,26785,26787,26789,26793,26794,26798,26802,26811,26821,26824,26828,26831,26832,26833,26835,26838,26841,26844,26845,26853,26856,26858,26859,26860,26861,26864,26865,26869,26870,26875,26876,26877,26886,26889,26890,26896,26897,26899,26902,26903,26929,26931,26933,26936,26939,26946,26949,26953,26958,26967,26971,26979,26980,26981,26982,26984,26985,26988,26992,26993,26994,27002,27003,27007,27008,27021,27026,27030,27032,27041,27045,27046,27048,27051,27053,27055,27063,27064,27066,27068,27077,27080,27089,27094,27095,27106,27109,27118,27119,27121,27123,27125,27134,27136,27137,27139,27151,27153,27157,27162,27165,27168,27172,27176,27184,27186,27188,27191,27195,27198,27199,27205,27206,27209,27210,27214,27216,27217,27218,27221,27222,27227,27236,27239,27242,27249,27251,27262,27265,27267,27270,27271,27273,27275,27281,27291,27293,27294,27295,27301,27307,27311,27312,27313,27316,27325,27326,27327,27334,27337,27336,27340,27344,27348,27349,27350,27356,27357,27364,27367,27372,27376,27377,27378,27388,27389,27394,27395,27398,27399,27401,27407,27408,27409,27415,27419,27422,27428,27432,27435,27436,27439,27445,27446,27451,27455,27462,27466,27469,27474,27478,27480,27485,27488,27495,27499,27502,27504,27509,27517,27518,27522,27525,27543,27547,27551,27552,27554,27555,27560,27561,27564,27565,27566,27568,27576,27577,27581,27582,27587,27588,27593,27596,27606,27610,27617,27619,27622,27623,27630,27633,27639,27641,27647,27650,27652,27653,27657,27661,27662,27664,27666,27673,27679,27686,27687,27688,27692,27694,27699,27701,27702,27706,27707,27711,27722,27723,27725,27727,27730,27732,27737,27739,27740,27755,27757,27759,27764,27766,27768,27769,27771,27781,27782,27783,27785,27796,27797,27799,27800,27804,27807,27824,27826,27828,27842,27846,27853,27855,27856,27857,27858,27860,27862,27866,27868,27872,27879,27881,27883,27884,27886,27890,27892,27908,27911,27914,27918,27919,27921,27923,27930,27942,27943,27944,27751,27950,27951,27953,27961,27964,27967,27991,27998,27999,28001,28005,28007,28015,28016,28028,28034,28039,28049,28050,28052,28054,28055,28056,28074,28076,28084,28087,28089,28093,28095,28100,28104,28106,28110,28111,28118,28123,28125,28127,28128,28130,28133,28137,28143,28144,28148,28150,28156,28160,28164,28190,28194,28199,28210,28214,28217,28219,28220,28228,28229,28232,28233,28235,28239,28241,28242,28243,28244,28247,28252,28253,28254,28258,28259,28264,28275,28283,28285,28301,28307,28313,28320,28327,28333,28334,28337,28339,28347,28351,28352,28353,28355,28359,28360,28362,28365,28366,28367,28395,28397,28398,28409,28411,28413,28420,28424,28426,28428,28429,28438,28440,28442,28443,28454,28457,28458,28463,28464,28467,28470,28475,28476,28461,28495,28497,28498,28499,28503,28505,28506,28509,28510,28513,28514,28520,28524,28541,28542,28547,28551,28552,28555,28556,28557,28560,28562,28563,28564,28566,28570,28575,28576,28581,28582,28583,28584,28590,28591,28592,28597,28598,28604,28613,28615,28616,28618,28634,28638,28648,28649,28656,28661,28665,28668,28669,28672,28677,28678,28679,28685,28695,28704,28707,28719,28724,28727,28729,28732,28739,28740,28744,28745,28746,28747,28756,28757,28765,28766,28750,28772,28773,28780,28782,28789,28790,28798,28801,28805,28806,28820,28821,28822,28823,28824,28827,28836,28843,28848,28849,28852,28855,28874,28881,28883,28884,28885,28886,28888,28892,28900,28922,28931,28932,28933,28934,28935,28939,28940,28943,28958,28960,28971,28973,28975,28976,28977,28984,28993,28997,28998,28999,29002,29003,29008,29010,29015,29018,29020,29022,29024,29032,29049,29056,29061,29063,29068,29074,29082,29083,29088,29090,29103,29104,29106,29107,29114,29119,29120,29121,29124,29131,29132,29139,29142,29145,29146,29148,29176,29182,29184,29191,29192,29193,29203,29207,29210,29213,29215,29220,29227,29231,29236,29240,29241,29249,29250,29251,29253,29262,29263,29264,29267,29269,29270,29274,29276,29278,29280,29283,29288,29291,29294,29295,29297,29303,29304,29307,29308,29311,29316,29321,29325,29326,29331,29339,29352,29357,29358,29361,29364,29374,29377,29383,29385,29388,29397,29398,29400,29407,29413,29427,29428,29434,29435,29438,29442,29444,29445,29447,29451,29453,29458,29459,29464,29465,29470,29474,29476,29479,29480,29484,29489,29490,29493,29498,29499,29501,29507,29517,29520,29522,29526,29528,29533,29534,29535,29536,29542,29543,29545,29547,29548,29550,29551,29553,29559,29561,29564,29568,29569,29571,29573,29574,29582,29584,29587,29589,29591,29592,29596,29598,29599,29600,29602,29605,29606,29610,29611,29613,29621,29623,29625,29628,29629,29631,29637,29638,29641,29643,29644,29647,29650,29651,29654,29657,29661,29665,29667,29670,29671,29673,29684,29685,29687,29689,29690,29691,29693,29695,29696,29697,29700,29703,29706,29713,29722,29723,29732,29734,29736,29737,29738,29739,29740,29741,29742,29743,29744,29745,29753,29760,29763,29764,29766,29767,29771,29773,29777,29778,29783,29789,29794,29798,29799,29800,29803,29805,29806,29809,29810,29824,29825,29829,29830,29831,29833,29839,29840,29841,29842,29848,29849,29850,29852,29855,29856,29857,29859,29862,29864,29865,29866,29867,29870,29871,29873,29874,29877,29881,29883,29887,29896,29897,29900,29904,29907,29912,29914,29915,29918,29919,29924,29928,29930,29931,29935,29940,29946,29947,29948,29951,29958,29970,29974,29975,29984,29985,29988,29991,29993,29994,29999,30006,30009,30013,30014,30015,30016,30019,30023,30024,30030,30032,30034,30039,30046,30047,30049,30063,30065,30073,30074,30075,30076,30077,30078,30081,30085,30096,30098,30099,30101,30105,30108,30114,30116,30132,30138,30143,30144,30145,30148,30150,30156,30158,30159,30167,30172,30175,30176,30177,30180,30183,30188,30190,30191,30193,30201,30208,30210,30211,30212,30215,30216,30218,30220,30223,30226,30227,30229,30230,30233,30235,30236,30237,30238,30243,30245,30246,30249,30253,30258,30259,30261,30264,30265,30266,30268,30282,30272,30273,30275,30276,30277,30281,30283,30293,30297,30303,30308,30309,30317,30318,30319,30321,30324,30337,30341,30348,30349,30357,30363,30364,30365,30367,30368,30370,30371,30372,30373,30374,30375,30376,30378,30381,30397,30401,30405,30409,30411,30412,30414,30420,30425,30432,30438,30440,30444,30448,30449,30454,30457,30460,30464,30470,30474,30478,30482,30484,30485,30487,30489,30490,30492,30498,30504,30509,30510,30511,30516,30517,30518,30521,30525,30526,30530,30533,30534,30538,30541,30542,30543,30546,30550,30551,30556,30558,30559,30560,30562,30564,30567,30570,30572,30576,30578,30579,30580,30586,30589,30592,30596,30604,30605,30612,30613,30614,30618,30623,30626,30631,30634,30638,30639,30641,30645,30654,30659,30665,30673,30674,30677,30681,30686,30687,30688,30692,30694,30698,30700,30704,30705,30708,30712,30715,30725,30726,30729,30733,30734,30737,30749,30753,30754,30755,30765,30766,30768,30773,30775,30787,30788,30791,30792,30796,30798,30802,30812,30814,30816,30817,30819,30820,30824,30826,30830,30842,30846,30858,30863,30868,30872,30881,30877,30878,30879,30884,30888,30892,30893,30896,30897,30898,30899,30907,30909,30911,30919,30920,30921,30924,30926,30930,30931,30933,30934,30948,30939,30943,30944,30945,30950,30954,30962,30963,30976,30966,30967,30970,30971,30975,30982,30988,30992,31002,31004,31006,31007,31008,31013,31015,31017,31021,31025,31028,31029,31035,31037,31039,31044,31045,31046,31050,31051,31055,31057,31060,31064,31067,31068,31079,31081,31083,31090,31097,31099,31100,31102,31115,31116,31121,31123,31124,31125,31126,31128,31131,31132,31137,31144,31145,31147,31151,31153,31156,31160,31163,31170,31172,31175,31176,31178,31183,31188,31190,31194,31197,31198,31200,31202,31205,31210,31211,31213,31217,31224,31228,31234,31235,31239,31241,31242,31244,31249,31253,31259,31262,31265,31271,31275,31277,31279,31280,31284,31285,31288,31289,31290,31300,31301,31303,31304,31308,31317,31318,31321,31324,31325,31327,31328,31333,31335,31338,31341,31349,31352,31358,31360,31362,31365,31366,31370,31371,31376,31377,31380,31390,31392,31395,31404,31411,31413,31417,31419,31420,31430,31433,31436,31438,31441,31451,31464,31465,31467,31468,31473,31476,31483,31485,31486,31495,31508,31519,31523,31527,31529,31530,31531,31533,31534,31535,31536,31537,31540,31549,31551,31552,31553,31559,31566,31573,31584,31588,31590,31593,31594,31597,31599,31602,31603,31607,31620,31625,31630,31632,31633,31638,31643,31646,31648,31653,31660,31663,31664,31666,31669,31670,31674,31675,31676,31677,31682,31685,31688,31690,31700,31702,31703,31705,31706,31707,31720,31722,31730,31732,31733,31736,31737,31738,31740,31742,31745,31746,31747,31748,31750,31753,31755,31756,31758,31759,31769,31771,31776,31781,31782,31784,31788,31793,31795,31796,31798,31801,31802,31814,31818,31829,31825,31826,31827,31833,31834,31835,31836,31837,31838,31841,31843,31847,31849,31853,31854,31856,31858,31865,31868,31869,31878,31879,31887,31892,31902,31904,31910,31920,31926,31927,31930,31931,31932,31935,31940,31943,31944,31945,31949,31951,31955,31956,31957,31959,31961,31962,31965,31974,31977,31979,31989,32003,32007,32008,32009,32015,32017,32018,32019,32022,32029,32030,32035,32038,32042,32045,32049,32060,32061,32062,32064,32065,32071,32072,32077,32081,32083,32087,32089,32090,32092,32093,32101,32103,32106,32112,32120,32122,32123,32127,32129,32130,32131,32133,32134,32136,32139,32140,32141,32145,32150,32151,32157,32158,32166,32167,32170,32179,32182,32183,32185,32194,32195,32196,32197,32198,32204,32205,32206,32215,32217,32256,32226,32229,32230,32234,32235,32237,32241,32245,32246,32249,32250,32264,32272,32273,32277,32279,32284,32285,32288,32295,32296,32300,32301,32303,32307,32310,32319,32324,32325,32327,32334,32336,32338,32344,32351,32353,32354,32357,32363,32366,32367,32371,32376,32382,32385,32390,32391,32394,32397,32401,32405,32408,32410,32413,32414,32572,32571,32573,32574,32575,32579,32580,32583,32591,32594,32595,32603,32604,32605,32609,32611,32612,32613,32614,32621,32625,32637,32638,32639,32640,32651,32653,32655,32656,32657,32662,32663,32668,32673,32674,32678,32682,32685,32692,32700,32703,32704,32707,32712,32718,32719,32731,32735,32739,32741,32744,32748,32750,32751,32754,32762,32765,32766,32767,32775,32776,32778,32781,32782,32783,32785,32787,32788,32790,32797,32798,32799,32800,32804,32806,32812,32814,32816,32820,32821,32823,32825,32826,32828,32830,32832,32836,32864,32868,32870,32877,32881,32885,32897,32904,32910,32924,32926,32934,32935,32939,32952,32953,32968,32973,32975,32978,32980,32981,32983,32984,32992,33005,33006,33008,33010,33011,33014,33017,33018,33022,33027,33035,33046,33047,33048,33052,33054,33056,33060,33063,33068,33072,33077,33082,33084,33093,33095,33098,33100,33106,33111,33120,33121,33127,33128,33129,33133,33135,33143,33153,33168,33156,33157,33158,33163,33166,33174,33176,33179,33182,33186,33198,33202,33204,33211,33227,33219,33221,33226,33230,33231,33237,33239,33243,33245,33246,33249,33252,33259,33260,33264,33265,33266,33269,33270,33272,33273,33277,33279,33280,33283,33295,33299,33300,33305,33306,33309,33313,33314,33320,33330,33332,33338,33347,33348,33349,33350,33355,33358,33359,33361,33366,33372,33376,33379,33383,33389,33396,33403,33405,33407,33408,33409,33411,33412,33415,33417,33418,33422,33425,33428,33430,33432,33434,33435,33440,33441,33443,33444,33447,33448,33449,33450,33454,33456,33458,33460,33463,33466,33468,33470,33471,33478,33488,33493,33498,33504,33506,33508,33512,33514,33517,33519,33526,33527,33533,33534,33536,33537,33543,33544,33546,33547,33620,33563,33565,33566,33567,33569,33570,33580,33581,33582,33584,33587,33591,33594,33596,33597,33602,33603,33604,33607,33613,33614,33617,33621,33622,33623,33648,33656,33661,33663,33664,33666,33668,33670,33677,33682,33684,33685,33688,33689,33691,33692,33693,33702,33703,33705,33708,33726,33727,33728,33735,33737,33743,33744,33745,33748,33757,33619,33768,33770,33782,33784,33785,33788,33793,33798,33802,33807,33809,33813,33817,33709,33839,33849,33861,33863,33864,33866,33869,33871,33873,33874,33878,33880,33881,33882,33884,33888,33892,33893,33895,33898,33904,33907,33908,33910,33912,33916,33917,33921,33925,33938,33939,33941,33950,33958,33960,33961,33962,33967,33969,33972,33978,33981,33982,33984,33986,33991,33992,33996,33999,34003,34012,34023,34026,34031,34032,34033,34034,34039,34098,34042,34043,34045,34050,34051,34055,34060,34062,34064,34076,34078,34082,34083,34084,34085,34087,34090,34091,34095,34099,34100,34102,34111,34118,34127,34128,34129,34130,34131,34134,34137,34140,34141,34142,34143,34144,34145,34146,34148,34155,34159,34169,34170,34171,34173,34175,34177,34181,34182,34185,34187,34188,34191,34195,34200,34205,34207,34208,34210,34213,34215,34228,34230,34231,34232,34236,34237,34238,34239,34242,34247,34250,34251,34254,34221,34264,34266,34271,34272,34278,34280,34285,34291,34294,34300,34303,34304,34308,34309,34317,34318,34320,34321,34322,34328,34329,34331,34334,34337,34343,34345,34358,34360,34362,34364,34365,34368,34370,34374,34386,34387,34390,34391,34392,34393,34397,34400,34401,34402,34403,34404,34409,34412,34415,34421,34422,34423,34426,34445,34449,34454,34456,34458,34460,34465,34470,34471,34472,34477,34481,34483,34484,34485,34487,34488,34489,34495,34496,34497,34499,34501,34513,34514,34517,34519,34522,34524,34528,34531,34533,34535,34440,34554,34556,34557,34564,34565,34567,34571,34574,34575,34576,34579,34580,34585,34590,34591,34593,34595,34600,34606,34607,34609,34610,34617,34618,34620,34621,34622,34624,34627,34629,34637,34648,34653,34657,34660,34661,34671,34673,34674,34683,34691,34692,34693,34694,34695,34696,34697,34699,34700,34704,34707,34709,34711,34712,34713,34718,34720,34723,34727,34732,34733,34734,34737,34741,34750,34751,34753,34760,34761,34762,34766,34773,34774,34777,34778,34780,34783,34786,34787,34788,34794,34795,34797,34801,34803,34808,34810,34815,34817,34819,34822,34825,34826,34827,34832,34841,34834,34835,34836,34840,34842,34843,34844,34846,34847,34856,34861,34862,34864,34866,34869,34874,34876,34881,34883,34885,34888,34889,34890,34891,34894,34897,34901,34902,34904,34906,34908,34911,34912,34916,34921,34929,34937,34939,34944,34968,34970,34971,34972,34975,34976,34984,34986,35002,35005,35006,35008,35018,35019,35020,35021,35022,35025,35026,35027,35035,35038,35047,35055,35056,35057,35061,35063,35073,35078,35085,35086,35087,35093,35094,35096,35097,35098,35100,35104,35110,35111,35112,35120,35121,35122,35125,35129,35130,35134,35136,35138,35141,35142,35145,35151,35154,35159,35162,35163,35164,35169,35170,35171,35179,35182,35184,35187,35189,35194,35195,35196,35197,35209,35213,35216,35220,35221,35227,35228,35231,35232,35237,35248,35252,35253,35254,35255,35260,35284,35285,35286,35287,35288,35301,35305,35307,35309,35313,35315,35318,35321,35325,35327,35332,35333,35335,35343,35345,35346,35348,35349,35358,35360,35362,35364,35366,35371,35372,35375,35381,35383,35389,35390,35392,35395,35397,35399,35401,35405,35406,35411,35414,35415,35416,35420,35421,35425,35429,35431,35445,35446,35447,35449,35450,35451,35454,35455,35456,35459,35462,35467,35471,35472,35474,35478,35479,35481,35487,35495,35497,35502,35503,35507,35510,35511,35515,35518,35523,35526,35528,35529,35530,35537,35539,35540,35541,35543,35549,35551,35564,35568,35572,35573,35574,35580,35583,35589,35590,35595,35601,35612,35614,35615,35594,35629,35632,35639,35644,35650,35651,35652,35653,35654,35656,35666,35667,35668,35673,35661,35678,35683,35693,35702,35704,35705,35708,35710,35713,35716,35717,35723,35725,35727,35732,35733,35740,35742,35743,35896,35897,35901,35902,35909,35911,35913,35915,35919,35921,35923,35924,35927,35928,35931,35933,35929,35939,35940,35942,35944,35945,35949,35955,35957,35958,35963,35966,35974,35975,35979,35984,35986,35987,35993,35995,35996,36004,36025,36026,36037,36038,36041,36043,36047,36054,36053,36057,36061,36065,36072,36076,36079,36080,36082,36085,36087,36088,36094,36095,36097,36099,36105,36114,36119,36123,36197,36201,36204,36206,36223,36226,36228,36232,36237,36240,36241,36245,36254,36255,36256,36262,36267,36268,36271,36274,36277,36279,36281,36283,36288,36293,36294,36295,36296,36298,36302,36305,36308,36309,36311,36313,36324,36325,36327,36332,36336,36284,36337,36338,36340,36349,36353,36356,36357,36358,36363,36369,36372,36374,36384,36385,36386,36387,36390,36391,36401,36403,36406,36407,36408,36409,36413,36416,36417,36427,36429,36430,36431,36436,36443,36444,36445,36446,36449,36450,36457,36460,36461,36463,36464,36465,36473,36474,36475,36482,36483,36489,36496,36498,36501,36506,36507,36509,36510,36514,36519,36521,36525,36526,36531,36533,36538,36539,36544,36545,36547,36548,36551,36559,36561,36564,36572,36584,36590,36592,36593,36599,36601,36602,36589,36608,36610,36615,36616,36623,36624,36630,36631,36632,36638,36640,36641,36643,36645,36647,36648,36652,36653,36654,36660,36661,36662,36663,36666,36672,36673,36675,36679,36687,36689,36690,36691,36692,36693,36696,36701,36702,36709,36765,36768,36769,36772,36773,36774,36789,36790,36792,36798,36800,36801,36806,36810,36811,36813,36816,36818,36819,36821,36832,36835,36836,36840,36846,36849,36853,36854,36859,36862,36866,36868,36872,36876,36888,36891,36904,36905,36911,36906,36908,36909,36915,36916,36919,36927,36931,36932,36940,36955,36957,36962,36966,36967,36972,36976,36980,36985,36997,37000,37003,37004,37006,37008,37013,37015,37016,37017,37019,37024,37025,37026,37029,37040,37042,37043,37044,37046,37053,37068,37054,37059,37060,37061,37063,37064,37077,37079,37080,37081,37084,37085,37087,37093,37074,37110,37099,37103,37104,37108,37118,37119,37120,37124,37125,37126,37128,37133,37136,37140,37142,37143,37144,37146,37148,37150,37152,37157,37154,37155,37159,37161,37166,37167,37169,37172,37174,37175,37177,37178,37180,37181,37187,37191,37192,37199,37203,37207,37209,37210,37211,37217,37220,37223,37229,37236,37241,37242,37243,37249,37251,37253,37254,37258,37262,37265,37267,37268,37269,37272,37278,37281,37286,37288,37292,37293,37294,37296,37297,37298,37299,37302,37307,37308,37309,37311,37314,37315,37317,37331,37332,37335,37337,37338,37342,37348,37349,37353,37354,37356,37357,37358,37359,37360,37361,37367,37369,37371,37373,37376,37377,37380,37381,37382,37383,37385,37386,37388,37392,37394,37395,37398,37400,37404,37405,37411,37412,37413,37414,37416,37422,37423,37424,37427,37429,37430,37432,37433,37434,37436,37438,37440,37442,37443,37446,37447,37450,37453,37454,37455,37457,37464,37465,37468,37469,37472,37473,37477,37479,37480,37481,37486,37487,37488,37493,37494,37495,37496,37497,37499,37500,37501,37503,37512,37513,37514,37517,37518,37522,37527,37529,37535,37536,37540,37541,37543,37544,37547,37551,37554,37558,37560,37562,37563,37564,37565,37567,37568,37569,37570,37571,37573,37574,37575,37576,37579,37580,37581,37582,37584,37587,37589,37591,37592,37593,37596,37597,37599,37600,37601,37603,37605,37607,37608,37612,37614,37616,37625,37627,37631,37632,37634,37640,37645,37649,37652,37653,37660,37661,37662,37663,37665,37668,37669,37671,37673,37674,37683,37684,37686,37687,37703,37704,37705,37712,37713,37714,37717,37719,37720,37722,37726,37732,37733,37735,37737,37738,37741,37743,37744,37745,37747,37748,37750,37754,37757,37759,37760,37761,37762,37768,37770,37771,37773,37775,37778,37781,37784,37787,37790,37793,37795,37796,37798,37800,37803,37812,37813,37814,37818,37801,37825,37828,37829,37830,37831,37833,37834,37835,37836,37837,37843,37849,37852,37854,37855,37858,37862,37863,37881,37879,37880,37882,37883,37885,37889,37890,37892,37896,37897,37901,37902,37903,37909,37910,37911,37919,37934,37935,37937,37938,37939,37940,37947,37951,37949,37955,37957,37960,37962,37964,37973,37977,37980,37983,37985,37987,37992,37995,37997,37998,37999,38001,38002,38020,38019,38264,38265,38270,38276,38280,38284,38285,38286,38301,38302,38303,38305,38310,38313,38315,38316,38324,38326,38330,38333,38335,38342,38344,38345,38347,38352,38353,38354,38355,38361,38362,38365,38366,38367,38368,38372,38374,38429,38430,38434,38436,38437,38438,38444,38449,38451,38455,38456,38457,38458,38460,38461,38465,38482,38484,38486,38487,38488,38497,38510,38516,38523,38524,38526,38527,38529,38530,38531,38532,38537,38545,38550,38554,38557,38559,38564,38565,38566,38569,38574,38575,38579,38586,38602,38610,23986,38616,38618,38621,38622,38623,38633,38639,38641,38650,38658,38659,38661,38665,38682,38683,38685,38689,38690,38691,38696,38705,38707,38721,38723,38730,38734,38735,38741,38743,38744,38746,38747,38755,38759,38762,38766,38771,38774,38775,38776,38779,38781,38783,38784,38793,38805,38806,38807,38809,38810,38814,38815,38818,38828,38830,38833,38834,38837,38838,38840,38841,38842,38844,38846,38847,38849,38852,38853,38855,38857,38858,38860,38861,38862,38864,38865,38868,38871,38872,38873,38877,38878,38880,38875,38881,38884,38895,38897,38900,38903,38904,38906,38919,38922,38937,38925,38926,38932,38934,38940,38942,38944,38947,38950,38955,38958,38959,38960,38962,38963,38965,38949,38974,38980,38983,38986,38993,38994,38995,38998,38999,39001,39002,39010,39011,39013,39014,39018,39020,39083,39085,39086,39088,39092,39095,39096,39098,39099,39103,39106,39109,39112,39116,39137,39139,39141,39142,39143,39146,39155,39158,39170,39175,39176,39185,39189,39190,39191,39194,39195,39196,39199,39202,39206,39207,39211,39217,39218,39219,39220,39221,39225,39226,39227,39228,39232,39233,39238,39239,39240,39245,39246,39252,39256,39257,39259,39260,39262,39263,39264,39323,39325,39327,39334,39344,39345,39346,39349,39353,39354,39357,39359,39363,39369,39379,39380,39385,39386,39388,39390,39399,39402,39403,39404,39408,39412,39413,39417,39421,39422,39426,39427,39428,39435,39436,39440,39441,39446,39454,39456,39458,39459,39460,39463,39469,39470,39475,39477,39478,39480,39495,39489,39492,39498,39499,39500,39502,39505,39508,39510,39517,39594,39596,39598,39599,39602,39604,39605,39606,39609,39611,39614,39615,39617,39619,39622,39624,39630,39632,39634,39637,39638,39639,39643,39644,39648,39652,39653,39655,39657,39660,39666,39667,39669,39673,39674,39677,39679,39680,39681,39682,39683,39684,39685,39688,39689,39691,39692,39693,39694,39696,39698,39702,39705,39707,39708,39712,39718,39723,39725,39731,39732,39733,39735,39737,39738,39741,39752,39755,39756,39765,39766,39767,39771,39774,39777,39779,39781,39782,39784,39786,39787,39788,39789,39790,39795,39797,39799,39800,39801,39807,39808,39812,39813,39814,39815,39817,39818,39819,39821,39823,39824,39828,39834,39837,39838,39846,39847,39849,39852,39856,39857,39858,39863,39864,39867,39868,39870,39871,39873,39879,39880,39886,39888,39895,39896,39901,39903,39909,39911,39914,39915,39919,39923,39927,39928,39929,39930,39933,39935,39936,39938,39947,39951,39953,39958,39960,39961,39962,39964,39966,39970,39971,39974,39975,39976,39977,39978,39985,39989,39990,39991,39997,40001,40003,40004,40005,40009,40010,40014,40015,40016,40019,40020,40022,40024,40027,40029,40030,40031,40035,40041,40042,40028,40043,40040,40046,40048,40050,40053,40055,40059,40166,40178,40183,40185,40203,40194,40209,40215,40216,40220,40221,40222,40239,40240,40242,40243,40244,40250,40252,40261,40253,40258,40259,40263,40266,40275,40276,40287,40291,40290,40293,40297,40298,40299,40304,40310,40311,40315,40316,40318,40323,40324,40326,40330,40333,40334,40338,40339,40341,40342,40343,40344,40353,40362,40364,40366,40369,40373,40377,40380,40383,40387,40391,40393,40394,40404,40405,40406,40407,40410,40414,40415,40416,40421,40423,40425,40427,40430,40432,40435,40436,40446,40458,40450,40455,40462,40464,40465,40466,40469,40470,40473,40476,40477,40570,40571,40572,40576,40578,40579,40580,40581,40583,40590,40591,40598,40600,40603,40606,40612,40616,40620,40622,40623,40624,40627,40628,40629,40646,40648,40651,40661,40671,40676,40679,40684,40685,40686,40688,40689,40690,40693,40696,40703,40706,40707,40713,40719,40720,40721,40722,40724,40726,40727,40729,40730,40731,40735,40738,40742,40746,40747,40751,40753,40754,40756,40759,40761,40762,40764,40765,40767,40769,40771,40772,40773,40774,40775,40787,40789,40790,40791,40792,40794,40797,40798,40808,40809,40813,40814,40815,40816,40817,40819,40821,40826,40829,40847,40848,40849,40850,40852,40854,40855,40862,40865,40866,40867,40869,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],
27017 "ibm866":[1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488,9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575,9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103,1025,1105,1028,1108,1031,1111,1038,1118,176,8729,183,8730,8470,164,9632,160],
27018 "iso-8859-2":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,260,728,321,164,317,346,167,168,352,350,356,377,173,381,379,176,261,731,322,180,318,347,711,184,353,351,357,378,733,382,380,340,193,194,258,196,313,262,199,268,201,280,203,282,205,206,270,272,323,327,211,212,336,214,215,344,366,218,368,220,221,354,223,341,225,226,259,228,314,263,231,269,233,281,235,283,237,238,271,273,324,328,243,244,337,246,247,345,367,250,369,252,253,355,729],
27019 "iso-8859-3":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,294,728,163,164,null,292,167,168,304,350,286,308,173,null,379,176,295,178,179,180,181,293,183,184,305,351,287,309,189,null,380,192,193,194,null,196,266,264,199,200,201,202,203,204,205,206,207,null,209,210,211,212,288,214,215,284,217,218,219,220,364,348,223,224,225,226,null,228,267,265,231,232,233,234,235,236,237,238,239,null,241,242,243,244,289,246,247,285,249,250,251,252,365,349,729],
27020 "iso-8859-4":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,260,312,342,164,296,315,167,168,352,274,290,358,173,381,175,176,261,731,343,180,297,316,711,184,353,275,291,359,330,382,331,256,193,194,195,196,197,198,302,268,201,280,203,278,205,206,298,272,325,332,310,212,213,214,215,216,370,218,219,220,360,362,223,257,225,226,227,228,229,230,303,269,233,281,235,279,237,238,299,273,326,333,311,244,245,246,247,248,371,250,251,252,361,363,729],
27021 "iso-8859-5":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,1025,1026,1027,1028,1029,1030,1031,1032,1033,1034,1035,1036,173,1038,1039,1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103,8470,1105,1106,1107,1108,1109,1110,1111,1112,1113,1114,1115,1116,167,1118,1119],
27022 "iso-8859-6":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,null,null,null,164,null,null,null,null,null,null,null,1548,173,null,null,null,null,null,null,null,null,null,null,null,null,null,1563,null,null,null,1567,null,1569,1570,1571,1572,1573,1574,1575,1576,1577,1578,1579,1580,1581,1582,1583,1584,1585,1586,1587,1588,1589,1590,1591,1592,1593,1594,null,null,null,null,null,1600,1601,1602,1603,1604,1605,1606,1607,1608,1609,1610,1611,1612,1613,1614,1615,1616,1617,1618,null,null,null,null,null,null,null,null,null,null,null,null,null],
27023 "iso-8859-7":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,8216,8217,163,8364,8367,166,167,168,169,890,171,172,173,null,8213,176,177,178,179,900,901,902,183,904,905,906,187,908,189,910,911,912,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,null,931,932,933,934,935,936,937,938,939,940,941,942,943,944,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960,961,962,963,964,965,966,967,968,969,970,971,972,973,974,null],
27024 "iso-8859-8":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,null,162,163,164,165,166,167,168,169,215,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,247,187,188,189,190,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,8215,1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1501,1502,1503,1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,null,null,8206,8207,null],
27025 "iso-8859-10":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,260,274,290,298,296,310,167,315,272,352,358,381,173,362,330,176,261,275,291,299,297,311,183,316,273,353,359,382,8213,363,331,256,193,194,195,196,197,198,302,268,201,280,203,278,205,206,207,208,325,332,211,212,213,214,360,216,370,218,219,220,221,222,223,257,225,226,227,228,229,230,303,269,233,281,235,279,237,238,239,240,326,333,243,244,245,246,361,248,371,250,251,252,253,254,312],
27026 "iso-8859-13":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,8221,162,163,164,8222,166,167,216,169,342,171,172,173,174,198,176,177,178,179,8220,181,182,183,248,185,343,187,188,189,190,230,260,302,256,262,196,197,280,274,268,201,377,278,290,310,298,315,352,323,325,211,332,213,214,215,370,321,346,362,220,379,381,223,261,303,257,263,228,229,281,275,269,233,378,279,291,311,299,316,353,324,326,243,333,245,246,247,371,322,347,363,252,380,382,8217],
27027 "iso-8859-14":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,7682,7683,163,266,267,7690,167,7808,169,7810,7691,7922,173,174,376,7710,7711,288,289,7744,7745,182,7766,7809,7767,7811,7776,7923,7812,7813,7777,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,372,209,210,211,212,213,214,7786,216,217,218,219,220,221,374,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,373,241,242,243,244,245,246,7787,248,249,250,251,252,253,375,255],
27028 "iso-8859-15":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,8364,165,352,167,353,169,170,171,172,173,174,175,176,177,178,179,381,181,182,183,382,185,186,187,338,339,376,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255],
27029 "iso-8859-16":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,260,261,321,8364,8222,352,167,353,169,536,171,377,173,378,379,176,177,268,322,381,8221,182,183,382,269,537,187,338,339,376,380,192,193,194,258,196,262,198,199,200,201,202,203,204,205,206,207,272,323,210,211,212,336,214,346,368,217,218,219,220,280,538,223,224,225,226,259,228,263,230,231,232,233,234,235,236,237,238,239,273,324,242,243,244,337,246,347,369,249,250,251,252,281,539,255],
27030 "koi8-r":[9472,9474,9484,9488,9492,9496,9500,9508,9516,9524,9532,9600,9604,9608,9612,9616,9617,9618,9619,8992,9632,8729,8730,8776,8804,8805,160,8993,176,178,183,247,9552,9553,9554,1105,9555,9556,9557,9558,9559,9560,9561,9562,9563,9564,9565,9566,9567,9568,9569,1025,9570,9571,9572,9573,9574,9575,9576,9577,9578,9579,9580,169,1102,1072,1073,1094,1076,1077,1092,1075,1093,1080,1081,1082,1083,1084,1085,1086,1087,1103,1088,1089,1090,1091,1078,1074,1100,1099,1079,1096,1101,1097,1095,1098,1070,1040,1041,1062,1044,1045,1060,1043,1061,1048,1049,1050,1051,1052,1053,1054,1055,1071,1056,1057,1058,1059,1046,1042,1068,1067,1047,1064,1069,1065,1063,1066],
27031 "koi8-u":[9472,9474,9484,9488,9492,9496,9500,9508,9516,9524,9532,9600,9604,9608,9612,9616,9617,9618,9619,8992,9632,8729,8730,8776,8804,8805,160,8993,176,178,183,247,9552,9553,9554,1105,1108,9556,1110,1111,9559,9560,9561,9562,9563,1169,1118,9566,9567,9568,9569,1025,1028,9571,1030,1031,9574,9575,9576,9577,9578,1168,1038,169,1102,1072,1073,1094,1076,1077,1092,1075,1093,1080,1081,1082,1083,1084,1085,1086,1087,1103,1088,1089,1090,1091,1078,1074,1100,1099,1079,1096,1101,1097,1095,1098,1070,1040,1041,1062,1044,1045,1060,1043,1061,1048,1049,1050,1051,1052,1053,1054,1055,1071,1056,1057,1058,1059,1046,1042,1068,1067,1047,1064,1069,1065,1063,1066],
27032 "macintosh":[196,197,199,201,209,214,220,225,224,226,228,227,229,231,233,232,234,235,237,236,238,239,241,243,242,244,246,245,250,249,251,252,8224,176,162,163,167,8226,182,223,174,169,8482,180,168,8800,198,216,8734,177,8804,8805,165,181,8706,8721,8719,960,8747,170,186,937,230,248,191,161,172,8730,402,8776,8710,171,187,8230,160,192,195,213,338,339,8211,8212,8220,8221,8216,8217,247,9674,255,376,8260,8364,8249,8250,64257,64258,8225,183,8218,8222,8240,194,202,193,203,200,205,206,207,204,211,212,63743,210,218,219,217,305,710,732,175,728,729,730,184,733,731,711],
27033 "windows-874":[8364,129,130,131,132,8230,134,135,136,137,138,139,140,141,142,143,144,8216,8217,8220,8221,8226,8211,8212,152,153,154,155,156,157,158,159,160,3585,3586,3587,3588,3589,3590,3591,3592,3593,3594,3595,3596,3597,3598,3599,3600,3601,3602,3603,3604,3605,3606,3607,3608,3609,3610,3611,3612,3613,3614,3615,3616,3617,3618,3619,3620,3621,3622,3623,3624,3625,3626,3627,3628,3629,3630,3631,3632,3633,3634,3635,3636,3637,3638,3639,3640,3641,3642,null,null,null,null,3647,3648,3649,3650,3651,3652,3653,3654,3655,3656,3657,3658,3659,3660,3661,3662,3663,3664,3665,3666,3667,3668,3669,3670,3671,3672,3673,3674,3675,null,null,null,null],
27034 "windows-1250":[8364,129,8218,131,8222,8230,8224,8225,136,8240,352,8249,346,356,381,377,144,8216,8217,8220,8221,8226,8211,8212,152,8482,353,8250,347,357,382,378,160,711,728,321,164,260,166,167,168,169,350,171,172,173,174,379,176,177,731,322,180,181,182,183,184,261,351,187,317,733,318,380,340,193,194,258,196,313,262,199,268,201,280,203,282,205,206,270,272,323,327,211,212,336,214,215,344,366,218,368,220,221,354,223,341,225,226,259,228,314,263,231,269,233,281,235,283,237,238,271,273,324,328,243,244,337,246,247,345,367,250,369,252,253,355,729],
27035 "windows-1251":[1026,1027,8218,1107,8222,8230,8224,8225,8364,8240,1033,8249,1034,1036,1035,1039,1106,8216,8217,8220,8221,8226,8211,8212,152,8482,1113,8250,1114,1116,1115,1119,160,1038,1118,1032,164,1168,166,167,1025,169,1028,171,172,173,174,1031,176,177,1030,1110,1169,181,182,183,1105,8470,1108,187,1112,1029,1109,1111,1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103],
27036 "windows-1252":[8364,129,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,141,381,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,157,382,376,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255],
27037 "windows-1253":[8364,129,8218,402,8222,8230,8224,8225,136,8240,138,8249,140,141,142,143,144,8216,8217,8220,8221,8226,8211,8212,152,8482,154,8250,156,157,158,159,160,901,902,163,164,165,166,167,168,169,null,171,172,173,174,8213,176,177,178,179,900,181,182,183,904,905,906,187,908,189,910,911,912,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,null,931,932,933,934,935,936,937,938,939,940,941,942,943,944,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960,961,962,963,964,965,966,967,968,969,970,971,972,973,974,null],
27038 "windows-1254":[8364,129,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,141,142,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,157,158,376,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,286,209,210,211,212,213,214,215,216,217,218,219,220,304,350,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,287,241,242,243,244,245,246,247,248,249,250,251,252,305,351,255],
27039 "windows-1255":[8364,129,8218,402,8222,8230,8224,8225,710,8240,138,8249,140,141,142,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,154,8250,156,157,158,159,160,161,162,163,8362,165,166,167,168,169,215,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,247,187,188,189,190,191,1456,1457,1458,1459,1460,1461,1462,1463,1464,1465,null,1467,1468,1469,1470,1471,1472,1473,1474,1475,1520,1521,1522,1523,1524,null,null,null,null,null,null,null,1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1501,1502,1503,1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,null,null,8206,8207,null],
27040 "windows-1256":[8364,1662,8218,402,8222,8230,8224,8225,710,8240,1657,8249,338,1670,1688,1672,1711,8216,8217,8220,8221,8226,8211,8212,1705,8482,1681,8250,339,8204,8205,1722,160,1548,162,163,164,165,166,167,168,169,1726,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,1563,187,188,189,190,1567,1729,1569,1570,1571,1572,1573,1574,1575,1576,1577,1578,1579,1580,1581,1582,1583,1584,1585,1586,1587,1588,1589,1590,215,1591,1592,1593,1594,1600,1601,1602,1603,224,1604,226,1605,1606,1607,1608,231,232,233,234,235,1609,1610,238,239,1611,1612,1613,1614,244,1615,1616,247,1617,249,1618,251,252,8206,8207,1746],
27041 "windows-1257":[8364,129,8218,131,8222,8230,8224,8225,136,8240,138,8249,140,168,711,184,144,8216,8217,8220,8221,8226,8211,8212,152,8482,154,8250,156,175,731,159,160,null,162,163,164,null,166,167,216,169,342,171,172,173,174,198,176,177,178,179,180,181,182,183,248,185,343,187,188,189,190,230,260,302,256,262,196,197,280,274,268,201,377,278,290,310,298,315,352,323,325,211,332,213,214,215,370,321,346,362,220,379,381,223,261,303,257,263,228,229,281,275,269,233,378,279,291,311,299,316,353,324,326,243,333,245,246,247,371,322,347,363,252,380,382,729],
27042 "windows-1258":[8364,129,8218,402,8222,8230,8224,8225,710,8240,138,8249,338,141,142,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,154,8250,339,157,158,376,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,258,196,197,198,199,200,201,202,203,768,205,206,207,272,209,777,211,212,416,214,215,216,217,218,219,220,431,771,223,224,225,226,259,228,229,230,231,232,233,234,235,769,237,238,239,273,241,803,243,244,417,246,247,248,249,250,251,252,432,8363,255],
27043 "x-mac-cyrillic":[1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,8224,176,1168,163,167,8226,182,1030,174,169,8482,1026,1106,8800,1027,1107,8734,177,8804,8805,1110,181,1169,1032,1028,1108,1031,1111,1033,1113,1034,1114,1112,1029,172,8730,402,8776,8710,171,187,8230,160,1035,1115,1036,1116,1109,8211,8212,8220,8221,8216,8217,247,8222,1038,1118,1039,1119,8470,1025,1105,1103,1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,8364]
27044};
27045}(this));
27046
27047},{}],321:[function(require,module,exports){
27048// This is free and unencumbered software released into the public domain.
27049// See LICENSE.md for more information.
27050
27051// If we're in node require encoding-indexes and attach it to the global.
27052/**
27053 * @fileoverview Global |this| required for resolving indexes in node.
27054 * @suppress {globalThis}
27055 */
27056if (typeof module !== "undefined" && module.exports) {
27057 this["encoding-indexes"] =
27058 require("./encoding-indexes.js")["encoding-indexes"];
27059}
27060
27061(function(global) {
27062 'use strict';
27063
27064 //
27065 // Utilities
27066 //
27067
27068 /**
27069 * @param {number} a The number to test.
27070 * @param {number} min The minimum value in the range, inclusive.
27071 * @param {number} max The maximum value in the range, inclusive.
27072 * @return {boolean} True if a >= min and a <= max.
27073 */
27074 function inRange(a, min, max) {
27075 return min <= a && a <= max;
27076 }
27077
27078 /**
27079 * @param {number} n The numerator.
27080 * @param {number} d The denominator.
27081 * @return {number} The result of the integer division of n by d.
27082 */
27083 function div(n, d) {
27084 return Math.floor(n / d);
27085 }
27086
27087 /**
27088 * @param {*} o
27089 * @return {Object}
27090 */
27091 function ToDictionary(o) {
27092 if (o === undefined) return {};
27093 if (o === Object(o)) return o;
27094 throw TypeError('Could not convert argument to dictionary');
27095 }
27096
27097 /**
27098 * @param {string} string Input string of UTF-16 code units.
27099 * @return {!Array.<number>} Code points.
27100 */
27101 function stringToCodePoints(string) {
27102 // https://heycam.github.io/webidl/#dfn-obtain-unicode
27103
27104 // 1. Let S be the DOMString value.
27105 var s = String(string);
27106
27107 // 2. Let n be the length of S.
27108 var n = s.length;
27109
27110 // 3. Initialize i to 0.
27111 var i = 0;
27112
27113 // 4. Initialize U to be an empty sequence of Unicode characters.
27114 var u = [];
27115
27116 // 5. While i < n:
27117 while (i < n) {
27118
27119 // 1. Let c be the code unit in S at index i.
27120 var c = s.charCodeAt(i);
27121
27122 // 2. Depending on the value of c:
27123
27124 // c < 0xD800 or c > 0xDFFF
27125 if (c < 0xD800 || c > 0xDFFF) {
27126 // Append to U the Unicode character with code point c.
27127 u.push(c);
27128 }
27129
27130 // 0xDC00 ≤ c ≤ 0xDFFF
27131 else if (0xDC00 <= c && c <= 0xDFFF) {
27132 // Append to U a U+FFFD REPLACEMENT CHARACTER.
27133 u.push(0xFFFD);
27134 }
27135
27136 // 0xD800 ≤ c ≤ 0xDBFF
27137 else if (0xD800 <= c && c <= 0xDBFF) {
27138 // 1. If i = n−1, then append to U a U+FFFD REPLACEMENT
27139 // CHARACTER.
27140 if (i === n - 1) {
27141 u.push(0xFFFD);
27142 }
27143 // 2. Otherwise, i < n−1:
27144 else {
27145 // 1. Let d be the code unit in S at index i+1.
27146 var d = string.charCodeAt(i + 1);
27147
27148 // 2. If 0xDC00 ≤ d ≤ 0xDFFF, then:
27149 if (0xDC00 <= d && d <= 0xDFFF) {
27150 // 1. Let a be c & 0x3FF.
27151 var a = c & 0x3FF;
27152
27153 // 2. Let b be d & 0x3FF.
27154 var b = d & 0x3FF;
27155
27156 // 3. Append to U the Unicode character with code point
27157 // 2^16+2^10*a+b.
27158 u.push(0x10000 + (a << 10) + b);
27159
27160 // 4. Set i to i+1.
27161 i += 1;
27162 }
27163
27164 // 3. Otherwise, d < 0xDC00 or d > 0xDFFF. Append to U a
27165 // U+FFFD REPLACEMENT CHARACTER.
27166 else {
27167 u.push(0xFFFD);
27168 }
27169 }
27170 }
27171
27172 // 3. Set i to i+1.
27173 i += 1;
27174 }
27175
27176 // 6. Return U.
27177 return u;
27178 }
27179
27180 /**
27181 * @param {!Array.<number>} code_points Array of code points.
27182 * @return {string} string String of UTF-16 code units.
27183 */
27184 function codePointsToString(code_points) {
27185 var s = '';
27186 for (var i = 0; i < code_points.length; ++i) {
27187 var cp = code_points[i];
27188 if (cp <= 0xFFFF) {
27189 s += String.fromCharCode(cp);
27190 } else {
27191 cp -= 0x10000;
27192 s += String.fromCharCode((cp >> 10) + 0xD800,
27193 (cp & 0x3FF) + 0xDC00);
27194 }
27195 }
27196 return s;
27197 }
27198
27199
27200 //
27201 // Implementation of Encoding specification
27202 // https://encoding.spec.whatwg.org/
27203 //
27204
27205 //
27206 // 3. Terminology
27207 //
27208
27209 /**
27210 * End-of-stream is a special token that signifies no more tokens
27211 * are in the stream.
27212 * @const
27213 */ var end_of_stream = -1;
27214
27215 /**
27216 * A stream represents an ordered sequence of tokens.
27217 *
27218 * @constructor
27219 * @param {!(Array.<number>|Uint8Array)} tokens Array of tokens that provide the
27220 * stream.
27221 */
27222 function Stream(tokens) {
27223 /** @type {!Array.<number>} */
27224 this.tokens = [].slice.call(tokens);
27225 }
27226
27227 Stream.prototype = {
27228 /**
27229 * @return {boolean} True if end-of-stream has been hit.
27230 */
27231 endOfStream: function() {
27232 return !this.tokens.length;
27233 },
27234
27235 /**
27236 * When a token is read from a stream, the first token in the
27237 * stream must be returned and subsequently removed, and
27238 * end-of-stream must be returned otherwise.
27239 *
27240 * @return {number} Get the next token from the stream, or
27241 * end_of_stream.
27242 */
27243 read: function() {
27244 if (!this.tokens.length)
27245 return end_of_stream;
27246 return this.tokens.shift();
27247 },
27248
27249 /**
27250 * When one or more tokens are prepended to a stream, those tokens
27251 * must be inserted, in given order, before the first token in the
27252 * stream.
27253 *
27254 * @param {(number|!Array.<number>)} token The token(s) to prepend to the stream.
27255 */
27256 prepend: function(token) {
27257 if (Array.isArray(token)) {
27258 var tokens = /**@type {!Array.<number>}*/(token);
27259 while (tokens.length)
27260 this.tokens.unshift(tokens.pop());
27261 } else {
27262 this.tokens.unshift(token);
27263 }
27264 },
27265
27266 /**
27267 * When one or more tokens are pushed to a stream, those tokens
27268 * must be inserted, in given order, after the last token in the
27269 * stream.
27270 *
27271 * @param {(number|!Array.<number>)} token The tokens(s) to prepend to the stream.
27272 */
27273 push: function(token) {
27274 if (Array.isArray(token)) {
27275 var tokens = /**@type {!Array.<number>}*/(token);
27276 while (tokens.length)
27277 this.tokens.push(tokens.shift());
27278 } else {
27279 this.tokens.push(token);
27280 }
27281 }
27282 };
27283
27284 //
27285 // 4. Encodings
27286 //
27287
27288 // 4.1 Encoders and decoders
27289
27290 /** @const */
27291 var finished = -1;
27292
27293 /**
27294 * @param {boolean} fatal If true, decoding errors raise an exception.
27295 * @param {number=} opt_code_point Override the standard fallback code point.
27296 * @return {number} The code point to insert on a decoding error.
27297 */
27298 function decoderError(fatal, opt_code_point) {
27299 if (fatal)
27300 throw TypeError('Decoder error');
27301 return opt_code_point || 0xFFFD;
27302 }
27303
27304 /**
27305 * @param {number} code_point The code point that could not be encoded.
27306 * @return {number} Always throws, no value is actually returned.
27307 */
27308 function encoderError(code_point) {
27309 throw TypeError('The code point ' + code_point + ' could not be encoded.');
27310 }
27311
27312 /** @interface */
27313 function Decoder() {}
27314 Decoder.prototype = {
27315 /**
27316 * @param {Stream} stream The stream of bytes being decoded.
27317 * @param {number} bite The next byte read from the stream.
27318 * @return {?(number|!Array.<number>)} The next code point(s)
27319 * decoded, or null if not enough data exists in the input
27320 * stream to decode a complete code point, or |finished|.
27321 */
27322 handler: function(stream, bite) {}
27323 };
27324
27325 /** @interface */
27326 function Encoder() {}
27327 Encoder.prototype = {
27328 /**
27329 * @param {Stream} stream The stream of code points being encoded.
27330 * @param {number} code_point Next code point read from the stream.
27331 * @return {(number|!Array.<number>)} Byte(s) to emit, or |finished|.
27332 */
27333 handler: function(stream, code_point) {}
27334 };
27335
27336 // 4.2 Names and labels
27337
27338 // TODO: Define @typedef for Encoding: {name:string,labels:Array.<string>}
27339 // https://github.com/google/closure-compiler/issues/247
27340
27341 /**
27342 * @param {string} label The encoding label.
27343 * @return {?{name:string,labels:Array.<string>}}
27344 */
27345 function getEncoding(label) {
27346 // 1. Remove any leading and trailing ASCII whitespace from label.
27347 label = String(label).trim().toLowerCase();
27348
27349 // 2. If label is an ASCII case-insensitive match for any of the
27350 // labels listed in the table below, return the corresponding
27351 // encoding, and failure otherwise.
27352 if (Object.prototype.hasOwnProperty.call(label_to_encoding, label)) {
27353 return label_to_encoding[label];
27354 }
27355 return null;
27356 }
27357
27358 /**
27359 * Encodings table: https://encoding.spec.whatwg.org/encodings.json
27360 * @const
27361 * @type {!Array.<{
27362 * heading: string,
27363 * encodings: Array.<{name:string,labels:Array.<string>}>
27364 * }>}
27365 */
27366 var encodings = [
27367 {
27368 "encodings": [
27369 {
27370 "labels": [
27371 "unicode-1-1-utf-8",
27372 "utf-8",
27373 "utf8"
27374 ],
27375 "name": "utf-8"
27376 }
27377 ],
27378 "heading": "The Encoding"
27379 },
27380 {
27381 "encodings": [
27382 {
27383 "labels": [
27384 "866",
27385 "cp866",
27386 "csibm866",
27387 "ibm866"
27388 ],
27389 "name": "ibm866"
27390 },
27391 {
27392 "labels": [
27393 "csisolatin2",
27394 "iso-8859-2",
27395 "iso-ir-101",
27396 "iso8859-2",
27397 "iso88592",
27398 "iso_8859-2",
27399 "iso_8859-2:1987",
27400 "l2",
27401 "latin2"
27402 ],
27403 "name": "iso-8859-2"
27404 },
27405 {
27406 "labels": [
27407 "csisolatin3",
27408 "iso-8859-3",
27409 "iso-ir-109",
27410 "iso8859-3",
27411 "iso88593",
27412 "iso_8859-3",
27413 "iso_8859-3:1988",
27414 "l3",
27415 "latin3"
27416 ],
27417 "name": "iso-8859-3"
27418 },
27419 {
27420 "labels": [
27421 "csisolatin4",
27422 "iso-8859-4",
27423 "iso-ir-110",
27424 "iso8859-4",
27425 "iso88594",
27426 "iso_8859-4",
27427 "iso_8859-4:1988",
27428 "l4",
27429 "latin4"
27430 ],
27431 "name": "iso-8859-4"
27432 },
27433 {
27434 "labels": [
27435 "csisolatincyrillic",
27436 "cyrillic",
27437 "iso-8859-5",
27438 "iso-ir-144",
27439 "iso8859-5",
27440 "iso88595",
27441 "iso_8859-5",
27442 "iso_8859-5:1988"
27443 ],
27444 "name": "iso-8859-5"
27445 },
27446 {
27447 "labels": [
27448 "arabic",
27449 "asmo-708",
27450 "csiso88596e",
27451 "csiso88596i",
27452 "csisolatinarabic",
27453 "ecma-114",
27454 "iso-8859-6",
27455 "iso-8859-6-e",
27456 "iso-8859-6-i",
27457 "iso-ir-127",
27458 "iso8859-6",
27459 "iso88596",
27460 "iso_8859-6",
27461 "iso_8859-6:1987"
27462 ],
27463 "name": "iso-8859-6"
27464 },
27465 {
27466 "labels": [
27467 "csisolatingreek",
27468 "ecma-118",
27469 "elot_928",
27470 "greek",
27471 "greek8",
27472 "iso-8859-7",
27473 "iso-ir-126",
27474 "iso8859-7",
27475 "iso88597",
27476 "iso_8859-7",
27477 "iso_8859-7:1987",
27478 "sun_eu_greek"
27479 ],
27480 "name": "iso-8859-7"
27481 },
27482 {
27483 "labels": [
27484 "csiso88598e",
27485 "csisolatinhebrew",
27486 "hebrew",
27487 "iso-8859-8",
27488 "iso-8859-8-e",
27489 "iso-ir-138",
27490 "iso8859-8",
27491 "iso88598",
27492 "iso_8859-8",
27493 "iso_8859-8:1988",
27494 "visual"
27495 ],
27496 "name": "iso-8859-8"
27497 },
27498 {
27499 "labels": [
27500 "csiso88598i",
27501 "iso-8859-8-i",
27502 "logical"
27503 ],
27504 "name": "iso-8859-8-i"
27505 },
27506 {
27507 "labels": [
27508 "csisolatin6",
27509 "iso-8859-10",
27510 "iso-ir-157",
27511 "iso8859-10",
27512 "iso885910",
27513 "l6",
27514 "latin6"
27515 ],
27516 "name": "iso-8859-10"
27517 },
27518 {
27519 "labels": [
27520 "iso-8859-13",
27521 "iso8859-13",
27522 "iso885913"
27523 ],
27524 "name": "iso-8859-13"
27525 },
27526 {
27527 "labels": [
27528 "iso-8859-14",
27529 "iso8859-14",
27530 "iso885914"
27531 ],
27532 "name": "iso-8859-14"
27533 },
27534 {
27535 "labels": [
27536 "csisolatin9",
27537 "iso-8859-15",
27538 "iso8859-15",
27539 "iso885915",
27540 "iso_8859-15",
27541 "l9"
27542 ],
27543 "name": "iso-8859-15"
27544 },
27545 {
27546 "labels": [
27547 "iso-8859-16"
27548 ],
27549 "name": "iso-8859-16"
27550 },
27551 {
27552 "labels": [
27553 "cskoi8r",
27554 "koi",
27555 "koi8",
27556 "koi8-r",
27557 "koi8_r"
27558 ],
27559 "name": "koi8-r"
27560 },
27561 {
27562 "labels": [
27563 "koi8-ru",
27564 "koi8-u"
27565 ],
27566 "name": "koi8-u"
27567 },
27568 {
27569 "labels": [
27570 "csmacintosh",
27571 "mac",
27572 "macintosh",
27573 "x-mac-roman"
27574 ],
27575 "name": "macintosh"
27576 },
27577 {
27578 "labels": [
27579 "dos-874",
27580 "iso-8859-11",
27581 "iso8859-11",
27582 "iso885911",
27583 "tis-620",
27584 "windows-874"
27585 ],
27586 "name": "windows-874"
27587 },
27588 {
27589 "labels": [
27590 "cp1250",
27591 "windows-1250",
27592 "x-cp1250"
27593 ],
27594 "name": "windows-1250"
27595 },
27596 {
27597 "labels": [
27598 "cp1251",
27599 "windows-1251",
27600 "x-cp1251"
27601 ],
27602 "name": "windows-1251"
27603 },
27604 {
27605 "labels": [
27606 "ansi_x3.4-1968",
27607 "ascii",
27608 "cp1252",
27609 "cp819",
27610 "csisolatin1",
27611 "ibm819",
27612 "iso-8859-1",
27613 "iso-ir-100",
27614 "iso8859-1",
27615 "iso88591",
27616 "iso_8859-1",
27617 "iso_8859-1:1987",
27618 "l1",
27619 "latin1",
27620 "us-ascii",
27621 "windows-1252",
27622 "x-cp1252"
27623 ],
27624 "name": "windows-1252"
27625 },
27626 {
27627 "labels": [
27628 "cp1253",
27629 "windows-1253",
27630 "x-cp1253"
27631 ],
27632 "name": "windows-1253"
27633 },
27634 {
27635 "labels": [
27636 "cp1254",
27637 "csisolatin5",
27638 "iso-8859-9",
27639 "iso-ir-148",
27640 "iso8859-9",
27641 "iso88599",
27642 "iso_8859-9",
27643 "iso_8859-9:1989",
27644 "l5",
27645 "latin5",
27646 "windows-1254",
27647 "x-cp1254"
27648 ],
27649 "name": "windows-1254"
27650 },
27651 {
27652 "labels": [
27653 "cp1255",
27654 "windows-1255",
27655 "x-cp1255"
27656 ],
27657 "name": "windows-1255"
27658 },
27659 {
27660 "labels": [
27661 "cp1256",
27662 "windows-1256",
27663 "x-cp1256"
27664 ],
27665 "name": "windows-1256"
27666 },
27667 {
27668 "labels": [
27669 "cp1257",
27670 "windows-1257",
27671 "x-cp1257"
27672 ],
27673 "name": "windows-1257"
27674 },
27675 {
27676 "labels": [
27677 "cp1258",
27678 "windows-1258",
27679 "x-cp1258"
27680 ],
27681 "name": "windows-1258"
27682 },
27683 {
27684 "labels": [
27685 "x-mac-cyrillic",
27686 "x-mac-ukrainian"
27687 ],
27688 "name": "x-mac-cyrillic"
27689 }
27690 ],
27691 "heading": "Legacy single-byte encodings"
27692 },
27693 {
27694 "encodings": [
27695 {
27696 "labels": [
27697 "chinese",
27698 "csgb2312",
27699 "csiso58gb231280",
27700 "gb2312",
27701 "gb_2312",
27702 "gb_2312-80",
27703 "gbk",
27704 "iso-ir-58",
27705 "x-gbk"
27706 ],
27707 "name": "gbk"
27708 },
27709 {
27710 "labels": [
27711 "gb18030"
27712 ],
27713 "name": "gb18030"
27714 }
27715 ],
27716 "heading": "Legacy multi-byte Chinese (simplified) encodings"
27717 },
27718 {
27719 "encodings": [
27720 {
27721 "labels": [
27722 "big5",
27723 "big5-hkscs",
27724 "cn-big5",
27725 "csbig5",
27726 "x-x-big5"
27727 ],
27728 "name": "big5"
27729 }
27730 ],
27731 "heading": "Legacy multi-byte Chinese (traditional) encodings"
27732 },
27733 {
27734 "encodings": [
27735 {
27736 "labels": [
27737 "cseucpkdfmtjapanese",
27738 "euc-jp",
27739 "x-euc-jp"
27740 ],
27741 "name": "euc-jp"
27742 },
27743 {
27744 "labels": [
27745 "csiso2022jp",
27746 "iso-2022-jp"
27747 ],
27748 "name": "iso-2022-jp"
27749 },
27750 {
27751 "labels": [
27752 "csshiftjis",
27753 "ms932",
27754 "ms_kanji",
27755 "shift-jis",
27756 "shift_jis",
27757 "sjis",
27758 "windows-31j",
27759 "x-sjis"
27760 ],
27761 "name": "shift_jis"
27762 }
27763 ],
27764 "heading": "Legacy multi-byte Japanese encodings"
27765 },
27766 {
27767 "encodings": [
27768 {
27769 "labels": [
27770 "cseuckr",
27771 "csksc56011987",
27772 "euc-kr",
27773 "iso-ir-149",
27774 "korean",
27775 "ks_c_5601-1987",
27776 "ks_c_5601-1989",
27777 "ksc5601",
27778 "ksc_5601",
27779 "windows-949"
27780 ],
27781 "name": "euc-kr"
27782 }
27783 ],
27784 "heading": "Legacy multi-byte Korean encodings"
27785 },
27786 {
27787 "encodings": [
27788 {
27789 "labels": [
27790 "csiso2022kr",
27791 "hz-gb-2312",
27792 "iso-2022-cn",
27793 "iso-2022-cn-ext",
27794 "iso-2022-kr"
27795 ],
27796 "name": "replacement"
27797 },
27798 {
27799 "labels": [
27800 "utf-16be"
27801 ],
27802 "name": "utf-16be"
27803 },
27804 {
27805 "labels": [
27806 "utf-16",
27807 "utf-16le"
27808 ],
27809 "name": "utf-16le"
27810 },
27811 {
27812 "labels": [
27813 "x-user-defined"
27814 ],
27815 "name": "x-user-defined"
27816 }
27817 ],
27818 "heading": "Legacy miscellaneous encodings"
27819 }
27820 ];
27821
27822 // Label to encoding registry.
27823 /** @type {Object.<string,{name:string,labels:Array.<string>}>} */
27824 var label_to_encoding = {};
27825 encodings.forEach(function(category) {
27826 category.encodings.forEach(function(encoding) {
27827 encoding.labels.forEach(function(label) {
27828 label_to_encoding[label] = encoding;
27829 });
27830 });
27831 });
27832
27833 // Registry of of encoder/decoder factories, by encoding name.
27834 /** @type {Object.<string, function({fatal:boolean}): Encoder>} */
27835 var encoders = {};
27836 /** @type {Object.<string, function({fatal:boolean}): Decoder>} */
27837 var decoders = {};
27838
27839 //
27840 // 5. Indexes
27841 //
27842
27843 /**
27844 * @param {number} pointer The |pointer| to search for.
27845 * @param {(!Array.<?number>|undefined)} index The |index| to search within.
27846 * @return {?number} The code point corresponding to |pointer| in |index|,
27847 * or null if |code point| is not in |index|.
27848 */
27849 function indexCodePointFor(pointer, index) {
27850 if (!index) return null;
27851 return index[pointer] || null;
27852 }
27853
27854 /**
27855 * @param {number} code_point The |code point| to search for.
27856 * @param {!Array.<?number>} index The |index| to search within.
27857 * @return {?number} The first pointer corresponding to |code point| in
27858 * |index|, or null if |code point| is not in |index|.
27859 */
27860 function indexPointerFor(code_point, index) {
27861 var pointer = index.indexOf(code_point);
27862 return pointer === -1 ? null : pointer;
27863 }
27864
27865 /**
27866 * @param {string} name Name of the index.
27867 * @return {(!Array.<number>|!Array.<Array.<number>>)}
27868 * */
27869 function index(name) {
27870 if (!('encoding-indexes' in global)) {
27871 throw Error("Indexes missing." +
27872 " Did you forget to include encoding-indexes.js?");
27873 }
27874 return global['encoding-indexes'][name];
27875 }
27876
27877 /**
27878 * @param {number} pointer The |pointer| to search for in the gb18030 index.
27879 * @return {?number} The code point corresponding to |pointer| in |index|,
27880 * or null if |code point| is not in the gb18030 index.
27881 */
27882 function indexGB18030RangesCodePointFor(pointer) {
27883 // 1. If pointer is greater than 39419 and less than 189000, or
27884 // pointer is greater than 1237575, return null.
27885 if ((pointer > 39419 && pointer < 189000) || (pointer > 1237575))
27886 return null;
27887
27888 // 2. Let offset be the last pointer in index gb18030 ranges that
27889 // is equal to or less than pointer and let code point offset be
27890 // its corresponding code point.
27891 var offset = 0;
27892 var code_point_offset = 0;
27893 var idx = index('gb18030');
27894 var i;
27895 for (i = 0; i < idx.length; ++i) {
27896 /** @type {!Array.<number>} */
27897 var entry = idx[i];
27898 if (entry[0] <= pointer) {
27899 offset = entry[0];
27900 code_point_offset = entry[1];
27901 } else {
27902 break;
27903 }
27904 }
27905
27906 // 3. Return a code point whose value is code point offset +
27907 // pointer − offset.
27908 return code_point_offset + pointer - offset;
27909 }
27910
27911 /**
27912 * @param {number} code_point The |code point| to locate in the gb18030 index.
27913 * @return {number} The first pointer corresponding to |code point| in the
27914 * gb18030 index.
27915 */
27916 function indexGB18030RangesPointerFor(code_point) {
27917 // 1. Let offset be the last code point in index gb18030 ranges
27918 // that is equal to or less than code point and let pointer offset
27919 // be its corresponding pointer.
27920 var offset = 0;
27921 var pointer_offset = 0;
27922 var idx = index('gb18030');
27923 var i;
27924 for (i = 0; i < idx.length; ++i) {
27925 /** @type {!Array.<number>} */
27926 var entry = idx[i];
27927 if (entry[1] <= code_point) {
27928 offset = entry[1];
27929 pointer_offset = entry[0];
27930 } else {
27931 break;
27932 }
27933 }
27934
27935 // 2. Return a pointer whose value is pointer offset + code point
27936 // − offset.
27937 return pointer_offset + code_point - offset;
27938 }
27939
27940 /**
27941 * @param {number} code_point The |code_point| to search for in the shift_jis index.
27942 * @return {?number} The code point corresponding to |pointer| in |index|,
27943 * or null if |code point| is not in the shift_jis index.
27944 */
27945 function indexShiftJISPointerFor(code_point) {
27946 // 1. Let index be index jis0208 excluding all pointers in the
27947 // range 8272 to 8835.
27948 var pointer = indexPointerFor(code_point, index('jis0208'));
27949 if (pointer === null || inRange(pointer, 8272, 8835))
27950 return null;
27951
27952 // 2. Return the index pointer for code point in index.
27953 return pointer;
27954 }
27955
27956 /**
27957 * @param {number} code_point The |code_point| to search for in the big5 index.
27958 * @return {?number} The code point corresponding to |pointer| in |index|,
27959 * or null if |code point| is not in the big5 index.
27960 */
27961 function indexBig5PointerFor(code_point) {
27962
27963 // 1. Let index be index big5.
27964 var index_ = index('big5');
27965
27966 // 2. If code point is U+2550, U+255E, U+2561, U+256A, U+5341, or
27967 // U+5345, return the last pointer corresponding to code point in
27968 // index.
27969 if (code_point === 0x2550 || code_point === 0x255E ||
27970 code_point === 0x2561 || code_point === 0x256A ||
27971 code_point === 0x5341 || code_point === 0x5345) {
27972 return index.lastIndexOf(code_point);
27973 }
27974
27975 // 3. Return the index pointer for code point in index.
27976 return indexPointerFor(code_point, index_);
27977 }
27978
27979 //
27980 // 7. API
27981 //
27982
27983 /** @const */ var DEFAULT_ENCODING = 'utf-8';
27984
27985 // 7.1 Interface TextDecoder
27986
27987 /**
27988 * @constructor
27989 * @param {string=} encoding The label of the encoding;
27990 * defaults to 'utf-8'.
27991 * @param {Object=} options
27992 */
27993 function TextDecoder(encoding, options) {
27994 if (!(this instanceof TextDecoder)) {
27995 return new TextDecoder(encoding, options);
27996 }
27997 encoding = encoding !== undefined ? String(encoding) : DEFAULT_ENCODING;
27998 options = ToDictionary(options);
27999 /** @private */
28000 this._encoding = getEncoding(encoding);
28001 if (this._encoding === null || this._encoding.name === 'replacement')
28002 throw RangeError('Unknown encoding: ' + encoding);
28003
28004 if (!decoders[this._encoding.name]) {
28005 throw Error('Decoder not present.' +
28006 ' Did you forget to include encoding-indexes.js?');
28007 }
28008
28009 /** @private @type {boolean} */
28010 this._streaming = false;
28011 /** @private @type {boolean} */
28012 this._BOMseen = false;
28013 /** @private @type {?Decoder} */
28014 this._decoder = null;
28015 /** @private @type {boolean} */
28016 this._fatal = Boolean(options['fatal']);
28017 /** @private @type {boolean} */
28018 this._ignoreBOM = Boolean(options['ignoreBOM']);
28019
28020 if (Object.defineProperty) {
28021 Object.defineProperty(this, 'encoding', {value: this._encoding.name});
28022 Object.defineProperty(this, 'fatal', {value: this._fatal});
28023 Object.defineProperty(this, 'ignoreBOM', {value: this._ignoreBOM});
28024 } else {
28025 this.encoding = this._encoding.name;
28026 this.fatal = this._fatal;
28027 this.ignoreBOM = this._ignoreBOM;
28028 }
28029
28030 return this;
28031 }
28032
28033 TextDecoder.prototype = {
28034 /**
28035 * @param {ArrayBufferView=} input The buffer of bytes to decode.
28036 * @param {Object=} options
28037 * @return {string} The decoded string.
28038 */
28039 decode: function decode(input, options) {
28040 var bytes;
28041 if (typeof input === 'object' && input instanceof ArrayBuffer) {
28042 bytes = new Uint8Array(input);
28043 } else if (typeof input === 'object' && 'buffer' in input &&
28044 input.buffer instanceof ArrayBuffer) {
28045 bytes = new Uint8Array(input.buffer,
28046 input.byteOffset,
28047 input.byteLength);
28048 } else {
28049 bytes = new Uint8Array(0);
28050 }
28051
28052 options = ToDictionary(options);
28053
28054 if (!this._streaming) {
28055 this._decoder = decoders[this._encoding.name]({fatal: this._fatal});
28056 this._BOMseen = false;
28057 }
28058 this._streaming = Boolean(options['stream']);
28059
28060 var input_stream = new Stream(bytes);
28061
28062 var code_points = [];
28063
28064 /** @type {?(number|!Array.<number>)} */
28065 var result;
28066
28067 while (!input_stream.endOfStream()) {
28068 result = this._decoder.handler(input_stream, input_stream.read());
28069 if (result === finished)
28070 break;
28071 if (result === null)
28072 continue;
28073 if (Array.isArray(result))
28074 code_points.push.apply(code_points, /**@type {!Array.<number>}*/(result));
28075 else
28076 code_points.push(result);
28077 }
28078 if (!this._streaming) {
28079 do {
28080 result = this._decoder.handler(input_stream, input_stream.read());
28081 if (result === finished)
28082 break;
28083 if (result === null)
28084 continue;
28085 if (Array.isArray(result))
28086 code_points.push.apply(code_points, /**@type {!Array.<number>}*/(result));
28087 else
28088 code_points.push(result);
28089 } while (!input_stream.endOfStream());
28090 this._decoder = null;
28091 }
28092
28093 if (code_points.length) {
28094 // If encoding is one of utf-8, utf-16be, and utf-16le, and
28095 // ignore BOM flag and BOM seen flag are unset, run these
28096 // subsubsteps:
28097 if (['utf-8', 'utf-16le', 'utf-16be'].indexOf(this.encoding) !== -1 &&
28098 !this._ignoreBOM && !this._BOMseen) {
28099 // If token is U+FEFF, set BOM seen flag.
28100 if (code_points[0] === 0xFEFF) {
28101 this._BOMseen = true;
28102 code_points.shift();
28103 } else {
28104 // Otherwise, if token is not end-of-stream, set BOM seen
28105 // flag and append token to output.
28106 this._BOMseen = true;
28107 }
28108 }
28109 }
28110
28111 return codePointsToString(code_points);
28112 }
28113 };
28114
28115 // 7.2 Interface TextEncoder
28116
28117 /**
28118 * @constructor
28119 * @param {string=} encoding The label of the encoding;
28120 * defaults to 'utf-8'.
28121 * @param {Object=} options
28122 */
28123 function TextEncoder(encoding, options) {
28124 if (!(this instanceof TextEncoder))
28125 return new TextEncoder(encoding, options);
28126 encoding = encoding !== undefined ? String(encoding) : DEFAULT_ENCODING;
28127 options = ToDictionary(options);
28128 /** @private */
28129 this._encoding = getEncoding(encoding);
28130 if (this._encoding === null || this._encoding.name === 'replacement')
28131 throw RangeError('Unknown encoding: ' + encoding);
28132
28133 var allowLegacyEncoding =
28134 Boolean(options['NONSTANDARD_allowLegacyEncoding']);
28135 var isLegacyEncoding = (this._encoding.name !== 'utf-8' &&
28136 this._encoding.name !== 'utf-16le' &&
28137 this._encoding.name !== 'utf-16be');
28138 if (this._encoding === null || (isLegacyEncoding && !allowLegacyEncoding))
28139 throw RangeError('Unknown encoding: ' + encoding);
28140
28141 if (!encoders[this._encoding.name]) {
28142 throw Error('Encoder not present.' +
28143 ' Did you forget to include encoding-indexes.js?');
28144 }
28145
28146 /** @private @type {boolean} */
28147 this._streaming = false;
28148 /** @private @type {?Encoder} */
28149 this._encoder = null;
28150 /** @private @type {{fatal: boolean}} */
28151 this._options = {fatal: Boolean(options['fatal'])};
28152
28153 if (Object.defineProperty)
28154 Object.defineProperty(this, 'encoding', {value: this._encoding.name});
28155 else
28156 this.encoding = this._encoding.name;
28157
28158 return this;
28159 }
28160
28161 TextEncoder.prototype = {
28162 /**
28163 * @param {string=} opt_string The string to encode.
28164 * @param {Object=} options
28165 * @return {Uint8Array} Encoded bytes, as a Uint8Array.
28166 */
28167 encode: function encode(opt_string, options) {
28168 opt_string = opt_string ? String(opt_string) : '';
28169 options = ToDictionary(options);
28170
28171 // NOTE: This option is nonstandard. None of the encodings
28172 // permitted for encoding (i.e. UTF-8, UTF-16) are stateful,
28173 // so streaming is not necessary.
28174 if (!this._streaming)
28175 this._encoder = encoders[this._encoding.name](this._options);
28176 this._streaming = Boolean(options['stream']);
28177
28178 var bytes = [];
28179 var input_stream = new Stream(stringToCodePoints(opt_string));
28180 /** @type {?(number|!Array.<number>)} */
28181 var result;
28182 while (!input_stream.endOfStream()) {
28183 result = this._encoder.handler(input_stream, input_stream.read());
28184 if (result === finished)
28185 break;
28186 if (Array.isArray(result))
28187 bytes.push.apply(bytes, /**@type {!Array.<number>}*/(result));
28188 else
28189 bytes.push(result);
28190 }
28191 if (!this._streaming) {
28192 while (true) {
28193 result = this._encoder.handler(input_stream, input_stream.read());
28194 if (result === finished)
28195 break;
28196 if (Array.isArray(result))
28197 bytes.push.apply(bytes, /**@type {!Array.<number>}*/(result));
28198 else
28199 bytes.push(result);
28200 }
28201 this._encoder = null;
28202 }
28203 return new Uint8Array(bytes);
28204 }
28205 };
28206
28207
28208 //
28209 // 8. The encoding
28210 //
28211
28212 // 8.1 utf-8
28213
28214 /**
28215 * @constructor
28216 * @implements {Decoder}
28217 * @param {{fatal: boolean}} options
28218 */
28219 function UTF8Decoder(options) {
28220 var fatal = options.fatal;
28221
28222 // utf-8's decoder's has an associated utf-8 code point, utf-8
28223 // bytes seen, and utf-8 bytes needed (all initially 0), a utf-8
28224 // lower boundary (initially 0x80), and a utf-8 upper boundary
28225 // (initially 0xBF).
28226 var /** @type {number} */ utf8_code_point = 0,
28227 /** @type {number} */ utf8_bytes_seen = 0,
28228 /** @type {number} */ utf8_bytes_needed = 0,
28229 /** @type {number} */ utf8_lower_boundary = 0x80,
28230 /** @type {number} */ utf8_upper_boundary = 0xBF;
28231
28232 /**
28233 * @param {Stream} stream The stream of bytes being decoded.
28234 * @param {number} bite The next byte read from the stream.
28235 * @return {?(number|!Array.<number>)} The next code point(s)
28236 * decoded, or null if not enough data exists in the input
28237 * stream to decode a complete code point.
28238 */
28239 this.handler = function(stream, bite) {
28240 // 1. If byte is end-of-stream and utf-8 bytes needed is not 0,
28241 // set utf-8 bytes needed to 0 and return error.
28242 if (bite === end_of_stream && utf8_bytes_needed !== 0) {
28243 utf8_bytes_needed = 0;
28244 return decoderError(fatal);
28245 }
28246
28247 // 2. If byte is end-of-stream, return finished.
28248 if (bite === end_of_stream)
28249 return finished;
28250
28251 // 3. If utf-8 bytes needed is 0, based on byte:
28252 if (utf8_bytes_needed === 0) {
28253
28254 // 0x00 to 0x7F
28255 if (inRange(bite, 0x00, 0x7F)) {
28256 // Return a code point whose value is byte.
28257 return bite;
28258 }
28259
28260 // 0xC2 to 0xDF
28261 if (inRange(bite, 0xC2, 0xDF)) {
28262 // Set utf-8 bytes needed to 1 and utf-8 code point to byte
28263 // − 0xC0.
28264 utf8_bytes_needed = 1;
28265 utf8_code_point = bite - 0xC0;
28266 }
28267
28268 // 0xE0 to 0xEF
28269 else if (inRange(bite, 0xE0, 0xEF)) {
28270 // 1. If byte is 0xE0, set utf-8 lower boundary to 0xA0.
28271 if (bite === 0xE0)
28272 utf8_lower_boundary = 0xA0;
28273 // 2. If byte is 0xED, set utf-8 upper boundary to 0x9F.
28274 if (bite === 0xED)
28275 utf8_upper_boundary = 0x9F;
28276 // 3. Set utf-8 bytes needed to 2 and utf-8 code point to
28277 // byte − 0xE0.
28278 utf8_bytes_needed = 2;
28279 utf8_code_point = bite - 0xE0;
28280 }
28281
28282 // 0xF0 to 0xF4
28283 else if (inRange(bite, 0xF0, 0xF4)) {
28284 // 1. If byte is 0xF0, set utf-8 lower boundary to 0x90.
28285 if (bite === 0xF0)
28286 utf8_lower_boundary = 0x90;
28287 // 2. If byte is 0xF4, set utf-8 upper boundary to 0x8F.
28288 if (bite === 0xF4)
28289 utf8_upper_boundary = 0x8F;
28290 // 3. Set utf-8 bytes needed to 3 and utf-8 code point to
28291 // byte − 0xF0.
28292 utf8_bytes_needed = 3;
28293 utf8_code_point = bite - 0xF0;
28294 }
28295
28296 // Otherwise
28297 else {
28298 // Return error.
28299 return decoderError(fatal);
28300 }
28301
28302 // Then (byte is in the range 0xC2 to 0xF4) set utf-8 code
28303 // point to utf-8 code point << (6 × utf-8 bytes needed) and
28304 // return continue.
28305 utf8_code_point = utf8_code_point << (6 * utf8_bytes_needed);
28306 return null;
28307 }
28308
28309 // 4. If byte is not in the range utf-8 lower boundary to utf-8
28310 // upper boundary, run these substeps:
28311 if (!inRange(bite, utf8_lower_boundary, utf8_upper_boundary)) {
28312
28313 // 1. Set utf-8 code point, utf-8 bytes needed, and utf-8
28314 // bytes seen to 0, set utf-8 lower boundary to 0x80, and set
28315 // utf-8 upper boundary to 0xBF.
28316 utf8_code_point = utf8_bytes_needed = utf8_bytes_seen = 0;
28317 utf8_lower_boundary = 0x80;
28318 utf8_upper_boundary = 0xBF;
28319
28320 // 2. Prepend byte to stream.
28321 stream.prepend(bite);
28322
28323 // 3. Return error.
28324 return decoderError(fatal);
28325 }
28326
28327 // 5. Set utf-8 lower boundary to 0x80 and utf-8 upper boundary
28328 // to 0xBF.
28329 utf8_lower_boundary = 0x80;
28330 utf8_upper_boundary = 0xBF;
28331
28332 // 6. Increase utf-8 bytes seen by one and set utf-8 code point
28333 // to utf-8 code point + (byte − 0x80) << (6 × (utf-8 bytes
28334 // needed − utf-8 bytes seen)).
28335 utf8_bytes_seen += 1;
28336 utf8_code_point += (bite - 0x80) << (6 * (utf8_bytes_needed - utf8_bytes_seen));
28337
28338 // 7. If utf-8 bytes seen is not equal to utf-8 bytes needed,
28339 // continue.
28340 if (utf8_bytes_seen !== utf8_bytes_needed)
28341 return null;
28342
28343 // 8. Let code point be utf-8 code point.
28344 var code_point = utf8_code_point;
28345
28346 // 9. Set utf-8 code point, utf-8 bytes needed, and utf-8 bytes
28347 // seen to 0.
28348 utf8_code_point = utf8_bytes_needed = utf8_bytes_seen = 0;
28349
28350 // 10. Return a code point whose value is code point.
28351 return code_point;
28352 };
28353 }
28354
28355 /**
28356 * @constructor
28357 * @implements {Encoder}
28358 * @param {{fatal: boolean}} options
28359 */
28360 function UTF8Encoder(options) {
28361 var fatal = options.fatal;
28362 /**
28363 * @param {Stream} stream Input stream.
28364 * @param {number} code_point Next code point read from the stream.
28365 * @return {(number|!Array.<number>)} Byte(s) to emit.
28366 */
28367 this.handler = function(stream, code_point) {
28368 // 1. If code point is end-of-stream, return finished.
28369 if (code_point === end_of_stream)
28370 return finished;
28371
28372 // 2. If code point is in the range U+0000 to U+007F, return a
28373 // byte whose value is code point.
28374 if (inRange(code_point, 0x0000, 0x007f))
28375 return code_point;
28376
28377 // 3. Set count and offset based on the range code point is in:
28378 var count, offset;
28379 // U+0080 to U+07FF: 1 and 0xC0
28380 if (inRange(code_point, 0x0080, 0x07FF)) {
28381 count = 1;
28382 offset = 0xC0;
28383 }
28384 // U+0800 to U+FFFF: 2 and 0xE0
28385 else if (inRange(code_point, 0x0800, 0xFFFF)) {
28386 count = 2;
28387 offset = 0xE0;
28388 }
28389 // U+10000 to U+10FFFF: 3 and 0xF0
28390 else if (inRange(code_point, 0x10000, 0x10FFFF)) {
28391 count = 3;
28392 offset = 0xF0;
28393 }
28394
28395 // 4.Let bytes be a byte sequence whose first byte is (code
28396 // point >> (6 × count)) + offset.
28397 var bytes = [(code_point >> (6 * count)) + offset];
28398
28399 // 5. Run these substeps while count is greater than 0:
28400 while (count > 0) {
28401
28402 // 1. Set temp to code point >> (6 × (count − 1)).
28403 var temp = code_point >> (6 * (count - 1));
28404
28405 // 2. Append to bytes 0x80 | (temp & 0x3F).
28406 bytes.push(0x80 | (temp & 0x3F));
28407
28408 // 3. Decrease count by one.
28409 count -= 1;
28410 }
28411
28412 // 6. Return bytes bytes, in order.
28413 return bytes;
28414 };
28415 }
28416
28417 /** @param {{fatal: boolean}} options */
28418 encoders['utf-8'] = function(options) {
28419 return new UTF8Encoder(options);
28420 };
28421 /** @param {{fatal: boolean}} options */
28422 decoders['utf-8'] = function(options) {
28423 return new UTF8Decoder(options);
28424 };
28425
28426 //
28427 // 9. Legacy single-byte encodings
28428 //
28429
28430 // 9.1 single-byte decoder
28431 /**
28432 * @constructor
28433 * @implements {Decoder}
28434 * @param {!Array.<number>} index The encoding index.
28435 * @param {{fatal: boolean}} options
28436 */
28437 function SingleByteDecoder(index, options) {
28438 var fatal = options.fatal;
28439 /**
28440 * @param {Stream} stream The stream of bytes being decoded.
28441 * @param {number} bite The next byte read from the stream.
28442 * @return {?(number|!Array.<number>)} The next code point(s)
28443 * decoded, or null if not enough data exists in the input
28444 * stream to decode a complete code point.
28445 */
28446 this.handler = function(stream, bite) {
28447 // 1. If byte is end-of-stream, return finished.
28448 if (bite === end_of_stream)
28449 return finished;
28450
28451 // 2. If byte is in the range 0x00 to 0x7F, return a code point
28452 // whose value is byte.
28453 if (inRange(bite, 0x00, 0x7F))
28454 return bite;
28455
28456 // 3. Let code point be the index code point for byte − 0x80 in
28457 // index single-byte.
28458 var code_point = index[bite - 0x80];
28459
28460 // 4. If code point is null, return error.
28461 if (code_point === null)
28462 return decoderError(fatal);
28463
28464 // 5. Return a code point whose value is code point.
28465 return code_point;
28466 };
28467 }
28468
28469 // 9.2 single-byte encoder
28470 /**
28471 * @constructor
28472 * @implements {Encoder}
28473 * @param {!Array.<?number>} index The encoding index.
28474 * @param {{fatal: boolean}} options
28475 */
28476 function SingleByteEncoder(index, options) {
28477 var fatal = options.fatal;
28478 /**
28479 * @param {Stream} stream Input stream.
28480 * @param {number} code_point Next code point read from the stream.
28481 * @return {(number|!Array.<number>)} Byte(s) to emit.
28482 */
28483 this.handler = function(stream, code_point) {
28484 // 1. If code point is end-of-stream, return finished.
28485 if (code_point === end_of_stream)
28486 return finished;
28487
28488 // 2. If code point is in the range U+0000 to U+007F, return a
28489 // byte whose value is code point.
28490 if (inRange(code_point, 0x0000, 0x007F))
28491 return code_point;
28492
28493 // 3. Let pointer be the index pointer for code point in index
28494 // single-byte.
28495 var pointer = indexPointerFor(code_point, index);
28496
28497 // 4. If pointer is null, return error with code point.
28498 if (pointer === null)
28499 encoderError(code_point);
28500
28501 // 5. Return a byte whose value is pointer + 0x80.
28502 return pointer + 0x80;
28503 };
28504 }
28505
28506 (function() {
28507 if (!('encoding-indexes' in global))
28508 return;
28509 encodings.forEach(function(category) {
28510 if (category.heading !== 'Legacy single-byte encodings')
28511 return;
28512 category.encodings.forEach(function(encoding) {
28513 var name = encoding.name;
28514 var idx = index(name);
28515 /** @param {{fatal: boolean}} options */
28516 decoders[name] = function(options) {
28517 return new SingleByteDecoder(idx, options);
28518 };
28519 /** @param {{fatal: boolean}} options */
28520 encoders[name] = function(options) {
28521 return new SingleByteEncoder(idx, options);
28522 };
28523 });
28524 });
28525 }());
28526
28527 //
28528 // 10. Legacy multi-byte Chinese (simplified) encodings
28529 //
28530
28531 // 10.1 gbk
28532
28533 // 10.1.1 gbk decoder
28534 // gbk's decoder is gb18030's decoder.
28535 /** @param {{fatal: boolean}} options */
28536 decoders['gbk'] = function(options) {
28537 return new GB18030Decoder(options);
28538 };
28539
28540 // 10.1.2 gbk encoder
28541 // gbk's encoder is gb18030's encoder with its gbk flag set.
28542 /** @param {{fatal: boolean}} options */
28543 encoders['gbk'] = function(options) {
28544 return new GB18030Encoder(options, true);
28545 };
28546
28547 // 10.2 gb18030
28548
28549 // 10.2.1 gb18030 decoder
28550 /**
28551 * @constructor
28552 * @implements {Decoder}
28553 * @param {{fatal: boolean}} options
28554 */
28555 function GB18030Decoder(options) {
28556 var fatal = options.fatal;
28557 // gb18030's decoder has an associated gb18030 first, gb18030
28558 // second, and gb18030 third (all initially 0x00).
28559 var /** @type {number} */ gb18030_first = 0x00,
28560 /** @type {number} */ gb18030_second = 0x00,
28561 /** @type {number} */ gb18030_third = 0x00;
28562 /**
28563 * @param {Stream} stream The stream of bytes being decoded.
28564 * @param {number} bite The next byte read from the stream.
28565 * @return {?(number|!Array.<number>)} The next code point(s)
28566 * decoded, or null if not enough data exists in the input
28567 * stream to decode a complete code point.
28568 */
28569 this.handler = function(stream, bite) {
28570 // 1. If byte is end-of-stream and gb18030 first, gb18030
28571 // second, and gb18030 third are 0x00, return finished.
28572 if (bite === end_of_stream && gb18030_first === 0x00 &&
28573 gb18030_second === 0x00 && gb18030_third === 0x00) {
28574 return finished;
28575 }
28576 // 2. If byte is end-of-stream, and gb18030 first, gb18030
28577 // second, or gb18030 third is not 0x00, set gb18030 first,
28578 // gb18030 second, and gb18030 third to 0x00, and return error.
28579 if (bite === end_of_stream &&
28580 (gb18030_first !== 0x00 || gb18030_second !== 0x00 || gb18030_third !== 0x00)) {
28581 gb18030_first = 0x00;
28582 gb18030_second = 0x00;
28583 gb18030_third = 0x00;
28584 decoderError(fatal);
28585 }
28586 var code_point;
28587 // 3. If gb18030 third is not 0x00, run these substeps:
28588 if (gb18030_third !== 0x00) {
28589 // 1. Let code point be null.
28590 code_point = null;
28591 // 2. If byte is in the range 0x30 to 0x39, set code point to
28592 // the index gb18030 ranges code point for (((gb18030 first −
28593 // 0x81) × 10 + gb18030 second − 0x30) × 126 + gb18030 third −
28594 // 0x81) × 10 + byte − 0x30.
28595 if (inRange(bite, 0x30, 0x39)) {
28596 code_point = indexGB18030RangesCodePointFor(
28597 (((gb18030_first - 0x81) * 10 + (gb18030_second - 0x30)) * 126 +
28598 (gb18030_third - 0x81)) * 10 + bite - 0x30);
28599 }
28600
28601 // 3. Let buffer be a byte sequence consisting of gb18030
28602 // second, gb18030 third, and byte, in order.
28603 var buffer = [gb18030_second, gb18030_third, bite];
28604
28605 // 4. Set gb18030 first, gb18030 second, and gb18030 third to
28606 // 0x00.
28607 gb18030_first = 0x00;
28608 gb18030_second = 0x00;
28609 gb18030_third = 0x00;
28610
28611 // 5. If code point is null, prepend buffer to stream and
28612 // return error.
28613 if (code_point === null) {
28614 stream.prepend(buffer);
28615 return decoderError(fatal);
28616 }
28617
28618 // 6. Return a code point whose value is code point.
28619 return code_point;
28620 }
28621
28622 // 4. If gb18030 second is not 0x00, run these substeps:
28623 if (gb18030_second !== 0x00) {
28624
28625 // 1. If byte is in the range 0x81 to 0xFE, set gb18030 third
28626 // to byte and return continue.
28627 if (inRange(bite, 0x81, 0xFE)) {
28628 gb18030_third = bite;
28629 return null;
28630 }
28631
28632 // 2. Prepend gb18030 second followed by byte to stream, set
28633 // gb18030 first and gb18030 second to 0x00, and return error.
28634 stream.prepend([gb18030_second, bite]);
28635 gb18030_first = 0x00;
28636 gb18030_second = 0x00;
28637 return decoderError(fatal);
28638 }
28639
28640 // 5. If gb18030 first is not 0x00, run these substeps:
28641 if (gb18030_first !== 0x00) {
28642
28643 // 1. If byte is in the range 0x30 to 0x39, set gb18030 second
28644 // to byte and return continue.
28645 if (inRange(bite, 0x30, 0x39)) {
28646 gb18030_second = bite;
28647 return null;
28648 }
28649
28650 // 2. Let lead be gb18030 first, let pointer be null, and set
28651 // gb18030 first to 0x00.
28652 var lead = gb18030_first;
28653 var pointer = null;
28654 gb18030_first = 0x00;
28655
28656 // 3. Let offset be 0x40 if byte is less than 0x7F and 0x41
28657 // otherwise.
28658 var offset = bite < 0x7F ? 0x40 : 0x41;
28659
28660 // 4. If byte is in the range 0x40 to 0x7E or 0x80 to 0xFE,
28661 // set pointer to (lead − 0x81) × 190 + (byte − offset).
28662 if (inRange(bite, 0x40, 0x7E) || inRange(bite, 0x80, 0xFE))
28663 pointer = (lead - 0x81) * 190 + (bite - offset);
28664
28665 // 5. Let code point be null if pointer is null and the index
28666 // code point for pointer in index gb18030 otherwise.
28667 code_point = pointer === null ? null :
28668 indexCodePointFor(pointer, index('gb18030'));
28669
28670 // 6. If code point is null and byte is in the range 0x00 to
28671 // 0x7F, prepend byte to stream.
28672 if (code_point === null && inRange(bite, 0x00, 0x7F))
28673 stream.prepend(bite);
28674
28675 // 7. If code point is null, return error.
28676 if (code_point === null)
28677 return decoderError(fatal);
28678
28679 // 8. Return a code point whose value is code point.
28680 return code_point;
28681 }
28682
28683 // 6. If byte is in the range 0x00 to 0x7F, return a code point
28684 // whose value is byte.
28685 if (inRange(bite, 0x00, 0x7F))
28686 return bite;
28687
28688 // 7. If byte is 0x80, return code point U+20AC.
28689 if (bite === 0x80)
28690 return 0x20AC;
28691
28692 // 8. If byte is in the range 0x81 to 0xFE, set gb18030 first to
28693 // byte and return continue.
28694 if (inRange(bite, 0x81, 0xFE)) {
28695 gb18030_first = bite;
28696 return null;
28697 }
28698
28699 // 9. Return error.
28700 return decoderError(fatal);
28701 };
28702 }
28703
28704 // 10.2.2 gb18030 encoder
28705 /**
28706 * @constructor
28707 * @implements {Encoder}
28708 * @param {{fatal: boolean}} options
28709 * @param {boolean=} gbk_flag
28710 */
28711 function GB18030Encoder(options, gbk_flag) {
28712 var fatal = options.fatal;
28713 // gb18030's decoder has an associated gbk flag (initially unset).
28714 /**
28715 * @param {Stream} stream Input stream.
28716 * @param {number} code_point Next code point read from the stream.
28717 * @return {(number|!Array.<number>)} Byte(s) to emit.
28718 */
28719 this.handler = function(stream, code_point) {
28720 // 1. If code point is end-of-stream, return finished.
28721 if (code_point === end_of_stream)
28722 return finished;
28723
28724 // 2. If code point is in the range U+0000 to U+007F, return a
28725 // byte whose value is code point.
28726 if (inRange(code_point, 0x0000, 0x007F)) {
28727 return code_point;
28728 }
28729
28730 // 3. If the gbk flag is set and code point is U+20AC, return
28731 // byte 0x80.
28732 if (gbk_flag && code_point === 0x20AC)
28733 return 0x80;
28734
28735 // 4. Let pointer be the index pointer for code point in index
28736 // gb18030.
28737 var pointer = indexPointerFor(code_point, index('gb18030'));
28738
28739 // 5. If pointer is not null, run these substeps:
28740 if (pointer !== null) {
28741
28742 // 1. Let lead be pointer / 190 + 0x81.
28743 var lead = div(pointer, 190) + 0x81;
28744
28745 // 2. Let trail be pointer % 190.
28746 var trail = pointer % 190;
28747
28748 // 3. Let offset be 0x40 if trail is less than 0x3F and 0x41 otherwise.
28749 var offset = trail < 0x3F ? 0x40 : 0x41;
28750
28751 // 4. Return two bytes whose values are lead and trail + offset.
28752 return [lead, trail + offset];
28753 }
28754
28755 // 6. If gbk flag is set, return error with code point.
28756 if (gbk_flag)
28757 return encoderError(code_point);
28758
28759 // 7. Set pointer to the index gb18030 ranges pointer for code
28760 // point.
28761 pointer = indexGB18030RangesPointerFor(code_point);
28762
28763 // 8. Let byte1 be pointer / 10 / 126 / 10.
28764 var byte1 = div(div(div(pointer, 10), 126), 10);
28765
28766 // 9. Set pointer to pointer − byte1 × 10 × 126 × 10.
28767 pointer = pointer - byte1 * 10 * 126 * 10;
28768
28769 // 10. Let byte2 be pointer / 10 / 126.
28770 var byte2 = div(div(pointer, 10), 126);
28771
28772 // 11. Set pointer to pointer − byte2 × 10 × 126.
28773 pointer = pointer - byte2 * 10 * 126;
28774
28775 // 12. Let byte3 be pointer / 10.
28776 var byte3 = div(pointer, 10);
28777
28778 // 13. Let byte4 be pointer − byte3 × 10.
28779 var byte4 = pointer - byte3 * 10;
28780
28781 // 14. Return four bytes whose values are byte1 + 0x81, byte2 +
28782 // 0x30, byte3 + 0x81, byte4 + 0x30.
28783 return [byte1 + 0x81,
28784 byte2 + 0x30,
28785 byte3 + 0x81,
28786 byte4 + 0x30];
28787 };
28788 }
28789
28790 /** @param {{fatal: boolean}} options */
28791 encoders['gb18030'] = function(options) {
28792 return new GB18030Encoder(options);
28793 };
28794 /** @param {{fatal: boolean}} options */
28795 decoders['gb18030'] = function(options) {
28796 return new GB18030Decoder(options);
28797 };
28798
28799
28800 //
28801 // 11. Legacy multi-byte Chinese (traditional) encodings
28802 //
28803
28804 // 11.1 big5
28805
28806 /**
28807 * @constructor
28808 * @implements {Decoder}
28809 * @param {{fatal: boolean}} options
28810 */
28811 function Big5Decoder(options) {
28812 var fatal = options.fatal;
28813 // big5's decoder has an associated big5 lead (initially 0x00).
28814 var /** @type {number} */ big5_lead = 0x00;
28815
28816 /**
28817 * @param {Stream} stream The stream of bytes being decoded.
28818 * @param {number} bite The next byte read from the stream.
28819 * @return {?(number|!Array.<number>)} The next code point(s)
28820 * decoded, or null if not enough data exists in the input
28821 * stream to decode a complete code point.
28822 */
28823 this.handler = function(stream, bite) {
28824 // 1. If byte is end-of-stream and big5 lead is not 0x00, set
28825 // big5 lead to 0x00 and return error.
28826 if (bite === end_of_stream && big5_lead !== 0x00) {
28827 big5_lead = 0x00;
28828 return decoderError(fatal);
28829 }
28830
28831 // 2. If byte is end-of-stream and big5 lead is 0x00, return
28832 // finished.
28833 if (bite === end_of_stream && big5_lead === 0x00)
28834 return finished;
28835
28836 // 3. If big5 lead is not 0x00, let lead be big5 lead, let
28837 // pointer be null, set big5 lead to 0x00, and then run these
28838 // substeps:
28839 if (big5_lead !== 0x00) {
28840 var lead = big5_lead;
28841 var pointer = null;
28842 big5_lead = 0x00;
28843
28844 // 1. Let offset be 0x40 if byte is less than 0x7F and 0x62
28845 // otherwise.
28846 var offset = bite < 0x7F ? 0x40 : 0x62;
28847
28848 // 2. If byte is in the range 0x40 to 0x7E or 0xA1 to 0xFE,
28849 // set pointer to (lead − 0x81) × 157 + (byte − offset).
28850 if (inRange(bite, 0x40, 0x7E) || inRange(bite, 0xA1, 0xFE))
28851 pointer = (lead - 0x81) * 157 + (bite - offset);
28852
28853 // 3. If there is a row in the table below whose first column
28854 // is pointer, return the two code points listed in its second
28855 // column
28856 // Pointer | Code points
28857 // --------+--------------
28858 // 1133 | U+00CA U+0304
28859 // 1135 | U+00CA U+030C
28860 // 1164 | U+00EA U+0304
28861 // 1166 | U+00EA U+030C
28862 switch (pointer) {
28863 case 1133: return [0x00CA, 0x0304];
28864 case 1135: return [0x00CA, 0x030C];
28865 case 1164: return [0x00EA, 0x0304];
28866 case 1166: return [0x00EA, 0x030C];
28867 }
28868
28869 // 4. Let code point be null if pointer is null and the index
28870 // code point for pointer in index big5 otherwise.
28871 var code_point = (pointer === null) ? null :
28872 indexCodePointFor(pointer, index('big5'));
28873
28874 // 5. If code point is null and byte is in the range 0x00 to
28875 // 0x7F, prepend byte to stream.
28876 if (code_point === null && inRange(bite, 0x00, 0x7F))
28877 stream.prepend(bite);
28878
28879 // 6. If code point is null, return error.
28880 if (code_point === null)
28881 return decoderError(fatal);
28882
28883 // 7. Return a code point whose value is code point.
28884 return code_point;
28885 }
28886
28887 // 4. If byte is in the range 0x00 to 0x7F, return a code point
28888 // whose value is byte.
28889 if (inRange(bite, 0x00, 0x7F))
28890 return bite;
28891
28892 // 5. If byte is in the range 0x81 to 0xFE, set big5 lead to
28893 // byte and return continue.
28894 if (inRange(bite, 0x81, 0xFE)) {
28895 big5_lead = bite;
28896 return null;
28897 }
28898
28899 // 6. Return error.
28900 return decoderError(fatal);
28901 };
28902 }
28903
28904 /**
28905 * @constructor
28906 * @implements {Encoder}
28907 * @param {{fatal: boolean}} options
28908 */
28909 function Big5Encoder(options) {
28910 var fatal = options.fatal;
28911 /**
28912 * @param {Stream} stream Input stream.
28913 * @param {number} code_point Next code point read from the stream.
28914 * @return {(number|!Array.<number>)} Byte(s) to emit.
28915 */
28916 this.handler = function(stream, code_point) {
28917 // 1. If code point is end-of-stream, return finished.
28918 if (code_point === end_of_stream)
28919 return finished;
28920
28921 // 2. If code point is in the range U+0000 to U+007F, return a
28922 // byte whose value is code point.
28923 if (inRange(code_point, 0x0000, 0x007F))
28924 return code_point;
28925
28926 // 3. Let pointer be the index big5 pointer for code point.
28927 var pointer = indexBig5PointerFor(code_point, index('big5'));
28928
28929 // 4. If pointer is null, return error with code point.
28930 if (pointer === null)
28931 return encoderError(code_point);
28932
28933 // 5. Let lead be pointer / 157 + 0x81.
28934 var lead = div(pointer, 157) + 0x81;
28935
28936 // 6. If lead is less than 0xA1, return error with code point.
28937 if (lead < 0xA1)
28938 return encoderError(code_point);
28939
28940 // 7. Let trail be pointer % 157.
28941 var trail = pointer % 157;
28942
28943 // 8. Let offset be 0x40 if trail is less than 0x3F and 0x62
28944 // otherwise.
28945 var offset = trail < 0x3F ? 0x40 : 0x62;
28946
28947 // Return two bytes whose values are lead and trail + offset.
28948 return [lead, trail + offset];
28949 };
28950 }
28951
28952 /** @param {{fatal: boolean}} options */
28953 encoders['big5'] = function(options) {
28954 return new Big5Encoder(options);
28955 };
28956 /** @param {{fatal: boolean}} options */
28957 decoders['big5'] = function(options) {
28958 return new Big5Decoder(options);
28959 };
28960
28961
28962 //
28963 // 12. Legacy multi-byte Japanese encodings
28964 //
28965
28966 // 12.1 euc-jp
28967
28968 /**
28969 * @constructor
28970 * @implements {Decoder}
28971 * @param {{fatal: boolean}} options
28972 */
28973 function EUCJPDecoder(options) {
28974 var fatal = options.fatal;
28975
28976 // euc-jp's decoder has an associated euc-jp jis0212 flag
28977 // (initially unset) and euc-jp lead (initially 0x00).
28978 var /** @type {boolean} */ eucjp_jis0212_flag = false,
28979 /** @type {number} */ eucjp_lead = 0x00;
28980
28981 /**
28982 * @param {Stream} stream The stream of bytes being decoded.
28983 * @param {number} bite The next byte read from the stream.
28984 * @return {?(number|!Array.<number>)} The next code point(s)
28985 * decoded, or null if not enough data exists in the input
28986 * stream to decode a complete code point.
28987 */
28988 this.handler = function(stream, bite) {
28989 // 1. If byte is end-of-stream and euc-jp lead is not 0x00, set
28990 // euc-jp lead to 0x00, and return error.
28991 if (bite === end_of_stream && eucjp_lead !== 0x00) {
28992 eucjp_lead = 0x00;
28993 return decoderError(fatal);
28994 }
28995
28996 // 2. If byte is end-of-stream and euc-jp lead is 0x00, return
28997 // finished.
28998 if (bite === end_of_stream && eucjp_lead === 0x00)
28999 return finished;
29000
29001 // 3. If euc-jp lead is 0x8E and byte is in the range 0xA1 to
29002 // 0xDF, set euc-jp lead to 0x00 and return a code point whose
29003 // value is 0xFF61 + byte − 0xA1.
29004 if (eucjp_lead === 0x8E && inRange(bite, 0xA1, 0xDF)) {
29005 eucjp_lead = 0x00;
29006 return 0xFF61 + bite - 0xA1;
29007 }
29008
29009 // 4. If euc-jp lead is 0x8F and byte is in the range 0xA1 to
29010 // 0xFE, set the euc-jp jis0212 flag, set euc-jp lead to byte,
29011 // and return continue.
29012 if (eucjp_lead === 0x8F && inRange(bite, 0xA1, 0xFE)) {
29013 eucjp_jis0212_flag = true;
29014 eucjp_lead = bite;
29015 return null;
29016 }
29017
29018 // 5. If euc-jp lead is not 0x00, let lead be euc-jp lead, set
29019 // euc-jp lead to 0x00, and run these substeps:
29020 if (eucjp_lead !== 0x00) {
29021 var lead = eucjp_lead;
29022 eucjp_lead = 0x00;
29023
29024 // 1. Let code point be null.
29025 var code_point = null;
29026
29027 // 2. If lead and byte are both in the range 0xA1 to 0xFE, set
29028 // code point to the index code point for (lead − 0xA1) × 94 +
29029 // byte − 0xA1 in index jis0208 if the euc-jp jis0212 flag is
29030 // unset and in index jis0212 otherwise.
29031 if (inRange(lead, 0xA1, 0xFE) && inRange(bite, 0xA1, 0xFE)) {
29032 code_point = indexCodePointFor(
29033 (lead - 0xA1) * 94 + (bite - 0xA1),
29034 index(!eucjp_jis0212_flag ? 'jis0208' : 'jis0212'));
29035 }
29036
29037 // 3. Unset the euc-jp jis0212 flag.
29038 eucjp_jis0212_flag = false;
29039
29040 // 4. If byte is not in the range 0xA1 to 0xFE, prepend byte
29041 // to stream.
29042 if (!inRange(bite, 0xA1, 0xFE))
29043 stream.prepend(bite);
29044
29045 // 5. If code point is null, return error.
29046 if (code_point === null)
29047 return decoderError(fatal);
29048
29049 // 6. Return a code point whose value is code point.
29050 return code_point;
29051 }
29052
29053 // 6. If byte is in the range 0x00 to 0x7F, return a code point
29054 // whose value is byte.
29055 if (inRange(bite, 0x00, 0x7F))
29056 return bite;
29057
29058 // 7. If byte is 0x8E, 0x8F, or in the range 0xA1 to 0xFE, set
29059 // euc-jp lead to byte and return continue.
29060 if (bite === 0x8E || bite === 0x8F || inRange(bite, 0xA1, 0xFE)) {
29061 eucjp_lead = bite;
29062 return null;
29063 }
29064
29065 // 8. Return error.
29066 return decoderError(fatal);
29067 };
29068 }
29069
29070 /**
29071 * @constructor
29072 * @implements {Encoder}
29073 * @param {{fatal: boolean}} options
29074 */
29075 function EUCJPEncoder(options) {
29076 var fatal = options.fatal;
29077 /**
29078 * @param {Stream} stream Input stream.
29079 * @param {number} code_point Next code point read from the stream.
29080 * @return {(number|!Array.<number>)} Byte(s) to emit.
29081 */
29082 this.handler = function(stream, code_point) {
29083 // 1. If code point is end-of-stream, return finished.
29084 if (code_point === end_of_stream)
29085 return finished;
29086
29087 // 2. If code point is in the range U+0000 to U+007F, return a
29088 // byte whose value is code point.
29089 if (inRange(code_point, 0x0000, 0x007F))
29090 return code_point;
29091
29092 // 3. If code point is U+00A5, return byte 0x5C.
29093 if (code_point === 0x00A5)
29094 return 0x5C;
29095
29096 // 4. If code point is U+203E, return byte 0x7E.
29097 if (code_point === 0x203E)
29098 return 0x7E;
29099
29100 // 5. If code point is in the range U+FF61 to U+FF9F, return two
29101 // bytes whose values are 0x8E and code point − 0xFF61 + 0xA1.
29102 if (inRange(code_point, 0xFF61, 0xFF9F))
29103 return [0x8E, code_point - 0xFF61 + 0xA1];
29104
29105 // 6. If code point is U+2022, set it to U+FF0D.
29106 if (code_point === 0x2022)
29107 code_point = 0xFF0D;
29108
29109 // 7. Let pointer be the index pointer for code point in index
29110 // jis0208.
29111 var pointer = indexPointerFor(code_point, index('jis0208'));
29112
29113 // 8. If pointer is null, return error with code point.
29114 if (pointer === null)
29115 return encoderError(code_point);
29116
29117 // 9. Let lead be pointer / 94 + 0xA1.
29118 var lead = div(pointer, 94) + 0xA1;
29119
29120 // 10. Let trail be pointer % 94 + 0xA1.
29121 var trail = pointer % 94 + 0xA1;
29122
29123 // 11. Return two bytes whose values are lead and trail.
29124 return [lead, trail];
29125 };
29126 }
29127
29128 /** @param {{fatal: boolean}} options */
29129 encoders['euc-jp'] = function(options) {
29130 return new EUCJPEncoder(options);
29131 };
29132 /** @param {{fatal: boolean}} options */
29133 decoders['euc-jp'] = function(options) {
29134 return new EUCJPDecoder(options);
29135 };
29136
29137 // 12.2 iso-2022-jp
29138
29139 /**
29140 * @constructor
29141 * @implements {Decoder}
29142 * @param {{fatal: boolean}} options
29143 */
29144 function ISO2022JPDecoder(options) {
29145 var fatal = options.fatal;
29146 /** @enum */
29147 var states = {
29148 ASCII: 0,
29149 Roman: 1,
29150 Katakana: 2,
29151 LeadByte: 3,
29152 TrailByte: 4,
29153 EscapeStart: 5,
29154 Escape: 6
29155 };
29156 // iso-2022-jp's decoder has an associated iso-2022-jp decoder
29157 // state (initially ASCII), iso-2022-jp decoder output state
29158 // (initially ASCII), iso-2022-jp lead (initially 0x00), and
29159 // iso-2022-jp output flag (initially unset).
29160 var /** @type {number} */ iso2022jp_decoder_state = states.ASCII,
29161 /** @type {number} */ iso2022jp_decoder_output_state = states.ASCII,
29162 /** @type {number} */ iso2022jp_lead = 0x00,
29163 /** @type {boolean} */ iso2022jp_output_flag = false;
29164 /**
29165 * @param {Stream} stream The stream of bytes being decoded.
29166 * @param {number} bite The next byte read from the stream.
29167 * @return {?(number|!Array.<number>)} The next code point(s)
29168 * decoded, or null if not enough data exists in the input
29169 * stream to decode a complete code point.
29170 */
29171 this.handler = function(stream, bite) {
29172 // switching on iso-2022-jp decoder state:
29173 switch (iso2022jp_decoder_state) {
29174 default:
29175 case states.ASCII:
29176 // ASCII
29177 // Based on byte:
29178
29179 // 0x1B
29180 if (bite === 0x1B) {
29181 // Set iso-2022-jp decoder state to escape start and return
29182 // continue.
29183 iso2022jp_decoder_state = states.EscapeStart;
29184 return null;
29185 }
29186
29187 // 0x00 to 0x7F, excluding 0x0E, 0x0F, and 0x1B
29188 if (inRange(bite, 0x00, 0x7F) && bite !== 0x0E
29189 && bite !== 0x0F && bite !== 0x1B) {
29190 // Unset the iso-2022-jp output flag and return a code point
29191 // whose value is byte.
29192 iso2022jp_output_flag = false;
29193 return bite;
29194 }
29195
29196 // end-of-stream
29197 if (bite === end_of_stream) {
29198 // Return finished.
29199 return finished;
29200 }
29201
29202 // Otherwise
29203 // Unset the iso-2022-jp output flag and return error.
29204 iso2022jp_output_flag = false;
29205 return decoderError(fatal);
29206
29207 case states.Roman:
29208 // Roman
29209 // Based on byte:
29210
29211 // 0x1B
29212 if (bite === 0x1B) {
29213 // Set iso-2022-jp decoder state to escape start and return
29214 // continue.
29215 iso2022jp_decoder_state = states.EscapeStart;
29216 return null;
29217 }
29218
29219 // 0x5C
29220 if (bite === 0x5C) {
29221 // Unset the iso-2022-jp output flag and return code point
29222 // U+00A5.
29223 iso2022jp_output_flag = false;
29224 return 0x00A5;
29225 }
29226
29227 // 0x7E
29228 if (bite === 0x7E) {
29229 // Unset the iso-2022-jp output flag and return code point
29230 // U+203E.
29231 iso2022jp_output_flag = false;
29232 return 0x203E;
29233 }
29234
29235 // 0x00 to 0x7F, excluding 0x0E, 0x0F, 0x1B, 0x5C, and 0x7E
29236 if (inRange(bite, 0x00, 0x7F) && bite !== 0x0E && bite !== 0x0F
29237 && bite !== 0x1B && bite !== 0x5C && bite !== 0x7E) {
29238 // Unset the iso-2022-jp output flag and return a code point
29239 // whose value is byte.
29240 iso2022jp_output_flag = false;
29241 return bite;
29242 }
29243
29244 // end-of-stream
29245 if (bite === end_of_stream) {
29246 // Return finished.
29247 return finished;
29248 }
29249
29250 // Otherwise
29251 // Unset the iso-2022-jp output flag and return error.
29252 iso2022jp_output_flag = false;
29253 return decoderError(fatal);
29254
29255 case states.Katakana:
29256 // Katakana
29257 // Based on byte:
29258
29259 // 0x1B
29260 if (bite === 0x1B) {
29261 // Set iso-2022-jp decoder state to escape start and return
29262 // continue.
29263 iso2022jp_decoder_state = states.EscapeStart;
29264 return null;
29265 }
29266
29267 // 0x21 to 0x5F
29268 if (inRange(bite, 0x21, 0x5F)) {
29269 // Unset the iso-2022-jp output flag and return a code point
29270 // whose value is 0xFF61 + byte − 0x21.
29271 iso2022jp_output_flag = false;
29272 return 0xFF61 + bite - 0x21;
29273 }
29274
29275 // end-of-stream
29276 if (bite === end_of_stream) {
29277 // Return finished.
29278 return finished;
29279 }
29280
29281 // Otherwise
29282 // Unset the iso-2022-jp output flag and return error.
29283 iso2022jp_output_flag = false;
29284 return decoderError(fatal);
29285
29286 case states.LeadByte:
29287 // Lead byte
29288 // Based on byte:
29289
29290 // 0x1B
29291 if (bite === 0x1B) {
29292 // Set iso-2022-jp decoder state to escape start and return
29293 // continue.
29294 iso2022jp_decoder_state = states.EscapeStart;
29295 return null;
29296 }
29297
29298 // 0x21 to 0x7E
29299 if (inRange(bite, 0x21, 0x7E)) {
29300 // Unset the iso-2022-jp output flag, set iso-2022-jp lead
29301 // to byte, iso-2022-jp decoder state to trail byte, and
29302 // return continue.
29303 iso2022jp_output_flag = false;
29304 iso2022jp_lead = bite;
29305 iso2022jp_decoder_state = states.TrailByte;
29306 return null;
29307 }
29308
29309 // end-of-stream
29310 if (bite === end_of_stream) {
29311 // Return finished.
29312 return finished;
29313 }
29314
29315 // Otherwise
29316 // Unset the iso-2022-jp output flag and return error.
29317 iso2022jp_output_flag = false;
29318 return decoderError(fatal);
29319
29320 case states.TrailByte:
29321 // Trail byte
29322 // Based on byte:
29323
29324 // 0x1B
29325 if (bite === 0x1B) {
29326 // Set iso-2022-jp decoder state to escape start and return
29327 // continue.
29328 iso2022jp_decoder_state = states.EscapeStart;
29329 return decoderError(fatal);
29330 }
29331
29332 // 0x21 to 0x7E
29333 if (inRange(bite, 0x21, 0x7E)) {
29334 // 1. Set the iso-2022-jp decoder state to lead byte.
29335 iso2022jp_decoder_state = states.LeadByte;
29336
29337 // 2. Let pointer be (iso-2022-jp lead − 0x21) × 94 + byte − 0x21.
29338 var pointer = (iso2022jp_lead - 0x21) * 94 + bite - 0x21;
29339
29340 // 3. Let code point be the index code point for pointer in index jis0208.
29341 var code_point = indexCodePointFor(pointer, index('jis0208'));
29342
29343 // 4. If code point is null, return error.
29344 if (code_point === null)
29345 return decoderError(fatal);
29346
29347 // 5. Return a code point whose value is code point.
29348 return code_point;
29349 }
29350
29351 // end-of-stream
29352 if (bite === end_of_stream) {
29353 // Set the iso-2022-jp decoder state to lead byte, prepend
29354 // byte to stream, and return error.
29355 iso2022jp_decoder_state = states.LeadByte;
29356 stream.prepend(bite);
29357 return decoderError(fatal);
29358 }
29359
29360 // Otherwise
29361 // Set iso-2022-jp decoder state to lead byte and return
29362 // error.
29363 iso2022jp_decoder_state = states.LeadByte;
29364 return decoderError(fatal);
29365
29366 case states.EscapeStart:
29367 // Escape start
29368
29369 // 1. If byte is either 0x24 or 0x28, set iso-2022-jp lead to
29370 // byte, iso-2022-jp decoder state to escape, and return
29371 // continue.
29372 if (bite === 0x24 || bite === 0x28) {
29373 iso2022jp_lead = bite;
29374 iso2022jp_decoder_state = states.Escape;
29375 return null;
29376 }
29377
29378 // 2. Prepend byte to stream.
29379 stream.prepend(bite);
29380
29381 // 3. Unset the iso-2022-jp output flag, set iso-2022-jp
29382 // decoder state to iso-2022-jp decoder output state, and
29383 // return error.
29384 iso2022jp_output_flag = false;
29385 iso2022jp_decoder_state = iso2022jp_decoder_output_state;
29386 return decoderError(fatal);
29387
29388 case states.Escape:
29389 // Escape
29390
29391 // 1. Let lead be iso-2022-jp lead and set iso-2022-jp lead to
29392 // 0x00.
29393 var lead = iso2022jp_lead;
29394 iso2022jp_lead = 0x00;
29395
29396 // 2. Let state be null.
29397 var state = null;
29398
29399 // 3. If lead is 0x28 and byte is 0x42, set state to ASCII.
29400 if (lead === 0x28 && bite === 0x42)
29401 state = states.ASCII;
29402
29403 // 4. If lead is 0x28 and byte is 0x4A, set state to Roman.
29404 if (lead === 0x28 && bite === 0x4A)
29405 state = states.Roman;
29406
29407 // 5. If lead is 0x28 and byte is 0x49, set state to Katakana.
29408 if (lead === 0x28 && bite === 0x49)
29409 state = states.Katakana;
29410
29411 // 6. If lead is 0x24 and byte is either 0x40 or 0x42, set
29412 // state to lead byte.
29413 if (lead === 0x24 && (bite === 0x40 || bite === 0x42))
29414 state = states.LeadByte;
29415
29416 // 7. If state is non-null, run these substeps:
29417 if (state !== null) {
29418 // 1. Set iso-2022-jp decoder state and iso-2022-jp decoder
29419 // output state to states.
29420 iso2022jp_decoder_state = iso2022jp_decoder_state = state;
29421
29422 // 2. Let output flag be the iso-2022-jp output flag.
29423 var output_flag = iso2022jp_output_flag;
29424
29425 // 3. Set the iso-2022-jp output flag.
29426 iso2022jp_output_flag = true;
29427
29428 // 4. Return continue, if output flag is unset, and error
29429 // otherwise.
29430 return !output_flag ? null : decoderError(fatal);
29431 }
29432
29433 // 8. Prepend lead and byte to stream.
29434 stream.prepend([lead, bite]);
29435
29436 // 9. Unset the iso-2022-jp output flag, set iso-2022-jp
29437 // decoder state to iso-2022-jp decoder output state and
29438 // return error.
29439 iso2022jp_output_flag = false;
29440 iso2022jp_decoder_state = iso2022jp_decoder_output_state;
29441 return decoderError(fatal);
29442 }
29443 };
29444 }
29445
29446 /**
29447 * @constructor
29448 * @implements {Encoder}
29449 * @param {{fatal: boolean}} options
29450 */
29451 function ISO2022JPEncoder(options) {
29452 var fatal = options.fatal;
29453 // iso-2022-jp's encoder has an associated iso-2022-jp encoder
29454 // state which is one of ASCII, Roman, and jis0208 (initially
29455 // ASCII).
29456 /** @enum */
29457 var states = {
29458 ASCII: 0,
29459 Roman: 1,
29460 jis0208: 2
29461 };
29462 var /** @type {number} */ iso2022jp_state = states.ASCII;
29463 /**
29464 * @param {Stream} stream Input stream.
29465 * @param {number} code_point Next code point read from the stream.
29466 * @return {(number|!Array.<number>)} Byte(s) to emit.
29467 */
29468 this.handler = function(stream, code_point) {
29469 // 1. If code point is end-of-stream and iso-2022-jp encoder
29470 // state is not ASCII, prepend code point to stream, set
29471 // iso-2022-jp encoder state to ASCII, and return three bytes
29472 // 0x1B 0x28 0x42.
29473 if (code_point === end_of_stream &&
29474 iso2022jp_state !== states.ASCII) {
29475 stream.prepend(code_point);
29476 return [0x1B, 0x28, 0x42];
29477 }
29478
29479 // 2. If code point is end-of-stream and iso-2022-jp encoder
29480 // state is ASCII, return finished.
29481 if (code_point === end_of_stream && iso2022jp_state === states.ASCII)
29482 return finished;
29483
29484 // 3. If iso-2022-jp encoder state is ASCII and code point is in
29485 // the range U+0000 to U+007F, return a byte whose value is code
29486 // point.
29487 if (iso2022jp_state === states.ASCII &&
29488 inRange(code_point, 0x0000, 0x007F))
29489 return code_point;
29490
29491 // 4. If iso-2022-jp encoder state is Roman and code point is in
29492 // the range U+0000 to U+007F, excluding U+005C and U+007E, or
29493 // is U+00A5 or U+203E, run these substeps:
29494 if (iso2022jp_state === states.Roman &&
29495 inRange(code_point, 0x0000, 0x007F) &&
29496 code_point !== 0x005C && code_point !== 0x007E) {
29497
29498 // 1. If code point is in the range U+0000 to U+007F, return a
29499 // byte whose value is code point.
29500 if (inRange(code_point, 0x0000, 0x007F))
29501 return code_point;
29502
29503 // 2. If code point is U+00A5, return byte 0x5C.
29504 if (code_point === 0x00A5)
29505 return 0x5C;
29506
29507 // 3. If code point is U+203E, return byte 0x7E.
29508 if (code_point === 0x203E)
29509 return 0x7E;
29510 }
29511
29512 // 5. If code point is in the range U+0000 to U+007F, and
29513 // iso-2022-jp encoder state is not ASCII, prepend code point to
29514 // stream, set iso-2022-jp encoder state to ASCII, and return
29515 // three bytes 0x1B 0x28 0x42.
29516 if (inRange(code_point, 0x0000, 0x007F) &&
29517 iso2022jp_state !== states.ASCII) {
29518 stream.prepend(code_point);
29519 iso2022jp_state = states.ASCII;
29520 return [0x1B, 0x28, 0x42];
29521 }
29522
29523 // 6. If code point is either U+00A5 or U+203E, and iso-2022-jp
29524 // encoder state is not Roman, prepend code point to stream, set
29525 // iso-2022-jp encoder state to Roman, and return three bytes
29526 // 0x1B 0x28 0x4A.
29527 if ((code_point === 0x00A5 || code_point === 0x203E) &&
29528 iso2022jp_state !== states.Roman) {
29529 stream.prepend(code_point);
29530 iso2022jp_state = states.Roman;
29531 return [0x1B, 0x28, 0x4A];
29532 }
29533
29534 // 7. If code point is U+2022, set it to U+FF0D.
29535 if (code_point === 0x2022)
29536 code_point = 0xFF0D;
29537
29538 // 8. Let pointer be the index pointer for code point in index
29539 // jis0208.
29540 var pointer = indexPointerFor(code_point, index('jis0208'));
29541
29542 // 9. If pointer is null, return error with code point.
29543 if (pointer === null)
29544 return encoderError(code_point);
29545
29546 // 10. If iso-2022-jp encoder state is not jis0208, prepend code
29547 // point to stream, set iso-2022-jp encoder state to jis0208,
29548 // and return three bytes 0x1B 0x24 0x42.
29549 if (iso2022jp_state !== states.jis0208) {
29550 stream.prepend(code_point);
29551 iso2022jp_state = states.jis0208;
29552 return [0x1B, 0x24, 0x42];
29553 }
29554
29555 // 11. Let lead be pointer / 94 + 0x21.
29556 var lead = div(pointer, 94) + 0x21;
29557
29558 // 12. Let trail be pointer % 94 + 0x21.
29559 var trail = pointer % 94 + 0x21;
29560
29561 // 13. Return two bytes whose values are lead and trail.
29562 return [lead, trail];
29563 };
29564 }
29565
29566 /** @param {{fatal: boolean}} options */
29567 encoders['iso-2022-jp'] = function(options) {
29568 return new ISO2022JPEncoder(options);
29569 };
29570 /** @param {{fatal: boolean}} options */
29571 decoders['iso-2022-jp'] = function(options) {
29572 return new ISO2022JPDecoder(options);
29573 };
29574
29575 // 12.3 shift_jis
29576
29577 /**
29578 * @constructor
29579 * @implements {Decoder}
29580 * @param {{fatal: boolean}} options
29581 */
29582 function ShiftJISDecoder(options) {
29583 var fatal = options.fatal;
29584 // shift_jis's decoder has an associated shift_jis lead (initially
29585 // 0x00).
29586 var /** @type {number} */ shiftjis_lead = 0x00;
29587 /**
29588 * @param {Stream} stream The stream of bytes being decoded.
29589 * @param {number} bite The next byte read from the stream.
29590 * @return {?(number|!Array.<number>)} The next code point(s)
29591 * decoded, or null if not enough data exists in the input
29592 * stream to decode a complete code point.
29593 */
29594 this.handler = function(stream, bite) {
29595 // 1. If byte is end-of-stream and shift_jis lead is not 0x00,
29596 // set shift_jis lead to 0x00 and return error.
29597 if (bite === end_of_stream && shiftjis_lead !== 0x00) {
29598 shiftjis_lead = 0x00;
29599 return decoderError(fatal);
29600 }
29601
29602 // 2. If byte is end-of-stream and shift_jis lead is 0x00,
29603 // return finished.
29604 if (bite === end_of_stream && shiftjis_lead === 0x00)
29605 return finished;
29606
29607 // 3. If shift_jis lead is not 0x00, let lead be shift_jis lead,
29608 // let pointer be null, set shift_jis lead to 0x00, and then run
29609 // these substeps:
29610 if (shiftjis_lead !== 0x00) {
29611 var lead = shiftjis_lead;
29612 var pointer = null;
29613 shiftjis_lead = 0x00;
29614
29615 // 1. Let offset be 0x40, if byte is less than 0x7F, and 0x41
29616 // otherwise.
29617 var offset = (bite < 0x7F) ? 0x40 : 0x41;
29618
29619 // 2. Let lead offset be 0x81, if lead is less than 0xA0, and
29620 // 0xC1 otherwise.
29621 var lead_offset = (lead < 0xA0) ? 0x81 : 0xC1;
29622
29623 // 3. If byte is in the range 0x40 to 0x7E or 0x80 to 0xFC,
29624 // set pointer to (lead − lead offset) × 188 + byte − offset.
29625 if (inRange(bite, 0x40, 0x7E) || inRange(bite, 0x80, 0xFC))
29626 pointer = (lead - lead_offset) * 188 + bite - offset;
29627
29628 // 4. Let code point be null, if pointer is null, and the
29629 // index code point for pointer in index jis0208 otherwise.
29630 var code_point = (pointer === null) ? null :
29631 indexCodePointFor(pointer, index('jis0208'));
29632
29633 // 5. If code point is null and pointer is in the range 8836
29634 // to 10528, return a code point whose value is 0xE000 +
29635 // pointer − 8836.
29636 if (code_point === null && pointer !== null &&
29637 inRange(pointer, 8836, 10528))
29638 return 0xE000 + pointer - 8836;
29639
29640 // 6. If code point is null and byte is in the range 0x00 to
29641 // 0x7F, prepend byte to stream.
29642 if (code_point === null && inRange(bite, 0x00, 0x7F))
29643 stream.prepend(bite);
29644
29645 // 7. If code point is null, return error.
29646 if (code_point === null)
29647 return decoderError(fatal);
29648
29649 // 8. Return a code point whose value is code point.
29650 return code_point;
29651 }
29652
29653 // 4. If byte is in the range 0x00 to 0x80, return a code point
29654 // whose value is byte.
29655 if (inRange(bite, 0x00, 0x80))
29656 return bite;
29657
29658 // 5. If byte is in the range 0xA1 to 0xDF, return a code point
29659 // whose value is 0xFF61 + byte − 0xA1.
29660 if (inRange(bite, 0xA1, 0xDF))
29661 return 0xFF61 + bite - 0xA1;
29662
29663 // 6. If byte is in the range 0x81 to 0x9F or 0xE0 to 0xFC, set
29664 // shift_jis lead to byte and return continue.
29665 if (inRange(bite, 0x81, 0x9F) || inRange(bite, 0xE0, 0xFC)) {
29666 shiftjis_lead = bite;
29667 return null;
29668 }
29669
29670 // 7. Return error.
29671 return decoderError(fatal);
29672 };
29673 }
29674
29675 /**
29676 * @constructor
29677 * @implements {Encoder}
29678 * @param {{fatal: boolean}} options
29679 */
29680 function ShiftJISEncoder(options) {
29681 var fatal = options.fatal;
29682 /**
29683 * @param {Stream} stream Input stream.
29684 * @param {number} code_point Next code point read from the stream.
29685 * @return {(number|!Array.<number>)} Byte(s) to emit.
29686 */
29687 this.handler = function(stream, code_point) {
29688 // 1. If code point is end-of-stream, return finished.
29689 if (code_point === end_of_stream)
29690 return finished;
29691
29692 // 2. If code point is in the range U+0000 to U+0080, return a
29693 // byte whose value is code point.
29694 if (inRange(code_point, 0x0000, 0x0080))
29695 return code_point;
29696
29697 // 3. If code point is U+00A5, return byte 0x5C.
29698 if (code_point === 0x00A5)
29699 return 0x5C;
29700
29701 // 4. If code point is U+203E, return byte 0x7E.
29702 if (code_point === 0x203E)
29703 return 0x7E;
29704
29705 // 5. If code point is in the range U+FF61 to U+FF9F, return a
29706 // byte whose value is code point − 0xFF61 + 0xA1.
29707 if (inRange(code_point, 0xFF61, 0xFF9F))
29708 return code_point - 0xFF61 + 0xA1;
29709
29710 // 6. If code point is U+2022, set it to U+FF0D.
29711 if (code_point === 0x2022)
29712 code_point = 0xFF0D;
29713
29714 // 7. Let pointer be the index shift_jis pointer for code point.
29715 var pointer = indexShiftJISPointerFor(code_point);
29716
29717 // 8. If pointer is null, return error with code point.
29718 if (pointer === null)
29719 return encoderError(code_point);
29720
29721 // 9. Let lead be pointer / 188.
29722 var lead = div(pointer, 188);
29723
29724 // 10. Let lead offset be 0x81, if lead is less than 0x1F, and
29725 // 0xC1 otherwise.
29726 var lead_offset = (lead < 0x1F) ? 0x81 : 0xC1;
29727
29728 // 11. Let trail be pointer % 188.
29729 var trail = pointer % 188;
29730
29731 // 12. Let offset be 0x40, if trail is less than 0x3F, and 0x41
29732 // otherwise.
29733 var offset = (trail < 0x3F) ? 0x40 : 0x41;
29734
29735 // 13. Return two bytes whose values are lead + lead offset and
29736 // trail + offset.
29737 return [lead + lead_offset, trail + offset];
29738 };
29739 }
29740
29741 /** @param {{fatal: boolean}} options */
29742 encoders['shift_jis'] = function(options) {
29743 return new ShiftJISEncoder(options);
29744 };
29745 /** @param {{fatal: boolean}} options */
29746 decoders['shift_jis'] = function(options) {
29747 return new ShiftJISDecoder(options);
29748 };
29749
29750 //
29751 // 13. Legacy multi-byte Korean encodings
29752 //
29753
29754 // 13.1 euc-kr
29755
29756 /**
29757 * @constructor
29758 * @implements {Decoder}
29759 * @param {{fatal: boolean}} options
29760 */
29761 function EUCKRDecoder(options) {
29762 var fatal = options.fatal;
29763
29764 // euc-kr's decoder has an associated euc-kr lead (initially 0x00).
29765 var /** @type {number} */ euckr_lead = 0x00;
29766 /**
29767 * @param {Stream} stream The stream of bytes being decoded.
29768 * @param {number} bite The next byte read from the stream.
29769 * @return {?(number|!Array.<number>)} The next code point(s)
29770 * decoded, or null if not enough data exists in the input
29771 * stream to decode a complete code point.
29772 */
29773 this.handler = function(stream, bite) {
29774 // 1. If byte is end-of-stream and euc-kr lead is not 0x00, set
29775 // euc-kr lead to 0x00 and return error.
29776 if (bite === end_of_stream && euckr_lead !== 0) {
29777 euckr_lead = 0x00;
29778 return decoderError(fatal);
29779 }
29780
29781 // 2. If byte is end-of-stream and euc-kr lead is 0x00, return
29782 // finished.
29783 if (bite === end_of_stream && euckr_lead === 0)
29784 return finished;
29785
29786 // 3. If euc-kr lead is not 0x00, let lead be euc-kr lead, let
29787 // pointer be null, set euc-kr lead to 0x00, and then run these
29788 // substeps:
29789 if (euckr_lead !== 0x00) {
29790 var lead = euckr_lead;
29791 var pointer = null;
29792 euckr_lead = 0x00;
29793
29794 // 1. If byte is in the range 0x41 to 0xFE, set pointer to
29795 // (lead − 0x81) × 190 + (byte − 0x41).
29796 if (inRange(bite, 0x41, 0xFE))
29797 pointer = (lead - 0x81) * 190 + (bite - 0x41);
29798
29799 // 2. Let code point be null, if pointer is null, and the
29800 // index code point for pointer in index euc-kr otherwise.
29801 var code_point = (pointer === null) ? null : indexCodePointFor(pointer, index('euc-kr'));
29802
29803 // 3. If code point is null and byte is in the range 0x00 to
29804 // 0x7F, prepend byte to stream.
29805 if (pointer === null && inRange(bite, 0x00, 0x7F))
29806 stream.prepend(bite);
29807
29808 // 4. If code point is null, return error.
29809 if (code_point === null)
29810 return decoderError(fatal);
29811
29812 // 5. Return a code point whose value is code point.
29813 return code_point;
29814 }
29815
29816 // 4. If byte is in the range 0x00 to 0x7F, return a code point
29817 // whose value is byte.
29818 if (inRange(bite, 0x00, 0x7F))
29819 return bite;
29820
29821 // 5. If byte is in the range 0x81 to 0xFE, set euc-kr lead to
29822 // byte and return continue.
29823 if (inRange(bite, 0x81, 0xFE)) {
29824 euckr_lead = bite;
29825 return null;
29826 }
29827
29828 // 6. Return error.
29829 return decoderError(fatal);
29830 };
29831 }
29832
29833 /**
29834 * @constructor
29835 * @implements {Encoder}
29836 * @param {{fatal: boolean}} options
29837 */
29838 function EUCKREncoder(options) {
29839 var fatal = options.fatal;
29840 /**
29841 * @param {Stream} stream Input stream.
29842 * @param {number} code_point Next code point read from the stream.
29843 * @return {(number|!Array.<number>)} Byte(s) to emit.
29844 */
29845 this.handler = function(stream, code_point) {
29846 // 1. If code point is end-of-stream, return finished.
29847 if (code_point === end_of_stream)
29848 return finished;
29849
29850 // 2. If code point is in the range U+0000 to U+007F, return a
29851 // byte whose value is code point.
29852 if (inRange(code_point, 0x0000, 0x007F))
29853 return code_point;
29854
29855 // 3. Let pointer be the index pointer for code point in index
29856 // euc-kr.
29857 var pointer = indexPointerFor(code_point, index('euc-kr'));
29858
29859 // 4. If pointer is null, return error with code point.
29860 if (pointer === null)
29861 return encoderError(code_point);
29862
29863 // 5. Let lead be pointer / 190 + 0x81.
29864 var lead = div(pointer, 190) + 0x81;
29865
29866 // 6. Let trail be pointer % 190 + 0x41.
29867 var trail = (pointer % 190) + 0x41;
29868
29869 // 7. Return two bytes whose values are lead and trail.
29870 return [lead, trail];
29871 };
29872 }
29873
29874 /** @param {{fatal: boolean}} options */
29875 encoders['euc-kr'] = function(options) {
29876 return new EUCKREncoder(options);
29877 };
29878 /** @param {{fatal: boolean}} options */
29879 decoders['euc-kr'] = function(options) {
29880 return new EUCKRDecoder(options);
29881 };
29882
29883
29884 //
29885 // 14. Legacy miscellaneous encodings
29886 //
29887
29888 // 14.1 replacement
29889
29890 // Not needed - API throws RangeError
29891
29892 // 14.2 utf-16
29893
29894 /**
29895 * @param {number} code_unit
29896 * @param {boolean} utf16be
29897 * @return {!Array.<number>} bytes
29898 */
29899 function convertCodeUnitToBytes(code_unit, utf16be) {
29900 // 1. Let byte1 be code unit >> 8.
29901 var byte1 = code_unit >> 8;
29902
29903 // 2. Let byte2 be code unit & 0x00FF.
29904 var byte2 = code_unit & 0x00FF;
29905
29906 // 3. Then return the bytes in order:
29907 // utf-16be flag is set: byte1, then byte2.
29908 if (utf16be)
29909 return [byte1, byte2];
29910 // utf-16be flag is unset: byte2, then byte1.
29911 return [byte2, byte1];
29912 }
29913
29914 /**
29915 * @constructor
29916 * @implements {Decoder}
29917 * @param {boolean} utf16_be True if big-endian, false if little-endian.
29918 * @param {{fatal: boolean}} options
29919 */
29920 function UTF16Decoder(utf16_be, options) {
29921 var fatal = options.fatal;
29922 var /** @type {?number} */ utf16_lead_byte = null,
29923 /** @type {?number} */ utf16_lead_surrogate = null;
29924 /**
29925 * @param {Stream} stream The stream of bytes being decoded.
29926 * @param {number} bite The next byte read from the stream.
29927 * @return {?(number|!Array.<number>)} The next code point(s)
29928 * decoded, or null if not enough data exists in the input
29929 * stream to decode a complete code point.
29930 */
29931 this.handler = function(stream, bite) {
29932 // 1. If byte is end-of-stream and either utf-16 lead byte or
29933 // utf-16 lead surrogate is not null, set utf-16 lead byte and
29934 // utf-16 lead surrogate to null, and return error.
29935 if (bite === end_of_stream && (utf16_lead_byte !== null ||
29936 utf16_lead_surrogate !== null)) {
29937 return decoderError(fatal);
29938 }
29939
29940 // 2. If byte is end-of-stream and utf-16 lead byte and utf-16
29941 // lead surrogate are null, return finished.
29942 if (bite === end_of_stream && utf16_lead_byte === null &&
29943 utf16_lead_surrogate === null) {
29944 return finished;
29945 }
29946
29947 // 3. If utf-16 lead byte is null, set utf-16 lead byte to byte
29948 // and return continue.
29949 if (utf16_lead_byte === null) {
29950 utf16_lead_byte = bite;
29951 return null;
29952 }
29953
29954 // 4. Let code unit be the result of:
29955 var code_unit;
29956 if (utf16_be) {
29957 // utf-16be decoder flag is set
29958 // (utf-16 lead byte << 8) + byte.
29959 code_unit = (utf16_lead_byte << 8) + bite;
29960 } else {
29961 // utf-16be decoder flag is unset
29962 // (byte << 8) + utf-16 lead byte.
29963 code_unit = (bite << 8) + utf16_lead_byte;
29964 }
29965 // Then set utf-16 lead byte to null.
29966 utf16_lead_byte = null;
29967
29968 // 5. If utf-16 lead surrogate is not null, let lead surrogate
29969 // be utf-16 lead surrogate, set utf-16 lead surrogate to null,
29970 // and then run these substeps:
29971 if (utf16_lead_surrogate !== null) {
29972 var lead_surrogate = utf16_lead_surrogate;
29973 utf16_lead_surrogate = null;
29974
29975 // 1. If code unit is in the range U+DC00 to U+DFFF, return a
29976 // code point whose value is 0x10000 + ((lead surrogate −
29977 // 0xD800) << 10) + (code unit − 0xDC00).
29978 if (inRange(code_unit, 0xDC00, 0xDFFF)) {
29979 return 0x10000 + (lead_surrogate - 0xD800) * 0x400 +
29980 (code_unit - 0xDC00);
29981 }
29982
29983 // 2. Prepend the sequence resulting of converting code unit
29984 // to bytes using utf-16be decoder flag to stream and return
29985 // error.
29986 stream.prepend(convertCodeUnitToBytes(code_unit, utf16_be));
29987 return decoderError(fatal);
29988 }
29989
29990 // 6. If code unit is in the range U+D800 to U+DBFF, set utf-16
29991 // lead surrogate to code unit and return continue.
29992 if (inRange(code_unit, 0xD800, 0xDBFF)) {
29993 utf16_lead_surrogate = code_unit;
29994 return null;
29995 }
29996
29997 // 7. If code unit is in the range U+DC00 to U+DFFF, return
29998 // error.
29999 if (inRange(code_unit, 0xDC00, 0xDFFF))
30000 return decoderError(fatal);
30001
30002 // 8. Return code point code unit.
30003 return code_unit;
30004 };
30005 }
30006
30007 /**
30008 * @constructor
30009 * @implements {Encoder}
30010 * @param {boolean} utf16_be True if big-endian, false if little-endian.
30011 * @param {{fatal: boolean}} options
30012 */
30013 function UTF16Encoder(utf16_be, options) {
30014 var fatal = options.fatal;
30015 /**
30016 * @param {Stream} stream Input stream.
30017 * @param {number} code_point Next code point read from the stream.
30018 * @return {(number|!Array.<number>)} Byte(s) to emit.
30019 */
30020 this.handler = function(stream, code_point) {
30021 // 1. If code point is end-of-stream, return finished.
30022 if (code_point === end_of_stream)
30023 return finished;
30024
30025 // 2. If code point is in the range U+0000 to U+FFFF, return the
30026 // sequence resulting of converting code point to bytes using
30027 // utf-16be encoder flag.
30028 if (inRange(code_point, 0x0000, 0xFFFF))
30029 return convertCodeUnitToBytes(code_point, utf16_be);
30030
30031 // 3. Let lead be ((code point − 0x10000) >> 10) + 0xD800,
30032 // converted to bytes using utf-16be encoder flag.
30033 var lead = convertCodeUnitToBytes(
30034 ((code_point - 0x10000) >> 10) + 0xD800, utf16_be);
30035
30036 // 4. Let trail be ((code point − 0x10000) & 0x3FF) + 0xDC00,
30037 // converted to bytes using utf-16be encoder flag.
30038 var trail = convertCodeUnitToBytes(
30039 ((code_point - 0x10000) & 0x3FF) + 0xDC00, utf16_be);
30040
30041 // 5. Return a byte sequence of lead followed by trail.
30042 return lead.concat(trail);
30043 };
30044 }
30045
30046 // 14.3 utf-16be
30047 /** @param {{fatal: boolean}} options */
30048 encoders['utf-16be'] = function(options) {
30049 return new UTF16Encoder(true, options);
30050 };
30051 /** @param {{fatal: boolean}} options */
30052 decoders['utf-16be'] = function(options) {
30053 return new UTF16Decoder(true, options);
30054 };
30055
30056 // 14.4 utf-16le
30057 /** @param {{fatal: boolean}} options */
30058 encoders['utf-16le'] = function(options) {
30059 return new UTF16Encoder(false, options);
30060 };
30061 /** @param {{fatal: boolean}} options */
30062 decoders['utf-16le'] = function(options) {
30063 return new UTF16Decoder(false, options);
30064 };
30065
30066 // 14.5 x-user-defined
30067
30068 /**
30069 * @constructor
30070 * @implements {Decoder}
30071 * @param {{fatal: boolean}} options
30072 */
30073 function XUserDefinedDecoder(options) {
30074 var fatal = options.fatal;
30075 /**
30076 * @param {Stream} stream The stream of bytes being decoded.
30077 * @param {number} bite The next byte read from the stream.
30078 * @return {?(number|!Array.<number>)} The next code point(s)
30079 * decoded, or null if not enough data exists in the input
30080 * stream to decode a complete code point.
30081 */
30082 this.handler = function(stream, bite) {
30083 // 1. If byte is end-of-stream, return finished.
30084 if (bite === end_of_stream)
30085 return finished;
30086
30087 // 2. If byte is in the range 0x00 to 0x7F, return a code point
30088 // whose value is byte.
30089 if (inRange(bite, 0x00, 0x7F))
30090 return bite;
30091
30092 // 3. Return a code point whose value is 0xF780 + byte − 0x80.
30093 return 0xF780 + bite - 0x80;
30094 };
30095 }
30096
30097 /**
30098 * @constructor
30099 * @implements {Encoder}
30100 * @param {{fatal: boolean}} options
30101 */
30102 function XUserDefinedEncoder(options) {
30103 var fatal = options.fatal;
30104 /**
30105 * @param {Stream} stream Input stream.
30106 * @param {number} code_point Next code point read from the stream.
30107 * @return {(number|!Array.<number>)} Byte(s) to emit.
30108 */
30109 this.handler = function(stream, code_point) {
30110 // 1.If code point is end-of-stream, return finished.
30111 if (code_point === end_of_stream)
30112 return finished;
30113
30114 // 2. If code point is in the range U+0000 to U+007F, return a
30115 // byte whose value is code point.
30116 if (inRange(code_point, 0x0000, 0x007F))
30117 return code_point;
30118
30119 // 3. If code point is in the range U+F780 to U+F7FF, return a
30120 // byte whose value is code point − 0xF780 + 0x80.
30121 if (inRange(code_point, 0xF780, 0xF7FF))
30122 return code_point - 0xF780 + 0x80;
30123
30124 // 4. Return error with code point.
30125 return encoderError(code_point);
30126 };
30127 }
30128
30129 /** @param {{fatal: boolean}} options */
30130 encoders['x-user-defined'] = function(options) {
30131 return new XUserDefinedEncoder(options);
30132 };
30133 /** @param {{fatal: boolean}} options */
30134 decoders['x-user-defined'] = function(options) {
30135 return new XUserDefinedDecoder(options);
30136 };
30137
30138 if (!global['TextEncoder'])
30139 global['TextEncoder'] = TextEncoder;
30140 if (!global['TextDecoder'])
30141 global['TextDecoder'] = TextDecoder;
30142}(this));
30143
30144},{"./encoding-indexes.js":320}],322:[function(require,module,exports){
30145'use strict';
30146
30147Object.defineProperty(exports, "__esModule", {
30148 value: true
30149});
30150exports.v1 = undefined;
30151
30152var _index = require('./v1/index');
30153
30154var v1 = _interopRequireWildcard(_index);
30155
30156function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
30157
30158exports.v1 = v1; /**
30159 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
30160 *
30161 * This file is part of Neo4j.
30162 *
30163 * Licensed under the Apache License, Version 2.0 (the "License");
30164 * you may not use this file except in compliance with the License.
30165 * You may obtain a copy of the License at
30166 *
30167 * http://www.apache.org/licenses/LICENSE-2.0
30168 *
30169 * Unless required by applicable law or agreed to in writing, software
30170 * distributed under the License is distributed on an "AS IS" BASIS,
30171 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30172 * See the License for the specific language governing permissions and
30173 * limitations under the License.
30174 */
30175
30176exports.default = v1;
30177
30178},{"./v1/index":326}],323:[function(require,module,exports){
30179'use strict';
30180
30181Object.defineProperty(exports, "__esModule", {
30182 value: true
30183});
30184exports.WRITE = exports.READ = exports.Driver = undefined;
30185
30186var _maxSafeInteger = require('babel-runtime/core-js/number/max-safe-integer');
30187
30188var _maxSafeInteger2 = _interopRequireDefault(_maxSafeInteger);
30189
30190var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
30191
30192var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
30193
30194var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
30195
30196var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
30197
30198var _get2 = require('babel-runtime/helpers/get');
30199
30200var _get3 = _interopRequireDefault(_get2);
30201
30202var _inherits2 = require('babel-runtime/helpers/inherits');
30203
30204var _inherits3 = _interopRequireDefault(_inherits2);
30205
30206var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
30207
30208var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
30209
30210var _createClass2 = require('babel-runtime/helpers/createClass');
30211
30212var _createClass3 = _interopRequireDefault(_createClass2);
30213
30214var _session = require('./session');
30215
30216var _session2 = _interopRequireDefault(_session);
30217
30218var _pool = require('./internal/pool');
30219
30220var _pool2 = _interopRequireDefault(_pool);
30221
30222var _connector = require('./internal/connector');
30223
30224var _streamObserver = require('./internal/stream-observer');
30225
30226var _streamObserver2 = _interopRequireDefault(_streamObserver);
30227
30228var _error = require('./error');
30229
30230var _connectionProviders = require('./internal/connection-providers');
30231
30232var _bookmark = require('./internal/bookmark');
30233
30234var _bookmark2 = _interopRequireDefault(_bookmark);
30235
30236var _connectivityVerifier = require('./internal/connectivity-verifier');
30237
30238var _connectivityVerifier2 = _interopRequireDefault(_connectivityVerifier);
30239
30240var _poolConfig = require('./internal/pool-config');
30241
30242var _poolConfig2 = _interopRequireDefault(_poolConfig);
30243
30244function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30245
30246var DEFAULT_MAX_CONNECTION_LIFETIME = 60 * 60 * 1000; // 1 hour
30247
30248/**
30249 * Constant that represents read session access mode.
30250 * Should be used like this: <code>driver.session(READ)</code>.
30251 * @type {string}
30252 */
30253/**
30254 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
30255 *
30256 * This file is part of Neo4j.
30257 *
30258 * Licensed under the Apache License, Version 2.0 (the "License");
30259 * you may not use this file except in compliance with the License.
30260 * You may obtain a copy of the License at
30261 *
30262 * http://www.apache.org/licenses/LICENSE-2.0
30263 *
30264 * Unless required by applicable law or agreed to in writing, software
30265 * distributed under the License is distributed on an "AS IS" BASIS,
30266 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30267 * See the License for the specific language governing permissions and
30268 * limitations under the License.
30269 */
30270
30271var READ = 'READ';
30272
30273/**
30274 * Constant that represents write session access mode.
30275 * Should be used like this: <code>driver.session(WRITE)</code>.
30276 * @type {string}
30277 */
30278var WRITE = 'WRITE';
30279
30280/**
30281 * A driver maintains one or more {@link Session}s with a remote
30282 * Neo4j instance. Through the {@link Session}s you can send statements
30283 * and retrieve results from the database.
30284 *
30285 * Drivers are reasonably expensive to create - you should strive to keep one
30286 * driver instance around per Neo4j Instance you connect to.
30287 *
30288 * @access public
30289 */
30290
30291var Driver = function () {
30292 /**
30293 * You should not be calling this directly, instead use {@link driver}.
30294 * @constructor
30295 * @param {string} hostPort
30296 * @param {string} userAgent
30297 * @param {object} token
30298 * @param {object} config
30299 * @protected
30300 */
30301 function Driver(hostPort, userAgent) {
30302 var token = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
30303 var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
30304 (0, _classCallCheck3.default)(this, Driver);
30305
30306 sanitizeConfig(config);
30307
30308 this._hostPort = hostPort;
30309 this._userAgent = userAgent;
30310 this._openSessions = {};
30311 this._sessionIdGenerator = 0;
30312 this._token = token;
30313 this._config = config;
30314 this._pool = new _pool2.default(this._createConnection.bind(this), this._destroyConnection.bind(this), this._validateConnection.bind(this), _poolConfig2.default.fromDriverConfig(config));
30315
30316 /**
30317 * Reference to the connection provider. Initialized lazily by {@link _getOrCreateConnectionProvider}.
30318 * @type {ConnectionProvider}
30319 * @protected
30320 */
30321 this._connectionProvider = null;
30322
30323 this._onCompleted = null;
30324 }
30325
30326 /**
30327 * Get the installed connectivity verification callback.
30328 * @return {null|function}
30329 * @deprecated driver can be used directly once instantiated, use of this callback is not required.
30330 */
30331
30332
30333 (0, _createClass3.default)(Driver, [{
30334 key: '_createConnection',
30335
30336
30337 /**
30338 * Create a new connection instance.
30339 * @return {Connection} new connector-api session instance, a low level session API.
30340 * @access private
30341 */
30342 value: function _createConnection(hostPort, release) {
30343 var sessionId = this._sessionIdGenerator++;
30344 var conn = (0, _connector.connect)(hostPort, this._config, this._connectionErrorCode());
30345 var streamObserver = new _ConnectionStreamObserver(this, conn);
30346 conn.initialize(this._userAgent, this._token, streamObserver);
30347 conn._id = sessionId;
30348 conn._release = function () {
30349 return release(hostPort, conn);
30350 };
30351
30352 this._openSessions[sessionId] = conn;
30353 return conn;
30354 }
30355
30356 /**
30357 * Check that a connection is usable
30358 * @return {boolean} true if the connection is open
30359 * @access private
30360 **/
30361
30362 }, {
30363 key: '_validateConnection',
30364 value: function _validateConnection(conn) {
30365 if (!conn.isOpen()) {
30366 return false;
30367 }
30368
30369 var maxConnectionLifetime = this._config.maxConnectionLifetime;
30370 var lifetime = Date.now() - conn.creationTimestamp;
30371 return lifetime <= maxConnectionLifetime;
30372 }
30373
30374 /**
30375 * Dispose of a live session, closing any associated resources.
30376 * @return {Session} new session.
30377 * @access private
30378 */
30379
30380 }, {
30381 key: '_destroyConnection',
30382 value: function _destroyConnection(conn) {
30383 delete this._openSessions[conn._id];
30384 conn.close();
30385 }
30386
30387 /**
30388 * Acquire a session to communicate with the database. The driver maintains
30389 * a pool of sessions, so calling this method is normally cheap because you
30390 * will be pulling a session out of the common pool.
30391 *
30392 * This comes with some responsibility - make sure you always call
30393 * {@link close} when you are done using a session, and likewise,
30394 * make sure you don't close your session before you are done using it. Once
30395 * it is returned to the pool, the session will be reset to a clean state and
30396 * made available for others to use.
30397 *
30398 * @param {string} [mode=WRITE] the access mode of this session, allowed values are {@link READ} and {@link WRITE}.
30399 * @param {string|string[]} [bookmarkOrBookmarks=null] the initial reference or references to some previous
30400 * transactions. Value is optional and absence indicates that that the bookmarks do not exist or are unknown.
30401 * @return {Session} new session.
30402 */
30403
30404 }, {
30405 key: 'session',
30406 value: function session(mode, bookmarkOrBookmarks) {
30407 var sessionMode = Driver._validateSessionMode(mode);
30408 var connectionProvider = this._getOrCreateConnectionProvider();
30409 var bookmark = new _bookmark2.default(bookmarkOrBookmarks);
30410 return this._createSession(sessionMode, connectionProvider, bookmark, this._config);
30411 }
30412 }, {
30413 key: '_createConnectionProvider',
30414
30415
30416 // Extension point
30417 value: function _createConnectionProvider(hostPort, connectionPool, driverOnErrorCallback) {
30418 return new _connectionProviders.DirectConnectionProvider(hostPort, connectionPool, driverOnErrorCallback);
30419 }
30420
30421 // Extension point
30422
30423 }, {
30424 key: '_createSession',
30425 value: function _createSession(mode, connectionProvider, bookmark, config) {
30426 return new _session2.default(mode, connectionProvider, bookmark, config);
30427 }
30428
30429 // Extension point
30430
30431 }, {
30432 key: '_connectionErrorCode',
30433 value: function _connectionErrorCode() {
30434 // connection errors might result in different error codes depending on the driver
30435 return _error.SERVICE_UNAVAILABLE;
30436 }
30437 }, {
30438 key: '_getOrCreateConnectionProvider',
30439 value: function _getOrCreateConnectionProvider() {
30440 if (!this._connectionProvider) {
30441 var driverOnErrorCallback = this._driverOnErrorCallback.bind(this);
30442 this._connectionProvider = this._createConnectionProvider(this._hostPort, this._pool, driverOnErrorCallback);
30443 }
30444 return this._connectionProvider;
30445 }
30446 }, {
30447 key: '_driverOnErrorCallback',
30448 value: function _driverOnErrorCallback(error) {
30449 var userDefinedOnErrorCallback = this.onError;
30450 if (userDefinedOnErrorCallback && error.code === _error.SERVICE_UNAVAILABLE) {
30451 userDefinedOnErrorCallback(error);
30452 } else {
30453 // we don't need to tell the driver about this error
30454 }
30455 }
30456
30457 /**
30458 * Close all open sessions and other associated resources. You should
30459 * make sure to use this when you are done with this driver instance.
30460 * @return undefined
30461 */
30462
30463 }, {
30464 key: 'close',
30465 value: function close() {
30466 for (var sessionId in this._openSessions) {
30467 if (this._openSessions.hasOwnProperty(sessionId)) {
30468 this._openSessions[sessionId].close();
30469 }
30470 this._pool.purgeAll();
30471 }
30472 }
30473 }, {
30474 key: 'onCompleted',
30475 get: function get() {
30476 return this._onCompleted;
30477 }
30478
30479 /**
30480 * Install a connectivity verification callback.
30481 * @param {null|function} callback the new function to be notified about successful connection.
30482 * @deprecated driver can be used directly once instantiated, use of this callback is not required.
30483 */
30484 ,
30485 set: function set(callback) {
30486 this._onCompleted = callback;
30487 if (this._onCompleted) {
30488 var connectionProvider = this._getOrCreateConnectionProvider();
30489 var connectivityVerifier = new _connectivityVerifier2.default(connectionProvider, this._onCompleted);
30490 connectivityVerifier.verify();
30491 }
30492 }
30493 }], [{
30494 key: '_validateSessionMode',
30495 value: function _validateSessionMode(rawMode) {
30496 var mode = rawMode || WRITE;
30497 if (mode !== READ && mode !== WRITE) {
30498 throw (0, _error.newError)('Illegal session mode ' + mode);
30499 }
30500 return mode;
30501 }
30502 }]);
30503 return Driver;
30504}();
30505
30506/** Internal stream observer used for connection state */
30507
30508
30509var _ConnectionStreamObserver = function (_StreamObserver) {
30510 (0, _inherits3.default)(_ConnectionStreamObserver, _StreamObserver);
30511
30512 function _ConnectionStreamObserver(driver, conn) {
30513 (0, _classCallCheck3.default)(this, _ConnectionStreamObserver);
30514
30515 var _this = (0, _possibleConstructorReturn3.default)(this, (_ConnectionStreamObserver.__proto__ || (0, _getPrototypeOf2.default)(_ConnectionStreamObserver)).call(this));
30516
30517 _this._driver = driver;
30518 _this._conn = conn;
30519 _this._hasFailed = false;
30520 return _this;
30521 }
30522
30523 (0, _createClass3.default)(_ConnectionStreamObserver, [{
30524 key: 'onError',
30525 value: function onError(error) {
30526 if (!this._hasFailed) {
30527 (0, _get3.default)(_ConnectionStreamObserver.prototype.__proto__ || (0, _getPrototypeOf2.default)(_ConnectionStreamObserver.prototype), 'onError', this).call(this, error);
30528 if (this._driver.onError) {
30529 this._driver.onError(error);
30530 }
30531 this._hasFailed = true;
30532 }
30533 }
30534 }]);
30535 return _ConnectionStreamObserver;
30536}(_streamObserver2.default);
30537
30538/**
30539 * @private
30540 */
30541
30542
30543function sanitizeConfig(config) {
30544 config.maxConnectionLifetime = sanitizeIntValue(config.maxConnectionLifetime, DEFAULT_MAX_CONNECTION_LIFETIME);
30545 config.maxConnectionPoolSize = sanitizeIntValue(config.maxConnectionPoolSize, _poolConfig.DEFAULT_MAX_SIZE);
30546 config.connectionAcquisitionTimeout = sanitizeIntValue(config.connectionAcquisitionTimeout, _poolConfig.DEFAULT_ACQUISITION_TIMEOUT);
30547}
30548
30549function sanitizeIntValue(rawValue, defaultWhenAbsent) {
30550 var sanitizedValue = parseInt(rawValue, 10);
30551 if (sanitizedValue > 0 || sanitizedValue === 0) {
30552 return sanitizedValue;
30553 } else if (sanitizedValue < 0) {
30554 return _maxSafeInteger2.default;
30555 } else {
30556 return defaultWhenAbsent;
30557 }
30558}
30559
30560exports.Driver = Driver;
30561exports.READ = READ;
30562exports.WRITE = WRITE;
30563exports.default = Driver;
30564
30565},{"./error":324,"./internal/bookmark":328,"./internal/connection-providers":335,"./internal/connectivity-verifier":336,"./internal/connector":337,"./internal/pool":351,"./internal/pool-config":350,"./internal/stream-observer":358,"./session":368,"babel-runtime/core-js/number/max-safe-integer":20,"babel-runtime/core-js/object/get-prototype-of":26,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34,"babel-runtime/helpers/get":36,"babel-runtime/helpers/inherits":37,"babel-runtime/helpers/possibleConstructorReturn":38}],324:[function(require,module,exports){
30566'use strict';
30567
30568Object.defineProperty(exports, "__esModule", {
30569 value: true
30570});
30571exports.PROTOCOL_ERROR = exports.SESSION_EXPIRED = exports.SERVICE_UNAVAILABLE = exports.Neo4jError = exports.newError = undefined;
30572
30573var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
30574
30575var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
30576
30577var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
30578
30579var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
30580
30581var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
30582
30583var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
30584
30585var _inherits2 = require('babel-runtime/helpers/inherits');
30586
30587var _inherits3 = _interopRequireDefault(_inherits2);
30588
30589function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30590
30591/**
30592 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
30593 *
30594 * This file is part of Neo4j.
30595 *
30596 * Licensed under the Apache License, Version 2.0 (the "License");
30597 * you may not use this file except in compliance with the License.
30598 * You may obtain a copy of the License at
30599 *
30600 * http://www.apache.org/licenses/LICENSE-2.0
30601 *
30602 * Unless required by applicable law or agreed to in writing, software
30603 * distributed under the License is distributed on an "AS IS" BASIS,
30604 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30605 * See the License for the specific language governing permissions and
30606 * limitations under the License.
30607 */
30608
30609// A common place for constructing error objects, to keep them
30610// uniform across the driver surface.
30611
30612/**
30613 * Error code representing complete loss of service. Used by {@link Neo4jError#code}.
30614 * @type {string}
30615 */
30616var SERVICE_UNAVAILABLE = 'ServiceUnavailable';
30617
30618/**
30619 * Error code representing transient loss of service. Used by {@link Neo4jError#code}.
30620 * @type {string}
30621 */
30622var SESSION_EXPIRED = 'SessionExpired';
30623
30624/**
30625 * Error code representing serialization/deserialization issue in the Bolt protocol. Used by {@link Neo4jError#code}.
30626 * @type {string}
30627 */
30628var PROTOCOL_ERROR = 'ProtocolError';
30629
30630function newError(message) {
30631 var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "N/A";
30632
30633 // TODO: Idea is that we can check the code here and throw sub-classes
30634 // of Neo4jError as appropriate
30635 return new Neo4jError(message, code);
30636}
30637
30638/**
30639 * Class for all errors thrown/returned by the driver.
30640 */
30641
30642var Neo4jError = function (_Error) {
30643 (0, _inherits3.default)(Neo4jError, _Error);
30644
30645 /**
30646 * @constructor
30647 * @param {string} message - The error message.
30648 * @param {string} code - Optional error code. Will be populated when error originates in the database.
30649 */
30650 function Neo4jError(message) {
30651 var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'N/A';
30652 (0, _classCallCheck3.default)(this, Neo4jError);
30653
30654 var _this = (0, _possibleConstructorReturn3.default)(this, (Neo4jError.__proto__ || (0, _getPrototypeOf2.default)(Neo4jError)).call(this, message));
30655
30656 _this.message = message;
30657 _this.code = code;
30658 _this.name = "Neo4jError";
30659 return _this;
30660 }
30661
30662 return Neo4jError;
30663}(Error);
30664
30665exports.newError = newError;
30666exports.Neo4jError = Neo4jError;
30667exports.SERVICE_UNAVAILABLE = SERVICE_UNAVAILABLE;
30668exports.SESSION_EXPIRED = SESSION_EXPIRED;
30669exports.PROTOCOL_ERROR = PROTOCOL_ERROR;
30670
30671},{"babel-runtime/core-js/object/get-prototype-of":26,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/inherits":37,"babel-runtime/helpers/possibleConstructorReturn":38}],325:[function(require,module,exports){
30672"use strict";
30673
30674Object.defineProperty(exports, "__esModule", {
30675 value: true
30676});
30677exports.PathSegment = exports.Path = exports.UnboundRelationship = exports.Relationship = exports.Node = undefined;
30678
30679var _stringify = require("babel-runtime/core-js/json/stringify");
30680
30681var _stringify2 = _interopRequireDefault(_stringify);
30682
30683var _keys = require("babel-runtime/core-js/object/keys");
30684
30685var _keys2 = _interopRequireDefault(_keys);
30686
30687var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
30688
30689var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
30690
30691var _createClass2 = require("babel-runtime/helpers/createClass");
30692
30693var _createClass3 = _interopRequireDefault(_createClass2);
30694
30695var _integer = require("./integer");
30696
30697var _integer2 = _interopRequireDefault(_integer);
30698
30699function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30700
30701/**
30702 * Class for Node Type.
30703 */
30704var Node = function () {
30705 /**
30706 * @constructor
30707 * @param {Integer} identity - Unique identity
30708 * @param {Array<string>} labels - Array for all labels
30709 * @param {Object} properties - Map with node properties
30710 */
30711 function Node(identity, labels, properties) {
30712 (0, _classCallCheck3.default)(this, Node);
30713
30714 this.identity = identity;
30715 this.labels = labels;
30716 this.properties = properties;
30717 }
30718
30719 (0, _createClass3.default)(Node, [{
30720 key: "toString",
30721 value: function toString() {
30722 var s = "(" + this.identity;
30723 for (var i = 0; i < this.labels.length; i++) {
30724 s += ":" + this.labels[i];
30725 }
30726 var keys = (0, _keys2.default)(this.properties);
30727 if (keys.length > 0) {
30728 s += " {";
30729 for (var _i = 0; _i < keys.length; _i++) {
30730 if (_i > 0) s += ",";
30731 s += keys[_i] + ":" + (0, _stringify2.default)(this.properties[keys[_i]]);
30732 }
30733 s += "}";
30734 }
30735 s += ")";
30736 return s;
30737 }
30738 }]);
30739 return Node;
30740}();
30741
30742/**
30743 * Class for Relationship Type.
30744 */
30745/**
30746 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
30747 *
30748 * This file is part of Neo4j.
30749 *
30750 * Licensed under the Apache License, Version 2.0 (the "License");
30751 * you may not use this file except in compliance with the License.
30752 * You may obtain a copy of the License at
30753 *
30754 * http://www.apache.org/licenses/LICENSE-2.0
30755 *
30756 * Unless required by applicable law or agreed to in writing, software
30757 * distributed under the License is distributed on an "AS IS" BASIS,
30758 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30759 * See the License for the specific language governing permissions and
30760 * limitations under the License.
30761 */
30762
30763var Relationship = function () {
30764 /**
30765 * @constructor
30766 * @param {Integer} identity - Unique identity
30767 * @param {Integer} start - Identity of start Node
30768 * @param {Integer} end - Identity of end Node
30769 * @param {string} type - Relationship type
30770 * @param {Object} properties - Map with relationship properties
30771 */
30772 function Relationship(identity, start, end, type, properties) {
30773 (0, _classCallCheck3.default)(this, Relationship);
30774
30775 this.identity = identity;
30776 this.start = start;
30777 this.end = end;
30778 this.type = type;
30779 this.properties = properties;
30780 }
30781
30782 (0, _createClass3.default)(Relationship, [{
30783 key: "toString",
30784 value: function toString() {
30785 var s = "(" + this.start + ")-[:" + this.type;
30786 var keys = (0, _keys2.default)(this.properties);
30787 if (keys.length > 0) {
30788 s += " {";
30789 for (var i = 0; i < keys.length; i++) {
30790 if (i > 0) s += ",";
30791 s += keys[i] + ":" + (0, _stringify2.default)(this.properties[keys[i]]);
30792 }
30793 s += "}";
30794 }
30795 s += "]->(" + this.end + ")";
30796 return s;
30797 }
30798 }]);
30799 return Relationship;
30800}();
30801
30802/**
30803 * Class for UnboundRelationship Type.
30804 * @access private
30805 */
30806
30807
30808var UnboundRelationship = function () {
30809 /**
30810 * @constructor
30811 * @param {Integer} identity - Unique identity
30812 * @param {string} type - Relationship type
30813 * @param {Object} properties - Map with relationship properties
30814 */
30815 function UnboundRelationship(identity, type, properties) {
30816 (0, _classCallCheck3.default)(this, UnboundRelationship);
30817
30818 this.identity = identity;
30819 this.type = type;
30820 this.properties = properties;
30821 }
30822
30823 /**
30824 * Bind relationship
30825 * @param {Integer} start - Identity of start node
30826 * @param {Integer} end - Identity of end node
30827 * @return {Relationship} - Created relationship
30828 */
30829
30830
30831 (0, _createClass3.default)(UnboundRelationship, [{
30832 key: "bind",
30833 value: function bind(start, end) {
30834 return new Relationship(this.identity, start, end, this.type, this.properties);
30835 }
30836 }, {
30837 key: "toString",
30838 value: function toString() {
30839 var s = "-[:" + this.type;
30840 var keys = (0, _keys2.default)(this.properties);
30841 if (keys.length > 0) {
30842 s += " {";
30843 for (var i = 0; i < keys.length; i++) {
30844 if (i > 0) s += ",";
30845 s += keys[i] + ":" + (0, _stringify2.default)(this.properties[keys[i]]);
30846 }
30847 s += "}";
30848 }
30849 s += "]->";
30850 return s;
30851 }
30852 }]);
30853 return UnboundRelationship;
30854}();
30855
30856/**
30857 * Class for PathSegment Type.
30858 */
30859
30860
30861var PathSegment =
30862/**
30863 * @constructor
30864 * @param {Node} start - start node
30865 * @param {Relationship} rel - relationship that connects start and end node
30866 * @param {Node} end - end node
30867 */
30868function PathSegment(start, rel, end) {
30869 (0, _classCallCheck3.default)(this, PathSegment);
30870
30871 this.start = start;
30872 this.relationship = rel;
30873 this.end = end;
30874};
30875
30876/**
30877 * Class for Path Type.
30878 */
30879
30880
30881var Path =
30882/**
30883 * @constructor
30884 * @param {Node} start - start node
30885 * @param {Node} end - end node
30886 * @param {Array<PathSegment>} segments - Array of Segments
30887 */
30888function Path(start, end, segments) {
30889 (0, _classCallCheck3.default)(this, Path);
30890
30891 this.start = start;
30892 this.end = end;
30893 this.segments = segments;
30894 this.length = segments.length;
30895};
30896
30897exports.Node = Node;
30898exports.Relationship = Relationship;
30899exports.UnboundRelationship = UnboundRelationship;
30900exports.Path = Path;
30901exports.PathSegment = PathSegment;
30902
30903},{"./integer":327,"babel-runtime/core-js/json/stringify":18,"babel-runtime/core-js/object/keys":27,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34}],326:[function(require,module,exports){
30904'use strict';
30905
30906Object.defineProperty(exports, "__esModule", {
30907 value: true
30908});
30909exports.temporal = exports.spatial = exports.error = exports.session = exports.types = exports.auth = exports.Neo4jError = exports.integer = exports.isDateTime = exports.isLocalDateTime = exports.isDate = exports.isTime = exports.isLocalTime = exports.isDuration = exports.isPoint = exports.isInt = exports.int = exports.driver = undefined;
30910
30911var _integer = require('./integer');
30912
30913var _graphTypes = require('./graph-types');
30914
30915var _error = require('./error');
30916
30917var _result = require('./result');
30918
30919var _result2 = _interopRequireDefault(_result);
30920
30921var _resultSummary = require('./result-summary');
30922
30923var _resultSummary2 = _interopRequireDefault(_resultSummary);
30924
30925var _record = require('./record');
30926
30927var _record2 = _interopRequireDefault(_record);
30928
30929var _driver = require('./driver');
30930
30931var _routingDriver = require('./routing-driver');
30932
30933var _routingDriver2 = _interopRequireDefault(_routingDriver);
30934
30935var _version = require('../version');
30936
30937var _version2 = _interopRequireDefault(_version);
30938
30939var _util = require('./internal/util');
30940
30941var _urlUtil = require('./internal/url-util');
30942
30943var _urlUtil2 = _interopRequireDefault(_urlUtil);
30944
30945var _httpDriver = require('./internal/http/http-driver');
30946
30947var _httpDriver2 = _interopRequireDefault(_httpDriver);
30948
30949var _spatialTypes = require('./spatial-types');
30950
30951var _temporalTypes = require('./temporal-types');
30952
30953function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30954
30955/**
30956 * @property {function(username: string, password: string, realm: ?string)} basic the function to create a
30957 * basic authentication token.
30958 * @property {function(base64EncodedTicket: string)} kerberos the function to create a Kerberos authentication token.
30959 * Accepts a single string argument - base64 encoded Kerberos ticket.
30960 * @property {function(principal: string, credentials: string, realm: string, scheme: string, parameters: ?object)} custom
30961 * the function to create a custom authentication token.
30962 */
30963/**
30964 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
30965 *
30966 * This file is part of Neo4j.
30967 *
30968 * Licensed under the Apache License, Version 2.0 (the "License");
30969 * you may not use this file except in compliance with the License.
30970 * You may obtain a copy of the License at
30971 *
30972 * http://www.apache.org/licenses/LICENSE-2.0
30973 *
30974 * Unless required by applicable law or agreed to in writing, software
30975 * distributed under the License is distributed on an "AS IS" BASIS,
30976 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30977 * See the License for the specific language governing permissions and
30978 * limitations under the License.
30979 */
30980
30981var auth = {
30982 basic: function basic(username, password) {
30983 var realm = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
30984
30985 if (realm) {
30986 return { scheme: 'basic', principal: username, credentials: password, realm: realm };
30987 } else {
30988 return { scheme: 'basic', principal: username, credentials: password };
30989 }
30990 },
30991 kerberos: function kerberos(base64EncodedTicket) {
30992 return {
30993 scheme: 'kerberos',
30994 principal: '', // This empty string is required for backwards compatibility.
30995 credentials: base64EncodedTicket
30996 };
30997 },
30998 custom: function custom(principal, credentials, realm, scheme) {
30999 var parameters = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;
31000
31001 if (parameters) {
31002 return {
31003 scheme: scheme, principal: principal, credentials: credentials, realm: realm,
31004 parameters: parameters
31005 };
31006 } else {
31007 return { scheme: scheme, principal: principal, credentials: credentials, realm: realm };
31008 }
31009 }
31010};
31011var USER_AGENT = "neo4j-javascript/" + _version2.default;
31012
31013/**
31014 * Construct a new Neo4j Driver. This is your main entry point for this
31015 * library.
31016 *
31017 * ## Configuration
31018 *
31019 * This function optionally takes a configuration argument. Available configuration
31020 * options are as follows:
31021 *
31022 * {
31023 * // Encryption level: ENCRYPTION_ON or ENCRYPTION_OFF.
31024 * encrypted: ENCRYPTION_ON|ENCRYPTION_OFF
31025 *
31026 * // Trust strategy to use if encryption is enabled. There is no mode to disable
31027 * // trust other than disabling encryption altogether. The reason for
31028 * // this is that if you don't know who you are talking to, it is easy for an
31029 * // attacker to hijack your encrypted connection, rendering encryption pointless.
31030 * //
31031 * // TRUST_ALL_CERTIFICATES is the default choice for NodeJS deployments. It only requires
31032 * // new host to provide a certificate and does no verification of the provided certificate.
31033 * //
31034 * // TRUST_ON_FIRST_USE is available for modern NodeJS deployments, and works
31035 * // similarly to how `ssl` works - the first time we connect to a new host,
31036 * // we remember the certificate they use. If the certificate ever changes, we
31037 * // assume it is an attempt to hijack the connection and require manual intervention.
31038 * // This means that by default, connections "just work" while still giving you
31039 * // good encrypted protection.
31040 * //
31041 * // TRUST_CUSTOM_CA_SIGNED_CERTIFICATES is the classic approach to trust verification -
31042 * // whenever we establish an encrypted connection, we ensure the host is using
31043 * // an encryption certificate that is in, or is signed by, a certificate listed
31044 * // as trusted. In the web bundle, this list of trusted certificates is maintained
31045 * // by the web browser. In NodeJS, you configure the list with the next config option.
31046 * //
31047 * // TRUST_SYSTEM_CA_SIGNED_CERTIFICATES means that you trust whatever certificates
31048 * // are in the default certificate chain of th
31049 * trust: "TRUST_ALL_CERTIFICATES" | "TRUST_ON_FIRST_USE" | "TRUST_SIGNED_CERTIFICATES" |
31050 * "TRUST_CUSTOM_CA_SIGNED_CERTIFICATES" | "TRUST_SYSTEM_CA_SIGNED_CERTIFICATES",
31051 *
31052 * // List of one or more paths to trusted encryption certificates. This only
31053 * // works in the NodeJS bundle, and only matters if you use "TRUST_CUSTOM_CA_SIGNED_CERTIFICATES".
31054 * // The certificate files should be in regular X.509 PEM format.
31055 * // For instance, ['./trusted.pem']
31056 * trustedCertificates: [],
31057 *
31058 * // Path to a file where the driver saves hosts it has seen in the past, this is
31059 * // very similar to the ssl tool's known_hosts file. Each time we connect to a
31060 * // new host, a hash of their certificate is stored along with the domain name and
31061 * // port, and this is then used to verify the host certificate does not change.
31062 * // This setting has no effect unless TRUST_ON_FIRST_USE is enabled.
31063 * knownHosts:"~/.neo4j/known_hosts",
31064 *
31065 * // The max number of connections that are allowed idle in the pool at any time.
31066 * // Connection will be destroyed if this threshold is exceeded.
31067 * // <b>Deprecated:</b> please use <code>maxConnectionPoolSize</code> instead.
31068 * connectionPoolSize: 100,
31069 *
31070 * // The maximum total number of connections allowed to be managed by the connection pool, per host.
31071 * // This includes both in-use and idle connections. No maximum connection pool size is imposed
31072 * // by default.
31073 * maxConnectionPoolSize: 100,
31074 *
31075 * // The maximum allowed lifetime for a pooled connection in milliseconds. Pooled connections older than this
31076 * // threshold will be closed and removed from the pool. Such discarding happens during connection acquisition
31077 * // so that new session is never backed by an old connection. Setting this option to a low value will cause
31078 * // a high connection churn and might result in a performance hit. It is recommended to set maximum lifetime
31079 * // to a slightly smaller value than the one configured in network equipment (load balancer, proxy, firewall,
31080 * // etc. can also limit maximum connection lifetime). No maximum lifetime limit is imposed by default. Zero
31081 * // and negative values result in lifetime not being checked.
31082 * maxConnectionLifetime: 60 * 60 * 1000, // 1 hour
31083 *
31084 * // The maximum amount of time to wait to acquire a connection from the pool (to either create a new
31085 * // connection or borrow an existing one.
31086 * connectionAcquisitionTimeout: 60000, // 1 minute
31087 *
31088 * // Specify the maximum time in milliseconds transactions are allowed to retry via
31089 * // <code>Session#readTransaction()</code> and <code>Session#writeTransaction()</code> functions.
31090 * // These functions will retry the given unit of work on `ServiceUnavailable`, `SessionExpired` and transient
31091 * // errors with exponential backoff using initial delay of 1 second.
31092 * // Default value is 30000 which is 30 seconds.
31093 * maxTransactionRetryTime: 30000, // 30 seconds
31094 *
31095 * // Provide an alternative load balancing strategy for the routing driver to use.
31096 * // Driver uses "least_connected" by default.
31097 * // <b>Note:</b> We are experimenting with different strategies. This could be removed in the next minor
31098 * // version.
31099 * loadBalancingStrategy: "least_connected" | "round_robin",
31100 *
31101 * // Specify socket connection timeout in milliseconds. Numeric values are expected. Negative and zero values
31102 * // result in no timeout being applied. Connection establishment will be then bound by the timeout configured
31103 * // on the operating system level. Default value is 5000, which is 5 seconds.
31104 * connectionTimeout: 5000, // 5 seconds
31105 *
31106 * // Make this driver always return native JavaScript numbers for integer values, instead of the
31107 * // dedicated {@link Integer} class. Values that do not fit in native number bit range will be represented as
31108 * // <code>Number.NEGATIVE_INFINITY</code> or <code>Number.POSITIVE_INFINITY</code>.
31109 * // <b>Warning:</b> It is not always safe to enable this setting when JavaScript applications are not the only ones
31110 * // interacting with the database. Stored numbers might in such case be not representable by native
31111 * // {@link Number} type and thus driver will return lossy values. This might also happen when data was
31112 * // initially imported using neo4j import tool and contained numbers larger than
31113 * // <code>Number.MAX_SAFE_INTEGER</code>. Driver will then return positive infinity, which is lossy.
31114 * // Default value for this option is <code>false</code> because native JavaScript numbers might result
31115 * // in loss of precision in the general case.
31116 * disableLosslessIntegers: false,
31117 * }
31118 *
31119 * @param {string} url The URL for the Neo4j database, for instance "bolt://localhost"
31120 * @param {Map<String,String>} authToken Authentication credentials. See {@link auth} for helpers.
31121 * @param {Object} config Configuration object. See the configuration section above for details.
31122 * @returns {Driver}
31123 */
31124function driver(url, authToken) {
31125 var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
31126
31127 (0, _util.assertString)(url, 'Bolt URL');
31128 var parsedUrl = _urlUtil2.default.parseDatabaseUrl(url);
31129 if (parsedUrl.scheme === 'bolt+routing') {
31130 return new _routingDriver2.default(parsedUrl.hostAndPort, parsedUrl.query, USER_AGENT, authToken, config);
31131 } else if (parsedUrl.scheme === 'bolt') {
31132 if (!(0, _util.isEmptyObjectOrNull)(parsedUrl.query)) {
31133 throw new Error('Parameters are not supported with scheme \'bolt\'. Given URL: \'' + url + '\'');
31134 }
31135 return new _driver.Driver(parsedUrl.hostAndPort, USER_AGENT, authToken, config);
31136 } else if (parsedUrl.scheme === 'http' || parsedUrl.scheme === 'https') {
31137 return new _httpDriver2.default(parsedUrl, USER_AGENT, authToken, config);
31138 } else {
31139 throw new Error('Unknown scheme: ' + parsedUrl.scheme);
31140 }
31141}
31142
31143/**
31144 * Object containing constructors for all neo4j types.
31145 */
31146var types = {
31147 Node: _graphTypes.Node,
31148 Relationship: _graphTypes.Relationship,
31149 UnboundRelationship: _graphTypes.UnboundRelationship,
31150 PathSegment: _graphTypes.PathSegment,
31151 Path: _graphTypes.Path,
31152 Result: _result2.default,
31153 ResultSummary: _resultSummary2.default,
31154 Record: _record2.default,
31155 Point: _spatialTypes.Point,
31156 Date: _temporalTypes.Date,
31157 DateTime: _temporalTypes.DateTime,
31158 Duration: _temporalTypes.Duration,
31159 LocalDateTime: _temporalTypes.LocalDateTime,
31160 LocalTime: _temporalTypes.LocalTime,
31161 Time: _temporalTypes.Time
31162};
31163
31164/**
31165 * Object containing string constants representing session access modes.
31166 */
31167var session = {
31168 READ: _driver.READ,
31169 WRITE: _driver.WRITE
31170};
31171
31172/**
31173 * Object containing string constants representing predefined {@link Neo4jError} codes.
31174 */
31175var error = {
31176 SERVICE_UNAVAILABLE: _error.SERVICE_UNAVAILABLE,
31177 SESSION_EXPIRED: _error.SESSION_EXPIRED,
31178 PROTOCOL_ERROR: _error.PROTOCOL_ERROR
31179};
31180
31181/**
31182 * Object containing functions to work with {@link Integer} objects.
31183 */
31184var integer = {
31185 toNumber: _integer.toNumber,
31186 toString: _integer.toString,
31187 inSafeRange: _integer.inSafeRange
31188};
31189
31190/**
31191 * Object containing functions to work with spatial types, like {@link Point}.
31192 */
31193var spatial = {
31194 isPoint: _spatialTypes.isPoint
31195};
31196
31197/**
31198 * Object containing functions to work with temporal types, like {@link Time} or {@link Duration}.
31199 */
31200var temporal = {
31201 isDuration: _temporalTypes.isDuration,
31202 isLocalTime: _temporalTypes.isLocalTime,
31203 isTime: _temporalTypes.isTime,
31204 isDate: _temporalTypes.isDate,
31205 isLocalDateTime: _temporalTypes.isLocalDateTime,
31206 isDateTime: _temporalTypes.isDateTime
31207};
31208
31209/**
31210 * @private
31211 */
31212var forExport = {
31213 driver: driver,
31214 int: _integer.int,
31215 isInt: _integer.isInt,
31216 isPoint: _spatialTypes.isPoint,
31217 isDuration: _temporalTypes.isDuration,
31218 isLocalTime: _temporalTypes.isLocalTime,
31219 isTime: _temporalTypes.isTime,
31220 isDate: _temporalTypes.isDate,
31221 isLocalDateTime: _temporalTypes.isLocalDateTime,
31222 isDateTime: _temporalTypes.isDateTime,
31223 integer: integer,
31224 Neo4jError: _error.Neo4jError,
31225 auth: auth,
31226 types: types,
31227 session: session,
31228 error: error,
31229 spatial: spatial,
31230 temporal: temporal
31231};
31232
31233exports.driver = driver;
31234exports.int = _integer.int;
31235exports.isInt = _integer.isInt;
31236exports.isPoint = _spatialTypes.isPoint;
31237exports.isDuration = _temporalTypes.isDuration;
31238exports.isLocalTime = _temporalTypes.isLocalTime;
31239exports.isTime = _temporalTypes.isTime;
31240exports.isDate = _temporalTypes.isDate;
31241exports.isLocalDateTime = _temporalTypes.isLocalDateTime;
31242exports.isDateTime = _temporalTypes.isDateTime;
31243exports.integer = integer;
31244exports.Neo4jError = _error.Neo4jError;
31245exports.auth = auth;
31246exports.types = types;
31247exports.session = session;
31248exports.error = error;
31249exports.spatial = spatial;
31250exports.temporal = temporal;
31251exports.default = forExport;
31252
31253},{"../version":372,"./driver":323,"./error":324,"./graph-types":325,"./integer":327,"./internal/http/http-driver":340,"./internal/url-util":361,"./internal/util":363,"./record":364,"./result":366,"./result-summary":365,"./routing-driver":367,"./spatial-types":369,"./temporal-types":370}],327:[function(require,module,exports){
31254'use strict';
31255
31256Object.defineProperty(exports, "__esModule", {
31257 value: true
31258});
31259exports.toString = exports.toNumber = exports.inSafeRange = exports.isInt = exports.int = undefined;
31260
31261var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
31262
31263var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
31264
31265var _createClass2 = require('babel-runtime/helpers/createClass');
31266
31267var _createClass3 = _interopRequireDefault(_createClass2);
31268
31269var _error = require('./error');
31270
31271function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31272
31273/**
31274 * Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as *signed* integers.
31275 * See exported functions for more convenient ways of operating integers.
31276 * Use <code>int()</code> function to create new integers, <code>isInt()</code> to check if given object is integer,
31277 * <code>inSafeRange()</code> to check if it is safe to convert given value to native number,
31278 * <code>toNumber()</code> and <code>toString()</code> to convert given integer to number or string respectively.
31279 * @access public
31280 * @exports Integer
31281 * @class A Integer class for representing a 64 bit two's-complement integer value.
31282 * @param {number} low The low (signed) 32 bits of the long
31283 * @param {number} high The high (signed) 32 bits of the long
31284 * @constructor
31285 *
31286 * @deprecated This class will be removed or made internal in a future version of the driver.
31287 */
31288var Integer = function () {
31289 function Integer(low, high) {
31290 (0, _classCallCheck3.default)(this, Integer);
31291
31292 /**
31293 * The low 32 bits as a signed value.
31294 * @type {number}
31295 * @expose
31296 */
31297 this.low = low | 0;
31298
31299 /**
31300 * The high 32 bits as a signed value.
31301 * @type {number}
31302 * @expose
31303 */
31304 this.high = high | 0;
31305 }
31306
31307 // The internal representation of an Integer is the two given signed, 32-bit values.
31308 // We use 32-bit pieces because these are the size of integers on which
31309 // JavaScript performs bit-operations. For operations like addition and
31310 // multiplication, we split each number into 16 bit pieces, which can easily be
31311 // multiplied within JavaScript's floating-point representation without overflow
31312 // or change in sign.
31313 //
31314 // In the algorithms below, we frequently reduce the negative case to the
31315 // positive case by negating the input(s) and then post-processing the result.
31316 // Note that we must ALWAYS check specially whether those values are MIN_VALUE
31317 // (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as
31318 // a positive number, it overflows back into a negative). Not handling this
31319 // case would often result in infinite recursion.
31320 //
31321 // Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the from*
31322 // methods on which they depend.
31323
31324
31325 (0, _createClass3.default)(Integer, [{
31326 key: 'inSafeRange',
31327 value: function inSafeRange() {
31328 return this.greaterThanOrEqual(Integer.MIN_SAFE_VALUE) && this.lessThanOrEqual(Integer.MAX_SAFE_VALUE);
31329 }
31330 /**
31331 * Converts the Integer to an exact javascript Number, assuming it is a 32 bit integer.
31332 * @returns {number}
31333 * @expose
31334 */
31335
31336 }, {
31337 key: 'toInt',
31338 value: function toInt() {
31339 return this.low;
31340 }
31341 }, {
31342 key: 'toNumber',
31343
31344
31345 /**
31346 * Converts the Integer to a the nearest floating-point representation of this value (double, 53 bit mantissa).
31347 * @returns {number}
31348 * @expose
31349 */
31350 value: function toNumber() {
31351 return this.high * TWO_PWR_32_DBL + (this.low >>> 0);
31352 }
31353
31354 /**
31355 * Converts the Integer to native number or -Infinity/+Infinity when it does not fit.
31356 * @return {number}
31357 * @package
31358 */
31359
31360 }, {
31361 key: 'toNumberOrInfinity',
31362 value: function toNumberOrInfinity() {
31363 if (this.lessThan(Integer.MIN_SAFE_VALUE)) {
31364 return Number.NEGATIVE_INFINITY;
31365 } else if (this.greaterThan(Integer.MAX_SAFE_VALUE)) {
31366 return Number.POSITIVE_INFINITY;
31367 } else {
31368 return this.toNumber();
31369 }
31370 }
31371
31372 /**
31373 * Converts the Integer to a string written in the specified radix.
31374 * @param {number=} radix Radix (2-36), defaults to 10
31375 * @returns {string}
31376 * @override
31377 * @throws {RangeError} If `radix` is out of range
31378 * @expose
31379 */
31380
31381 }, {
31382 key: 'toString',
31383 value: function toString(radix) {
31384 radix = radix || 10;
31385 if (radix < 2 || 36 < radix) throw RangeError('radix out of range: ' + radix);
31386 if (this.isZero()) return '0';
31387 var rem;
31388 if (this.isNegative()) {
31389 if (this.equals(Integer.MIN_VALUE)) {
31390 // We need to change the Integer value before it can be negated, so we remove
31391 // the bottom-most digit in this base and then recurse to do the rest.
31392 var radixInteger = Integer.fromNumber(radix);
31393 var div = this.div(radixInteger);
31394 rem = div.multiply(radixInteger).subtract(this);
31395 return div.toString(radix) + rem.toInt().toString(radix);
31396 } else return '-' + this.negate().toString(radix);
31397 }
31398
31399 // Do several (6) digits each time through the loop, so as to
31400 // minimize the calls to the very expensive emulated div.
31401 var radixToPower = Integer.fromNumber(Math.pow(radix, 6));
31402 rem = this;
31403 var result = '';
31404 while (true) {
31405 var remDiv = rem.div(radixToPower),
31406 intval = rem.subtract(remDiv.multiply(radixToPower)).toInt() >>> 0,
31407 digits = intval.toString(radix);
31408 rem = remDiv;
31409 if (rem.isZero()) return digits + result;else {
31410 while (digits.length < 6) {
31411 digits = '0' + digits;
31412 }result = '' + digits + result;
31413 }
31414 }
31415 }
31416
31417 /**
31418 * Gets the high 32 bits as a signed integer.
31419 * @returns {number} Signed high bits
31420 * @expose
31421 */
31422
31423 }, {
31424 key: 'getHighBits',
31425 value: function getHighBits() {
31426 return this.high;
31427 }
31428
31429 /**
31430 * Gets the low 32 bits as a signed integer.
31431 * @returns {number} Signed low bits
31432 * @expose
31433 */
31434
31435 }, {
31436 key: 'getLowBits',
31437 value: function getLowBits() {
31438 return this.low;
31439 }
31440
31441 /**
31442 * Gets the number of bits needed to represent the absolute value of this Integer.
31443 * @returns {number}
31444 * @expose
31445 */
31446
31447 }, {
31448 key: 'getNumBitsAbs',
31449 value: function getNumBitsAbs() {
31450 if (this.isNegative()) return this.equals(Integer.MIN_VALUE) ? 64 : this.negate().getNumBitsAbs();
31451 var val = this.high != 0 ? this.high : this.low;
31452 for (var bit = 31; bit > 0; bit--) {
31453 if ((val & 1 << bit) != 0) break;
31454 }return this.high != 0 ? bit + 33 : bit + 1;
31455 }
31456
31457 /**
31458 * Tests if this Integer's value equals zero.
31459 * @returns {boolean}
31460 * @expose
31461 */
31462
31463 }, {
31464 key: 'isZero',
31465 value: function isZero() {
31466 return this.high === 0 && this.low === 0;
31467 }
31468
31469 /**
31470 * Tests if this Integer's value is negative.
31471 * @returns {boolean}
31472 * @expose
31473 */
31474
31475 }, {
31476 key: 'isNegative',
31477 value: function isNegative() {
31478 return this.high < 0;
31479 }
31480
31481 /**
31482 * Tests if this Integer's value is positive.
31483 * @returns {boolean}
31484 * @expose
31485 */
31486
31487 }, {
31488 key: 'isPositive',
31489 value: function isPositive() {
31490 return this.high >= 0;
31491 }
31492
31493 /**
31494 * Tests if this Integer's value is odd.
31495 * @returns {boolean}
31496 * @expose
31497 */
31498
31499 }, {
31500 key: 'isOdd',
31501 value: function isOdd() {
31502 return (this.low & 1) === 1;
31503 }
31504
31505 /**
31506 * Tests if this Integer's value is even.
31507 * @returns {boolean}
31508 * @expose
31509 */
31510
31511 }, {
31512 key: 'isEven',
31513 value: function isEven() {
31514 return (this.low & 1) === 0;
31515 }
31516 }, {
31517 key: 'equals',
31518
31519
31520 /**
31521 * Tests if this Integer's value equals the specified's.
31522 * @param {!Integer|number|string} other Other value
31523 * @returns {boolean}
31524 * @expose
31525 */
31526 value: function equals(other) {
31527 if (!Integer.isInteger(other)) other = Integer.fromValue(other);
31528 return this.high === other.high && this.low === other.low;
31529 }
31530
31531 /**
31532 * Tests if this Integer's value differs from the specified's.
31533 * @param {!Integer|number|string} other Other value
31534 * @returns {boolean}
31535 * @expose
31536 */
31537
31538 }, {
31539 key: 'notEquals',
31540 value: function notEquals(other) {
31541 return !this.equals( /* validates */other);
31542 }
31543
31544 /**
31545 * Tests if this Integer's value is less than the specified's.
31546 * @param {!Integer|number|string} other Other value
31547 * @returns {boolean}
31548 * @expose
31549 */
31550
31551 }, {
31552 key: 'lessThan',
31553 value: function lessThan(other) {
31554 return this.compare( /* validates */other) < 0;
31555 }
31556
31557 /**
31558 * Tests if this Integer's value is less than or equal the specified's.
31559 * @param {!Integer|number|string} other Other value
31560 * @returns {boolean}
31561 * @expose
31562 */
31563
31564 }, {
31565 key: 'lessThanOrEqual',
31566 value: function lessThanOrEqual(other) {
31567 return this.compare( /* validates */other) <= 0;
31568 }
31569
31570 /**
31571 * Tests if this Integer's value is greater than the specified's.
31572 * @param {!Integer|number|string} other Other value
31573 * @returns {boolean}
31574 * @expose
31575 */
31576
31577 }, {
31578 key: 'greaterThan',
31579 value: function greaterThan(other) {
31580 return this.compare( /* validates */other) > 0;
31581 }
31582
31583 /**
31584 * Tests if this Integer's value is greater than or equal the specified's.
31585 * @param {!Integer|number|string} other Other value
31586 * @returns {boolean}
31587 * @expose
31588 */
31589
31590 }, {
31591 key: 'greaterThanOrEqual',
31592 value: function greaterThanOrEqual(other) {
31593 return this.compare( /* validates */other) >= 0;
31594 }
31595
31596 /**
31597 * Compares this Integer's value with the specified's.
31598 * @param {!Integer|number|string} other Other value
31599 * @returns {number} 0 if they are the same, 1 if the this is greater and -1
31600 * if the given one is greater
31601 * @expose
31602 */
31603
31604 }, {
31605 key: 'compare',
31606 value: function compare(other) {
31607 if (!Integer.isInteger(other)) other = Integer.fromValue(other);
31608 if (this.equals(other)) return 0;
31609 var thisNeg = this.isNegative(),
31610 otherNeg = other.isNegative();
31611 if (thisNeg && !otherNeg) return -1;
31612 if (!thisNeg && otherNeg) return 1;
31613 // At this point the sign bits are the same
31614 return this.subtract(other).isNegative() ? -1 : 1;
31615 }
31616
31617 /**
31618 * Negates this Integer's value.
31619 * @returns {!Integer} Negated Integer
31620 * @expose
31621 */
31622
31623 }, {
31624 key: 'negate',
31625 value: function negate() {
31626 if (this.equals(Integer.MIN_VALUE)) return Integer.MIN_VALUE;
31627 return this.not().add(Integer.ONE);
31628 }
31629
31630 /**
31631 * Returns the sum of this and the specified Integer.
31632 * @param {!Integer|number|string} addend Addend
31633 * @returns {!Integer} Sum
31634 * @expose
31635 */
31636
31637 }, {
31638 key: 'add',
31639 value: function add(addend) {
31640 if (!Integer.isInteger(addend)) addend = Integer.fromValue(addend);
31641
31642 // Divide each number into 4 chunks of 16 bits, and then sum the chunks.
31643
31644 var a48 = this.high >>> 16;
31645 var a32 = this.high & 0xFFFF;
31646 var a16 = this.low >>> 16;
31647 var a00 = this.low & 0xFFFF;
31648
31649 var b48 = addend.high >>> 16;
31650 var b32 = addend.high & 0xFFFF;
31651 var b16 = addend.low >>> 16;
31652 var b00 = addend.low & 0xFFFF;
31653
31654 var c48 = 0,
31655 c32 = 0,
31656 c16 = 0,
31657 c00 = 0;
31658 c00 += a00 + b00;
31659 c16 += c00 >>> 16;
31660 c00 &= 0xFFFF;
31661 c16 += a16 + b16;
31662 c32 += c16 >>> 16;
31663 c16 &= 0xFFFF;
31664 c32 += a32 + b32;
31665 c48 += c32 >>> 16;
31666 c32 &= 0xFFFF;
31667 c48 += a48 + b48;
31668 c48 &= 0xFFFF;
31669 return Integer.fromBits(c16 << 16 | c00, c48 << 16 | c32);
31670 }
31671
31672 /**
31673 * Returns the difference of this and the specified Integer.
31674 * @param {!Integer|number|string} subtrahend Subtrahend
31675 * @returns {!Integer} Difference
31676 * @expose
31677 */
31678
31679 }, {
31680 key: 'subtract',
31681 value: function subtract(subtrahend) {
31682 if (!Integer.isInteger(subtrahend)) subtrahend = Integer.fromValue(subtrahend);
31683 return this.add(subtrahend.negate());
31684 }
31685
31686 /**
31687 * Returns the product of this and the specified Integer.
31688 * @param {!Integer|number|string} multiplier Multiplier
31689 * @returns {!Integer} Product
31690 * @expose
31691 */
31692
31693 }, {
31694 key: 'multiply',
31695 value: function multiply(multiplier) {
31696 if (this.isZero()) return Integer.ZERO;
31697 if (!Integer.isInteger(multiplier)) multiplier = Integer.fromValue(multiplier);
31698 if (multiplier.isZero()) return Integer.ZERO;
31699 if (this.equals(Integer.MIN_VALUE)) return multiplier.isOdd() ? Integer.MIN_VALUE : Integer.ZERO;
31700 if (multiplier.equals(Integer.MIN_VALUE)) return this.isOdd() ? Integer.MIN_VALUE : Integer.ZERO;
31701
31702 if (this.isNegative()) {
31703 if (multiplier.isNegative()) return this.negate().multiply(multiplier.negate());else return this.negate().multiply(multiplier).negate();
31704 } else if (multiplier.isNegative()) return this.multiply(multiplier.negate()).negate();
31705
31706 // If both longs are small, use float multiplication
31707 if (this.lessThan(TWO_PWR_24) && multiplier.lessThan(TWO_PWR_24)) return Integer.fromNumber(this.toNumber() * multiplier.toNumber());
31708
31709 // Divide each long into 4 chunks of 16 bits, and then add up 4x4 products.
31710 // We can skip products that would overflow.
31711
31712 var a48 = this.high >>> 16;
31713 var a32 = this.high & 0xFFFF;
31714 var a16 = this.low >>> 16;
31715 var a00 = this.low & 0xFFFF;
31716
31717 var b48 = multiplier.high >>> 16;
31718 var b32 = multiplier.high & 0xFFFF;
31719 var b16 = multiplier.low >>> 16;
31720 var b00 = multiplier.low & 0xFFFF;
31721
31722 var c48 = 0,
31723 c32 = 0,
31724 c16 = 0,
31725 c00 = 0;
31726 c00 += a00 * b00;
31727 c16 += c00 >>> 16;
31728 c00 &= 0xFFFF;
31729 c16 += a16 * b00;
31730 c32 += c16 >>> 16;
31731 c16 &= 0xFFFF;
31732 c16 += a00 * b16;
31733 c32 += c16 >>> 16;
31734 c16 &= 0xFFFF;
31735 c32 += a32 * b00;
31736 c48 += c32 >>> 16;
31737 c32 &= 0xFFFF;
31738 c32 += a16 * b16;
31739 c48 += c32 >>> 16;
31740 c32 &= 0xFFFF;
31741 c32 += a00 * b32;
31742 c48 += c32 >>> 16;
31743 c32 &= 0xFFFF;
31744 c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48;
31745 c48 &= 0xFFFF;
31746 return Integer.fromBits(c16 << 16 | c00, c48 << 16 | c32);
31747 }
31748 }, {
31749 key: 'div',
31750
31751
31752 /**
31753 * Returns this Integer divided by the specified.
31754 * @param {!Integer|number|string} divisor Divisor
31755 * @returns {!Integer} Quotient
31756 * @expose
31757 */
31758 value: function div(divisor) {
31759 if (!Integer.isInteger(divisor)) divisor = Integer.fromValue(divisor);
31760 if (divisor.isZero()) throw (0, _error.newError)('division by zero');
31761 if (this.isZero()) return Integer.ZERO;
31762 var approx, rem, res;
31763 if (this.equals(Integer.MIN_VALUE)) {
31764 if (divisor.equals(Integer.ONE) || divisor.equals(Integer.NEG_ONE)) return Integer.MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE
31765 else if (divisor.equals(Integer.MIN_VALUE)) return Integer.ONE;else {
31766 // At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|.
31767 var halfThis = this.shiftRight(1);
31768 approx = halfThis.div(divisor).shiftLeft(1);
31769 if (approx.equals(Integer.ZERO)) {
31770 return divisor.isNegative() ? Integer.ONE : Integer.NEG_ONE;
31771 } else {
31772 rem = this.subtract(divisor.multiply(approx));
31773 res = approx.add(rem.div(divisor));
31774 return res;
31775 }
31776 }
31777 } else if (divisor.equals(Integer.MIN_VALUE)) return Integer.ZERO;
31778 if (this.isNegative()) {
31779 if (divisor.isNegative()) return this.negate().div(divisor.negate());
31780 return this.negate().div(divisor).negate();
31781 } else if (divisor.isNegative()) return this.div(divisor.negate()).negate();
31782
31783 // Repeat the following until the remainder is less than other: find a
31784 // floating-point that approximates remainder / other *from below*, add this
31785 // into the result, and subtract it from the remainder. It is critical that
31786 // the approximate value is less than or equal to the real value so that the
31787 // remainder never becomes negative.
31788 res = Integer.ZERO;
31789 rem = this;
31790 while (rem.greaterThanOrEqual(divisor)) {
31791 // Approximate the result of division. This may be a little greater or
31792 // smaller than the actual value.
31793 approx = Math.max(1, Math.floor(rem.toNumber() / divisor.toNumber()));
31794
31795 // We will tweak the approximate result by changing it in the 48-th digit or
31796 // the smallest non-fractional digit, whichever is larger.
31797 var log2 = Math.ceil(Math.log(approx) / Math.LN2),
31798 delta = log2 <= 48 ? 1 : Math.pow(2, log2 - 48),
31799
31800
31801 // Decrease the approximation until it is smaller than the remainder. Note
31802 // that if it is too large, the product overflows and is negative.
31803 approxRes = Integer.fromNumber(approx),
31804 approxRem = approxRes.multiply(divisor);
31805 while (approxRem.isNegative() || approxRem.greaterThan(rem)) {
31806 approx -= delta;
31807 approxRes = Integer.fromNumber(approx);
31808 approxRem = approxRes.multiply(divisor);
31809 }
31810
31811 // We know the answer can't be zero... and actually, zero would cause
31812 // infinite recursion since we would make no progress.
31813 if (approxRes.isZero()) approxRes = Integer.ONE;
31814
31815 res = res.add(approxRes);
31816 rem = rem.subtract(approxRem);
31817 }
31818 return res;
31819 }
31820
31821 /**
31822 * Returns this Integer modulo the specified.
31823 * @param {!Integer|number|string} divisor Divisor
31824 * @returns {!Integer} Remainder
31825 * @expose
31826 */
31827
31828 }, {
31829 key: 'modulo',
31830 value: function modulo(divisor) {
31831 if (!Integer.isInteger(divisor)) divisor = Integer.fromValue(divisor);
31832 return this.subtract(this.div(divisor).multiply(divisor));
31833 }
31834
31835 /**
31836 * Returns the bitwise NOT of this Integer.
31837 * @returns {!Integer}
31838 * @expose
31839 */
31840
31841 }, {
31842 key: 'not',
31843 value: function not() {
31844 return Integer.fromBits(~this.low, ~this.high);
31845 }
31846
31847 /**
31848 * Returns the bitwise AND of this Integer and the specified.
31849 * @param {!Integer|number|string} other Other Integer
31850 * @returns {!Integer}
31851 * @expose
31852 */
31853
31854 }, {
31855 key: 'and',
31856 value: function and(other) {
31857 if (!Integer.isInteger(other)) other = Integer.fromValue(other);
31858 return Integer.fromBits(this.low & other.low, this.high & other.high);
31859 }
31860
31861 /**
31862 * Returns the bitwise OR of this Integer and the specified.
31863 * @param {!Integer|number|string} other Other Integer
31864 * @returns {!Integer}
31865 * @expose
31866 */
31867
31868 }, {
31869 key: 'or',
31870 value: function or(other) {
31871 if (!Integer.isInteger(other)) other = Integer.fromValue(other);
31872 return Integer.fromBits(this.low | other.low, this.high | other.high);
31873 }
31874
31875 /**
31876 * Returns the bitwise XOR of this Integer and the given one.
31877 * @param {!Integer|number|string} other Other Integer
31878 * @returns {!Integer}
31879 * @expose
31880 */
31881
31882 }, {
31883 key: 'xor',
31884 value: function xor(other) {
31885 if (!Integer.isInteger(other)) other = Integer.fromValue(other);
31886 return Integer.fromBits(this.low ^ other.low, this.high ^ other.high);
31887 }
31888
31889 /**
31890 * Returns this Integer with bits shifted to the left by the given amount.
31891 * @param {number|!Integer} numBits Number of bits
31892 * @returns {!Integer} Shifted Integer
31893 * @expose
31894 */
31895
31896 }, {
31897 key: 'shiftLeft',
31898 value: function shiftLeft(numBits) {
31899 if (Integer.isInteger(numBits)) numBits = numBits.toInt();
31900 if ((numBits &= 63) === 0) return this;else if (numBits < 32) return Integer.fromBits(this.low << numBits, this.high << numBits | this.low >>> 32 - numBits);else return Integer.fromBits(0, this.low << numBits - 32);
31901 }
31902
31903 /**
31904 * Returns this Integer with bits arithmetically shifted to the right by the given amount.
31905 * @param {number|!Integer} numBits Number of bits
31906 * @returns {!Integer} Shifted Integer
31907 * @expose
31908 */
31909
31910 }, {
31911 key: 'shiftRight',
31912 value: function shiftRight(numBits) {
31913 if (Integer.isInteger(numBits)) numBits = numBits.toInt();
31914 if ((numBits &= 63) === 0) return this;else if (numBits < 32) return Integer.fromBits(this.low >>> numBits | this.high << 32 - numBits, this.high >> numBits);else return Integer.fromBits(this.high >> numBits - 32, this.high >= 0 ? 0 : -1);
31915 }
31916 }]);
31917 return Integer;
31918}();
31919
31920/**
31921 * An indicator used to reliably determine if an object is a Integer or not.
31922 * @type {boolean}
31923 * @const
31924 * @expose
31925 * @private
31926 */
31927/**
31928 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
31929 *
31930 * This file is part of Neo4j.
31931 *
31932 * Licensed under the Apache License, Version 2.0 (the "License");
31933 * you may not use this file except in compliance with the License.
31934 * You may obtain a copy of the License at
31935 *
31936 * http://www.apache.org/licenses/LICENSE-2.0
31937 *
31938 * Unless required by applicable law or agreed to in writing, software
31939 * distributed under the License is distributed on an "AS IS" BASIS,
31940 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31941 * See the License for the specific language governing permissions and
31942 * limitations under the License.
31943 */
31944
31945// 64-bit Integer library, originally from Long.js by dcodeIO
31946// https://github.com/dcodeIO/Long.js
31947// License Apache 2
31948
31949Integer.__isInteger__;
31950
31951Object.defineProperty(Integer.prototype, "__isInteger__", {
31952 value: true,
31953 enumerable: false,
31954 configurable: false
31955});
31956
31957/**
31958 * Tests if the specified object is a Integer.
31959 * @access private
31960 * @param {*} obj Object
31961 * @returns {boolean}
31962 * @expose
31963 */
31964Integer.isInteger = function (obj) {
31965 return (obj && obj["__isInteger__"]) === true;
31966};
31967
31968/**
31969 * A cache of the Integer representations of small integer values.
31970 * @type {!Object}
31971 * @inner
31972 * @private
31973 */
31974var INT_CACHE = {};
31975
31976/**
31977 * Returns a Integer representing the given 32 bit integer value.
31978 * @access private
31979 * @param {number} value The 32 bit integer in question
31980 * @returns {!Integer} The corresponding Integer value
31981 * @expose
31982 */
31983Integer.fromInt = function (value) {
31984 var obj, cachedObj;
31985 value = value | 0;
31986 if (-128 <= value && value < 128) {
31987 cachedObj = INT_CACHE[value];
31988 if (cachedObj) return cachedObj;
31989 }
31990 obj = new Integer(value, value < 0 ? -1 : 0, false);
31991 if (-128 <= value && value < 128) INT_CACHE[value] = obj;
31992 return obj;
31993};
31994
31995/**
31996 * Returns a Integer representing the given value, provided that it is a finite number. Otherwise, zero is returned.
31997 * @access private
31998 * @param {number} value The number in question
31999 * @returns {!Integer} The corresponding Integer value
32000 * @expose
32001 */
32002Integer.fromNumber = function (value) {
32003 if (isNaN(value) || !isFinite(value)) return Integer.ZERO;
32004 if (value <= -TWO_PWR_63_DBL) return Integer.MIN_VALUE;
32005 if (value + 1 >= TWO_PWR_63_DBL) return Integer.MAX_VALUE;
32006 if (value < 0) return Integer.fromNumber(-value).negate();
32007 return new Integer(value % TWO_PWR_32_DBL | 0, value / TWO_PWR_32_DBL | 0);
32008};
32009
32010/**
32011 * Returns a Integer representing the 64 bit integer that comes by concatenating the given low and high bits. Each is
32012 * assumed to use 32 bits.
32013 * @access private
32014 * @param {number} lowBits The low 32 bits
32015 * @param {number} highBits The high 32 bits
32016 * @returns {!Integer} The corresponding Integer value
32017 * @expose
32018 */
32019Integer.fromBits = function (lowBits, highBits) {
32020 return new Integer(lowBits, highBits);
32021};
32022
32023/**
32024 * Returns a Integer representation of the given string, written using the specified radix.
32025 * @access private
32026 * @param {string} str The textual representation of the Integer
32027 * @param {number=} radix The radix in which the text is written (2-36), defaults to 10
32028 * @returns {!Integer} The corresponding Integer value
32029 * @expose
32030 */
32031Integer.fromString = function (str, radix) {
32032 if (str.length === 0) throw (0, _error.newError)('number format error: empty string');
32033 if (str === "NaN" || str === "Infinity" || str === "+Infinity" || str === "-Infinity") return Integer.ZERO;
32034 radix = radix || 10;
32035 if (radix < 2 || 36 < radix) throw (0, _error.newError)('radix out of range: ' + radix);
32036
32037 var p;
32038 if ((p = str.indexOf('-')) > 0) throw (0, _error.newError)('number format error: interior "-" character: ' + str);else if (p === 0) return Integer.fromString(str.substring(1), radix).negate();
32039
32040 // Do several (8) digits each time through the loop, so as to
32041 // minimize the calls to the very expensive emulated div.
32042 var radixToPower = Integer.fromNumber(Math.pow(radix, 8));
32043
32044 var result = Integer.ZERO;
32045 for (var i = 0; i < str.length; i += 8) {
32046 var size = Math.min(8, str.length - i);
32047 var value = parseInt(str.substring(i, i + size), radix);
32048 if (size < 8) {
32049 var power = Integer.fromNumber(Math.pow(radix, size));
32050 result = result.multiply(power).add(Integer.fromNumber(value));
32051 } else {
32052 result = result.multiply(radixToPower);
32053 result = result.add(Integer.fromNumber(value));
32054 }
32055 }
32056 return result;
32057};
32058
32059/**
32060 * Converts the specified value to a Integer.
32061 * @access private
32062 * @param {!Integer|number|string|!{low: number, high: number}} val Value
32063 * @returns {!Integer}
32064 * @expose
32065 */
32066Integer.fromValue = function (val) {
32067 if (val /* is compatible */ instanceof Integer) return val;
32068 if (typeof val === 'number') return Integer.fromNumber(val);
32069 if (typeof val === 'string') return Integer.fromString(val);
32070 // Throws for non-objects, converts non-instanceof Integer:
32071 return new Integer(val.low, val.high);
32072};
32073
32074/**
32075 * Converts the specified value to a number.
32076 * @access private
32077 * @param {!Integer|number|string|!{low: number, high: number}} val Value
32078 * @returns {number}
32079 * @expose
32080 */
32081Integer.toNumber = function (val) {
32082 return Integer.fromValue(val).toNumber();
32083};
32084
32085/**
32086* Converts the specified value to a string.
32087* @access private
32088* @param {!Integer|number|string|!{low: number, high: number}} val Value
32089* @param {number} radix optional radix for string conversion, defaults to 10
32090* @returns {String}
32091* @expose
32092*/
32093Integer.toString = function (val, radix) {
32094 return Integer.fromValue(val).toString(radix);
32095};
32096
32097/**
32098 * Checks if the given value is in the safe range in order to be converted to a native number
32099 * @access private
32100 * @param {!Integer|number|string|!{low: number, high: number}} val Value
32101 * @param {number} radix optional radix for string conversion, defaults to 10
32102 * @returns {boolean}
32103 * @expose
32104 */
32105Integer.inSafeRange = function (val) {
32106 return Integer.fromValue(val).inSafeRange();
32107};
32108
32109/**
32110 * @type {number}
32111 * @const
32112 * @inner
32113 * @private
32114 */
32115var TWO_PWR_16_DBL = 1 << 16;
32116
32117/**
32118 * @type {number}
32119 * @const
32120 * @inner
32121 * @private
32122 */
32123var TWO_PWR_24_DBL = 1 << 24;
32124
32125/**
32126 * @type {number}
32127 * @const
32128 * @inner
32129 * @private
32130 */
32131var TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL;
32132
32133/**
32134 * @type {number}
32135 * @const
32136 * @inner
32137 * @private
32138 */
32139var TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL;
32140
32141/**
32142 * @type {number}
32143 * @const
32144 * @inner
32145 * @private
32146 */
32147var TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2;
32148
32149/**
32150 * @type {!Integer}
32151 * @const
32152 * @inner
32153 * @private
32154 */
32155var TWO_PWR_24 = Integer.fromInt(TWO_PWR_24_DBL);
32156
32157/**
32158 * Signed zero.
32159 * @type {!Integer}
32160 * @expose
32161 */
32162Integer.ZERO = Integer.fromInt(0);
32163
32164/**
32165 * Signed one.
32166 * @type {!Integer}
32167 * @expose
32168 */
32169Integer.ONE = Integer.fromInt(1);
32170
32171/**
32172 * Signed negative one.
32173 * @type {!Integer}
32174 * @expose
32175 */
32176Integer.NEG_ONE = Integer.fromInt(-1);
32177
32178/**
32179 * Maximum signed value.
32180 * @type {!Integer}
32181 * @expose
32182 */
32183Integer.MAX_VALUE = Integer.fromBits(0xFFFFFFFF | 0, 0x7FFFFFFF | 0, false);
32184
32185/**
32186 * Minimum signed value.
32187 * @type {!Integer}
32188 * @expose
32189 */
32190Integer.MIN_VALUE = Integer.fromBits(0, 0x80000000 | 0, false);
32191
32192/**
32193 * Minimum safe value.
32194 * @type {!Integer}
32195 * @expose
32196 */
32197Integer.MIN_SAFE_VALUE = Integer.fromBits(0x1 | 0, 0xFFFFFFFFFFE00000 | 0);
32198
32199/**
32200* Maximum safe value.
32201* @type {!Integer}
32202* @expose
32203*/
32204Integer.MAX_SAFE_VALUE = Integer.fromBits(0xFFFFFFFF | 0, 0x1FFFFF | 0);
32205
32206/**
32207 * Cast value to Integer type.
32208 * @access public
32209 * @param {Mixed} value - The value to use.
32210 * @return {Integer} - An object of type Integer.
32211 */
32212var int = Integer.fromValue;
32213
32214/**
32215 * Check if a variable is of Integer type.
32216 * @access public
32217 * @param {Mixed} value - The variable to check.
32218 * @return {Boolean} - Is it of the Integer type?
32219 */
32220var isInt = Integer.isInteger;
32221
32222/**
32223 * Check if a variable can be safely converted to a number
32224 * @access public
32225 * @param {Mixed} value - The variable to check
32226 * @return {Boolean} - true if it is safe to call toNumber on variable otherwise false
32227 */
32228var inSafeRange = Integer.inSafeRange;
32229
32230/**
32231 * Converts a variable to a number
32232 * @access public
32233 * @param {Mixed} value - The variable to convert
32234 * @return {number} - the variable as a number
32235 */
32236var toNumber = Integer.toNumber;
32237
32238/**
32239 * Converts the integer to a string representation
32240 * @access public
32241 * @param {Mixed} value - The variable to convert
32242 * @param {number} radix - radix to use in string conversion, defaults to 10
32243 * @return {String} - returns a string representation of the integer
32244 */
32245var toString = Integer.toString;
32246
32247exports.int = int;
32248exports.isInt = isInt;
32249exports.inSafeRange = inSafeRange;
32250exports.toNumber = toNumber;
32251exports.toString = toString;
32252exports.default = Integer;
32253
32254},{"./error":324,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34}],328:[function(require,module,exports){
32255'use strict';
32256
32257Object.defineProperty(exports, "__esModule", {
32258 value: true
32259});
32260
32261var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
32262
32263var _defineProperty3 = _interopRequireDefault(_defineProperty2);
32264
32265var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
32266
32267var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
32268
32269var _createClass2 = require('babel-runtime/helpers/createClass');
32270
32271var _createClass3 = _interopRequireDefault(_createClass2);
32272
32273var _util = require('./util');
32274
32275var util = _interopRequireWildcard(_util);
32276
32277function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
32278
32279function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
32280
32281var BOOKMARK_KEY = 'bookmark'; /**
32282 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
32283 *
32284 * This file is part of Neo4j.
32285 *
32286 * Licensed under the Apache License, Version 2.0 (the "License");
32287 * you may not use this file except in compliance with the License.
32288 * You may obtain a copy of the License at
32289 *
32290 * http://www.apache.org/licenses/LICENSE-2.0
32291 *
32292 * Unless required by applicable law or agreed to in writing, software
32293 * distributed under the License is distributed on an "AS IS" BASIS,
32294 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32295 * See the License for the specific language governing permissions and
32296 * limitations under the License.
32297 */
32298
32299var BOOKMARKS_KEY = 'bookmarks';
32300var BOOKMARK_PREFIX = 'neo4j:bookmark:v1:tx';
32301
32302var UNKNOWN_BOOKMARK_VALUE = -1;
32303
32304var Bookmark = function () {
32305
32306 /**
32307 * @constructor
32308 * @param {string|string[]} values single bookmark as string or multiple bookmarks as a string array.
32309 */
32310 function Bookmark(values) {
32311 (0, _classCallCheck3.default)(this, Bookmark);
32312
32313 this._values = asStringArray(values);
32314 this._maxValue = maxBookmark(this._values);
32315 }
32316
32317 /**
32318 * Check if the given bookmark is meaningful and can be send to the database.
32319 * @return {boolean} returns <code>true</code> bookmark has a value, <code>false</code> otherwise.
32320 */
32321
32322
32323 (0, _createClass3.default)(Bookmark, [{
32324 key: 'isEmpty',
32325 value: function isEmpty() {
32326 return this._maxValue === null;
32327 }
32328
32329 /**
32330 * Get maximum value of this bookmark as string.
32331 * @return {string|null} the maximum value or <code>null</code> if it is not defined.
32332 */
32333
32334 }, {
32335 key: 'maxBookmarkAsString',
32336 value: function maxBookmarkAsString() {
32337 return this._maxValue;
32338 }
32339
32340 /**
32341 * Get this bookmark as an object for begin transaction call.
32342 * @return {object} the value of this bookmark as object.
32343 */
32344
32345 }, {
32346 key: 'asBeginTransactionParameters',
32347 value: function asBeginTransactionParameters() {
32348 var _ref;
32349
32350 if (this.isEmpty()) {
32351 return {};
32352 }
32353
32354 // Driver sends {bookmark: "max", bookmarks: ["one", "two", "max"]} instead of simple
32355 // {bookmarks: ["one", "two", "max"]} for backwards compatibility reasons. Old servers can only accept single
32356 // bookmark that is why driver has to parse and compare given list of bookmarks. This functionality will
32357 // eventually be removed.
32358 return _ref = {}, (0, _defineProperty3.default)(_ref, BOOKMARK_KEY, this._maxValue), (0, _defineProperty3.default)(_ref, BOOKMARKS_KEY, this._values), _ref;
32359 }
32360 }]);
32361 return Bookmark;
32362}();
32363
32364/**
32365 * Converts given value to an array.
32366 * @param {string|string[]} [value=undefined] argument to convert.
32367 * @return {string[]} value converted to an array.
32368 */
32369
32370
32371exports.default = Bookmark;
32372function asStringArray(value) {
32373 if (!value) {
32374 return [];
32375 }
32376
32377 if (util.isString(value)) {
32378 return [value];
32379 }
32380
32381 if (Array.isArray(value)) {
32382 var result = [];
32383 for (var i = 0; i < value.length; i++) {
32384 var element = value[i];
32385 // if it is undefined or null, ignore it
32386 if (element !== undefined && element !== null) {
32387 if (!util.isString(element)) {
32388 throw new TypeError('Bookmark should be a string, given: \'' + element + '\'');
32389 }
32390 result.push(element);
32391 }
32392 }
32393 return result;
32394 }
32395
32396 throw new TypeError('Bookmark should either be a string or a string array, given: \'' + value + '\'');
32397}
32398
32399/**
32400 * Find latest bookmark in the given array of bookmarks.
32401 * @param {string[]} bookmarks array of bookmarks.
32402 * @return {string|null} latest bookmark value.
32403 */
32404function maxBookmark(bookmarks) {
32405 if (!bookmarks || bookmarks.length === 0) {
32406 return null;
32407 }
32408
32409 var maxBookmark = bookmarks[0];
32410 var maxValue = bookmarkValue(maxBookmark);
32411
32412 for (var i = 1; i < bookmarks.length; i++) {
32413 var bookmark = bookmarks[i];
32414 var value = bookmarkValue(bookmark);
32415
32416 if (value > maxValue) {
32417 maxBookmark = bookmark;
32418 maxValue = value;
32419 }
32420 }
32421
32422 return maxBookmark;
32423}
32424
32425/**
32426 * Calculate numeric value for the given bookmark.
32427 * @param {string} bookmark argument to get numeric value for.
32428 * @return {number} value of the bookmark.
32429 */
32430function bookmarkValue(bookmark) {
32431 if (bookmark && bookmark.indexOf(BOOKMARK_PREFIX) === 0) {
32432 var result = parseInt(bookmark.substring(BOOKMARK_PREFIX.length));
32433 return result ? result : UNKNOWN_BOOKMARK_VALUE;
32434 }
32435 return UNKNOWN_BOOKMARK_VALUE;
32436}
32437
32438},{"./util":363,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34,"babel-runtime/helpers/defineProperty":35}],329:[function(require,module,exports){
32439"use strict";
32440
32441Object.defineProperty(exports, "__esModule", {
32442 value: true
32443});
32444exports.alloc = exports.NodeBuffer = exports.CombinedBuffer = exports.SliceBuffer = exports.HeapBuffer = exports.BaseBuffer = undefined;
32445
32446var _get2 = require("babel-runtime/helpers/get");
32447
32448var _get3 = _interopRequireDefault(_get2);
32449
32450var _getPrototypeOf = require("babel-runtime/core-js/object/get-prototype-of");
32451
32452var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
32453
32454var _possibleConstructorReturn2 = require("babel-runtime/helpers/possibleConstructorReturn");
32455
32456var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
32457
32458var _inherits2 = require("babel-runtime/helpers/inherits");
32459
32460var _inherits3 = _interopRequireDefault(_inherits2);
32461
32462var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
32463
32464var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
32465
32466var _createClass2 = require("babel-runtime/helpers/createClass");
32467
32468var _createClass3 = _interopRequireDefault(_createClass2);
32469
32470function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
32471
32472/**
32473 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
32474 *
32475 * This file is part of Neo4j.
32476 *
32477 * Licensed under the Apache License, Version 2.0 (the "License");
32478 * you may not use this file except in compliance with the License.
32479 * You may obtain a copy of the License at
32480 *
32481 * http://www.apache.org/licenses/LICENSE-2.0
32482 *
32483 * Unless required by applicable law or agreed to in writing, software
32484 * distributed under the License is distributed on an "AS IS" BASIS,
32485 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32486 * See the License for the specific language governing permissions and
32487 * limitations under the License.
32488 */
32489
32490/** This module defines a common API for dealing with binary data that
32491 * works for both browsers (via ArrayBuffer/DataView) and for NodeJS
32492 *(via Buffer API).
32493 */
32494
32495var _node = require("buffer");
32496/**
32497 * Common base with default implementation for most buffer methods.
32498 * Buffers are stateful - they track a current "position", this helps greatly
32499 * when reading and writing from them incrementally. You can also ignore the
32500 * stateful read/write methods.
32501 * readXXX and writeXXX-methods move the inner position of the buffer.
32502 * putXXX and getXXX-methods do not.
32503 * @access private
32504 */
32505
32506var BaseBuffer = function () {
32507 /**
32508 * Create a instance with the injected size.
32509 * @constructor
32510 * @param {Integer} size
32511 */
32512 function BaseBuffer(size) {
32513 (0, _classCallCheck3.default)(this, BaseBuffer);
32514
32515 this.position = 0;
32516 this.length = size;
32517 // Calling these out - this is the required
32518 // methods a subclass needs to implement
32519 var getUInt8 = null;
32520 var getInt8 = null;
32521 var getFloat64 = null;
32522 var getSlice = null;
32523 var putFloat64 = null;
32524 var putUInt8 = null;
32525 var putInt8 = null;
32526 }
32527
32528 /**
32529 * @param p
32530 */
32531
32532
32533 (0, _createClass3.default)(BaseBuffer, [{
32534 key: "getInt16",
32535 value: function getInt16(p) {
32536 return this.getInt8(p) << 8 | this.getUInt8(p + 1);
32537 }
32538
32539 /**
32540 * @param p
32541 */
32542
32543 }, {
32544 key: "getUInt16",
32545 value: function getUInt16(p) {
32546 return this.getUInt8(p) << 8 | this.getUInt8(p + 1);
32547 }
32548
32549 /**
32550 * @param p
32551 */
32552
32553 }, {
32554 key: "getInt32",
32555 value: function getInt32(p) {
32556 return this.getInt8(p) << 24 | this.getUInt8(p + 1) << 16 | this.getUInt8(p + 2) << 8 | this.getUInt8(p + 3);
32557 }
32558
32559 /**
32560 * @param p
32561 */
32562
32563 }, {
32564 key: "getUInt32",
32565 value: function getUInt32(p) {
32566 return this.getUInt8(p) << 24 | this.getUInt8(p + 1) << 16 | this.getUInt8(p + 2) << 8 | this.getUInt8(p + 3);
32567 }
32568
32569 /**
32570 * @param p
32571 */
32572
32573 }, {
32574 key: "getInt64",
32575 value: function getInt64(p) {
32576 return this.getInt8(p) << 56 | this.getUInt8(p + 1) << 48 | this.getUInt8(p + 2) << 40 | this.getUInt8(p + 3) << 32 | this.getUInt8(p + 4) << 24 | this.getUInt8(p + 5) << 16 | this.getUInt8(p + 6) << 8 | this.getUInt8(p + 7);
32577 }
32578
32579 /**
32580 * Get a slice of this buffer. This method does not copy any data,
32581 * but simply provides a slice view of this buffer
32582 * @param start
32583 * @param length
32584 */
32585
32586 }, {
32587 key: "getSlice",
32588 value: function getSlice(start, length) {
32589 return new SliceBuffer(start, length, this);
32590 }
32591
32592 /**
32593 * @param p
32594 * @param val
32595 */
32596
32597 }, {
32598 key: "putInt16",
32599 value: function putInt16(p, val) {
32600 this.putInt8(p, val >> 8);
32601 this.putUInt8(p + 1, val & 0xFF);
32602 }
32603
32604 /**
32605 * @param p
32606 * @param val
32607 */
32608
32609 }, {
32610 key: "putUInt16",
32611 value: function putUInt16(p, val) {
32612 this.putUInt8(p, val >> 8 & 0xFF);
32613 this.putUInt8(p + 1, val & 0xFF);
32614 }
32615
32616 /**
32617 * @param p
32618 * @param val
32619 */
32620
32621 }, {
32622 key: "putInt32",
32623 value: function putInt32(p, val) {
32624 this.putInt8(p, val >> 24);
32625 this.putUInt8(p + 1, val >> 16 & 0xFF);
32626 this.putUInt8(p + 2, val >> 8 & 0xFF);
32627 this.putUInt8(p + 3, val & 0xFF);
32628 }
32629
32630 /**
32631 * @param p
32632 * @param val
32633 */
32634
32635 }, {
32636 key: "putUInt32",
32637 value: function putUInt32(p, val) {
32638 this.putUInt8(p, val >> 24 & 0xFF);
32639 this.putUInt8(p + 1, val >> 16 & 0xFF);
32640 this.putUInt8(p + 2, val >> 8 & 0xFF);
32641 this.putUInt8(p + 3, val & 0xFF);
32642 }
32643
32644 /**
32645 * @param p
32646 * @param val
32647 */
32648
32649 }, {
32650 key: "putInt64",
32651 value: function putInt64(p, val) {
32652 this.putInt8(p, val >> 48);
32653 this.putUInt8(p + 1, val >> 42 & 0xFF);
32654 this.putUInt8(p + 2, val >> 36 & 0xFF);
32655 this.putUInt8(p + 3, val >> 30 & 0xFF);
32656 this.putUInt8(p + 4, val >> 24 & 0xFF);
32657 this.putUInt8(p + 5, val >> 16 & 0xFF);
32658 this.putUInt8(p + 6, val >> 8 & 0xFF);
32659 this.putUInt8(p + 7, val & 0xFF);
32660 }
32661
32662 /**
32663 * @param position
32664 * @param other
32665 */
32666
32667 }, {
32668 key: "putBytes",
32669 value: function putBytes(position, other) {
32670 for (var i = 0, end = other.remaining(); i < end; i++) {
32671 this.putUInt8(position + i, other.readUInt8());
32672 }
32673 }
32674
32675 /**
32676 * Read from state position.
32677 */
32678
32679 }, {
32680 key: "readUInt8",
32681 value: function readUInt8() {
32682 return this.getUInt8(this._updatePos(1));
32683 }
32684
32685 /**
32686 * Read from state position.
32687 */
32688
32689 }, {
32690 key: "readInt8",
32691 value: function readInt8() {
32692 return this.getInt8(this._updatePos(1));
32693 }
32694
32695 /**
32696 * Read from state position.
32697 */
32698
32699 }, {
32700 key: "readUInt16",
32701 value: function readUInt16() {
32702 return this.getUInt16(this._updatePos(2));
32703 }
32704
32705 /**
32706 * Read from state position.
32707 */
32708
32709 }, {
32710 key: "readUInt32",
32711 value: function readUInt32() {
32712 return this.getUInt32(this._updatePos(4));
32713 }
32714
32715 /**
32716 * Read from state position.
32717 */
32718
32719 }, {
32720 key: "readInt16",
32721 value: function readInt16() {
32722 return this.getInt16(this._updatePos(2));
32723 }
32724
32725 /**
32726 * Read from state position.
32727 */
32728
32729 }, {
32730 key: "readInt32",
32731 value: function readInt32() {
32732 return this.getInt32(this._updatePos(4));
32733 }
32734
32735 /**
32736 * Read from state position.
32737 */
32738
32739 }, {
32740 key: "readInt64",
32741 value: function readInt64() {
32742 return this.getInt32(this._updatePos(8));
32743 }
32744
32745 /**
32746 * Read from state position.
32747 */
32748
32749 }, {
32750 key: "readFloat64",
32751 value: function readFloat64() {
32752 return this.getFloat64(this._updatePos(8));
32753 }
32754
32755 /**
32756 * Write to state position.
32757 * @param val
32758 */
32759
32760 }, {
32761 key: "writeUInt8",
32762 value: function writeUInt8(val) {
32763 this.putUInt8(this._updatePos(1), val);
32764 }
32765
32766 /**
32767 * Write to state position.
32768 * @param val
32769 */
32770
32771 }, {
32772 key: "writeInt8",
32773 value: function writeInt8(val) {
32774 this.putInt8(this._updatePos(1), val);
32775 }
32776
32777 /**
32778 * Write to state position.
32779 * @param val
32780 */
32781
32782 }, {
32783 key: "writeInt16",
32784 value: function writeInt16(val) {
32785 this.putInt16(this._updatePos(2), val);
32786 }
32787
32788 /**
32789 * Write to state position.
32790 * @param val
32791 */
32792
32793 }, {
32794 key: "writeInt32",
32795 value: function writeInt32(val) {
32796 this.putInt32(this._updatePos(4), val);
32797 }
32798
32799 /**
32800 * Write to state position.
32801 * @param val
32802 */
32803
32804 }, {
32805 key: "writeUInt32",
32806 value: function writeUInt32(val) {
32807 this.putUInt32(this._updatePos(4), val);
32808 }
32809
32810 /**
32811 * Write to state position.
32812 * @param val
32813 */
32814
32815 }, {
32816 key: "writeInt64",
32817 value: function writeInt64(val) {
32818 this.putInt64(this._updatePos(8), val);
32819 }
32820
32821 /**
32822 * Write to state position.
32823 * @param val
32824 */
32825
32826 }, {
32827 key: "writeFloat64",
32828 value: function writeFloat64(val) {
32829 this.putFloat64(this._updatePos(8), val);
32830 }
32831
32832 /**
32833 * Write to state position.
32834 * @param val
32835 */
32836
32837 }, {
32838 key: "writeBytes",
32839 value: function writeBytes(val) {
32840 this.putBytes(this._updatePos(val.remaining()), val);
32841 }
32842
32843 /**
32844 * Get a slice of this buffer. This method does not copy any data,
32845 * but simply provides a slice view of this buffer
32846 * @param length
32847 */
32848
32849 }, {
32850 key: "readSlice",
32851 value: function readSlice(length) {
32852 return this.getSlice(this._updatePos(length), length);
32853 }
32854 }, {
32855 key: "_updatePos",
32856 value: function _updatePos(length) {
32857 var p = this.position;
32858 this.position += length;
32859 return p;
32860 }
32861
32862 /**
32863 * Get remaining
32864 */
32865
32866 }, {
32867 key: "remaining",
32868 value: function remaining() {
32869 return this.length - this.position;
32870 }
32871
32872 /**
32873 * Has remaining
32874 */
32875
32876 }, {
32877 key: "hasRemaining",
32878 value: function hasRemaining() {
32879 return this.remaining() > 0;
32880 }
32881
32882 /**
32883 * Reset position state
32884 */
32885
32886 }, {
32887 key: "reset",
32888 value: function reset() {
32889 this.position = 0;
32890 }
32891
32892 /**
32893 * Get string representation of buffer and it's state.
32894 * @return {string} Buffer as a string
32895 */
32896
32897 }, {
32898 key: "toString",
32899 value: function toString() {
32900 return this.constructor.name + "( position=" + this.position + " )\n " + this.toHex();
32901 }
32902
32903 /**
32904 * Get string representation of buffer.
32905 * @return {string} Buffer as a string
32906 */
32907
32908 }, {
32909 key: "toHex",
32910 value: function toHex() {
32911 // TODO something like StringBuilder?
32912 var out = "";
32913 for (var i = 0; i < this.length; i++) {
32914 var hexByte = this.getUInt8(i).toString(16);
32915 if (hexByte.length == 1) {
32916 hexByte = "0" + hexByte;
32917 }
32918 out += hexByte + " ";
32919 }
32920 return out;
32921 }
32922 }]);
32923 return BaseBuffer;
32924}();
32925
32926/**
32927 * Basic buffer implementation that should work in most any modern JS env.
32928 * @access private
32929 */
32930
32931
32932var HeapBuffer = function (_BaseBuffer) {
32933 (0, _inherits3.default)(HeapBuffer, _BaseBuffer);
32934
32935 function HeapBuffer(arg) {
32936 (0, _classCallCheck3.default)(this, HeapBuffer);
32937
32938 var buffer = arg instanceof ArrayBuffer ? arg : new ArrayBuffer(arg);
32939
32940 var _this = (0, _possibleConstructorReturn3.default)(this, (HeapBuffer.__proto__ || (0, _getPrototypeOf2.default)(HeapBuffer)).call(this, buffer.byteLength));
32941
32942 _this._buffer = buffer;
32943 _this._view = new DataView(_this._buffer);
32944 return _this;
32945 }
32946
32947 (0, _createClass3.default)(HeapBuffer, [{
32948 key: "putUInt8",
32949 value: function putUInt8(position, val) {
32950 this._view.setUint8(position, val);
32951 }
32952 }, {
32953 key: "getUInt8",
32954 value: function getUInt8(position) {
32955 return this._view.getUint8(position);
32956 }
32957 }, {
32958 key: "putInt8",
32959 value: function putInt8(position, val) {
32960 this._view.setInt8(position, val);
32961 }
32962 }, {
32963 key: "getInt8",
32964 value: function getInt8(position) {
32965 return this._view.getInt8(position);
32966 }
32967 }, {
32968 key: "getFloat64",
32969 value: function getFloat64(position) {
32970 return this._view.getFloat64(position);
32971 }
32972 }, {
32973 key: "putFloat64",
32974 value: function putFloat64(position, val) {
32975 this._view.setFloat64(position, val);
32976 }
32977 }, {
32978 key: "getSlice",
32979 value: function getSlice(start, length) {
32980 if (this._buffer.slice) {
32981 return new HeapBuffer(this._buffer.slice(start, start + length));
32982 } else {
32983 // Some platforms (eg. phantomjs) don't support slice, so fall back to a copy
32984 // We do this rather than return a SliceBuffer, because sliceBuffer cannot
32985 // be passed to native network write ops etc - we need ArrayBuffer for that
32986 var copy = new HeapBuffer(length);
32987 for (var i = 0; i < length; i++) {
32988 copy.putUInt8(i, this.getUInt8(i + start));
32989 }
32990 return copy;
32991 }
32992 }
32993
32994 /**
32995 * Specific to HeapBuffer, this gets a DataView from the
32996 * current position and of the specified length.
32997 */
32998
32999 }, {
33000 key: "readView",
33001 value: function readView(length) {
33002 return new DataView(this._buffer, this._updatePos(length), length);
33003 }
33004 }]);
33005 return HeapBuffer;
33006}(BaseBuffer);
33007
33008/**
33009 * Represents a view as slice of another buffer.
33010 * @access private
33011 */
33012
33013
33014var SliceBuffer = function (_BaseBuffer2) {
33015 (0, _inherits3.default)(SliceBuffer, _BaseBuffer2);
33016
33017 function SliceBuffer(start, length, inner) {
33018 (0, _classCallCheck3.default)(this, SliceBuffer);
33019
33020 var _this2 = (0, _possibleConstructorReturn3.default)(this, (SliceBuffer.__proto__ || (0, _getPrototypeOf2.default)(SliceBuffer)).call(this, length));
33021
33022 _this2._start = start;
33023 _this2._inner = inner;
33024 return _this2;
33025 }
33026
33027 (0, _createClass3.default)(SliceBuffer, [{
33028 key: "putUInt8",
33029 value: function putUInt8(position, val) {
33030 this._inner.putUInt8(this._start + position, val);
33031 }
33032 }, {
33033 key: "getUInt8",
33034 value: function getUInt8(position) {
33035 return this._inner.getUInt8(this._start + position);
33036 }
33037 }, {
33038 key: "putInt8",
33039 value: function putInt8(position, val) {
33040 this._inner.putInt8(this._start + position, val);
33041 }
33042 }, {
33043 key: "putFloat64",
33044 value: function putFloat64(position, val) {
33045 this._inner.putFloat64(this._start + position, val);
33046 }
33047 }, {
33048 key: "getInt8",
33049 value: function getInt8(position) {
33050 return this._inner.getInt8(this._start + position);
33051 }
33052 }, {
33053 key: "getFloat64",
33054 value: function getFloat64(position) {
33055 return this._inner.getFloat64(this._start + position);
33056 }
33057 }]);
33058 return SliceBuffer;
33059}(BaseBuffer);
33060
33061/**
33062 * Buffer that combines multiple buffers, exposing them as one single buffer.
33063 * @access private
33064 */
33065
33066
33067var CombinedBuffer = function (_BaseBuffer3) {
33068 (0, _inherits3.default)(CombinedBuffer, _BaseBuffer3);
33069
33070 function CombinedBuffer(buffers) {
33071 (0, _classCallCheck3.default)(this, CombinedBuffer);
33072
33073 var length = 0;
33074 for (var i = 0; i < buffers.length; i++) {
33075 length += buffers[i].length;
33076 }
33077
33078 var _this3 = (0, _possibleConstructorReturn3.default)(this, (CombinedBuffer.__proto__ || (0, _getPrototypeOf2.default)(CombinedBuffer)).call(this, length));
33079
33080 _this3._buffers = buffers;
33081 return _this3;
33082 }
33083
33084 (0, _createClass3.default)(CombinedBuffer, [{
33085 key: "getUInt8",
33086 value: function getUInt8(position) {
33087 // Surely there's a faster way to do this.. some sort of lookup table thing?
33088 for (var i = 0; i < this._buffers.length; i++) {
33089 var buffer = this._buffers[i];
33090 // If the position is not in the current buffer, skip the current buffer
33091 if (position >= buffer.length) {
33092 position -= buffer.length;
33093 } else {
33094 return buffer.getUInt8(position);
33095 }
33096 }
33097 }
33098 }, {
33099 key: "getInt8",
33100 value: function getInt8(position) {
33101 // Surely there's a faster way to do this.. some sort of lookup table thing?
33102 for (var i = 0; i < this._buffers.length; i++) {
33103 var buffer = this._buffers[i];
33104 // If the position is not in the current buffer, skip the current buffer
33105 if (position >= buffer.length) {
33106 position -= buffer.length;
33107 } else {
33108 return buffer.getInt8(position);
33109 }
33110 }
33111 }
33112 }, {
33113 key: "getFloat64",
33114 value: function getFloat64(position) {
33115 // At some point, a more efficient impl. For now, we copy the 8 bytes
33116 // we want to read and depend on the platform impl of IEEE 754.
33117 var b = alloc(8);
33118 for (var i = 0; i < 8; i++) {
33119 b.putUInt8(i, this.getUInt8(position + i));
33120 };
33121 return b.getFloat64(0);
33122 }
33123 }]);
33124 return CombinedBuffer;
33125}(BaseBuffer);
33126
33127/**
33128 * Buffer used in a Node.js environment
33129 * @access private
33130 */
33131
33132
33133var NodeBuffer = function (_BaseBuffer4) {
33134 (0, _inherits3.default)(NodeBuffer, _BaseBuffer4);
33135
33136 function NodeBuffer(arg) {
33137 (0, _classCallCheck3.default)(this, NodeBuffer);
33138
33139 var buffer = arg instanceof _node.Buffer ? arg : newNodeJSBuffer(arg);
33140
33141 var _this4 = (0, _possibleConstructorReturn3.default)(this, (NodeBuffer.__proto__ || (0, _getPrototypeOf2.default)(NodeBuffer)).call(this, buffer.length));
33142
33143 _this4._buffer = buffer;
33144 return _this4;
33145 }
33146
33147 (0, _createClass3.default)(NodeBuffer, [{
33148 key: "getUInt8",
33149 value: function getUInt8(position) {
33150 return this._buffer.readUInt8(position);
33151 }
33152 }, {
33153 key: "getInt8",
33154 value: function getInt8(position) {
33155 return this._buffer.readInt8(position);
33156 }
33157 }, {
33158 key: "getFloat64",
33159 value: function getFloat64(position) {
33160 return this._buffer.readDoubleBE(position);
33161 }
33162 }, {
33163 key: "putUInt8",
33164 value: function putUInt8(position, val) {
33165 this._buffer.writeUInt8(val, position);
33166 }
33167 }, {
33168 key: "putInt8",
33169 value: function putInt8(position, val) {
33170 this._buffer.writeInt8(val, position);
33171 }
33172 }, {
33173 key: "putFloat64",
33174 value: function putFloat64(position, val) {
33175 this._buffer.writeDoubleBE(val, position);
33176 }
33177 }, {
33178 key: "putBytes",
33179 value: function putBytes(position, val) {
33180 if (val instanceof NodeBuffer) {
33181 var bytesToCopy = Math.min(val.length - val.position, this.length - position);
33182 val._buffer.copy(this._buffer, position, val.position, val.position + bytesToCopy);
33183 val.position += bytesToCopy;
33184 } else {
33185 (0, _get3.default)(NodeBuffer.prototype.__proto__ || (0, _getPrototypeOf2.default)(NodeBuffer.prototype), "putBytes", this).call(this, position, val);
33186 }
33187 }
33188 }, {
33189 key: "getSlice",
33190 value: function getSlice(start, length) {
33191 return new NodeBuffer(this._buffer.slice(start, start + length));
33192 }
33193 }]);
33194 return NodeBuffer;
33195}(BaseBuffer);
33196
33197function newNodeJSBuffer(arg) {
33198 if (typeof arg === 'number' && typeof _node.Buffer.alloc === 'function') {
33199 // use static factory function present in newer NodeJS versions to allocate new buffer with specified size
33200 return _node.Buffer.alloc(arg);
33201 } else {
33202 // fallback to the old, potentially deprecated constructor
33203 return new _node.Buffer(arg);
33204 }
33205}
33206
33207// Use HeapBuffer by default, unless Buffer API is available, see below
33208var _DefaultBuffer = HeapBuffer;
33209try {
33210 // This will throw an exception if we're not running on NodeJS or equivalent
33211 require.resolve("buffer");
33212 _DefaultBuffer = NodeBuffer;
33213} catch (e) {}
33214
33215/**
33216 * Allocate a new buffer using whatever mechanism is most sensible for the
33217 * current platform
33218 * @access private
33219 * @param {Integer} size
33220 * @return new buffer
33221 */
33222function alloc(size) {
33223 return new _DefaultBuffer(size);
33224}
33225
33226exports.BaseBuffer = BaseBuffer;
33227exports.HeapBuffer = HeapBuffer;
33228exports.SliceBuffer = SliceBuffer;
33229exports.CombinedBuffer = CombinedBuffer;
33230exports.NodeBuffer = NodeBuffer;
33231exports.alloc = alloc;
33232
33233},{"babel-runtime/core-js/object/get-prototype-of":26,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34,"babel-runtime/helpers/get":36,"babel-runtime/helpers/inherits":37,"babel-runtime/helpers/possibleConstructorReturn":38,"buffer":75}],330:[function(require,module,exports){
33234'use strict';
33235
33236Object.defineProperty(exports, "__esModule", {
33237 value: true
33238});
33239
33240var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
33241
33242var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
33243
33244var _features = require('./features');
33245
33246var _features2 = _interopRequireDefault(_features);
33247
33248var _error = require('../error');
33249
33250function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33251
33252/**
33253 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
33254 *
33255 * This file is part of Neo4j.
33256 *
33257 * Licensed under the Apache License, Version 2.0 (the "License");
33258 * you may not use this file except in compliance with the License.
33259 * You may obtain a copy of the License at
33260 *
33261 * http://www.apache.org/licenses/LICENSE-2.0
33262 *
33263 * Unless required by applicable law or agreed to in writing, software
33264 * distributed under the License is distributed on an "AS IS" BASIS,
33265 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33266 * See the License for the specific language governing permissions and
33267 * limitations under the License.
33268 */
33269
33270var DEFAULT_CONNECTION_TIMEOUT_MILLIS = 5000; // 5 seconds by default
33271
33272var ChannelConfig =
33273
33274/**
33275 * @constructor
33276 * @param {Url} url the URL for the channel to connect to.
33277 * @param {object} driverConfig the driver config provided by the user when driver is created.
33278 * @param {string} connectionErrorCode the default error code to use on connection errors.
33279 */
33280function ChannelConfig(url, driverConfig, connectionErrorCode) {
33281 (0, _classCallCheck3.default)(this, ChannelConfig);
33282
33283 this.url = url;
33284 this.encrypted = extractEncrypted(driverConfig);
33285 this.trust = extractTrust(driverConfig);
33286 this.trustedCertificates = extractTrustedCertificates(driverConfig);
33287 this.knownHostsPath = extractKnownHostsPath(driverConfig);
33288 this.connectionErrorCode = connectionErrorCode || _error.SERVICE_UNAVAILABLE;
33289 this.connectionTimeout = extractConnectionTimeout(driverConfig);
33290};
33291
33292exports.default = ChannelConfig;
33293
33294
33295function extractEncrypted(driverConfig) {
33296 // check if encryption was configured by the user, use explicit null check because we permit boolean value
33297 var encryptionConfigured = driverConfig.encrypted == null;
33298 // default to using encryption if trust-all-certificates is available
33299 return encryptionConfigured ? (0, _features2.default)('trust_all_certificates') : driverConfig.encrypted;
33300}
33301
33302function extractTrust(driverConfig) {
33303 if (driverConfig.trust) {
33304 return driverConfig.trust;
33305 }
33306 // default to using TRUST_ALL_CERTIFICATES if it is available
33307 return (0, _features2.default)('trust_all_certificates') ? 'TRUST_ALL_CERTIFICATES' : 'TRUST_CUSTOM_CA_SIGNED_CERTIFICATES';
33308}
33309
33310function extractTrustedCertificates(driverConfig) {
33311 return driverConfig.trustedCertificates || [];
33312}
33313
33314function extractKnownHostsPath(driverConfig) {
33315 return driverConfig.knownHosts || null;
33316}
33317
33318function extractConnectionTimeout(driverConfig) {
33319 var configuredTimeout = parseInt(driverConfig.connectionTimeout, 10);
33320 if (configuredTimeout === 0) {
33321 // timeout explicitly configured to 0
33322 return null;
33323 } else if (configuredTimeout && configuredTimeout < 0) {
33324 // timeout explicitly configured to a negative value
33325 return null;
33326 } else if (!configuredTimeout) {
33327 // timeout not configured, use default value
33328 return DEFAULT_CONNECTION_TIMEOUT_MILLIS;
33329 } else {
33330 // timeout configured, use the provided value
33331 return configuredTimeout;
33332 }
33333}
33334
33335},{"../error":324,"./features":338,"babel-runtime/helpers/classCallCheck":33}],331:[function(require,module,exports){
33336'use strict';
33337
33338Object.defineProperty(exports, "__esModule", {
33339 value: true
33340});
33341
33342var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
33343
33344var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
33345
33346var _createClass2 = require('babel-runtime/helpers/createClass');
33347
33348var _createClass3 = _interopRequireDefault(_createClass2);
33349
33350var _net = require('net');
33351
33352var _net2 = _interopRequireDefault(_net);
33353
33354var _tls = require('tls');
33355
33356var _tls2 = _interopRequireDefault(_tls);
33357
33358var _fs = require('fs');
33359
33360var _fs2 = _interopRequireDefault(_fs);
33361
33362var _path = require('path');
33363
33364var _path2 = _interopRequireDefault(_path);
33365
33366var _os = require('os');
33367
33368var _buf = require('./buf');
33369
33370var _util = require('./util');
33371
33372var _error = require('./../error');
33373
33374function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33375
33376/**
33377 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
33378 *
33379 * This file is part of Neo4j.
33380 *
33381 * Licensed under the Apache License, Version 2.0 (the "License");
33382 * you may not use this file except in compliance with the License.
33383 * You may obtain a copy of the License at
33384 *
33385 * http://www.apache.org/licenses/LICENSE-2.0
33386 *
33387 * Unless required by applicable law or agreed to in writing, software
33388 * distributed under the License is distributed on an "AS IS" BASIS,
33389 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33390 * See the License for the specific language governing permissions and
33391 * limitations under the License.
33392 */
33393var _CONNECTION_IDGEN = 0;
33394
33395function userHome() {
33396 // For some reason, Browserify chokes on shimming `process`. This code
33397 // will never get executed on the browser anyway, to just hack around it
33398 var getOutOfHereBrowserifyYoureDrunk = require;
33399 var process = getOutOfHereBrowserifyYoureDrunk('process');
33400
33401 return process.env[process.platform == 'win32' ? 'USERPROFILE' : 'HOME'];
33402}
33403
33404function mkFullPath(pathToCreate) {
33405 try {
33406 _fs2.default.mkdirSync(pathToCreate);
33407 } catch (e) {
33408 if (e.code === 'ENOENT') {
33409 // Create parent dir
33410 mkFullPath(_path2.default.dirname(pathToCreate));
33411 // And now try again
33412 mkFullPath(pathToCreate);
33413 return;
33414 }
33415 if (e.code === 'EEXIST') {
33416 return;
33417 }
33418 throw e;
33419 }
33420}
33421
33422function loadFingerprint(serverId, knownHostsPath, cb) {
33423 try {
33424 _fs2.default.accessSync(knownHostsPath);
33425 } catch (e) {
33426 return cb(null);
33427 }
33428 var found = false;
33429 require('readline').createInterface({
33430 input: _fs2.default.createReadStream(knownHostsPath)
33431 }).on('line', function (line) {
33432 if (!found && line.startsWith(serverId)) {
33433 found = true;
33434 cb(line.split(" ")[1]);
33435 }
33436 }).on('close', function () {
33437 if (!found) {
33438 cb(null);
33439 }
33440 });
33441}
33442
33443var _lockFingerprintFromAppending = {};
33444function storeFingerprint(serverId, knownHostsPath, fingerprint, cb) {
33445 // we check if the serverId has been appended
33446 if (!!_lockFingerprintFromAppending[serverId]) {
33447 // if it has, we ignore it
33448 return cb(null);
33449 }
33450
33451 // we make the line as appended
33452 // ( 1 is more efficient to store than true because true is an oddball )
33453 _lockFingerprintFromAppending[serverId] = 1;
33454
33455 // If file doesn't exist, create full path to it
33456 try {
33457 _fs2.default.accessSync(knownHostsPath);
33458 } catch (_) {
33459 mkFullPath(_path2.default.dirname(knownHostsPath));
33460 }
33461
33462 _fs2.default.appendFile(knownHostsPath, serverId + " " + fingerprint + _os.EOL, "utf8", function (err) {
33463 delete _lockFingerprintFromAppending[serverId];
33464 if (err) {
33465 console.log(err);
33466 }
33467 return cb(err);
33468 });
33469}
33470
33471var TrustStrategy = {
33472 /**
33473 * @deprecated Since version 1.0. Will be deleted in a future version. {@link #TRUST_CUSTOM_CA_SIGNED_CERTIFICATES}.
33474 */
33475 TRUST_SIGNED_CERTIFICATES: function TRUST_SIGNED_CERTIFICATES(config, onSuccess, onFailure) {
33476 console.warn('`TRUST_SIGNED_CERTIFICATES` has been deprecated as option and will be removed in a future version of ' + "the driver. Please use `TRUST_CUSTOM_CA_SIGNED_CERTIFICATES` instead.");
33477 return TrustStrategy.TRUST_CUSTOM_CA_SIGNED_CERTIFICATES(config, onSuccess, onFailure);
33478 },
33479 TRUST_CUSTOM_CA_SIGNED_CERTIFICATES: function TRUST_CUSTOM_CA_SIGNED_CERTIFICATES(config, onSuccess, onFailure) {
33480 if (!config.trustedCertificates || config.trustedCertificates.length === 0) {
33481 onFailure((0, _error.newError)("You are using TRUST_CUSTOM_CA_SIGNED_CERTIFICATES as the method " + "to verify trust for encrypted connections, but have not configured any " + "trustedCertificates. You must specify the path to at least one trusted " + "X.509 certificate for this to work. Two other alternatives is to use " + "TRUST_ALL_CERTIFICATES or to disable encryption by setting encrypted=\"" + _util.ENCRYPTION_OFF + "\"" + "in your driver configuration."));
33482 return;
33483 }
33484
33485 var tlsOpts = {
33486 ca: config.trustedCertificates.map(function (f) {
33487 return _fs2.default.readFileSync(f);
33488 }),
33489 // Because we manually check for this in the connect callback, to give
33490 // a more helpful error to the user
33491 rejectUnauthorized: false
33492 };
33493
33494 var socket = _tls2.default.connect(config.url.port, config.url.host, tlsOpts, function () {
33495 if (!socket.authorized) {
33496 onFailure((0, _error.newError)("Server certificate is not trusted. If you trust the database you are connecting to, add" + " the signing certificate, or the server certificate, to the list of certificates trusted by this driver" + " using `neo4j.v1.driver(.., { trustedCertificates:['path/to/certificate.crt']}). This " + " is a security measure to protect against man-in-the-middle attacks. If you are just trying " + " Neo4j out and are not concerned about encryption, simply disable it using `encrypted=\"" + _util.ENCRYPTION_OFF + "\"`" + " in the driver options. Socket responded with: " + socket.authorizationError));
33497 } else {
33498 onSuccess();
33499 }
33500 });
33501 socket.on('error', onFailure);
33502 return socket;
33503 },
33504 TRUST_SYSTEM_CA_SIGNED_CERTIFICATES: function TRUST_SYSTEM_CA_SIGNED_CERTIFICATES(config, onSuccess, onFailure) {
33505
33506 var tlsOpts = {
33507 // Because we manually check for this in the connect callback, to give
33508 // a more helpful error to the user
33509 rejectUnauthorized: false
33510 };
33511 var socket = _tls2.default.connect(config.url.port, config.url.host, tlsOpts, function () {
33512 if (!socket.authorized) {
33513 onFailure((0, _error.newError)("Server certificate is not trusted. If you trust the database you are connecting to, use " + "TRUST_CUSTOM_CA_SIGNED_CERTIFICATES and add" + " the signing certificate, or the server certificate, to the list of certificates trusted by this driver" + " using `neo4j.v1.driver(.., { trustedCertificates:['path/to/certificate.crt']}). This " + " is a security measure to protect against man-in-the-middle attacks. If you are just trying " + " Neo4j out and are not concerned about encryption, simply disable it using `encrypted=\"" + _util.ENCRYPTION_OFF + "\"`" + " in the driver options. Socket responded with: " + socket.authorizationError));
33514 } else {
33515 onSuccess();
33516 }
33517 });
33518 socket.on('error', onFailure);
33519 return socket;
33520 },
33521 /**
33522 * @deprecated in 1.1 in favour of {@link #TRUST_ALL_CERTIFICATES}. Will be deleted in a future version.
33523 */
33524 TRUST_ON_FIRST_USE: function TRUST_ON_FIRST_USE(config, onSuccess, onFailure) {
33525 console.warn('`TRUST_ON_FIRST_USE` has been deprecated as option and will be removed in a future version of ' + "the driver. Please use `TRUST_ALL_CERTIFICATES` instead.");
33526
33527 var tlsOpts = {
33528 // Because we manually verify the certificate against known_hosts
33529 rejectUnauthorized: false
33530 };
33531
33532 var socket = _tls2.default.connect(config.url.port, config.url.host, tlsOpts, function () {
33533 var serverCert = socket.getPeerCertificate( /*raw=*/true);
33534
33535 if (!serverCert.raw) {
33536 // If `raw` is not available, we're on an old version of NodeJS, and
33537 // the raw cert cannot be accessed (or, at least I couldn't find a way to)
33538 // therefore, we can't generate a SHA512 fingerprint, meaning we can't
33539 // do TOFU, and the safe approach is to fail.
33540 onFailure((0, _error.newError)("You are using a version of NodeJS that does not " + "support trust-on-first use encryption. You can either upgrade NodeJS to " + "a newer version, use `trust:TRUST_CUSTOM_CA_SIGNED_CERTIFICATES` in your driver " + "config instead, or disable encryption using `encrypted:\"" + _util.ENCRYPTION_OFF + "\"`."));
33541 return;
33542 }
33543
33544 var serverFingerprint = require('crypto').createHash('sha512').update(serverCert.raw).digest("hex");
33545 var knownHostsPath = config.knownHostsPath || _path2.default.join(userHome(), ".neo4j", "known_hosts");
33546 var serverId = config.url.hostAndPort;
33547
33548 loadFingerprint(serverId, knownHostsPath, function (knownFingerprint) {
33549 if (knownFingerprint === serverFingerprint) {
33550 onSuccess();
33551 } else if (knownFingerprint == null) {
33552 storeFingerprint(serverId, knownHostsPath, serverFingerprint, function (err) {
33553 if (err) {
33554 return onFailure(err);
33555 }
33556 return onSuccess();
33557 });
33558 } else {
33559 onFailure((0, _error.newError)("Database encryption certificate has changed, and no longer " + "matches the certificate stored for " + serverId + " in `" + knownHostsPath + "`. As a security precaution, this driver will not automatically trust the new " + "certificate, because doing so would allow an attacker to pretend to be the Neo4j " + "instance we want to connect to. The certificate provided by the server looks like: " + serverCert + ". If you trust that this certificate is valid, simply remove the line " + "starting with " + serverId + " in `" + knownHostsPath + "`, and the driver will " + "update the file with the new certificate. You can configure which file the driver " + "should use to store this information by setting `knownHosts` to another path in " + "your driver configuration - and you can disable encryption there as well using " + "`encrypted:\"" + _util.ENCRYPTION_OFF + "\"`."));
33560 }
33561 });
33562 });
33563 socket.on('error', onFailure);
33564 return socket;
33565 },
33566
33567 TRUST_ALL_CERTIFICATES: function TRUST_ALL_CERTIFICATES(config, onSuccess, onFailure) {
33568 var tlsOpts = {
33569 rejectUnauthorized: false
33570 };
33571 var socket = _tls2.default.connect(config.url.port, config.url.host, tlsOpts, function () {
33572 var certificate = socket.getPeerCertificate();
33573 if ((0, _util.isEmptyObjectOrNull)(certificate)) {
33574 onFailure((0, _error.newError)("Secure connection was successful but server did not return any valid " + "certificates. Such connection can not be trusted. If you are just trying " + " Neo4j out and are not concerned about encryption, simply disable it using " + "`encrypted=\"" + _util.ENCRYPTION_OFF + "\"` in the driver options. " + "Socket responded with: " + socket.authorizationError));
33575 } else {
33576 onSuccess();
33577 }
33578 });
33579 socket.on('error', onFailure);
33580 return socket;
33581 }
33582};
33583
33584/**
33585 * Connect using node socket.
33586 * @param {ChannelConfig} config - configuration of this channel.
33587 * @param {function} onSuccess - callback to execute on connection success.
33588 * @param {function} onFailure - callback to execute on connection failure.
33589 * @return {*} socket connection.
33590 */
33591function connect(config, onSuccess) {
33592 var onFailure = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {
33593 return null;
33594 };
33595
33596 //still allow boolean for backwards compatibility
33597 if (config.encrypted === false || config.encrypted === _util.ENCRYPTION_OFF) {
33598 var conn = _net2.default.connect(config.url.port, config.url.host, onSuccess);
33599 conn.on('error', onFailure);
33600 return conn;
33601 } else if (TrustStrategy[config.trust]) {
33602 return TrustStrategy[config.trust](config, onSuccess, onFailure);
33603 } else {
33604 onFailure((0, _error.newError)("Unknown trust strategy: " + config.trust + ". Please use either " + "trust:'TRUST_CUSTOM_CA_SIGNED_CERTIFICATES' or trust:'TRUST_ALL_CERTIFICATES' in your driver " + "configuration. Alternatively, you can disable encryption by setting " + "`encrypted:\"" + _util.ENCRYPTION_OFF + "\"`. There is no mechanism to use encryption without trust verification, " + "because this incurs the overhead of encryption without improving security. If " + "the driver does not verify that the peer it is connected to is really Neo4j, it " + "is very easy for an attacker to bypass the encryption by pretending to be Neo4j."));
33605 }
33606}
33607
33608/**
33609 * In a Node.js environment the 'net' module is used
33610 * as transport.
33611 * @access private
33612 */
33613
33614var NodeChannel = function () {
33615
33616 /**
33617 * Create new instance
33618 * @param {ChannelConfig} config - configuration for this channel.
33619 */
33620 function NodeChannel(config) {
33621 (0, _classCallCheck3.default)(this, NodeChannel);
33622
33623 var self = this;
33624
33625 this.id = _CONNECTION_IDGEN++;
33626 this.available = true;
33627 this._pending = [];
33628 this._open = true;
33629 this._error = null;
33630 this._handleConnectionError = this._handleConnectionError.bind(this);
33631 this._handleConnectionTerminated = this._handleConnectionTerminated.bind(this);
33632 this._connectionErrorCode = config.connectionErrorCode;
33633
33634 this._encrypted = config.encrypted;
33635 this._conn = connect(config, function () {
33636 if (!self._open) {
33637 return;
33638 }
33639
33640 self._conn.on('data', function (buffer) {
33641 if (self.onmessage) {
33642 self.onmessage(new _buf.NodeBuffer(buffer));
33643 }
33644 });
33645
33646 self._conn.on('error', self._handleConnectionError);
33647 self._conn.on('end', self._handleConnectionTerminated);
33648
33649 // Drain all pending messages
33650 var pending = self._pending;
33651 self._pending = null;
33652 for (var i = 0; i < pending.length; i++) {
33653 self.write(pending[i]);
33654 }
33655 }, this._handleConnectionError);
33656
33657 this._setupConnectionTimeout(config, this._conn);
33658 }
33659
33660 (0, _createClass3.default)(NodeChannel, [{
33661 key: '_handleConnectionError',
33662 value: function _handleConnectionError(err) {
33663 var msg = err.message || 'Failed to connect to server';
33664 this._error = (0, _error.newError)(msg, this._connectionErrorCode);
33665 if (this.onerror) {
33666 this.onerror(this._error);
33667 }
33668 }
33669 }, {
33670 key: '_handleConnectionTerminated',
33671 value: function _handleConnectionTerminated() {
33672 this._error = (0, _error.newError)('Connection was closed by server', this._connectionErrorCode);
33673 if (this.onerror) {
33674 this.onerror(this._error);
33675 }
33676 }
33677
33678 /**
33679 * Setup connection timeout on the socket, if configured.
33680 * @param {ChannelConfig} config - configuration of this channel.
33681 * @param {object} socket - `net.Socket` or `tls.TLSSocket` object.
33682 * @private
33683 */
33684
33685 }, {
33686 key: '_setupConnectionTimeout',
33687 value: function _setupConnectionTimeout(config, socket) {
33688 var timeout = config.connectionTimeout;
33689 if (timeout) {
33690 socket.on('connect', function () {
33691 // connected - clear connection timeout
33692 socket.setTimeout(0);
33693 });
33694
33695 socket.on('timeout', function () {
33696 // timeout fired - not connected within configured time. cancel timeout and destroy socket
33697 socket.setTimeout(0);
33698 socket.destroy((0, _error.newError)('Failed to establish connection in ' + timeout + 'ms', config.connectionErrorCode));
33699 });
33700
33701 socket.setTimeout(timeout);
33702 }
33703 }
33704 }, {
33705 key: 'isEncrypted',
33706 value: function isEncrypted() {
33707 return this._encrypted;
33708 }
33709
33710 /**
33711 * Write the passed in buffer to connection
33712 * @param {NodeBuffer} buffer - Buffer to write
33713 */
33714
33715 }, {
33716 key: 'write',
33717 value: function write(buffer) {
33718 // If there is a pending queue, push this on that queue. This means
33719 // we are not yet connected, so we queue things locally.
33720 if (this._pending !== null) {
33721 this._pending.push(buffer);
33722 } else if (buffer instanceof _buf.NodeBuffer) {
33723 // console.log( "[Conn#"+this.id+"] SEND: ", buffer.toString() );
33724 this._conn.write(buffer._buffer);
33725 } else {
33726 throw (0, _error.newError)("Don't know how to write: " + buffer);
33727 }
33728 }
33729
33730 /**
33731 * Close the connection
33732 * @param {function} cb - Function to call on close.
33733 */
33734
33735 }, {
33736 key: 'close',
33737 value: function close() {
33738 var cb = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {
33739 return null;
33740 };
33741
33742 this._open = false;
33743 if (this._conn) {
33744 this._conn.end();
33745 this._conn.removeListener('end', this._handleConnectionTerminated);
33746 this._conn.on('end', cb);
33747 } else {
33748 cb();
33749 }
33750 }
33751 }]);
33752 return NodeChannel;
33753}();
33754
33755var _nodeChannelModule = { channel: NodeChannel, available: true };
33756
33757try {
33758 // Only define this module if 'net' is available
33759 require.resolve("net");
33760} catch (e) {
33761 _nodeChannelModule = { available: false };
33762}
33763
33764exports.default = _nodeChannelModule;
33765
33766},{"./../error":324,"./buf":329,"./util":363,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34,"crypto":215,"fs":73,"net":73,"os":268,"path":274,"readline":73,"tls":73}],332:[function(require,module,exports){
33767'use strict';
33768
33769Object.defineProperty(exports, "__esModule", {
33770 value: true
33771});
33772
33773var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
33774
33775var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
33776
33777var _createClass2 = require('babel-runtime/helpers/createClass');
33778
33779var _createClass3 = _interopRequireDefault(_createClass2);
33780
33781var _buf = require('./buf');
33782
33783var _error = require('./../error');
33784
33785var _util = require('./util');
33786
33787function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33788
33789/**
33790 * Create a new WebSocketChannel to be used in web browsers.
33791 * @access private
33792 */
33793var WebSocketChannel = function () {
33794
33795 /**
33796 * Create new instance
33797 * @param {ChannelConfig} config - configuration for this channel.
33798 */
33799 function WebSocketChannel(config) {
33800 (0, _classCallCheck3.default)(this, WebSocketChannel);
33801
33802
33803 this._open = true;
33804 this._pending = [];
33805 this._error = null;
33806 this._handleConnectionError = this._handleConnectionError.bind(this);
33807 this._config = config;
33808
33809 var scheme = "ws";
33810 //Allow boolean for backwards compatibility
33811 if (config.encrypted === true || config.encrypted === _util.ENCRYPTION_ON) {
33812 if (!config.trust || config.trust === 'TRUST_CUSTOM_CA_SIGNED_CERTIFICATES') {
33813 scheme = "wss";
33814 } else {
33815 this._error = (0, _error.newError)("The browser version of this driver only supports one trust " + 'strategy, \'TRUST_CUSTOM_CA_SIGNED_CERTIFICATES\'. ' + config.trust + ' is not supported. Please ' + "either use TRUST_CUSTOM_CA_SIGNED_CERTIFICATES or disable encryption by setting " + "`encrypted:\"" + _util.ENCRYPTION_OFF + "\"` in the driver configuration.");
33816 return;
33817 }
33818 }
33819
33820 this._ws = createWebSocket(scheme, config.url);
33821 this._ws.binaryType = "arraybuffer";
33822
33823 var self = this;
33824 //All connection errors are not sent to the error handler
33825 //we must also check for dirty close calls
33826 this._ws.onclose = function (e) {
33827 if (!e.wasClean) {
33828 self._handleConnectionError();
33829 }
33830 };
33831 this._ws.onopen = function () {
33832 // Connected! Cancel the connection timeout
33833 self._clearConnectionTimeout();
33834
33835 // Drain all pending messages
33836 var pending = self._pending;
33837 self._pending = null;
33838 for (var i = 0; i < pending.length; i++) {
33839 self.write(pending[i]);
33840 }
33841 };
33842 this._ws.onmessage = function (event) {
33843 if (self.onmessage) {
33844 var b = new _buf.HeapBuffer(event.data);
33845 self.onmessage(b);
33846 }
33847 };
33848
33849 this._ws.onerror = this._handleConnectionError;
33850
33851 this._connectionTimeoutFired = false;
33852 this._connectionTimeoutId = this._setupConnectionTimeout();
33853 }
33854
33855 (0, _createClass3.default)(WebSocketChannel, [{
33856 key: '_handleConnectionError',
33857 value: function _handleConnectionError() {
33858 if (this._connectionTimeoutFired) {
33859 // timeout fired - not connected within configured time
33860 this._error = (0, _error.newError)('Failed to establish connection in ' + this._config.connectionTimeout + 'ms', this._config.connectionErrorCode);
33861
33862 if (this.onerror) {
33863 this.onerror(this._error);
33864 }
33865 return;
33866 }
33867
33868 // onerror triggers on websocket close as well.. don't get me started.
33869 if (this._open) {
33870 // http://stackoverflow.com/questions/25779831/how-to-catch-websocket-connection-to-ws-xxxnn-failed-connection-closed-be
33871 this._error = (0, _error.newError)("WebSocket connection failure. Due to security " + "constraints in your web browser, the reason for the failure is not available " + "to this Neo4j Driver. Please use your browsers development console to determine " + "the root cause of the failure. Common reasons include the database being " + "unavailable, using the wrong connection URL or temporary network problems. " + "If you have enabled encryption, ensure your browser is configured to trust the " + 'certificate Neo4j is configured to use. WebSocket `readyState` is: ' + this._ws.readyState, this._config.connectionErrorCode);
33872 if (this.onerror) {
33873 this.onerror(this._error);
33874 }
33875 }
33876 }
33877 }, {
33878 key: 'isEncrypted',
33879 value: function isEncrypted() {
33880 return this._config.encrypted;
33881 }
33882
33883 /**
33884 * Write the passed in buffer to connection
33885 * @param {HeapBuffer} buffer - Buffer to write
33886 */
33887
33888 }, {
33889 key: 'write',
33890 value: function write(buffer) {
33891 // If there is a pending queue, push this on that queue. This means
33892 // we are not yet connected, so we queue things locally.
33893 if (this._pending !== null) {
33894 this._pending.push(buffer);
33895 } else if (buffer instanceof _buf.HeapBuffer) {
33896 this._ws.send(buffer._buffer);
33897 } else {
33898 throw (0, _error.newError)("Don't know how to send buffer: " + buffer);
33899 }
33900 }
33901
33902 /**
33903 * Close the connection
33904 * @param {function} cb - Function to call on close.
33905 */
33906
33907 }, {
33908 key: 'close',
33909 value: function close() {
33910 var cb = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {
33911 return null;
33912 };
33913
33914 this._open = false;
33915 this._clearConnectionTimeout();
33916 this._ws.close();
33917 this._ws.onclose = cb;
33918 }
33919
33920 /**
33921 * Set connection timeout on the given WebSocket, if configured.
33922 * @return {number} the timeout id or null.
33923 * @private
33924 */
33925
33926 }, {
33927 key: '_setupConnectionTimeout',
33928 value: function _setupConnectionTimeout() {
33929 var _this = this;
33930
33931 var timeout = this._config.connectionTimeout;
33932 if (timeout) {
33933 var webSocket = this._ws;
33934
33935 return setTimeout(function () {
33936 if (webSocket.readyState !== WebSocket.OPEN) {
33937 _this._connectionTimeoutFired = true;
33938 webSocket.close();
33939 }
33940 }, timeout);
33941 }
33942 return null;
33943 }
33944
33945 /**
33946 * Remove active connection timeout, if any.
33947 * @private
33948 */
33949
33950 }, {
33951 key: '_clearConnectionTimeout',
33952 value: function _clearConnectionTimeout() {
33953 var timeoutId = this._connectionTimeoutId;
33954 if (timeoutId || timeoutId === 0) {
33955 this._connectionTimeoutFired = false;
33956 this._connectionTimeoutId = null;
33957 clearTimeout(timeoutId);
33958 }
33959 }
33960 }]);
33961 return WebSocketChannel;
33962}(); /**
33963 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
33964 *
33965 * This file is part of Neo4j.
33966 *
33967 * Licensed under the Apache License, Version 2.0 (the "License");
33968 * you may not use this file except in compliance with the License.
33969 * You may obtain a copy of the License at
33970 *
33971 * http://www.apache.org/licenses/LICENSE-2.0
33972 *
33973 * Unless required by applicable law or agreed to in writing, software
33974 * distributed under the License is distributed on an "AS IS" BASIS,
33975 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33976 * See the License for the specific language governing permissions and
33977 * limitations under the License.
33978 */
33979
33980var available = typeof WebSocket !== 'undefined';
33981var _websocketChannelModule = { channel: WebSocketChannel, available: available };
33982
33983function createWebSocket(scheme, parsedUrl) {
33984 var url = scheme + '://' + parsedUrl.hostAndPort;
33985
33986 try {
33987 return new WebSocket(url);
33988 } catch (error) {
33989 if (isIPv6AddressIssueOnWindows(error, parsedUrl)) {
33990
33991 // WebSocket in IE and Edge browsers on Windows do not support regular IPv6 address syntax because they contain ':'.
33992 // It's an invalid character for UNC (https://en.wikipedia.org/wiki/IPv6_address#Literal_IPv6_addresses_in_UNC_path_names)
33993 // and Windows requires IPv6 to be changes in the following way:
33994 // 1) replace all ':' with '-'
33995 // 2) replace '%' with 's' for link-local address
33996 // 3) append '.ipv6-literal.net' suffix
33997 // only then resulting string can be considered a valid IPv6 address. Yes, this is extremely weird!
33998 // For more details see:
33999 // https://social.msdn.microsoft.com/Forums/ie/en-US/06cca73b-63c2-4bf9-899b-b229c50449ff/whether-ie10-websocket-support-ipv6?forum=iewebdevelopment
34000 // https://www.itdojo.com/ipv6-addresses-and-unc-path-names-overcoming-illegal/
34001 // Creation of WebSocket with unconverted address results in SyntaxError without message or stacktrace.
34002 // That is why here we "catch" SyntaxError and rewrite IPv6 address if needed.
34003
34004 var windowsFriendlyUrl = asWindowsFriendlyIPv6Address(scheme, parsedUrl);
34005 return new WebSocket(windowsFriendlyUrl);
34006 } else {
34007 throw error;
34008 }
34009 }
34010}
34011
34012function isIPv6AddressIssueOnWindows(error, parsedUrl) {
34013 return error.name === 'SyntaxError' && isIPv6Address(parsedUrl);
34014}
34015
34016function isIPv6Address(parsedUrl) {
34017 var hostAndPort = parsedUrl.hostAndPort;
34018 return hostAndPort.charAt(0) === '[' && hostAndPort.indexOf(']') !== -1;
34019}
34020
34021function asWindowsFriendlyIPv6Address(scheme, parsedUrl) {
34022 // replace all ':' with '-'
34023 var hostWithoutColons = parsedUrl.host.replace(new RegExp(':', 'g'), '-');
34024
34025 // replace '%' with 's' for link-local IPv6 address like 'fe80::1%lo0'
34026 var hostWithoutPercent = hostWithoutColons.replace('%', 's');
34027
34028 // append magic '.ipv6-literal.net' suffix
34029 var ipv6Host = hostWithoutPercent + '.ipv6-literal.net';
34030
34031 return scheme + '://' + ipv6Host + ':' + parsedUrl.port;
34032}
34033
34034exports.default = _websocketChannelModule;
34035
34036},{"./../error":324,"./buf":329,"./util":363,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34}],333:[function(require,module,exports){
34037'use strict';
34038
34039Object.defineProperty(exports, "__esModule", {
34040 value: true
34041});
34042exports.Dechunker = exports.Chunker = undefined;
34043
34044var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
34045
34046var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
34047
34048var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
34049
34050var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
34051
34052var _createClass2 = require('babel-runtime/helpers/createClass');
34053
34054var _createClass3 = _interopRequireDefault(_createClass2);
34055
34056var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
34057
34058var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
34059
34060var _inherits2 = require('babel-runtime/helpers/inherits');
34061
34062var _inherits3 = _interopRequireDefault(_inherits2);
34063
34064var _buf = require('./buf');
34065
34066function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
34067
34068var _CHUNK_HEADER_SIZE = 2,
34069 _MESSAGE_BOUNDARY = 0x00,
34070 _DEFAULT_BUFFER_SIZE = 1400; // http://stackoverflow.com/questions/2613734/maximum-packet-size-for-a-tcp-connection
34071
34072/**
34073 * Looks like a writable buffer, chunks output transparently into a channel below.
34074 * @access private
34075 */
34076/**
34077 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
34078 *
34079 * This file is part of Neo4j.
34080 *
34081 * Licensed under the Apache License, Version 2.0 (the "License");
34082 * you may not use this file except in compliance with the License.
34083 * You may obtain a copy of the License at
34084 *
34085 * http://www.apache.org/licenses/LICENSE-2.0
34086 *
34087 * Unless required by applicable law or agreed to in writing, software
34088 * distributed under the License is distributed on an "AS IS" BASIS,
34089 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34090 * See the License for the specific language governing permissions and
34091 * limitations under the License.
34092 */
34093
34094var Chunker = function (_BaseBuffer) {
34095 (0, _inherits3.default)(Chunker, _BaseBuffer);
34096
34097 function Chunker(channel, bufferSize) {
34098 (0, _classCallCheck3.default)(this, Chunker);
34099
34100 var _this = (0, _possibleConstructorReturn3.default)(this, (Chunker.__proto__ || (0, _getPrototypeOf2.default)(Chunker)).call(this, 0));
34101
34102 _this._bufferSize = bufferSize || _DEFAULT_BUFFER_SIZE;
34103 _this._ch = channel;
34104 _this._buffer = (0, _buf.alloc)(_this._bufferSize);
34105 _this._currentChunkStart = 0;
34106 _this._chunkOpen = false;
34107 return _this;
34108 }
34109
34110 (0, _createClass3.default)(Chunker, [{
34111 key: 'putUInt8',
34112 value: function putUInt8(position, val) {
34113 this._ensure(1);
34114 this._buffer.writeUInt8(val);
34115 }
34116 }, {
34117 key: 'putInt8',
34118 value: function putInt8(position, val) {
34119 this._ensure(1);
34120 this._buffer.writeInt8(val);
34121 }
34122 }, {
34123 key: 'putFloat64',
34124 value: function putFloat64(position, val) {
34125 this._ensure(8);
34126 this._buffer.writeFloat64(val);
34127 }
34128 }, {
34129 key: 'putBytes',
34130 value: function putBytes(position, data) {
34131 // TODO: If data is larger than our chunk size or so, we're very likely better off just passing this buffer on
34132 // rather than doing the copy here TODO: *however* note that we need some way to find out when the data has been
34133 // written (and thus the buffer can be re-used) if we take that approach
34134 while (data.remaining() > 0) {
34135 // Ensure there is an open chunk, and that it has at least one byte of space left
34136 this._ensure(1);
34137 if (this._buffer.remaining() > data.remaining()) {
34138 this._buffer.writeBytes(data);
34139 } else {
34140 this._buffer.writeBytes(data.readSlice(this._buffer.remaining()));
34141 }
34142 }
34143 return this;
34144 }
34145 }, {
34146 key: 'flush',
34147 value: function flush() {
34148 if (this._buffer.position > 0) {
34149 this._closeChunkIfOpen();
34150
34151 // Local copy and clear the buffer field. This ensures that the buffer is not re-released if the flush call fails
34152 var out = this._buffer;
34153 this._buffer = null;
34154
34155 this._ch.write(out.getSlice(0, out.position));
34156
34157 // Alloc a new output buffer. We assume we're using NodeJS's buffer pooling under the hood here!
34158 this._buffer = (0, _buf.alloc)(this._bufferSize);
34159 this._chunkOpen = false;
34160 }
34161 return this;
34162 }
34163
34164 /**
34165 * Bolt messages are encoded in one or more chunks, and the boundary between two messages
34166 * is encoded as a 0-length chunk, `00 00`. This inserts such a message boundary, closing
34167 * any currently open chunk as needed
34168 */
34169
34170 }, {
34171 key: 'messageBoundary',
34172 value: function messageBoundary() {
34173
34174 this._closeChunkIfOpen();
34175
34176 if (this._buffer.remaining() < _CHUNK_HEADER_SIZE) {
34177 this.flush();
34178 }
34179
34180 // Write message boundary
34181 this._buffer.writeInt16(_MESSAGE_BOUNDARY);
34182 }
34183
34184 /** Ensure at least the given size is available for writing */
34185
34186 }, {
34187 key: '_ensure',
34188 value: function _ensure(size) {
34189 var toWriteSize = this._chunkOpen ? size : size + _CHUNK_HEADER_SIZE;
34190 if (this._buffer.remaining() < toWriteSize) {
34191 this.flush();
34192 }
34193
34194 if (!this._chunkOpen) {
34195 this._currentChunkStart = this._buffer.position;
34196 this._buffer.position = this._buffer.position + _CHUNK_HEADER_SIZE;
34197 this._chunkOpen = true;
34198 }
34199 }
34200 }, {
34201 key: '_closeChunkIfOpen',
34202 value: function _closeChunkIfOpen() {
34203 if (this._chunkOpen) {
34204 var chunkSize = this._buffer.position - (this._currentChunkStart + _CHUNK_HEADER_SIZE);
34205 this._buffer.putUInt16(this._currentChunkStart, chunkSize);
34206 this._chunkOpen = false;
34207 }
34208 }
34209 }]);
34210 return Chunker;
34211}(_buf.BaseBuffer);
34212
34213/**
34214 * Combines chunks until a complete message is gathered up, and then forwards that
34215 * message to an 'onmessage' listener.
34216 * @access private
34217 */
34218
34219
34220var Dechunker = function () {
34221 function Dechunker() {
34222 (0, _classCallCheck3.default)(this, Dechunker);
34223
34224 this._currentMessage = [];
34225 this._partialChunkHeader = 0;
34226 this._state = this.AWAITING_CHUNK;
34227 }
34228
34229 (0, _createClass3.default)(Dechunker, [{
34230 key: 'AWAITING_CHUNK',
34231 value: function AWAITING_CHUNK(buf) {
34232 if (buf.remaining() >= 2) {
34233 // Whole header available, read that
34234 return this._onHeader(buf.readUInt16());
34235 } else {
34236 // Only one byte available, read that and wait for the second byte
34237 this._partialChunkHeader = buf.readUInt8() << 8;
34238 return this.IN_HEADER;
34239 }
34240 }
34241 }, {
34242 key: 'IN_HEADER',
34243 value: function IN_HEADER(buf) {
34244 // First header byte read, now we read the next one
34245 return this._onHeader((this._partialChunkHeader | buf.readUInt8()) & 0xFFFF);
34246 }
34247 }, {
34248 key: 'IN_CHUNK',
34249 value: function IN_CHUNK(buf) {
34250 if (this._chunkSize <= buf.remaining()) {
34251 // Current packet is larger than current chunk, or same size:
34252 this._currentMessage.push(buf.readSlice(this._chunkSize));
34253 return this.AWAITING_CHUNK;
34254 } else {
34255 // Current packet is smaller than the chunk we're reading, split the current chunk itself up
34256 this._chunkSize -= buf.remaining();
34257 this._currentMessage.push(buf.readSlice(buf.remaining()));
34258 return this.IN_CHUNK;
34259 }
34260 }
34261 }, {
34262 key: 'CLOSED',
34263 value: function CLOSED(buf) {}
34264 // no-op
34265
34266
34267 /** Called when a complete chunk header has been received */
34268
34269 }, {
34270 key: '_onHeader',
34271 value: function _onHeader(header) {
34272 if (header == 0) {
34273 // Message boundary
34274 var message = void 0;
34275 if (this._currentMessage.length == 1) {
34276 message = this._currentMessage[0];
34277 } else {
34278 message = new _buf.CombinedBuffer(this._currentMessage);
34279 }
34280 this._currentMessage = [];
34281 this.onmessage(message);
34282 return this.AWAITING_CHUNK;
34283 } else {
34284 this._chunkSize = header;
34285 return this.IN_CHUNK;
34286 }
34287 }
34288 }, {
34289 key: 'write',
34290 value: function write(buf) {
34291 while (buf.hasRemaining()) {
34292 this._state = this._state(buf);
34293 }
34294 }
34295 }]);
34296 return Dechunker;
34297}();
34298
34299exports.Chunker = Chunker;
34300exports.Dechunker = Dechunker;
34301
34302},{"./buf":329,"babel-runtime/core-js/object/get-prototype-of":26,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34,"babel-runtime/helpers/inherits":37,"babel-runtime/helpers/possibleConstructorReturn":38}],334:[function(require,module,exports){
34303'use strict';
34304
34305Object.defineProperty(exports, "__esModule", {
34306 value: true
34307});
34308exports.EMPTY_CONNECTION_HOLDER = undefined;
34309
34310var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
34311
34312var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
34313
34314var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
34315
34316var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
34317
34318var _inherits2 = require('babel-runtime/helpers/inherits');
34319
34320var _inherits3 = _interopRequireDefault(_inherits2);
34321
34322var _promise = require('babel-runtime/core-js/promise');
34323
34324var _promise2 = _interopRequireDefault(_promise);
34325
34326var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
34327
34328var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
34329
34330var _createClass2 = require('babel-runtime/helpers/createClass');
34331
34332var _createClass3 = _interopRequireDefault(_createClass2);
34333
34334var _error = require('../error');
34335
34336function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
34337
34338/**
34339 * Utility to lazily initialize connections and return them back to the pool when unused.
34340 */
34341var ConnectionHolder = function () {
34342
34343 /**
34344 * @constructor
34345 * @param {string} mode - the access mode for new connection holder.
34346 * @param {ConnectionProvider} connectionProvider - the connection provider to acquire connections from.
34347 */
34348 function ConnectionHolder(mode, connectionProvider) {
34349 (0, _classCallCheck3.default)(this, ConnectionHolder);
34350
34351 this._mode = mode;
34352 this._connectionProvider = connectionProvider;
34353 this._referenceCount = 0;
34354 this._connectionPromise = _promise2.default.resolve(null);
34355 }
34356
34357 /**
34358 * Make this holder initialize new connection if none exists already.
34359 * @return {undefined}
34360 */
34361
34362
34363 (0, _createClass3.default)(ConnectionHolder, [{
34364 key: 'initializeConnection',
34365 value: function initializeConnection() {
34366 if (this._referenceCount === 0) {
34367 this._connectionPromise = this._connectionProvider.acquireConnection(this._mode);
34368 }
34369 this._referenceCount++;
34370 }
34371
34372 /**
34373 * Get the current connection promise.
34374 * @param {StreamObserver} streamObserver an observer for this connection.
34375 * @return {Promise<Connection>} promise resolved with the current connection.
34376 */
34377
34378 }, {
34379 key: 'getConnection',
34380 value: function getConnection(streamObserver) {
34381 return this._connectionPromise.then(function (connection) {
34382 streamObserver.resolveConnection(connection);
34383 return connection.initializationCompleted();
34384 });
34385 }
34386
34387 /**
34388 * Notify this holder that single party does not require current connection any more.
34389 * @return {Promise<Connection>} promise resolved with the current connection, never a rejected promise.
34390 */
34391
34392 }, {
34393 key: 'releaseConnection',
34394 value: function releaseConnection() {
34395 if (this._referenceCount === 0) {
34396 return this._connectionPromise;
34397 }
34398
34399 this._referenceCount--;
34400 if (this._referenceCount === 0) {
34401 // release a connection without muting ACK_FAILURE, this is the last action on this connection
34402 return this._releaseConnection(true);
34403 }
34404 return this._connectionPromise;
34405 }
34406
34407 /**
34408 * Closes this holder and releases current connection (if any) despite any existing users.
34409 * @return {Promise<Connection>} promise resolved when current connection is released to the pool.
34410 */
34411
34412 }, {
34413 key: 'close',
34414 value: function close() {
34415 if (this._referenceCount === 0) {
34416 return this._connectionPromise;
34417 }
34418 this._referenceCount = 0;
34419 // release a connection and mute ACK_FAILURE, this might be called concurrently with other
34420 // operations and thus should ignore failure handling
34421 return this._releaseConnection(false);
34422 }
34423
34424 /**
34425 * Return the current pooled connection instance to the connection pool.
34426 * We don't pool Session instances, to avoid users using the Session after they've called close.
34427 * The `Session` object is just a thin wrapper around Connection anyway, so it makes little difference.
34428 * @return {Promise} - promise resolved then connection is returned to the pool.
34429 * @private
34430 */
34431
34432 }, {
34433 key: '_releaseConnection',
34434 value: function _releaseConnection(sync) {
34435 this._connectionPromise = this._connectionPromise.then(function (connection) {
34436 if (connection) {
34437 if (sync) {
34438 connection.reset();
34439 } else {
34440 connection.resetAsync();
34441 }
34442 connection.sync();
34443 connection._release();
34444 }
34445 }).catch(function (ignoredError) {});
34446
34447 return this._connectionPromise;
34448 }
34449 }]);
34450 return ConnectionHolder;
34451}(); /**
34452 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
34453 *
34454 * This file is part of Neo4j.
34455 *
34456 * Licensed under the Apache License, Version 2.0 (the "License");
34457 * you may not use this file except in compliance with the License.
34458 * You may obtain a copy of the License at
34459 *
34460 * http://www.apache.org/licenses/LICENSE-2.0
34461 *
34462 * Unless required by applicable law or agreed to in writing, software
34463 * distributed under the License is distributed on an "AS IS" BASIS,
34464 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34465 * See the License for the specific language governing permissions and
34466 * limitations under the License.
34467 */
34468
34469exports.default = ConnectionHolder;
34470
34471var EmptyConnectionHolder = function (_ConnectionHolder) {
34472 (0, _inherits3.default)(EmptyConnectionHolder, _ConnectionHolder);
34473
34474 function EmptyConnectionHolder() {
34475 (0, _classCallCheck3.default)(this, EmptyConnectionHolder);
34476 return (0, _possibleConstructorReturn3.default)(this, (EmptyConnectionHolder.__proto__ || (0, _getPrototypeOf2.default)(EmptyConnectionHolder)).apply(this, arguments));
34477 }
34478
34479 (0, _createClass3.default)(EmptyConnectionHolder, [{
34480 key: 'initializeConnection',
34481 value: function initializeConnection() {
34482 // nothing to initialize
34483 }
34484 }, {
34485 key: 'getConnection',
34486 value: function getConnection(streamObserver) {
34487 return _promise2.default.reject((0, _error.newError)('This connection holder does not serve connections'));
34488 }
34489 }, {
34490 key: 'releaseConnection',
34491 value: function releaseConnection() {
34492 return _promise2.default.resolve();
34493 }
34494 }, {
34495 key: 'close',
34496 value: function close() {
34497 return _promise2.default.resolve();
34498 }
34499 }]);
34500 return EmptyConnectionHolder;
34501}(ConnectionHolder);
34502
34503/**
34504 * Connection holder that does not manage any connections.
34505 * @type {ConnectionHolder}
34506 */
34507
34508
34509var EMPTY_CONNECTION_HOLDER = exports.EMPTY_CONNECTION_HOLDER = new EmptyConnectionHolder();
34510
34511},{"../error":324,"babel-runtime/core-js/object/get-prototype-of":26,"babel-runtime/core-js/promise":29,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34,"babel-runtime/helpers/inherits":37,"babel-runtime/helpers/possibleConstructorReturn":38}],335:[function(require,module,exports){
34512'use strict';
34513
34514Object.defineProperty(exports, "__esModule", {
34515 value: true
34516});
34517exports.SingleConnectionProvider = exports.LoadBalancer = exports.DirectConnectionProvider = undefined;
34518
34519var _promise = require('babel-runtime/core-js/promise');
34520
34521var _promise2 = _interopRequireDefault(_promise);
34522
34523var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
34524
34525var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
34526
34527var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
34528
34529var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
34530
34531var _inherits2 = require('babel-runtime/helpers/inherits');
34532
34533var _inherits3 = _interopRequireDefault(_inherits2);
34534
34535var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
34536
34537var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
34538
34539var _createClass2 = require('babel-runtime/helpers/createClass');
34540
34541var _createClass3 = _interopRequireDefault(_createClass2);
34542
34543var _error = require('../error');
34544
34545var _driver = require('../driver');
34546
34547var _session = require('../session');
34548
34549var _session2 = _interopRequireDefault(_session);
34550
34551var _routingTable = require('./routing-table');
34552
34553var _routingTable2 = _interopRequireDefault(_routingTable);
34554
34555var _rediscovery = require('./rediscovery');
34556
34557var _rediscovery2 = _interopRequireDefault(_rediscovery);
34558
34559var _features = require('./features');
34560
34561var _features2 = _interopRequireDefault(_features);
34562
34563var _hostNameResolvers = require('./host-name-resolvers');
34564
34565var _routingUtil = require('./routing-util');
34566
34567var _routingUtil2 = _interopRequireDefault(_routingUtil);
34568
34569function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
34570
34571/**
34572 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
34573 *
34574 * This file is part of Neo4j.
34575 *
34576 * Licensed under the Apache License, Version 2.0 (the "License");
34577 * you may not use this file except in compliance with the License.
34578 * You may obtain a copy of the License at
34579 *
34580 * http://www.apache.org/licenses/LICENSE-2.0
34581 *
34582 * Unless required by applicable law or agreed to in writing, software
34583 * distributed under the License is distributed on an "AS IS" BASIS,
34584 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34585 * See the License for the specific language governing permissions and
34586 * limitations under the License.
34587 */
34588
34589var ConnectionProvider = function () {
34590 function ConnectionProvider() {
34591 (0, _classCallCheck3.default)(this, ConnectionProvider);
34592 }
34593
34594 (0, _createClass3.default)(ConnectionProvider, [{
34595 key: 'acquireConnection',
34596 value: function acquireConnection(mode) {
34597 throw new Error('Abstract function');
34598 }
34599 }, {
34600 key: '_withAdditionalOnErrorCallback',
34601 value: function _withAdditionalOnErrorCallback(connectionPromise, driverOnErrorCallback) {
34602 // install error handler from the driver on the connection promise; this callback is installed separately
34603 // so that it does not handle errors, instead it is just an additional error reporting facility.
34604 connectionPromise.catch(function (error) {
34605 driverOnErrorCallback(error);
34606 });
34607 // return the original connection promise
34608 return connectionPromise;
34609 }
34610 }]);
34611 return ConnectionProvider;
34612}();
34613
34614var DirectConnectionProvider = exports.DirectConnectionProvider = function (_ConnectionProvider) {
34615 (0, _inherits3.default)(DirectConnectionProvider, _ConnectionProvider);
34616
34617 function DirectConnectionProvider(hostPort, connectionPool, driverOnErrorCallback) {
34618 (0, _classCallCheck3.default)(this, DirectConnectionProvider);
34619
34620 var _this = (0, _possibleConstructorReturn3.default)(this, (DirectConnectionProvider.__proto__ || (0, _getPrototypeOf2.default)(DirectConnectionProvider)).call(this));
34621
34622 _this._hostPort = hostPort;
34623 _this._connectionPool = connectionPool;
34624 _this._driverOnErrorCallback = driverOnErrorCallback;
34625 return _this;
34626 }
34627
34628 (0, _createClass3.default)(DirectConnectionProvider, [{
34629 key: 'acquireConnection',
34630 value: function acquireConnection(mode) {
34631 var connectionPromise = this._connectionPool.acquire(this._hostPort);
34632 return this._withAdditionalOnErrorCallback(connectionPromise, this._driverOnErrorCallback);
34633 }
34634 }]);
34635 return DirectConnectionProvider;
34636}(ConnectionProvider);
34637
34638var LoadBalancer = exports.LoadBalancer = function (_ConnectionProvider2) {
34639 (0, _inherits3.default)(LoadBalancer, _ConnectionProvider2);
34640
34641 function LoadBalancer(hostPort, routingContext, connectionPool, loadBalancingStrategy, driverOnErrorCallback) {
34642 (0, _classCallCheck3.default)(this, LoadBalancer);
34643
34644 var _this2 = (0, _possibleConstructorReturn3.default)(this, (LoadBalancer.__proto__ || (0, _getPrototypeOf2.default)(LoadBalancer)).call(this));
34645
34646 _this2._seedRouter = hostPort;
34647 _this2._routingTable = new _routingTable2.default([_this2._seedRouter]);
34648 _this2._rediscovery = new _rediscovery2.default(new _routingUtil2.default(routingContext));
34649 _this2._connectionPool = connectionPool;
34650 _this2._driverOnErrorCallback = driverOnErrorCallback;
34651 _this2._hostNameResolver = LoadBalancer._createHostNameResolver();
34652 _this2._loadBalancingStrategy = loadBalancingStrategy;
34653 _this2._useSeedRouter = false;
34654 return _this2;
34655 }
34656
34657 (0, _createClass3.default)(LoadBalancer, [{
34658 key: 'acquireConnection',
34659 value: function acquireConnection(accessMode) {
34660 var _this3 = this;
34661
34662 var connectionPromise = this._freshRoutingTable(accessMode).then(function (routingTable) {
34663 if (accessMode === _driver.READ) {
34664 var address = _this3._loadBalancingStrategy.selectReader(routingTable.readers);
34665 return _this3._acquireConnectionToServer(address, 'read');
34666 } else if (accessMode === _driver.WRITE) {
34667 var _address = _this3._loadBalancingStrategy.selectWriter(routingTable.writers);
34668 return _this3._acquireConnectionToServer(_address, 'write');
34669 } else {
34670 throw (0, _error.newError)('Illegal mode ' + accessMode);
34671 }
34672 });
34673 return this._withAdditionalOnErrorCallback(connectionPromise, this._driverOnErrorCallback);
34674 }
34675 }, {
34676 key: 'forget',
34677 value: function forget(address) {
34678 this._routingTable.forget(address);
34679 this._connectionPool.purge(address);
34680 }
34681 }, {
34682 key: 'forgetWriter',
34683 value: function forgetWriter(address) {
34684 this._routingTable.forgetWriter(address);
34685 }
34686 }, {
34687 key: '_acquireConnectionToServer',
34688 value: function _acquireConnectionToServer(address, serverName) {
34689 if (!address) {
34690 return _promise2.default.reject((0, _error.newError)('Failed to obtain connection towards ' + serverName + ' server. Known routing table is: ' + this._routingTable, _error.SESSION_EXPIRED));
34691 }
34692 return this._connectionPool.acquire(address);
34693 }
34694 }, {
34695 key: '_freshRoutingTable',
34696 value: function _freshRoutingTable(accessMode) {
34697 var currentRoutingTable = this._routingTable;
34698
34699 if (!currentRoutingTable.isStaleFor(accessMode)) {
34700 return _promise2.default.resolve(currentRoutingTable);
34701 }
34702 return this._refreshRoutingTable(currentRoutingTable);
34703 }
34704 }, {
34705 key: '_refreshRoutingTable',
34706 value: function _refreshRoutingTable(currentRoutingTable) {
34707 var knownRouters = currentRoutingTable.routers;
34708
34709 if (this._useSeedRouter) {
34710 return this._fetchRoutingTableFromSeedRouterFallbackToKnownRouters(knownRouters, currentRoutingTable);
34711 }
34712 return this._fetchRoutingTableFromKnownRoutersFallbackToSeedRouter(knownRouters, currentRoutingTable);
34713 }
34714 }, {
34715 key: '_fetchRoutingTableFromSeedRouterFallbackToKnownRouters',
34716 value: function _fetchRoutingTableFromSeedRouterFallbackToKnownRouters(knownRouters, currentRoutingTable) {
34717 var _this4 = this;
34718
34719 // we start with seed router, no routers were probed before
34720 var seenRouters = [];
34721 return this._fetchRoutingTableUsingSeedRouter(seenRouters, this._seedRouter).then(function (newRoutingTable) {
34722 if (newRoutingTable) {
34723 _this4._useSeedRouter = false;
34724 return newRoutingTable;
34725 }
34726
34727 // seed router did not return a valid routing table - try to use other known routers
34728 return _this4._fetchRoutingTableUsingKnownRouters(knownRouters, currentRoutingTable);
34729 }).then(function (newRoutingTable) {
34730 _this4._applyRoutingTableIfPossible(newRoutingTable);
34731 return newRoutingTable;
34732 });
34733 }
34734 }, {
34735 key: '_fetchRoutingTableFromKnownRoutersFallbackToSeedRouter',
34736 value: function _fetchRoutingTableFromKnownRoutersFallbackToSeedRouter(knownRouters, currentRoutingTable) {
34737 var _this5 = this;
34738
34739 return this._fetchRoutingTableUsingKnownRouters(knownRouters, currentRoutingTable).then(function (newRoutingTable) {
34740 if (newRoutingTable) {
34741 return newRoutingTable;
34742 }
34743
34744 // none of the known routers returned a valid routing table - try to use seed router address for rediscovery
34745 return _this5._fetchRoutingTableUsingSeedRouter(knownRouters, _this5._seedRouter);
34746 }).then(function (newRoutingTable) {
34747 _this5._applyRoutingTableIfPossible(newRoutingTable);
34748 return newRoutingTable;
34749 });
34750 }
34751 }, {
34752 key: '_fetchRoutingTableUsingKnownRouters',
34753 value: function _fetchRoutingTableUsingKnownRouters(knownRouters, currentRoutingTable) {
34754 return this._fetchRoutingTable(knownRouters, currentRoutingTable).then(function (newRoutingTable) {
34755 if (newRoutingTable) {
34756 // one of the known routers returned a valid routing table - use it
34757 return newRoutingTable;
34758 }
34759
34760 // returned routing table was undefined, this means a connection error happened and the last known
34761 // router did not return a valid routing table, so we need to forget it
34762 var lastRouterIndex = knownRouters.length - 1;
34763 LoadBalancer._forgetRouter(currentRoutingTable, knownRouters, lastRouterIndex);
34764
34765 return null;
34766 });
34767 }
34768 }, {
34769 key: '_fetchRoutingTableUsingSeedRouter',
34770 value: function _fetchRoutingTableUsingSeedRouter(seenRouters, seedRouter) {
34771 var _this6 = this;
34772
34773 return this._hostNameResolver.resolve(seedRouter).then(function (resolvedRouterAddresses) {
34774 // filter out all addresses that we've already tried
34775 var newAddresses = resolvedRouterAddresses.filter(function (address) {
34776 return seenRouters.indexOf(address) < 0;
34777 });
34778 return _this6._fetchRoutingTable(newAddresses, null);
34779 });
34780 }
34781 }, {
34782 key: '_fetchRoutingTable',
34783 value: function _fetchRoutingTable(routerAddresses, routingTable) {
34784 var _this7 = this;
34785
34786 return routerAddresses.reduce(function (refreshedTablePromise, currentRouter, currentIndex) {
34787 return refreshedTablePromise.then(function (newRoutingTable) {
34788 if (newRoutingTable) {
34789 // valid routing table was fetched - just return it, try next router otherwise
34790 return newRoutingTable;
34791 } else {
34792 // returned routing table was undefined, this means a connection error happened and we need to forget the
34793 // previous router and try the next one
34794 var previousRouterIndex = currentIndex - 1;
34795 LoadBalancer._forgetRouter(routingTable, routerAddresses, previousRouterIndex);
34796 }
34797
34798 // try next router
34799 return _this7._createSessionForRediscovery(currentRouter).then(function (session) {
34800 return _this7._rediscovery.lookupRoutingTableOnRouter(session, currentRouter);
34801 });
34802 });
34803 }, _promise2.default.resolve(null));
34804 }
34805 }, {
34806 key: '_createSessionForRediscovery',
34807 value: function _createSessionForRediscovery(routerAddress) {
34808 return this._connectionPool.acquire(routerAddress).then(function (connection) {
34809 // initialized connection is required for routing procedure call
34810 // server version needs to be known to decide which routing procedure to use
34811 var initializedConnectionPromise = connection.initializationCompleted();
34812 var connectionProvider = new SingleConnectionProvider(initializedConnectionPromise);
34813 return new _session2.default(_driver.READ, connectionProvider);
34814 });
34815 }
34816 }, {
34817 key: '_applyRoutingTableIfPossible',
34818 value: function _applyRoutingTableIfPossible(newRoutingTable) {
34819 if (!newRoutingTable) {
34820 // none of routing servers returned valid routing table, throw exception
34821 throw (0, _error.newError)('Could not perform discovery. No routing servers available. Known routing table: ' + this._routingTable, _error.SERVICE_UNAVAILABLE);
34822 }
34823
34824 if (newRoutingTable.writers.length === 0) {
34825 // use seed router next time. this is important when cluster is partitioned. it tries to make sure driver
34826 // does not always get routing table without writers because it talks exclusively to a minority partition
34827 this._useSeedRouter = true;
34828 }
34829
34830 this._updateRoutingTable(newRoutingTable);
34831 }
34832 }, {
34833 key: '_updateRoutingTable',
34834 value: function _updateRoutingTable(newRoutingTable) {
34835 var _this8 = this;
34836
34837 var currentRoutingTable = this._routingTable;
34838
34839 // close old connections to servers not present in the new routing table
34840 var staleServers = currentRoutingTable.serversDiff(newRoutingTable);
34841 staleServers.forEach(function (server) {
34842 return _this8._connectionPool.purge(server);
34843 });
34844
34845 // make this driver instance aware of the new table
34846 this._routingTable = newRoutingTable;
34847 }
34848 }], [{
34849 key: '_forgetRouter',
34850 value: function _forgetRouter(routingTable, routersArray, routerIndex) {
34851 var address = routersArray[routerIndex];
34852 if (routingTable && address) {
34853 routingTable.forgetRouter(address);
34854 }
34855 }
34856 }, {
34857 key: '_createHostNameResolver',
34858 value: function _createHostNameResolver() {
34859 if ((0, _features2.default)('dns_lookup')) {
34860 return new _hostNameResolvers.DnsHostNameResolver();
34861 }
34862 return new _hostNameResolvers.DummyHostNameResolver();
34863 }
34864 }]);
34865 return LoadBalancer;
34866}(ConnectionProvider);
34867
34868var SingleConnectionProvider = exports.SingleConnectionProvider = function (_ConnectionProvider3) {
34869 (0, _inherits3.default)(SingleConnectionProvider, _ConnectionProvider3);
34870
34871 function SingleConnectionProvider(connectionPromise) {
34872 (0, _classCallCheck3.default)(this, SingleConnectionProvider);
34873
34874 var _this9 = (0, _possibleConstructorReturn3.default)(this, (SingleConnectionProvider.__proto__ || (0, _getPrototypeOf2.default)(SingleConnectionProvider)).call(this));
34875
34876 _this9._connectionPromise = connectionPromise;
34877 return _this9;
34878 }
34879
34880 (0, _createClass3.default)(SingleConnectionProvider, [{
34881 key: 'acquireConnection',
34882 value: function acquireConnection(mode) {
34883 var connectionPromise = this._connectionPromise;
34884 this._connectionPromise = null;
34885 return connectionPromise;
34886 }
34887 }]);
34888 return SingleConnectionProvider;
34889}(ConnectionProvider);
34890
34891},{"../driver":323,"../error":324,"../session":368,"./features":338,"./host-name-resolvers":339,"./rediscovery":352,"./routing-table":355,"./routing-util":356,"babel-runtime/core-js/object/get-prototype-of":26,"babel-runtime/core-js/promise":29,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34,"babel-runtime/helpers/inherits":37,"babel-runtime/helpers/possibleConstructorReturn":38}],336:[function(require,module,exports){
34892'use strict';
34893
34894Object.defineProperty(exports, "__esModule", {
34895 value: true
34896});
34897
34898var _promise = require('babel-runtime/core-js/promise');
34899
34900var _promise2 = _interopRequireDefault(_promise);
34901
34902var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
34903
34904var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
34905
34906var _createClass2 = require('babel-runtime/helpers/createClass');
34907
34908var _createClass3 = _interopRequireDefault(_createClass2);
34909
34910var _connectionHolder = require('./connection-holder');
34911
34912var _connectionHolder2 = _interopRequireDefault(_connectionHolder);
34913
34914var _driver = require('../driver');
34915
34916var _streamObserver = require('./stream-observer');
34917
34918var _streamObserver2 = _interopRequireDefault(_streamObserver);
34919
34920function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
34921
34922/**
34923 * Verifies connectivity using the given connection provider.
34924 */
34925var ConnectivityVerifier = function () {
34926
34927 /**
34928 * @constructor
34929 * @param {ConnectionProvider} connectionProvider the provider to obtain connections from.
34930 * @param {function} successCallback a callback to invoke when verification succeeds.
34931 */
34932 function ConnectivityVerifier(connectionProvider, successCallback) {
34933 (0, _classCallCheck3.default)(this, ConnectivityVerifier);
34934
34935 this._connectionProvider = connectionProvider;
34936 this._successCallback = successCallback;
34937 }
34938
34939 (0, _createClass3.default)(ConnectivityVerifier, [{
34940 key: 'verify',
34941 value: function verify() {
34942 var _this = this;
34943
34944 acquireAndReleaseDummyConnection(this._connectionProvider).then(function (serverInfo) {
34945 if (_this._successCallback) {
34946 _this._successCallback(serverInfo);
34947 }
34948 }).catch(function (ignoredError) {});
34949 }
34950 }]);
34951 return ConnectivityVerifier;
34952}();
34953
34954/**
34955 * @private
34956 * @param {ConnectionProvider} connectionProvider the provider to obtain connections from.
34957 * @return {Promise<object>} promise resolved with server info or rejected with error.
34958 */
34959/**
34960 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
34961 *
34962 * This file is part of Neo4j.
34963 *
34964 * Licensed under the Apache License, Version 2.0 (the "License");
34965 * you may not use this file except in compliance with the License.
34966 * You may obtain a copy of the License at
34967 *
34968 * http://www.apache.org/licenses/LICENSE-2.0
34969 *
34970 * Unless required by applicable law or agreed to in writing, software
34971 * distributed under the License is distributed on an "AS IS" BASIS,
34972 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34973 * See the License for the specific language governing permissions and
34974 * limitations under the License.
34975 */
34976
34977exports.default = ConnectivityVerifier;
34978function acquireAndReleaseDummyConnection(connectionProvider) {
34979 var connectionHolder = new _connectionHolder2.default(_driver.READ, connectionProvider);
34980 connectionHolder.initializeConnection();
34981 var dummyObserver = new _streamObserver2.default();
34982 var connectionPromise = connectionHolder.getConnection(dummyObserver);
34983
34984 return connectionPromise.then(function (connection) {
34985 // able to establish a connection
34986 return connectionHolder.close().then(function () {
34987 return connection.server;
34988 });
34989 }).catch(function (error) {
34990 // failed to establish a connection
34991 return connectionHolder.close().catch(function (ignoredError) {
34992 // ignore connection release error
34993 }).then(function () {
34994 return _promise2.default.reject(error);
34995 });
34996 });
34997}
34998
34999},{"../driver":323,"./connection-holder":334,"./stream-observer":358,"babel-runtime/core-js/promise":29,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34}],337:[function(require,module,exports){
35000'use strict';
35001
35002Object.defineProperty(exports, "__esModule", {
35003 value: true
35004});
35005exports.Connection = exports.connect = undefined;
35006
35007var _promise = require('babel-runtime/core-js/promise');
35008
35009var _promise2 = _interopRequireDefault(_promise);
35010
35011var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
35012
35013var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
35014
35015var _createClass2 = require('babel-runtime/helpers/createClass');
35016
35017var _createClass3 = _interopRequireDefault(_createClass2);
35018
35019var _stringify = require('babel-runtime/core-js/json/stringify');
35020
35021var _stringify2 = _interopRequireDefault(_stringify);
35022
35023var _chWebsocket = require('./ch-websocket');
35024
35025var _chWebsocket2 = _interopRequireDefault(_chWebsocket);
35026
35027var _chNode = require('./ch-node');
35028
35029var _chNode2 = _interopRequireDefault(_chNode);
35030
35031var _chunking = require('./chunking');
35032
35033var _packstreamUtil = require('./packstream-util');
35034
35035var _packstreamUtil2 = _interopRequireDefault(_packstreamUtil);
35036
35037var _buf = require('./buf');
35038
35039var _error = require('./../error');
35040
35041var _chConfig = require('./ch-config');
35042
35043var _chConfig2 = _interopRequireDefault(_chConfig);
35044
35045var _urlUtil = require('./url-util');
35046
35047var _urlUtil2 = _interopRequireDefault(_urlUtil);
35048
35049var _streamObserver = require('./stream-observer');
35050
35051var _streamObserver2 = _interopRequireDefault(_streamObserver);
35052
35053var _serverVersion = require('./server-version');
35054
35055function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
35056
35057/**
35058 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
35059 *
35060 * This file is part of Neo4j.
35061 *
35062 * Licensed under the Apache License, Version 2.0 (the "License");
35063 * you may not use this file except in compliance with the License.
35064 * You may obtain a copy of the License at
35065 *
35066 * http://www.apache.org/licenses/LICENSE-2.0
35067 *
35068 * Unless required by applicable law or agreed to in writing, software
35069 * distributed under the License is distributed on an "AS IS" BASIS,
35070 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35071 * See the License for the specific language governing permissions and
35072 * limitations under the License.
35073 */
35074
35075var Channel = void 0;
35076if (_chNode2.default.available) {
35077 Channel = _chNode2.default.channel;
35078} else if (_chWebsocket2.default.available) {
35079 Channel = _chWebsocket2.default.channel;
35080} else {
35081 throw (0, _error.newError)("Fatal: No compatible transport available. Need to run on a platform with the WebSocket API.");
35082}
35083
35084var
35085// Signature bytes for each message type
35086INIT = 0x01,
35087 // 0000 0001 // INIT <user_agent>
35088ACK_FAILURE = 0x0E,
35089 // 0000 1110 // ACK_FAILURE
35090RESET = 0x0F,
35091 // 0000 1111 // RESET
35092RUN = 0x10,
35093 // 0001 0000 // RUN <statement> <parameters>
35094DISCARD_ALL = 0x2F,
35095 // 0010 1111 // DISCARD *
35096PULL_ALL = 0x3F,
35097 // 0011 1111 // PULL *
35098SUCCESS = 0x70,
35099 // 0111 0000 // SUCCESS <metadata>
35100RECORD = 0x71,
35101 // 0111 0001 // RECORD <value>
35102IGNORED = 0x7E,
35103 // 0111 1110 // IGNORED <metadata>
35104FAILURE = 0x7F,
35105 // 0111 1111 // FAILURE <metadata>
35106
35107//sent before version negotiation
35108MAGIC_PREAMBLE = 0x6060B017,
35109 DEBUG = false;
35110
35111/**
35112 * Very rudimentary log handling, should probably be replaced by something proper at some point.
35113 * @param actor the part that sent the message, 'S' for server and 'C' for client
35114 * @param msg the bolt message
35115 */
35116function log(actor, msg) {
35117 if (DEBUG) {
35118 for (var i = 2; i < arguments.length; i++) {
35119 msg += " " + (0, _stringify2.default)(arguments[i]);
35120 }
35121 console.log(actor + ":" + msg);
35122 }
35123}
35124
35125function NO_OP() {}
35126
35127var NO_OP_OBSERVER = {
35128 onNext: NO_OP,
35129 onCompleted: NO_OP,
35130 onError: NO_OP
35131};
35132
35133/**
35134 * A connection manages sending and receiving messages over a channel. A
35135 * connector is very closely tied to the Bolt protocol, it implements the
35136 * same message structure with very little frills. This means Connectors are
35137 * naturally tied to a specific version of the protocol, and we expect
35138 * another layer will be needed to support multiple versions.
35139 *
35140 * The connector tries to batch outbound messages by requiring its users
35141 * to call 'sync' when messages need to be sent, and it routes response
35142 * messages back to the originators of the requests that created those
35143 * response messages.
35144 * @access private
35145 */
35146
35147var Connection = function () {
35148
35149 /**
35150 * @constructor
35151 * @param {NodeChannel|WebSocketChannel} channel - channel with a 'write' function and a 'onmessage' callback property.
35152 * @param {string} hostPort - the hostname and port to connect to.
35153 * @param {boolean} disableLosslessIntegers if this connection should convert all received integers to native JS numbers.
35154 */
35155 function Connection(channel, hostPort) {
35156 var _this = this;
35157
35158 var disableLosslessIntegers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
35159 (0, _classCallCheck3.default)(this, Connection);
35160
35161 /**
35162 * An ordered queue of observers, each exchange response (zero or more
35163 * RECORD messages followed by a SUCCESS message) we receive will be routed
35164 * to the next pending observer.
35165 */
35166 this.hostPort = hostPort;
35167 this.server = { address: hostPort };
35168 this.creationTimestamp = Date.now();
35169 this._disableLosslessIntegers = disableLosslessIntegers;
35170 this._pendingObservers = [];
35171 this._currentObserver = undefined;
35172 this._ch = channel;
35173 this._dechunker = new _chunking.Dechunker();
35174 this._chunker = new _chunking.Chunker(channel);
35175
35176 // initially assume that database supports latest Bolt version, create latest packer and unpacker
35177 this._packer = _packstreamUtil2.default.createLatestPacker(this._chunker);
35178 this._unpacker = _packstreamUtil2.default.createLatestUnpacker(disableLosslessIntegers);
35179
35180 this._isHandlingFailure = false;
35181 this._currentFailure = null;
35182
35183 this._state = new ConnectionState(this);
35184
35185 // Set to true on fatal errors, to get this out of session pool.
35186 this._isBroken = false;
35187
35188 // TODO: Using `onmessage` and `onerror` came from the WebSocket API,
35189 // it reads poorly and has several annoying drawbacks. Swap to having
35190 // Channel extend EventEmitter instead, then we can use `on('data',..)`
35191 this._ch.onmessage = function (buf) {
35192 var proposed = buf.readInt32();
35193 if (proposed == 1 || proposed == 2) {
35194 _this._initializeProtocol(proposed, buf);
35195 } else if (proposed == 1213486160) {
35196 //server responded 1213486160 == 0x48545450 == "HTTP"
35197 _this._handleFatalError((0, _error.newError)('Server responded HTTP. Make sure you are not trying to connect to the http endpoint ' + '(HTTP defaults to port 7474 whereas BOLT defaults to port 7687)'));
35198 } else {
35199 _this._handleFatalError((0, _error.newError)('Unknown Bolt protocol version: ' + proposed));
35200 }
35201 };
35202
35203 // Listen to connection errors. Important note though;
35204 // In some cases we will get a channel that is already broken (for instance,
35205 // if the user passes invalid configuration options). In this case, onerror
35206 // will have "already triggered" before we add out listener here. So the line
35207 // below also checks that the channel is not already failed. This could be nicely
35208 // encapsulated into Channel if we used `on('error', ..)` rather than `onerror=..`
35209 // as outlined in the comment about `onmessage` further up in this file.
35210 this._ch.onerror = this._handleFatalError.bind(this);
35211 if (this._ch._error) {
35212 this._handleFatalError(this._ch._error);
35213 }
35214
35215 this._dechunker.onmessage = function (buf) {
35216 _this._handleMessage(_this._unpacker.unpack(buf));
35217 };
35218
35219 var handshake = (0, _buf.alloc)(5 * 4);
35220 //magic preamble
35221 handshake.writeInt32(MAGIC_PREAMBLE);
35222 //proposed versions
35223 handshake.writeInt32(2);
35224 handshake.writeInt32(1);
35225 handshake.writeInt32(0);
35226 handshake.writeInt32(0);
35227 handshake.reset();
35228 this._ch.write(handshake);
35229 }
35230
35231 /**
35232 * Complete protocol initialization.
35233 * @param {number} version the selected protocol version.
35234 * @param {BaseBuffer} buffer the handshake response buffer.
35235 * @private
35236 */
35237
35238
35239 (0, _createClass3.default)(Connection, [{
35240 key: '_initializeProtocol',
35241 value: function _initializeProtocol(version, buffer) {
35242 var _this2 = this;
35243
35244 // re-create packer and unpacker because version might be lower than we initially assumed
35245 this._packer = _packstreamUtil2.default.createPackerForProtocolVersion(version, this._chunker);
35246 this._unpacker = _packstreamUtil2.default.createUnpackerForProtocolVersion(version, this._disableLosslessIntegers);
35247
35248 // Ok, protocol running. Simply forward all messages to the dechunker
35249 this._ch.onmessage = function (buf) {
35250 return _this2._dechunker.write(buf);
35251 };
35252
35253 if (buffer.hasRemaining()) {
35254 this._dechunker.write(buffer.readSlice(buffer.remaining()));
35255 }
35256 }
35257
35258 /**
35259 * "Fatal" means the connection is dead. Only call this if something
35260 * happens that cannot be recovered from. This will lead to all subscribers
35261 * failing, and the connection getting ejected from the session pool.
35262 *
35263 * @param err an error object, forwarded to all current and future subscribers
35264 * @protected
35265 */
35266
35267 }, {
35268 key: '_handleFatalError',
35269 value: function _handleFatalError(err) {
35270 this._isBroken = true;
35271 this._error = err;
35272 if (this._currentObserver && this._currentObserver.onError) {
35273 this._currentObserver.onError(err);
35274 }
35275 while (this._pendingObservers.length > 0) {
35276 var observer = this._pendingObservers.shift();
35277 if (observer && observer.onError) {
35278 observer.onError(err);
35279 }
35280 }
35281 }
35282 }, {
35283 key: '_handleMessage',
35284 value: function _handleMessage(msg) {
35285 var _this3 = this;
35286
35287 if (this._isBroken) {
35288 // ignore all incoming messages when this connection is broken. all previously pending observers failed
35289 // with the fatal error. all future observers will fail with same fatal error.
35290 return;
35291 }
35292
35293 var payload = msg.fields[0];
35294
35295 switch (msg.signature) {
35296 case RECORD:
35297 log("S", "RECORD", msg);
35298 this._currentObserver.onNext(payload);
35299 break;
35300 case SUCCESS:
35301 log("S", "SUCCESS", msg);
35302 try {
35303 this._currentObserver.onCompleted(payload);
35304 } finally {
35305 this._updateCurrentObserver();
35306 }
35307 break;
35308 case FAILURE:
35309 log("S", "FAILURE", msg);
35310 try {
35311 this._currentFailure = (0, _error.newError)(payload.message, payload.code);
35312 this._currentObserver.onError(this._currentFailure);
35313 } finally {
35314 this._updateCurrentObserver();
35315 // Things are now broken. Pending observers will get FAILURE messages routed until
35316 // We are done handling this failure.
35317 if (!this._isHandlingFailure) {
35318 this._isHandlingFailure = true;
35319
35320 // isHandlingFailure was false, meaning this is the first failure message
35321 // we see from this failure. We may see several others, one for each message
35322 // we had "optimistically" already sent after whatever it was that failed.
35323 // We only want to and need to ACK the first one, which is why we are tracking
35324 // this _isHandlingFailure thing.
35325 this._ackFailure({
35326 onNext: NO_OP,
35327 onError: NO_OP,
35328 onCompleted: function onCompleted() {
35329 _this3._isHandlingFailure = false;
35330 _this3._currentFailure = null;
35331 }
35332 });
35333 }
35334 }
35335 break;
35336 case IGNORED:
35337 log("S", "IGNORED", msg);
35338 try {
35339 if (this._currentFailure && this._currentObserver.onError) this._currentObserver.onError(this._currentFailure);else if (this._currentObserver.onError) this._currentObserver.onError(payload);
35340 } finally {
35341 this._updateCurrentObserver();
35342 }
35343 break;
35344 default:
35345 this._handleFatalError((0, _error.newError)("Unknown Bolt protocol message: " + msg));
35346 }
35347 }
35348
35349 /** Queue an INIT-message to be sent to the database */
35350
35351 }, {
35352 key: 'initialize',
35353 value: function initialize(clientName, token, observer) {
35354 var _this4 = this;
35355
35356 log("C", "INIT", clientName, token);
35357 var initObserver = this._state.wrap(observer);
35358 this._queueObserver(initObserver);
35359 this._packer.packStruct(INIT, [this._packable(clientName), this._packable(token)], function (err) {
35360 return _this4._handleFatalError(err);
35361 });
35362 this._chunker.messageBoundary();
35363 this.sync();
35364 }
35365
35366 /** Queue a RUN-message to be sent to the database */
35367
35368 }, {
35369 key: 'run',
35370 value: function run(statement, params, observer) {
35371 var _this5 = this;
35372
35373 log("C", "RUN", statement, params);
35374 this._queueObserver(observer);
35375 this._packer.packStruct(RUN, [this._packable(statement), this._packable(params)], function (err) {
35376 return _this5._handleFatalError(err);
35377 });
35378 this._chunker.messageBoundary();
35379 }
35380
35381 /** Queue a PULL_ALL-message to be sent to the database */
35382
35383 }, {
35384 key: 'pullAll',
35385 value: function pullAll(observer) {
35386 var _this6 = this;
35387
35388 log("C", "PULL_ALL");
35389 this._queueObserver(observer);
35390 this._packer.packStruct(PULL_ALL, [], function (err) {
35391 return _this6._handleFatalError(err);
35392 });
35393 this._chunker.messageBoundary();
35394 }
35395
35396 /** Queue a DISCARD_ALL-message to be sent to the database */
35397
35398 }, {
35399 key: 'discardAll',
35400 value: function discardAll(observer) {
35401 var _this7 = this;
35402
35403 log("C", "DISCARD_ALL");
35404 this._queueObserver(observer);
35405 this._packer.packStruct(DISCARD_ALL, [], function (err) {
35406 return _this7._handleFatalError(err);
35407 });
35408 this._chunker.messageBoundary();
35409 }
35410
35411 /** Queue a RESET-message to be sent to the database. Mutes failure handling. */
35412
35413 }, {
35414 key: 'resetAsync',
35415 value: function resetAsync(observer) {
35416 var _this8 = this;
35417
35418 log("C", "RESET_ASYNC");
35419 this._isHandlingFailure = true;
35420 var self = this;
35421 var wrappedObs = {
35422 onNext: observer ? observer.onNext : NO_OP,
35423 onError: observer ? observer.onError : NO_OP,
35424 onCompleted: function onCompleted() {
35425 self._isHandlingFailure = false;
35426 if (observer) {
35427 observer.onCompleted();
35428 }
35429 }
35430 };
35431 this._queueObserver(wrappedObs);
35432 this._packer.packStruct(RESET, [], function (err) {
35433 return _this8._handleFatalError(err);
35434 });
35435 this._chunker.messageBoundary();
35436 }
35437
35438 /** Queue a RESET-message to be sent to the database */
35439
35440 }, {
35441 key: 'reset',
35442 value: function reset(observer) {
35443 var _this9 = this;
35444
35445 log('C', 'RESET');
35446 this._queueObserver(observer);
35447 this._packer.packStruct(RESET, [], function (err) {
35448 return _this9._handleFatalError(err);
35449 });
35450 this._chunker.messageBoundary();
35451 }
35452
35453 /** Queue a ACK_FAILURE-message to be sent to the database */
35454
35455 }, {
35456 key: '_ackFailure',
35457 value: function _ackFailure(observer) {
35458 var _this10 = this;
35459
35460 log("C", "ACK_FAILURE");
35461 this._queueObserver(observer);
35462 this._packer.packStruct(ACK_FAILURE, [], function (err) {
35463 return _this10._handleFatalError(err);
35464 });
35465 this._chunker.messageBoundary();
35466 }
35467 }, {
35468 key: '_queueObserver',
35469 value: function _queueObserver(observer) {
35470 if (this._isBroken) {
35471 if (observer && observer.onError) {
35472 observer.onError(this._error);
35473 }
35474 return;
35475 }
35476 observer = observer || NO_OP_OBSERVER;
35477 observer.onCompleted = observer.onCompleted || NO_OP;
35478 observer.onError = observer.onError || NO_OP;
35479 observer.onNext = observer.onNext || NO_OP;
35480 if (this._currentObserver === undefined) {
35481 this._currentObserver = observer;
35482 } else {
35483 this._pendingObservers.push(observer);
35484 }
35485 }
35486
35487 /**
35488 * Get promise resolved when connection initialization succeed or rejected when it fails.
35489 * Connection is initialized using {@link initialize} function.
35490 * @return {Promise<Connection>} the result of connection initialization.
35491 */
35492
35493 }, {
35494 key: 'initializationCompleted',
35495 value: function initializationCompleted() {
35496 return this._state.initializationCompleted();
35497 }
35498
35499 /*
35500 * Pop next pending observer form the list of observers and make it current observer.
35501 * @protected
35502 */
35503
35504 }, {
35505 key: '_updateCurrentObserver',
35506 value: function _updateCurrentObserver() {
35507 this._currentObserver = this._pendingObservers.shift();
35508 }
35509
35510 /**
35511 * Synchronize - flush all queued outgoing messages and route their responses
35512 * to their respective handlers.
35513 */
35514
35515 }, {
35516 key: 'sync',
35517 value: function sync() {
35518 this._chunker.flush();
35519 }
35520
35521 /** Check if this connection is in working condition */
35522
35523 }, {
35524 key: 'isOpen',
35525 value: function isOpen() {
35526 return !this._isBroken && this._ch._open;
35527 }
35528 }, {
35529 key: 'isEncrypted',
35530 value: function isEncrypted() {
35531 return this._ch.isEncrypted();
35532 }
35533
35534 /**
35535 * Call close on the channel.
35536 * @param {function} cb - Function to call on close.
35537 */
35538
35539 }, {
35540 key: 'close',
35541 value: function close(cb) {
35542 this._ch.close(cb);
35543 }
35544 }, {
35545 key: '_packable',
35546 value: function _packable(value) {
35547 var _this11 = this;
35548
35549 return this._packer.packable(value, function (err) {
35550 return _this11._handleFatalError(err);
35551 });
35552 }
35553
35554 /**
35555 * @protected
35556 */
35557
35558 }, {
35559 key: '_markInitialized',
35560 value: function _markInitialized(metadata) {
35561 var serverVersion = metadata ? metadata.server : null;
35562 if (!this.server.version) {
35563 this.server.version = serverVersion;
35564 var version = _serverVersion.ServerVersion.fromString(serverVersion);
35565 if (version.compareTo(_serverVersion.VERSION_3_2_0) < 0) {
35566 this._packer.disableByteArrays();
35567 }
35568 }
35569 }
35570 }]);
35571 return Connection;
35572}();
35573
35574var ConnectionState = function () {
35575
35576 /**
35577 * @constructor
35578 * @param {Connection} connection the connection to track state for.
35579 */
35580 function ConnectionState(connection) {
35581 var _this12 = this;
35582
35583 (0, _classCallCheck3.default)(this, ConnectionState);
35584
35585 this._connection = connection;
35586
35587 this._initRequested = false;
35588 this._initError = null;
35589
35590 this._resolveInitPromise = null;
35591 this._rejectInitPromise = null;
35592 this._initPromise = new _promise2.default(function (resolve, reject) {
35593 _this12._resolveInitPromise = resolve;
35594 _this12._rejectInitPromise = reject;
35595 });
35596 }
35597
35598 /**
35599 * Wrap the given observer to track connection's initialization state. Connection is closed by the server if
35600 * processing of INIT message fails so returned observer will handle initialization failure as a fatal error.
35601 * @param {StreamObserver} observer the observer used for INIT message.
35602 * @return {StreamObserver} updated observer.
35603 */
35604
35605
35606 (0, _createClass3.default)(ConnectionState, [{
35607 key: 'wrap',
35608 value: function wrap(observer) {
35609 var _this13 = this;
35610
35611 return {
35612 onNext: function onNext(record) {
35613 if (observer && observer.onNext) {
35614 observer.onNext(record);
35615 }
35616 },
35617 onError: function onError(error) {
35618 _this13._processFailure(error);
35619
35620 _this13._connection._updateCurrentObserver(); // make sure this same observer will not be called again
35621 try {
35622 if (observer && observer.onError) {
35623 observer.onError(error);
35624 }
35625 } finally {
35626 _this13._connection._handleFatalError(error);
35627 }
35628 },
35629 onCompleted: function onCompleted(metaData) {
35630 _this13._connection._markInitialized(metaData);
35631 _this13._resolveInitPromise(_this13._connection);
35632
35633 if (observer && observer.onCompleted) {
35634 observer.onCompleted(metaData);
35635 }
35636 }
35637 };
35638 }
35639
35640 /**
35641 * Get promise resolved when connection initialization succeed or rejected when it fails.
35642 * @return {Promise<Connection>} the result of connection initialization.
35643 */
35644
35645 }, {
35646 key: 'initializationCompleted',
35647 value: function initializationCompleted() {
35648 this._initRequested = true;
35649
35650 if (this._initError) {
35651 var error = this._initError;
35652 this._initError = null; // to reject initPromise only once
35653 this._rejectInitPromise(error);
35654 }
35655
35656 return this._initPromise;
35657 }
35658
35659 /**
35660 * @private
35661 */
35662
35663 }, {
35664 key: '_processFailure',
35665 value: function _processFailure(error) {
35666 if (this._initRequested) {
35667 // someone is waiting for initialization to complete, reject the promise
35668 this._rejectInitPromise(error);
35669 } else {
35670 // no one is waiting for initialization, memorize the error but do not reject the promise
35671 // to avoid unnecessary unhandled promise rejection warnings
35672 this._initError = error;
35673 }
35674 }
35675 }]);
35676 return ConnectionState;
35677}();
35678
35679/**
35680 * Crete new connection to the provided address.
35681 * @access private
35682 * @param {string} hostPort - the Bolt endpoint to connect to
35683 * @param {object} config - this driver configuration
35684 * @param {string=null} connectionErrorCode - error code for errors raised on connection errors
35685 * @return {Connection} - New connection
35686 */
35687
35688
35689function connect(hostPort) {
35690 var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
35691 var connectionErrorCode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
35692
35693 var Ch = config.channel || Channel;
35694 var parsedAddress = _urlUtil2.default.parseDatabaseUrl(hostPort);
35695 var channelConfig = new _chConfig2.default(parsedAddress, config, connectionErrorCode);
35696 return new Connection(new Ch(channelConfig), parsedAddress.hostAndPort, config.disableLosslessIntegers);
35697}
35698
35699exports.connect = connect;
35700exports.Connection = Connection;
35701
35702},{"./../error":324,"./buf":329,"./ch-config":330,"./ch-node":331,"./ch-websocket":332,"./chunking":333,"./packstream-util":347,"./server-version":357,"./stream-observer":358,"./url-util":361,"babel-runtime/core-js/json/stringify":18,"babel-runtime/core-js/promise":29,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34}],338:[function(require,module,exports){
35703'use strict';
35704
35705Object.defineProperty(exports, "__esModule", {
35706 value: true
35707});
35708/**
35709 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
35710 *
35711 * This file is part of Neo4j.
35712 *
35713 * Licensed under the Apache License, Version 2.0 (the "License");
35714 * you may not use this file except in compliance with the License.
35715 * You may obtain a copy of the License at
35716 *
35717 * http://www.apache.org/licenses/LICENSE-2.0
35718 *
35719 * Unless required by applicable law or agreed to in writing, software
35720 * distributed under the License is distributed on an "AS IS" BASIS,
35721 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35722 * See the License for the specific language governing permissions and
35723 * limitations under the License.
35724 */
35725
35726// Central place to detect feature support for the current platform,
35727// expand as needed.
35728
35729var FEATURES = {
35730 trust_on_first_use: function trust_on_first_use() {
35731 try {
35732 // This is insane. We are verifying that we have a version of getPeerCertificate
35733 // that supports reading the whole certificate, eg this commit:
35734 // https://github.com/nodejs/node/commit/345c40b6
35735 var getPeerCertificateFunction = require('tls').TLSSocket.prototype.getPeerCertificate;
35736 var numberOfParameters = getPeerCertificateFunction.length;
35737 return numberOfParameters >= 1;
35738 } catch (e) {
35739 return false;
35740 }
35741 },
35742 trust_all_certificates: function trust_all_certificates() {
35743 try {
35744 var getPeerCertificateFunction = require('tls').TLSSocket.prototype.getPeerCertificate;
35745 return true;
35746 } catch (e) {
35747 return false;
35748 }
35749 },
35750 dns_lookup: function dns_lookup() {
35751 try {
35752 var lookupFunction = require('dns').lookup;
35753 if (lookupFunction && typeof lookupFunction === 'function') {
35754 return true;
35755 }
35756 return false;
35757 } catch (e) {
35758 return false;
35759 }
35760 }
35761};
35762
35763function hasFeature(name) {
35764 return FEATURES[name] && FEATURES[name]();
35765}
35766
35767exports.default = hasFeature;
35768
35769},{"dns":73,"tls":73}],339:[function(require,module,exports){
35770'use strict';
35771
35772Object.defineProperty(exports, "__esModule", {
35773 value: true
35774});
35775exports.DnsHostNameResolver = exports.DummyHostNameResolver = undefined;
35776
35777var _promise = require('babel-runtime/core-js/promise');
35778
35779var _promise2 = _interopRequireDefault(_promise);
35780
35781var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
35782
35783var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
35784
35785var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
35786
35787var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
35788
35789var _inherits2 = require('babel-runtime/helpers/inherits');
35790
35791var _inherits3 = _interopRequireDefault(_inherits2);
35792
35793var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
35794
35795var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
35796
35797var _createClass2 = require('babel-runtime/helpers/createClass');
35798
35799var _createClass3 = _interopRequireDefault(_createClass2);
35800
35801var _urlUtil = require('./url-util');
35802
35803var _urlUtil2 = _interopRequireDefault(_urlUtil);
35804
35805function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
35806
35807var HostNameResolver = function () {
35808 function HostNameResolver() {
35809 (0, _classCallCheck3.default)(this, HostNameResolver);
35810 }
35811
35812 (0, _createClass3.default)(HostNameResolver, [{
35813 key: 'resolve',
35814 value: function resolve() {
35815 throw new Error('Abstract function');
35816 }
35817 }]);
35818 return HostNameResolver;
35819}(); /**
35820 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
35821 *
35822 * This file is part of Neo4j.
35823 *
35824 * Licensed under the Apache License, Version 2.0 (the "License");
35825 * you may not use this file except in compliance with the License.
35826 * You may obtain a copy of the License at
35827 *
35828 * http://www.apache.org/licenses/LICENSE-2.0
35829 *
35830 * Unless required by applicable law or agreed to in writing, software
35831 * distributed under the License is distributed on an "AS IS" BASIS,
35832 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35833 * See the License for the specific language governing permissions and
35834 * limitations under the License.
35835 */
35836
35837var DummyHostNameResolver = exports.DummyHostNameResolver = function (_HostNameResolver) {
35838 (0, _inherits3.default)(DummyHostNameResolver, _HostNameResolver);
35839
35840 function DummyHostNameResolver() {
35841 (0, _classCallCheck3.default)(this, DummyHostNameResolver);
35842 return (0, _possibleConstructorReturn3.default)(this, (DummyHostNameResolver.__proto__ || (0, _getPrototypeOf2.default)(DummyHostNameResolver)).apply(this, arguments));
35843 }
35844
35845 (0, _createClass3.default)(DummyHostNameResolver, [{
35846 key: 'resolve',
35847 value: function resolve(seedRouter) {
35848 return resolveToItself(seedRouter);
35849 }
35850 }]);
35851 return DummyHostNameResolver;
35852}(HostNameResolver);
35853
35854var DnsHostNameResolver = exports.DnsHostNameResolver = function (_HostNameResolver2) {
35855 (0, _inherits3.default)(DnsHostNameResolver, _HostNameResolver2);
35856
35857 function DnsHostNameResolver() {
35858 (0, _classCallCheck3.default)(this, DnsHostNameResolver);
35859
35860 var _this2 = (0, _possibleConstructorReturn3.default)(this, (DnsHostNameResolver.__proto__ || (0, _getPrototypeOf2.default)(DnsHostNameResolver)).call(this));
35861
35862 _this2._dns = require('dns');
35863 return _this2;
35864 }
35865
35866 (0, _createClass3.default)(DnsHostNameResolver, [{
35867 key: 'resolve',
35868 value: function resolve(seedRouter) {
35869 var _this3 = this;
35870
35871 var parsedAddress = _urlUtil2.default.parseDatabaseUrl(seedRouter);
35872
35873 return new _promise2.default(function (resolve) {
35874 _this3._dns.lookup(parsedAddress.host, { all: true }, function (error, addresses) {
35875 if (error) {
35876 resolve(resolveToItself(seedRouter));
35877 } else {
35878 var addressesWithPorts = addresses.map(function (address) {
35879 return addressWithPort(address, parsedAddress.port);
35880 });
35881 resolve(addressesWithPorts);
35882 }
35883 });
35884 });
35885 }
35886 }]);
35887 return DnsHostNameResolver;
35888}(HostNameResolver);
35889
35890function resolveToItself(address) {
35891 return _promise2.default.resolve([address]);
35892}
35893
35894function addressWithPort(addressObject, port) {
35895 var address = addressObject.address;
35896 var addressFamily = addressObject.family;
35897
35898 if (!port) {
35899 return address;
35900 }
35901
35902 return addressFamily === 6 ? _urlUtil2.default.formatIPv6Address(address, port) : _urlUtil2.default.formatIPv4Address(address, port);
35903}
35904
35905},{"./url-util":361,"babel-runtime/core-js/object/get-prototype-of":26,"babel-runtime/core-js/promise":29,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34,"babel-runtime/helpers/inherits":37,"babel-runtime/helpers/possibleConstructorReturn":38,"dns":73}],340:[function(require,module,exports){
35906'use strict';
35907
35908Object.defineProperty(exports, "__esModule", {
35909 value: true
35910});
35911
35912var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
35913
35914var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
35915
35916var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
35917
35918var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
35919
35920var _createClass2 = require('babel-runtime/helpers/createClass');
35921
35922var _createClass3 = _interopRequireDefault(_createClass2);
35923
35924var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
35925
35926var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
35927
35928var _inherits2 = require('babel-runtime/helpers/inherits');
35929
35930var _inherits3 = _interopRequireDefault(_inherits2);
35931
35932var _driver = require('../../driver');
35933
35934var _driver2 = _interopRequireDefault(_driver);
35935
35936var _httpSession = require('./http-session');
35937
35938var _httpSession2 = _interopRequireDefault(_httpSession);
35939
35940var _httpSessionTracker = require('./http-session-tracker');
35941
35942var _httpSessionTracker2 = _interopRequireDefault(_httpSessionTracker);
35943
35944function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
35945
35946var HttpDriver = function (_Driver) {
35947 (0, _inherits3.default)(HttpDriver, _Driver);
35948
35949 function HttpDriver(hostPort, userAgent, token, config) {
35950 (0, _classCallCheck3.default)(this, HttpDriver);
35951
35952 var _this = (0, _possibleConstructorReturn3.default)(this, (HttpDriver.__proto__ || (0, _getPrototypeOf2.default)(HttpDriver)).call(this, hostPort, userAgent, token, config));
35953
35954 _this._sessionTracker = new _httpSessionTracker2.default();
35955 return _this;
35956 }
35957
35958 (0, _createClass3.default)(HttpDriver, [{
35959 key: 'session',
35960 value: function session() {
35961 return new _httpSession2.default(this._hostPort, this._token, this._config, this._sessionTracker);
35962 }
35963 }, {
35964 key: 'close',
35965 value: function close() {
35966 return this._sessionTracker.close();
35967 }
35968 }]);
35969 return HttpDriver;
35970}(_driver2.default); /**
35971 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
35972 *
35973 * This file is part of Neo4j.
35974 *
35975 * Licensed under the Apache License, Version 2.0 (the "License");
35976 * you may not use this file except in compliance with the License.
35977 * You may obtain a copy of the License at
35978 *
35979 * http://www.apache.org/licenses/LICENSE-2.0
35980 *
35981 * Unless required by applicable law or agreed to in writing, software
35982 * distributed under the License is distributed on an "AS IS" BASIS,
35983 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35984 * See the License for the specific language governing permissions and
35985 * limitations under the License.
35986 */
35987
35988exports.default = HttpDriver;
35989
35990},{"../../driver":323,"./http-session":344,"./http-session-tracker":343,"babel-runtime/core-js/object/get-prototype-of":26,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34,"babel-runtime/helpers/inherits":37,"babel-runtime/helpers/possibleConstructorReturn":38}],341:[function(require,module,exports){
35991'use strict';
35992
35993Object.defineProperty(exports, "__esModule", {
35994 value: true
35995});
35996
35997var _stringify = require('babel-runtime/core-js/json/stringify');
35998
35999var _stringify2 = _interopRequireDefault(_stringify);
36000
36001var _promise = require('babel-runtime/core-js/promise');
36002
36003var _promise2 = _interopRequireDefault(_promise);
36004
36005var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
36006
36007var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
36008
36009var _createClass2 = require('babel-runtime/helpers/createClass');
36010
36011var _createClass3 = _interopRequireDefault(_createClass2);
36012
36013var _streamObserver = require('../stream-observer');
36014
36015var _streamObserver2 = _interopRequireDefault(_streamObserver);
36016
36017var _httpResponseConverter = require('./http-response-converter');
36018
36019var _httpResponseConverter2 = _interopRequireDefault(_httpResponseConverter);
36020
36021var _error = require('../../error');
36022
36023function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
36024
36025var HttpRequestRunner = function () {
36026 function HttpRequestRunner(url, authToken) {
36027 (0, _classCallCheck3.default)(this, HttpRequestRunner);
36028
36029 this._url = url;
36030 this._authToken = authToken;
36031 this._converter = new _httpResponseConverter2.default();
36032 }
36033
36034 /**
36035 * Send a HTTP request to begin a transaction.
36036 * @return {Promise<number>} promise resolved with the transaction id or rejected with an error.
36037 */
36038
36039
36040 (0, _createClass3.default)(HttpRequestRunner, [{
36041 key: 'beginTransaction',
36042 value: function beginTransaction() {
36043 var _this = this;
36044
36045 var url = beginTransactionUrl(this._url);
36046 return sendRequest('POST', url, null, this._authToken).then(function (responseJson) {
36047 var neo4jError = _this._converter.extractError(responseJson);
36048 if (neo4jError) {
36049 throw neo4jError;
36050 }
36051 return _this._converter.extractTransactionId(responseJson);
36052 });
36053 }
36054
36055 /**
36056 * Send a HTTP request to commit a transaction.
36057 * @param {number} transactionId id of the transaction to commit.
36058 * @return {Promise<void>} promise resolved if transaction got committed or rejected when commit failed.
36059 */
36060
36061 }, {
36062 key: 'commitTransaction',
36063 value: function commitTransaction(transactionId) {
36064 var _this2 = this;
36065
36066 var url = commitTransactionUrl(this._url, transactionId);
36067 return sendRequest('POST', url, null, this._authToken).then(function (responseJson) {
36068 var neo4jError = _this2._converter.extractError(responseJson);
36069 if (neo4jError) {
36070 throw neo4jError;
36071 }
36072 });
36073 }
36074
36075 /**
36076 * Send a HTTP request to rollback a transaction.
36077 * @param {number} transactionId id of the transaction to rollback.
36078 * @return {Promise<void>} promise resolved if transaction got rolled back or rejected when rollback failed.
36079 */
36080
36081 }, {
36082 key: 'rollbackTransaction',
36083 value: function rollbackTransaction(transactionId) {
36084 var _this3 = this;
36085
36086 var url = transactionUrl(this._url, transactionId);
36087 return sendRequest('DELETE', url, null, this._authToken).then(function (responseJson) {
36088 var neo4jError = _this3._converter.extractError(responseJson);
36089 if (neo4jError) {
36090 throw neo4jError;
36091 }
36092 });
36093 }
36094
36095 /**
36096 * Send a HTTP request to execute a query in a transaction with the given id.
36097 * @param {number} transactionId the transaction id.
36098 * @param {string} statement the cypher query.
36099 * @param {object} parameters the cypher query parameters.
36100 * @return {Promise<StreamObserver>} a promise resolved with {@link StreamObserver} containing either records or error.
36101 */
36102
36103 }, {
36104 key: 'runQuery',
36105 value: function runQuery(transactionId, statement, parameters) {
36106 var _this4 = this;
36107
36108 var streamObserver = new _streamObserver2.default();
36109 var url = transactionUrl(this._url, transactionId);
36110 var body = createStatementJson(statement, parameters, this._converter, streamObserver);
36111 if (!body) {
36112 // unable to encode given statement and parameters, return a failed stream observer
36113 return _promise2.default.resolve(streamObserver);
36114 }
36115
36116 return sendRequest('POST', url, body, this._authToken).then(function (responseJson) {
36117 processResponseJson(responseJson, _this4._converter, streamObserver);
36118 }).catch(function (error) {
36119 streamObserver.onError(error);
36120 }).then(function () {
36121 return streamObserver;
36122 });
36123 }
36124 }]);
36125 return HttpRequestRunner;
36126}(); /**
36127 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
36128 *
36129 * This file is part of Neo4j.
36130 *
36131 * Licensed under the Apache License, Version 2.0 (the "License");
36132 * you may not use this file except in compliance with the License.
36133 * You may obtain a copy of the License at
36134 *
36135 * http://www.apache.org/licenses/LICENSE-2.0
36136 *
36137 * Unless required by applicable law or agreed to in writing, software
36138 * distributed under the License is distributed on an "AS IS" BASIS,
36139 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
36140 * See the License for the specific language governing permissions and
36141 * limitations under the License.
36142 */
36143
36144exports.default = HttpRequestRunner;
36145
36146
36147function sendRequest(method, url, bodyString, authToken) {
36148 try {
36149 var options = {
36150 method: method,
36151 headers: createHttpHeaders(authToken),
36152 body: bodyString
36153 };
36154
36155 return new _promise2.default(function (resolve, reject) {
36156 fetch(url, options).then(function (response) {
36157 return response.json();
36158 }).then(function (responseJson) {
36159 return resolve(responseJson);
36160 }).catch(function (error) {
36161 return reject(new _error.Neo4jError(error.message, _error.SERVICE_UNAVAILABLE));
36162 });
36163 });
36164 } catch (e) {
36165 return _promise2.default.reject(e);
36166 }
36167}
36168
36169function createHttpHeaders(authToken) {
36170 var headers = new Headers();
36171 headers.append('Accept', 'application/json; charset=UTF-8');
36172 headers.append('Content-Type', 'application/json');
36173 headers.append('Authorization', 'Basic ' + btoa(authToken.principal + ':' + authToken.credentials));
36174 return headers;
36175}
36176
36177function createStatementJson(statement, parameters, converter, streamObserver) {
36178 try {
36179 return createStatementJsonOrThrow(statement, parameters, converter);
36180 } catch (e) {
36181 streamObserver.onError(e);
36182 return null;
36183 }
36184}
36185
36186function createStatementJsonOrThrow(statement, parameters, converter) {
36187 var encodedParameters = converter.encodeStatementParameters(parameters);
36188 return (0, _stringify2.default)({
36189 statements: [{
36190 statement: statement,
36191 parameters: encodedParameters,
36192 resultDataContents: ['row', 'graph'],
36193 includeStats: true
36194 }]
36195 });
36196}
36197
36198function processResponseJson(responseJson, converter, streamObserver) {
36199 if (!responseJson) {
36200 // request failed and there is no response
36201 return;
36202 }
36203
36204 try {
36205 processResponseJsonOrThrow(responseJson, converter, streamObserver);
36206 } catch (e) {
36207 streamObserver.onError(e);
36208 }
36209}
36210
36211function processResponseJsonOrThrow(responseJson, converter, streamObserver) {
36212 var neo4jError = converter.extractError(responseJson);
36213 if (neo4jError) {
36214 streamObserver.onError(neo4jError);
36215 } else {
36216 var recordMetadata = converter.extractRecordMetadata(responseJson);
36217 streamObserver.onCompleted(recordMetadata);
36218
36219 var rawRecords = converter.extractRawRecords(responseJson);
36220 rawRecords.forEach(function (rawRecord) {
36221 return streamObserver.onNext(rawRecord);
36222 });
36223
36224 var statementMetadata = converter.extractStatementMetadata(responseJson);
36225 streamObserver.onCompleted(statementMetadata);
36226 }
36227}
36228
36229function beginTransactionUrl(baseUrl) {
36230 return createUrl(baseUrl, '/db/data/transaction');
36231}
36232
36233function commitTransactionUrl(baseUrl, transactionId) {
36234 return transactionUrl(baseUrl, transactionId) + '/commit';
36235}
36236
36237function transactionUrl(baseUrl, transactionId) {
36238 return beginTransactionUrl(baseUrl) + '/' + transactionId;
36239}
36240
36241function createUrl(baseUrl, path) {
36242 return baseUrl.scheme + '://' + baseUrl.host + ':' + baseUrl.port + path;
36243}
36244
36245},{"../../error":324,"../stream-observer":358,"./http-response-converter":342,"babel-runtime/core-js/json/stringify":18,"babel-runtime/core-js/promise":29,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34}],342:[function(require,module,exports){
36246'use strict';
36247
36248Object.defineProperty(exports, "__esModule", {
36249 value: true
36250});
36251
36252var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
36253
36254var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
36255
36256var _typeof2 = require('babel-runtime/helpers/typeof');
36257
36258var _typeof3 = _interopRequireDefault(_typeof2);
36259
36260var _keys = require('babel-runtime/core-js/object/keys');
36261
36262var _keys2 = _interopRequireDefault(_keys);
36263
36264var _stringify = require('babel-runtime/core-js/json/stringify');
36265
36266var _stringify2 = _interopRequireDefault(_stringify);
36267
36268var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
36269
36270var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
36271
36272var _createClass2 = require('babel-runtime/helpers/createClass');
36273
36274var _createClass3 = _interopRequireDefault(_createClass2);
36275
36276var _integer = require('../../integer');
36277
36278var _graphTypes = require('../../graph-types');
36279
36280var _error = require('../../error');
36281
36282var _spatialTypes = require('../../spatial-types');
36283
36284var _temporalTypes = require('../../temporal-types');
36285
36286function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
36287
36288var CREDENTIALS_EXPIRED_CODE = 'Neo.ClientError.Security.CredentialsExpired'; /**
36289 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
36290 *
36291 * This file is part of Neo4j.
36292 *
36293 * Licensed under the Apache License, Version 2.0 (the "License");
36294 * you may not use this file except in compliance with the License.
36295 * You may obtain a copy of the License at
36296 *
36297 * http://www.apache.org/licenses/LICENSE-2.0
36298 *
36299 * Unless required by applicable law or agreed to in writing, software
36300 * distributed under the License is distributed on an "AS IS" BASIS,
36301 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
36302 * See the License for the specific language governing permissions and
36303 * limitations under the License.
36304 */
36305
36306var HttpResponseConverter = function () {
36307 function HttpResponseConverter() {
36308 (0, _classCallCheck3.default)(this, HttpResponseConverter);
36309 }
36310
36311 (0, _createClass3.default)(HttpResponseConverter, [{
36312 key: 'encodeStatementParameters',
36313 value: function encodeStatementParameters(parameters) {
36314 return encodeQueryParameters(parameters);
36315 }
36316
36317 /**
36318 * Attempts to extract error from transactional cypher endpoint response and convert it to {@link Neo4jError}.
36319 * @param {object} response the response.
36320 * @return {Neo4jError|null} new driver friendly error, if exists.
36321 */
36322
36323 }, {
36324 key: 'extractError',
36325 value: function extractError(response) {
36326 var errors = response.errors;
36327 if (errors) {
36328 var error = errors[0];
36329 if (error) {
36330 // endpoint returns 'Neo.ClientError.Security.Forbidden' code and 'password_change' that points to another endpoint
36331 // this is different from code returned via Bolt and less descriptive
36332 // make code same as in Bolt, if password change is required
36333 var code = response.password_change ? CREDENTIALS_EXPIRED_CODE : error.code;
36334 var message = error.message;
36335 return new _error.Neo4jError(message, code);
36336 }
36337 }
36338 return null;
36339 }
36340
36341 /**
36342 * Extracts transaction id from the db/data/transaction endpoint response.
36343 * @param {object} response the response.
36344 * @return {number} the transaction id.
36345 */
36346
36347 }, {
36348 key: 'extractTransactionId',
36349 value: function extractTransactionId(response) {
36350 var commitUrl = response.commit;
36351 if (commitUrl) {
36352 // extract id 42 from commit url like 'http://localhost:7474/db/data/transaction/42/commit'
36353 var url = commitUrl.replace('/commit', '');
36354 var transactionIdString = url.substring(url.lastIndexOf('/') + 1);
36355 var transactionId = parseInt(transactionIdString, 10);
36356 if (transactionId || transactionId === 0) {
36357 return transactionId;
36358 }
36359 }
36360 throw new _error.Neo4jError('Unable to extract transaction id from the response JSON: ' + (0, _stringify2.default)(response));
36361 }
36362
36363 /**
36364 * Extracts record metadata (array of column names) from transactional cypher endpoint response.
36365 * @param {object} response the response.
36366 * @return {object} new metadata object.
36367 */
36368
36369 }, {
36370 key: 'extractRecordMetadata',
36371 value: function extractRecordMetadata(response) {
36372 var result = extractResult(response);
36373 var fields = result ? result.columns : [];
36374 return { fields: fields };
36375 }
36376
36377 /**
36378 * Extracts raw records (each raw record is just an array of value) from transactional cypher endpoint response.
36379 * @param {object} response the response.
36380 * @return {object[][]} raw records from the response.
36381 */
36382
36383 }, {
36384 key: 'extractRawRecords',
36385 value: function extractRawRecords(response) {
36386 var result = extractResult(response);
36387 if (result) {
36388 var data = result.data;
36389 if (data) {
36390 return data.map(function (element) {
36391 return extractRawRecord(element);
36392 });
36393 }
36394 }
36395 return [];
36396 }
36397
36398 /**
36399 * Extracts metadata for a completed statement.
36400 * @param {object} response the response.
36401 * @return {object} metadata as object.
36402 */
36403
36404 }, {
36405 key: 'extractStatementMetadata',
36406 value: function extractStatementMetadata(response) {
36407 var result = extractResult(response);
36408 if (result) {
36409 var stats = result.stats;
36410 if (stats) {
36411 var convertedStats = (0, _keys2.default)(stats).reduce(function (newStats, key) {
36412 if (key === 'contains_updates') {
36413 // skip because such key does not exist in bolt
36414 return newStats;
36415 }
36416
36417 // fix key name for future parsing by StatementStatistics class
36418 var newKey = (key === 'relationship_deleted' ? 'relationships_deleted' : key).replace('_', '-');
36419 newStats[newKey] = stats[key];
36420 return newStats;
36421 }, {});
36422
36423 return { stats: convertedStats };
36424 }
36425 }
36426 return {};
36427 }
36428 }]);
36429 return HttpResponseConverter;
36430}();
36431
36432exports.default = HttpResponseConverter;
36433
36434
36435function encodeQueryParameters(parameters) {
36436 if (parameters && (typeof parameters === 'undefined' ? 'undefined' : (0, _typeof3.default)(parameters)) === 'object') {
36437 return (0, _keys2.default)(parameters).reduce(function (result, key) {
36438 result[key] = encodeQueryParameter(parameters[key]);
36439 return result;
36440 }, {});
36441 }
36442 return parameters;
36443}
36444
36445function encodeQueryParameter(value) {
36446 if (value instanceof _graphTypes.Node) {
36447 throw new _error.Neo4jError('It is not allowed to pass nodes in query parameters', _error.PROTOCOL_ERROR);
36448 } else if (value instanceof _graphTypes.Relationship) {
36449 throw new _error.Neo4jError('It is not allowed to pass relationships in query parameters', _error.PROTOCOL_ERROR);
36450 } else if (value instanceof _graphTypes.Path) {
36451 throw new _error.Neo4jError('It is not allowed to pass paths in query parameters', _error.PROTOCOL_ERROR);
36452 } else if ((0, _spatialTypes.isPoint)(value)) {
36453 throw newUnsupportedParameterError('points');
36454 } else if ((0, _temporalTypes.isDate)(value)) {
36455 throw newUnsupportedParameterError('dates');
36456 } else if ((0, _temporalTypes.isDateTime)(value)) {
36457 throw newUnsupportedParameterError('date-time');
36458 } else if ((0, _temporalTypes.isDuration)(value)) {
36459 throw newUnsupportedParameterError('durations');
36460 } else if ((0, _temporalTypes.isLocalDateTime)(value)) {
36461 throw newUnsupportedParameterError('local date-time');
36462 } else if ((0, _temporalTypes.isLocalTime)(value)) {
36463 throw newUnsupportedParameterError('local time');
36464 } else if ((0, _temporalTypes.isTime)(value)) {
36465 throw newUnsupportedParameterError('time');
36466 } else if ((0, _integer.isInt)(value)) {
36467 return value.toNumber();
36468 } else if (Array.isArray(value)) {
36469 return value.map(function (element) {
36470 return encodeQueryParameter(element);
36471 });
36472 } else if ((typeof value === 'undefined' ? 'undefined' : (0, _typeof3.default)(value)) === 'object') {
36473 return encodeQueryParameters(value);
36474 } else {
36475 return value;
36476 }
36477}
36478
36479function newUnsupportedParameterError(name) {
36480 return new _error.Neo4jError('It is not allowed to pass ' + name + ' in query parameters when using HTTP endpoint. ' + ('Please consider using Cypher functions to create ' + name + ' so that query parameters are plain objects.'), _error.PROTOCOL_ERROR);
36481}
36482
36483function extractResult(response) {
36484 var results = response.results;
36485 if (results) {
36486 var result = results[0];
36487 if (result) {
36488 return result;
36489 }
36490 }
36491 return null;
36492}
36493
36494function extractRawRecord(data) {
36495 var row = data.row;
36496
36497 var nodesById = indexNodesById(data);
36498 var relationshipsById = indexRelationshipsById(data);
36499
36500 if (row) {
36501 return row.map(function (ignore, index) {
36502 return extractRawRecordElement(index, data, nodesById, relationshipsById);
36503 });
36504 }
36505 return [];
36506}
36507
36508function indexNodesById(data) {
36509 var graph = data.graph;
36510 if (graph) {
36511 var nodes = graph.nodes;
36512 if (nodes) {
36513 return nodes.reduce(function (result, node) {
36514
36515 var identity = convertNumber(node.id);
36516 var labels = node.labels;
36517 var properties = convertPrimitiveValue(node.properties);
36518 result[node.id] = new _graphTypes.Node(identity, labels, properties);
36519
36520 return result;
36521 }, {});
36522 }
36523 }
36524 return {};
36525}
36526
36527function indexRelationshipsById(data) {
36528 var graph = data.graph;
36529 if (graph) {
36530 var relationships = graph.relationships;
36531 if (relationships) {
36532 return relationships.reduce(function (result, relationship) {
36533
36534 var identity = convertNumber(relationship.id);
36535 var startNode = convertNumber(relationship.startNode);
36536 var endNode = convertNumber(relationship.endNode);
36537 var type = relationship.type;
36538 var properties = convertPrimitiveValue(relationship.properties);
36539 result[relationship.id] = new _graphTypes.Relationship(identity, startNode, endNode, type, properties);
36540
36541 return result;
36542 }, {});
36543 }
36544 }
36545 return {};
36546}
36547
36548function extractRawRecordElement(index, data, nodesById, relationshipsById) {
36549 var element = data.row ? data.row[index] : null;
36550 var elementMetadata = data.meta ? data.meta[index] : null;
36551
36552 if (elementMetadata) {
36553 // element is either a graph, spatial or temporal type
36554 return convertComplexValue(element, elementMetadata, nodesById, relationshipsById);
36555 } else {
36556 // element is a primitive, like number, string, array or object
36557 return convertPrimitiveValue(element);
36558 }
36559}
36560
36561function convertComplexValue(element, elementMetadata, nodesById, relationshipsById) {
36562 if (isNodeMetadata(elementMetadata)) {
36563 return nodesById[elementMetadata.id];
36564 } else if (isRelationshipMetadata(elementMetadata)) {
36565 return relationshipsById[elementMetadata.id];
36566 } else if (isPathMetadata(elementMetadata)) {
36567 return convertPath(elementMetadata, nodesById, relationshipsById);
36568 } else if (isPointMetadata(elementMetadata)) {
36569 return convertPoint(element);
36570 } else {
36571 return element;
36572 }
36573}
36574
36575function convertPath(metadata, nodesById, relationshipsById) {
36576 var startNode = null;
36577 var relationship = null;
36578 var pathSegments = [];
36579
36580 for (var i = 0; i < metadata.length; i++) {
36581 var element = metadata[i];
36582 var elementId = element.id;
36583 var elementType = element.type;
36584
36585 var nodeExpected = startNode === null && relationship === null || startNode !== null && relationship !== null;
36586 if (nodeExpected && elementType !== 'node') {
36587 throw new _error.Neo4jError('Unable to parse path, node expected but got: ' + (0, _stringify2.default)(element) + ' in ' + (0, _stringify2.default)(metadata));
36588 }
36589 if (!nodeExpected && elementType === 'node') {
36590 throw new _error.Neo4jError('Unable to parse path, relationship expected but got: ' + (0, _stringify2.default)(element) + ' in ' + (0, _stringify2.default)(metadata));
36591 }
36592
36593 if (nodeExpected) {
36594 var node = nodesById[elementId];
36595 if (startNode === null) {
36596 startNode = node;
36597 } else if (startNode !== null && relationship !== null) {
36598 var pathSegment = new _graphTypes.PathSegment(startNode, relationship, node);
36599 pathSegments.push(pathSegment);
36600 startNode = node;
36601 relationship = null;
36602 } else {
36603 throw new _error.Neo4jError('Unable to parse path, illegal node configuration: ' + (0, _stringify2.default)(metadata));
36604 }
36605 } else {
36606 if (relationship === null) {
36607 relationship = relationshipsById[elementId];
36608 } else {
36609 throw new _error.Neo4jError('Unable to parse path, illegal relationship configuration: ' + (0, _stringify2.default)(metadata));
36610 }
36611 }
36612 }
36613
36614 var lastPathSegment = pathSegments[pathSegments.length - 1];
36615 if (lastPathSegment && lastPathSegment.end !== startNode || relationship !== null) {
36616 throw new _error.Neo4jError('Unable to parse path: ' + (0, _stringify2.default)(metadata));
36617 }
36618
36619 return createPath(pathSegments);
36620}
36621
36622function createPath(pathSegments) {
36623 var pathStartNode = pathSegments[0].start;
36624 var pathEndNode = pathSegments[pathSegments.length - 1].end;
36625 return new _graphTypes.Path(pathStartNode, pathEndNode, pathSegments);
36626}
36627
36628function convertPoint(element) {
36629 var type = element.type;
36630 if (type !== 'Point') {
36631 throw new _error.Neo4jError('Unexpected Point type received: ' + (0, _stringify2.default)(element));
36632 }
36633
36634 var coordinates = element.coordinates;
36635 if (!Array.isArray(coordinates) && (coordinates.length !== 2 || coordinates.length !== 3)) {
36636 throw new _error.Neo4jError('Unexpected Point coordinates received: ' + (0, _stringify2.default)(element));
36637 }
36638
36639 var srid = convertCrsToId(element);
36640
36641 return new (Function.prototype.bind.apply(_spatialTypes.Point, [null].concat([srid], (0, _toConsumableArray3.default)(coordinates))))();
36642}
36643
36644function convertCrsToId(element) {
36645 var crs = element.crs;
36646 if (!crs || !crs.name) {
36647 throw new _error.Neo4jError('Unexpected Point crs received: ' + (0, _stringify2.default)(element));
36648 }
36649 var name = crs.name.toLowerCase();
36650
36651 if (name === 'wgs-84') {
36652 return 4326;
36653 } else if (name === 'wgs-84-3d') {
36654 return 4979;
36655 } else if (name === 'cartesian') {
36656 return 7203;
36657 } else if (name === 'cartesian-3d') {
36658 return 9157;
36659 } else {
36660 throw new _error.Neo4jError('Unexpected Point crs received: ' + (0, _stringify2.default)(element));
36661 }
36662}
36663
36664function convertPrimitiveValue(element) {
36665 if (element == null || element === undefined) {
36666 return null;
36667 } else if (typeof element === 'number') {
36668 return convertNumber(element);
36669 } else if (Array.isArray(element)) {
36670 return element.map(function (element) {
36671 return convertPrimitiveValue(element);
36672 });
36673 } else if ((typeof element === 'undefined' ? 'undefined' : (0, _typeof3.default)(element)) === 'object') {
36674 return (0, _keys2.default)(element).reduce(function (result, key) {
36675 result[key] = convertPrimitiveValue(element[key]);
36676 return result;
36677 }, {});
36678 } else {
36679 return element;
36680 }
36681}
36682
36683function convertNumber(value) {
36684 return typeof value === 'number' ? value : Number(value);
36685}
36686
36687function isNodeMetadata(metadata) {
36688 return isMetadataForType('node', metadata);
36689}
36690
36691function isRelationshipMetadata(metadata) {
36692 return isMetadataForType('relationship', metadata);
36693}
36694
36695function isPointMetadata(metadata) {
36696 return isMetadataForType('point', metadata);
36697}
36698
36699function isMetadataForType(name, metadata) {
36700 return !Array.isArray(metadata) && (typeof metadata === 'undefined' ? 'undefined' : (0, _typeof3.default)(metadata)) === 'object' && metadata.type === name;
36701}
36702
36703function isPathMetadata(metadata) {
36704 return Array.isArray(metadata);
36705}
36706
36707},{"../../error":324,"../../graph-types":325,"../../integer":327,"../../spatial-types":369,"../../temporal-types":370,"babel-runtime/core-js/json/stringify":18,"babel-runtime/core-js/object/keys":27,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34,"babel-runtime/helpers/toConsumableArray":40,"babel-runtime/helpers/typeof":41}],343:[function(require,module,exports){
36708"use strict";
36709
36710Object.defineProperty(exports, "__esModule", {
36711 value: true
36712});
36713
36714var _promise = require("babel-runtime/core-js/promise");
36715
36716var _promise2 = _interopRequireDefault(_promise);
36717
36718var _from = require("babel-runtime/core-js/array/from");
36719
36720var _from2 = _interopRequireDefault(_from);
36721
36722var _set = require("babel-runtime/core-js/set");
36723
36724var _set2 = _interopRequireDefault(_set);
36725
36726var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
36727
36728var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
36729
36730var _createClass2 = require("babel-runtime/helpers/createClass");
36731
36732var _createClass3 = _interopRequireDefault(_createClass2);
36733
36734function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
36735
36736/**
36737 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
36738 *
36739 * This file is part of Neo4j.
36740 *
36741 * Licensed under the Apache License, Version 2.0 (the "License");
36742 * you may not use this file except in compliance with the License.
36743 * You may obtain a copy of the License at
36744 *
36745 * http://www.apache.org/licenses/LICENSE-2.0
36746 *
36747 * Unless required by applicable law or agreed to in writing, software
36748 * distributed under the License is distributed on an "AS IS" BASIS,
36749 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
36750 * See the License for the specific language governing permissions and
36751 * limitations under the License.
36752 */
36753
36754var HttpSessionTracker = function () {
36755 function HttpSessionTracker() {
36756 (0, _classCallCheck3.default)(this, HttpSessionTracker);
36757
36758 this._openSessions = new _set2.default();
36759 }
36760
36761 /**
36762 * Record given session as open.
36763 * @param {HttpSession} session the newly open session.
36764 */
36765
36766
36767 (0, _createClass3.default)(HttpSessionTracker, [{
36768 key: "sessionOpened",
36769 value: function sessionOpened(session) {
36770 this._openSessions.add(session);
36771 }
36772
36773 /**
36774 * Record given session as close.
36775 * @param {HttpSession} session the just closed session.
36776 */
36777
36778 }, {
36779 key: "sessionClosed",
36780 value: function sessionClosed(session) {
36781 this._openSessions.delete(session);
36782 }
36783
36784 /**
36785 * Close this tracker and all open sessions.
36786 */
36787
36788 }, {
36789 key: "close",
36790 value: function close() {
36791 var sessions = (0, _from2.default)(this._openSessions);
36792 this._openSessions.clear();
36793 return _promise2.default.all(sessions.map(function (session) {
36794 return closeSession(session);
36795 }));
36796 }
36797 }]);
36798 return HttpSessionTracker;
36799}();
36800
36801/**
36802 * Close given session and get a promise back.
36803 * @param {HttpSession} session the session to close.
36804 * @return {Promise<void>} promise resolved when session is closed.
36805 */
36806
36807
36808exports.default = HttpSessionTracker;
36809function closeSession(session) {
36810 return new _promise2.default(function (resolve) {
36811 session.close(function () {
36812 resolve();
36813 });
36814 });
36815}
36816
36817},{"babel-runtime/core-js/array/from":15,"babel-runtime/core-js/promise":29,"babel-runtime/core-js/set":30,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34}],344:[function(require,module,exports){
36818'use strict';
36819
36820Object.defineProperty(exports, "__esModule", {
36821 value: true
36822});
36823
36824var _promise = require('babel-runtime/core-js/promise');
36825
36826var _promise2 = _interopRequireDefault(_promise);
36827
36828var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
36829
36830var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
36831
36832var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
36833
36834var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
36835
36836var _createClass2 = require('babel-runtime/helpers/createClass');
36837
36838var _createClass3 = _interopRequireDefault(_createClass2);
36839
36840var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
36841
36842var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
36843
36844var _inherits2 = require('babel-runtime/helpers/inherits');
36845
36846var _inherits3 = _interopRequireDefault(_inherits2);
36847
36848var _driver = require('../../driver');
36849
36850var _session = require('../../session');
36851
36852var _session2 = _interopRequireDefault(_session);
36853
36854var _util = require('../util');
36855
36856var _error = require('../../error');
36857
36858var _httpRequestRunner = require('./http-request-runner');
36859
36860var _httpRequestRunner2 = _interopRequireDefault(_httpRequestRunner);
36861
36862var _connectionHolder = require('../connection-holder');
36863
36864var _result = require('../../result');
36865
36866var _result2 = _interopRequireDefault(_result);
36867
36868function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
36869
36870var HttpSession = function (_Session) {
36871 (0, _inherits3.default)(HttpSession, _Session);
36872
36873 function HttpSession(url, authToken, config, sessionTracker) {
36874 (0, _classCallCheck3.default)(this, HttpSession);
36875
36876 var _this = (0, _possibleConstructorReturn3.default)(this, (HttpSession.__proto__ || (0, _getPrototypeOf2.default)(HttpSession)).call(this, _driver.WRITE, null, null, config));
36877
36878 _this._ongoingTransactionIds = [];
36879 _this._serverInfoSupplier = createServerInfoSupplier(url);
36880 _this._requestRunner = new _httpRequestRunner2.default(url, authToken);
36881 _this._sessionTracker = sessionTracker;
36882 _this._sessionTracker.sessionOpened(_this);
36883 return _this;
36884 }
36885
36886 (0, _createClass3.default)(HttpSession, [{
36887 key: 'run',
36888 value: function run(statement) {
36889 var _this2 = this;
36890
36891 var parameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
36892
36893 var _validateStatementAnd = (0, _util.validateStatementAndParameters)(statement, parameters),
36894 query = _validateStatementAnd.query,
36895 params = _validateStatementAnd.params;
36896
36897 return this._requestRunner.beginTransaction().then(function (transactionId) {
36898 _this2._ongoingTransactionIds.push(transactionId);
36899 var queryPromise = _this2._requestRunner.runQuery(transactionId, query, params);
36900
36901 return queryPromise.then(function (streamObserver) {
36902 if (streamObserver.hasFailed()) {
36903 return rollbackTransactionAfterQueryFailure(transactionId, streamObserver, _this2._requestRunner);
36904 } else {
36905 return commitTransactionAfterQuerySuccess(transactionId, streamObserver, _this2._requestRunner);
36906 }
36907 }).then(function (streamObserver) {
36908 _this2._ongoingTransactionIds = _this2._ongoingTransactionIds.filter(function (id) {
36909 return id !== transactionId;
36910 });
36911 return new _result2.default(streamObserver, query, params, _this2._serverInfoSupplier, _connectionHolder.EMPTY_CONNECTION_HOLDER);
36912 });
36913 });
36914 }
36915 }, {
36916 key: 'beginTransaction',
36917 value: function beginTransaction() {
36918 throwTransactionsNotSupported();
36919 }
36920 }, {
36921 key: 'readTransaction',
36922 value: function readTransaction() {
36923 throwTransactionsNotSupported();
36924 }
36925 }, {
36926 key: 'writeTransaction',
36927 value: function writeTransaction() {
36928 throwTransactionsNotSupported();
36929 }
36930 }, {
36931 key: 'lastBookmark',
36932 value: function lastBookmark() {
36933 throw new _error.Neo4jError('Experimental HTTP driver does not support bookmarks and routing');
36934 }
36935 }, {
36936 key: 'close',
36937 value: function close() {
36938 var _this3 = this;
36939
36940 var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {
36941 return null;
36942 };
36943
36944 var rollbackAllOngoingTransactions = this._ongoingTransactionIds.map(function (transactionId) {
36945 return rollbackTransactionSilently(transactionId, _this3._requestRunner);
36946 });
36947
36948 _promise2.default.all(rollbackAllOngoingTransactions).then(function () {
36949 _this3._sessionTracker.sessionClosed(_this3);
36950 callback();
36951 });
36952 }
36953 }]);
36954 return HttpSession;
36955}(_session2.default); /**
36956 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
36957 *
36958 * This file is part of Neo4j.
36959 *
36960 * Licensed under the Apache License, Version 2.0 (the "License");
36961 * you may not use this file except in compliance with the License.
36962 * You may obtain a copy of the License at
36963 *
36964 * http://www.apache.org/licenses/LICENSE-2.0
36965 *
36966 * Unless required by applicable law or agreed to in writing, software
36967 * distributed under the License is distributed on an "AS IS" BASIS,
36968 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
36969 * See the License for the specific language governing permissions and
36970 * limitations under the License.
36971 */
36972
36973exports.default = HttpSession;
36974
36975
36976function rollbackTransactionAfterQueryFailure(transactionId, streamObserver, requestRunner) {
36977 return rollbackTransactionSilently(transactionId, requestRunner).then(function () {
36978 return streamObserver;
36979 });
36980}
36981
36982function commitTransactionAfterQuerySuccess(transactionId, streamObserver, requestRunner) {
36983 return requestRunner.commitTransaction(transactionId).catch(function (error) {
36984 streamObserver.onError(error);
36985 }).then(function () {
36986 return streamObserver;
36987 });
36988}
36989
36990function rollbackTransactionSilently(transactionId, requestRunner) {
36991 return requestRunner.rollbackTransaction(transactionId).catch(function (error) {
36992 // ignore all rollback errors
36993 });
36994}
36995
36996function createServerInfoSupplier(url) {
36997 return function () {
36998 return { server: { address: url.hostAndPort } };
36999 };
37000}
37001
37002function throwTransactionsNotSupported() {
37003 throw new _error.Neo4jError('Experimental HTTP driver does not support transactions');
37004}
37005
37006},{"../../driver":323,"../../error":324,"../../result":366,"../../session":368,"../connection-holder":334,"../util":363,"./http-request-runner":341,"babel-runtime/core-js/object/get-prototype-of":26,"babel-runtime/core-js/promise":29,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34,"babel-runtime/helpers/inherits":37,"babel-runtime/helpers/possibleConstructorReturn":38}],345:[function(require,module,exports){
37007'use strict';
37008
37009Object.defineProperty(exports, "__esModule", {
37010 value: true
37011});
37012exports.LEAST_CONNECTED_STRATEGY_NAME = undefined;
37013
37014var _maxSafeInteger = require('babel-runtime/core-js/number/max-safe-integer');
37015
37016var _maxSafeInteger2 = _interopRequireDefault(_maxSafeInteger);
37017
37018var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
37019
37020var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
37021
37022var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
37023
37024var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
37025
37026var _createClass2 = require('babel-runtime/helpers/createClass');
37027
37028var _createClass3 = _interopRequireDefault(_createClass2);
37029
37030var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
37031
37032var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
37033
37034var _inherits2 = require('babel-runtime/helpers/inherits');
37035
37036var _inherits3 = _interopRequireDefault(_inherits2);
37037
37038var _roundRobinArrayIndex = require('./round-robin-array-index');
37039
37040var _roundRobinArrayIndex2 = _interopRequireDefault(_roundRobinArrayIndex);
37041
37042var _loadBalancingStrategy = require('./load-balancing-strategy');
37043
37044var _loadBalancingStrategy2 = _interopRequireDefault(_loadBalancingStrategy);
37045
37046function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
37047
37048/**
37049 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
37050 *
37051 * This file is part of Neo4j.
37052 *
37053 * Licensed under the Apache License, Version 2.0 (the "License");
37054 * you may not use this file except in compliance with the License.
37055 * You may obtain a copy of the License at
37056 *
37057 * http://www.apache.org/licenses/LICENSE-2.0
37058 *
37059 * Unless required by applicable law or agreed to in writing, software
37060 * distributed under the License is distributed on an "AS IS" BASIS,
37061 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37062 * See the License for the specific language governing permissions and
37063 * limitations under the License.
37064 */
37065var LEAST_CONNECTED_STRATEGY_NAME = exports.LEAST_CONNECTED_STRATEGY_NAME = 'least_connected';
37066
37067var LeastConnectedLoadBalancingStrategy = function (_LoadBalancingStrateg) {
37068 (0, _inherits3.default)(LeastConnectedLoadBalancingStrategy, _LoadBalancingStrateg);
37069
37070 /**
37071 * @constructor
37072 * @param {Pool} connectionPool the connection pool of this driver.
37073 */
37074 function LeastConnectedLoadBalancingStrategy(connectionPool) {
37075 (0, _classCallCheck3.default)(this, LeastConnectedLoadBalancingStrategy);
37076
37077 var _this = (0, _possibleConstructorReturn3.default)(this, (LeastConnectedLoadBalancingStrategy.__proto__ || (0, _getPrototypeOf2.default)(LeastConnectedLoadBalancingStrategy)).call(this));
37078
37079 _this._readersIndex = new _roundRobinArrayIndex2.default();
37080 _this._writersIndex = new _roundRobinArrayIndex2.default();
37081 _this._connectionPool = connectionPool;
37082 return _this;
37083 }
37084
37085 /**
37086 * @inheritDoc
37087 */
37088
37089
37090 (0, _createClass3.default)(LeastConnectedLoadBalancingStrategy, [{
37091 key: 'selectReader',
37092 value: function selectReader(knownReaders) {
37093 return this._select(knownReaders, this._readersIndex);
37094 }
37095
37096 /**
37097 * @inheritDoc
37098 */
37099
37100 }, {
37101 key: 'selectWriter',
37102 value: function selectWriter(knownWriters) {
37103 return this._select(knownWriters, this._writersIndex);
37104 }
37105 }, {
37106 key: '_select',
37107 value: function _select(addresses, roundRobinIndex) {
37108 var length = addresses.length;
37109 if (length === 0) {
37110 return null;
37111 }
37112
37113 // choose start index for iteration in round-robin fashion
37114 var startIndex = roundRobinIndex.next(length);
37115 var index = startIndex;
37116
37117 var leastConnectedAddress = null;
37118 var leastActiveConnections = _maxSafeInteger2.default;
37119
37120 // iterate over the array to find least connected address
37121 do {
37122 var address = addresses[index];
37123 var activeConnections = this._connectionPool.activeResourceCount(address);
37124
37125 if (activeConnections < leastActiveConnections) {
37126 leastConnectedAddress = address;
37127 leastActiveConnections = activeConnections;
37128 }
37129
37130 // loop over to the start of the array when end is reached
37131 if (index === length - 1) {
37132 index = 0;
37133 } else {
37134 index++;
37135 }
37136 } while (index !== startIndex);
37137
37138 return leastConnectedAddress;
37139 }
37140 }]);
37141 return LeastConnectedLoadBalancingStrategy;
37142}(_loadBalancingStrategy2.default);
37143
37144exports.default = LeastConnectedLoadBalancingStrategy;
37145
37146},{"./load-balancing-strategy":346,"./round-robin-array-index":353,"babel-runtime/core-js/number/max-safe-integer":20,"babel-runtime/core-js/object/get-prototype-of":26,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34,"babel-runtime/helpers/inherits":37,"babel-runtime/helpers/possibleConstructorReturn":38}],346:[function(require,module,exports){
37147'use strict';
37148
37149Object.defineProperty(exports, "__esModule", {
37150 value: true
37151});
37152
37153var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
37154
37155var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
37156
37157var _createClass2 = require('babel-runtime/helpers/createClass');
37158
37159var _createClass3 = _interopRequireDefault(_createClass2);
37160
37161function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
37162
37163/**
37164 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
37165 *
37166 * This file is part of Neo4j.
37167 *
37168 * Licensed under the Apache License, Version 2.0 (the "License");
37169 * you may not use this file except in compliance with the License.
37170 * You may obtain a copy of the License at
37171 *
37172 * http://www.apache.org/licenses/LICENSE-2.0
37173 *
37174 * Unless required by applicable law or agreed to in writing, software
37175 * distributed under the License is distributed on an "AS IS" BASIS,
37176 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37177 * See the License for the specific language governing permissions and
37178 * limitations under the License.
37179 */
37180
37181/**
37182 * A facility to select most appropriate reader or writer among the given addresses for request processing.
37183 */
37184var LoadBalancingStrategy = function () {
37185 function LoadBalancingStrategy() {
37186 (0, _classCallCheck3.default)(this, LoadBalancingStrategy);
37187 }
37188
37189 (0, _createClass3.default)(LoadBalancingStrategy, [{
37190 key: 'selectReader',
37191
37192
37193 /**
37194 * Select next most appropriate reader from the list of given readers.
37195 * @param {string[]} knownReaders an array of currently known readers to select from.
37196 * @return {string} most appropriate reader or <code>null</code> if given array is empty.
37197 */
37198 value: function selectReader(knownReaders) {
37199 throw new Error('Abstract function');
37200 }
37201
37202 /**
37203 * Select next most appropriate writer from the list of given writers.
37204 * @param {string[]} knownWriters an array of currently known writers to select from.
37205 * @return {string} most appropriate writer or <code>null</code> if given array is empty.
37206 */
37207
37208 }, {
37209 key: 'selectWriter',
37210 value: function selectWriter(knownWriters) {
37211 throw new Error('Abstract function');
37212 }
37213 }]);
37214 return LoadBalancingStrategy;
37215}();
37216
37217exports.default = LoadBalancingStrategy;
37218
37219},{"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34}],347:[function(require,module,exports){
37220'use strict';
37221
37222Object.defineProperty(exports, "__esModule", {
37223 value: true
37224});
37225
37226var _packstreamV = require('./packstream-v1');
37227
37228var v1 = _interopRequireWildcard(_packstreamV);
37229
37230var _packstreamV2 = require('./packstream-v2');
37231
37232var v2 = _interopRequireWildcard(_packstreamV2);
37233
37234function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
37235
37236/**
37237 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
37238 *
37239 * This file is part of Neo4j.
37240 *
37241 * Licensed under the Apache License, Version 2.0 (the "License");
37242 * you may not use this file except in compliance with the License.
37243 * You may obtain a copy of the License at
37244 *
37245 * http://www.apache.org/licenses/LICENSE-2.0
37246 *
37247 * Unless required by applicable law or agreed to in writing, software
37248 * distributed under the License is distributed on an "AS IS" BASIS,
37249 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37250 * See the License for the specific language governing permissions and
37251 * limitations under the License.
37252 */
37253
37254var PACKER_CONSTRUCTORS_BY_VERSION = [null, v1.Packer, v2.Packer];
37255var UNPACKER_CONSTRUCTORS_BY_VERSION = [null, v1.Unpacker, v2.Unpacker];
37256
37257function createLatestPacker(chunker) {
37258 return createPackerForProtocolVersion(PACKER_CONSTRUCTORS_BY_VERSION.length - 1, chunker);
37259}
37260
37261function createLatestUnpacker(disableLosslessIntegers) {
37262 return createUnpackerForProtocolVersion(UNPACKER_CONSTRUCTORS_BY_VERSION.length - 1, disableLosslessIntegers);
37263}
37264
37265function createPackerForProtocolVersion(version, chunker) {
37266 var packerConstructor = PACKER_CONSTRUCTORS_BY_VERSION[version];
37267 if (!packerConstructor) {
37268 throw new Error('Packer can\'t be created for protocol version ' + version);
37269 }
37270 return new packerConstructor(chunker);
37271}
37272
37273function createUnpackerForProtocolVersion(version, disableLosslessIntegers) {
37274 var unpackerConstructor = UNPACKER_CONSTRUCTORS_BY_VERSION[version];
37275 if (!unpackerConstructor) {
37276 throw new Error('Unpacker can\'t be created for protocol version ' + version);
37277 }
37278 return new unpackerConstructor(disableLosslessIntegers);
37279}
37280
37281exports.default = {
37282 createLatestPacker: createLatestPacker,
37283 createLatestUnpacker: createLatestUnpacker,
37284 createPackerForProtocolVersion: createPackerForProtocolVersion,
37285 createUnpackerForProtocolVersion: createUnpackerForProtocolVersion
37286};
37287
37288},{"./packstream-v1":348,"./packstream-v2":349}],348:[function(require,module,exports){
37289'use strict';
37290
37291Object.defineProperty(exports, "__esModule", {
37292 value: true
37293});
37294exports.Structure = exports.Unpacker = exports.Packer = undefined;
37295
37296var _iterator = require('babel-runtime/core-js/symbol/iterator');
37297
37298var _iterator2 = _interopRequireDefault(_iterator);
37299
37300var _from = require('babel-runtime/core-js/array/from');
37301
37302var _from2 = _interopRequireDefault(_from);
37303
37304var _keys = require('babel-runtime/core-js/object/keys');
37305
37306var _keys2 = _interopRequireDefault(_keys);
37307
37308var _typeof2 = require('babel-runtime/helpers/typeof');
37309
37310var _typeof3 = _interopRequireDefault(_typeof2);
37311
37312var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
37313
37314var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
37315
37316var _createClass2 = require('babel-runtime/helpers/createClass');
37317
37318var _createClass3 = _interopRequireDefault(_createClass2);
37319
37320var _utf = require('./utf8');
37321
37322var _utf2 = _interopRequireDefault(_utf);
37323
37324var _integer = require('../integer');
37325
37326var _integer2 = _interopRequireDefault(_integer);
37327
37328var _error = require('./../error');
37329
37330var _chunking = require('./chunking');
37331
37332var _graphTypes = require('../graph-types');
37333
37334function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
37335
37336var TINY_STRING = 0x80; /**
37337 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
37338 *
37339 * This file is part of Neo4j.
37340 *
37341 * Licensed under the Apache License, Version 2.0 (the "License");
37342 * you may not use this file except in compliance with the License.
37343 * You may obtain a copy of the License at
37344 *
37345 * http://www.apache.org/licenses/LICENSE-2.0
37346 *
37347 * Unless required by applicable law or agreed to in writing, software
37348 * distributed under the License is distributed on an "AS IS" BASIS,
37349 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37350 * See the License for the specific language governing permissions and
37351 * limitations under the License.
37352 */
37353
37354var TINY_LIST = 0x90;
37355var TINY_MAP = 0xA0;
37356var TINY_STRUCT = 0xB0;
37357var NULL = 0xC0;
37358var FLOAT_64 = 0xC1;
37359var FALSE = 0xC2;
37360var TRUE = 0xC3;
37361var INT_8 = 0xC8;
37362var INT_16 = 0xC9;
37363var INT_32 = 0xCA;
37364var INT_64 = 0xCB;
37365var STRING_8 = 0xD0;
37366var STRING_16 = 0xD1;
37367var STRING_32 = 0xD2;
37368var LIST_8 = 0xD4;
37369var LIST_16 = 0xD5;
37370var LIST_32 = 0xD6;
37371var BYTES_8 = 0xCC;
37372var BYTES_16 = 0xCD;
37373var BYTES_32 = 0xCE;
37374var MAP_8 = 0xD8;
37375var MAP_16 = 0xD9;
37376var MAP_32 = 0xDA;
37377var STRUCT_8 = 0xDC;
37378var STRUCT_16 = 0xDD;
37379
37380var NODE = 0x4E;
37381var NODE_STRUCT_SIZE = 3;
37382
37383var RELATIONSHIP = 0x52;
37384var RELATIONSHIP_STRUCT_SIZE = 5;
37385
37386var UNBOUND_RELATIONSHIP = 0x72;
37387var UNBOUND_RELATIONSHIP_STRUCT_SIZE = 3;
37388
37389var PATH = 0x50;
37390var PATH_STRUCT_SIZE = 3;
37391
37392/**
37393 * A Structure have a signature and fields.
37394 * @access private
37395 */
37396
37397var Structure = function () {
37398 /**
37399 * Create new instance
37400 */
37401 function Structure(signature, fields) {
37402 (0, _classCallCheck3.default)(this, Structure);
37403
37404 this.signature = signature;
37405 this.fields = fields;
37406 }
37407
37408 (0, _createClass3.default)(Structure, [{
37409 key: 'toString',
37410 value: function toString() {
37411 var fieldStr = "";
37412 for (var i = 0; i < this.fields.length; i++) {
37413 if (i > 0) {
37414 fieldStr += ", ";
37415 }
37416 fieldStr += this.fields[i];
37417 }
37418 return "Structure(" + this.signature + ", [" + this.fields + "])";
37419 }
37420 }]);
37421 return Structure;
37422}();
37423
37424/**
37425 * Class to pack
37426 * @access private
37427 */
37428
37429
37430var Packer = function () {
37431
37432 /**
37433 * @constructor
37434 * @param {Chunker} channel the chunker backed by a network channel.
37435 */
37436 function Packer(channel) {
37437 (0, _classCallCheck3.default)(this, Packer);
37438
37439 this._ch = channel;
37440 this._byteArraysSupported = true;
37441 }
37442
37443 /**
37444 * Creates a packable function out of the provided value
37445 * @param x the value to pack
37446 * @param onError callback for the case when value cannot be packed
37447 * @returns Function
37448 */
37449
37450
37451 (0, _createClass3.default)(Packer, [{
37452 key: 'packable',
37453 value: function packable(x, onError) {
37454 var _this = this;
37455
37456 if (x === null) {
37457 return function () {
37458 return _this._ch.writeUInt8(NULL);
37459 };
37460 } else if (x === true) {
37461 return function () {
37462 return _this._ch.writeUInt8(TRUE);
37463 };
37464 } else if (x === false) {
37465 return function () {
37466 return _this._ch.writeUInt8(FALSE);
37467 };
37468 } else if (typeof x == "number") {
37469 return function () {
37470 return _this.packFloat(x);
37471 };
37472 } else if (typeof x == "string") {
37473 return function () {
37474 return _this.packString(x, onError);
37475 };
37476 } else if ((0, _integer.isInt)(x)) {
37477 return function () {
37478 return _this.packInteger(x);
37479 };
37480 } else if (x instanceof Int8Array) {
37481 return function () {
37482 return _this.packBytes(x, onError);
37483 };
37484 } else if (x instanceof Array) {
37485 return function () {
37486 _this.packListHeader(x.length, onError);
37487 for (var _i = 0; _i < x.length; _i++) {
37488 _this.packable(x[_i] === undefined ? null : x[_i], onError)();
37489 }
37490 };
37491 } else if (isIterable(x)) {
37492 return this.packableIterable(x, onError);
37493 } else if (x instanceof _graphTypes.Node) {
37494 return this._nonPackableValue('It is not allowed to pass nodes in query parameters, given: ' + x, onError);
37495 } else if (x instanceof _graphTypes.Relationship) {
37496 return this._nonPackableValue('It is not allowed to pass relationships in query parameters, given: ' + x, onError);
37497 } else if (x instanceof _graphTypes.Path) {
37498 return this._nonPackableValue('It is not allowed to pass paths in query parameters, given: ' + x, onError);
37499 } else if (x instanceof Structure) {
37500 var packableFields = [];
37501 for (var i = 0; i < x.fields.length; i++) {
37502 packableFields[i] = this.packable(x.fields[i], onError);
37503 }
37504 return function () {
37505 return _this.packStruct(x.signature, packableFields);
37506 };
37507 } else if ((typeof x === 'undefined' ? 'undefined' : (0, _typeof3.default)(x)) == "object") {
37508 return function () {
37509 var keys = (0, _keys2.default)(x);
37510
37511 var count = 0;
37512 for (var _i2 = 0; _i2 < keys.length; _i2++) {
37513 if (x[keys[_i2]] !== undefined) {
37514 count++;
37515 }
37516 }
37517 _this.packMapHeader(count, onError);
37518 for (var _i3 = 0; _i3 < keys.length; _i3++) {
37519 var key = keys[_i3];
37520 if (x[key] !== undefined) {
37521 _this.packString(key);
37522 _this.packable(x[key], onError)();
37523 }
37524 }
37525 };
37526 } else {
37527 return this._nonPackableValue('Unable to pack the given value: ' + x, onError);
37528 }
37529 }
37530 }, {
37531 key: 'packableIterable',
37532 value: function packableIterable(iterable, onError) {
37533 try {
37534 var array = (0, _from2.default)(iterable);
37535 return this.packable(array, onError);
37536 } catch (e) {
37537 // handle errors from iterable to array conversion
37538 onError((0, _error.newError)('Cannot pack given iterable, ' + e.message + ': ' + iterable));
37539 }
37540 }
37541
37542 /**
37543 * Packs a struct
37544 * @param signature the signature of the struct
37545 * @param packableFields the fields of the struct, make sure you call `packable on all fields`
37546 */
37547
37548 }, {
37549 key: 'packStruct',
37550 value: function packStruct(signature, packableFields, onError) {
37551 packableFields = packableFields || [];
37552 this.packStructHeader(packableFields.length, signature, onError);
37553 for (var i = 0; i < packableFields.length; i++) {
37554 packableFields[i]();
37555 }
37556 }
37557 }, {
37558 key: 'packInteger',
37559 value: function packInteger(x) {
37560 var high = x.high,
37561 low = x.low;
37562
37563 if (x.greaterThanOrEqual(-0x10) && x.lessThan(0x80)) {
37564 this._ch.writeInt8(low);
37565 } else if (x.greaterThanOrEqual(-0x80) && x.lessThan(-0x10)) {
37566 this._ch.writeUInt8(INT_8);
37567 this._ch.writeInt8(low);
37568 } else if (x.greaterThanOrEqual(-0x8000) && x.lessThan(0x8000)) {
37569 this._ch.writeUInt8(INT_16);
37570 this._ch.writeInt16(low);
37571 } else if (x.greaterThanOrEqual(-0x80000000) && x.lessThan(0x80000000)) {
37572 this._ch.writeUInt8(INT_32);
37573 this._ch.writeInt32(low);
37574 } else {
37575 this._ch.writeUInt8(INT_64);
37576 this._ch.writeInt32(high);
37577 this._ch.writeInt32(low);
37578 }
37579 }
37580 }, {
37581 key: 'packFloat',
37582 value: function packFloat(x) {
37583 this._ch.writeUInt8(FLOAT_64);
37584 this._ch.writeFloat64(x);
37585 }
37586 }, {
37587 key: 'packString',
37588 value: function packString(x, onError) {
37589 var bytes = _utf2.default.encode(x);
37590 var size = bytes.length;
37591 if (size < 0x10) {
37592 this._ch.writeUInt8(TINY_STRING | size);
37593 this._ch.writeBytes(bytes);
37594 } else if (size < 0x100) {
37595 this._ch.writeUInt8(STRING_8);
37596 this._ch.writeUInt8(size);
37597 this._ch.writeBytes(bytes);
37598 } else if (size < 0x10000) {
37599 this._ch.writeUInt8(STRING_16);
37600 this._ch.writeUInt8(size / 256 >> 0);
37601 this._ch.writeUInt8(size % 256);
37602 this._ch.writeBytes(bytes);
37603 } else if (size < 0x100000000) {
37604 this._ch.writeUInt8(STRING_32);
37605 this._ch.writeUInt8((size / 16777216 >> 0) % 256);
37606 this._ch.writeUInt8((size / 65536 >> 0) % 256);
37607 this._ch.writeUInt8((size / 256 >> 0) % 256);
37608 this._ch.writeUInt8(size % 256);
37609 this._ch.writeBytes(bytes);
37610 } else {
37611 onError((0, _error.newError)("UTF-8 strings of size " + size + " are not supported"));
37612 }
37613 }
37614 }, {
37615 key: 'packListHeader',
37616 value: function packListHeader(size, onError) {
37617 if (size < 0x10) {
37618 this._ch.writeUInt8(TINY_LIST | size);
37619 } else if (size < 0x100) {
37620 this._ch.writeUInt8(LIST_8);
37621 this._ch.writeUInt8(size);
37622 } else if (size < 0x10000) {
37623 this._ch.writeUInt8(LIST_16);
37624 this._ch.writeUInt8((size / 256 >> 0) % 256);
37625 this._ch.writeUInt8(size % 256);
37626 } else if (size < 0x100000000) {
37627 this._ch.writeUInt8(LIST_32);
37628 this._ch.writeUInt8((size / 16777216 >> 0) % 256);
37629 this._ch.writeUInt8((size / 65536 >> 0) % 256);
37630 this._ch.writeUInt8((size / 256 >> 0) % 256);
37631 this._ch.writeUInt8(size % 256);
37632 } else {
37633 onError((0, _error.newError)("Lists of size " + size + " are not supported"));
37634 }
37635 }
37636 }, {
37637 key: 'packBytes',
37638 value: function packBytes(array, onError) {
37639 if (this._byteArraysSupported) {
37640 this.packBytesHeader(array.length, onError);
37641 for (var i = 0; i < array.length; i++) {
37642 this._ch.writeInt8(array[i]);
37643 }
37644 } else {
37645 onError((0, _error.newError)("Byte arrays are not supported by the database this driver is connected to"));
37646 }
37647 }
37648 }, {
37649 key: 'packBytesHeader',
37650 value: function packBytesHeader(size, onError) {
37651 if (size < 0x100) {
37652 this._ch.writeUInt8(BYTES_8);
37653 this._ch.writeUInt8(size);
37654 } else if (size < 0x10000) {
37655 this._ch.writeUInt8(BYTES_16);
37656 this._ch.writeUInt8((size / 256 >> 0) % 256);
37657 this._ch.writeUInt8(size % 256);
37658 } else if (size < 0x100000000) {
37659 this._ch.writeUInt8(BYTES_32);
37660 this._ch.writeUInt8((size / 16777216 >> 0) % 256);
37661 this._ch.writeUInt8((size / 65536 >> 0) % 256);
37662 this._ch.writeUInt8((size / 256 >> 0) % 256);
37663 this._ch.writeUInt8(size % 256);
37664 } else {
37665 onError((0, _error.newError)('Byte arrays of size ' + size + ' are not supported'));
37666 }
37667 }
37668 }, {
37669 key: 'packMapHeader',
37670 value: function packMapHeader(size, onError) {
37671 if (size < 0x10) {
37672 this._ch.writeUInt8(TINY_MAP | size);
37673 } else if (size < 0x100) {
37674 this._ch.writeUInt8(MAP_8);
37675 this._ch.writeUInt8(size);
37676 } else if (size < 0x10000) {
37677 this._ch.writeUInt8(MAP_16);
37678 this._ch.writeUInt8(size / 256 >> 0);
37679 this._ch.writeUInt8(size % 256);
37680 } else if (size < 0x100000000) {
37681 this._ch.writeUInt8(MAP_32);
37682 this._ch.writeUInt8((size / 16777216 >> 0) % 256);
37683 this._ch.writeUInt8((size / 65536 >> 0) % 256);
37684 this._ch.writeUInt8((size / 256 >> 0) % 256);
37685 this._ch.writeUInt8(size % 256);
37686 } else {
37687 onError((0, _error.newError)("Maps of size " + size + " are not supported"));
37688 }
37689 }
37690 }, {
37691 key: 'packStructHeader',
37692 value: function packStructHeader(size, signature, onError) {
37693 if (size < 0x10) {
37694 this._ch.writeUInt8(TINY_STRUCT | size);
37695 this._ch.writeUInt8(signature);
37696 } else if (size < 0x100) {
37697 this._ch.writeUInt8(STRUCT_8);
37698 this._ch.writeUInt8(size);
37699 this._ch.writeUInt8(signature);
37700 } else if (size < 0x10000) {
37701 this._ch.writeUInt8(STRUCT_16);
37702 this._ch.writeUInt8(size / 256 >> 0);
37703 this._ch.writeUInt8(size % 256);
37704 } else {
37705 onError((0, _error.newError)("Structures of size " + size + " are not supported"));
37706 }
37707 }
37708 }, {
37709 key: 'disableByteArrays',
37710 value: function disableByteArrays() {
37711 this._byteArraysSupported = false;
37712 }
37713 }, {
37714 key: '_nonPackableValue',
37715 value: function _nonPackableValue(message, onError) {
37716 if (onError) {
37717 onError((0, _error.newError)(message, _error.PROTOCOL_ERROR));
37718 }
37719 return function () {
37720 return undefined;
37721 };
37722 }
37723 }]);
37724 return Packer;
37725}();
37726
37727/**
37728 * Class to unpack
37729 * @access private
37730 */
37731
37732
37733var Unpacker = function () {
37734
37735 /**
37736 * @constructor
37737 * @param {boolean} disableLosslessIntegers if this unpacker should convert all received integers to native JS numbers.
37738 */
37739 function Unpacker() {
37740 var disableLosslessIntegers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
37741 (0, _classCallCheck3.default)(this, Unpacker);
37742
37743 this._disableLosslessIntegers = disableLosslessIntegers;
37744 }
37745
37746 (0, _createClass3.default)(Unpacker, [{
37747 key: 'unpack',
37748 value: function unpack(buffer) {
37749 var marker = buffer.readUInt8();
37750 var markerHigh = marker & 0xF0;
37751 var markerLow = marker & 0x0F;
37752
37753 if (marker == NULL) {
37754 return null;
37755 }
37756
37757 var boolean = this._unpackBoolean(marker);
37758 if (boolean !== null) {
37759 return boolean;
37760 }
37761
37762 var numberOrInteger = this._unpackNumberOrInteger(marker, buffer);
37763 if (numberOrInteger !== null) {
37764 if (this._disableLosslessIntegers && (0, _integer.isInt)(numberOrInteger)) {
37765 return numberOrInteger.toNumberOrInfinity();
37766 }
37767 return numberOrInteger;
37768 }
37769
37770 var string = this._unpackString(marker, markerHigh, markerLow, buffer);
37771 if (string !== null) {
37772 return string;
37773 }
37774
37775 var list = this._unpackList(marker, markerHigh, markerLow, buffer);
37776 if (list !== null) {
37777 return list;
37778 }
37779
37780 var byteArray = this._unpackByteArray(marker, buffer);
37781 if (byteArray !== null) {
37782 return byteArray;
37783 }
37784
37785 var map = this._unpackMap(marker, markerHigh, markerLow, buffer);
37786 if (map !== null) {
37787 return map;
37788 }
37789
37790 var struct = this._unpackStruct(marker, markerHigh, markerLow, buffer);
37791 if (struct !== null) {
37792 return struct;
37793 }
37794
37795 throw (0, _error.newError)('Unknown packed value with marker ' + marker.toString(16));
37796 }
37797 }, {
37798 key: 'unpackInteger',
37799 value: function unpackInteger(buffer) {
37800 var marker = buffer.readUInt8();
37801 var result = this._unpackInteger(marker, buffer);
37802 if (result == null) {
37803 throw (0, _error.newError)('Unable to unpack integer value with marker ' + marker.toString(16));
37804 }
37805 return result;
37806 }
37807 }, {
37808 key: '_unpackBoolean',
37809 value: function _unpackBoolean(marker) {
37810 if (marker == TRUE) {
37811 return true;
37812 } else if (marker == FALSE) {
37813 return false;
37814 } else {
37815 return null;
37816 }
37817 }
37818 }, {
37819 key: '_unpackNumberOrInteger',
37820 value: function _unpackNumberOrInteger(marker, buffer) {
37821 if (marker == FLOAT_64) {
37822 return buffer.readFloat64();
37823 } else {
37824 return this._unpackInteger(marker, buffer);
37825 }
37826 }
37827 }, {
37828 key: '_unpackInteger',
37829 value: function _unpackInteger(marker, buffer) {
37830 if (marker >= 0 && marker < 128) {
37831 return (0, _integer.int)(marker);
37832 } else if (marker >= 240 && marker < 256) {
37833 return (0, _integer.int)(marker - 256);
37834 } else if (marker == INT_8) {
37835 return (0, _integer.int)(buffer.readInt8());
37836 } else if (marker == INT_16) {
37837 return (0, _integer.int)(buffer.readInt16());
37838 } else if (marker == INT_32) {
37839 var b = buffer.readInt32();
37840 return (0, _integer.int)(b);
37841 } else if (marker == INT_64) {
37842 var high = buffer.readInt32();
37843 var low = buffer.readInt32();
37844 return new _integer2.default(low, high);
37845 } else {
37846 return null;
37847 }
37848 }
37849 }, {
37850 key: '_unpackString',
37851 value: function _unpackString(marker, markerHigh, markerLow, buffer) {
37852 if (markerHigh == TINY_STRING) {
37853 return _utf2.default.decode(buffer, markerLow);
37854 } else if (marker == STRING_8) {
37855 return _utf2.default.decode(buffer, buffer.readUInt8());
37856 } else if (marker == STRING_16) {
37857 return _utf2.default.decode(buffer, buffer.readUInt16());
37858 } else if (marker == STRING_32) {
37859 return _utf2.default.decode(buffer, buffer.readUInt32());
37860 } else {
37861 return null;
37862 }
37863 }
37864 }, {
37865 key: '_unpackList',
37866 value: function _unpackList(marker, markerHigh, markerLow, buffer) {
37867 if (markerHigh == TINY_LIST) {
37868 return this._unpackListWithSize(markerLow, buffer);
37869 } else if (marker == LIST_8) {
37870 return this._unpackListWithSize(buffer.readUInt8(), buffer);
37871 } else if (marker == LIST_16) {
37872 return this._unpackListWithSize(buffer.readUInt16(), buffer);
37873 } else if (marker == LIST_32) {
37874 return this._unpackListWithSize(buffer.readUInt32(), buffer);
37875 } else {
37876 return null;
37877 }
37878 }
37879 }, {
37880 key: '_unpackListWithSize',
37881 value: function _unpackListWithSize(size, buffer) {
37882 var value = [];
37883 for (var i = 0; i < size; i++) {
37884 value.push(this.unpack(buffer));
37885 }
37886 return value;
37887 }
37888 }, {
37889 key: '_unpackByteArray',
37890 value: function _unpackByteArray(marker, buffer) {
37891 if (marker == BYTES_8) {
37892 return this._unpackByteArrayWithSize(buffer.readUInt8(), buffer);
37893 } else if (marker == BYTES_16) {
37894 return this._unpackByteArrayWithSize(buffer.readUInt16(), buffer);
37895 } else if (marker == BYTES_32) {
37896 return this._unpackByteArrayWithSize(buffer.readUInt32(), buffer);
37897 } else {
37898 return null;
37899 }
37900 }
37901 }, {
37902 key: '_unpackByteArrayWithSize',
37903 value: function _unpackByteArrayWithSize(size, buffer) {
37904 var value = new Int8Array(size);
37905 for (var i = 0; i < size; i++) {
37906 value[i] = buffer.readInt8();
37907 }
37908 return value;
37909 }
37910 }, {
37911 key: '_unpackMap',
37912 value: function _unpackMap(marker, markerHigh, markerLow, buffer) {
37913 if (markerHigh == TINY_MAP) {
37914 return this._unpackMapWithSize(markerLow, buffer);
37915 } else if (marker == MAP_8) {
37916 return this._unpackMapWithSize(buffer.readUInt8(), buffer);
37917 } else if (marker == MAP_16) {
37918 return this._unpackMapWithSize(buffer.readUInt16(), buffer);
37919 } else if (marker == MAP_32) {
37920 return this._unpackMapWithSize(buffer.readUInt32(), buffer);
37921 } else {
37922 return null;
37923 }
37924 }
37925 }, {
37926 key: '_unpackMapWithSize',
37927 value: function _unpackMapWithSize(size, buffer) {
37928 var value = {};
37929 for (var i = 0; i < size; i++) {
37930 var key = this.unpack(buffer);
37931 value[key] = this.unpack(buffer);
37932 }
37933 return value;
37934 }
37935 }, {
37936 key: '_unpackStruct',
37937 value: function _unpackStruct(marker, markerHigh, markerLow, buffer) {
37938 if (markerHigh == TINY_STRUCT) {
37939 return this._unpackStructWithSize(markerLow, buffer);
37940 } else if (marker == STRUCT_8) {
37941 return this._unpackStructWithSize(buffer.readUInt8(), buffer);
37942 } else if (marker == STRUCT_16) {
37943 return this._unpackStructWithSize(buffer.readUInt16(), buffer);
37944 } else {
37945 return null;
37946 }
37947 }
37948 }, {
37949 key: '_unpackStructWithSize',
37950 value: function _unpackStructWithSize(structSize, buffer) {
37951 var signature = buffer.readUInt8();
37952 if (signature == NODE) {
37953 return this._unpackNode(structSize, buffer);
37954 } else if (signature == RELATIONSHIP) {
37955 return this._unpackRelationship(structSize, buffer);
37956 } else if (signature == UNBOUND_RELATIONSHIP) {
37957 return this._unpackUnboundRelationship(structSize, buffer);
37958 } else if (signature == PATH) {
37959 return this._unpackPath(structSize, buffer);
37960 } else {
37961 return this._unpackUnknownStruct(signature, structSize, buffer);
37962 }
37963 }
37964 }, {
37965 key: '_unpackNode',
37966 value: function _unpackNode(structSize, buffer) {
37967 this._verifyStructSize('Node', NODE_STRUCT_SIZE, structSize);
37968
37969 return new _graphTypes.Node(this.unpack(buffer), // Identity
37970 this.unpack(buffer), // Labels
37971 this.unpack(buffer) // Properties
37972 );
37973 }
37974 }, {
37975 key: '_unpackRelationship',
37976 value: function _unpackRelationship(structSize, buffer) {
37977 this._verifyStructSize('Relationship', RELATIONSHIP_STRUCT_SIZE, structSize);
37978
37979 return new _graphTypes.Relationship(this.unpack(buffer), // Identity
37980 this.unpack(buffer), // Start Node Identity
37981 this.unpack(buffer), // End Node Identity
37982 this.unpack(buffer), // Type
37983 this.unpack(buffer) // Properties
37984 );
37985 }
37986 }, {
37987 key: '_unpackUnboundRelationship',
37988 value: function _unpackUnboundRelationship(structSize, buffer) {
37989 this._verifyStructSize('UnboundRelationship', UNBOUND_RELATIONSHIP_STRUCT_SIZE, structSize);
37990
37991 return new _graphTypes.UnboundRelationship(this.unpack(buffer), // Identity
37992 this.unpack(buffer), // Type
37993 this.unpack(buffer) // Properties
37994 );
37995 }
37996 }, {
37997 key: '_unpackPath',
37998 value: function _unpackPath(structSize, buffer) {
37999 this._verifyStructSize('Path', PATH_STRUCT_SIZE, structSize);
38000
38001 var nodes = this.unpack(buffer);
38002 var rels = this.unpack(buffer);
38003 var sequence = this.unpack(buffer);
38004
38005 var segments = [];
38006 var prevNode = nodes[0];
38007
38008 for (var i = 0; i < sequence.length; i += 2) {
38009 var nextNode = nodes[sequence[i + 1]];
38010 var relIndex = sequence[i];
38011 var rel = void 0;
38012
38013 if (relIndex > 0) {
38014 rel = rels[relIndex - 1];
38015 if (rel instanceof _graphTypes.UnboundRelationship) {
38016 // To avoid duplication, relationships in a path do not contain
38017 // information about their start and end nodes, that's instead
38018 // inferred from the path sequence. This is us inferring (and,
38019 // for performance reasons remembering) the start/end of a rel.
38020 rels[relIndex - 1] = rel = rel.bind(prevNode.identity, nextNode.identity);
38021 }
38022 } else {
38023 rel = rels[-relIndex - 1];
38024 if (rel instanceof _graphTypes.UnboundRelationship) {
38025 // See above
38026 rels[-relIndex - 1] = rel = rel.bind(nextNode.identity, prevNode.identity);
38027 }
38028 }
38029 // Done hydrating one path segment.
38030 segments.push(new _graphTypes.PathSegment(prevNode, rel, nextNode));
38031 prevNode = nextNode;
38032 }
38033 return new _graphTypes.Path(nodes[0], nodes[nodes.length - 1], segments);
38034 }
38035 }, {
38036 key: '_unpackUnknownStruct',
38037 value: function _unpackUnknownStruct(signature, structSize, buffer) {
38038 var result = new Structure(signature, []);
38039 for (var i = 0; i < structSize; i++) {
38040 result.fields.push(this.unpack(buffer));
38041 }
38042 return result;
38043 }
38044 }, {
38045 key: '_verifyStructSize',
38046 value: function _verifyStructSize(structName, expectedSize, actualSize) {
38047 if (expectedSize !== actualSize) {
38048 throw (0, _error.newError)('Wrong struct size for ' + structName + ', expected ' + expectedSize + ' but was ' + actualSize, _error.PROTOCOL_ERROR);
38049 }
38050 }
38051 }]);
38052 return Unpacker;
38053}();
38054
38055function isIterable(obj) {
38056 if (obj == null) {
38057 return false;
38058 }
38059 return typeof obj[_iterator2.default] === 'function';
38060}
38061
38062exports.Packer = Packer;
38063exports.Unpacker = Unpacker;
38064exports.Structure = Structure;
38065
38066},{"../graph-types":325,"../integer":327,"./../error":324,"./chunking":333,"./utf8":362,"babel-runtime/core-js/array/from":15,"babel-runtime/core-js/object/keys":27,"babel-runtime/core-js/symbol/iterator":32,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34,"babel-runtime/helpers/typeof":41}],349:[function(require,module,exports){
38067'use strict';
38068
38069Object.defineProperty(exports, "__esModule", {
38070 value: true
38071});
38072exports.Unpacker = exports.Packer = undefined;
38073
38074var _freeze = require('babel-runtime/core-js/object/freeze');
38075
38076var _freeze2 = _interopRequireDefault(_freeze);
38077
38078var _create = require('babel-runtime/core-js/object/create');
38079
38080var _create2 = _interopRequireDefault(_create);
38081
38082var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
38083
38084var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
38085
38086var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
38087
38088var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
38089
38090var _createClass2 = require('babel-runtime/helpers/createClass');
38091
38092var _createClass3 = _interopRequireDefault(_createClass2);
38093
38094var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
38095
38096var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
38097
38098var _get2 = require('babel-runtime/helpers/get');
38099
38100var _get3 = _interopRequireDefault(_get2);
38101
38102var _inherits2 = require('babel-runtime/helpers/inherits');
38103
38104var _inherits3 = _interopRequireDefault(_inherits2);
38105
38106var _packstreamV = require('./packstream-v1');
38107
38108var v1 = _interopRequireWildcard(_packstreamV);
38109
38110var _spatialTypes = require('../spatial-types');
38111
38112var _temporalTypes = require('../temporal-types');
38113
38114var _integer = require('../integer');
38115
38116var _temporalUtil = require('../internal/temporal-util');
38117
38118function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
38119
38120function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
38121
38122var POINT_2D = 0x58; /**
38123 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
38124 *
38125 * This file is part of Neo4j.
38126 *
38127 * Licensed under the Apache License, Version 2.0 (the "License");
38128 * you may not use this file except in compliance with the License.
38129 * You may obtain a copy of the License at
38130 *
38131 * http://www.apache.org/licenses/LICENSE-2.0
38132 *
38133 * Unless required by applicable law or agreed to in writing, software
38134 * distributed under the License is distributed on an "AS IS" BASIS,
38135 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
38136 * See the License for the specific language governing permissions and
38137 * limitations under the License.
38138 */
38139
38140var POINT_2D_STRUCT_SIZE = 3;
38141
38142var POINT_3D = 0x59;
38143var POINT_3D_STRUCT_SIZE = 4;
38144
38145var DURATION = 0x45;
38146var DURATION_STRUCT_SIZE = 4;
38147
38148var LOCAL_TIME = 0x74;
38149var LOCAL_TIME_STRUCT_SIZE = 1;
38150
38151var TIME = 0x54;
38152var TIME_STRUCT_SIZE = 2;
38153
38154var DATE = 0x44;
38155var DATE_STRUCT_SIZE = 1;
38156
38157var LOCAL_DATE_TIME = 0x64;
38158var LOCAL_DATE_TIME_STRUCT_SIZE = 2;
38159
38160var DATE_TIME_WITH_ZONE_OFFSET = 0x46;
38161var DATE_TIME_WITH_ZONE_OFFSET_STRUCT_SIZE = 3;
38162
38163var DATE_TIME_WITH_ZONE_ID = 0x66;
38164var DATE_TIME_WITH_ZONE_ID_STRUCT_SIZE = 3;
38165
38166var Packer = exports.Packer = function (_v1$Packer) {
38167 (0, _inherits3.default)(Packer, _v1$Packer);
38168
38169 /**
38170 * @constructor
38171 * @param {Chunker} chunker the chunker backed by a network channel.
38172 */
38173 function Packer(chunker) {
38174 (0, _classCallCheck3.default)(this, Packer);
38175 return (0, _possibleConstructorReturn3.default)(this, (Packer.__proto__ || (0, _getPrototypeOf2.default)(Packer)).call(this, chunker));
38176 }
38177
38178 (0, _createClass3.default)(Packer, [{
38179 key: 'disableByteArrays',
38180 value: function disableByteArrays() {
38181 throw new Error('Bolt V2 should always support byte arrays');
38182 }
38183 }, {
38184 key: 'packable',
38185 value: function packable(obj, onError) {
38186 var _this2 = this;
38187
38188 if ((0, _spatialTypes.isPoint)(obj)) {
38189 return function () {
38190 return packPoint(obj, _this2, onError);
38191 };
38192 } else if ((0, _temporalTypes.isDuration)(obj)) {
38193 return function () {
38194 return packDuration(obj, _this2, onError);
38195 };
38196 } else if ((0, _temporalTypes.isLocalTime)(obj)) {
38197 return function () {
38198 return packLocalTime(obj, _this2, onError);
38199 };
38200 } else if ((0, _temporalTypes.isTime)(obj)) {
38201 return function () {
38202 return packTime(obj, _this2, onError);
38203 };
38204 } else if ((0, _temporalTypes.isDate)(obj)) {
38205 return function () {
38206 return packDate(obj, _this2, onError);
38207 };
38208 } else if ((0, _temporalTypes.isLocalDateTime)(obj)) {
38209 return function () {
38210 return packLocalDateTime(obj, _this2, onError);
38211 };
38212 } else if ((0, _temporalTypes.isDateTime)(obj)) {
38213 return function () {
38214 return packDateTime(obj, _this2, onError);
38215 };
38216 } else {
38217 return (0, _get3.default)(Packer.prototype.__proto__ || (0, _getPrototypeOf2.default)(Packer.prototype), 'packable', this).call(this, obj, onError);
38218 }
38219 }
38220 }]);
38221 return Packer;
38222}(v1.Packer);
38223
38224var Unpacker = exports.Unpacker = function (_v1$Unpacker) {
38225 (0, _inherits3.default)(Unpacker, _v1$Unpacker);
38226
38227 /**
38228 * @constructor
38229 * @param {boolean} disableLosslessIntegers if this unpacker should convert all received integers to native JS numbers.
38230 */
38231 function Unpacker() {
38232 var disableLosslessIntegers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
38233 (0, _classCallCheck3.default)(this, Unpacker);
38234 return (0, _possibleConstructorReturn3.default)(this, (Unpacker.__proto__ || (0, _getPrototypeOf2.default)(Unpacker)).call(this, disableLosslessIntegers));
38235 }
38236
38237 (0, _createClass3.default)(Unpacker, [{
38238 key: '_unpackUnknownStruct',
38239 value: function _unpackUnknownStruct(signature, structSize, buffer) {
38240 if (signature == POINT_2D) {
38241 return unpackPoint2D(this, structSize, buffer);
38242 } else if (signature == POINT_3D) {
38243 return unpackPoint3D(this, structSize, buffer);
38244 } else if (signature == DURATION) {
38245 return unpackDuration(this, structSize, buffer);
38246 } else if (signature == LOCAL_TIME) {
38247 return unpackLocalTime(this, structSize, buffer, this._disableLosslessIntegers);
38248 } else if (signature == TIME) {
38249 return unpackTime(this, structSize, buffer, this._disableLosslessIntegers);
38250 } else if (signature == DATE) {
38251 return unpackDate(this, structSize, buffer, this._disableLosslessIntegers);
38252 } else if (signature == LOCAL_DATE_TIME) {
38253 return unpackLocalDateTime(this, structSize, buffer, this._disableLosslessIntegers);
38254 } else if (signature == DATE_TIME_WITH_ZONE_OFFSET) {
38255 return unpackDateTimeWithZoneOffset(this, structSize, buffer, this._disableLosslessIntegers);
38256 } else if (signature == DATE_TIME_WITH_ZONE_ID) {
38257 return unpackDateTimeWithZoneId(this, structSize, buffer, this._disableLosslessIntegers);
38258 } else {
38259 return (0, _get3.default)(Unpacker.prototype.__proto__ || (0, _getPrototypeOf2.default)(Unpacker.prototype), '_unpackUnknownStruct', this).call(this, signature, structSize, buffer, this._disableLosslessIntegers);
38260 }
38261 }
38262 }]);
38263 return Unpacker;
38264}(v1.Unpacker);
38265
38266/**
38267 * Pack given 2D or 3D point.
38268 * @param {Point} point the point value to pack.
38269 * @param {Packer} packer the packer to use.
38270 * @param {function} onError the error callback.
38271 */
38272
38273
38274function packPoint(point, packer, onError) {
38275 var is2DPoint = point.z === null || point.z === undefined;
38276 if (is2DPoint) {
38277 packPoint2D(point, packer, onError);
38278 } else {
38279 packPoint3D(point, packer, onError);
38280 }
38281}
38282
38283/**
38284 * Pack given 2D point.
38285 * @param {Point} point the point value to pack.
38286 * @param {Packer} packer the packer to use.
38287 * @param {function} onError the error callback.
38288 */
38289function packPoint2D(point, packer, onError) {
38290 var packableStructFields = [packer.packable((0, _integer.int)(point.srid), onError), packer.packable(point.x, onError), packer.packable(point.y, onError)];
38291 packer.packStruct(POINT_2D, packableStructFields, onError);
38292}
38293
38294/**
38295 * Pack given 3D point.
38296 * @param {Point} point the point value to pack.
38297 * @param {Packer} packer the packer to use.
38298 * @param {function} onError the error callback.
38299 */
38300function packPoint3D(point, packer, onError) {
38301 var packableStructFields = [packer.packable((0, _integer.int)(point.srid), onError), packer.packable(point.x, onError), packer.packable(point.y, onError), packer.packable(point.z, onError)];
38302 packer.packStruct(POINT_3D, packableStructFields, onError);
38303}
38304
38305/**
38306 * Unpack 2D point value using the given unpacker.
38307 * @param {Unpacker} unpacker the unpacker to use.
38308 * @param {number} structSize the retrieved struct size.
38309 * @param {BaseBuffer} buffer the buffer to unpack from.
38310 * @return {Point} the unpacked 2D point value.
38311 */
38312function unpackPoint2D(unpacker, structSize, buffer) {
38313 unpacker._verifyStructSize('Point2D', POINT_2D_STRUCT_SIZE, structSize);
38314
38315 return new _spatialTypes.Point(unpacker.unpack(buffer), // srid
38316 unpacker.unpack(buffer), // x
38317 unpacker.unpack(buffer), // y
38318 undefined // z
38319 );
38320}
38321
38322/**
38323 * Unpack 3D point value using the given unpacker.
38324 * @param {Unpacker} unpacker the unpacker to use.
38325 * @param {number} structSize the retrieved struct size.
38326 * @param {BaseBuffer} buffer the buffer to unpack from.
38327 * @return {Point} the unpacked 3D point value.
38328 */
38329function unpackPoint3D(unpacker, structSize, buffer) {
38330 unpacker._verifyStructSize('Point3D', POINT_3D_STRUCT_SIZE, structSize);
38331
38332 return new _spatialTypes.Point(unpacker.unpack(buffer), // srid
38333 unpacker.unpack(buffer), // x
38334 unpacker.unpack(buffer), // y
38335 unpacker.unpack(buffer) // z
38336 );
38337}
38338
38339/**
38340 * Pack given duration.
38341 * @param {Duration} value the duration value to pack.
38342 * @param {Packer} packer the packer to use.
38343 * @param {function} onError the error callback.
38344 */
38345function packDuration(value, packer, onError) {
38346 var months = (0, _integer.int)(value.months);
38347 var days = (0, _integer.int)(value.days);
38348 var seconds = (0, _integer.int)(value.seconds);
38349 var nanoseconds = (0, _integer.int)(value.nanoseconds);
38350
38351 var packableStructFields = [packer.packable(months, onError), packer.packable(days, onError), packer.packable(seconds, onError), packer.packable(nanoseconds, onError)];
38352 packer.packStruct(DURATION, packableStructFields, onError);
38353}
38354
38355/**
38356 * Unpack duration value using the given unpacker.
38357 * @param {Unpacker} unpacker the unpacker to use.
38358 * @param {number} structSize the retrieved struct size.
38359 * @param {BaseBuffer} buffer the buffer to unpack from.
38360 * @return {Duration} the unpacked duration value.
38361 */
38362function unpackDuration(unpacker, structSize, buffer) {
38363 unpacker._verifyStructSize('Duration', DURATION_STRUCT_SIZE, structSize);
38364
38365 var months = unpacker.unpack(buffer);
38366 var days = unpacker.unpack(buffer);
38367 var seconds = unpacker.unpack(buffer);
38368 var nanoseconds = unpacker.unpack(buffer);
38369
38370 return new _temporalTypes.Duration(months, days, seconds, nanoseconds);
38371}
38372
38373/**
38374 * Pack given local time.
38375 * @param {LocalTime} value the local time value to pack.
38376 * @param {Packer} packer the packer to use.
38377 * @param {function} onError the error callback.
38378 */
38379function packLocalTime(value, packer, onError) {
38380 var nanoOfDay = (0, _temporalUtil.localTimeToNanoOfDay)(value.hour, value.minute, value.second, value.nanosecond);
38381
38382 var packableStructFields = [packer.packable(nanoOfDay, onError)];
38383 packer.packStruct(LOCAL_TIME, packableStructFields, onError);
38384}
38385
38386/**
38387 * Unpack local time value using the given unpacker.
38388 * @param {Unpacker} unpacker the unpacker to use.
38389 * @param {number} structSize the retrieved struct size.
38390 * @param {BaseBuffer} buffer the buffer to unpack from.
38391 * @param {boolean} disableLosslessIntegers if integer properties in the result local time should be native JS numbers.
38392 * @return {LocalTime} the unpacked local time value.
38393 */
38394function unpackLocalTime(unpacker, structSize, buffer, disableLosslessIntegers) {
38395 unpacker._verifyStructSize('LocalTime', LOCAL_TIME_STRUCT_SIZE, structSize);
38396
38397 var nanoOfDay = unpacker.unpackInteger(buffer);
38398 var result = (0, _temporalUtil.nanoOfDayToLocalTime)(nanoOfDay);
38399 return convertIntegerPropsIfNeeded(result, disableLosslessIntegers);
38400}
38401
38402/**
38403 * Pack given time.
38404 * @param {Time} value the time value to pack.
38405 * @param {Packer} packer the packer to use.
38406 * @param {function} onError the error callback.
38407 */
38408function packTime(value, packer, onError) {
38409 var nanoOfDay = (0, _temporalUtil.localTimeToNanoOfDay)(value.hour, value.minute, value.second, value.nanosecond);
38410 var offsetSeconds = (0, _integer.int)(value.timeZoneOffsetSeconds);
38411
38412 var packableStructFields = [packer.packable(nanoOfDay, onError), packer.packable(offsetSeconds, onError)];
38413 packer.packStruct(TIME, packableStructFields, onError);
38414}
38415
38416/**
38417 * Unpack time value using the given unpacker.
38418 * @param {Unpacker} unpacker the unpacker to use.
38419 * @param {number} structSize the retrieved struct size.
38420 * @param {BaseBuffer} buffer the buffer to unpack from.
38421 * @param {boolean} disableLosslessIntegers if integer properties in the result time should be native JS numbers.
38422 * @return {Time} the unpacked time value.
38423 */
38424function unpackTime(unpacker, structSize, buffer, disableLosslessIntegers) {
38425 unpacker._verifyStructSize('Time', TIME_STRUCT_SIZE, structSize);
38426
38427 var nanoOfDay = unpacker.unpackInteger(buffer);
38428 var offsetSeconds = unpacker.unpackInteger(buffer);
38429
38430 var localTime = (0, _temporalUtil.nanoOfDayToLocalTime)(nanoOfDay);
38431 var result = new _temporalTypes.Time(localTime.hour, localTime.minute, localTime.second, localTime.nanosecond, offsetSeconds);
38432 return convertIntegerPropsIfNeeded(result, disableLosslessIntegers);
38433}
38434
38435/**
38436 * Pack given neo4j date.
38437 * @param {Date} value the date value to pack.
38438 * @param {Packer} packer the packer to use.
38439 * @param {function} onError the error callback.
38440 */
38441function packDate(value, packer, onError) {
38442 var epochDay = (0, _temporalUtil.dateToEpochDay)(value.year, value.month, value.day);
38443
38444 var packableStructFields = [packer.packable(epochDay, onError)];
38445 packer.packStruct(DATE, packableStructFields, onError);
38446}
38447
38448/**
38449 * Unpack neo4j date value using the given unpacker.
38450 * @param {Unpacker} unpacker the unpacker to use.
38451 * @param {number} structSize the retrieved struct size.
38452 * @param {BaseBuffer} buffer the buffer to unpack from.
38453 * @param {boolean} disableLosslessIntegers if integer properties in the result date should be native JS numbers.
38454 * @return {Date} the unpacked neo4j date value.
38455 */
38456function unpackDate(unpacker, structSize, buffer, disableLosslessIntegers) {
38457 unpacker._verifyStructSize('Date', DATE_STRUCT_SIZE, structSize);
38458
38459 var epochDay = unpacker.unpackInteger(buffer);
38460 var result = (0, _temporalUtil.epochDayToDate)(epochDay);
38461 return convertIntegerPropsIfNeeded(result, disableLosslessIntegers);
38462}
38463
38464/**
38465 * Pack given local date time.
38466 * @param {LocalDateTime} value the local date time value to pack.
38467 * @param {Packer} packer the packer to use.
38468 * @param {function} onError the error callback.
38469 */
38470function packLocalDateTime(value, packer, onError) {
38471 var epochSecond = (0, _temporalUtil.localDateTimeToEpochSecond)(value.year, value.month, value.day, value.hour, value.minute, value.second, value.nanosecond);
38472 var nano = (0, _integer.int)(value.nanosecond);
38473
38474 var packableStructFields = [packer.packable(epochSecond, onError), packer.packable(nano, onError)];
38475 packer.packStruct(LOCAL_DATE_TIME, packableStructFields, onError);
38476}
38477
38478/**
38479 * Unpack local date time value using the given unpacker.
38480 * @param {Unpacker} unpacker the unpacker to use.
38481 * @param {number} structSize the retrieved struct size.
38482 * @param {BaseBuffer} buffer the buffer to unpack from.
38483 * @param {boolean} disableLosslessIntegers if integer properties in the result local date-time should be native JS numbers.
38484 * @return {LocalDateTime} the unpacked local date time value.
38485 */
38486function unpackLocalDateTime(unpacker, structSize, buffer, disableLosslessIntegers) {
38487 unpacker._verifyStructSize('LocalDateTime', LOCAL_DATE_TIME_STRUCT_SIZE, structSize);
38488
38489 var epochSecond = unpacker.unpackInteger(buffer);
38490 var nano = unpacker.unpackInteger(buffer);
38491 var result = (0, _temporalUtil.epochSecondAndNanoToLocalDateTime)(epochSecond, nano);
38492 return convertIntegerPropsIfNeeded(result, disableLosslessIntegers);
38493}
38494
38495/**
38496 * Pack given date time.
38497 * @param {DateTime} value the date time value to pack.
38498 * @param {Packer} packer the packer to use.
38499 * @param {function} onError the error callback.
38500 */
38501function packDateTime(value, packer, onError) {
38502 if (value.timeZoneId) {
38503 packDateTimeWithZoneId(value, packer, onError);
38504 } else {
38505 packDateTimeWithZoneOffset(value, packer, onError);
38506 }
38507}
38508
38509/**
38510 * Pack given date time with zone offset.
38511 * @param {DateTime} value the date time value to pack.
38512 * @param {Packer} packer the packer to use.
38513 * @param {function} onError the error callback.
38514 */
38515function packDateTimeWithZoneOffset(value, packer, onError) {
38516 var epochSecond = (0, _temporalUtil.localDateTimeToEpochSecond)(value.year, value.month, value.day, value.hour, value.minute, value.second, value.nanosecond);
38517 var nano = (0, _integer.int)(value.nanosecond);
38518 var timeZoneOffsetSeconds = (0, _integer.int)(value.timeZoneOffsetSeconds);
38519
38520 var packableStructFields = [packer.packable(epochSecond, onError), packer.packable(nano, onError), packer.packable(timeZoneOffsetSeconds, onError)];
38521 packer.packStruct(DATE_TIME_WITH_ZONE_OFFSET, packableStructFields, onError);
38522}
38523
38524/**
38525 * Unpack date time with zone offset value using the given unpacker.
38526 * @param {Unpacker} unpacker the unpacker to use.
38527 * @param {number} structSize the retrieved struct size.
38528 * @param {BaseBuffer} buffer the buffer to unpack from.
38529 * @param {boolean} disableLosslessIntegers if integer properties in the result date-time should be native JS numbers.
38530 * @return {DateTime} the unpacked date time with zone offset value.
38531 */
38532function unpackDateTimeWithZoneOffset(unpacker, structSize, buffer, disableLosslessIntegers) {
38533 unpacker._verifyStructSize('DateTimeWithZoneOffset', DATE_TIME_WITH_ZONE_OFFSET_STRUCT_SIZE, structSize);
38534
38535 var epochSecond = unpacker.unpackInteger(buffer);
38536 var nano = unpacker.unpackInteger(buffer);
38537 var timeZoneOffsetSeconds = unpacker.unpackInteger(buffer);
38538
38539 var localDateTime = (0, _temporalUtil.epochSecondAndNanoToLocalDateTime)(epochSecond, nano);
38540 var result = new _temporalTypes.DateTime(localDateTime.year, localDateTime.month, localDateTime.day, localDateTime.hour, localDateTime.minute, localDateTime.second, localDateTime.nanosecond, timeZoneOffsetSeconds, null);
38541 return convertIntegerPropsIfNeeded(result, disableLosslessIntegers);
38542}
38543
38544/**
38545 * Pack given date time with zone id.
38546 * @param {DateTime} value the date time value to pack.
38547 * @param {Packer} packer the packer to use.
38548 * @param {function} onError the error callback.
38549 */
38550function packDateTimeWithZoneId(value, packer, onError) {
38551 var epochSecond = (0, _temporalUtil.localDateTimeToEpochSecond)(value.year, value.month, value.day, value.hour, value.minute, value.second, value.nanosecond);
38552 var nano = (0, _integer.int)(value.nanosecond);
38553 var timeZoneId = value.timeZoneId;
38554
38555 var packableStructFields = [packer.packable(epochSecond, onError), packer.packable(nano, onError), packer.packable(timeZoneId, onError)];
38556 packer.packStruct(DATE_TIME_WITH_ZONE_ID, packableStructFields, onError);
38557}
38558
38559/**
38560 * Unpack date time with zone id value using the given unpacker.
38561 * @param {Unpacker} unpacker the unpacker to use.
38562 * @param {number} structSize the retrieved struct size.
38563 * @param {BaseBuffer} buffer the buffer to unpack from.
38564 * @param {boolean} disableLosslessIntegers if integer properties in the result date-time should be native JS numbers.
38565 * @return {DateTime} the unpacked date time with zone id value.
38566 */
38567function unpackDateTimeWithZoneId(unpacker, structSize, buffer, disableLosslessIntegers) {
38568 unpacker._verifyStructSize('DateTimeWithZoneId', DATE_TIME_WITH_ZONE_ID_STRUCT_SIZE, structSize);
38569
38570 var epochSecond = unpacker.unpackInteger(buffer);
38571 var nano = unpacker.unpackInteger(buffer);
38572 var timeZoneId = unpacker.unpack(buffer);
38573
38574 var localDateTime = (0, _temporalUtil.epochSecondAndNanoToLocalDateTime)(epochSecond, nano);
38575 var result = new _temporalTypes.DateTime(localDateTime.year, localDateTime.month, localDateTime.day, localDateTime.hour, localDateTime.minute, localDateTime.second, localDateTime.nanosecond, null, timeZoneId);
38576 return convertIntegerPropsIfNeeded(result, disableLosslessIntegers);
38577}
38578
38579function convertIntegerPropsIfNeeded(obj, disableLosslessIntegers) {
38580 if (!disableLosslessIntegers) {
38581 return obj;
38582 }
38583
38584 var clone = (0, _create2.default)((0, _getPrototypeOf2.default)(obj));
38585 for (var prop in obj) {
38586 if (obj.hasOwnProperty(prop)) {
38587 var value = obj[prop];
38588 clone[prop] = (0, _integer.isInt)(value) ? value.toNumberOrInfinity() : value;
38589 }
38590 }
38591 (0, _freeze2.default)(clone);
38592 return clone;
38593}
38594
38595},{"../integer":327,"../internal/temporal-util":359,"../spatial-types":369,"../temporal-types":370,"./packstream-v1":348,"babel-runtime/core-js/object/create":22,"babel-runtime/core-js/object/freeze":24,"babel-runtime/core-js/object/get-prototype-of":26,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34,"babel-runtime/helpers/get":36,"babel-runtime/helpers/inherits":37,"babel-runtime/helpers/possibleConstructorReturn":38}],350:[function(require,module,exports){
38596'use strict';
38597
38598Object.defineProperty(exports, "__esModule", {
38599 value: true
38600});
38601exports.DEFAULT_ACQUISITION_TIMEOUT = exports.DEFAULT_MAX_SIZE = undefined;
38602
38603var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
38604
38605var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
38606
38607var _createClass2 = require('babel-runtime/helpers/createClass');
38608
38609var _createClass3 = _interopRequireDefault(_createClass2);
38610
38611function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
38612
38613/**
38614 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
38615 *
38616 * This file is part of Neo4j.
38617 *
38618 * Licensed under the Apache License, Version 2.0 (the "License");
38619 * you may not use this file except in compliance with the License.
38620 * You may obtain a copy of the License at
38621 *
38622 * http://www.apache.org/licenses/LICENSE-2.0
38623 *
38624 * Unless required by applicable law or agreed to in writing, software
38625 * distributed under the License is distributed on an "AS IS" BASIS,
38626 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
38627 * See the License for the specific language governing permissions and
38628 * limitations under the License.
38629 */
38630
38631var DEFAULT_MAX_SIZE = 100;
38632var DEFAULT_ACQUISITION_TIMEOUT = 60 * 1000; // 60 seconds
38633
38634var PoolConfig = function () {
38635 function PoolConfig(maxSize, acquisitionTimeout) {
38636 (0, _classCallCheck3.default)(this, PoolConfig);
38637
38638 this.maxSize = valueOrDefault(maxSize, DEFAULT_MAX_SIZE);
38639 this.acquisitionTimeout = valueOrDefault(acquisitionTimeout, DEFAULT_ACQUISITION_TIMEOUT);
38640 }
38641
38642 (0, _createClass3.default)(PoolConfig, null, [{
38643 key: 'defaultConfig',
38644 value: function defaultConfig() {
38645 return new PoolConfig(DEFAULT_MAX_SIZE, DEFAULT_ACQUISITION_TIMEOUT);
38646 }
38647 }, {
38648 key: 'fromDriverConfig',
38649 value: function fromDriverConfig(config) {
38650 var maxIdleSizeConfigured = isConfigured(config.connectionPoolSize);
38651 var maxSizeConfigured = isConfigured(config.maxConnectionPoolSize);
38652
38653 var maxSize = void 0;
38654
38655 if (maxSizeConfigured) {
38656 // correct size setting is set - use it's value
38657 maxSize = config.maxConnectionPoolSize;
38658 } else if (maxIdleSizeConfigured) {
38659 // deprecated size setting is set - use it's value
38660 console.warn('WARNING: neo4j-driver setting "connectionPoolSize" is deprecated, please use "maxConnectionPoolSize" instead');
38661 maxSize = config.connectionPoolSize;
38662 } else {
38663 maxSize = DEFAULT_MAX_SIZE;
38664 }
38665
38666 var acquisitionTimeoutConfigured = isConfigured(config.connectionAcquisitionTimeout);
38667 var acquisitionTimeout = acquisitionTimeoutConfigured ? config.connectionAcquisitionTimeout : DEFAULT_ACQUISITION_TIMEOUT;
38668
38669 return new PoolConfig(maxSize, acquisitionTimeout);
38670 }
38671 }]);
38672 return PoolConfig;
38673}();
38674
38675exports.default = PoolConfig;
38676
38677
38678function valueOrDefault(value, defaultValue) {
38679 return value === 0 || value ? value : defaultValue;
38680}
38681
38682function isConfigured(value) {
38683 return value === 0 || value;
38684}
38685
38686exports.DEFAULT_MAX_SIZE = DEFAULT_MAX_SIZE;
38687exports.DEFAULT_ACQUISITION_TIMEOUT = DEFAULT_ACQUISITION_TIMEOUT;
38688
38689},{"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34}],351:[function(require,module,exports){
38690'use strict';
38691
38692Object.defineProperty(exports, "__esModule", {
38693 value: true
38694});
38695
38696var _keys = require('babel-runtime/core-js/object/keys');
38697
38698var _keys2 = _interopRequireDefault(_keys);
38699
38700var _promise = require('babel-runtime/core-js/promise');
38701
38702var _promise2 = _interopRequireDefault(_promise);
38703
38704var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
38705
38706var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
38707
38708var _createClass2 = require('babel-runtime/helpers/createClass');
38709
38710var _createClass3 = _interopRequireDefault(_createClass2);
38711
38712var _poolConfig = require('./pool-config');
38713
38714var _poolConfig2 = _interopRequireDefault(_poolConfig);
38715
38716var _error = require('../error');
38717
38718function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
38719
38720/**
38721 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
38722 *
38723 * This file is part of Neo4j.
38724 *
38725 * Licensed under the Apache License, Version 2.0 (the "License");
38726 * you may not use this file except in compliance with the License.
38727 * You may obtain a copy of the License at
38728 *
38729 * http://www.apache.org/licenses/LICENSE-2.0
38730 *
38731 * Unless required by applicable law or agreed to in writing, software
38732 * distributed under the License is distributed on an "AS IS" BASIS,
38733 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
38734 * See the License for the specific language governing permissions and
38735 * limitations under the License.
38736 */
38737
38738var Pool = function () {
38739 /**
38740 * @param {function} create an allocation function that creates a new resource. It's given
38741 * a single argument, a function that will return the resource to
38742 * the pool if invoked, which is meant to be called on .dispose
38743 * or .close or whatever mechanism the resource uses to finalize.
38744 * @param {function} destroy called with the resource when it is evicted from this pool
38745 * @param {function} validate called at various times (like when an instance is acquired and
38746 * when it is returned). If this returns false, the resource will
38747 * be evicted
38748 * @param {PoolConfig} config configuration for the new driver.
38749 */
38750 function Pool(create) {
38751 var destroy = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
38752 return true;
38753 };
38754 var validate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {
38755 return true;
38756 };
38757 var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _poolConfig2.default.defaultConfig();
38758 (0, _classCallCheck3.default)(this, Pool);
38759
38760 this._create = create;
38761 this._destroy = destroy;
38762 this._validate = validate;
38763 this._maxSize = config.maxSize;
38764 this._acquisitionTimeout = config.acquisitionTimeout;
38765 this._pools = {};
38766 this._acquireRequests = {};
38767 this._activeResourceCounts = {};
38768 this._release = this._release.bind(this);
38769 }
38770
38771 /**
38772 * Acquire and idle resource fom the pool or create a new one.
38773 * @param {string} key the resource key.
38774 * @return {object} resource that is ready to use.
38775 */
38776
38777
38778 (0, _createClass3.default)(Pool, [{
38779 key: 'acquire',
38780 value: function acquire(key) {
38781 var _this = this;
38782
38783 var resource = this._acquire(key);
38784
38785 if (resource) {
38786 resourceAcquired(key, this._activeResourceCounts);
38787
38788 return _promise2.default.resolve(resource);
38789 }
38790
38791 // We're out of resources and will try to acquire later on when an existing resource is released.
38792 var allRequests = this._acquireRequests;
38793 var requests = allRequests[key];
38794 if (!requests) {
38795 allRequests[key] = [];
38796 }
38797
38798 return new _promise2.default(function (resolve, reject) {
38799 var request = void 0;
38800
38801 var timeoutId = setTimeout(function () {
38802 allRequests[key] = allRequests[key].filter(function (item) {
38803 return item !== request;
38804 });
38805 reject((0, _error.newError)('Connection acquisition timed out in ' + _this._acquisitionTimeout + ' ms.'));
38806 }, _this._acquisitionTimeout);
38807
38808 request = new PendingRequest(resolve, timeoutId);
38809 allRequests[key].push(request);
38810 });
38811 }
38812
38813 /**
38814 * Destroy all idle resources for the given key.
38815 * @param {string} key the resource key to purge.
38816 */
38817
38818 }, {
38819 key: 'purge',
38820 value: function purge(key) {
38821 var pool = this._pools[key] || [];
38822 while (pool.length) {
38823 var resource = pool.pop();
38824 this._destroy(resource);
38825 }
38826 delete this._pools[key];
38827 }
38828
38829 /**
38830 * Destroy all idle resources in this pool.
38831 */
38832
38833 }, {
38834 key: 'purgeAll',
38835 value: function purgeAll() {
38836 var _this2 = this;
38837
38838 (0, _keys2.default)(this._pools).forEach(function (key) {
38839 return _this2.purge(key);
38840 });
38841 }
38842
38843 /**
38844 * Check if this pool contains resources for the given key.
38845 * @param {string} key the resource key to check.
38846 * @return {boolean} <code>true</code> when pool contains entries for the given key, <code>false</code> otherwise.
38847 */
38848
38849 }, {
38850 key: 'has',
38851 value: function has(key) {
38852 return key in this._pools;
38853 }
38854
38855 /**
38856 * Get count of active (checked out of the pool) resources for the given key.
38857 * @param {string} key the resource key to check.
38858 * @return {number} count of resources acquired by clients.
38859 */
38860
38861 }, {
38862 key: 'activeResourceCount',
38863 value: function activeResourceCount(key) {
38864 return this._activeResourceCounts[key] || 0;
38865 }
38866 }, {
38867 key: '_acquire',
38868 value: function _acquire(key) {
38869 var pool = this._pools[key];
38870 if (!pool) {
38871 pool = [];
38872 this._pools[key] = pool;
38873 }
38874 while (pool.length) {
38875 var resource = pool.pop();
38876
38877 if (this._validate(resource)) {
38878 // idle resource is valid and can be acquired
38879 return resource;
38880 } else {
38881 this._destroy(resource);
38882 }
38883 }
38884
38885 if (this._maxSize && this.activeResourceCount(key) >= this._maxSize) {
38886 return null;
38887 }
38888
38889 // there exist no idle valid resources, create a new one for acquisition
38890 return this._create(key, this._release);
38891 }
38892 }, {
38893 key: '_release',
38894 value: function _release(key, resource) {
38895 var pool = this._pools[key];
38896
38897 if (pool) {
38898 // there exist idle connections for the given key
38899 if (!this._validate(resource)) {
38900 this._destroy(resource);
38901 } else {
38902 pool.push(resource);
38903 }
38904 } else {
38905 // key has been purged, don't put it back, just destroy the resource
38906 this._destroy(resource);
38907 }
38908
38909 // check if there are any pending requests
38910 var requests = this._acquireRequests[key];
38911 if (requests) {
38912 var pending = requests.shift();
38913
38914 if (pending) {
38915 var _resource = this._acquire(key);
38916 if (_resource) {
38917 pending.resolve(_resource);
38918
38919 return;
38920 }
38921 } else {
38922 delete this._acquireRequests[key];
38923 }
38924 }
38925
38926 resourceReleased(key, this._activeResourceCounts);
38927 }
38928 }]);
38929 return Pool;
38930}();
38931
38932/**
38933 * Increment active (checked out of the pool) resource counter.
38934 * @param {string} key the resource group identifier (server address for connections).
38935 * @param {Object.<string, number>} activeResourceCounts the object holding active counts per key.
38936 */
38937
38938
38939function resourceAcquired(key, activeResourceCounts) {
38940 var currentCount = activeResourceCounts[key] || 0;
38941 activeResourceCounts[key] = currentCount + 1;
38942}
38943
38944/**
38945 * Decrement active (checked out of the pool) resource counter.
38946 * @param {string} key the resource group identifier (server address for connections).
38947 * @param {Object.<string, number>} activeResourceCounts the object holding active counts per key.
38948 */
38949function resourceReleased(key, activeResourceCounts) {
38950 var currentCount = activeResourceCounts[key] || 0;
38951 var nextCount = currentCount - 1;
38952
38953 if (nextCount > 0) {
38954 activeResourceCounts[key] = nextCount;
38955 } else {
38956 delete activeResourceCounts[key];
38957 }
38958}
38959
38960var PendingRequest = function () {
38961 function PendingRequest(resolve, timeoutId) {
38962 (0, _classCallCheck3.default)(this, PendingRequest);
38963
38964 this._resolve = resolve;
38965 this._timeoutId = timeoutId;
38966 }
38967
38968 (0, _createClass3.default)(PendingRequest, [{
38969 key: 'resolve',
38970 value: function resolve(resource) {
38971 clearTimeout(this._timeoutId);
38972 this._resolve(resource);
38973 }
38974 }]);
38975 return PendingRequest;
38976}();
38977
38978exports.default = Pool;
38979
38980},{"../error":324,"./pool-config":350,"babel-runtime/core-js/object/keys":27,"babel-runtime/core-js/promise":29,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34}],352:[function(require,module,exports){
38981'use strict';
38982
38983Object.defineProperty(exports, "__esModule", {
38984 value: true
38985});
38986
38987var _stringify = require('babel-runtime/core-js/json/stringify');
38988
38989var _stringify2 = _interopRequireDefault(_stringify);
38990
38991var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
38992
38993var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
38994
38995var _createClass2 = require('babel-runtime/helpers/createClass');
38996
38997var _createClass3 = _interopRequireDefault(_createClass2);
38998
38999var _routingTable = require('./routing-table');
39000
39001var _routingTable2 = _interopRequireDefault(_routingTable);
39002
39003var _error = require('../error');
39004
39005function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39006
39007/**
39008 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
39009 *
39010 * This file is part of Neo4j.
39011 *
39012 * Licensed under the Apache License, Version 2.0 (the "License");
39013 * you may not use this file except in compliance with the License.
39014 * You may obtain a copy of the License at
39015 *
39016 * http://www.apache.org/licenses/LICENSE-2.0
39017 *
39018 * Unless required by applicable law or agreed to in writing, software
39019 * distributed under the License is distributed on an "AS IS" BASIS,
39020 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
39021 * See the License for the specific language governing permissions and
39022 * limitations under the License.
39023 */
39024
39025var Rediscovery = function () {
39026
39027 /**
39028 * @constructor
39029 * @param {RoutingUtil} routingUtil the util to use.
39030 */
39031 function Rediscovery(routingUtil) {
39032 (0, _classCallCheck3.default)(this, Rediscovery);
39033
39034 this._routingUtil = routingUtil;
39035 }
39036
39037 /**
39038 * Try to fetch new routing table from the given router.
39039 * @param {Session} session the session to use.
39040 * @param {string} routerAddress the URL of the router.
39041 * @return {Promise<RoutingTable>} promise resolved with new routing table or null when connection error happened.
39042 */
39043
39044
39045 (0, _createClass3.default)(Rediscovery, [{
39046 key: 'lookupRoutingTableOnRouter',
39047 value: function lookupRoutingTableOnRouter(session, routerAddress) {
39048 var _this = this;
39049
39050 return this._routingUtil.callRoutingProcedure(session, routerAddress).then(function (records) {
39051 if (records === null) {
39052 // connection error happened, unable to retrieve routing table from this router, next one should be queried
39053 return null;
39054 }
39055
39056 if (records.length !== 1) {
39057 throw (0, _error.newError)('Illegal response from router "' + routerAddress + '". ' + 'Received ' + records.length + ' records but expected only one.\n' + (0, _stringify2.default)(records), _error.PROTOCOL_ERROR);
39058 }
39059
39060 var record = records[0];
39061
39062 var expirationTime = _this._routingUtil.parseTtl(record, routerAddress);
39063
39064 var _routingUtil$parseSer = _this._routingUtil.parseServers(record, routerAddress),
39065 routers = _routingUtil$parseSer.routers,
39066 readers = _routingUtil$parseSer.readers,
39067 writers = _routingUtil$parseSer.writers;
39068
39069 Rediscovery._assertNonEmpty(routers, 'routers', routerAddress);
39070 Rediscovery._assertNonEmpty(readers, 'readers', routerAddress);
39071 // case with no writers is processed higher in the promise chain because only RoutingDriver knows
39072 // how to deal with such table and how to treat router that returned such table
39073
39074 return new _routingTable2.default(routers, readers, writers, expirationTime);
39075 });
39076 }
39077 }], [{
39078 key: '_assertNonEmpty',
39079 value: function _assertNonEmpty(serverAddressesArray, serversName, routerAddress) {
39080 if (serverAddressesArray.length === 0) {
39081 throw (0, _error.newError)('Received no ' + serversName + ' from router ' + routerAddress, _error.PROTOCOL_ERROR);
39082 }
39083 }
39084 }]);
39085 return Rediscovery;
39086}();
39087
39088exports.default = Rediscovery;
39089
39090},{"../error":324,"./routing-table":355,"babel-runtime/core-js/json/stringify":18,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34}],353:[function(require,module,exports){
39091"use strict";
39092
39093Object.defineProperty(exports, "__esModule", {
39094 value: true
39095});
39096
39097var _maxSafeInteger = require("babel-runtime/core-js/number/max-safe-integer");
39098
39099var _maxSafeInteger2 = _interopRequireDefault(_maxSafeInteger);
39100
39101var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
39102
39103var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
39104
39105var _createClass2 = require("babel-runtime/helpers/createClass");
39106
39107var _createClass3 = _interopRequireDefault(_createClass2);
39108
39109function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39110
39111/**
39112 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
39113 *
39114 * This file is part of Neo4j.
39115 *
39116 * Licensed under the Apache License, Version 2.0 (the "License");
39117 * you may not use this file except in compliance with the License.
39118 * You may obtain a copy of the License at
39119 *
39120 * http://www.apache.org/licenses/LICENSE-2.0
39121 *
39122 * Unless required by applicable law or agreed to in writing, software
39123 * distributed under the License is distributed on an "AS IS" BASIS,
39124 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
39125 * See the License for the specific language governing permissions and
39126 * limitations under the License.
39127 */
39128
39129var RoundRobinArrayIndex = function () {
39130
39131 /**
39132 * @constructor
39133 * @param {number} [initialOffset=0] the initial offset for round robin.
39134 */
39135 function RoundRobinArrayIndex(initialOffset) {
39136 (0, _classCallCheck3.default)(this, RoundRobinArrayIndex);
39137
39138 this._offset = initialOffset || 0;
39139 }
39140
39141 /**
39142 * Get next index for an array with given length.
39143 * @param {number} arrayLength the array length.
39144 * @return {number} index in the array.
39145 */
39146
39147
39148 (0, _createClass3.default)(RoundRobinArrayIndex, [{
39149 key: "next",
39150 value: function next(arrayLength) {
39151 if (arrayLength === 0) {
39152 return -1;
39153 }
39154
39155 var nextOffset = this._offset;
39156 this._offset += 1;
39157 if (this._offset === _maxSafeInteger2.default) {
39158 this._offset = 0;
39159 }
39160
39161 return nextOffset % arrayLength;
39162 }
39163 }]);
39164 return RoundRobinArrayIndex;
39165}();
39166
39167exports.default = RoundRobinArrayIndex;
39168
39169},{"babel-runtime/core-js/number/max-safe-integer":20,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34}],354:[function(require,module,exports){
39170'use strict';
39171
39172Object.defineProperty(exports, "__esModule", {
39173 value: true
39174});
39175exports.ROUND_ROBIN_STRATEGY_NAME = undefined;
39176
39177var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
39178
39179var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
39180
39181var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
39182
39183var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
39184
39185var _createClass2 = require('babel-runtime/helpers/createClass');
39186
39187var _createClass3 = _interopRequireDefault(_createClass2);
39188
39189var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
39190
39191var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
39192
39193var _inherits2 = require('babel-runtime/helpers/inherits');
39194
39195var _inherits3 = _interopRequireDefault(_inherits2);
39196
39197var _roundRobinArrayIndex = require('./round-robin-array-index');
39198
39199var _roundRobinArrayIndex2 = _interopRequireDefault(_roundRobinArrayIndex);
39200
39201var _loadBalancingStrategy = require('./load-balancing-strategy');
39202
39203var _loadBalancingStrategy2 = _interopRequireDefault(_loadBalancingStrategy);
39204
39205function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39206
39207/**
39208 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
39209 *
39210 * This file is part of Neo4j.
39211 *
39212 * Licensed under the Apache License, Version 2.0 (the "License");
39213 * you may not use this file except in compliance with the License.
39214 * You may obtain a copy of the License at
39215 *
39216 * http://www.apache.org/licenses/LICENSE-2.0
39217 *
39218 * Unless required by applicable law or agreed to in writing, software
39219 * distributed under the License is distributed on an "AS IS" BASIS,
39220 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
39221 * See the License for the specific language governing permissions and
39222 * limitations under the License.
39223 */
39224
39225var ROUND_ROBIN_STRATEGY_NAME = exports.ROUND_ROBIN_STRATEGY_NAME = 'round_robin';
39226
39227var RoundRobinLoadBalancingStrategy = function (_LoadBalancingStrateg) {
39228 (0, _inherits3.default)(RoundRobinLoadBalancingStrategy, _LoadBalancingStrateg);
39229
39230 function RoundRobinLoadBalancingStrategy() {
39231 (0, _classCallCheck3.default)(this, RoundRobinLoadBalancingStrategy);
39232
39233 var _this = (0, _possibleConstructorReturn3.default)(this, (RoundRobinLoadBalancingStrategy.__proto__ || (0, _getPrototypeOf2.default)(RoundRobinLoadBalancingStrategy)).call(this));
39234
39235 _this._readersIndex = new _roundRobinArrayIndex2.default();
39236 _this._writersIndex = new _roundRobinArrayIndex2.default();
39237 return _this;
39238 }
39239
39240 /**
39241 * @inheritDoc
39242 */
39243
39244
39245 (0, _createClass3.default)(RoundRobinLoadBalancingStrategy, [{
39246 key: 'selectReader',
39247 value: function selectReader(knownReaders) {
39248 return this._select(knownReaders, this._readersIndex);
39249 }
39250
39251 /**
39252 * @inheritDoc
39253 */
39254
39255 }, {
39256 key: 'selectWriter',
39257 value: function selectWriter(knownWriters) {
39258 return this._select(knownWriters, this._writersIndex);
39259 }
39260 }, {
39261 key: '_select',
39262 value: function _select(addresses, roundRobinIndex) {
39263 var length = addresses.length;
39264 if (length === 0) {
39265 return null;
39266 }
39267 var index = roundRobinIndex.next(length);
39268 return addresses[index];
39269 }
39270 }]);
39271 return RoundRobinLoadBalancingStrategy;
39272}(_loadBalancingStrategy2.default);
39273
39274exports.default = RoundRobinLoadBalancingStrategy;
39275
39276},{"./load-balancing-strategy":346,"./round-robin-array-index":353,"babel-runtime/core-js/object/get-prototype-of":26,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34,"babel-runtime/helpers/inherits":37,"babel-runtime/helpers/possibleConstructorReturn":38}],355:[function(require,module,exports){
39277'use strict';
39278
39279Object.defineProperty(exports, "__esModule", {
39280 value: true
39281});
39282
39283var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
39284
39285var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
39286
39287var _from = require('babel-runtime/core-js/array/from');
39288
39289var _from2 = _interopRequireDefault(_from);
39290
39291var _set = require('babel-runtime/core-js/set');
39292
39293var _set2 = _interopRequireDefault(_set);
39294
39295var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
39296
39297var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
39298
39299var _createClass2 = require('babel-runtime/helpers/createClass');
39300
39301var _createClass3 = _interopRequireDefault(_createClass2);
39302
39303var _integer = require('../integer');
39304
39305var _driver = require('../driver');
39306
39307function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39308
39309/**
39310 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
39311 *
39312 * This file is part of Neo4j.
39313 *
39314 * Licensed under the Apache License, Version 2.0 (the "License");
39315 * you may not use this file except in compliance with the License.
39316 * You may obtain a copy of the License at
39317 *
39318 * http://www.apache.org/licenses/LICENSE-2.0
39319 *
39320 * Unless required by applicable law or agreed to in writing, software
39321 * distributed under the License is distributed on an "AS IS" BASIS,
39322 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
39323 * See the License for the specific language governing permissions and
39324 * limitations under the License.
39325 */
39326var MIN_ROUTERS = 1;
39327
39328var RoutingTable = function () {
39329 function RoutingTable(routers, readers, writers, expirationTime) {
39330 (0, _classCallCheck3.default)(this, RoutingTable);
39331
39332 this.routers = routers || [];
39333 this.readers = readers || [];
39334 this.writers = writers || [];
39335 this.expirationTime = expirationTime || (0, _integer.int)(0);
39336 }
39337
39338 (0, _createClass3.default)(RoutingTable, [{
39339 key: 'forget',
39340 value: function forget(address) {
39341 // Don't remove it from the set of routers, since that might mean we lose our ability to re-discover,
39342 // just remove it from the set of readers and writers, so that we don't use it for actual work without
39343 // performing discovery first.
39344
39345 this.readers = removeFromArray(this.readers, address);
39346 this.writers = removeFromArray(this.writers, address);
39347 }
39348 }, {
39349 key: 'forgetRouter',
39350 value: function forgetRouter(address) {
39351 this.routers = removeFromArray(this.routers, address);
39352 }
39353 }, {
39354 key: 'forgetWriter',
39355 value: function forgetWriter(address) {
39356 this.writers = removeFromArray(this.writers, address);
39357 }
39358 }, {
39359 key: 'serversDiff',
39360 value: function serversDiff(otherRoutingTable) {
39361 var oldServers = new _set2.default(this._allServers());
39362 var newServers = otherRoutingTable._allServers();
39363 newServers.forEach(function (newServer) {
39364 return oldServers.delete(newServer);
39365 });
39366 return (0, _from2.default)(oldServers);
39367 }
39368
39369 /**
39370 * Check if this routing table is fresh to perform the required operation.
39371 * @param {string} accessMode the type of operation. Allowed values are {@link READ} and {@link WRITE}.
39372 * @return {boolean} <code>true</code> when this table contains servers to serve the required operation,
39373 * <code>false</code> otherwise.
39374 */
39375
39376 }, {
39377 key: 'isStaleFor',
39378 value: function isStaleFor(accessMode) {
39379 return this.expirationTime.lessThan(Date.now()) || this.routers.length < MIN_ROUTERS || accessMode === _driver.READ && this.readers.length === 0 || accessMode === _driver.WRITE && this.writers.length === 0;
39380 }
39381 }, {
39382 key: '_allServers',
39383 value: function _allServers() {
39384 return [].concat((0, _toConsumableArray3.default)(this.routers), (0, _toConsumableArray3.default)(this.readers), (0, _toConsumableArray3.default)(this.writers));
39385 }
39386 }, {
39387 key: 'toString',
39388 value: function toString() {
39389 return 'RoutingTable[' + ('expirationTime=' + this.expirationTime + ', ') + ('routers=[' + this.routers + '], ') + ('readers=[' + this.readers + '], ') + ('writers=[' + this.writers + ']]');
39390 }
39391 }]);
39392 return RoutingTable;
39393}();
39394
39395/**
39396 * Remove all occurrences of the element in the array.
39397 * @param {Array} array the array to filter.
39398 * @param {object} element the element to remove.
39399 * @return {Array} new filtered array.
39400 */
39401
39402
39403exports.default = RoutingTable;
39404function removeFromArray(array, element) {
39405 return array.filter(function (item) {
39406 return item !== element;
39407 });
39408}
39409
39410},{"../driver":323,"../integer":327,"babel-runtime/core-js/array/from":15,"babel-runtime/core-js/set":30,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34,"babel-runtime/helpers/toConsumableArray":40}],356:[function(require,module,exports){
39411'use strict';
39412
39413Object.defineProperty(exports, "__esModule", {
39414 value: true
39415});
39416
39417var _from = require('babel-runtime/core-js/array/from');
39418
39419var _from2 = _interopRequireDefault(_from);
39420
39421var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
39422
39423var _defineProperty3 = _interopRequireDefault(_defineProperty2);
39424
39425var _stringify = require('babel-runtime/core-js/json/stringify');
39426
39427var _stringify2 = _interopRequireDefault(_stringify);
39428
39429var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
39430
39431var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
39432
39433var _createClass2 = require('babel-runtime/helpers/createClass');
39434
39435var _createClass3 = _interopRequireDefault(_createClass2);
39436
39437var _error = require('../error');
39438
39439var _integer = require('../integer');
39440
39441var _integer2 = _interopRequireDefault(_integer);
39442
39443var _serverVersion = require('./server-version');
39444
39445function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39446
39447var CALL_GET_SERVERS = 'CALL dbms.cluster.routing.getServers'; /**
39448 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
39449 *
39450 * This file is part of Neo4j.
39451 *
39452 * Licensed under the Apache License, Version 2.0 (the "License");
39453 * you may not use this file except in compliance with the License.
39454 * You may obtain a copy of the License at
39455 *
39456 * http://www.apache.org/licenses/LICENSE-2.0
39457 *
39458 * Unless required by applicable law or agreed to in writing, software
39459 * distributed under the License is distributed on an "AS IS" BASIS,
39460 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
39461 * See the License for the specific language governing permissions and
39462 * limitations under the License.
39463 */
39464
39465var GET_ROUTING_TABLE_PARAM = 'context';
39466var CALL_GET_ROUTING_TABLE = 'CALL dbms.cluster.routing.getRoutingTable({' + GET_ROUTING_TABLE_PARAM + '})';
39467var PROCEDURE_NOT_FOUND_CODE = 'Neo.ClientError.Procedure.ProcedureNotFound';
39468var UNAUTHORIZED_CODE = 'Neo.ClientError.Security.Unauthorized';
39469
39470var RoutingUtil = function () {
39471 function RoutingUtil(routingContext) {
39472 (0, _classCallCheck3.default)(this, RoutingUtil);
39473
39474 this._routingContext = routingContext;
39475 }
39476
39477 /**
39478 * Invoke routing procedure using the given session.
39479 * @param {Session} session the session to use.
39480 * @param {string} routerAddress the URL of the router.
39481 * @return {Promise<Record[]>} promise resolved with records returned by the procedure call or null if
39482 * connection error happened.
39483 */
39484
39485
39486 (0, _createClass3.default)(RoutingUtil, [{
39487 key: 'callRoutingProcedure',
39488 value: function callRoutingProcedure(session, routerAddress) {
39489 return this._callAvailableRoutingProcedure(session).then(function (result) {
39490 session.close();
39491 return result.records;
39492 }).catch(function (error) {
39493 if (error.code === PROCEDURE_NOT_FOUND_CODE) {
39494 // throw when getServers procedure not found because this is clearly a configuration issue
39495 throw (0, _error.newError)('Server at ' + routerAddress + ' can\'t perform routing. Make sure you are connecting to a causal cluster', _error.SERVICE_UNAVAILABLE);
39496 } else if (error.code === UNAUTHORIZED_CODE) {
39497 // auth error is a sign of a configuration issue, rediscovery should not proceed
39498 throw error;
39499 } else {
39500 // return nothing when failed to connect because code higher in the callstack is still able to retry with a
39501 // different session towards a different router
39502 return null;
39503 }
39504 });
39505 }
39506 }, {
39507 key: 'parseTtl',
39508 value: function parseTtl(record, routerAddress) {
39509 try {
39510 var now = (0, _integer.int)(Date.now());
39511 var expires = record.get('ttl').multiply(1000).add(now);
39512 // if the server uses a really big expire time like Long.MAX_VALUE this may have overflowed
39513 if (expires.lessThan(now)) {
39514 return _integer2.default.MAX_VALUE;
39515 }
39516 return expires;
39517 } catch (error) {
39518 throw (0, _error.newError)('Unable to parse TTL entry from router ' + routerAddress + ' from record:\n' + (0, _stringify2.default)(record), _error.PROTOCOL_ERROR);
39519 }
39520 }
39521 }, {
39522 key: 'parseServers',
39523 value: function parseServers(record, routerAddress) {
39524 try {
39525 var servers = record.get('servers');
39526
39527 var routers = [];
39528 var readers = [];
39529 var writers = [];
39530
39531 servers.forEach(function (server) {
39532 var role = server['role'];
39533 var addresses = server['addresses'];
39534
39535 if (role === 'ROUTE') {
39536 routers = parseArray(addresses);
39537 } else if (role === 'WRITE') {
39538 writers = parseArray(addresses);
39539 } else if (role === 'READ') {
39540 readers = parseArray(addresses);
39541 } else {
39542 throw (0, _error.newError)('Unknown server role "' + role + '"', _error.PROTOCOL_ERROR);
39543 }
39544 });
39545
39546 return {
39547 routers: routers,
39548 readers: readers,
39549 writers: writers
39550 };
39551 } catch (ignore) {
39552 throw (0, _error.newError)('Unable to parse servers entry from router ' + routerAddress + ' from record:\n' + (0, _stringify2.default)(record), _error.PROTOCOL_ERROR);
39553 }
39554 }
39555 }, {
39556 key: '_callAvailableRoutingProcedure',
39557 value: function _callAvailableRoutingProcedure(session) {
39558 var _this = this;
39559
39560 return session._run(null, null, function (connection, streamObserver) {
39561 var serverVersionString = connection.server.version;
39562 var serverVersion = _serverVersion.ServerVersion.fromString(serverVersionString);
39563
39564 if (serverVersion.compareTo(_serverVersion.VERSION_3_2_0) >= 0) {
39565 var params = (0, _defineProperty3.default)({}, GET_ROUTING_TABLE_PARAM, _this._routingContext);
39566 connection.run(CALL_GET_ROUTING_TABLE, params, streamObserver);
39567 } else {
39568 connection.run(CALL_GET_SERVERS, {}, streamObserver);
39569 }
39570 });
39571 }
39572 }]);
39573 return RoutingUtil;
39574}();
39575
39576exports.default = RoutingUtil;
39577
39578
39579function parseArray(addresses) {
39580 if (!Array.isArray(addresses)) {
39581 throw new TypeError('Array expected but got: ' + addresses);
39582 }
39583 return (0, _from2.default)(addresses);
39584}
39585
39586},{"../error":324,"../integer":327,"./server-version":357,"babel-runtime/core-js/array/from":15,"babel-runtime/core-js/json/stringify":18,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34,"babel-runtime/helpers/defineProperty":35}],357:[function(require,module,exports){
39587'use strict';
39588
39589Object.defineProperty(exports, "__esModule", {
39590 value: true
39591});
39592exports.VERSION_IN_DEV = exports.VERSION_3_4_0 = exports.VERSION_3_2_0 = exports.VERSION_3_1_0 = exports.ServerVersion = undefined;
39593
39594var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
39595
39596var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
39597
39598var _createClass2 = require('babel-runtime/helpers/createClass');
39599
39600var _createClass3 = _interopRequireDefault(_createClass2);
39601
39602var _util = require('./util');
39603
39604function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39605
39606var SERVER_VERSION_REGEX = new RegExp('^(Neo4j/)?(\\d+)\\.(\\d+)(?:\\.)?(\\d*)(\\.|-|\\+)?([0-9A-Za-z-.]*)?$'); /**
39607 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
39608 *
39609 * This file is part of Neo4j.
39610 *
39611 * Licensed under the Apache License, Version 2.0 (the "License");
39612 * you may not use this file except in compliance with the License.
39613 * You may obtain a copy of the License at
39614 *
39615 * http://www.apache.org/licenses/LICENSE-2.0
39616 *
39617 * Unless required by applicable law or agreed to in writing, software
39618 * distributed under the License is distributed on an "AS IS" BASIS,
39619 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
39620 * See the License for the specific language governing permissions and
39621 * limitations under the License.
39622 */
39623
39624var NEO4J_IN_DEV_VERSION_STRING = 'Neo4j/dev';
39625
39626var ServerVersion = function () {
39627
39628 /**
39629 * @constructor
39630 * @param {number} major the major version number.
39631 * @param {number} minor the minor version number.
39632 * @param {number} patch the patch version number.
39633 */
39634 function ServerVersion(major, minor, patch) {
39635 (0, _classCallCheck3.default)(this, ServerVersion);
39636
39637 this.major = major;
39638 this.minor = minor;
39639 this.patch = patch;
39640 }
39641
39642 /**
39643 * Fetch server version using the given driver.
39644 * @param {Driver} driver the driver to use.
39645 * @return {Promise<ServerVersion>} promise resolved with a {@link ServerVersion} object or rejected with error.
39646 */
39647
39648
39649 (0, _createClass3.default)(ServerVersion, [{
39650 key: 'compareTo',
39651
39652
39653 /**
39654 * Compare this version to the given one.
39655 * @param {ServerVersion} other the version to compare with.
39656 * @return {number} value 0 if this version is the same as the given one, value less then 0 when this version
39657 * was released earlier than the given one and value greater then 0 when this version was released after
39658 * than the given one.
39659 */
39660 value: function compareTo(other) {
39661 var result = compareInts(this.major, other.major);
39662 if (result === 0) {
39663 result = compareInts(this.minor, other.minor);
39664 if (result === 0) {
39665 result = compareInts(this.patch, other.patch);
39666 }
39667 }
39668 return result;
39669 }
39670 }], [{
39671 key: 'fromDriver',
39672 value: function fromDriver(driver) {
39673 var session = driver.session();
39674 return session.run('RETURN 1').then(function (result) {
39675 session.close();
39676 return ServerVersion.fromString(result.summary.server.version);
39677 });
39678 }
39679
39680 /**
39681 * Parse given string to a {@link ServerVersion} object.
39682 * @param {string} versionStr the string to parse.
39683 * @return {ServerVersion} version for the given string.
39684 * @throws Error if given string can't be parsed.
39685 */
39686
39687 }, {
39688 key: 'fromString',
39689 value: function fromString(versionStr) {
39690 if (!versionStr) {
39691 return new ServerVersion(3, 0, 0);
39692 }
39693
39694 (0, _util.assertString)(versionStr, 'Neo4j version string');
39695
39696 if (versionStr.toLowerCase() === NEO4J_IN_DEV_VERSION_STRING.toLowerCase()) {
39697 return VERSION_IN_DEV;
39698 }
39699
39700 var version = versionStr.match(SERVER_VERSION_REGEX);
39701 if (!version) {
39702 throw new Error('Unparsable Neo4j version: ' + versionStr);
39703 }
39704
39705 var major = parseIntStrict(version[2]);
39706 var minor = parseIntStrict(version[3]);
39707 var patch = parseIntStrict(version[4] || 0);
39708
39709 return new ServerVersion(major, minor, patch);
39710 }
39711 }]);
39712 return ServerVersion;
39713}();
39714
39715function parseIntStrict(str, name) {
39716 var value = parseInt(str, 10);
39717 if (!value && value !== 0) {
39718 throw new Error('Unparsable number ' + name + ': \'' + str + '\'');
39719 }
39720 return value;
39721}
39722
39723function compareInts(x, y) {
39724 return x < y ? -1 : x === y ? 0 : 1;
39725}
39726
39727var VERSION_3_1_0 = new ServerVersion(3, 1, 0);
39728var VERSION_3_2_0 = new ServerVersion(3, 2, 0);
39729var VERSION_3_4_0 = new ServerVersion(3, 4, 0);
39730var VERSION_IN_DEV = new ServerVersion(0, 0, 0);
39731
39732exports.ServerVersion = ServerVersion;
39733exports.VERSION_3_1_0 = VERSION_3_1_0;
39734exports.VERSION_3_2_0 = VERSION_3_2_0;
39735exports.VERSION_3_4_0 = VERSION_3_4_0;
39736exports.VERSION_IN_DEV = VERSION_IN_DEV;
39737
39738},{"./util":363,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34}],358:[function(require,module,exports){
39739'use strict';
39740
39741Object.defineProperty(exports, "__esModule", {
39742 value: true
39743});
39744
39745var _assign = require('babel-runtime/core-js/object/assign');
39746
39747var _assign2 = _interopRequireDefault(_assign);
39748
39749var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
39750
39751var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
39752
39753var _createClass2 = require('babel-runtime/helpers/createClass');
39754
39755var _createClass3 = _interopRequireDefault(_createClass2);
39756
39757var _record = require('../record');
39758
39759var _record2 = _interopRequireDefault(_record);
39760
39761function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39762
39763/**
39764 * Handles a RUN/PULL_ALL, or RUN/DISCARD_ALL requests, maps the responses
39765 * in a way that a user-provided observer can see these as a clean Stream
39766 * of records.
39767 * This class will queue up incoming messages until a user-provided observer
39768 * for the incoming stream is registered. Thus, we keep fields around
39769 * for tracking head/records/tail. These are only used if there is no
39770 * observer registered.
39771 * @access private
39772 */
39773var StreamObserver = function () {
39774 /**
39775 * @constructor
39776 * @param errorTransformer optional callback to be used for adding additional logic on error
39777 */
39778 function StreamObserver() {
39779 var errorTransformer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function (err) {
39780 return err;
39781 };
39782 (0, _classCallCheck3.default)(this, StreamObserver);
39783
39784 this._fieldKeys = null;
39785 this._fieldLookup = null;
39786 this._queuedRecords = [];
39787 this._tail = null;
39788 this._error = null;
39789 this._hasFailed = false;
39790 this._errorTransformer = errorTransformer;
39791 this._observer = null;
39792 this._conn = null;
39793 this._meta = {};
39794 }
39795
39796 /**
39797 * Will be called on every record that comes in and transform a raw record
39798 * to a Object. If user-provided observer is present, pass transformed record
39799 * to it's onNext method, otherwise, push to record que.
39800 * @param {Array} rawRecord - An array with the raw record
39801 */
39802
39803
39804 (0, _createClass3.default)(StreamObserver, [{
39805 key: 'onNext',
39806 value: function onNext(rawRecord) {
39807 var record = new _record2.default(this._fieldKeys, rawRecord, this._fieldLookup);
39808 if (this._observer) {
39809 this._observer.onNext(record);
39810 } else {
39811 this._queuedRecords.push(record);
39812 }
39813 }
39814 }, {
39815 key: 'onCompleted',
39816 value: function onCompleted(meta) {
39817 if (this._fieldKeys === null) {
39818 // Stream header, build a name->index field lookup table
39819 // to be used by records. This is an optimization to make it
39820 // faster to look up fields in a record by name, rather than by index.
39821 // Since the records we get back via Bolt are just arrays of values.
39822 this._fieldKeys = [];
39823 this._fieldLookup = {};
39824 if (meta.fields && meta.fields.length > 0) {
39825 this._fieldKeys = meta.fields;
39826 for (var i = 0; i < meta.fields.length; i++) {
39827 this._fieldLookup[meta.fields[i]] = i;
39828 }
39829 }
39830 } else {
39831 // End of stream
39832 if (this._observer) {
39833 this._observer.onCompleted(meta);
39834 } else {
39835 this._tail = meta;
39836 }
39837 }
39838 this._copyMetadataOnCompletion(meta);
39839 }
39840 }, {
39841 key: '_copyMetadataOnCompletion',
39842 value: function _copyMetadataOnCompletion(meta) {
39843 for (var key in meta) {
39844 if (meta.hasOwnProperty(key)) {
39845 this._meta[key] = meta[key];
39846 }
39847 }
39848 }
39849 }, {
39850 key: 'serverMetadata',
39851 value: function serverMetadata() {
39852 var serverMeta = { server: this._conn.server };
39853 return (0, _assign2.default)({}, this._meta, serverMeta);
39854 }
39855 }, {
39856 key: 'resolveConnection',
39857 value: function resolveConnection(conn) {
39858 this._conn = conn;
39859 }
39860
39861 /**
39862 * Will be called on errors.
39863 * If user-provided observer is present, pass the error
39864 * to it's onError method, otherwise set instance variable _error.
39865 * @param {Object} error - An error object
39866 */
39867
39868 }, {
39869 key: 'onError',
39870 value: function onError(error) {
39871 var transformedError = this._errorTransformer(error, this._conn);
39872 if (this._hasFailed) {
39873 return;
39874 }
39875 this._hasFailed = true;
39876 if (this._observer) {
39877 if (this._observer.onError) {
39878 this._observer.onError(transformedError);
39879 } else {
39880 console.log(transformedError);
39881 }
39882 } else {
39883 this._error = transformedError;
39884 }
39885 }
39886
39887 /**
39888 * Subscribe to events with provided observer.
39889 * @param {Object} observer - Observer object
39890 * @param {function(record: Object)} observer.onNext - Handle records, one by one.
39891 * @param {function(metadata: Object)} observer.onComplete - Handle stream tail, the metadata.
39892 * @param {function(error: Object)} observer.onError - Handle errors.
39893 */
39894
39895 }, {
39896 key: 'subscribe',
39897 value: function subscribe(observer) {
39898 if (this._error) {
39899 observer.onError(this._error);
39900 return;
39901 }
39902 if (this._queuedRecords.length > 0) {
39903 for (var i = 0; i < this._queuedRecords.length; i++) {
39904 observer.onNext(this._queuedRecords[i]);
39905 }
39906 }
39907 if (this._tail) {
39908 observer.onCompleted(this._tail);
39909 }
39910 this._observer = observer;
39911 }
39912 }, {
39913 key: 'hasFailed',
39914 value: function hasFailed() {
39915 return this._hasFailed;
39916 }
39917 }]);
39918 return StreamObserver;
39919}(); /**
39920 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
39921 *
39922 * This file is part of Neo4j.
39923 *
39924 * Licensed under the Apache License, Version 2.0 (the "License");
39925 * you may not use this file except in compliance with the License.
39926 * You may obtain a copy of the License at
39927 *
39928 * http://www.apache.org/licenses/LICENSE-2.0
39929 *
39930 * Unless required by applicable law or agreed to in writing, software
39931 * distributed under the License is distributed on an "AS IS" BASIS,
39932 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
39933 * See the License for the specific language governing permissions and
39934 * limitations under the License.
39935 */
39936
39937
39938exports.default = StreamObserver;
39939
39940},{"../record":364,"babel-runtime/core-js/object/assign":21,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34}],359:[function(require,module,exports){
39941'use strict';
39942
39943Object.defineProperty(exports, "__esModule", {
39944 value: true
39945});
39946exports.localTimeToNanoOfDay = localTimeToNanoOfDay;
39947exports.nanoOfDayToLocalTime = nanoOfDayToLocalTime;
39948exports.localDateTimeToEpochSecond = localDateTimeToEpochSecond;
39949exports.epochSecondAndNanoToLocalDateTime = epochSecondAndNanoToLocalDateTime;
39950exports.dateToEpochDay = dateToEpochDay;
39951exports.epochDayToDate = epochDayToDate;
39952exports.durationToIsoString = durationToIsoString;
39953exports.timeToIsoString = timeToIsoString;
39954exports.timeZoneOffsetToIsoString = timeZoneOffsetToIsoString;
39955exports.dateToIsoString = dateToIsoString;
39956
39957var _integer = require('../integer');
39958
39959var _temporalTypes = require('../temporal-types');
39960
39961/*
39962 Code in this util should be compatible with code in the database that uses JSR-310 java.time APIs.
39963
39964 It is based on a library called ThreeTen (https://github.com/ThreeTen/threetenbp) which was derived
39965 from JSR-310 reference implementation previously hosted on GitHub. Code uses `Integer` type everywhere
39966 to correctly handle large integer values that are greater than <code>Number.MAX_SAFE_INTEGER</code>.
39967
39968 Please consult either ThreeTen or js-joda (https://github.com/js-joda/js-joda) when working with the
39969 conversion functions.
39970 */
39971
39972/**
39973 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
39974 *
39975 * This file is part of Neo4j.
39976 *
39977 * Licensed under the Apache License, Version 2.0 (the "License");
39978 * you may not use this file except in compliance with the License.
39979 * You may obtain a copy of the License at
39980 *
39981 * http://www.apache.org/licenses/LICENSE-2.0
39982 *
39983 * Unless required by applicable law or agreed to in writing, software
39984 * distributed under the License is distributed on an "AS IS" BASIS,
39985 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
39986 * See the License for the specific language governing permissions and
39987 * limitations under the License.
39988 */
39989
39990var MINUTES_PER_HOUR = 60;
39991var SECONDS_PER_MINUTE = 60;
39992var SECONDS_PER_HOUR = SECONDS_PER_MINUTE * MINUTES_PER_HOUR;
39993var NANOS_PER_SECOND = 1000000000;
39994var NANOS_PER_MINUTE = NANOS_PER_SECOND * SECONDS_PER_MINUTE;
39995var NANOS_PER_HOUR = NANOS_PER_MINUTE * MINUTES_PER_HOUR;
39996var DAYS_0000_TO_1970 = 719528;
39997var DAYS_PER_400_YEAR_CYCLE = 146097;
39998var SECONDS_PER_DAY = 86400;
39999
40000/**
40001 * Converts given local time into a single integer representing this same time in nanoseconds of the day.
40002 * @param {Integer|number|string} hour the hour of the local time to convert.
40003 * @param {Integer|number|string} minute the minute of the local time to convert.
40004 * @param {Integer|number|string} second the second of the local time to convert.
40005 * @param {Integer|number|string} nanosecond the nanosecond of the local time to convert.
40006 * @return {Integer} nanoseconds representing the given local time.
40007 */
40008function localTimeToNanoOfDay(hour, minute, second, nanosecond) {
40009 hour = (0, _integer.int)(hour);
40010 minute = (0, _integer.int)(minute);
40011 second = (0, _integer.int)(second);
40012 nanosecond = (0, _integer.int)(nanosecond);
40013
40014 var totalNanos = hour.multiply(NANOS_PER_HOUR);
40015 totalNanos = totalNanos.add(minute.multiply(NANOS_PER_MINUTE));
40016 totalNanos = totalNanos.add(second.multiply(NANOS_PER_SECOND));
40017 return totalNanos.add(nanosecond);
40018}
40019
40020/**
40021 * Converts nanoseconds of the day into local time.
40022 * @param {Integer|number|string} nanoOfDay the nanoseconds of the day to convert.
40023 * @return {LocalTime} the local time representing given nanoseconds of the day.
40024 */
40025function nanoOfDayToLocalTime(nanoOfDay) {
40026 nanoOfDay = (0, _integer.int)(nanoOfDay);
40027
40028 var hour = nanoOfDay.div(NANOS_PER_HOUR);
40029 nanoOfDay = nanoOfDay.subtract(hour.multiply(NANOS_PER_HOUR));
40030
40031 var minute = nanoOfDay.div(NANOS_PER_MINUTE);
40032 nanoOfDay = nanoOfDay.subtract(minute.multiply(NANOS_PER_MINUTE));
40033
40034 var second = nanoOfDay.div(NANOS_PER_SECOND);
40035 var nanosecond = nanoOfDay.subtract(second.multiply(NANOS_PER_SECOND));
40036
40037 return new _temporalTypes.LocalTime(hour, minute, second, nanosecond);
40038}
40039
40040/**
40041 * Converts given local date time into a single integer representing this same time in epoch seconds UTC.
40042 * @param {Integer|number|string} year the year of the local date-time to convert.
40043 * @param {Integer|number|string} month the month of the local date-time to convert.
40044 * @param {Integer|number|string} day the day of the local date-time to convert.
40045 * @param {Integer|number|string} hour the hour of the local date-time to convert.
40046 * @param {Integer|number|string} minute the minute of the local date-time to convert.
40047 * @param {Integer|number|string} second the second of the local date-time to convert.
40048 * @param {Integer|number|string} nanosecond the nanosecond of the local date-time to convert.
40049 * @return {Integer} epoch second in UTC representing the given local date time.
40050 */
40051function localDateTimeToEpochSecond(year, month, day, hour, minute, second, nanosecond) {
40052 var epochDay = dateToEpochDay(year, month, day);
40053 var localTimeSeconds = localTimeToSecondOfDay(hour, minute, second);
40054 return epochDay.multiply(SECONDS_PER_DAY).add(localTimeSeconds);
40055}
40056
40057/**
40058 * Converts given epoch second and nanosecond adjustment into a local date time object.
40059 * @param {Integer|number|string} epochSecond the epoch second to use.
40060 * @param {Integer|number|string} nano the nanosecond to use.
40061 * @return {LocalDateTime} the local date time representing given epoch second and nano.
40062 */
40063function epochSecondAndNanoToLocalDateTime(epochSecond, nano) {
40064 var epochDay = floorDiv(epochSecond, SECONDS_PER_DAY);
40065 var secondsOfDay = floorMod(epochSecond, SECONDS_PER_DAY);
40066 var nanoOfDay = secondsOfDay.multiply(NANOS_PER_SECOND).add(nano);
40067
40068 var localDate = epochDayToDate(epochDay);
40069 var localTime = nanoOfDayToLocalTime(nanoOfDay);
40070 return new _temporalTypes.LocalDateTime(localDate.year, localDate.month, localDate.day, localTime.hour, localTime.minute, localTime.second, localTime.nanosecond);
40071}
40072
40073/**
40074 * Converts given local date into a single integer representing it's epoch day.
40075 * @param {Integer|number|string} year the year of the local date to convert.
40076 * @param {Integer|number|string} month the month of the local date to convert.
40077 * @param {Integer|number|string} day the day of the local date to convert.
40078 * @return {Integer} epoch day representing the given date.
40079 */
40080function dateToEpochDay(year, month, day) {
40081 year = (0, _integer.int)(year);
40082 month = (0, _integer.int)(month);
40083 day = (0, _integer.int)(day);
40084
40085 var epochDay = year.multiply(365);
40086
40087 if (year.greaterThanOrEqual(0)) {
40088 epochDay = epochDay.add(year.add(3).div(4).subtract(year.add(99).div(100)).add(year.add(399).div(400)));
40089 } else {
40090 epochDay = epochDay.subtract(year.div(-4).subtract(year.div(-100)).add(year.div(-400)));
40091 }
40092
40093 epochDay = epochDay.add(month.multiply(367).subtract(362).div(12));
40094 epochDay = epochDay.add(day.subtract(1));
40095 if (month.greaterThan(2)) {
40096 epochDay = epochDay.subtract(1);
40097 if (!isLeapYear(year)) {
40098 epochDay = epochDay.subtract(1);
40099 }
40100 }
40101 return epochDay.subtract(DAYS_0000_TO_1970);
40102}
40103
40104/**
40105 * Converts given epoch day to a local date.
40106 * @param {Integer|number|string} epochDay the epoch day to convert.
40107 * @return {Date} the date representing the epoch day in years, months and days.
40108 */
40109function epochDayToDate(epochDay) {
40110 epochDay = (0, _integer.int)(epochDay);
40111
40112 var zeroDay = epochDay.add(DAYS_0000_TO_1970).subtract(60);
40113 var adjust = (0, _integer.int)(0);
40114 if (zeroDay.lessThan(0)) {
40115 var adjustCycles = zeroDay.add(1).div(DAYS_PER_400_YEAR_CYCLE).subtract(1);
40116 adjust = adjustCycles.multiply(400);
40117 zeroDay = zeroDay.add(adjustCycles.multiply(-DAYS_PER_400_YEAR_CYCLE));
40118 }
40119 var year = zeroDay.multiply(400).add(591).div(DAYS_PER_400_YEAR_CYCLE);
40120 var dayOfYearEst = zeroDay.subtract(year.multiply(365).add(year.div(4)).subtract(year.div(100)).add(year.div(400)));
40121 if (dayOfYearEst.lessThan(0)) {
40122 year = year.subtract(1);
40123 dayOfYearEst = zeroDay.subtract(year.multiply(365).add(year.div(4)).subtract(year.div(100)).add(year.div(400)));
40124 }
40125 year = year.add(adjust);
40126 var marchDayOfYear = dayOfYearEst;
40127
40128 var marchMonth = marchDayOfYear.multiply(5).add(2).div(153);
40129 var month = marchMonth.add(2).modulo(12).add(1);
40130 var day = marchDayOfYear.subtract(marchMonth.multiply(306).add(5).div(10)).add(1);
40131 year = year.add(marchMonth.div(10));
40132
40133 return new _temporalTypes.Date(year, month, day);
40134}
40135
40136/**
40137 * Format given duration to an ISO 8601 string.
40138 * @param {Integer|number|string} months the number of months.
40139 * @param {Integer|number|string} days the number of days.
40140 * @param {Integer|number|string} seconds the number of seconds.
40141 * @param {Integer|number|string} nanoseconds the number of nanoseconds.
40142 * @return {string} ISO string that represents given duration.
40143 */
40144function durationToIsoString(months, days, seconds, nanoseconds) {
40145 var monthsString = formatNumber(months);
40146 var daysString = formatNumber(days);
40147 var secondsString = formatNumber(seconds);
40148 var nanosecondsString = formatNanoseconds(nanoseconds);
40149 return 'P' + monthsString + 'M' + daysString + 'DT' + secondsString + nanosecondsString + 'S';
40150}
40151
40152/**
40153 * Formats given time to an ISO 8601 string.
40154 * @param {Integer|number|string} hour the hour value.
40155 * @param {Integer|number|string} minute the minute value.
40156 * @param {Integer|number|string} second the second value.
40157 * @param {Integer|number|string} nanosecond the nanosecond value.
40158 * @return {string} ISO string that represents given time.
40159 */
40160function timeToIsoString(hour, minute, second, nanosecond) {
40161 var hourString = formatNumber(hour, 2);
40162 var minuteString = formatNumber(minute, 2);
40163 var secondString = formatNumber(second, 2);
40164 var nanosecondString = formatNanoseconds(nanosecond);
40165 return hourString + ':' + minuteString + ':' + secondString + nanosecondString;
40166}
40167
40168/**
40169 * Formats given time zone offset in seconds to string representation like '±HH:MM', '±HH:MM:SS' or 'Z' for UTC.
40170 * @param {Integer|number|string} offsetSeconds the offset in seconds.
40171 * @return {string} ISO string that represents given offset.
40172 */
40173function timeZoneOffsetToIsoString(offsetSeconds) {
40174 offsetSeconds = (0, _integer.int)(offsetSeconds);
40175 if (offsetSeconds.equals(0)) {
40176 return 'Z';
40177 }
40178
40179 var isNegative = offsetSeconds.isNegative();
40180 if (isNegative) {
40181 offsetSeconds = offsetSeconds.multiply(-1);
40182 }
40183 var signPrefix = isNegative ? '-' : '+';
40184
40185 var hours = formatNumber(offsetSeconds.div(SECONDS_PER_HOUR), 2);
40186 var minutes = formatNumber(offsetSeconds.div(SECONDS_PER_MINUTE).modulo(MINUTES_PER_HOUR), 2);
40187 var secondsValue = offsetSeconds.modulo(SECONDS_PER_MINUTE);
40188 var seconds = secondsValue.equals(0) ? null : formatNumber(secondsValue, 2);
40189
40190 return seconds ? '' + signPrefix + hours + ':' + minutes + ':' + seconds : '' + signPrefix + hours + ':' + minutes;
40191}
40192
40193/**
40194 * Formats given date to an ISO 8601 string.
40195 * @param {Integer|number|string} year the date year.
40196 * @param {Integer|number|string} month the date month.
40197 * @param {Integer|number|string} day the date day.
40198 * @return {string} ISO string that represents given date.
40199 */
40200function dateToIsoString(year, month, day) {
40201 year = (0, _integer.int)(year);
40202 var isNegative = year.isNegative();
40203 if (isNegative) {
40204 year = year.multiply(-1);
40205 }
40206 var yearString = formatNumber(year, 4);
40207 if (isNegative) {
40208 yearString = '-' + yearString;
40209 }
40210
40211 var monthString = formatNumber(month, 2);
40212 var dayString = formatNumber(day, 2);
40213 return yearString + '-' + monthString + '-' + dayString;
40214}
40215
40216/**
40217 * Converts given local time into a single integer representing this same time in seconds of the day. Nanoseconds are skipped.
40218 * @param {Integer|number|string} hour the hour of the local time.
40219 * @param {Integer|number|string} minute the minute of the local time.
40220 * @param {Integer|number|string} second the second of the local time.
40221 * @return {Integer} seconds representing the given local time.
40222 */
40223function localTimeToSecondOfDay(hour, minute, second) {
40224 hour = (0, _integer.int)(hour);
40225 minute = (0, _integer.int)(minute);
40226 second = (0, _integer.int)(second);
40227
40228 var totalSeconds = hour.multiply(SECONDS_PER_HOUR);
40229 totalSeconds = totalSeconds.add(minute.multiply(SECONDS_PER_MINUTE));
40230 return totalSeconds.add(second);
40231}
40232
40233/**
40234 * Check if given year is a leap year. Uses algorithm described here {@link https://en.wikipedia.org/wiki/Leap_year#Algorithm}.
40235 * @param {Integer|number|string} year the year to check. Will be converted to {@link Integer} for all calculations.
40236 * @return {boolean} <code>true</code> if given year is a leap year, <code>false</code> otherwise.
40237 */
40238function isLeapYear(year) {
40239 year = (0, _integer.int)(year);
40240
40241 if (!year.modulo(4).equals(0)) {
40242 return false;
40243 } else if (!year.modulo(100).equals(0)) {
40244 return true;
40245 } else if (!year.modulo(400).equals(0)) {
40246 return false;
40247 } else {
40248 return true;
40249 }
40250}
40251
40252/**
40253 * @param {Integer|number|string} x the divident.
40254 * @param {Integer|number|string} y the divisor.
40255 * @return {Integer} the result.
40256 */
40257function floorDiv(x, y) {
40258 x = (0, _integer.int)(x);
40259 y = (0, _integer.int)(y);
40260
40261 var result = x.div(y);
40262 if (x.isPositive() !== y.isPositive() && result.multiply(y).notEquals(x)) {
40263 result = result.subtract(1);
40264 }
40265 return result;
40266}
40267
40268/**
40269 * @param {Integer|number|string} x the divident.
40270 * @param {Integer|number|string} y the divisor.
40271 * @return {Integer} the result.
40272 */
40273function floorMod(x, y) {
40274 x = (0, _integer.int)(x);
40275 y = (0, _integer.int)(y);
40276
40277 return x.subtract(floorDiv(x, y).multiply(y));
40278}
40279
40280/**
40281 * @param {Integer|number|string} value the number of nanoseconds to format.
40282 * @return {string} formatted and possibly left-padded nanoseconds part as string.
40283 */
40284function formatNanoseconds(value) {
40285 value = (0, _integer.int)(value);
40286 return value.equals(0) ? '' : '.' + formatNumber(value, 9);
40287}
40288
40289/**
40290 * @param {Integer|number|string} num the number to format.
40291 * @param {number} [stringLength=undefined] the string length to left-pad to.
40292 * @return {string} formatted and possibly left-padded number as string.
40293 */
40294function formatNumber(num) {
40295 var stringLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
40296
40297 num = (0, _integer.int)(num);
40298 var isNegative = num.isNegative();
40299 if (isNegative) {
40300 num = num.multiply(-1);
40301 }
40302 var numString = num.toString();
40303 var paddedNumString = stringLength ? numString.padStart(stringLength, '0') : numString;
40304 return isNegative ? '-' + paddedNumString : paddedNumString;
40305}
40306
40307},{"../integer":327,"../temporal-types":370}],360:[function(require,module,exports){
40308'use strict';
40309
40310Object.defineProperty(exports, "__esModule", {
40311 value: true
40312});
40313
40314var _promise = require('babel-runtime/core-js/promise');
40315
40316var _promise2 = _interopRequireDefault(_promise);
40317
40318var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
40319
40320var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
40321
40322var _createClass2 = require('babel-runtime/helpers/createClass');
40323
40324var _createClass3 = _interopRequireDefault(_createClass2);
40325
40326var _error = require('../error');
40327
40328function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
40329
40330var DEFAULT_MAX_RETRY_TIME_MS = 30 * 1000; // 30 seconds
40331/**
40332 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
40333 *
40334 * This file is part of Neo4j.
40335 *
40336 * Licensed under the Apache License, Version 2.0 (the "License");
40337 * you may not use this file except in compliance with the License.
40338 * You may obtain a copy of the License at
40339 *
40340 * http://www.apache.org/licenses/LICENSE-2.0
40341 *
40342 * Unless required by applicable law or agreed to in writing, software
40343 * distributed under the License is distributed on an "AS IS" BASIS,
40344 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
40345 * See the License for the specific language governing permissions and
40346 * limitations under the License.
40347 */
40348
40349var DEFAULT_INITIAL_RETRY_DELAY_MS = 1000; // 1 seconds
40350var DEFAULT_RETRY_DELAY_MULTIPLIER = 2.0;
40351var DEFAULT_RETRY_DELAY_JITTER_FACTOR = 0.2;
40352
40353var TransactionExecutor = function () {
40354 function TransactionExecutor(maxRetryTimeMs, initialRetryDelayMs, multiplier, jitterFactor) {
40355 (0, _classCallCheck3.default)(this, TransactionExecutor);
40356
40357 this._maxRetryTimeMs = _valueOrDefault(maxRetryTimeMs, DEFAULT_MAX_RETRY_TIME_MS);
40358 this._initialRetryDelayMs = _valueOrDefault(initialRetryDelayMs, DEFAULT_INITIAL_RETRY_DELAY_MS);
40359 this._multiplier = _valueOrDefault(multiplier, DEFAULT_RETRY_DELAY_MULTIPLIER);
40360 this._jitterFactor = _valueOrDefault(jitterFactor, DEFAULT_RETRY_DELAY_JITTER_FACTOR);
40361
40362 this._inFlightTimeoutIds = [];
40363
40364 this._verifyAfterConstruction();
40365 }
40366
40367 (0, _createClass3.default)(TransactionExecutor, [{
40368 key: 'execute',
40369 value: function execute(transactionCreator, transactionWork) {
40370 var _this = this;
40371
40372 return new _promise2.default(function (resolve, reject) {
40373 _this._executeTransactionInsidePromise(transactionCreator, transactionWork, resolve, reject);
40374 }).catch(function (error) {
40375 var retryStartTimeMs = Date.now();
40376 var retryDelayMs = _this._initialRetryDelayMs;
40377 return _this._retryTransactionPromise(transactionCreator, transactionWork, error, retryStartTimeMs, retryDelayMs);
40378 });
40379 }
40380 }, {
40381 key: 'close',
40382 value: function close() {
40383 // cancel all existing timeouts to prevent further retries
40384 this._inFlightTimeoutIds.forEach(function (timeoutId) {
40385 return clearTimeout(timeoutId);
40386 });
40387 this._inFlightTimeoutIds = [];
40388 }
40389 }, {
40390 key: '_retryTransactionPromise',
40391 value: function _retryTransactionPromise(transactionCreator, transactionWork, error, retryStartTime, retryDelayMs) {
40392 var _this2 = this;
40393
40394 var elapsedTimeMs = Date.now() - retryStartTime;
40395
40396 if (elapsedTimeMs > this._maxRetryTimeMs || !TransactionExecutor._canRetryOn(error)) {
40397 return _promise2.default.reject(error);
40398 }
40399
40400 return new _promise2.default(function (resolve, reject) {
40401 var nextRetryTime = _this2._computeDelayWithJitter(retryDelayMs);
40402 var timeoutId = setTimeout(function () {
40403 // filter out this timeoutId when time has come and function is being executed
40404 _this2._inFlightTimeoutIds = _this2._inFlightTimeoutIds.filter(function (id) {
40405 return id !== timeoutId;
40406 });
40407 _this2._executeTransactionInsidePromise(transactionCreator, transactionWork, resolve, reject);
40408 }, nextRetryTime);
40409 // add newly created timeoutId to the list of all in-flight timeouts
40410 _this2._inFlightTimeoutIds.push(timeoutId);
40411 }).catch(function (error) {
40412 var nextRetryDelayMs = retryDelayMs * _this2._multiplier;
40413 return _this2._retryTransactionPromise(transactionCreator, transactionWork, error, retryStartTime, nextRetryDelayMs);
40414 });
40415 }
40416 }, {
40417 key: '_executeTransactionInsidePromise',
40418 value: function _executeTransactionInsidePromise(transactionCreator, transactionWork, resolve, reject) {
40419 try {
40420 var tx = transactionCreator();
40421 var transactionWorkResult = transactionWork(tx);
40422
40423 // user defined callback is supposed to return a promise, but it might not; so to protect against an
40424 // incorrect API usage we wrap the returned value with a resolved promise; this is effectively a
40425 // validation step without type checks
40426 var resultPromise = _promise2.default.resolve(transactionWorkResult);
40427
40428 resultPromise.then(function (result) {
40429 if (tx.isOpen()) {
40430 // transaction work returned resolved promise and transaction has not been committed/rolled back
40431 // try to commit the transaction
40432 tx.commit().then(function () {
40433 // transaction was committed, return result to the user
40434 resolve(result);
40435 }).catch(function (error) {
40436 // transaction failed to commit, propagate the failure
40437 reject(error);
40438 });
40439 } else {
40440 // transaction work returned resolved promise and transaction is already committed/rolled back
40441 // return the result returned by given transaction work
40442 resolve(result);
40443 }
40444 }).catch(function (error) {
40445 // transaction work returned rejected promise, propagate the failure
40446 reject(error);
40447 });
40448 } catch (error) {
40449 reject(error);
40450 }
40451 }
40452 }, {
40453 key: '_computeDelayWithJitter',
40454 value: function _computeDelayWithJitter(delayMs) {
40455 var jitter = delayMs * this._jitterFactor;
40456 var min = delayMs - jitter;
40457 var max = delayMs + jitter;
40458 return Math.random() * (max - min) + min;
40459 }
40460 }, {
40461 key: '_verifyAfterConstruction',
40462 value: function _verifyAfterConstruction() {
40463 if (this._maxRetryTimeMs < 0) {
40464 throw (0, _error.newError)('Max retry time should be >= 0: ' + this._maxRetryTimeMs);
40465 }
40466 if (this._initialRetryDelayMs < 0) {
40467 throw (0, _error.newError)('Initial retry delay should >= 0: ' + this._initialRetryDelayMs);
40468 }
40469 if (this._multiplier < 1.0) {
40470 throw (0, _error.newError)('Multiplier should be >= 1.0: ' + this._multiplier);
40471 }
40472 if (this._jitterFactor < 0 || this._jitterFactor > 1) {
40473 throw (0, _error.newError)('Jitter factor should be in [0.0, 1.0]: ' + this._jitterFactor);
40474 }
40475 }
40476 }], [{
40477 key: '_canRetryOn',
40478 value: function _canRetryOn(error) {
40479 return error && error.code && (error.code === _error.SERVICE_UNAVAILABLE || error.code === _error.SESSION_EXPIRED || this._isTransientError(error));
40480 }
40481 }, {
40482 key: '_isTransientError',
40483 value: function _isTransientError(error) {
40484 // Retries should not happen when transaction was explicitly terminated by the user.
40485 // Termination of transaction might result in two different error codes depending on where it was
40486 // terminated. These are really client errors but classification on the server is not entirely correct and
40487 // they are classified as transient.
40488
40489 var code = error.code;
40490 if (code.indexOf('TransientError') >= 0) {
40491 if (code === 'Neo.TransientError.Transaction.Terminated' || code === 'Neo.TransientError.Transaction.LockClientStopped') {
40492 return false;
40493 }
40494 return true;
40495 }
40496 return false;
40497 }
40498 }]);
40499 return TransactionExecutor;
40500}();
40501
40502exports.default = TransactionExecutor;
40503;
40504
40505function _valueOrDefault(value, defaultValue) {
40506 if (value || value === 0) {
40507 return value;
40508 }
40509 return defaultValue;
40510}
40511
40512},{"../error":324,"babel-runtime/core-js/promise":29,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34}],361:[function(require,module,exports){
40513'use strict';
40514
40515Object.defineProperty(exports, "__esModule", {
40516 value: true
40517});
40518
40519var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
40520
40521var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
40522
40523var _uriJs = require('uri-js');
40524
40525var _util = require('./util');
40526
40527function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
40528
40529/**
40530 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
40531 *
40532 * This file is part of Neo4j.
40533 *
40534 * Licensed under the Apache License, Version 2.0 (the "License");
40535 * you may not use this file except in compliance with the License.
40536 * You may obtain a copy of the License at
40537 *
40538 * http://www.apache.org/licenses/LICENSE-2.0
40539 *
40540 * Unless required by applicable law or agreed to in writing, software
40541 * distributed under the License is distributed on an "AS IS" BASIS,
40542 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
40543 * See the License for the specific language governing permissions and
40544 * limitations under the License.
40545 */
40546
40547var DEFAULT_BOLT_PORT = 7687;
40548var DEFAULT_HTTP_PORT = 7474;
40549var DEFAULT_HTTPS_PORT = 7473;
40550
40551var Url = function Url(scheme, host, port, hostAndPort, query) {
40552 (0, _classCallCheck3.default)(this, Url);
40553
40554 /**
40555 * Nullable scheme (protocol) of the URL.
40556 * Example: 'bolt', 'bolt+routing', 'http', 'https', etc.
40557 * @type {string}
40558 */
40559 this.scheme = scheme;
40560
40561 /**
40562 * Nonnull host name or IP address. IPv6 not wrapped in square brackets.
40563 * Example: 'neo4j.com', 'localhost', '127.0.0.1', '192.168.10.15', '::1', '2001:4860:4860::8844', etc.
40564 * @type {string}
40565 */
40566 this.host = host;
40567
40568 /**
40569 * Nonnull number representing port. Default port for the given scheme is used if given URL string
40570 * does not contain port. Example: 7687 for bolt, 7474 for HTTP and 7473 for HTTPS.
40571 * @type {number}
40572 */
40573 this.port = port;
40574
40575 /**
40576 * Nonnull host name or IP address plus port, separated by ':'. IPv6 wrapped in square brackets.
40577 * Example: 'neo4j.com', 'neo4j.com:7687', '127.0.0.1', '127.0.0.1:8080', '[2001:4860:4860::8844]',
40578 * '[2001:4860:4860::8844]:9090', etc.
40579 * @type {string}
40580 */
40581 this.hostAndPort = hostAndPort;
40582
40583 /**
40584 * Nonnull object representing parsed query string key-value pairs. Duplicated keys not supported.
40585 * Example: '{}', '{'key1': 'value1', 'key2': 'value2'}', etc.
40586 * @type {object}
40587 */
40588 this.query = query;
40589};
40590
40591function parseDatabaseUrl(url) {
40592 (0, _util.assertString)(url, 'URL');
40593
40594 var sanitized = sanitizeUrl(url);
40595 var parsedUrl = (0, _uriJs.parse)(sanitized.url);
40596
40597 var scheme = sanitized.schemeMissing ? null : extractScheme(parsedUrl.scheme);
40598 var host = extractHost(parsedUrl.host); // no square brackets for IPv6
40599 var formattedHost = formatHost(host); // has square brackets for IPv6
40600 var port = extractPort(parsedUrl.port, scheme);
40601 var hostAndPort = formattedHost + ':' + port;
40602 var query = extractQuery(parsedUrl.query, url);
40603
40604 return new Url(scheme, host, port, hostAndPort, query);
40605}
40606
40607function sanitizeUrl(url) {
40608 url = url.trim();
40609
40610 if (url.indexOf('://') === -1) {
40611 // url does not contain scheme, add dummy 'none://' to make parser work correctly
40612 return { schemeMissing: true, url: 'none://' + url };
40613 }
40614
40615 return { schemeMissing: false, url: url };
40616}
40617
40618function extractScheme(scheme) {
40619 if (scheme) {
40620 scheme = scheme.trim();
40621 if (scheme.charAt(scheme.length - 1) === ':') {
40622 scheme = scheme.substring(0, scheme.length - 1);
40623 }
40624 return scheme;
40625 }
40626 return null;
40627}
40628
40629function extractHost(host, url) {
40630 if (!host) {
40631 throw new Error('Unable to extract host from ' + url);
40632 }
40633 return host.trim();
40634}
40635
40636function extractPort(portString, scheme) {
40637 var port = parseInt(portString, 10);
40638 return port === 0 || port ? port : defaultPortForScheme(scheme);
40639}
40640
40641function extractQuery(queryString, url) {
40642 var query = trimAndSanitizeQuery(queryString);
40643 var context = {};
40644
40645 if (query) {
40646 query.split('&').forEach(function (pair) {
40647 var keyValue = pair.split('=');
40648 if (keyValue.length !== 2) {
40649 throw new Error('Invalid parameters: \'' + keyValue + '\' in URL \'' + url + '\'.');
40650 }
40651
40652 var key = trimAndVerifyQueryElement(keyValue[0], 'key', url);
40653 var value = trimAndVerifyQueryElement(keyValue[1], 'value', url);
40654
40655 if (context[key]) {
40656 throw new Error('Duplicated query parameters with key \'' + key + '\' in URL \'' + url + '\'');
40657 }
40658
40659 context[key] = value;
40660 });
40661 }
40662
40663 return context;
40664}
40665
40666function trimAndSanitizeQuery(query) {
40667 query = (query || '').trim();
40668 if (query && query.charAt(0) === '?') {
40669 query = query.substring(1, query.length);
40670 }
40671 return query;
40672}
40673
40674function trimAndVerifyQueryElement(element, name, url) {
40675 element = (element || '').trim();
40676 if (!element) {
40677 throw new Error('Illegal empty ' + name + ' in URL query \'' + url + '\'');
40678 }
40679 return element;
40680}
40681
40682function escapeIPv6Address(address) {
40683 var startsWithSquareBracket = address.charAt(0) === '[';
40684 var endsWithSquareBracket = address.charAt(address.length - 1) === ']';
40685
40686 if (!startsWithSquareBracket && !endsWithSquareBracket) {
40687 return '[' + address + ']';
40688 } else if (startsWithSquareBracket && endsWithSquareBracket) {
40689 return address;
40690 } else {
40691 throw new Error('Illegal IPv6 address ' + address);
40692 }
40693}
40694
40695function formatHost(host) {
40696 if (!host) {
40697 throw new Error('Illegal host ' + host);
40698 }
40699 var isIPv6Address = host.indexOf(':') >= 0;
40700 return isIPv6Address ? escapeIPv6Address(host) : host;
40701}
40702
40703function formatIPv4Address(address, port) {
40704 return address + ':' + port;
40705}
40706
40707function formatIPv6Address(address, port) {
40708 var escapedAddress = escapeIPv6Address(address);
40709 return escapedAddress + ':' + port;
40710}
40711
40712function defaultPortForScheme(scheme) {
40713 if (scheme === 'http') {
40714 return DEFAULT_HTTP_PORT;
40715 } else if (scheme === 'https') {
40716 return DEFAULT_HTTPS_PORT;
40717 } else {
40718 return DEFAULT_BOLT_PORT;
40719 }
40720}
40721
40722exports.default = {
40723 parseDatabaseUrl: parseDatabaseUrl,
40724 defaultPortForScheme: defaultPortForScheme,
40725 formatIPv4Address: formatIPv4Address,
40726 formatIPv6Address: formatIPv6Address
40727};
40728
40729},{"./util":363,"babel-runtime/helpers/classCallCheck":33,"uri-js":316}],362:[function(require,module,exports){
40730'use strict';
40731
40732Object.defineProperty(exports, "__esModule", {
40733 value: true
40734});
40735
40736var _buf = require('./buf');
40737
40738var _string_decoder = require('string_decoder');
40739
40740var _error = require('./../error');
40741
40742var platformObj = {}; /**
40743 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
40744 *
40745 * This file is part of Neo4j.
40746 *
40747 * Licensed under the Apache License, Version 2.0 (the "License");
40748 * you may not use this file except in compliance with the License.
40749 * You may obtain a copy of the License at
40750 *
40751 * http://www.apache.org/licenses/LICENSE-2.0
40752 *
40753 * Unless required by applicable law or agreed to in writing, software
40754 * distributed under the License is distributed on an "AS IS" BASIS,
40755 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
40756 * See the License for the specific language governing permissions and
40757 * limitations under the License.
40758 */
40759
40760// This module defines a cross-platform UTF-8 encoder and decoder that works
40761// with the Buffer API defined in buf.js
40762
40763try {
40764 // This will throw an exception is 'buffer' is not available
40765 require.resolve("buffer");
40766 var decoder = new _string_decoder.StringDecoder('utf8');
40767 var node = require('buffer');
40768
40769 // use static factory function present in newer NodeJS versions to create a buffer containing the given string
40770 // or fallback to the old, potentially deprecated constructor
40771 var newNodeJSBuffer = typeof node.Buffer.from === 'function' ? function (str) {
40772 return node.Buffer.from(str, 'utf8');
40773 } : function (str) {
40774 return new node.Buffer(str, 'utf8');
40775 };
40776
40777 platformObj = {
40778 "encode": function encode(str) {
40779 return new _buf.NodeBuffer(newNodeJSBuffer(str));
40780 },
40781 "decode": function decode(buffer, length) {
40782 if (buffer instanceof _buf.NodeBuffer) {
40783 var start = buffer.position,
40784 end = start + length;
40785 buffer.position = Math.min(end, buffer.length);
40786 return buffer._buffer.toString('utf8', start, end);
40787 } else if (buffer instanceof _buf.CombinedBuffer) {
40788 var out = streamDecodeCombinedBuffer(buffer, length, function (partBuffer) {
40789 return decoder.write(partBuffer._buffer);
40790 }, function () {
40791 return decoder.end();
40792 });
40793 return out;
40794 } else {
40795 throw (0, _error.newError)("Don't know how to decode strings from `" + buffer + "`.");
40796 }
40797 }
40798 };
40799} catch (e) {
40800
40801 // Not on NodeJS, add shim for WebAPI TextEncoder/TextDecoder
40802 var textEncoding = require('../../external/text-encoding/index');
40803 var encoder = new textEncoding.TextEncoder("utf-8");
40804 var _decoder = new textEncoding.TextDecoder("utf-8");
40805
40806 platformObj = {
40807 "encode": function encode(str) {
40808 return new _buf.HeapBuffer(encoder.encode(str).buffer);
40809 },
40810 "decode": function decode(buffer, length) {
40811 if (buffer instanceof _buf.HeapBuffer) {
40812 return _decoder.decode(buffer.readView(Math.min(length, buffer.length - buffer.position)));
40813 } else {
40814 // Decoding combined buffer is complicated. For simplicity, for now,
40815 // we simply copy the combined buffer into a regular buffer and decode that.
40816 var tmpBuf = (0, _buf.alloc)(length);
40817 for (var i = 0; i < length; i++) {
40818 tmpBuf.writeUInt8(buffer.readUInt8());
40819 }
40820 tmpBuf.reset();
40821 return _decoder.decode(tmpBuf.readView(length));
40822 }
40823 }
40824 };
40825}
40826
40827var streamDecodeCombinedBuffer = function streamDecodeCombinedBuffer(combinedBuffers, length, decodeFn, endFn) {
40828 var remainingBytesToRead = length;
40829 var position = combinedBuffers.position;
40830 combinedBuffers._updatePos(Math.min(length, combinedBuffers.length - position));
40831 // Reduce CombinedBuffers to a decoded string
40832 var out = combinedBuffers._buffers.reduce(function (last, partBuffer) {
40833 if (remainingBytesToRead <= 0) {
40834 return last;
40835 } else if (position >= partBuffer.length) {
40836 position -= partBuffer.length;
40837 return '';
40838 } else {
40839 partBuffer._updatePos(position - partBuffer.position);
40840 var bytesToRead = Math.min(partBuffer.length - position, remainingBytesToRead);
40841 var lastSlice = partBuffer.readSlice(bytesToRead);
40842 partBuffer._updatePos(bytesToRead);
40843 remainingBytesToRead = Math.max(remainingBytesToRead - lastSlice.length, 0);
40844 position = 0;
40845 return last + decodeFn(lastSlice);
40846 }
40847 }, '');
40848 return out + endFn();
40849};
40850
40851exports.default = platformObj;
40852
40853},{"../../external/text-encoding/index":319,"./../error":324,"./buf":329,"buffer":75,"string_decoder":315}],363:[function(require,module,exports){
40854"use strict";
40855
40856Object.defineProperty(exports, "__esModule", {
40857 value: true
40858});
40859exports.ENCRYPTION_OFF = exports.ENCRYPTION_ON = exports.validateStatementAndParameters = exports.assertString = exports.isString = exports.isEmptyObjectOrNull = undefined;
40860
40861var _stringify = require("babel-runtime/core-js/json/stringify");
40862
40863var _stringify2 = _interopRequireDefault(_stringify);
40864
40865var _typeof2 = require("babel-runtime/helpers/typeof");
40866
40867var _typeof3 = _interopRequireDefault(_typeof2);
40868
40869function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
40870
40871/**
40872 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
40873 *
40874 * This file is part of Neo4j.
40875 *
40876 * Licensed under the Apache License, Version 2.0 (the "License");
40877 * you may not use this file except in compliance with the License.
40878 * You may obtain a copy of the License at
40879 *
40880 * http://www.apache.org/licenses/LICENSE-2.0
40881 *
40882 * Unless required by applicable law or agreed to in writing, software
40883 * distributed under the License is distributed on an "AS IS" BASIS,
40884 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
40885 * See the License for the specific language governing permissions and
40886 * limitations under the License.
40887 */
40888
40889var ENCRYPTION_ON = "ENCRYPTION_ON";
40890var ENCRYPTION_OFF = "ENCRYPTION_OFF";
40891
40892function isEmptyObjectOrNull(obj) {
40893 if (obj === null) {
40894 return true;
40895 }
40896
40897 if (!isObject(obj)) {
40898 return false;
40899 }
40900
40901 for (var prop in obj) {
40902 if (obj.hasOwnProperty(prop)) {
40903 return false;
40904 }
40905 }
40906
40907 return true;
40908}
40909
40910function isObject(obj) {
40911 return (typeof obj === "undefined" ? "undefined" : (0, _typeof3.default)(obj)) === 'object' && !Array.isArray(obj) && obj !== null;
40912}
40913
40914/**
40915 * Check and normalize given statement and parameters.
40916 * @param {string|{text: string, parameters: object}} statement the statement to check.
40917 * @param {object} parameters
40918 * @return {{query: string, params: object}} the normalized query with parameters.
40919 * @throws TypeError when either given query or parameters are invalid.
40920 */
40921function validateStatementAndParameters(statement, parameters) {
40922 var query = statement;
40923 var params = parameters || {};
40924
40925 if ((typeof statement === "undefined" ? "undefined" : (0, _typeof3.default)(statement)) === 'object' && statement.text) {
40926 query = statement.text;
40927 params = statement.parameters || {};
40928 }
40929
40930 assertCypherStatement(query);
40931 assertQueryParameters(params);
40932
40933 return { query: query, params: params };
40934}
40935
40936function assertString(obj, objName) {
40937 if (!isString(obj)) {
40938 throw new TypeError(objName + ' expected to be string but was: ' + (0, _stringify2.default)(obj));
40939 }
40940 return obj;
40941}
40942
40943function assertCypherStatement(obj) {
40944 assertString(obj, 'Cypher statement');
40945 if (obj.trim().length === 0) {
40946 throw new TypeError('Cypher statement is expected to be a non-empty string.');
40947 }
40948}
40949
40950function assertQueryParameters(obj) {
40951 if (!isObject(obj)) {
40952 // objects created with `Object.create(null)` do not have a constructor property
40953 var _constructor = obj.constructor ? ' ' + obj.constructor.name : '';
40954 throw new TypeError("Query parameters are expected to either be undefined/null or an object, given:" + _constructor + " " + obj);
40955 }
40956}
40957
40958function isString(str) {
40959 return Object.prototype.toString.call(str) === '[object String]';
40960}
40961
40962exports.isEmptyObjectOrNull = isEmptyObjectOrNull;
40963exports.isString = isString;
40964exports.assertString = assertString;
40965exports.validateStatementAndParameters = validateStatementAndParameters;
40966exports.ENCRYPTION_ON = ENCRYPTION_ON;
40967exports.ENCRYPTION_OFF = ENCRYPTION_OFF;
40968
40969},{"babel-runtime/core-js/json/stringify":18,"babel-runtime/helpers/typeof":41}],364:[function(require,module,exports){
40970"use strict";
40971
40972Object.defineProperty(exports, "__esModule", {
40973 value: true
40974});
40975
40976var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
40977
40978var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
40979
40980var _createClass2 = require("babel-runtime/helpers/createClass");
40981
40982var _createClass3 = _interopRequireDefault(_createClass2);
40983
40984var _error = require("./error");
40985
40986function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
40987
40988function generateFieldLookup(keys) {
40989 var lookup = {};
40990 keys.forEach(function (name, idx) {
40991 lookup[name] = idx;
40992 });
40993 return lookup;
40994}
40995
40996/**
40997 * Records make up the contents of the {@link Result}, and is how you access
40998 * the output of a statement. A simple statement might yield a result stream
40999 * with a single record, for instance:
41000 *
41001 * MATCH (u:User) RETURN u.name, u.age
41002 *
41003 * This returns a stream of records with two fields, named `u.name` and `u.age`,
41004 * each record represents one user found by the statement above. You can access
41005 * the values of each field either by name:
41006 *
41007 * record.get("u.name")
41008 *
41009 * Or by it's position:
41010 *
41011 * record.get(0)
41012 *
41013 * @access public
41014 */
41015/**
41016 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
41017 *
41018 * This file is part of Neo4j.
41019 *
41020 * Licensed under the Apache License, Version 2.0 (the "License");
41021 * you may not use this file except in compliance with the License.
41022 * You may obtain a copy of the License at
41023 *
41024 * http://www.apache.org/licenses/LICENSE-2.0
41025 *
41026 * Unless required by applicable law or agreed to in writing, software
41027 * distributed under the License is distributed on an "AS IS" BASIS,
41028 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
41029 * See the License for the specific language governing permissions and
41030 * limitations under the License.
41031 */
41032
41033var Record = function () {
41034 /**
41035 * Create a new record object.
41036 * @constructor
41037 * @access private
41038 * @param {string[]} keys An array of field keys, in the order the fields appear in the record
41039 * @param {Array} fields An array of field values
41040 * @param {Object} fieldLookup An object of fieldName -> value index, used to map
41041 * field names to values. If this is null, one will be
41042 * generated.
41043 */
41044 function Record(keys, fields) {
41045 var fieldLookup = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
41046 (0, _classCallCheck3.default)(this, Record);
41047
41048 this.keys = keys;
41049 this.length = keys.length;
41050 this._fields = fields;
41051 this._fieldLookup = fieldLookup || generateFieldLookup(keys);
41052 }
41053
41054 /**
41055 * Run the given function for each field in this record. The function
41056 * will get three arguments - the value, the key and this record, in that
41057 * order.
41058 *
41059 * @param {function(value: Object, key: string, record: Record)} visitor the function to apply to each field.
41060 */
41061
41062
41063 (0, _createClass3.default)(Record, [{
41064 key: "forEach",
41065 value: function forEach(visitor) {
41066 for (var i = 0; i < this.keys.length; i++) {
41067 visitor(this._fields[i], this.keys[i], this);
41068 }
41069 }
41070
41071 /**
41072 * Generates an object out of the current Record
41073 *
41074 * @returns {Object}
41075 */
41076
41077 }, {
41078 key: "toObject",
41079 value: function toObject() {
41080 var object = {};
41081 this.forEach(function (value, key) {
41082 object[key] = value;
41083 });
41084
41085 return object;
41086 }
41087
41088 /**
41089 * Get a value from this record, either by index or by field key.
41090 *
41091 * @param {string|Number} key Field key, or the index of the field.
41092 * @returns {*}
41093 */
41094
41095 }, {
41096 key: "get",
41097 value: function get(key) {
41098 var index = void 0;
41099 if (!(typeof key === "number")) {
41100 index = this._fieldLookup[key];
41101 if (index === undefined) {
41102 throw (0, _error.newError)("This record has no field with key '" + key + "', available key are: [" + this.keys + "].");
41103 }
41104 } else {
41105 index = key;
41106 }
41107
41108 if (index > this._fields.length - 1 || index < 0) {
41109 throw (0, _error.newError)("This record has no field with index '" + index + "'. Remember that indexes start at `0`, " + "and make sure your statement returns records in the shape you meant it to.");
41110 }
41111
41112 return this._fields[index];
41113 }
41114
41115 /**
41116 * Check if a value from this record, either by index or by field key, exists.
41117 *
41118 * @param {string|Number} key Field key, or the index of the field.
41119 * @returns {boolean}
41120 */
41121
41122 }, {
41123 key: "has",
41124 value: function has(key) {
41125 // if key is a number, we check if it is in the _fields array
41126 if (typeof key === "number") {
41127 return key >= 0 && key < this._fields.length;
41128 }
41129
41130 // if it's not a number, we check _fieldLookup dictionary directly
41131 return this._fieldLookup[key] !== undefined;
41132 }
41133 }]);
41134 return Record;
41135}();
41136
41137exports.default = Record;
41138
41139},{"./error":324,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34}],365:[function(require,module,exports){
41140'use strict';
41141
41142Object.defineProperty(exports, "__esModule", {
41143 value: true
41144});
41145exports.statementType = undefined;
41146
41147var _keys = require('babel-runtime/core-js/object/keys');
41148
41149var _keys2 = _interopRequireDefault(_keys);
41150
41151var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
41152
41153var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
41154
41155var _createClass2 = require('babel-runtime/helpers/createClass');
41156
41157var _createClass3 = _interopRequireDefault(_createClass2);
41158
41159var _integer = require('./integer');
41160
41161function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
41162
41163/**
41164 * A ResultSummary instance contains structured metadata for a {Result}.
41165 * @access public
41166 */
41167var ResultSummary = function () {
41168 /**
41169 * @constructor
41170 * @param {string} statement - The statement this summary is for
41171 * @param {Object} parameters - Parameters for the statement
41172 * @param {Object} metadata - Statement metadata
41173 */
41174 function ResultSummary(statement, parameters, metadata) {
41175 (0, _classCallCheck3.default)(this, ResultSummary);
41176
41177 /**
41178 * The statement and parameters this summary is for.
41179 * @type {{text: string, parameters: Object}}
41180 * @public
41181 */
41182 this.statement = { text: statement, parameters: parameters };
41183
41184 /**
41185 * The type of statement executed. Can be "r" for read-only statement, "rw" for read-write statement,
41186 * "w" for write-only statement and "s" for schema-write statement.
41187 * String constants are available in {@link statementType} object.
41188 * @type {string}
41189 * @public
41190 */
41191 this.statementType = metadata.type;
41192
41193 /**
41194 * Counters for operations the statement triggered.
41195 * @type {StatementStatistics}
41196 * @public
41197 */
41198 this.counters = new StatementStatistics(metadata.stats || {});
41199 //for backwards compatibility, remove in future version
41200 this.updateStatistics = this.counters;
41201
41202 /**
41203 * This describes how the database will execute the statement.
41204 * Statement plan for the executed statement if available, otherwise undefined.
41205 * Will only be populated for queries that start with "EXPLAIN".
41206 * @type {Plan}
41207 */
41208 this.plan = metadata.plan || metadata.profile ? new Plan(metadata.plan || metadata.profile) : false;
41209
41210 /**
41211 * This describes how the database did execute your statement. This will contain detailed information about what
41212 * each step of the plan did. Profiled statement plan for the executed statement if available, otherwise undefined.
41213 * Will only be populated for queries that start with "PROFILE".
41214 * @type {ProfiledPlan}
41215 * @public
41216 */
41217 this.profile = metadata.profile ? new ProfiledPlan(metadata.profile) : false;
41218
41219 /**
41220 * An array of notifications that might arise when executing the statement. Notifications can be warnings about
41221 * problematic statements or other valuable information that can be presented in a client. Unlike failures
41222 * or errors, notifications do not affect the execution of a statement.
41223 * @type {Array<Notification>}
41224 * @public
41225 */
41226 this.notifications = this._buildNotifications(metadata.notifications);
41227
41228 /**
41229 * The basic information of the server where the result is obtained from.
41230 * @type {ServerInfo}
41231 * @public
41232 */
41233 this.server = new ServerInfo(metadata.server);
41234
41235 /**
41236 * The time it took the server to consume the result.
41237 * @type {number}
41238 * @public
41239 */
41240 this.resultConsumedAfter = metadata.result_consumed_after;
41241
41242 /**
41243 * The time it took the server to make the result available for consumption in milliseconds.
41244 * @type {number}
41245 * @public
41246 */
41247 this.resultAvailableAfter = metadata.result_available_after;
41248 }
41249
41250 (0, _createClass3.default)(ResultSummary, [{
41251 key: '_buildNotifications',
41252 value: function _buildNotifications(notifications) {
41253 if (!notifications) {
41254 return [];
41255 }
41256 return notifications.map(function (n) {
41257 return new Notification(n);
41258 });
41259 }
41260
41261 /**
41262 * Check if the result summary has a plan
41263 * @return {boolean}
41264 */
41265
41266 }, {
41267 key: 'hasPlan',
41268 value: function hasPlan() {
41269 return this.plan instanceof Plan;
41270 }
41271
41272 /**
41273 * Check if the result summary has a profile
41274 * @return {boolean}
41275 */
41276
41277 }, {
41278 key: 'hasProfile',
41279 value: function hasProfile() {
41280 return this.profile instanceof ProfiledPlan;
41281 }
41282 }]);
41283 return ResultSummary;
41284}();
41285
41286/**
41287 * Class for execution plan received by prepending Cypher with EXPLAIN.
41288 * @access public
41289 */
41290/**
41291 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
41292 *
41293 * This file is part of Neo4j.
41294 *
41295 * Licensed under the Apache License, Version 2.0 (the "License");
41296 * you may not use this file except in compliance with the License.
41297 * You may obtain a copy of the License at
41298 *
41299 * http://www.apache.org/licenses/LICENSE-2.0
41300 *
41301 * Unless required by applicable law or agreed to in writing, software
41302 * distributed under the License is distributed on an "AS IS" BASIS,
41303 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
41304 * See the License for the specific language governing permissions and
41305 * limitations under the License.
41306 */
41307
41308var Plan =
41309/**
41310 * Create a Plan instance
41311 * @constructor
41312 * @param {Object} plan - Object with plan data
41313 */
41314function Plan(plan) {
41315 (0, _classCallCheck3.default)(this, Plan);
41316
41317 this.operatorType = plan.operatorType;
41318 this.identifiers = plan.identifiers;
41319 this.arguments = plan.args;
41320 this.children = plan.children ? plan.children.map(function (child) {
41321 return new Plan(child);
41322 }) : [];
41323};
41324
41325/**
41326 * Class for execution plan received by prepending Cypher with PROFILE.
41327 * @access public
41328 */
41329
41330
41331var ProfiledPlan =
41332/**
41333 * Create a ProfiledPlan instance
41334 * @constructor
41335 * @param {Object} profile - Object with profile data
41336 */
41337function ProfiledPlan(profile) {
41338 (0, _classCallCheck3.default)(this, ProfiledPlan);
41339
41340 this.operatorType = profile.operatorType;
41341 this.identifiers = profile.identifiers;
41342 this.arguments = profile.args;
41343 this.dbHits = profile.args.DbHits.toInt();
41344 this.rows = profile.args.Rows.toInt();
41345 this.children = profile.children ? profile.children.map(function (child) {
41346 return new ProfiledPlan(child);
41347 }) : [];
41348};
41349
41350/**
41351 * Get statistical information for a {@link Result}.
41352 * @access public
41353 */
41354
41355
41356var StatementStatistics = function () {
41357 /**
41358 * Structurize the statistics
41359 * @constructor
41360 * @param {Object} statistics - Result statistics
41361 */
41362 function StatementStatistics(statistics) {
41363 var _this = this;
41364
41365 (0, _classCallCheck3.default)(this, StatementStatistics);
41366
41367 this._stats = {
41368 nodesCreated: 0,
41369 nodesDeleted: 0,
41370 relationshipsCreated: 0,
41371 relationshipsDeleted: 0,
41372 propertiesSet: 0,
41373 labelsAdded: 0,
41374 labelsRemoved: 0,
41375 indexesAdded: 0,
41376 indexesRemoved: 0,
41377 constraintsAdded: 0,
41378 constraintsRemoved: 0
41379 };
41380 (0, _keys2.default)(statistics).forEach(function (index) {
41381 //To camelCase
41382 _this._stats[index.replace(/(\-\w)/g, function (m) {
41383 return m[1].toUpperCase();
41384 })] = (0, _integer.isInt)(statistics[index]) ? statistics[index].toInt() : statistics[index];
41385 });
41386 }
41387
41388 /**
41389 * Did the database get updated?
41390 * @return {boolean}
41391 */
41392
41393
41394 (0, _createClass3.default)(StatementStatistics, [{
41395 key: 'containsUpdates',
41396 value: function containsUpdates() {
41397 var _this2 = this;
41398
41399 return (0, _keys2.default)(this._stats).reduce(function (last, current) {
41400 return last + _this2._stats[current];
41401 }, 0) > 0;
41402 }
41403
41404 /**
41405 * @return {Number} - Number of nodes created.
41406 */
41407
41408 }, {
41409 key: 'nodesCreated',
41410 value: function nodesCreated() {
41411 return this._stats.nodesCreated;
41412 }
41413
41414 /**
41415 * @return {Number} - Number of nodes deleted.
41416 */
41417
41418 }, {
41419 key: 'nodesDeleted',
41420 value: function nodesDeleted() {
41421 return this._stats.nodesDeleted;
41422 }
41423
41424 /**
41425 * @return {Number} - Number of relationships created.
41426 */
41427
41428 }, {
41429 key: 'relationshipsCreated',
41430 value: function relationshipsCreated() {
41431 return this._stats.relationshipsCreated;
41432 }
41433
41434 /**
41435 * @return {Number} - Number of nodes deleted.
41436 */
41437
41438 }, {
41439 key: 'relationshipsDeleted',
41440 value: function relationshipsDeleted() {
41441 return this._stats.relationshipsDeleted;
41442 }
41443
41444 /**
41445 * @return {Number} - Number of properties set.
41446 */
41447
41448 }, {
41449 key: 'propertiesSet',
41450 value: function propertiesSet() {
41451 return this._stats.propertiesSet;
41452 }
41453
41454 /**
41455 * @return {Number} - Number of labels added.
41456 */
41457
41458 }, {
41459 key: 'labelsAdded',
41460 value: function labelsAdded() {
41461 return this._stats.labelsAdded;
41462 }
41463
41464 /**
41465 * @return {Number} - Number of labels removed.
41466 */
41467
41468 }, {
41469 key: 'labelsRemoved',
41470 value: function labelsRemoved() {
41471 return this._stats.labelsRemoved;
41472 }
41473
41474 /**
41475 * @return {Number} - Number of indexes added.
41476 */
41477
41478 }, {
41479 key: 'indexesAdded',
41480 value: function indexesAdded() {
41481 return this._stats.indexesAdded;
41482 }
41483
41484 /**
41485 * @return {Number} - Number of indexes removed.
41486 */
41487
41488 }, {
41489 key: 'indexesRemoved',
41490 value: function indexesRemoved() {
41491 return this._stats.indexesRemoved;
41492 }
41493
41494 /**
41495 * @return {Number} - Number of constraints added.
41496 */
41497
41498 }, {
41499 key: 'constraintsAdded',
41500 value: function constraintsAdded() {
41501 return this._stats.constraintsAdded;
41502 }
41503
41504 /**
41505 * @return {Number} - Number of constraints removed.
41506 */
41507
41508 }, {
41509 key: 'constraintsRemoved',
41510 value: function constraintsRemoved() {
41511 return this._stats.constraintsRemoved;
41512 }
41513 }]);
41514 return StatementStatistics;
41515}();
41516
41517/**
41518 * Class for Cypher notifications
41519 * @access public
41520 */
41521
41522
41523var Notification = function () {
41524 /**
41525 * Create a Notification instance
41526 * @constructor
41527 * @param {Object} notification - Object with notification data
41528 */
41529 function Notification(notification) {
41530 (0, _classCallCheck3.default)(this, Notification);
41531
41532 this.code = notification.code;
41533 this.title = notification.title;
41534 this.description = notification.description;
41535 this.severity = notification.severity;
41536 this.position = Notification._constructPosition(notification.position);
41537 }
41538
41539 (0, _createClass3.default)(Notification, null, [{
41540 key: '_constructPosition',
41541 value: function _constructPosition(pos) {
41542 if (!pos) {
41543 return {};
41544 }
41545 return {
41546 offset: pos.offset.toInt(),
41547 line: pos.line.toInt(),
41548 column: pos.column.toInt()
41549 };
41550 }
41551 }]);
41552 return Notification;
41553}();
41554
41555/**
41556 * Class for exposing server info from a result.
41557 * @access public
41558 */
41559
41560
41561var ServerInfo =
41562/**
41563 * Create a ServerInfo instance
41564 * @constructor
41565 * @param {Object} serverMeta - Object with serverMeta data
41566 */
41567function ServerInfo(serverMeta) {
41568 (0, _classCallCheck3.default)(this, ServerInfo);
41569
41570 if (serverMeta) {
41571 this.address = serverMeta.address;
41572 this.version = serverMeta.version;
41573 }
41574};
41575
41576var statementType = {
41577 READ_ONLY: 'r',
41578 READ_WRITE: 'rw',
41579 WRITE_ONLY: 'w',
41580 SCHEMA_WRITE: 's'
41581};
41582
41583exports.statementType = statementType;
41584exports.default = ResultSummary;
41585
41586},{"./integer":327,"babel-runtime/core-js/object/keys":27,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34}],366:[function(require,module,exports){
41587'use strict';
41588
41589Object.defineProperty(exports, "__esModule", {
41590 value: true
41591});
41592
41593var _promise = require('babel-runtime/core-js/promise');
41594
41595var _promise2 = _interopRequireDefault(_promise);
41596
41597var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
41598
41599var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
41600
41601var _createClass2 = require('babel-runtime/helpers/createClass');
41602
41603var _createClass3 = _interopRequireDefault(_createClass2);
41604
41605var _resultSummary = require('./result-summary');
41606
41607var _resultSummary2 = _interopRequireDefault(_resultSummary);
41608
41609var _connectionHolder = require('./internal/connection-holder');
41610
41611function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
41612
41613/**
41614 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
41615 *
41616 * This file is part of Neo4j.
41617 *
41618 * Licensed under the Apache License, Version 2.0 (the "License");
41619 * you may not use this file except in compliance with the License.
41620 * You may obtain a copy of the License at
41621 *
41622 * http://www.apache.org/licenses/LICENSE-2.0
41623 *
41624 * Unless required by applicable law or agreed to in writing, software
41625 * distributed under the License is distributed on an "AS IS" BASIS,
41626 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
41627 * See the License for the specific language governing permissions and
41628 * limitations under the License.
41629 */
41630
41631var DEFAULT_ON_ERROR = function DEFAULT_ON_ERROR(error) {
41632 console.log('Uncaught error when processing result: ' + error);
41633};
41634var DEFAULT_ON_COMPLETED = function DEFAULT_ON_COMPLETED(summary) {};
41635
41636/**
41637 * A stream of {@link Record} representing the result of a statement.
41638 * Can be consumed eagerly as {@link Promise} resolved with array of records and {@link ResultSummary}
41639 * summary, or rejected with error that contains {@link string} code and {@link string} message.
41640 * Alternatively can be consumed lazily using <code>Result.subscribe()</code> function.
41641 * @access public
41642 */
41643
41644var Result = function () {
41645 /**
41646 * Inject the observer to be used.
41647 * @constructor
41648 * @access private
41649 * @param {StreamObserver} streamObserver
41650 * @param {mixed} statement - Cypher statement to execute
41651 * @param {Object} parameters - Map with parameters to use in statement
41652 * @param metaSupplier function, when called provides metadata
41653 * @param {ConnectionHolder} connectionHolder - to be notified when result is either fully consumed or error happened.
41654 */
41655 function Result(streamObserver, statement, parameters, metaSupplier, connectionHolder) {
41656 (0, _classCallCheck3.default)(this, Result);
41657
41658 this._stack = captureStacktrace();
41659 this._streamObserver = streamObserver;
41660 this._p = null;
41661 this._statement = statement;
41662 this._parameters = parameters || {};
41663 this._metaSupplier = metaSupplier || function () {
41664 return {};
41665 };
41666 this._connectionHolder = connectionHolder || _connectionHolder.EMPTY_CONNECTION_HOLDER;
41667 }
41668
41669 /**
41670 * Create and return new Promise
41671 * @return {Promise} new Promise.
41672 * @access private
41673 */
41674
41675
41676 (0, _createClass3.default)(Result, [{
41677 key: '_createPromise',
41678 value: function _createPromise() {
41679 if (this._p) {
41680 return;
41681 }
41682 var self = this;
41683 this._p = new _promise2.default(function (resolve, reject) {
41684 var records = [];
41685 var observer = {
41686 onNext: function onNext(record) {
41687 records.push(record);
41688 },
41689 onCompleted: function onCompleted(summary) {
41690 resolve({ records: records, summary: summary });
41691 },
41692 onError: function onError(error) {
41693 reject(error);
41694 }
41695 };
41696 self.subscribe(observer);
41697 });
41698 }
41699
41700 /**
41701 * Waits for all results and calls the passed in function with the results.
41702 * Cannot be combined with the <code>Result.subscribe()</code> function.
41703 *
41704 * @param {function(result: {records:Array<Record>, summary: ResultSummary})} onFulfilled - function to be called
41705 * when finished.
41706 * @param {function(error: {message:string, code:string})} onRejected - function to be called upon errors.
41707 * @return {Promise} promise.
41708 */
41709
41710 }, {
41711 key: 'then',
41712 value: function then(onFulfilled, onRejected) {
41713 this._createPromise();
41714 return this._p.then(onFulfilled, onRejected);
41715 }
41716
41717 /**
41718 * Catch errors when using promises.
41719 * Cannot be used with the subscribe function.
41720 * @param {function(error: Neo4jError)} onRejected - Function to be called upon errors.
41721 * @return {Promise} promise.
41722 */
41723
41724 }, {
41725 key: 'catch',
41726 value: function _catch(onRejected) {
41727 this._createPromise();
41728 return this._p.catch(onRejected);
41729 }
41730
41731 /**
41732 * Stream records to observer as they come in, this is a more efficient method
41733 * of handling the results, and allows you to handle arbitrarily large results.
41734 *
41735 * @param {Object} observer - Observer object
41736 * @param {function(record: Record)} observer.onNext - handle records, one by one.
41737 * @param {function(summary: ResultSummary)} observer.onCompleted - handle stream tail, the result summary.
41738 * @param {function(error: {message:string, code:string})} observer.onError - handle errors.
41739 * @return
41740 */
41741
41742 }, {
41743 key: 'subscribe',
41744 value: function subscribe(observer) {
41745 var _this = this;
41746
41747 var self = this;
41748
41749 var onCompletedOriginal = observer.onCompleted || DEFAULT_ON_COMPLETED;
41750 var onCompletedWrapper = function onCompletedWrapper(metadata) {
41751 var additionalMeta = self._metaSupplier();
41752 for (var key in additionalMeta) {
41753 if (additionalMeta.hasOwnProperty(key)) {
41754 metadata[key] = additionalMeta[key];
41755 }
41756 }
41757 var sum = new _resultSummary2.default(_this._statement, _this._parameters, metadata);
41758
41759 // notify connection holder that the used connection is not needed any more because result has
41760 // been fully consumed; call the original onCompleted callback after that
41761 self._connectionHolder.releaseConnection().then(function () {
41762 onCompletedOriginal.call(observer, sum);
41763 });
41764 };
41765 observer.onCompleted = onCompletedWrapper;
41766
41767 var onErrorOriginal = observer.onError || DEFAULT_ON_ERROR;
41768 var onErrorWrapper = function onErrorWrapper(error) {
41769 // notify connection holder that the used connection is not needed any more because error happened
41770 // and result can't bee consumed any further; call the original onError callback after that
41771 self._connectionHolder.releaseConnection().then(function () {
41772 replaceStacktrace(error, _this._stack);
41773 onErrorOriginal.call(observer, error);
41774 });
41775 };
41776 observer.onError = onErrorWrapper;
41777
41778 this._streamObserver.subscribe(observer);
41779 }
41780 }]);
41781 return Result;
41782}();
41783
41784function captureStacktrace() {
41785 var error = new Error('');
41786 if (error.stack) {
41787 return error.stack.replace(/^Error(\n\r)*/, ''); // we don't need the 'Error\n' part, if only it exists
41788 }
41789 return null;
41790}
41791
41792function replaceStacktrace(error, newStack) {
41793 if (newStack) {
41794 // Error.prototype.toString() concatenates error.name and error.message nicely
41795 // then we add the rest of the stack trace
41796 error.stack = error.toString() + '\n' + newStack;
41797 }
41798}
41799
41800exports.default = Result;
41801
41802},{"./internal/connection-holder":334,"./result-summary":365,"babel-runtime/core-js/promise":29,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34}],367:[function(require,module,exports){
41803'use strict';
41804
41805Object.defineProperty(exports, "__esModule", {
41806 value: true
41807});
41808
41809var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
41810
41811var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
41812
41813var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
41814
41815var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
41816
41817var _createClass2 = require('babel-runtime/helpers/createClass');
41818
41819var _createClass3 = _interopRequireDefault(_createClass2);
41820
41821var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
41822
41823var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
41824
41825var _inherits2 = require('babel-runtime/helpers/inherits');
41826
41827var _inherits3 = _interopRequireDefault(_inherits2);
41828
41829var _session = require('./session');
41830
41831var _session2 = _interopRequireDefault(_session);
41832
41833var _driver = require('./driver');
41834
41835var _error = require('./error');
41836
41837var _connectionProviders = require('./internal/connection-providers');
41838
41839var _leastConnectedLoadBalancingStrategy = require('./internal/least-connected-load-balancing-strategy');
41840
41841var _leastConnectedLoadBalancingStrategy2 = _interopRequireDefault(_leastConnectedLoadBalancingStrategy);
41842
41843var _roundRobinLoadBalancingStrategy = require('./internal/round-robin-load-balancing-strategy');
41844
41845var _roundRobinLoadBalancingStrategy2 = _interopRequireDefault(_roundRobinLoadBalancingStrategy);
41846
41847function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
41848
41849/**
41850 * A driver that supports routing in a causal cluster.
41851 * @private
41852 */
41853/**
41854 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
41855 *
41856 * This file is part of Neo4j.
41857 *
41858 * Licensed under the Apache License, Version 2.0 (the "License");
41859 * you may not use this file except in compliance with the License.
41860 * You may obtain a copy of the License at
41861 *
41862 * http://www.apache.org/licenses/LICENSE-2.0
41863 *
41864 * Unless required by applicable law or agreed to in writing, software
41865 * distributed under the License is distributed on an "AS IS" BASIS,
41866 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
41867 * See the License for the specific language governing permissions and
41868 * limitations under the License.
41869 */
41870
41871var RoutingDriver = function (_Driver) {
41872 (0, _inherits3.default)(RoutingDriver, _Driver);
41873
41874 function RoutingDriver(hostPort, routingContext, userAgent) {
41875 var token = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
41876 var config = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
41877 (0, _classCallCheck3.default)(this, RoutingDriver);
41878
41879 var _this = (0, _possibleConstructorReturn3.default)(this, (RoutingDriver.__proto__ || (0, _getPrototypeOf2.default)(RoutingDriver)).call(this, hostPort, userAgent, token, validateConfig(config)));
41880
41881 _this._routingContext = routingContext;
41882 return _this;
41883 }
41884
41885 (0, _createClass3.default)(RoutingDriver, [{
41886 key: '_createConnectionProvider',
41887 value: function _createConnectionProvider(hostPort, connectionPool, driverOnErrorCallback) {
41888 var loadBalancingStrategy = RoutingDriver._createLoadBalancingStrategy(this._config, connectionPool);
41889 return new _connectionProviders.LoadBalancer(hostPort, this._routingContext, connectionPool, loadBalancingStrategy, driverOnErrorCallback);
41890 }
41891 }, {
41892 key: '_createSession',
41893 value: function _createSession(mode, connectionProvider, bookmark, config) {
41894 var _this2 = this;
41895
41896 return new RoutingSession(mode, connectionProvider, bookmark, config, function (error, conn) {
41897 if (!conn) {
41898 // connection can be undefined if error happened before connection was acquired
41899 return error;
41900 }
41901
41902 var hostPort = conn.hostPort;
41903
41904 if (error.code === _error.SESSION_EXPIRED || isDatabaseUnavailable(error)) {
41905 _this2._connectionProvider.forget(hostPort);
41906 return error;
41907 } else if (isFailureToWrite(error)) {
41908 _this2._connectionProvider.forgetWriter(hostPort);
41909 return (0, _error.newError)('No longer possible to write to server at ' + hostPort, _error.SESSION_EXPIRED);
41910 } else {
41911 return error;
41912 }
41913 });
41914 }
41915 }, {
41916 key: '_connectionErrorCode',
41917 value: function _connectionErrorCode() {
41918 // connection errors mean SERVICE_UNAVAILABLE for direct driver but for routing driver they should only
41919 // result in SESSION_EXPIRED because there might still exist other servers capable of serving the request
41920 return _error.SESSION_EXPIRED;
41921 }
41922
41923 /**
41924 * Create new load balancing strategy based on the config.
41925 * @param {object} config the user provided config.
41926 * @param {Pool} connectionPool the connection pool for this driver.
41927 * @return {LoadBalancingStrategy} new strategy.
41928 * @private
41929 */
41930
41931 }], [{
41932 key: '_createLoadBalancingStrategy',
41933 value: function _createLoadBalancingStrategy(config, connectionPool) {
41934 var configuredValue = config.loadBalancingStrategy;
41935 if (!configuredValue || configuredValue === _leastConnectedLoadBalancingStrategy.LEAST_CONNECTED_STRATEGY_NAME) {
41936 return new _leastConnectedLoadBalancingStrategy2.default(connectionPool);
41937 } else if (configuredValue === _roundRobinLoadBalancingStrategy.ROUND_ROBIN_STRATEGY_NAME) {
41938 return new _roundRobinLoadBalancingStrategy2.default();
41939 } else {
41940 throw (0, _error.newError)('Unknown load balancing strategy: ' + configuredValue);
41941 }
41942 }
41943 }]);
41944 return RoutingDriver;
41945}(_driver.Driver);
41946
41947/**
41948 * @private
41949 */
41950
41951
41952function validateConfig(config) {
41953 if (config.trust === 'TRUST_ON_FIRST_USE') {
41954 throw (0, _error.newError)('The chosen trust mode is not compatible with a routing driver');
41955 }
41956 return config;
41957}
41958
41959/**
41960 * @private
41961 */
41962function isFailureToWrite(error) {
41963 return error.code === 'Neo.ClientError.Cluster.NotALeader' || error.code === 'Neo.ClientError.General.ForbiddenOnReadOnlyDatabase';
41964}
41965
41966/**
41967 * @private
41968 */
41969function isDatabaseUnavailable(error) {
41970 return error.code === 'Neo.TransientError.General.DatabaseUnavailable';
41971}
41972
41973/**
41974 * @private
41975 */
41976
41977var RoutingSession = function (_Session) {
41978 (0, _inherits3.default)(RoutingSession, _Session);
41979
41980 function RoutingSession(mode, connectionProvider, bookmark, config, onFailedConnection) {
41981 (0, _classCallCheck3.default)(this, RoutingSession);
41982
41983 var _this3 = (0, _possibleConstructorReturn3.default)(this, (RoutingSession.__proto__ || (0, _getPrototypeOf2.default)(RoutingSession)).call(this, mode, connectionProvider, bookmark, config));
41984
41985 _this3._onFailedConnection = onFailedConnection;
41986 return _this3;
41987 }
41988
41989 (0, _createClass3.default)(RoutingSession, [{
41990 key: '_onRunFailure',
41991 value: function _onRunFailure() {
41992 return this._onFailedConnection;
41993 }
41994 }]);
41995 return RoutingSession;
41996}(_session2.default);
41997
41998exports.default = RoutingDriver;
41999
42000},{"./driver":323,"./error":324,"./internal/connection-providers":335,"./internal/least-connected-load-balancing-strategy":345,"./internal/round-robin-load-balancing-strategy":354,"./session":368,"babel-runtime/core-js/object/get-prototype-of":26,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34,"babel-runtime/helpers/inherits":37,"babel-runtime/helpers/possibleConstructorReturn":38}],368:[function(require,module,exports){
42001'use strict';
42002
42003Object.defineProperty(exports, "__esModule", {
42004 value: true
42005});
42006
42007var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
42008
42009var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
42010
42011var _createClass2 = require('babel-runtime/helpers/createClass');
42012
42013var _createClass3 = _interopRequireDefault(_createClass2);
42014
42015var _streamObserver = require('./internal/stream-observer');
42016
42017var _streamObserver2 = _interopRequireDefault(_streamObserver);
42018
42019var _result = require('./result');
42020
42021var _result2 = _interopRequireDefault(_result);
42022
42023var _transaction = require('./transaction');
42024
42025var _transaction2 = _interopRequireDefault(_transaction);
42026
42027var _error = require('./error');
42028
42029var _util = require('./internal/util');
42030
42031var _connectionHolder = require('./internal/connection-holder');
42032
42033var _connectionHolder2 = _interopRequireDefault(_connectionHolder);
42034
42035var _driver = require('./driver');
42036
42037var _driver2 = _interopRequireDefault(_driver);
42038
42039var _transactionExecutor = require('./internal/transaction-executor');
42040
42041var _transactionExecutor2 = _interopRequireDefault(_transactionExecutor);
42042
42043var _bookmark = require('./internal/bookmark');
42044
42045var _bookmark2 = _interopRequireDefault(_bookmark);
42046
42047function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
42048
42049/**
42050 * A Session instance is used for handling the connection and
42051 * sending statements through the connection.
42052 * @access public
42053 */
42054
42055var Session = function () {
42056
42057 /**
42058 * @constructor
42059 * @param {string} mode the default access mode for this session.
42060 * @param {ConnectionProvider} connectionProvider - the connection provider to acquire connections from.
42061 * @param {Bookmark} bookmark - the initial bookmark for this session.
42062 * @param {Object} [config={}] - this driver configuration.
42063 */
42064 function Session(mode, connectionProvider, bookmark, config) {
42065 (0, _classCallCheck3.default)(this, Session);
42066
42067 this._mode = mode;
42068 this._readConnectionHolder = new _connectionHolder2.default(_driver.READ, connectionProvider);
42069 this._writeConnectionHolder = new _connectionHolder2.default(_driver.WRITE, connectionProvider);
42070 this._open = true;
42071 this._hasTx = false;
42072 this._lastBookmark = bookmark;
42073 this._transactionExecutor = _createTransactionExecutor(config);
42074 }
42075
42076 /**
42077 * Run Cypher statement
42078 * Could be called with a statement object i.e.: {text: "MATCH ...", parameters: {param: 1}}
42079 * or with the statement and parameters as separate arguments.
42080 * @param {mixed} statement - Cypher statement to execute
42081 * @param {Object} parameters - Map with parameters to use in statement
42082 * @return {Result} - New Result
42083 */
42084
42085
42086 (0, _createClass3.default)(Session, [{
42087 key: 'run',
42088 value: function run(statement) {
42089 var parameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
42090
42091 var _validateStatementAnd = (0, _util.validateStatementAndParameters)(statement, parameters),
42092 query = _validateStatementAnd.query,
42093 params = _validateStatementAnd.params;
42094
42095 return this._run(query, params, function (connection, streamObserver) {
42096 return connection.run(query, params, streamObserver);
42097 });
42098 }
42099 }, {
42100 key: '_run',
42101 value: function _run(statement, parameters, statementRunner) {
42102 var streamObserver = new _streamObserver2.default(this._onRunFailure());
42103 var connectionHolder = this._connectionHolderWithMode(this._mode);
42104 if (!this._hasTx) {
42105 connectionHolder.initializeConnection();
42106 connectionHolder.getConnection(streamObserver).then(function (connection) {
42107 statementRunner(connection, streamObserver);
42108 connection.pullAll(streamObserver);
42109 connection.sync();
42110 }).catch(function (error) {
42111 return streamObserver.onError(error);
42112 });
42113 } else {
42114 streamObserver.onError((0, _error.newError)('Statements cannot be run directly on a ' + 'session with an open transaction; either run from within the ' + 'transaction or use a different session.'));
42115 }
42116 return new _result2.default(streamObserver, statement, parameters, function () {
42117 return streamObserver.serverMetadata();
42118 }, connectionHolder);
42119 }
42120
42121 /**
42122 * Begin a new transaction in this session. A session can have at most one transaction running at a time, if you
42123 * want to run multiple concurrent transactions, you should use multiple concurrent sessions.
42124 *
42125 * While a transaction is open the session cannot be used to run statements outside the transaction.
42126 *
42127 * @param {string|string[]} [bookmarkOrBookmarks=null] - reference or references to some previous transactions.
42128 * DEPRECATED: This parameter is deprecated in favour of {@link Driver#session} that accepts an initial bookmark.
42129 * Session will ensure that all nested transactions are chained with bookmarks to guarantee causal consistency.
42130 * @returns {Transaction} - New Transaction
42131 */
42132
42133 }, {
42134 key: 'beginTransaction',
42135 value: function beginTransaction(bookmarkOrBookmarks) {
42136 this._updateBookmark(new _bookmark2.default(bookmarkOrBookmarks));
42137 return this._beginTransaction(this._mode);
42138 }
42139 }, {
42140 key: '_beginTransaction',
42141 value: function _beginTransaction(accessMode) {
42142 var _this = this;
42143
42144 if (this._hasTx) {
42145 throw (0, _error.newError)('You cannot begin a transaction on a session with an open transaction; ' + 'either run from within the transaction or use a different session.');
42146 }
42147
42148 var mode = _driver2.default._validateSessionMode(accessMode);
42149 var connectionHolder = this._connectionHolderWithMode(mode);
42150 connectionHolder.initializeConnection();
42151 this._hasTx = true;
42152
42153 return new _transaction2.default(connectionHolder, function () {
42154 _this._hasTx = false;
42155 }, this._onRunFailure(), this._lastBookmark, this._updateBookmark.bind(this));
42156 }
42157
42158 /**
42159 * Return the bookmark received following the last completed {@link Transaction}.
42160 *
42161 * @return {string|null} a reference to a previous transaction
42162 */
42163
42164 }, {
42165 key: 'lastBookmark',
42166 value: function lastBookmark() {
42167 return this._lastBookmark.maxBookmarkAsString();
42168 }
42169
42170 /**
42171 * Execute given unit of work in a {@link READ} transaction.
42172 *
42173 * Transaction will automatically be committed unless the given function throws or returns a rejected promise.
42174 * Some failures of the given function or the commit itself will be retried with exponential backoff with initial
42175 * delay of 1 second and maximum retry time of 30 seconds. Maximum retry time is configurable via driver config's
42176 * <code>maxTransactionRetryTime</code> property in milliseconds.
42177 *
42178 * @param {function(tx: Transaction): Promise} transactionWork - callback that executes operations against
42179 * a given {@link Transaction}.
42180 * @return {Promise} resolved promise as returned by the given function or rejected promise when given
42181 * function or commit fails.
42182 */
42183
42184 }, {
42185 key: 'readTransaction',
42186 value: function readTransaction(transactionWork) {
42187 return this._runTransaction(_driver.READ, transactionWork);
42188 }
42189
42190 /**
42191 * Execute given unit of work in a {@link WRITE} transaction.
42192 *
42193 * Transaction will automatically be committed unless the given function throws or returns a rejected promise.
42194 * Some failures of the given function or the commit itself will be retried with exponential backoff with initial
42195 * delay of 1 second and maximum retry time of 30 seconds. Maximum retry time is configurable via driver config's
42196 * <code>maxTransactionRetryTime</code> property in milliseconds.
42197 *
42198 * @param {function(tx: Transaction): Promise} transactionWork - callback that executes operations against
42199 * a given {@link Transaction}.
42200 * @return {Promise} resolved promise as returned by the given function or rejected promise when given
42201 * function or commit fails.
42202 */
42203
42204 }, {
42205 key: 'writeTransaction',
42206 value: function writeTransaction(transactionWork) {
42207 return this._runTransaction(_driver.WRITE, transactionWork);
42208 }
42209 }, {
42210 key: '_runTransaction',
42211 value: function _runTransaction(accessMode, transactionWork) {
42212 var _this2 = this;
42213
42214 return this._transactionExecutor.execute(function () {
42215 return _this2._beginTransaction(accessMode);
42216 }, transactionWork);
42217 }
42218
42219 /**
42220 * Update value of the last bookmark.
42221 * @param {Bookmark} newBookmark the new bookmark.
42222 * @private
42223 */
42224
42225 }, {
42226 key: '_updateBookmark',
42227 value: function _updateBookmark(newBookmark) {
42228 if (newBookmark && !newBookmark.isEmpty()) {
42229 this._lastBookmark = newBookmark;
42230 }
42231 }
42232
42233 /**
42234 * Close this session.
42235 * @param {function()} callback - Function to be called after the session has been closed
42236 * @return
42237 */
42238
42239 }, {
42240 key: 'close',
42241 value: function close() {
42242 var _this3 = this;
42243
42244 var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {
42245 return null;
42246 };
42247
42248 if (this._open) {
42249 this._open = false;
42250 this._transactionExecutor.close();
42251 this._readConnectionHolder.close().then(function () {
42252 _this3._writeConnectionHolder.close().then(function () {
42253 callback();
42254 });
42255 });
42256 } else {
42257 callback();
42258 }
42259 }
42260
42261 //Can be overridden to add error callback on RUN
42262
42263 }, {
42264 key: '_onRunFailure',
42265 value: function _onRunFailure() {
42266 return function (err) {
42267 return err;
42268 };
42269 }
42270 }, {
42271 key: '_connectionHolderWithMode',
42272 value: function _connectionHolderWithMode(mode) {
42273 if (mode === _driver.READ) {
42274 return this._readConnectionHolder;
42275 } else if (mode === _driver.WRITE) {
42276 return this._writeConnectionHolder;
42277 } else {
42278 throw (0, _error.newError)('Unknown access mode: ' + mode);
42279 }
42280 }
42281 }]);
42282 return Session;
42283}(); /**
42284 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
42285 *
42286 * This file is part of Neo4j.
42287 *
42288 * Licensed under the Apache License, Version 2.0 (the "License");
42289 * you may not use this file except in compliance with the License.
42290 * You may obtain a copy of the License at
42291 *
42292 * http://www.apache.org/licenses/LICENSE-2.0
42293 *
42294 * Unless required by applicable law or agreed to in writing, software
42295 * distributed under the License is distributed on an "AS IS" BASIS,
42296 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42297 * See the License for the specific language governing permissions and
42298 * limitations under the License.
42299 */
42300
42301
42302function _createTransactionExecutor(config) {
42303 var maxRetryTimeMs = config && config.maxTransactionRetryTime ? config.maxTransactionRetryTime : null;
42304 return new _transactionExecutor2.default(maxRetryTimeMs);
42305}
42306
42307exports.default = Session;
42308
42309},{"./driver":323,"./error":324,"./internal/bookmark":328,"./internal/connection-holder":334,"./internal/stream-observer":358,"./internal/transaction-executor":360,"./internal/util":363,"./result":366,"./transaction":371,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34}],369:[function(require,module,exports){
42310'use strict';
42311
42312Object.defineProperty(exports, "__esModule", {
42313 value: true
42314});
42315exports.Point = undefined;
42316
42317var _defineProperty = require('babel-runtime/core-js/object/define-property');
42318
42319var _defineProperty2 = _interopRequireDefault(_defineProperty);
42320
42321var _isInteger = require('babel-runtime/core-js/number/is-integer');
42322
42323var _isInteger2 = _interopRequireDefault(_isInteger);
42324
42325var _freeze = require('babel-runtime/core-js/object/freeze');
42326
42327var _freeze2 = _interopRequireDefault(_freeze);
42328
42329var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
42330
42331var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
42332
42333var _createClass2 = require('babel-runtime/helpers/createClass');
42334
42335var _createClass3 = _interopRequireDefault(_createClass2);
42336
42337exports.isPoint = isPoint;
42338
42339function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
42340
42341/**
42342 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
42343 *
42344 * This file is part of Neo4j.
42345 *
42346 * Licensed under the Apache License, Version 2.0 (the "License");
42347 * you may not use this file except in compliance with the License.
42348 * You may obtain a copy of the License at
42349 *
42350 * http://www.apache.org/licenses/LICENSE-2.0
42351 *
42352 * Unless required by applicable law or agreed to in writing, software
42353 * distributed under the License is distributed on an "AS IS" BASIS,
42354 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42355 * See the License for the specific language governing permissions and
42356 * limitations under the License.
42357 */
42358
42359var POINT_IDENTIFIER_PROPERTY = '__isPoint__';
42360
42361/**
42362 * Represents a single two or three-dimensional point in a particular coordinate reference system.
42363 * Created <code>Point</code> objects are frozen with {@link Object#freeze()} in constructor and thus immutable.
42364 */
42365
42366var Point = exports.Point = function () {
42367
42368 /**
42369 * @constructor
42370 * @param {Integer|number} srid the coordinate reference system identifier.
42371 * @param {number} x the <code>x</code> coordinate of the point.
42372 * @param {number} y the <code>y</code> coordinate of the point.
42373 * @param {number} [z=undefined] the <code>y</code> coordinate of the point or <code>undefined</code> if point has 2 dimensions.
42374 */
42375 function Point(srid, x, y, z) {
42376 (0, _classCallCheck3.default)(this, Point);
42377
42378 this.srid = srid;
42379 this.x = x;
42380 this.y = y;
42381 this.z = z;
42382 (0, _freeze2.default)(this);
42383 }
42384
42385 (0, _createClass3.default)(Point, [{
42386 key: 'toString',
42387 value: function toString() {
42388 return this.z || this.z === 0 ? 'Point{srid=' + formatAsFloat(this.srid) + ', x=' + formatAsFloat(this.x) + ', y=' + formatAsFloat(this.y) + ', z=' + formatAsFloat(this.z) + '}' : 'Point{srid=' + formatAsFloat(this.srid) + ', x=' + formatAsFloat(this.x) + ', y=' + formatAsFloat(this.y) + '}';
42389 }
42390 }]);
42391 return Point;
42392}();
42393
42394function formatAsFloat(number) {
42395 return (0, _isInteger2.default)(number) ? number + '.0' : number.toString();
42396}
42397
42398(0, _defineProperty2.default)(Point.prototype, POINT_IDENTIFIER_PROPERTY, {
42399 value: true,
42400 enumerable: false,
42401 configurable: false
42402});
42403
42404/**
42405 * Test if given object is an instance of {@link Point} class.
42406 * @param {object} obj the object to test.
42407 * @return {boolean} <code>true</code> if given object is a {@link Point}, <code>false</code> otherwise.
42408 */
42409function isPoint(obj) {
42410 return (obj && obj[POINT_IDENTIFIER_PROPERTY]) === true;
42411}
42412
42413},{"babel-runtime/core-js/number/is-integer":19,"babel-runtime/core-js/object/define-property":23,"babel-runtime/core-js/object/freeze":24,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34}],370:[function(require,module,exports){
42414'use strict';
42415
42416Object.defineProperty(exports, "__esModule", {
42417 value: true
42418});
42419exports.DateTime = exports.LocalDateTime = exports.Date = exports.Time = exports.LocalTime = exports.Duration = undefined;
42420
42421var _slicedToArray2 = require('babel-runtime/helpers/slicedToArray');
42422
42423var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);
42424
42425var _defineProperty = require('babel-runtime/core-js/object/define-property');
42426
42427var _defineProperty2 = _interopRequireDefault(_defineProperty);
42428
42429var _freeze = require('babel-runtime/core-js/object/freeze');
42430
42431var _freeze2 = _interopRequireDefault(_freeze);
42432
42433var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
42434
42435var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
42436
42437var _createClass2 = require('babel-runtime/helpers/createClass');
42438
42439var _createClass3 = _interopRequireDefault(_createClass2);
42440
42441exports.isDuration = isDuration;
42442exports.isLocalTime = isLocalTime;
42443exports.isTime = isTime;
42444exports.isDate = isDate;
42445exports.isLocalDateTime = isLocalDateTime;
42446exports.isDateTime = isDateTime;
42447
42448var _temporalUtil = require('./internal/temporal-util');
42449
42450var _error = require('./error');
42451
42452function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
42453
42454/**
42455 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
42456 *
42457 * This file is part of Neo4j.
42458 *
42459 * Licensed under the Apache License, Version 2.0 (the "License");
42460 * you may not use this file except in compliance with the License.
42461 * You may obtain a copy of the License at
42462 *
42463 * http://www.apache.org/licenses/LICENSE-2.0
42464 *
42465 * Unless required by applicable law or agreed to in writing, software
42466 * distributed under the License is distributed on an "AS IS" BASIS,
42467 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42468 * See the License for the specific language governing permissions and
42469 * limitations under the License.
42470 */
42471
42472var IDENTIFIER_PROPERTY_ATTRIBUTES = {
42473 value: true,
42474 enumerable: false,
42475 configurable: false
42476};
42477
42478var DURATION_IDENTIFIER_PROPERTY = '__isDuration__';
42479var LOCAL_TIME_IDENTIFIER_PROPERTY = '__isLocalTime__';
42480var TIME_IDENTIFIER_PROPERTY = '__isTime__';
42481var DATE_IDENTIFIER_PROPERTY = '__isDate__';
42482var LOCAL_DATE_TIME_IDENTIFIER_PROPERTY = '__isLocalDateTime__';
42483var DATE_TIME_IDENTIFIER_PROPERTY = '__isDateTime__';
42484
42485/**
42486 * Represents an ISO 8601 duration. Contains both date-based values (years, months, days) and time-based values (seconds, nanoseconds).
42487 * Created <code>Duration</code> objects are frozen with {@link Object#freeze()} in constructor and thus immutable.
42488 */
42489
42490var Duration = exports.Duration = function () {
42491
42492 /**
42493 * @constructor
42494 * @param {Integer|number} months the number of months for the new duration.
42495 * @param {Integer|number} days the number of days for the new duration.
42496 * @param {Integer|number} seconds the number of seconds for the new duration.
42497 * @param {Integer|number} nanoseconds the number of nanoseconds for the new duration.
42498 */
42499 function Duration(months, days, seconds, nanoseconds) {
42500 (0, _classCallCheck3.default)(this, Duration);
42501
42502 this.months = months;
42503 this.days = days;
42504 this.seconds = seconds;
42505 this.nanoseconds = nanoseconds;
42506 (0, _freeze2.default)(this);
42507 }
42508
42509 (0, _createClass3.default)(Duration, [{
42510 key: 'toString',
42511 value: function toString() {
42512 return (0, _temporalUtil.durationToIsoString)(this.months, this.days, this.seconds, this.nanoseconds);
42513 }
42514 }]);
42515 return Duration;
42516}();
42517
42518(0, _defineProperty2.default)(Duration.prototype, DURATION_IDENTIFIER_PROPERTY, IDENTIFIER_PROPERTY_ATTRIBUTES);
42519
42520/**
42521 * Test if given object is an instance of {@link Duration} class.
42522 * @param {object} obj the object to test.
42523 * @return {boolean} <code>true</code> if given object is a {@link Duration}, <code>false</code> otherwise.
42524 */
42525function isDuration(obj) {
42526 return hasIdentifierProperty(obj, DURATION_IDENTIFIER_PROPERTY);
42527}
42528
42529/**
42530 * Represents an instant capturing the time of day, but not the date, nor the timezone.
42531 * Created <code>LocalTime</code> objects are frozen with {@link Object#freeze()} in constructor and thus immutable.
42532 */
42533
42534var LocalTime = exports.LocalTime = function () {
42535
42536 /**
42537 * @constructor
42538 * @param {Integer|number} hour the hour for the new local time.
42539 * @param {Integer|number} minute the minute for the new local time.
42540 * @param {Integer|number} second the second for the new local time.
42541 * @param {Integer|number} nanosecond the nanosecond for the new local time.
42542 */
42543 function LocalTime(hour, minute, second, nanosecond) {
42544 (0, _classCallCheck3.default)(this, LocalTime);
42545
42546 this.hour = hour;
42547 this.minute = minute;
42548 this.second = second;
42549 this.nanosecond = nanosecond;
42550 (0, _freeze2.default)(this);
42551 }
42552
42553 (0, _createClass3.default)(LocalTime, [{
42554 key: 'toString',
42555 value: function toString() {
42556 return (0, _temporalUtil.timeToIsoString)(this.hour, this.minute, this.second, this.nanosecond);
42557 }
42558 }]);
42559 return LocalTime;
42560}();
42561
42562(0, _defineProperty2.default)(LocalTime.prototype, LOCAL_TIME_IDENTIFIER_PROPERTY, IDENTIFIER_PROPERTY_ATTRIBUTES);
42563
42564/**
42565 * Test if given object is an instance of {@link LocalTime} class.
42566 * @param {object} obj the object to test.
42567 * @return {boolean} <code>true</code> if given object is a {@link LocalTime}, <code>false</code> otherwise.
42568 */
42569function isLocalTime(obj) {
42570 return hasIdentifierProperty(obj, LOCAL_TIME_IDENTIFIER_PROPERTY);
42571}
42572
42573/**
42574 * Represents an instant capturing the time of day, and the timezone offset in seconds, but not the date.
42575 * Created <code>Time</code> objects are frozen with {@link Object#freeze()} in constructor and thus immutable.
42576 */
42577
42578var Time = exports.Time = function () {
42579
42580 /**
42581 * @constructor
42582 * @param {Integer|number} hour the hour for the new local time.
42583 * @param {Integer|number} minute the minute for the new local time.
42584 * @param {Integer|number} second the second for the new local time.
42585 * @param {Integer|number} nanosecond the nanosecond for the new local time.
42586 * @param {Integer|number} timeZoneOffsetSeconds the time zone offset in seconds.
42587 */
42588 function Time(hour, minute, second, nanosecond, timeZoneOffsetSeconds) {
42589 (0, _classCallCheck3.default)(this, Time);
42590
42591 this.hour = hour;
42592 this.minute = minute;
42593 this.second = second;
42594 this.nanosecond = nanosecond;
42595 this.timeZoneOffsetSeconds = timeZoneOffsetSeconds;
42596 (0, _freeze2.default)(this);
42597 }
42598
42599 (0, _createClass3.default)(Time, [{
42600 key: 'toString',
42601 value: function toString() {
42602 return (0, _temporalUtil.timeToIsoString)(this.hour, this.minute, this.second, this.nanosecond) + (0, _temporalUtil.timeZoneOffsetToIsoString)(this.timeZoneOffsetSeconds);
42603 }
42604 }]);
42605 return Time;
42606}();
42607
42608(0, _defineProperty2.default)(Time.prototype, TIME_IDENTIFIER_PROPERTY, IDENTIFIER_PROPERTY_ATTRIBUTES);
42609
42610/**
42611 * Test if given object is an instance of {@link Time} class.
42612 * @param {object} obj the object to test.
42613 * @return {boolean} <code>true</code> if given object is a {@link Time}, <code>false</code> otherwise.
42614 */
42615function isTime(obj) {
42616 return hasIdentifierProperty(obj, TIME_IDENTIFIER_PROPERTY);
42617}
42618
42619/**
42620 * Represents an instant capturing the date, but not the time, nor the timezone.
42621 * Created <code>Date</code> objects are frozen with {@link Object#freeze()} in constructor and thus immutable.
42622 */
42623
42624var Date = exports.Date = function () {
42625
42626 /**
42627 * @constructor
42628 * @param {Integer|number} year the year for the new local date.
42629 * @param {Integer|number} month the month for the new local date.
42630 * @param {Integer|number} day the day for the new local date.
42631 */
42632 function Date(year, month, day) {
42633 (0, _classCallCheck3.default)(this, Date);
42634
42635 this.year = year;
42636 this.month = month;
42637 this.day = day;
42638 (0, _freeze2.default)(this);
42639 }
42640
42641 (0, _createClass3.default)(Date, [{
42642 key: 'toString',
42643 value: function toString() {
42644 return (0, _temporalUtil.dateToIsoString)(this.year, this.month, this.day);
42645 }
42646 }]);
42647 return Date;
42648}();
42649
42650(0, _defineProperty2.default)(Date.prototype, DATE_IDENTIFIER_PROPERTY, IDENTIFIER_PROPERTY_ATTRIBUTES);
42651
42652/**
42653 * Test if given object is an instance of {@link Date} class.
42654 * @param {object} obj the object to test.
42655 * @return {boolean} <code>true</code> if given object is a {@link Date}, <code>false</code> otherwise.
42656 */
42657function isDate(obj) {
42658 return hasIdentifierProperty(obj, DATE_IDENTIFIER_PROPERTY);
42659}
42660
42661/**
42662 * Represents an instant capturing the date and the time, but not the timezone.
42663 * Created <code>LocalDateTime</code> objects are frozen with {@link Object#freeze()} in constructor and thus immutable.
42664 */
42665
42666var LocalDateTime = exports.LocalDateTime = function () {
42667
42668 /**
42669 * @constructor
42670 * @param {Integer|number} year the year for the new local date.
42671 * @param {Integer|number} month the month for the new local date.
42672 * @param {Integer|number} day the day for the new local date.
42673 * @param {Integer|number} hour the hour for the new local time.
42674 * @param {Integer|number} minute the minute for the new local time.
42675 * @param {Integer|number} second the second for the new local time.
42676 * @param {Integer|number} nanosecond the nanosecond for the new local time.
42677 */
42678 function LocalDateTime(year, month, day, hour, minute, second, nanosecond) {
42679 (0, _classCallCheck3.default)(this, LocalDateTime);
42680
42681 this.year = year;
42682 this.month = month;
42683 this.day = day;
42684 this.hour = hour;
42685 this.minute = minute;
42686 this.second = second;
42687 this.nanosecond = nanosecond;
42688 (0, _freeze2.default)(this);
42689 }
42690
42691 (0, _createClass3.default)(LocalDateTime, [{
42692 key: 'toString',
42693 value: function toString() {
42694 return localDateTimeToString(this.year, this.month, this.day, this.hour, this.minute, this.second, this.nanosecond);
42695 }
42696 }]);
42697 return LocalDateTime;
42698}();
42699
42700(0, _defineProperty2.default)(LocalDateTime.prototype, LOCAL_DATE_TIME_IDENTIFIER_PROPERTY, IDENTIFIER_PROPERTY_ATTRIBUTES);
42701
42702/**
42703 * Test if given object is an instance of {@link LocalDateTime} class.
42704 * @param {object} obj the object to test.
42705 * @return {boolean} <code>true</code> if given object is a {@link LocalDateTime}, <code>false</code> otherwise.
42706 */
42707function isLocalDateTime(obj) {
42708 return hasIdentifierProperty(obj, LOCAL_DATE_TIME_IDENTIFIER_PROPERTY);
42709}
42710
42711/**
42712 * Represents an instant capturing the date, the time and the timezone identifier.
42713 * Created <code>DateTime</code> objects are frozen with {@link Object#freeze()} in constructor and thus immutable.
42714 */
42715
42716var DateTime = exports.DateTime = function () {
42717
42718 /**
42719 * @constructor
42720 * @param {Integer|number} year the year for the new date-time.
42721 * @param {Integer|number} month the month for the new date-time.
42722 * @param {Integer|number} day the day for the new date-time.
42723 * @param {Integer|number} hour the hour for the new date-time.
42724 * @param {Integer|number} minute the minute for the new date-time.
42725 * @param {Integer|number} second the second for the new date-time.
42726 * @param {Integer|number} nanosecond the nanosecond for the new date-time.
42727 * @param {Integer|number|null} timeZoneOffsetSeconds the total time zone offset in seconds for the new date-time. Either this argument or <code>timeZoneId</code> should be defined.
42728 * @param {string|null} timeZoneId the time zone id for the new date-time. Either this argument or <code>timeZoneOffsetSeconds</code> should be defined.
42729 */
42730 function DateTime(year, month, day, hour, minute, second, nanosecond, timeZoneOffsetSeconds, timeZoneId) {
42731 (0, _classCallCheck3.default)(this, DateTime);
42732
42733 this.year = year;
42734 this.month = month;
42735 this.day = day;
42736 this.hour = hour;
42737 this.minute = minute;
42738 this.second = second;
42739 this.nanosecond = nanosecond;
42740
42741 var _verifyTimeZoneArgume = verifyTimeZoneArguments(timeZoneOffsetSeconds, timeZoneId),
42742 _verifyTimeZoneArgume2 = (0, _slicedToArray3.default)(_verifyTimeZoneArgume, 2),
42743 offset = _verifyTimeZoneArgume2[0],
42744 id = _verifyTimeZoneArgume2[1];
42745
42746 this.timeZoneOffsetSeconds = offset;
42747 this.timeZoneId = id;
42748
42749 (0, _freeze2.default)(this);
42750 }
42751
42752 (0, _createClass3.default)(DateTime, [{
42753 key: 'toString',
42754 value: function toString() {
42755 var localDateTimeStr = localDateTimeToString(this.year, this.month, this.day, this.hour, this.minute, this.second, this.nanosecond);
42756 var timeZoneStr = this.timeZoneId ? '[' + this.timeZoneId + ']' : (0, _temporalUtil.timeZoneOffsetToIsoString)(this.timeZoneOffsetSeconds);
42757 return localDateTimeStr + timeZoneStr;
42758 }
42759 }]);
42760 return DateTime;
42761}();
42762
42763(0, _defineProperty2.default)(DateTime.prototype, DATE_TIME_IDENTIFIER_PROPERTY, IDENTIFIER_PROPERTY_ATTRIBUTES);
42764
42765/**
42766 * Test if given object is an instance of {@link DateTime} class.
42767 * @param {object} obj the object to test.
42768 * @return {boolean} <code>true</code> if given object is a {@link DateTime}, <code>false</code> otherwise.
42769 */
42770function isDateTime(obj) {
42771 return hasIdentifierProperty(obj, DATE_TIME_IDENTIFIER_PROPERTY);
42772}
42773
42774function hasIdentifierProperty(obj, property) {
42775 return (obj && obj[property]) === true;
42776}
42777
42778function localDateTimeToString(year, month, day, hour, minute, second, nanosecond) {
42779 return (0, _temporalUtil.dateToIsoString)(year, month, day) + 'T' + (0, _temporalUtil.timeToIsoString)(hour, minute, second, nanosecond);
42780}
42781
42782function verifyTimeZoneArguments(timeZoneOffsetSeconds, timeZoneId) {
42783 var offsetDefined = timeZoneOffsetSeconds || timeZoneOffsetSeconds === 0;
42784 var idDefined = timeZoneId && timeZoneId !== '';
42785
42786 if (offsetDefined && !idDefined) {
42787 return [timeZoneOffsetSeconds, null];
42788 } else if (!offsetDefined && idDefined) {
42789 return [null, timeZoneId];
42790 } else if (offsetDefined && idDefined) {
42791 throw (0, _error.newError)('Unable to create DateTime with both time zone offset and id. Please specify either of them. Given offset: ' + timeZoneOffsetSeconds + ' and id: ' + timeZoneId);
42792 } else {
42793 throw (0, _error.newError)('Unable to create DateTime without either time zone offset or id. Please specify either of them. Given offset: ' + timeZoneOffsetSeconds + ' and id: ' + timeZoneId);
42794 }
42795}
42796
42797},{"./error":324,"./internal/temporal-util":359,"babel-runtime/core-js/object/define-property":23,"babel-runtime/core-js/object/freeze":24,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34,"babel-runtime/helpers/slicedToArray":39}],371:[function(require,module,exports){
42798'use strict';
42799
42800Object.defineProperty(exports, "__esModule", {
42801 value: true
42802});
42803
42804var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
42805
42806var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
42807
42808var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
42809
42810var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
42811
42812var _get2 = require('babel-runtime/helpers/get');
42813
42814var _get3 = _interopRequireDefault(_get2);
42815
42816var _inherits2 = require('babel-runtime/helpers/inherits');
42817
42818var _inherits3 = _interopRequireDefault(_inherits2);
42819
42820var _promise = require('babel-runtime/core-js/promise');
42821
42822var _promise2 = _interopRequireDefault(_promise);
42823
42824var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
42825
42826var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
42827
42828var _createClass2 = require('babel-runtime/helpers/createClass');
42829
42830var _createClass3 = _interopRequireDefault(_createClass2);
42831
42832var _streamObserver = require('./internal/stream-observer');
42833
42834var _streamObserver2 = _interopRequireDefault(_streamObserver);
42835
42836var _result = require('./result');
42837
42838var _result2 = _interopRequireDefault(_result);
42839
42840var _util = require('./internal/util');
42841
42842var _connectionHolder = require('./internal/connection-holder');
42843
42844var _bookmark = require('./internal/bookmark');
42845
42846var _bookmark2 = _interopRequireDefault(_bookmark);
42847
42848function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
42849
42850/**
42851 * Represents a transaction in the Neo4j database.
42852 *
42853 * @access public
42854 */
42855var Transaction = function () {
42856 /**
42857 * @constructor
42858 * @param {ConnectionHolder} connectionHolder - the connection holder to get connection from.
42859 * @param {function()} onClose - Function to be called when transaction is committed or rolled back.
42860 * @param {function(error: Error): Error} errorTransformer callback use to transform error.
42861 * @param {Bookmark} bookmark bookmark for transaction begin.
42862 * @param {function(bookmark: Bookmark)} onBookmark callback invoked when new bookmark is produced.
42863 */
42864 function Transaction(connectionHolder, onClose, errorTransformer, bookmark, onBookmark) {
42865 (0, _classCallCheck3.default)(this, Transaction);
42866
42867 this._connectionHolder = connectionHolder;
42868 var streamObserver = new _TransactionStreamObserver(this);
42869
42870 this._connectionHolder.getConnection(streamObserver).then(function (conn) {
42871 conn.run('BEGIN', bookmark.asBeginTransactionParameters(), streamObserver);
42872 conn.pullAll(streamObserver);
42873 }).catch(function (error) {
42874 return streamObserver.onError(error);
42875 });
42876
42877 this._state = _states.ACTIVE;
42878 this._onClose = onClose;
42879 this._errorTransformer = errorTransformer;
42880 this._onBookmark = onBookmark;
42881 }
42882
42883 /**
42884 * Run Cypher statement
42885 * Could be called with a statement object i.e.: <code>{text: "MATCH ...", parameters: {param: 1}}</code>
42886 * or with the statement and parameters as separate arguments.
42887 * @param {mixed} statement - Cypher statement to execute
42888 * @param {Object} parameters - Map with parameters to use in statement
42889 * @return {Result} New Result
42890 */
42891
42892
42893 (0, _createClass3.default)(Transaction, [{
42894 key: 'run',
42895 value: function run(statement, parameters) {
42896 var _validateStatementAnd = (0, _util.validateStatementAndParameters)(statement, parameters),
42897 query = _validateStatementAnd.query,
42898 params = _validateStatementAnd.params;
42899
42900 return this._state.run(this._connectionHolder, new _TransactionStreamObserver(this), query, params);
42901 }
42902
42903 /**
42904 * Commits the transaction and returns the result.
42905 *
42906 * After committing the transaction can no longer be used.
42907 *
42908 * @returns {Result} New Result
42909 */
42910
42911 }, {
42912 key: 'commit',
42913 value: function commit() {
42914 var committed = this._state.commit(this._connectionHolder, new _TransactionStreamObserver(this));
42915 this._state = committed.state;
42916 //clean up
42917 this._onClose();
42918 return committed.result;
42919 }
42920
42921 /**
42922 * Rollbacks the transaction.
42923 *
42924 * After rolling back, the transaction can no longer be used.
42925 *
42926 * @returns {Result} New Result
42927 */
42928
42929 }, {
42930 key: 'rollback',
42931 value: function rollback() {
42932 var committed = this._state.rollback(this._connectionHolder, new _TransactionStreamObserver(this));
42933 this._state = committed.state;
42934 //clean up
42935 this._onClose();
42936 return committed.result;
42937 }
42938
42939 /**
42940 * Check if this transaction is active, which means commit and rollback did not happen.
42941 * @return {boolean} <code>true</code> when not committed and not rolled back, <code>false</code> otherwise.
42942 */
42943
42944 }, {
42945 key: 'isOpen',
42946 value: function isOpen() {
42947 return this._state == _states.ACTIVE;
42948 }
42949 }, {
42950 key: '_onError',
42951 value: function _onError() {
42952 var _this = this;
42953
42954 if (this.isOpen()) {
42955 // attempt to rollback, useful when Transaction#run() failed
42956 return this.rollback().catch(function (ignoredError) {
42957 // ignore all errors because it is best effort and transaction might already be rolled back
42958 }).then(function () {
42959 // after rollback attempt change this transaction's state to FAILED
42960 _this._state = _states.FAILED;
42961 });
42962 } else {
42963 // error happened in in-active transaction, just to the cleanup and change state to FAILED
42964 this._state = _states.FAILED;
42965 this._onClose();
42966 // no async actions needed - return resolved promise
42967 return _promise2.default.resolve();
42968 }
42969 }
42970 }]);
42971 return Transaction;
42972}();
42973
42974/** Internal stream observer used for transactional results*/
42975/**
42976 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
42977 *
42978 * This file is part of Neo4j.
42979 *
42980 * Licensed under the Apache License, Version 2.0 (the "License");
42981 * you may not use this file except in compliance with the License.
42982 * You may obtain a copy of the License at
42983 *
42984 * http://www.apache.org/licenses/LICENSE-2.0
42985 *
42986 * Unless required by applicable law or agreed to in writing, software
42987 * distributed under the License is distributed on an "AS IS" BASIS,
42988 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42989 * See the License for the specific language governing permissions and
42990 * limitations under the License.
42991 */
42992
42993
42994var _TransactionStreamObserver = function (_StreamObserver) {
42995 (0, _inherits3.default)(_TransactionStreamObserver, _StreamObserver);
42996
42997 function _TransactionStreamObserver(tx) {
42998 (0, _classCallCheck3.default)(this, _TransactionStreamObserver);
42999
43000 var _this2 = (0, _possibleConstructorReturn3.default)(this, (_TransactionStreamObserver.__proto__ || (0, _getPrototypeOf2.default)(_TransactionStreamObserver)).call(this, tx._errorTransformer || function (err) {
43001 return err;
43002 }));
43003
43004 _this2._tx = tx;
43005 //this is to to avoid multiple calls to onError caused by IGNORED
43006 _this2._hasFailed = false;
43007 return _this2;
43008 }
43009
43010 (0, _createClass3.default)(_TransactionStreamObserver, [{
43011 key: 'onError',
43012 value: function onError(error) {
43013 var _this3 = this;
43014
43015 if (!this._hasFailed) {
43016 this._tx._onError().then(function () {
43017 (0, _get3.default)(_TransactionStreamObserver.prototype.__proto__ || (0, _getPrototypeOf2.default)(_TransactionStreamObserver.prototype), 'onError', _this3).call(_this3, error);
43018 _this3._hasFailed = true;
43019 });
43020 }
43021 }
43022 }, {
43023 key: 'onCompleted',
43024 value: function onCompleted(meta) {
43025 (0, _get3.default)(_TransactionStreamObserver.prototype.__proto__ || (0, _getPrototypeOf2.default)(_TransactionStreamObserver.prototype), 'onCompleted', this).call(this, meta);
43026 var bookmark = new _bookmark2.default(meta.bookmark);
43027 this._tx._onBookmark(bookmark);
43028 }
43029 }]);
43030 return _TransactionStreamObserver;
43031}(_streamObserver2.default);
43032
43033/** internal state machine of the transaction*/
43034
43035
43036var _states = {
43037 //The transaction is running with no explicit success or failure marked
43038 ACTIVE: {
43039 commit: function commit(connectionHolder, observer) {
43040 return { result: _runPullAll("COMMIT", connectionHolder, observer),
43041 state: _states.SUCCEEDED };
43042 },
43043 rollback: function rollback(connectionHolder, observer) {
43044 return { result: _runPullAll("ROLLBACK", connectionHolder, observer), state: _states.ROLLED_BACK };
43045 },
43046 run: function run(connectionHolder, observer, statement, parameters) {
43047 connectionHolder.getConnection(observer).then(function (conn) {
43048 conn.run(statement, parameters || {}, observer);
43049 conn.pullAll(observer);
43050 conn.sync();
43051 }).catch(function (error) {
43052 return observer.onError(error);
43053 });
43054
43055 return _newRunResult(observer, statement, parameters, function () {
43056 return observer.serverMetadata();
43057 });
43058 }
43059 },
43060
43061 //An error has occurred, transaction can no longer be used and no more messages will
43062 // be sent for this transaction.
43063 FAILED: {
43064 commit: function commit(connectionHolder, observer) {
43065 observer.onError({
43066 error: "Cannot commit statements in this transaction, because previous statements in the " + "transaction has failed and the transaction has been rolled back. Please start a new" + " transaction to run another statement."
43067 });
43068 return { result: _newDummyResult(observer, "COMMIT", {}), state: _states.FAILED };
43069 },
43070 rollback: function rollback(connectionHolder, observer) {
43071 observer.onError({ error: "Cannot rollback transaction, because previous statements in the " + "transaction has failed and the transaction has already been rolled back." });
43072 return { result: _newDummyResult(observer, "ROLLBACK", {}), state: _states.FAILED };
43073 },
43074 run: function run(connectionHolder, observer, statement, parameters) {
43075 observer.onError({ error: "Cannot run statement, because previous statements in the " + "transaction has failed and the transaction has already been rolled back." });
43076 return _newDummyResult(observer, statement, parameters);
43077 }
43078 },
43079
43080 //This transaction has successfully committed
43081 SUCCEEDED: {
43082 commit: function commit(connectionHolder, observer) {
43083 observer.onError({
43084 error: "Cannot commit statements in this transaction, because commit has already been successfully called on the transaction and transaction has been closed. Please start a new" + " transaction to run another statement."
43085 });
43086 return { result: _newDummyResult(observer, "COMMIT", {}), state: _states.SUCCEEDED };
43087 },
43088 rollback: function rollback(connectionHolder, observer) {
43089 observer.onError({ error: "Cannot rollback transaction, because transaction has already been successfully closed." });
43090 return { result: _newDummyResult(observer, "ROLLBACK", {}), state: _states.SUCCEEDED };
43091 },
43092 run: function run(connectionHolder, observer, statement, parameters) {
43093 observer.onError({ error: "Cannot run statement, because transaction has already been successfully closed." });
43094 return _newDummyResult(observer, statement, parameters);
43095 }
43096 },
43097
43098 //This transaction has been rolled back
43099 ROLLED_BACK: {
43100 commit: function commit(connectionHolder, observer) {
43101 observer.onError({
43102 error: "Cannot commit this transaction, because it has already been rolled back."
43103 });
43104 return { result: _newDummyResult(observer, "COMMIT", {}), state: _states.ROLLED_BACK };
43105 },
43106 rollback: function rollback(connectionHolder, observer) {
43107 observer.onError({ error: "Cannot rollback transaction, because transaction has already been rolled back." });
43108 return { result: _newDummyResult(observer, "ROLLBACK", {}), state: _states.ROLLED_BACK };
43109 },
43110 run: function run(connectionHolder, observer, statement, parameters) {
43111 observer.onError({ error: "Cannot run statement, because transaction has already been rolled back." });
43112 return _newDummyResult(observer, statement, parameters);
43113 }
43114 }
43115};
43116
43117function _runPullAll(msg, connectionHolder, observer) {
43118 connectionHolder.getConnection(observer).then(function (conn) {
43119 conn.run(msg, {}, observer);
43120 conn.pullAll(observer);
43121 conn.sync();
43122 }).catch(function (error) {
43123 return observer.onError(error);
43124 });
43125
43126 // for commit & rollback we need result that uses real connection holder and notifies it when
43127 // connection is not needed and can be safely released to the pool
43128 return new _result2.default(observer, msg, {}, emptyMetadataSupplier, connectionHolder);
43129}
43130
43131/**
43132 * Creates a {@link Result} with empty connection holder.
43133 * Should be used as a result for running cypher statements. They can result in metadata but should not
43134 * influence real connection holder to release connections because single transaction can have
43135 * {@link Transaction#run} called multiple times.
43136 * @param {StreamObserver} observer - an observer for the created result.
43137 * @param {string} statement - the cypher statement that produced the result.
43138 * @param {object} parameters - the parameters for cypher statement that produced the result.
43139 * @param {function} metadataSupplier - the function that returns a metadata object.
43140 * @return {Result} new result.
43141 * @private
43142 */
43143function _newRunResult(observer, statement, parameters, metadataSupplier) {
43144 return new _result2.default(observer, statement, parameters, metadataSupplier, _connectionHolder.EMPTY_CONNECTION_HOLDER);
43145}
43146
43147/**
43148 * Creates a {@link Result} without metadata supplier and with empty connection holder.
43149 * For cases when result represents an intermediate or failed action, does not require any metadata and does not
43150 * need to influence real connection holder to release connections.
43151 * @param {StreamObserver} observer - an observer for the created result.
43152 * @param {string} statement - the cypher statement that produced the result.
43153 * @param {object} parameters - the parameters for cypher statement that produced the result.
43154 * @return {Result} new result.
43155 * @private
43156 */
43157function _newDummyResult(observer, statement, parameters) {
43158 return new _result2.default(observer, statement, parameters, emptyMetadataSupplier, _connectionHolder.EMPTY_CONNECTION_HOLDER);
43159}
43160
43161function emptyMetadataSupplier() {
43162 return {};
43163}
43164
43165exports.default = Transaction;
43166
43167},{"./internal/bookmark":328,"./internal/connection-holder":334,"./internal/stream-observer":358,"./internal/util":363,"./result":366,"babel-runtime/core-js/object/get-prototype-of":26,"babel-runtime/core-js/promise":29,"babel-runtime/helpers/classCallCheck":33,"babel-runtime/helpers/createClass":34,"babel-runtime/helpers/get":36,"babel-runtime/helpers/inherits":37,"babel-runtime/helpers/possibleConstructorReturn":38}],372:[function(require,module,exports){
43168"use strict";
43169
43170Object.defineProperty(exports, "__esModule", {
43171 value: true
43172});
43173/**
43174 * Copyright (c) 2002-2018 Neo4j Sweden AB [http://neo4j.com]
43175 *
43176 * This file is part of Neo4j.
43177 *
43178 * Licensed under the Apache License, Version 2.0 (the "License");
43179 * you may not use this file except in compliance with the License.
43180 * You may obtain a copy of the License at
43181 *
43182 * http://www.apache.org/licenses/LICENSE-2.0
43183 *
43184 * Unless required by applicable law or agreed to in writing, software
43185 * distributed under the License is distributed on an "AS IS" BASIS,
43186 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
43187 * See the License for the specific language governing permissions and
43188 * limitations under the License.
43189 */
43190
43191// DO NOT CHANGE THE VERSION BELOW HERE
43192// This is set by the build system at release time, using
43193// gulp set --version <releaseversion>
43194//
43195// This is set up this way to keep the version in the code in
43196// sync with the npm package version, and to allow the build
43197// system to control version names at packaging time.
43198exports.default = "1.6.0";
43199
43200},{}]},{},[322])(322)
43201});
\No newline at end of file