1 | function createCommonjsModule(fn, module) {
|
2 | return module = { exports: {} }, fn(module, module.exports), module.exports;
|
3 | }
|
4 |
|
5 | var _global = createCommonjsModule(function (module) {
|
6 |
|
7 | var global = module.exports = typeof window != 'undefined' && window.Math == Math
|
8 | ? window : typeof self != 'undefined' && self.Math == Math ? self
|
9 |
|
10 | : Function('return this')();
|
11 | if (typeof __g == 'number') __g = global;
|
12 | });
|
13 |
|
14 | var _core = createCommonjsModule(function (module) {
|
15 | var core = module.exports = { version: '2.5.7' };
|
16 | if (typeof __e == 'number') __e = core;
|
17 | });
|
18 | var _core_1 = _core.version;
|
19 |
|
20 | var _isObject = function (it) {
|
21 | return typeof it === 'object' ? it !== null : typeof it === 'function';
|
22 | };
|
23 |
|
24 | var _anObject = function (it) {
|
25 | if (!_isObject(it)) throw TypeError(it + ' is not an object!');
|
26 | return it;
|
27 | };
|
28 |
|
29 | var _fails = function (exec) {
|
30 | try {
|
31 | return !!exec();
|
32 | } catch (e) {
|
33 | return true;
|
34 | }
|
35 | };
|
36 |
|
37 |
|
38 | var _descriptors = !_fails(function () {
|
39 | return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
|
40 | });
|
41 |
|
42 | var document$1 = _global.document;
|
43 |
|
44 | var is = _isObject(document$1) && _isObject(document$1.createElement);
|
45 | var _domCreate = function (it) {
|
46 | return is ? document$1.createElement(it) : {};
|
47 | };
|
48 |
|
49 | var _ie8DomDefine = !_descriptors && !_fails(function () {
|
50 | return Object.defineProperty(_domCreate('div'), 'a', { get: function () { return 7; } }).a != 7;
|
51 | });
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 | var _toPrimitive = function (it, S) {
|
58 | if (!_isObject(it)) return it;
|
59 | var fn, val;
|
60 | if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
|
61 | if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) return val;
|
62 | if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
|
63 | throw TypeError("Can't convert object to primitive value");
|
64 | };
|
65 |
|
66 | var dP = Object.defineProperty;
|
67 |
|
68 | var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) {
|
69 | _anObject(O);
|
70 | P = _toPrimitive(P, true);
|
71 | _anObject(Attributes);
|
72 | if (_ie8DomDefine) try {
|
73 | return dP(O, P, Attributes);
|
74 | } catch (e) { }
|
75 | if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
|
76 | if ('value' in Attributes) O[P] = Attributes.value;
|
77 | return O;
|
78 | };
|
79 |
|
80 | var _objectDp = {
|
81 | f: f
|
82 | };
|
83 |
|
84 | var _propertyDesc = function (bitmap, value) {
|
85 | return {
|
86 | enumerable: !(bitmap & 1),
|
87 | configurable: !(bitmap & 2),
|
88 | writable: !(bitmap & 4),
|
89 | value: value
|
90 | };
|
91 | };
|
92 |
|
93 | var _hide = _descriptors ? function (object, key, value) {
|
94 | return _objectDp.f(object, key, _propertyDesc(1, value));
|
95 | } : function (object, key, value) {
|
96 | object[key] = value;
|
97 | return object;
|
98 | };
|
99 |
|
100 | var hasOwnProperty = {}.hasOwnProperty;
|
101 | var _has = function (it, key) {
|
102 | return hasOwnProperty.call(it, key);
|
103 | };
|
104 |
|
105 | var id = 0;
|
106 | var px = Math.random();
|
107 | var _uid = function (key) {
|
108 | return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
|
109 | };
|
110 |
|
111 | var _redefine = createCommonjsModule(function (module) {
|
112 | var SRC = _uid('src');
|
113 | var TO_STRING = 'toString';
|
114 | var $toString = Function[TO_STRING];
|
115 | var TPL = ('' + $toString).split(TO_STRING);
|
116 |
|
117 | _core.inspectSource = function (it) {
|
118 | return $toString.call(it);
|
119 | };
|
120 |
|
121 | (module.exports = function (O, key, val, safe) {
|
122 | var isFunction = typeof val == 'function';
|
123 | if (isFunction) _has(val, 'name') || _hide(val, 'name', key);
|
124 | if (O[key] === val) return;
|
125 | if (isFunction) _has(val, SRC) || _hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
|
126 | if (O === _global) {
|
127 | O[key] = val;
|
128 | } else if (!safe) {
|
129 | delete O[key];
|
130 | _hide(O, key, val);
|
131 | } else if (O[key]) {
|
132 | O[key] = val;
|
133 | } else {
|
134 | _hide(O, key, val);
|
135 | }
|
136 |
|
137 | })(Function.prototype, TO_STRING, function toString() {
|
138 | return typeof this == 'function' && this[SRC] || $toString.call(this);
|
139 | });
|
140 | });
|
141 |
|
142 | var _aFunction = function (it) {
|
143 | if (typeof it != 'function') throw TypeError(it + ' is not a function!');
|
144 | return it;
|
145 | };
|
146 |
|
147 |
|
148 |
|
149 | var _ctx = function (fn, that, length) {
|
150 | _aFunction(fn);
|
151 | if (that === undefined) return fn;
|
152 | switch (length) {
|
153 | case 1: return function (a) {
|
154 | return fn.call(that, a);
|
155 | };
|
156 | case 2: return function (a, b) {
|
157 | return fn.call(that, a, b);
|
158 | };
|
159 | case 3: return function (a, b, c) {
|
160 | return fn.call(that, a, b, c);
|
161 | };
|
162 | }
|
163 | return function (/* ...args */) {
|
164 | return fn.apply(that, arguments);
|
165 | };
|
166 | };
|
167 |
|
168 | var PROTOTYPE = 'prototype';
|
169 |
|
170 | var $export = function (type, name, source) {
|
171 | var IS_FORCED = type & $export.F;
|
172 | var IS_GLOBAL = type & $export.G;
|
173 | var IS_STATIC = type & $export.S;
|
174 | var IS_PROTO = type & $export.P;
|
175 | var IS_BIND = type & $export.B;
|
176 | var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] || (_global[name] = {}) : (_global[name] || {})[PROTOTYPE];
|
177 | var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {});
|
178 | var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});
|
179 | var key, own, out, exp;
|
180 | if (IS_GLOBAL) source = name;
|
181 | for (key in source) {
|
182 |
|
183 | own = !IS_FORCED && target && target[key] !== undefined;
|
184 |
|
185 | out = (own ? target : source)[key];
|
186 |
|
187 | exp = IS_BIND && own ? _ctx(out, _global) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out;
|
188 |
|
189 | if (target) _redefine(target, key, out, type & $export.U);
|
190 |
|
191 | if (exports[key] != out) _hide(exports, key, exp);
|
192 | if (IS_PROTO && expProto[key] != out) expProto[key] = out;
|
193 | }
|
194 | };
|
195 | _global.core = _core;
|
196 |
|
197 | $export.F = 1;
|
198 | $export.G = 2;
|
199 | $export.S = 4;
|
200 | $export.P = 8;
|
201 | $export.B = 16;
|
202 | $export.W = 32;
|
203 | $export.U = 64;
|
204 | $export.R = 128;
|
205 | var _export = $export;
|
206 |
|
207 | var toString = {}.toString;
|
208 |
|
209 | var _cof = function (it) {
|
210 | return toString.call(it).slice(8, -1);
|
211 | };
|
212 |
|
213 |
|
214 |
|
215 |
|
216 | var _iobject = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
|
217 | return _cof(it) == 'String' ? it.split('') : Object(it);
|
218 | };
|
219 |
|
220 |
|
221 | var _defined = function (it) {
|
222 | if (it == undefined) throw TypeError("Can't call method on " + it);
|
223 | return it;
|
224 | };
|
225 |
|
226 |
|
227 |
|
228 |
|
229 | var _toIobject = function (it) {
|
230 | return _iobject(_defined(it));
|
231 | };
|
232 |
|
233 |
|
234 | var ceil = Math.ceil;
|
235 | var floor = Math.floor;
|
236 | var _toInteger = function (it) {
|
237 | return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
|
238 | };
|
239 |
|
240 |
|
241 |
|
242 | var min = Math.min;
|
243 | var _toLength = function (it) {
|
244 | return it > 0 ? min(_toInteger(it), 0x1fffffffffffff) : 0;
|
245 | };
|
246 |
|
247 | var max = Math.max;
|
248 | var min$1 = Math.min;
|
249 | var _toAbsoluteIndex = function (index, length) {
|
250 | index = _toInteger(index);
|
251 | return index < 0 ? max(index + length, 0) : min$1(index, length);
|
252 | };
|
253 |
|
254 |
|
255 |
|
256 |
|
257 |
|
258 |
|
259 | var _arrayIncludes = function (IS_INCLUDES) {
|
260 | return function ($this, el, fromIndex) {
|
261 | var O = _toIobject($this);
|
262 | var length = _toLength(O.length);
|
263 | var index = _toAbsoluteIndex(fromIndex, length);
|
264 | var value;
|
265 |
|
266 |
|
267 | if (IS_INCLUDES && el != el) while (length > index) {
|
268 | value = O[index++];
|
269 |
|
270 | if (value != value) return true;
|
271 |
|
272 | } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
|
273 | if (O[index] === el) return IS_INCLUDES || index || 0;
|
274 | } return !IS_INCLUDES && -1;
|
275 | };
|
276 | };
|
277 |
|
278 | var _library = false;
|
279 |
|
280 | var _shared = createCommonjsModule(function (module) {
|
281 | var SHARED = '__core-js_shared__';
|
282 | var store = _global[SHARED] || (_global[SHARED] = {});
|
283 |
|
284 | (module.exports = function (key, value) {
|
285 | return store[key] || (store[key] = value !== undefined ? value : {});
|
286 | })('versions', []).push({
|
287 | version: _core.version,
|
288 | mode: 'global',
|
289 | copyright: '© 2018 Denis Pushkarev (zloirock.ru)'
|
290 | });
|
291 | });
|
292 |
|
293 | var shared = _shared('keys');
|
294 |
|
295 | var _sharedKey = function (key) {
|
296 | return shared[key] || (shared[key] = _uid(key));
|
297 | };
|
298 |
|
299 | var arrayIndexOf = _arrayIncludes(false);
|
300 | var IE_PROTO = _sharedKey('IE_PROTO');
|
301 |
|
302 | var _objectKeysInternal = function (object, names) {
|
303 | var O = _toIobject(object);
|
304 | var i = 0;
|
305 | var result = [];
|
306 | var key;
|
307 | for (key in O) if (key != IE_PROTO) _has(O, key) && result.push(key);
|
308 |
|
309 | while (names.length > i) if (_has(O, key = names[i++])) {
|
310 | ~arrayIndexOf(result, key) || result.push(key);
|
311 | }
|
312 | return result;
|
313 | };
|
314 |
|
315 |
|
316 | var _enumBugKeys = (
|
317 | 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
|
318 | ).split(',');
|
319 |
|
320 |
|
321 |
|
322 |
|
323 |
|
324 | var _objectKeys = Object.keys || function keys(O) {
|
325 | return _objectKeysInternal(O, _enumBugKeys);
|
326 | };
|
327 |
|
328 | var f$1 = Object.getOwnPropertySymbols;
|
329 |
|
330 | var _objectGops = {
|
331 | f: f$1
|
332 | };
|
333 |
|
334 | var f$2 = {}.propertyIsEnumerable;
|
335 |
|
336 | var _objectPie = {
|
337 | f: f$2
|
338 | };
|
339 |
|
340 |
|
341 |
|
342 | var _toObject = function (it) {
|
343 | return Object(_defined(it));
|
344 | };
|
345 |
|
346 |
|
347 |
|
348 |
|
349 |
|
350 |
|
351 |
|
352 | var $assign = Object.assign;
|
353 |
|
354 |
|
355 | var _objectAssign = !$assign || _fails(function () {
|
356 | var A = {};
|
357 | var B = {};
|
358 |
|
359 | var S = Symbol();
|
360 | var K = 'abcdefghijklmnopqrst';
|
361 | A[S] = 7;
|
362 | K.split('').forEach(function (k) { B[k] = k; });
|
363 | return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
|
364 | }) ? function assign(target, source) {
|
365 | var T = _toObject(target);
|
366 | var aLen = arguments.length;
|
367 | var index = 1;
|
368 | var getSymbols = _objectGops.f;
|
369 | var isEnum = _objectPie.f;
|
370 | while (aLen > index) {
|
371 | var S = _iobject(arguments[index++]);
|
372 | var keys = getSymbols ? _objectKeys(S).concat(getSymbols(S)) : _objectKeys(S);
|
373 | var length = keys.length;
|
374 | var j = 0;
|
375 | var key;
|
376 | while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key];
|
377 | } return T;
|
378 | } : $assign;
|
379 |
|
380 |
|
381 |
|
382 |
|
383 | _export(_export.S + _export.F, 'Object', { assign: _objectAssign });
|
384 |
|
385 | function _typeof(obj) {
|
386 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
387 | _typeof = function (obj) {
|
388 | return typeof obj;
|
389 | };
|
390 | } else {
|
391 | _typeof = function (obj) {
|
392 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
393 | };
|
394 | }
|
395 |
|
396 | return _typeof(obj);
|
397 | }
|
398 |
|
399 | function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
400 | try {
|
401 | var info = gen[key](arg);
|
402 | var value = info.value;
|
403 | } catch (error) {
|
404 | reject(error);
|
405 | return;
|
406 | }
|
407 |
|
408 | if (info.done) {
|
409 | resolve(value);
|
410 | } else {
|
411 | Promise.resolve(value).then(_next, _throw);
|
412 | }
|
413 | }
|
414 |
|
415 | function _asyncToGenerator(fn) {
|
416 | return function () {
|
417 | var self = this,
|
418 | args = arguments;
|
419 | return new Promise(function (resolve, reject) {
|
420 | var gen = fn.apply(self, args);
|
421 |
|
422 | function _next(value) {
|
423 | asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
424 | }
|
425 |
|
426 | function _throw(err) {
|
427 | asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
428 | }
|
429 |
|
430 | _next(undefined);
|
431 | });
|
432 | };
|
433 | }
|
434 |
|
435 | function _classCallCheck(instance, Constructor) {
|
436 | if (!(instance instanceof Constructor)) {
|
437 | throw new TypeError("Cannot call a class as a function");
|
438 | }
|
439 | }
|
440 |
|
441 | function _defineProperties(target, props) {
|
442 | for (var i = 0; i < props.length; i++) {
|
443 | var descriptor = props[i];
|
444 | descriptor.enumerable = descriptor.enumerable || false;
|
445 | descriptor.configurable = true;
|
446 | if ("value" in descriptor) descriptor.writable = true;
|
447 | Object.defineProperty(target, descriptor.key, descriptor);
|
448 | }
|
449 | }
|
450 |
|
451 | function _createClass(Constructor, protoProps, staticProps) {
|
452 | if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
453 | if (staticProps) _defineProperties(Constructor, staticProps);
|
454 | return Constructor;
|
455 | }
|
456 |
|
457 | function _defineProperty(obj, key, value) {
|
458 | if (key in obj) {
|
459 | Object.defineProperty(obj, key, {
|
460 | value: value,
|
461 | enumerable: true,
|
462 | configurable: true,
|
463 | writable: true
|
464 | });
|
465 | } else {
|
466 | obj[key] = value;
|
467 | }
|
468 |
|
469 | return obj;
|
470 | }
|
471 |
|
472 | function _toConsumableArray(arr) {
|
473 | return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
|
474 | }
|
475 |
|
476 | function _arrayWithoutHoles(arr) {
|
477 | if (Array.isArray(arr)) {
|
478 | for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
|
479 |
|
480 | return arr2;
|
481 | }
|
482 | }
|
483 |
|
484 | function _iterableToArray(iter) {
|
485 | if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
|
486 | }
|
487 |
|
488 | function _nonIterableSpread() {
|
489 | throw new TypeError("Invalid attempt to spread non-iterable instance");
|
490 | }
|
491 |
|
492 |
|
493 |
|
494 |
|
495 |
|
496 | var Model =
|
497 |
|
498 | function () {
|
499 | function Model() {
|
500 | _classCallCheck(this, Model);
|
501 | }
|
502 |
|
503 | _createClass(Model, null, [{
|
504 | key: "deserialize",
|
505 |
|
506 | |
507 |
|
508 |
|
509 |
|
510 |
|
511 | value: function deserialize(record) {
|
512 | return Object.assign({}, record);
|
513 | }
|
514 | }, {
|
515 | key: "attributes",
|
516 |
|
517 | |
518 |
|
519 |
|
520 | get: function get() {
|
521 | return [];
|
522 | }
|
523 | |
524 |
|
525 |
|
526 |
|
527 | }, {
|
528 | key: "relationship",
|
529 | get: function get() {
|
530 | return {};
|
531 | }
|
532 | }]);
|
533 |
|
534 | return Model;
|
535 | }();
|
536 |
|
537 | var _wks = createCommonjsModule(function (module) {
|
538 | var store = _shared('wks');
|
539 |
|
540 | var Symbol = _global.Symbol;
|
541 | var USE_SYMBOL = typeof Symbol == 'function';
|
542 |
|
543 | var $exports = module.exports = function (name) {
|
544 | return store[name] || (store[name] =
|
545 | USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : _uid)('Symbol.' + name));
|
546 | };
|
547 |
|
548 | $exports.store = store;
|
549 | });
|
550 |
|
551 |
|
552 | var UNSCOPABLES = _wks('unscopables');
|
553 | var ArrayProto = Array.prototype;
|
554 | if (ArrayProto[UNSCOPABLES] == undefined) _hide(ArrayProto, UNSCOPABLES, {});
|
555 | var _addToUnscopables = function (key) {
|
556 | ArrayProto[UNSCOPABLES][key] = true;
|
557 | };
|
558 |
|
559 |
|
560 |
|
561 | var $includes = _arrayIncludes(true);
|
562 |
|
563 | _export(_export.P, 'Array', {
|
564 | includes: function includes(el /* , fromIndex = 0 */) {
|
565 | return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
|
566 | }
|
567 | });
|
568 |
|
569 | _addToUnscopables('includes');
|
570 |
|
571 |
|
572 |
|
573 |
|
574 | var MATCH = _wks('match');
|
575 | var _isRegexp = function (it) {
|
576 | var isRegExp;
|
577 | return _isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : _cof(it) == 'RegExp');
|
578 | };
|
579 |
|
580 |
|
581 |
|
582 |
|
583 |
|
584 | var _stringContext = function (that, searchString, NAME) {
|
585 | if (_isRegexp(searchString)) throw TypeError('String#' + NAME + " doesn't accept regex!");
|
586 | return String(_defined(that));
|
587 | };
|
588 |
|
589 | var MATCH$1 = _wks('match');
|
590 | var _failsIsRegexp = function (KEY) {
|
591 | var re = /./;
|
592 | try {
|
593 | '/./'[KEY](re);
|
594 | } catch (e) {
|
595 | try {
|
596 | re[MATCH$1] = false;
|
597 | return !'/./'[KEY](re);
|
598 | } catch (f) { }
|
599 | } return true;
|
600 | };
|
601 |
|
602 | var INCLUDES = 'includes';
|
603 |
|
604 | _export(_export.P + _export.F * _failsIsRegexp(INCLUDES), 'String', {
|
605 | includes: function includes(searchString /* , position = 0 */) {
|
606 | return !!~_stringContext(this, searchString, INCLUDES)
|
607 | .indexOf(searchString, arguments.length > 1 ? arguments[1] : undefined);
|
608 | }
|
609 | });
|
610 |
|
611 | var _objectDps = _descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
|
612 | _anObject(O);
|
613 | var keys = _objectKeys(Properties);
|
614 | var length = keys.length;
|
615 | var i = 0;
|
616 | var P;
|
617 | while (length > i) _objectDp.f(O, P = keys[i++], Properties[P]);
|
618 | return O;
|
619 | };
|
620 |
|
621 | var document$2 = _global.document;
|
622 | var _html = document$2 && document$2.documentElement;
|
623 |
|
624 |
|
625 |
|
626 |
|
627 |
|
628 | var IE_PROTO$1 = _sharedKey('IE_PROTO');
|
629 | var Empty = function () { };
|
630 | var PROTOTYPE$1 = 'prototype';
|
631 |
|
632 |
|
633 | var createDict = function () {
|
634 |
|
635 | var iframe = _domCreate('iframe');
|
636 | var i = _enumBugKeys.length;
|
637 | var lt = '<';
|
638 | var gt = '>';
|
639 | var iframeDocument;
|
640 | iframe.style.display = 'none';
|
641 | _html.appendChild(iframe);
|
642 | iframe.src = 'javascript:';
|
643 |
|
644 |
|
645 | iframeDocument = iframe.contentWindow.document;
|
646 | iframeDocument.open();
|
647 | iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
|
648 | iframeDocument.close();
|
649 | createDict = iframeDocument.F;
|
650 | while (i--) delete createDict[PROTOTYPE$1][_enumBugKeys[i]];
|
651 | return createDict();
|
652 | };
|
653 |
|
654 | var _objectCreate = Object.create || function create(O, Properties) {
|
655 | var result;
|
656 | if (O !== null) {
|
657 | Empty[PROTOTYPE$1] = _anObject(O);
|
658 | result = new Empty();
|
659 | Empty[PROTOTYPE$1] = null;
|
660 |
|
661 | result[IE_PROTO$1] = O;
|
662 | } else result = createDict();
|
663 | return Properties === undefined ? result : _objectDps(result, Properties);
|
664 | };
|
665 |
|
666 | var _redefineAll = function (target, src, safe) {
|
667 | for (var key in src) _redefine(target, key, src[key], safe);
|
668 | return target;
|
669 | };
|
670 |
|
671 | var _anInstance = function (it, Constructor, name, forbiddenField) {
|
672 | if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) {
|
673 | throw TypeError(name + ': incorrect invocation!');
|
674 | } return it;
|
675 | };
|
676 |
|
677 |
|
678 |
|
679 | var _iterCall = function (iterator, fn, value, entries) {
|
680 | try {
|
681 | return entries ? fn(_anObject(value)[0], value[1]) : fn(value);
|
682 |
|
683 | } catch (e) {
|
684 | var ret = iterator['return'];
|
685 | if (ret !== undefined) _anObject(ret.call(iterator));
|
686 | throw e;
|
687 | }
|
688 | };
|
689 |
|
690 | var _iterators = {};
|
691 |
|
692 |
|
693 |
|
694 | var ITERATOR = _wks('iterator');
|
695 | var ArrayProto$1 = Array.prototype;
|
696 |
|
697 | var _isArrayIter = function (it) {
|
698 | return it !== undefined && (_iterators.Array === it || ArrayProto$1[ITERATOR] === it);
|
699 | };
|
700 |
|
701 |
|
702 |
|
703 | var TAG = _wks('toStringTag');
|
704 |
|
705 | var ARG = _cof(function () { return arguments; }()) == 'Arguments';
|
706 |
|
707 |
|
708 | var tryGet = function (it, key) {
|
709 | try {
|
710 | return it[key];
|
711 | } catch (e) { }
|
712 | };
|
713 |
|
714 | var _classof = function (it) {
|
715 | var O, T, B;
|
716 | return it === undefined ? 'Undefined' : it === null ? 'Null'
|
717 |
|
718 | : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
|
719 |
|
720 | : ARG ? _cof(O)
|
721 |
|
722 | : (B = _cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
|
723 | };
|
724 |
|
725 | var ITERATOR$1 = _wks('iterator');
|
726 |
|
727 | var core_getIteratorMethod = _core.getIteratorMethod = function (it) {
|
728 | if (it != undefined) return it[ITERATOR$1]
|
729 | || it['@@iterator']
|
730 | || _iterators[_classof(it)];
|
731 | };
|
732 |
|
733 | var _forOf = createCommonjsModule(function (module) {
|
734 | var BREAK = {};
|
735 | var RETURN = {};
|
736 | var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
|
737 | var iterFn = ITERATOR ? function () { return iterable; } : core_getIteratorMethod(iterable);
|
738 | var f = _ctx(fn, that, entries ? 2 : 1);
|
739 | var index = 0;
|
740 | var length, step, iterator, result;
|
741 | if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
|
742 |
|
743 | if (_isArrayIter(iterFn)) for (length = _toLength(iterable.length); length > index; index++) {
|
744 | result = entries ? f(_anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
|
745 | if (result === BREAK || result === RETURN) return result;
|
746 | } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
|
747 | result = _iterCall(iterator, f, step.value, entries);
|
748 | if (result === BREAK || result === RETURN) return result;
|
749 | }
|
750 | };
|
751 | exports.BREAK = BREAK;
|
752 | exports.RETURN = RETURN;
|
753 | });
|
754 |
|
755 | var def = _objectDp.f;
|
756 |
|
757 | var TAG$1 = _wks('toStringTag');
|
758 |
|
759 | var _setToStringTag = function (it, tag, stat) {
|
760 | if (it && !_has(it = stat ? it : it.prototype, TAG$1)) def(it, TAG$1, { configurable: true, value: tag });
|
761 | };
|
762 |
|
763 | var IteratorPrototype = {};
|
764 |
|
765 |
|
766 | _hide(IteratorPrototype, _wks('iterator'), function () { return this; });
|
767 |
|
768 | var _iterCreate = function (Constructor, NAME, next) {
|
769 | Constructor.prototype = _objectCreate(IteratorPrototype, { next: _propertyDesc(1, next) });
|
770 | _setToStringTag(Constructor, NAME + ' Iterator');
|
771 | };
|
772 |
|
773 |
|
774 |
|
775 |
|
776 | var IE_PROTO$2 = _sharedKey('IE_PROTO');
|
777 | var ObjectProto = Object.prototype;
|
778 |
|
779 | var _objectGpo = Object.getPrototypeOf || function (O) {
|
780 | O = _toObject(O);
|
781 | if (_has(O, IE_PROTO$2)) return O[IE_PROTO$2];
|
782 | if (typeof O.constructor == 'function' && O instanceof O.constructor) {
|
783 | return O.constructor.prototype;
|
784 | } return O instanceof Object ? ObjectProto : null;
|
785 | };
|
786 |
|
787 | var ITERATOR$2 = _wks('iterator');
|
788 | var BUGGY = !([].keys && 'next' in [].keys());
|
789 | var FF_ITERATOR = '@@iterator';
|
790 | var KEYS = 'keys';
|
791 | var VALUES = 'values';
|
792 |
|
793 | var returnThis = function () { return this; };
|
794 |
|
795 | var _iterDefine = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
|
796 | _iterCreate(Constructor, NAME, next);
|
797 | var getMethod = function (kind) {
|
798 | if (!BUGGY && kind in proto) return proto[kind];
|
799 | switch (kind) {
|
800 | case KEYS: return function keys() { return new Constructor(this, kind); };
|
801 | case VALUES: return function values() { return new Constructor(this, kind); };
|
802 | } return function entries() { return new Constructor(this, kind); };
|
803 | };
|
804 | var TAG = NAME + ' Iterator';
|
805 | var DEF_VALUES = DEFAULT == VALUES;
|
806 | var VALUES_BUG = false;
|
807 | var proto = Base.prototype;
|
808 | var $native = proto[ITERATOR$2] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
|
809 | var $default = $native || getMethod(DEFAULT);
|
810 | var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
|
811 | var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
|
812 | var methods, key, IteratorPrototype;
|
813 |
|
814 | if ($anyNative) {
|
815 | IteratorPrototype = _objectGpo($anyNative.call(new Base()));
|
816 | if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
|
817 |
|
818 | _setToStringTag(IteratorPrototype, TAG, true);
|
819 |
|
820 | if (typeof IteratorPrototype[ITERATOR$2] != 'function') _hide(IteratorPrototype, ITERATOR$2, returnThis);
|
821 | }
|
822 | }
|
823 |
|
824 | if (DEF_VALUES && $native && $native.name !== VALUES) {
|
825 | VALUES_BUG = true;
|
826 | $default = function values() { return $native.call(this); };
|
827 | }
|
828 |
|
829 | if (BUGGY || VALUES_BUG || !proto[ITERATOR$2]) {
|
830 | _hide(proto, ITERATOR$2, $default);
|
831 | }
|
832 |
|
833 | _iterators[NAME] = $default;
|
834 | _iterators[TAG] = returnThis;
|
835 | if (DEFAULT) {
|
836 | methods = {
|
837 | values: DEF_VALUES ? $default : getMethod(VALUES),
|
838 | keys: IS_SET ? $default : getMethod(KEYS),
|
839 | entries: $entries
|
840 | };
|
841 | if (FORCED) for (key in methods) {
|
842 | if (!(key in proto)) _redefine(proto, key, methods[key]);
|
843 | } else _export(_export.P + _export.F * (BUGGY || VALUES_BUG), NAME, methods);
|
844 | }
|
845 | return methods;
|
846 | };
|
847 |
|
848 | var _iterStep = function (done, value) {
|
849 | return { value: value, done: !!done };
|
850 | };
|
851 |
|
852 | var SPECIES = _wks('species');
|
853 |
|
854 | var _setSpecies = function (KEY) {
|
855 | var C = _global[KEY];
|
856 | if (_descriptors && C && !C[SPECIES]) _objectDp.f(C, SPECIES, {
|
857 | configurable: true,
|
858 | get: function () { return this; }
|
859 | });
|
860 | };
|
861 |
|
862 | var _meta = createCommonjsModule(function (module) {
|
863 | var META = _uid('meta');
|
864 |
|
865 |
|
866 | var setDesc = _objectDp.f;
|
867 | var id = 0;
|
868 | var isExtensible = Object.isExtensible || function () {
|
869 | return true;
|
870 | };
|
871 | var FREEZE = !_fails(function () {
|
872 | return isExtensible(Object.preventExtensions({}));
|
873 | });
|
874 | var setMeta = function (it) {
|
875 | setDesc(it, META, { value: {
|
876 | i: 'O' + ++id,
|
877 | w: {}
|
878 | } });
|
879 | };
|
880 | var fastKey = function (it, create) {
|
881 |
|
882 | if (!_isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
|
883 | if (!_has(it, META)) {
|
884 |
|
885 | if (!isExtensible(it)) return 'F';
|
886 |
|
887 | if (!create) return 'E';
|
888 |
|
889 | setMeta(it);
|
890 |
|
891 | } return it[META].i;
|
892 | };
|
893 | var getWeak = function (it, create) {
|
894 | if (!_has(it, META)) {
|
895 |
|
896 | if (!isExtensible(it)) return true;
|
897 |
|
898 | if (!create) return false;
|
899 |
|
900 | setMeta(it);
|
901 |
|
902 | } return it[META].w;
|
903 | };
|
904 |
|
905 | var onFreeze = function (it) {
|
906 | if (FREEZE && meta.NEED && isExtensible(it) && !_has(it, META)) setMeta(it);
|
907 | return it;
|
908 | };
|
909 | var meta = module.exports = {
|
910 | KEY: META,
|
911 | NEED: false,
|
912 | fastKey: fastKey,
|
913 | getWeak: getWeak,
|
914 | onFreeze: onFreeze
|
915 | };
|
916 | });
|
917 | var _meta_1 = _meta.KEY;
|
918 | var _meta_2 = _meta.NEED;
|
919 | var _meta_3 = _meta.fastKey;
|
920 | var _meta_4 = _meta.getWeak;
|
921 | var _meta_5 = _meta.onFreeze;
|
922 |
|
923 | var _validateCollection = function (it, TYPE) {
|
924 | if (!_isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!');
|
925 | return it;
|
926 | };
|
927 |
|
928 | var dP$1 = _objectDp.f;
|
929 |
|
930 |
|
931 |
|
932 |
|
933 |
|
934 |
|
935 |
|
936 |
|
937 |
|
938 | var fastKey = _meta.fastKey;
|
939 |
|
940 | var SIZE = _descriptors ? '_s' : 'size';
|
941 |
|
942 | var getEntry = function (that, key) {
|
943 |
|
944 | var index = fastKey(key);
|
945 | var entry;
|
946 | if (index !== 'F') return that._i[index];
|
947 |
|
948 | for (entry = that._f; entry; entry = entry.n) {
|
949 | if (entry.k == key) return entry;
|
950 | }
|
951 | };
|
952 |
|
953 | var _collectionStrong = {
|
954 | getConstructor: function (wrapper, NAME, IS_MAP, ADDER) {
|
955 | var C = wrapper(function (that, iterable) {
|
956 | _anInstance(that, C, NAME, '_i');
|
957 | that._t = NAME;
|
958 | that._i = _objectCreate(null);
|
959 | that._f = undefined;
|
960 | that._l = undefined;
|
961 | that[SIZE] = 0;
|
962 | if (iterable != undefined) _forOf(iterable, IS_MAP, that[ADDER], that);
|
963 | });
|
964 | _redefineAll(C.prototype, {
|
965 |
|
966 |
|
967 | clear: function clear() {
|
968 | for (var that = _validateCollection(this, NAME), data = that._i, entry = that._f; entry; entry = entry.n) {
|
969 | entry.r = true;
|
970 | if (entry.p) entry.p = entry.p.n = undefined;
|
971 | delete data[entry.i];
|
972 | }
|
973 | that._f = that._l = undefined;
|
974 | that[SIZE] = 0;
|
975 | },
|
976 |
|
977 |
|
978 | 'delete': function (key) {
|
979 | var that = _validateCollection(this, NAME);
|
980 | var entry = getEntry(that, key);
|
981 | if (entry) {
|
982 | var next = entry.n;
|
983 | var prev = entry.p;
|
984 | delete that._i[entry.i];
|
985 | entry.r = true;
|
986 | if (prev) prev.n = next;
|
987 | if (next) next.p = prev;
|
988 | if (that._f == entry) that._f = next;
|
989 | if (that._l == entry) that._l = prev;
|
990 | that[SIZE]--;
|
991 | } return !!entry;
|
992 | },
|
993 |
|
994 |
|
995 | forEach: function forEach(callbackfn /* , that = undefined */) {
|
996 | _validateCollection(this, NAME);
|
997 | var f = _ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);
|
998 | var entry;
|
999 | while (entry = entry ? entry.n : this._f) {
|
1000 | f(entry.v, entry.k, this);
|
1001 |
|
1002 | while (entry && entry.r) entry = entry.p;
|
1003 | }
|
1004 | },
|
1005 |
|
1006 |
|
1007 | has: function has(key) {
|
1008 | return !!getEntry(_validateCollection(this, NAME), key);
|
1009 | }
|
1010 | });
|
1011 | if (_descriptors) dP$1(C.prototype, 'size', {
|
1012 | get: function () {
|
1013 | return _validateCollection(this, NAME)[SIZE];
|
1014 | }
|
1015 | });
|
1016 | return C;
|
1017 | },
|
1018 | def: function (that, key, value) {
|
1019 | var entry = getEntry(that, key);
|
1020 | var prev, index;
|
1021 |
|
1022 | if (entry) {
|
1023 | entry.v = value;
|
1024 |
|
1025 | } else {
|
1026 | that._l = entry = {
|
1027 | i: index = fastKey(key, true),
|
1028 | k: key,
|
1029 | v: value,
|
1030 | p: prev = that._l,
|
1031 | n: undefined,
|
1032 | r: false
|
1033 | };
|
1034 | if (!that._f) that._f = entry;
|
1035 | if (prev) prev.n = entry;
|
1036 | that[SIZE]++;
|
1037 |
|
1038 | if (index !== 'F') that._i[index] = entry;
|
1039 | } return that;
|
1040 | },
|
1041 | getEntry: getEntry,
|
1042 | setStrong: function (C, NAME, IS_MAP) {
|
1043 |
|
1044 |
|
1045 | _iterDefine(C, NAME, function (iterated, kind) {
|
1046 | this._t = _validateCollection(iterated, NAME);
|
1047 | this._k = kind;
|
1048 | this._l = undefined;
|
1049 | }, function () {
|
1050 | var that = this;
|
1051 | var kind = that._k;
|
1052 | var entry = that._l;
|
1053 |
|
1054 | while (entry && entry.r) entry = entry.p;
|
1055 |
|
1056 | if (!that._t || !(that._l = entry = entry ? entry.n : that._t._f)) {
|
1057 |
|
1058 | that._t = undefined;
|
1059 | return _iterStep(1);
|
1060 | }
|
1061 |
|
1062 | if (kind == 'keys') return _iterStep(0, entry.k);
|
1063 | if (kind == 'values') return _iterStep(0, entry.v);
|
1064 | return _iterStep(0, [entry.k, entry.v]);
|
1065 | }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
|
1066 |
|
1067 |
|
1068 | _setSpecies(NAME);
|
1069 | }
|
1070 | };
|
1071 |
|
1072 | var ITERATOR$3 = _wks('iterator');
|
1073 | var SAFE_CLOSING = false;
|
1074 |
|
1075 | try {
|
1076 | var riter = [7][ITERATOR$3]();
|
1077 | riter['return'] = function () { SAFE_CLOSING = true; };
|
1078 | } catch (e) { }
|
1079 |
|
1080 | var _iterDetect = function (exec, skipClosing) {
|
1081 | if (!skipClosing && !SAFE_CLOSING) return false;
|
1082 | var safe = false;
|
1083 | try {
|
1084 | var arr = [7];
|
1085 | var iter = arr[ITERATOR$3]();
|
1086 | iter.next = function () { return { done: safe = true }; };
|
1087 | arr[ITERATOR$3] = function () { return iter; };
|
1088 | exec(arr);
|
1089 | } catch (e) { }
|
1090 | return safe;
|
1091 | };
|
1092 |
|
1093 | var gOPD = Object.getOwnPropertyDescriptor;
|
1094 |
|
1095 | var f$3 = _descriptors ? gOPD : function getOwnPropertyDescriptor(O, P) {
|
1096 | O = _toIobject(O);
|
1097 | P = _toPrimitive(P, true);
|
1098 | if (_ie8DomDefine) try {
|
1099 | return gOPD(O, P);
|
1100 | } catch (e) { }
|
1101 | if (_has(O, P)) return _propertyDesc(!_objectPie.f.call(O, P), O[P]);
|
1102 | };
|
1103 |
|
1104 | var _objectGopd = {
|
1105 | f: f$3
|
1106 | };
|
1107 |
|
1108 |
|
1109 |
|
1110 |
|
1111 |
|
1112 | var check = function (O, proto) {
|
1113 | _anObject(O);
|
1114 | if (!_isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!");
|
1115 | };
|
1116 | var _setProto = {
|
1117 | set: Object.setPrototypeOf || ('__proto__' in {} ?
|
1118 | function (test, buggy, set) {
|
1119 | try {
|
1120 | set = _ctx(Function.call, _objectGopd.f(Object.prototype, '__proto__').set, 2);
|
1121 | set(test, []);
|
1122 | buggy = !(test instanceof Array);
|
1123 | } catch (e) { buggy = true; }
|
1124 | return function setPrototypeOf(O, proto) {
|
1125 | check(O, proto);
|
1126 | if (buggy) O.__proto__ = proto;
|
1127 | else set(O, proto);
|
1128 | return O;
|
1129 | };
|
1130 | }({}, false) : undefined),
|
1131 | check: check
|
1132 | };
|
1133 |
|
1134 | var setPrototypeOf = _setProto.set;
|
1135 | var _inheritIfRequired = function (that, target, C) {
|
1136 | var S = target.constructor;
|
1137 | var P;
|
1138 | if (S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && _isObject(P) && setPrototypeOf) {
|
1139 | setPrototypeOf(that, P);
|
1140 | } return that;
|
1141 | };
|
1142 |
|
1143 | var _collection = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {
|
1144 | var Base = _global[NAME];
|
1145 | var C = Base;
|
1146 | var ADDER = IS_MAP ? 'set' : 'add';
|
1147 | var proto = C && C.prototype;
|
1148 | var O = {};
|
1149 | var fixMethod = function (KEY) {
|
1150 | var fn = proto[KEY];
|
1151 | _redefine(proto, KEY,
|
1152 | KEY == 'delete' ? function (a) {
|
1153 | return IS_WEAK && !_isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
|
1154 | } : KEY == 'has' ? function has(a) {
|
1155 | return IS_WEAK && !_isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
|
1156 | } : KEY == 'get' ? function get(a) {
|
1157 | return IS_WEAK && !_isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a);
|
1158 | } : KEY == 'add' ? function add(a) { fn.call(this, a === 0 ? 0 : a); return this; }
|
1159 | : function set(a, b) { fn.call(this, a === 0 ? 0 : a, b); return this; }
|
1160 | );
|
1161 | };
|
1162 | if (typeof C != 'function' || !(IS_WEAK || proto.forEach && !_fails(function () {
|
1163 | new C().entries().next();
|
1164 | }))) {
|
1165 |
|
1166 | C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
|
1167 | _redefineAll(C.prototype, methods);
|
1168 | _meta.NEED = true;
|
1169 | } else {
|
1170 | var instance = new C();
|
1171 |
|
1172 | var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance;
|
1173 |
|
1174 | var THROWS_ON_PRIMITIVES = _fails(function () { instance.has(1); });
|
1175 |
|
1176 | var ACCEPT_ITERABLES = _iterDetect(function (iter) { new C(iter); });
|
1177 |
|
1178 | var BUGGY_ZERO = !IS_WEAK && _fails(function () {
|
1179 |
|
1180 | var $instance = new C();
|
1181 | var index = 5;
|
1182 | while (index--) $instance[ADDER](index, index);
|
1183 | return !$instance.has(-0);
|
1184 | });
|
1185 | if (!ACCEPT_ITERABLES) {
|
1186 | C = wrapper(function (target, iterable) {
|
1187 | _anInstance(target, C, NAME);
|
1188 | var that = _inheritIfRequired(new Base(), target, C);
|
1189 | if (iterable != undefined) _forOf(iterable, IS_MAP, that[ADDER], that);
|
1190 | return that;
|
1191 | });
|
1192 | C.prototype = proto;
|
1193 | proto.constructor = C;
|
1194 | }
|
1195 | if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {
|
1196 | fixMethod('delete');
|
1197 | fixMethod('has');
|
1198 | IS_MAP && fixMethod('get');
|
1199 | }
|
1200 | if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER);
|
1201 |
|
1202 | if (IS_WEAK && proto.clear) delete proto.clear;
|
1203 | }
|
1204 |
|
1205 | _setToStringTag(C, NAME);
|
1206 |
|
1207 | O[NAME] = C;
|
1208 | _export(_export.G + _export.W + _export.F * (C != Base), O);
|
1209 |
|
1210 | if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP);
|
1211 |
|
1212 | return C;
|
1213 | };
|
1214 |
|
1215 | var SET = 'Set';
|
1216 |
|
1217 |
|
1218 | var es6_set = _collection(SET, function (get) {
|
1219 | return function Set() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };
|
1220 | }, {
|
1221 |
|
1222 | add: function add(value) {
|
1223 | return _collectionStrong.def(_validateCollection(this, SET), value = value === 0 ? 0 : value, value);
|
1224 | }
|
1225 | }, _collectionStrong);
|
1226 |
|
1227 |
|
1228 |
|
1229 | var _isArray = Array.isArray || function isArray(arg) {
|
1230 | return _cof(arg) == 'Array';
|
1231 | };
|
1232 |
|
1233 | var SPECIES$1 = _wks('species');
|
1234 |
|
1235 | var _arraySpeciesConstructor = function (original) {
|
1236 | var C;
|
1237 | if (_isArray(original)) {
|
1238 | C = original.constructor;
|
1239 |
|
1240 | if (typeof C == 'function' && (C === Array || _isArray(C.prototype))) C = undefined;
|
1241 | if (_isObject(C)) {
|
1242 | C = C[SPECIES$1];
|
1243 | if (C === null) C = undefined;
|
1244 | }
|
1245 | } return C === undefined ? Array : C;
|
1246 | };
|
1247 |
|
1248 |
|
1249 |
|
1250 |
|
1251 | var _arraySpeciesCreate = function (original, length) {
|
1252 | return new (_arraySpeciesConstructor(original))(length);
|
1253 | };
|
1254 |
|
1255 |
|
1256 |
|
1257 |
|
1258 |
|
1259 |
|
1260 |
|
1261 |
|
1262 |
|
1263 |
|
1264 |
|
1265 |
|
1266 |
|
1267 | var _arrayMethods = function (TYPE, $create) {
|
1268 | var IS_MAP = TYPE == 1;
|
1269 | var IS_FILTER = TYPE == 2;
|
1270 | var IS_SOME = TYPE == 3;
|
1271 | var IS_EVERY = TYPE == 4;
|
1272 | var IS_FIND_INDEX = TYPE == 6;
|
1273 | var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
|
1274 | var create = $create || _arraySpeciesCreate;
|
1275 | return function ($this, callbackfn, that) {
|
1276 | var O = _toObject($this);
|
1277 | var self = _iobject(O);
|
1278 | var f = _ctx(callbackfn, that, 3);
|
1279 | var length = _toLength(self.length);
|
1280 | var index = 0;
|
1281 | var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
|
1282 | var val, res;
|
1283 | for (;length > index; index++) if (NO_HOLES || index in self) {
|
1284 | val = self[index];
|
1285 | res = f(val, index, O);
|
1286 | if (TYPE) {
|
1287 | if (IS_MAP) result[index] = res;
|
1288 | else if (res) switch (TYPE) {
|
1289 | case 3: return true;
|
1290 | case 5: return val;
|
1291 | case 6: return index;
|
1292 | case 2: result.push(val);
|
1293 | } else if (IS_EVERY) return false;
|
1294 | }
|
1295 | }
|
1296 | return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
|
1297 | };
|
1298 | };
|
1299 |
|
1300 |
|
1301 |
|
1302 | var $find = _arrayMethods(5);
|
1303 | var KEY = 'find';
|
1304 | var forced = true;
|
1305 |
|
1306 | if (KEY in []) Array(1)[KEY](function () { forced = false; });
|
1307 | _export(_export.P + _export.F * forced, 'Array', {
|
1308 | find: function find(callbackfn /* , that = undefined */) {
|
1309 | return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
1310 | }
|
1311 | });
|
1312 | _addToUnscopables(KEY);
|
1313 |
|
1314 |
|
1315 |
|
1316 | var _flags = function () {
|
1317 | var that = _anObject(this);
|
1318 | var result = '';
|
1319 | if (that.global) result += 'g';
|
1320 | if (that.ignoreCase) result += 'i';
|
1321 | if (that.multiline) result += 'm';
|
1322 | if (that.unicode) result += 'u';
|
1323 | if (that.sticky) result += 'y';
|
1324 | return result;
|
1325 | };
|
1326 |
|
1327 |
|
1328 | if (_descriptors && /./g.flags != 'g') _objectDp.f(RegExp.prototype, 'flags', {
|
1329 | configurable: true,
|
1330 | get: _flags
|
1331 | });
|
1332 |
|
1333 | var TO_STRING = 'toString';
|
1334 | var $toString = /./[TO_STRING];
|
1335 |
|
1336 | var define = function (fn) {
|
1337 | _redefine(RegExp.prototype, TO_STRING, fn, true);
|
1338 | };
|
1339 |
|
1340 |
|
1341 | if (_fails(function () { return $toString.call({ source: 'a', flags: 'b' }) != '/a/b'; })) {
|
1342 | define(function toString() {
|
1343 | var R = _anObject(this);
|
1344 | return '/'.concat(R.source, '/',
|
1345 | 'flags' in R ? R.flags : !_descriptors && R instanceof RegExp ? _flags.call(R) : undefined);
|
1346 | });
|
1347 |
|
1348 | } else if ($toString.name != TO_STRING) {
|
1349 | define(function toString() {
|
1350 | return $toString.call(this);
|
1351 | });
|
1352 | }
|
1353 |
|
1354 |
|
1355 |
|
1356 |
|
1357 |
|
1358 | var _objectSap = function (KEY, exec) {
|
1359 | var fn = (_core.Object || {})[KEY] || Object[KEY];
|
1360 | var exp = {};
|
1361 | exp[KEY] = exec(fn);
|
1362 | _export(_export.S + _export.F * _fails(function () { fn(1); }), 'Object', exp);
|
1363 | };
|
1364 |
|
1365 |
|
1366 |
|
1367 |
|
1368 |
|
1369 | _objectSap('keys', function () {
|
1370 | return function keys(it) {
|
1371 | return _objectKeys(_toObject(it));
|
1372 | };
|
1373 | });
|
1374 |
|
1375 |
|
1376 |
|
1377 |
|
1378 | var SPECIES$2 = _wks('species');
|
1379 | var _speciesConstructor = function (O, D) {
|
1380 | var C = _anObject(O).constructor;
|
1381 | var S;
|
1382 | return C === undefined || (S = _anObject(C)[SPECIES$2]) == undefined ? D : _aFunction(S);
|
1383 | };
|
1384 |
|
1385 |
|
1386 | var _invoke = function (fn, args, that) {
|
1387 | var un = that === undefined;
|
1388 | switch (args.length) {
|
1389 | case 0: return un ? fn()
|
1390 | : fn.call(that);
|
1391 | case 1: return un ? fn(args[0])
|
1392 | : fn.call(that, args[0]);
|
1393 | case 2: return un ? fn(args[0], args[1])
|
1394 | : fn.call(that, args[0], args[1]);
|
1395 | case 3: return un ? fn(args[0], args[1], args[2])
|
1396 | : fn.call(that, args[0], args[1], args[2]);
|
1397 | case 4: return un ? fn(args[0], args[1], args[2], args[3])
|
1398 | : fn.call(that, args[0], args[1], args[2], args[3]);
|
1399 | } return fn.apply(that, args);
|
1400 | };
|
1401 |
|
1402 | var process = _global.process;
|
1403 | var setTask = _global.setImmediate;
|
1404 | var clearTask = _global.clearImmediate;
|
1405 | var MessageChannel = _global.MessageChannel;
|
1406 | var Dispatch = _global.Dispatch;
|
1407 | var counter = 0;
|
1408 | var queue = {};
|
1409 | var ONREADYSTATECHANGE = 'onreadystatechange';
|
1410 | var defer, channel, port;
|
1411 | var run = function () {
|
1412 | var id = +this;
|
1413 |
|
1414 | if (queue.hasOwnProperty(id)) {
|
1415 | var fn = queue[id];
|
1416 | delete queue[id];
|
1417 | fn();
|
1418 | }
|
1419 | };
|
1420 | var listener = function (event) {
|
1421 | run.call(event.data);
|
1422 | };
|
1423 |
|
1424 | if (!setTask || !clearTask) {
|
1425 | setTask = function setImmediate(fn) {
|
1426 | var args = [];
|
1427 | var i = 1;
|
1428 | while (arguments.length > i) args.push(arguments[i++]);
|
1429 | queue[++counter] = function () {
|
1430 |
|
1431 | _invoke(typeof fn == 'function' ? fn : Function(fn), args);
|
1432 | };
|
1433 | defer(counter);
|
1434 | return counter;
|
1435 | };
|
1436 | clearTask = function clearImmediate(id) {
|
1437 | delete queue[id];
|
1438 | };
|
1439 |
|
1440 | if (_cof(process) == 'process') {
|
1441 | defer = function (id) {
|
1442 | process.nextTick(_ctx(run, id, 1));
|
1443 | };
|
1444 |
|
1445 | } else if (Dispatch && Dispatch.now) {
|
1446 | defer = function (id) {
|
1447 | Dispatch.now(_ctx(run, id, 1));
|
1448 | };
|
1449 |
|
1450 | } else if (MessageChannel) {
|
1451 | channel = new MessageChannel();
|
1452 | port = channel.port2;
|
1453 | channel.port1.onmessage = listener;
|
1454 | defer = _ctx(port.postMessage, port, 1);
|
1455 |
|
1456 |
|
1457 | } else if (_global.addEventListener && typeof postMessage == 'function' && !_global.importScripts) {
|
1458 | defer = function (id) {
|
1459 | _global.postMessage(id + '', '*');
|
1460 | };
|
1461 | _global.addEventListener('message', listener, false);
|
1462 |
|
1463 | } else if (ONREADYSTATECHANGE in _domCreate('script')) {
|
1464 | defer = function (id) {
|
1465 | _html.appendChild(_domCreate('script'))[ONREADYSTATECHANGE] = function () {
|
1466 | _html.removeChild(this);
|
1467 | run.call(id);
|
1468 | };
|
1469 | };
|
1470 |
|
1471 | } else {
|
1472 | defer = function (id) {
|
1473 | setTimeout(_ctx(run, id, 1), 0);
|
1474 | };
|
1475 | }
|
1476 | }
|
1477 | var _task = {
|
1478 | set: setTask,
|
1479 | clear: clearTask
|
1480 | };
|
1481 |
|
1482 | var macrotask = _task.set;
|
1483 | var Observer = _global.MutationObserver || _global.WebKitMutationObserver;
|
1484 | var process$1 = _global.process;
|
1485 | var Promise$1 = _global.Promise;
|
1486 | var isNode = _cof(process$1) == 'process';
|
1487 |
|
1488 | var _microtask = function () {
|
1489 | var head, last, notify;
|
1490 |
|
1491 | var flush = function () {
|
1492 | var parent, fn;
|
1493 | if (isNode && (parent = process$1.domain)) parent.exit();
|
1494 | while (head) {
|
1495 | fn = head.fn;
|
1496 | head = head.next;
|
1497 | try {
|
1498 | fn();
|
1499 | } catch (e) {
|
1500 | if (head) notify();
|
1501 | else last = undefined;
|
1502 | throw e;
|
1503 | }
|
1504 | } last = undefined;
|
1505 | if (parent) parent.enter();
|
1506 | };
|
1507 |
|
1508 |
|
1509 | if (isNode) {
|
1510 | notify = function () {
|
1511 | process$1.nextTick(flush);
|
1512 | };
|
1513 |
|
1514 | } else if (Observer && !(_global.navigator && _global.navigator.standalone)) {
|
1515 | var toggle = true;
|
1516 | var node = document.createTextNode('');
|
1517 | new Observer(flush).observe(node, { characterData: true });
|
1518 | notify = function () {
|
1519 | node.data = toggle = !toggle;
|
1520 | };
|
1521 |
|
1522 | } else if (Promise$1 && Promise$1.resolve) {
|
1523 |
|
1524 | var promise = Promise$1.resolve(undefined);
|
1525 | notify = function () {
|
1526 | promise.then(flush);
|
1527 | };
|
1528 |
|
1529 |
|
1530 |
|
1531 |
|
1532 |
|
1533 |
|
1534 | } else {
|
1535 | notify = function () {
|
1536 |
|
1537 | macrotask.call(_global, flush);
|
1538 | };
|
1539 | }
|
1540 |
|
1541 | return function (fn) {
|
1542 | var task = { fn: fn, next: undefined };
|
1543 | if (last) last.next = task;
|
1544 | if (!head) {
|
1545 | head = task;
|
1546 | notify();
|
1547 | } last = task;
|
1548 | };
|
1549 | };
|
1550 |
|
1551 |
|
1552 |
|
1553 |
|
1554 | function PromiseCapability(C) {
|
1555 | var resolve, reject;
|
1556 | this.promise = new C(function ($$resolve, $$reject) {
|
1557 | if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
|
1558 | resolve = $$resolve;
|
1559 | reject = $$reject;
|
1560 | });
|
1561 | this.resolve = _aFunction(resolve);
|
1562 | this.reject = _aFunction(reject);
|
1563 | }
|
1564 |
|
1565 | var f$4 = function (C) {
|
1566 | return new PromiseCapability(C);
|
1567 | };
|
1568 |
|
1569 | var _newPromiseCapability = {
|
1570 | f: f$4
|
1571 | };
|
1572 |
|
1573 | var _perform = function (exec) {
|
1574 | try {
|
1575 | return { e: false, v: exec() };
|
1576 | } catch (e) {
|
1577 | return { e: true, v: e };
|
1578 | }
|
1579 | };
|
1580 |
|
1581 | var navigator = _global.navigator;
|
1582 |
|
1583 | var _userAgent = navigator && navigator.userAgent || '';
|
1584 |
|
1585 | var _promiseResolve = function (C, x) {
|
1586 | _anObject(C);
|
1587 | if (_isObject(x) && x.constructor === C) return x;
|
1588 | var promiseCapability = _newPromiseCapability.f(C);
|
1589 | var resolve = promiseCapability.resolve;
|
1590 | resolve(x);
|
1591 | return promiseCapability.promise;
|
1592 | };
|
1593 |
|
1594 | var task = _task.set;
|
1595 | var microtask = _microtask();
|
1596 |
|
1597 |
|
1598 |
|
1599 |
|
1600 | var PROMISE = 'Promise';
|
1601 | var TypeError$1 = _global.TypeError;
|
1602 | var process$2 = _global.process;
|
1603 | var versions = process$2 && process$2.versions;
|
1604 | var v8 = versions && versions.v8 || '';
|
1605 | var $Promise = _global[PROMISE];
|
1606 | var isNode$1 = _classof(process$2) == 'process';
|
1607 | var empty = function () { };
|
1608 | var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper;
|
1609 | var newPromiseCapability = newGenericPromiseCapability = _newPromiseCapability.f;
|
1610 |
|
1611 | var USE_NATIVE = !!function () {
|
1612 | try {
|
1613 |
|
1614 | var promise = $Promise.resolve(1);
|
1615 | var FakePromise = (promise.constructor = {})[_wks('species')] = function (exec) {
|
1616 | exec(empty, empty);
|
1617 | };
|
1618 |
|
1619 | return (isNode$1 || typeof PromiseRejectionEvent == 'function')
|
1620 | && promise.then(empty) instanceof FakePromise
|
1621 |
|
1622 |
|
1623 |
|
1624 | && v8.indexOf('6.6') !== 0
|
1625 | && _userAgent.indexOf('Chrome/66') === -1;
|
1626 | } catch (e) { }
|
1627 | }();
|
1628 |
|
1629 |
|
1630 | var isThenable = function (it) {
|
1631 | var then;
|
1632 | return _isObject(it) && typeof (then = it.then) == 'function' ? then : false;
|
1633 | };
|
1634 | var notify = function (promise, isReject) {
|
1635 | if (promise._n) return;
|
1636 | promise._n = true;
|
1637 | var chain = promise._c;
|
1638 | microtask(function () {
|
1639 | var value = promise._v;
|
1640 | var ok = promise._s == 1;
|
1641 | var i = 0;
|
1642 | var run = function (reaction) {
|
1643 | var handler = ok ? reaction.ok : reaction.fail;
|
1644 | var resolve = reaction.resolve;
|
1645 | var reject = reaction.reject;
|
1646 | var domain = reaction.domain;
|
1647 | var result, then, exited;
|
1648 | try {
|
1649 | if (handler) {
|
1650 | if (!ok) {
|
1651 | if (promise._h == 2) onHandleUnhandled(promise);
|
1652 | promise._h = 1;
|
1653 | }
|
1654 | if (handler === true) result = value;
|
1655 | else {
|
1656 | if (domain) domain.enter();
|
1657 | result = handler(value);
|
1658 | if (domain) {
|
1659 | domain.exit();
|
1660 | exited = true;
|
1661 | }
|
1662 | }
|
1663 | if (result === reaction.promise) {
|
1664 | reject(TypeError$1('Promise-chain cycle'));
|
1665 | } else if (then = isThenable(result)) {
|
1666 | then.call(result, resolve, reject);
|
1667 | } else resolve(result);
|
1668 | } else reject(value);
|
1669 | } catch (e) {
|
1670 | if (domain && !exited) domain.exit();
|
1671 | reject(e);
|
1672 | }
|
1673 | };
|
1674 | while (chain.length > i) run(chain[i++]);
|
1675 | promise._c = [];
|
1676 | promise._n = false;
|
1677 | if (isReject && !promise._h) onUnhandled(promise);
|
1678 | });
|
1679 | };
|
1680 | var onUnhandled = function (promise) {
|
1681 | task.call(_global, function () {
|
1682 | var value = promise._v;
|
1683 | var unhandled = isUnhandled(promise);
|
1684 | var result, handler, console;
|
1685 | if (unhandled) {
|
1686 | result = _perform(function () {
|
1687 | if (isNode$1) {
|
1688 | process$2.emit('unhandledRejection', value, promise);
|
1689 | } else if (handler = _global.onunhandledrejection) {
|
1690 | handler({ promise: promise, reason: value });
|
1691 | } else if ((console = _global.console) && console.error) {
|
1692 | console.error('Unhandled promise rejection', value);
|
1693 | }
|
1694 | });
|
1695 |
|
1696 | promise._h = isNode$1 || isUnhandled(promise) ? 2 : 1;
|
1697 | } promise._a = undefined;
|
1698 | if (unhandled && result.e) throw result.v;
|
1699 | });
|
1700 | };
|
1701 | var isUnhandled = function (promise) {
|
1702 | return promise._h !== 1 && (promise._a || promise._c).length === 0;
|
1703 | };
|
1704 | var onHandleUnhandled = function (promise) {
|
1705 | task.call(_global, function () {
|
1706 | var handler;
|
1707 | if (isNode$1) {
|
1708 | process$2.emit('rejectionHandled', promise);
|
1709 | } else if (handler = _global.onrejectionhandled) {
|
1710 | handler({ promise: promise, reason: promise._v });
|
1711 | }
|
1712 | });
|
1713 | };
|
1714 | var $reject = function (value) {
|
1715 | var promise = this;
|
1716 | if (promise._d) return;
|
1717 | promise._d = true;
|
1718 | promise = promise._w || promise;
|
1719 | promise._v = value;
|
1720 | promise._s = 2;
|
1721 | if (!promise._a) promise._a = promise._c.slice();
|
1722 | notify(promise, true);
|
1723 | };
|
1724 | var $resolve = function (value) {
|
1725 | var promise = this;
|
1726 | var then;
|
1727 | if (promise._d) return;
|
1728 | promise._d = true;
|
1729 | promise = promise._w || promise;
|
1730 | try {
|
1731 | if (promise === value) throw TypeError$1("Promise can't be resolved itself");
|
1732 | if (then = isThenable(value)) {
|
1733 | microtask(function () {
|
1734 | var wrapper = { _w: promise, _d: false };
|
1735 | try {
|
1736 | then.call(value, _ctx($resolve, wrapper, 1), _ctx($reject, wrapper, 1));
|
1737 | } catch (e) {
|
1738 | $reject.call(wrapper, e);
|
1739 | }
|
1740 | });
|
1741 | } else {
|
1742 | promise._v = value;
|
1743 | promise._s = 1;
|
1744 | notify(promise, false);
|
1745 | }
|
1746 | } catch (e) {
|
1747 | $reject.call({ _w: promise, _d: false }, e);
|
1748 | }
|
1749 | };
|
1750 |
|
1751 |
|
1752 | if (!USE_NATIVE) {
|
1753 |
|
1754 | $Promise = function Promise(executor) {
|
1755 | _anInstance(this, $Promise, PROMISE, '_h');
|
1756 | _aFunction(executor);
|
1757 | Internal.call(this);
|
1758 | try {
|
1759 | executor(_ctx($resolve, this, 1), _ctx($reject, this, 1));
|
1760 | } catch (err) {
|
1761 | $reject.call(this, err);
|
1762 | }
|
1763 | };
|
1764 |
|
1765 | Internal = function Promise(executor) {
|
1766 | this._c = [];
|
1767 | this._a = undefined;
|
1768 | this._s = 0;
|
1769 | this._d = false;
|
1770 | this._v = undefined;
|
1771 | this._h = 0;
|
1772 | this._n = false;
|
1773 | };
|
1774 | Internal.prototype = _redefineAll($Promise.prototype, {
|
1775 |
|
1776 | then: function then(onFulfilled, onRejected) {
|
1777 | var reaction = newPromiseCapability(_speciesConstructor(this, $Promise));
|
1778 | reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
|
1779 | reaction.fail = typeof onRejected == 'function' && onRejected;
|
1780 | reaction.domain = isNode$1 ? process$2.domain : undefined;
|
1781 | this._c.push(reaction);
|
1782 | if (this._a) this._a.push(reaction);
|
1783 | if (this._s) notify(this, false);
|
1784 | return reaction.promise;
|
1785 | },
|
1786 |
|
1787 | 'catch': function (onRejected) {
|
1788 | return this.then(undefined, onRejected);
|
1789 | }
|
1790 | });
|
1791 | OwnPromiseCapability = function () {
|
1792 | var promise = new Internal();
|
1793 | this.promise = promise;
|
1794 | this.resolve = _ctx($resolve, promise, 1);
|
1795 | this.reject = _ctx($reject, promise, 1);
|
1796 | };
|
1797 | _newPromiseCapability.f = newPromiseCapability = function (C) {
|
1798 | return C === $Promise || C === Wrapper
|
1799 | ? new OwnPromiseCapability(C)
|
1800 | : newGenericPromiseCapability(C);
|
1801 | };
|
1802 | }
|
1803 |
|
1804 | _export(_export.G + _export.W + _export.F * !USE_NATIVE, { Promise: $Promise });
|
1805 | _setToStringTag($Promise, PROMISE);
|
1806 | _setSpecies(PROMISE);
|
1807 | Wrapper = _core[PROMISE];
|
1808 |
|
1809 |
|
1810 | _export(_export.S + _export.F * !USE_NATIVE, PROMISE, {
|
1811 |
|
1812 | reject: function reject(r) {
|
1813 | var capability = newPromiseCapability(this);
|
1814 | var $$reject = capability.reject;
|
1815 | $$reject(r);
|
1816 | return capability.promise;
|
1817 | }
|
1818 | });
|
1819 | _export(_export.S + _export.F * (_library || !USE_NATIVE), PROMISE, {
|
1820 |
|
1821 | resolve: function resolve(x) {
|
1822 | return _promiseResolve(_library && this === Wrapper ? $Promise : this, x);
|
1823 | }
|
1824 | });
|
1825 | _export(_export.S + _export.F * !(USE_NATIVE && _iterDetect(function (iter) {
|
1826 | $Promise.all(iter)['catch'](empty);
|
1827 | })), PROMISE, {
|
1828 |
|
1829 | all: function all(iterable) {
|
1830 | var C = this;
|
1831 | var capability = newPromiseCapability(C);
|
1832 | var resolve = capability.resolve;
|
1833 | var reject = capability.reject;
|
1834 | var result = _perform(function () {
|
1835 | var values = [];
|
1836 | var index = 0;
|
1837 | var remaining = 1;
|
1838 | _forOf(iterable, false, function (promise) {
|
1839 | var $index = index++;
|
1840 | var alreadyCalled = false;
|
1841 | values.push(undefined);
|
1842 | remaining++;
|
1843 | C.resolve(promise).then(function (value) {
|
1844 | if (alreadyCalled) return;
|
1845 | alreadyCalled = true;
|
1846 | values[$index] = value;
|
1847 | --remaining || resolve(values);
|
1848 | }, reject);
|
1849 | });
|
1850 | --remaining || resolve(values);
|
1851 | });
|
1852 | if (result.e) reject(result.v);
|
1853 | return capability.promise;
|
1854 | },
|
1855 |
|
1856 | race: function race(iterable) {
|
1857 | var C = this;
|
1858 | var capability = newPromiseCapability(C);
|
1859 | var reject = capability.reject;
|
1860 | var result = _perform(function () {
|
1861 | _forOf(iterable, false, function (promise) {
|
1862 | C.resolve(promise).then(capability.resolve, reject);
|
1863 | });
|
1864 | });
|
1865 | if (result.e) reject(result.v);
|
1866 | return capability.promise;
|
1867 | }
|
1868 | });
|
1869 |
|
1870 |
|
1871 |
|
1872 |
|
1873 |
|
1874 | var es6_array_iterator = _iterDefine(Array, 'Array', function (iterated, kind) {
|
1875 | this._t = _toIobject(iterated);
|
1876 | this._i = 0;
|
1877 | this._k = kind;
|
1878 |
|
1879 | }, function () {
|
1880 | var O = this._t;
|
1881 | var kind = this._k;
|
1882 | var index = this._i++;
|
1883 | if (!O || index >= O.length) {
|
1884 | this._t = undefined;
|
1885 | return _iterStep(1);
|
1886 | }
|
1887 | if (kind == 'keys') return _iterStep(0, index);
|
1888 | if (kind == 'values') return _iterStep(0, O[index]);
|
1889 | return _iterStep(0, [index, O[index]]);
|
1890 | }, 'values');
|
1891 |
|
1892 |
|
1893 | _iterators.Arguments = _iterators.Array;
|
1894 |
|
1895 | _addToUnscopables('keys');
|
1896 | _addToUnscopables('values');
|
1897 | _addToUnscopables('entries');
|
1898 |
|
1899 |
|
1900 |
|
1901 | var _stringAt = function (TO_STRING) {
|
1902 | return function (that, pos) {
|
1903 | var s = String(_defined(that));
|
1904 | var i = _toInteger(pos);
|
1905 | var l = s.length;
|
1906 | var a, b;
|
1907 | if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
|
1908 | a = s.charCodeAt(i);
|
1909 | return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
|
1910 | ? TO_STRING ? s.charAt(i) : a
|
1911 | : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
|
1912 | };
|
1913 | };
|
1914 |
|
1915 | var $at = _stringAt(true);
|
1916 |
|
1917 |
|
1918 | _iterDefine(String, 'String', function (iterated) {
|
1919 | this._t = String(iterated);
|
1920 | this._i = 0;
|
1921 |
|
1922 | }, function () {
|
1923 | var O = this._t;
|
1924 | var index = this._i;
|
1925 | var point;
|
1926 | if (index >= O.length) return { value: undefined, done: true };
|
1927 | point = $at(O, index);
|
1928 | this._i += point.length;
|
1929 | return { value: point, done: false };
|
1930 | });
|
1931 |
|
1932 | var ITERATOR$4 = _wks('iterator');
|
1933 | var TO_STRING_TAG = _wks('toStringTag');
|
1934 | var ArrayValues = _iterators.Array;
|
1935 |
|
1936 | var DOMIterables = {
|
1937 | CSSRuleList: true,
|
1938 | CSSStyleDeclaration: false,
|
1939 | CSSValueList: false,
|
1940 | ClientRectList: false,
|
1941 | DOMRectList: false,
|
1942 | DOMStringList: false,
|
1943 | DOMTokenList: true,
|
1944 | DataTransferItemList: false,
|
1945 | FileList: false,
|
1946 | HTMLAllCollection: false,
|
1947 | HTMLCollection: false,
|
1948 | HTMLFormElement: false,
|
1949 | HTMLSelectElement: false,
|
1950 | MediaList: true,
|
1951 | MimeTypeArray: false,
|
1952 | NamedNodeMap: false,
|
1953 | NodeList: true,
|
1954 | PaintRequestList: false,
|
1955 | Plugin: false,
|
1956 | PluginArray: false,
|
1957 | SVGLengthList: false,
|
1958 | SVGNumberList: false,
|
1959 | SVGPathSegList: false,
|
1960 | SVGPointList: false,
|
1961 | SVGStringList: false,
|
1962 | SVGTransformList: false,
|
1963 | SourceBufferList: false,
|
1964 | StyleSheetList: true,
|
1965 | TextTrackCueList: false,
|
1966 | TextTrackList: false,
|
1967 | TouchList: false
|
1968 | };
|
1969 |
|
1970 | for (var collections = _objectKeys(DOMIterables), i = 0; i < collections.length; i++) {
|
1971 | var NAME = collections[i];
|
1972 | var explicit = DOMIterables[NAME];
|
1973 | var Collection = _global[NAME];
|
1974 | var proto = Collection && Collection.prototype;
|
1975 | var key;
|
1976 | if (proto) {
|
1977 | if (!proto[ITERATOR$4]) _hide(proto, ITERATOR$4, ArrayValues);
|
1978 | if (!proto[TO_STRING_TAG]) _hide(proto, TO_STRING_TAG, NAME);
|
1979 | _iterators[NAME] = ArrayValues;
|
1980 | if (explicit) for (key in es6_array_iterator) if (!proto[key]) _redefine(proto, key, es6_array_iterator[key], true);
|
1981 | }
|
1982 | }
|
1983 |
|
1984 | var runtime = createCommonjsModule(function (module) {
|
1985 |
|
1986 |
|
1987 |
|
1988 |
|
1989 |
|
1990 |
|
1991 |
|
1992 | !(function(global) {
|
1993 |
|
1994 | var Op = Object.prototype;
|
1995 | var hasOwn = Op.hasOwnProperty;
|
1996 | var undefined;
|
1997 | var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
1998 | var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
1999 | var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
2000 | var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
2001 | var runtime = global.regeneratorRuntime;
|
2002 | if (runtime) {
|
2003 | {
|
2004 |
|
2005 |
|
2006 | module.exports = runtime;
|
2007 | }
|
2008 |
|
2009 |
|
2010 | return;
|
2011 | }
|
2012 |
|
2013 |
|
2014 |
|
2015 | runtime = global.regeneratorRuntime = module.exports;
|
2016 |
|
2017 | function wrap(innerFn, outerFn, self, tryLocsList) {
|
2018 |
|
2019 | var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
2020 | var generator = Object.create(protoGenerator.prototype);
|
2021 | var context = new Context(tryLocsList || []);
|
2022 |
|
2023 |
|
2024 |
|
2025 | generator._invoke = makeInvokeMethod(innerFn, self, context);
|
2026 |
|
2027 | return generator;
|
2028 | }
|
2029 | runtime.wrap = wrap;
|
2030 |
|
2031 |
|
2032 |
|
2033 |
|
2034 |
|
2035 |
|
2036 |
|
2037 |
|
2038 |
|
2039 |
|
2040 |
|
2041 | function tryCatch(fn, obj, arg) {
|
2042 | try {
|
2043 | return { type: "normal", arg: fn.call(obj, arg) };
|
2044 | } catch (err) {
|
2045 | return { type: "throw", arg: err };
|
2046 | }
|
2047 | }
|
2048 |
|
2049 | var GenStateSuspendedStart = "suspendedStart";
|
2050 | var GenStateSuspendedYield = "suspendedYield";
|
2051 | var GenStateExecuting = "executing";
|
2052 | var GenStateCompleted = "completed";
|
2053 |
|
2054 |
|
2055 |
|
2056 | var ContinueSentinel = {};
|
2057 |
|
2058 |
|
2059 |
|
2060 |
|
2061 |
|
2062 | function Generator() {}
|
2063 | function GeneratorFunction() {}
|
2064 | function GeneratorFunctionPrototype() {}
|
2065 |
|
2066 |
|
2067 |
|
2068 | var IteratorPrototype = {};
|
2069 | IteratorPrototype[iteratorSymbol] = function () {
|
2070 | return this;
|
2071 | };
|
2072 |
|
2073 | var getProto = Object.getPrototypeOf;
|
2074 | var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
2075 | if (NativeIteratorPrototype &&
|
2076 | NativeIteratorPrototype !== Op &&
|
2077 | hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
2078 |
|
2079 |
|
2080 | IteratorPrototype = NativeIteratorPrototype;
|
2081 | }
|
2082 |
|
2083 | var Gp = GeneratorFunctionPrototype.prototype =
|
2084 | Generator.prototype = Object.create(IteratorPrototype);
|
2085 | GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
|
2086 | GeneratorFunctionPrototype.constructor = GeneratorFunction;
|
2087 | GeneratorFunctionPrototype[toStringTagSymbol] =
|
2088 | GeneratorFunction.displayName = "GeneratorFunction";
|
2089 |
|
2090 |
|
2091 |
|
2092 | function defineIteratorMethods(prototype) {
|
2093 | ["next", "throw", "return"].forEach(function(method) {
|
2094 | prototype[method] = function(arg) {
|
2095 | return this._invoke(method, arg);
|
2096 | };
|
2097 | });
|
2098 | }
|
2099 |
|
2100 | runtime.isGeneratorFunction = function(genFun) {
|
2101 | var ctor = typeof genFun === "function" && genFun.constructor;
|
2102 | return ctor
|
2103 | ? ctor === GeneratorFunction ||
|
2104 |
|
2105 |
|
2106 | (ctor.displayName || ctor.name) === "GeneratorFunction"
|
2107 | : false;
|
2108 | };
|
2109 |
|
2110 | runtime.mark = function(genFun) {
|
2111 | if (Object.setPrototypeOf) {
|
2112 | Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
2113 | } else {
|
2114 | genFun.__proto__ = GeneratorFunctionPrototype;
|
2115 | if (!(toStringTagSymbol in genFun)) {
|
2116 | genFun[toStringTagSymbol] = "GeneratorFunction";
|
2117 | }
|
2118 | }
|
2119 | genFun.prototype = Object.create(Gp);
|
2120 | return genFun;
|
2121 | };
|
2122 |
|
2123 |
|
2124 |
|
2125 |
|
2126 |
|
2127 | runtime.awrap = function(arg) {
|
2128 | return { __await: arg };
|
2129 | };
|
2130 |
|
2131 | function AsyncIterator(generator) {
|
2132 | function invoke(method, arg, resolve, reject) {
|
2133 | var record = tryCatch(generator[method], generator, arg);
|
2134 | if (record.type === "throw") {
|
2135 | reject(record.arg);
|
2136 | } else {
|
2137 | var result = record.arg;
|
2138 | var value = result.value;
|
2139 | if (value &&
|
2140 | typeof value === "object" &&
|
2141 | hasOwn.call(value, "__await")) {
|
2142 | return Promise.resolve(value.__await).then(function(value) {
|
2143 | invoke("next", value, resolve, reject);
|
2144 | }, function(err) {
|
2145 | invoke("throw", err, resolve, reject);
|
2146 | });
|
2147 | }
|
2148 |
|
2149 | return Promise.resolve(value).then(function(unwrapped) {
|
2150 |
|
2151 |
|
2152 |
|
2153 |
|
2154 |
|
2155 |
|
2156 |
|
2157 |
|
2158 |
|
2159 |
|
2160 |
|
2161 |
|
2162 |
|
2163 |
|
2164 |
|
2165 | result.value = unwrapped;
|
2166 | resolve(result);
|
2167 | }, reject);
|
2168 | }
|
2169 | }
|
2170 |
|
2171 | var previousPromise;
|
2172 |
|
2173 | function enqueue(method, arg) {
|
2174 | function callInvokeWithMethodAndArg() {
|
2175 | return new Promise(function(resolve, reject) {
|
2176 | invoke(method, arg, resolve, reject);
|
2177 | });
|
2178 | }
|
2179 |
|
2180 | return previousPromise =
|
2181 |
|
2182 |
|
2183 |
|
2184 |
|
2185 |
|
2186 |
|
2187 |
|
2188 |
|
2189 |
|
2190 |
|
2191 |
|
2192 |
|
2193 | previousPromise ? previousPromise.then(
|
2194 | callInvokeWithMethodAndArg,
|
2195 |
|
2196 |
|
2197 | callInvokeWithMethodAndArg
|
2198 | ) : callInvokeWithMethodAndArg();
|
2199 | }
|
2200 |
|
2201 |
|
2202 |
|
2203 | this._invoke = enqueue;
|
2204 | }
|
2205 |
|
2206 | defineIteratorMethods(AsyncIterator.prototype);
|
2207 | AsyncIterator.prototype[asyncIteratorSymbol] = function () {
|
2208 | return this;
|
2209 | };
|
2210 | runtime.AsyncIterator = AsyncIterator;
|
2211 |
|
2212 |
|
2213 |
|
2214 |
|
2215 | runtime.async = function(innerFn, outerFn, self, tryLocsList) {
|
2216 | var iter = new AsyncIterator(
|
2217 | wrap(innerFn, outerFn, self, tryLocsList)
|
2218 | );
|
2219 |
|
2220 | return runtime.isGeneratorFunction(outerFn)
|
2221 | ? iter
|
2222 | : iter.next().then(function(result) {
|
2223 | return result.done ? result.value : iter.next();
|
2224 | });
|
2225 | };
|
2226 |
|
2227 | function makeInvokeMethod(innerFn, self, context) {
|
2228 | var state = GenStateSuspendedStart;
|
2229 |
|
2230 | return function invoke(method, arg) {
|
2231 | if (state === GenStateExecuting) {
|
2232 | throw new Error("Generator is already running");
|
2233 | }
|
2234 |
|
2235 | if (state === GenStateCompleted) {
|
2236 | if (method === "throw") {
|
2237 | throw arg;
|
2238 | }
|
2239 |
|
2240 |
|
2241 |
|
2242 | return doneResult();
|
2243 | }
|
2244 |
|
2245 | context.method = method;
|
2246 | context.arg = arg;
|
2247 |
|
2248 | while (true) {
|
2249 | var delegate = context.delegate;
|
2250 | if (delegate) {
|
2251 | var delegateResult = maybeInvokeDelegate(delegate, context);
|
2252 | if (delegateResult) {
|
2253 | if (delegateResult === ContinueSentinel) continue;
|
2254 | return delegateResult;
|
2255 | }
|
2256 | }
|
2257 |
|
2258 | if (context.method === "next") {
|
2259 |
|
2260 |
|
2261 | context.sent = context._sent = context.arg;
|
2262 |
|
2263 | } else if (context.method === "throw") {
|
2264 | if (state === GenStateSuspendedStart) {
|
2265 | state = GenStateCompleted;
|
2266 | throw context.arg;
|
2267 | }
|
2268 |
|
2269 | context.dispatchException(context.arg);
|
2270 |
|
2271 | } else if (context.method === "return") {
|
2272 | context.abrupt("return", context.arg);
|
2273 | }
|
2274 |
|
2275 | state = GenStateExecuting;
|
2276 |
|
2277 | var record = tryCatch(innerFn, self, context);
|
2278 | if (record.type === "normal") {
|
2279 |
|
2280 |
|
2281 | state = context.done
|
2282 | ? GenStateCompleted
|
2283 | : GenStateSuspendedYield;
|
2284 |
|
2285 | if (record.arg === ContinueSentinel) {
|
2286 | continue;
|
2287 | }
|
2288 |
|
2289 | return {
|
2290 | value: record.arg,
|
2291 | done: context.done
|
2292 | };
|
2293 |
|
2294 | } else if (record.type === "throw") {
|
2295 | state = GenStateCompleted;
|
2296 |
|
2297 |
|
2298 | context.method = "throw";
|
2299 | context.arg = record.arg;
|
2300 | }
|
2301 | }
|
2302 | };
|
2303 | }
|
2304 |
|
2305 |
|
2306 |
|
2307 |
|
2308 |
|
2309 | function maybeInvokeDelegate(delegate, context) {
|
2310 | var method = delegate.iterator[context.method];
|
2311 | if (method === undefined) {
|
2312 |
|
2313 |
|
2314 | context.delegate = null;
|
2315 |
|
2316 | if (context.method === "throw") {
|
2317 | if (delegate.iterator.return) {
|
2318 |
|
2319 |
|
2320 | context.method = "return";
|
2321 | context.arg = undefined;
|
2322 | maybeInvokeDelegate(delegate, context);
|
2323 |
|
2324 | if (context.method === "throw") {
|
2325 |
|
2326 |
|
2327 | return ContinueSentinel;
|
2328 | }
|
2329 | }
|
2330 |
|
2331 | context.method = "throw";
|
2332 | context.arg = new TypeError(
|
2333 | "The iterator does not provide a 'throw' method");
|
2334 | }
|
2335 |
|
2336 | return ContinueSentinel;
|
2337 | }
|
2338 |
|
2339 | var record = tryCatch(method, delegate.iterator, context.arg);
|
2340 |
|
2341 | if (record.type === "throw") {
|
2342 | context.method = "throw";
|
2343 | context.arg = record.arg;
|
2344 | context.delegate = null;
|
2345 | return ContinueSentinel;
|
2346 | }
|
2347 |
|
2348 | var info = record.arg;
|
2349 |
|
2350 | if (! info) {
|
2351 | context.method = "throw";
|
2352 | context.arg = new TypeError("iterator result is not an object");
|
2353 | context.delegate = null;
|
2354 | return ContinueSentinel;
|
2355 | }
|
2356 |
|
2357 | if (info.done) {
|
2358 |
|
2359 |
|
2360 | context[delegate.resultName] = info.value;
|
2361 |
|
2362 |
|
2363 | context.next = delegate.nextLoc;
|
2364 |
|
2365 |
|
2366 |
|
2367 |
|
2368 |
|
2369 |
|
2370 |
|
2371 | if (context.method !== "return") {
|
2372 | context.method = "next";
|
2373 | context.arg = undefined;
|
2374 | }
|
2375 |
|
2376 | } else {
|
2377 |
|
2378 | return info;
|
2379 | }
|
2380 |
|
2381 |
|
2382 |
|
2383 | context.delegate = null;
|
2384 | return ContinueSentinel;
|
2385 | }
|
2386 |
|
2387 |
|
2388 |
|
2389 | defineIteratorMethods(Gp);
|
2390 |
|
2391 | Gp[toStringTagSymbol] = "Generator";
|
2392 |
|
2393 |
|
2394 |
|
2395 |
|
2396 |
|
2397 |
|
2398 | Gp[iteratorSymbol] = function() {
|
2399 | return this;
|
2400 | };
|
2401 |
|
2402 | Gp.toString = function() {
|
2403 | return "[object Generator]";
|
2404 | };
|
2405 |
|
2406 | function pushTryEntry(locs) {
|
2407 | var entry = { tryLoc: locs[0] };
|
2408 |
|
2409 | if (1 in locs) {
|
2410 | entry.catchLoc = locs[1];
|
2411 | }
|
2412 |
|
2413 | if (2 in locs) {
|
2414 | entry.finallyLoc = locs[2];
|
2415 | entry.afterLoc = locs[3];
|
2416 | }
|
2417 |
|
2418 | this.tryEntries.push(entry);
|
2419 | }
|
2420 |
|
2421 | function resetTryEntry(entry) {
|
2422 | var record = entry.completion || {};
|
2423 | record.type = "normal";
|
2424 | delete record.arg;
|
2425 | entry.completion = record;
|
2426 | }
|
2427 |
|
2428 | function Context(tryLocsList) {
|
2429 |
|
2430 |
|
2431 |
|
2432 | this.tryEntries = [{ tryLoc: "root" }];
|
2433 | tryLocsList.forEach(pushTryEntry, this);
|
2434 | this.reset(true);
|
2435 | }
|
2436 |
|
2437 | runtime.keys = function(object) {
|
2438 | var keys = [];
|
2439 | for (var key in object) {
|
2440 | keys.push(key);
|
2441 | }
|
2442 | keys.reverse();
|
2443 |
|
2444 |
|
2445 |
|
2446 | return function next() {
|
2447 | while (keys.length) {
|
2448 | var key = keys.pop();
|
2449 | if (key in object) {
|
2450 | next.value = key;
|
2451 | next.done = false;
|
2452 | return next;
|
2453 | }
|
2454 | }
|
2455 |
|
2456 |
|
2457 |
|
2458 |
|
2459 | next.done = true;
|
2460 | return next;
|
2461 | };
|
2462 | };
|
2463 |
|
2464 | function values(iterable) {
|
2465 | if (iterable) {
|
2466 | var iteratorMethod = iterable[iteratorSymbol];
|
2467 | if (iteratorMethod) {
|
2468 | return iteratorMethod.call(iterable);
|
2469 | }
|
2470 |
|
2471 | if (typeof iterable.next === "function") {
|
2472 | return iterable;
|
2473 | }
|
2474 |
|
2475 | if (!isNaN(iterable.length)) {
|
2476 | var i = -1, next = function next() {
|
2477 | while (++i < iterable.length) {
|
2478 | if (hasOwn.call(iterable, i)) {
|
2479 | next.value = iterable[i];
|
2480 | next.done = false;
|
2481 | return next;
|
2482 | }
|
2483 | }
|
2484 |
|
2485 | next.value = undefined;
|
2486 | next.done = true;
|
2487 |
|
2488 | return next;
|
2489 | };
|
2490 |
|
2491 | return next.next = next;
|
2492 | }
|
2493 | }
|
2494 |
|
2495 |
|
2496 | return { next: doneResult };
|
2497 | }
|
2498 | runtime.values = values;
|
2499 |
|
2500 | function doneResult() {
|
2501 | return { value: undefined, done: true };
|
2502 | }
|
2503 |
|
2504 | Context.prototype = {
|
2505 | constructor: Context,
|
2506 |
|
2507 | reset: function(skipTempReset) {
|
2508 | this.prev = 0;
|
2509 | this.next = 0;
|
2510 |
|
2511 |
|
2512 | this.sent = this._sent = undefined;
|
2513 | this.done = false;
|
2514 | this.delegate = null;
|
2515 |
|
2516 | this.method = "next";
|
2517 | this.arg = undefined;
|
2518 |
|
2519 | this.tryEntries.forEach(resetTryEntry);
|
2520 |
|
2521 | if (!skipTempReset) {
|
2522 | for (var name in this) {
|
2523 |
|
2524 | if (name.charAt(0) === "t" &&
|
2525 | hasOwn.call(this, name) &&
|
2526 | !isNaN(+name.slice(1))) {
|
2527 | this[name] = undefined;
|
2528 | }
|
2529 | }
|
2530 | }
|
2531 | },
|
2532 |
|
2533 | stop: function() {
|
2534 | this.done = true;
|
2535 |
|
2536 | var rootEntry = this.tryEntries[0];
|
2537 | var rootRecord = rootEntry.completion;
|
2538 | if (rootRecord.type === "throw") {
|
2539 | throw rootRecord.arg;
|
2540 | }
|
2541 |
|
2542 | return this.rval;
|
2543 | },
|
2544 |
|
2545 | dispatchException: function(exception) {
|
2546 | if (this.done) {
|
2547 | throw exception;
|
2548 | }
|
2549 |
|
2550 | var context = this;
|
2551 | function handle(loc, caught) {
|
2552 | record.type = "throw";
|
2553 | record.arg = exception;
|
2554 | context.next = loc;
|
2555 |
|
2556 | if (caught) {
|
2557 |
|
2558 |
|
2559 | context.method = "next";
|
2560 | context.arg = undefined;
|
2561 | }
|
2562 |
|
2563 | return !! caught;
|
2564 | }
|
2565 |
|
2566 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
2567 | var entry = this.tryEntries[i];
|
2568 | var record = entry.completion;
|
2569 |
|
2570 | if (entry.tryLoc === "root") {
|
2571 |
|
2572 |
|
2573 |
|
2574 | return handle("end");
|
2575 | }
|
2576 |
|
2577 | if (entry.tryLoc <= this.prev) {
|
2578 | var hasCatch = hasOwn.call(entry, "catchLoc");
|
2579 | var hasFinally = hasOwn.call(entry, "finallyLoc");
|
2580 |
|
2581 | if (hasCatch && hasFinally) {
|
2582 | if (this.prev < entry.catchLoc) {
|
2583 | return handle(entry.catchLoc, true);
|
2584 | } else if (this.prev < entry.finallyLoc) {
|
2585 | return handle(entry.finallyLoc);
|
2586 | }
|
2587 |
|
2588 | } else if (hasCatch) {
|
2589 | if (this.prev < entry.catchLoc) {
|
2590 | return handle(entry.catchLoc, true);
|
2591 | }
|
2592 |
|
2593 | } else if (hasFinally) {
|
2594 | if (this.prev < entry.finallyLoc) {
|
2595 | return handle(entry.finallyLoc);
|
2596 | }
|
2597 |
|
2598 | } else {
|
2599 | throw new Error("try statement without catch or finally");
|
2600 | }
|
2601 | }
|
2602 | }
|
2603 | },
|
2604 |
|
2605 | abrupt: function(type, arg) {
|
2606 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
2607 | var entry = this.tryEntries[i];
|
2608 | if (entry.tryLoc <= this.prev &&
|
2609 | hasOwn.call(entry, "finallyLoc") &&
|
2610 | this.prev < entry.finallyLoc) {
|
2611 | var finallyEntry = entry;
|
2612 | break;
|
2613 | }
|
2614 | }
|
2615 |
|
2616 | if (finallyEntry &&
|
2617 | (type === "break" ||
|
2618 | type === "continue") &&
|
2619 | finallyEntry.tryLoc <= arg &&
|
2620 | arg <= finallyEntry.finallyLoc) {
|
2621 |
|
2622 |
|
2623 | finallyEntry = null;
|
2624 | }
|
2625 |
|
2626 | var record = finallyEntry ? finallyEntry.completion : {};
|
2627 | record.type = type;
|
2628 | record.arg = arg;
|
2629 |
|
2630 | if (finallyEntry) {
|
2631 | this.method = "next";
|
2632 | this.next = finallyEntry.finallyLoc;
|
2633 | return ContinueSentinel;
|
2634 | }
|
2635 |
|
2636 | return this.complete(record);
|
2637 | },
|
2638 |
|
2639 | complete: function(record, afterLoc) {
|
2640 | if (record.type === "throw") {
|
2641 | throw record.arg;
|
2642 | }
|
2643 |
|
2644 | if (record.type === "break" ||
|
2645 | record.type === "continue") {
|
2646 | this.next = record.arg;
|
2647 | } else if (record.type === "return") {
|
2648 | this.rval = this.arg = record.arg;
|
2649 | this.method = "return";
|
2650 | this.next = "end";
|
2651 | } else if (record.type === "normal" && afterLoc) {
|
2652 | this.next = afterLoc;
|
2653 | }
|
2654 |
|
2655 | return ContinueSentinel;
|
2656 | },
|
2657 |
|
2658 | finish: function(finallyLoc) {
|
2659 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
2660 | var entry = this.tryEntries[i];
|
2661 | if (entry.finallyLoc === finallyLoc) {
|
2662 | this.complete(entry.completion, entry.afterLoc);
|
2663 | resetTryEntry(entry);
|
2664 | return ContinueSentinel;
|
2665 | }
|
2666 | }
|
2667 | },
|
2668 |
|
2669 | "catch": function(tryLoc) {
|
2670 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
2671 | var entry = this.tryEntries[i];
|
2672 | if (entry.tryLoc === tryLoc) {
|
2673 | var record = entry.completion;
|
2674 | if (record.type === "throw") {
|
2675 | var thrown = record.arg;
|
2676 | resetTryEntry(entry);
|
2677 | }
|
2678 | return thrown;
|
2679 | }
|
2680 | }
|
2681 |
|
2682 |
|
2683 |
|
2684 | throw new Error("illegal catch attempt");
|
2685 | },
|
2686 |
|
2687 | delegateYield: function(iterable, resultName, nextLoc) {
|
2688 | this.delegate = {
|
2689 | iterator: values(iterable),
|
2690 | resultName: resultName,
|
2691 | nextLoc: nextLoc
|
2692 | };
|
2693 |
|
2694 | if (this.method === "next") {
|
2695 |
|
2696 |
|
2697 | this.arg = undefined;
|
2698 | }
|
2699 |
|
2700 | return ContinueSentinel;
|
2701 | }
|
2702 | };
|
2703 | })(
|
2704 |
|
2705 |
|
2706 |
|
2707 | (function() { return this })() || Function("return this")()
|
2708 | );
|
2709 | });
|
2710 |
|
2711 |
|
2712 |
|
2713 |
|
2714 |
|
2715 | var Batch =
|
2716 |
|
2717 | function () {
|
2718 | |
2719 |
|
2720 |
|
2721 | function Batch(store) {
|
2722 | _classCallCheck(this, Batch);
|
2723 |
|
2724 | this.store = store;
|
2725 | this.queues = [];
|
2726 | }
|
2727 | |
2728 |
|
2729 |
|
2730 |
|
2731 |
|
2732 |
|
2733 |
|
2734 | _createClass(Batch, [{
|
2735 | key: "set",
|
2736 | value: function set(type, records) {
|
2737 | this.queues.push({
|
2738 | operation: 'set',
|
2739 | data: {
|
2740 | type: type,
|
2741 | records: records
|
2742 | }
|
2743 | });
|
2744 | }
|
2745 | |
2746 |
|
2747 |
|
2748 |
|
2749 |
|
2750 |
|
2751 |
|
2752 | }, {
|
2753 | key: "update",
|
2754 | value: function update(type, id, attribute) {
|
2755 | this.queues.push({
|
2756 | operation: 'update',
|
2757 | data: {
|
2758 | type: type,
|
2759 | id: id,
|
2760 | attribute: attribute
|
2761 | }
|
2762 | });
|
2763 | }
|
2764 | |
2765 |
|
2766 |
|
2767 |
|
2768 |
|
2769 |
|
2770 | }, {
|
2771 | key: "delete",
|
2772 | value: function _delete(type, id) {
|
2773 | this.queues.push({
|
2774 | operation: 'delete',
|
2775 | data: {
|
2776 | type: type,
|
2777 | id: id
|
2778 | }
|
2779 | });
|
2780 | }
|
2781 | |
2782 |
|
2783 |
|
2784 |
|
2785 |
|
2786 | }, {
|
2787 | key: "commit",
|
2788 | value: function commit(option) {
|
2789 | var _this = this;
|
2790 |
|
2791 | this.queues.forEach(function (_ref, index) {
|
2792 | var operation = _ref.operation,
|
2793 | data = _ref.data;
|
2794 | var finalOption = option;
|
2795 |
|
2796 | if (!finalOption) {
|
2797 | var isBackgroundOperation = index !== _this.queues.length - 1;
|
2798 | finalOption = {
|
2799 | isBackgroundOperation: isBackgroundOperation
|
2800 | };
|
2801 | }
|
2802 |
|
2803 | if (operation === 'set') {
|
2804 | _this.store.set(data.type, data.records, finalOption);
|
2805 | } else if (operation === 'update') {
|
2806 | _this.store.update(data.type, data.id, data.attribute, finalOption);
|
2807 | } else if (operation === 'delete') {
|
2808 | _this.store.delete(data.type, data.id, finalOption);
|
2809 | }
|
2810 | });
|
2811 | this.queues = [];
|
2812 | }
|
2813 | }]);
|
2814 |
|
2815 | return Batch;
|
2816 | }();
|
2817 |
|
2818 |
|
2819 |
|
2820 |
|
2821 |
|
2822 |
|
2823 |
|
2824 |
|
2825 | function getCardinality(model, type, attribute) {
|
2826 | var meta = model[type].relationship[attribute];
|
2827 |
|
2828 | if (meta.kind === 'belongsTo') {
|
2829 | if (meta.inverse) {
|
2830 | var inverseMeta = model[meta.type].relationship[meta.inverse];
|
2831 |
|
2832 | if (inverseMeta.kind === 'belongsTo') {
|
2833 | return 'oneToOne';
|
2834 | }
|
2835 |
|
2836 | return 'oneToMany';
|
2837 | }
|
2838 |
|
2839 | return 'oneToNone';
|
2840 | }
|
2841 |
|
2842 | if (meta.inverse) {
|
2843 | var _inverseMeta = model[meta.type].relationship[meta.inverse];
|
2844 |
|
2845 | if (_inverseMeta.kind === 'belongsTo') {
|
2846 | return 'oneToMany';
|
2847 | }
|
2848 |
|
2849 | return 'manyToMany';
|
2850 | }
|
2851 |
|
2852 | return 'manyToNone';
|
2853 | }
|
2854 |
|
2855 |
|
2856 |
|
2857 |
|
2858 |
|
2859 | function getDefaultRecord(model) {
|
2860 | var defaultRecord = {};
|
2861 | model.attributes.forEach(function (attribute) {
|
2862 | defaultRecord[attribute] = null;
|
2863 | });
|
2864 | Object.keys(model.relationship).forEach(function (relationshipKey) {
|
2865 | if (model.relationship[relationshipKey].kind === 'belongsTo') {
|
2866 | defaultRecord[relationshipKey] = null;
|
2867 | } else {
|
2868 | defaultRecord[relationshipKey] = [];
|
2869 | }
|
2870 | });
|
2871 | return defaultRecord;
|
2872 | }
|
2873 |
|
2874 |
|
2875 |
|
2876 |
|
2877 |
|
2878 |
|
2879 | function normalizeBelongsTo(record) {
|
2880 | if (typeof record === 'string' || record === null) {
|
2881 | return record;
|
2882 | }
|
2883 |
|
2884 | if (_typeof(record) === 'object') {
|
2885 | return record.id;
|
2886 | }
|
2887 |
|
2888 | return null;
|
2889 | }
|
2890 |
|
2891 |
|
2892 |
|
2893 |
|
2894 |
|
2895 |
|
2896 |
|
2897 | function normalizeHasMany(records) {
|
2898 | if (Array.isArray(records)) {
|
2899 | return records.map(function (record) {
|
2900 | if (typeof record === 'string') {
|
2901 | return record;
|
2902 | }
|
2903 |
|
2904 | return record.id;
|
2905 | });
|
2906 | }
|
2907 |
|
2908 | return [];
|
2909 | }
|
2910 |
|
2911 |
|
2912 |
|
2913 |
|
2914 |
|
2915 |
|
2916 |
|
2917 | function normalize(model, record) {
|
2918 | var normalizedRecord = {
|
2919 | id: record.id
|
2920 | };
|
2921 | model.attributes.forEach(function (attribute) {
|
2922 | normalizedRecord[attribute] = Object.prototype.hasOwnProperty.call(record, attribute) ? record[attribute] : null;
|
2923 | });
|
2924 | Object.keys(model.relationship).forEach(function (relationshipKey) {
|
2925 | if (model.relationship[relationshipKey].kind === 'belongsTo') {
|
2926 | normalizedRecord[relationshipKey] = normalizeBelongsTo(record[relationshipKey]);
|
2927 | } else {
|
2928 | normalizedRecord[relationshipKey] = normalizeHasMany(record[relationshipKey]);
|
2929 | }
|
2930 | });
|
2931 | return normalizedRecord;
|
2932 | }
|
2933 |
|
2934 |
|
2935 |
|
2936 |
|
2937 |
|
2938 |
|
2939 | var Store =
|
2940 |
|
2941 | function () {
|
2942 | |
2943 |
|
2944 |
|
2945 |
|
2946 |
|
2947 | |
2948 |
|
2949 |
|
2950 |
|
2951 | function Store(model) {
|
2952 | _classCallCheck(this, Store);
|
2953 |
|
2954 | this.model = model;
|
2955 | this.state = this.buildInitialState();
|
2956 | this.subscription = {};
|
2957 | }
|
2958 | |
2959 |
|
2960 |
|
2961 |
|
2962 |
|
2963 |
|
2964 |
|
2965 |
|
2966 | _createClass(Store, [{
|
2967 | key: "set",
|
2968 | value: function set(type, record) {
|
2969 | var option = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
2970 |
|
2971 | if (record.id) {
|
2972 | var modelForType = this.model[type];
|
2973 | var deserializedRecord = option.isDeserialized ? record : modelForType.deserialize(record);
|
2974 |
|
2975 | if (deserializedRecord) {
|
2976 | var normalizedRecord = normalize(modelForType, deserializedRecord);
|
2977 | this.state[type].data[normalizedRecord.id] = normalizedRecord;
|
2978 | this.syncAddedRelationships(type, deserializedRecord);
|
2979 |
|
2980 | if (!option.isBackgroundOperation) {
|
2981 | this.triggerSubscriptions();
|
2982 | }
|
2983 | }
|
2984 | } else {
|
2985 | throw new Error('Record to set has no ID');
|
2986 | }
|
2987 | }
|
2988 | |
2989 |
|
2990 |
|
2991 |
|
2992 |
|
2993 |
|
2994 |
|
2995 |
|
2996 | }, {
|
2997 | key: "update",
|
2998 | value: function update(type, id, attribute) {
|
2999 | var option = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
3000 | var cachedRecord = this.getStateForRecord(type, id);
|
3001 |
|
3002 | if (cachedRecord) {
|
3003 | var modelForType = this.model[type];
|
3004 | var updatedRecord = modelForType.deserialize(Object.assign({}, cachedRecord, attribute, {
|
3005 | id: id
|
3006 | }));
|
3007 | this.set(type, updatedRecord, {
|
3008 | isBackgroundOperation: true,
|
3009 | isDeserialized: true
|
3010 | });
|
3011 | this.syncRemovedRelationships(type, updatedRecord, cachedRecord);
|
3012 |
|
3013 | if (!option.isBackgroundOperation) {
|
3014 | this.triggerSubscriptions();
|
3015 | }
|
3016 | } else {
|
3017 | throw new Error('Record doesn\'t exist');
|
3018 | }
|
3019 | }
|
3020 | |
3021 |
|
3022 |
|
3023 |
|
3024 |
|
3025 |
|
3026 |
|
3027 | }, {
|
3028 | key: "delete",
|
3029 | value: function _delete(type, id) {
|
3030 | var option = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
3031 | var cachedRecord = this.getStateForRecord(type, id);
|
3032 |
|
3033 | if (cachedRecord) {
|
3034 | var modelForType = this.model[type];
|
3035 | var defaultRecord = getDefaultRecord(modelForType, type);
|
3036 | this.update(type, id, defaultRecord, {
|
3037 | isBackgroundOperation: true
|
3038 | });
|
3039 | delete this.state[type].data[id];
|
3040 |
|
3041 | if (!option.isBackgroundOperation) {
|
3042 | this.triggerSubscriptions();
|
3043 | }
|
3044 | } else {
|
3045 | throw new Error('Record doesn\'t exist');
|
3046 | }
|
3047 | }
|
3048 | |
3049 |
|
3050 |
|
3051 |
|
3052 |
|
3053 |
|
3054 |
|
3055 |
|
3056 | }, {
|
3057 | key: "get",
|
3058 | value: function () {
|
3059 | var _get$$1 = _asyncToGenerator(
|
3060 |
|
3061 | regeneratorRuntime.mark(function _callee(type, id) {
|
3062 | var option,
|
3063 | record,
|
3064 | recordState,
|
3065 | _args = arguments;
|
3066 | return regeneratorRuntime.wrap(function _callee$(_context) {
|
3067 | while (1) {
|
3068 | switch (_context.prev = _context.next) {
|
3069 | case 0:
|
3070 | option = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
|
3071 |
|
3072 | if (!(!this.isRecordAttributePopulated(type, id) && option.fetch)) {
|
3073 | _context.next = 8;
|
3074 | break;
|
3075 | }
|
3076 |
|
3077 | _context.next = 4;
|
3078 | return option.fetch();
|
3079 |
|
3080 | case 4:
|
3081 | record = _context.sent;
|
3082 |
|
3083 | if (record) {
|
3084 | _context.next = 7;
|
3085 | break;
|
3086 | }
|
3087 |
|
3088 | return _context.abrupt("return", null);
|
3089 |
|
3090 | case 7:
|
3091 | this.set(type, record, {
|
3092 | isBackgroundOperation: true
|
3093 | });
|
3094 |
|
3095 | case 8:
|
3096 | recordState = this.getStateForRecord(type, id);
|
3097 |
|
3098 | if (!(recordState && option.include)) {
|
3099 | _context.next = 12;
|
3100 | break;
|
3101 | }
|
3102 |
|
3103 | _context.next = 12;
|
3104 | return this.includeRelationships(type, recordState, option);
|
3105 |
|
3106 | case 12:
|
3107 | return _context.abrupt("return", this.getCachedRecord(type, id));
|
3108 |
|
3109 | case 13:
|
3110 | case "end":
|
3111 | return _context.stop();
|
3112 | }
|
3113 | }
|
3114 | }, _callee, this);
|
3115 | }));
|
3116 |
|
3117 | return function get(_x, _x2) {
|
3118 | return _get$$1.apply(this, arguments);
|
3119 | };
|
3120 | }()
|
3121 | |
3122 |
|
3123 |
|
3124 |
|
3125 |
|
3126 |
|
3127 |
|
3128 | }, {
|
3129 | key: "getAll",
|
3130 | value: function () {
|
3131 | var _getAll = _asyncToGenerator(
|
3132 |
|
3133 | regeneratorRuntime.mark(function _callee2(type) {
|
3134 | var _this = this;
|
3135 |
|
3136 | var option,
|
3137 | records,
|
3138 | _args2 = arguments;
|
3139 | return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
3140 | while (1) {
|
3141 | switch (_context2.prev = _context2.next) {
|
3142 | case 0:
|
3143 | option = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
|
3144 |
|
3145 | if (!(option.fetch && !this.state[type].isDataComplete)) {
|
3146 | _context2.next = 10;
|
3147 | break;
|
3148 | }
|
3149 |
|
3150 | _context2.next = 4;
|
3151 | return option.fetch();
|
3152 |
|
3153 | case 4:
|
3154 | _context2.t0 = _context2.sent;
|
3155 |
|
3156 | if (_context2.t0) {
|
3157 | _context2.next = 7;
|
3158 | break;
|
3159 | }
|
3160 |
|
3161 | _context2.t0 = [];
|
3162 |
|
3163 | case 7:
|
3164 | records = _context2.t0;
|
3165 | records.forEach(function (record) {
|
3166 | return _this.set(type, record, {
|
3167 | isBackgroundOperation: true
|
3168 | });
|
3169 | });
|
3170 | this.state[type].isDataComplete = true;
|
3171 |
|
3172 | case 10:
|
3173 | return _context2.abrupt("return", Promise.all(Object.keys(this.state[type].data).map(function (id) {
|
3174 | return _this.get(type, id, {
|
3175 | include: option.include
|
3176 | });
|
3177 | })));
|
3178 |
|
3179 | case 11:
|
3180 | case "end":
|
3181 | return _context2.stop();
|
3182 | }
|
3183 | }
|
3184 | }, _callee2, this);
|
3185 | }));
|
3186 |
|
3187 | return function getAll(_x3) {
|
3188 | return _getAll.apply(this, arguments);
|
3189 | };
|
3190 | }()
|
3191 | |
3192 |
|
3193 |
|
3194 |
|
3195 |
|
3196 |
|
3197 |
|
3198 | }, {
|
3199 | key: "query",
|
3200 | value: function () {
|
3201 | var _query = _asyncToGenerator(
|
3202 |
|
3203 | regeneratorRuntime.mark(function _callee3(type) {
|
3204 | var _this2 = this;
|
3205 |
|
3206 | var option,
|
3207 | records,
|
3208 | _args3 = arguments;
|
3209 | return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
3210 | while (1) {
|
3211 | switch (_context3.prev = _context3.next) {
|
3212 | case 0:
|
3213 | option = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
|
3214 | _context3.next = 3;
|
3215 | return option.fetch();
|
3216 |
|
3217 | case 3:
|
3218 | _context3.t0 = _context3.sent;
|
3219 |
|
3220 | if (_context3.t0) {
|
3221 | _context3.next = 6;
|
3222 | break;
|
3223 | }
|
3224 |
|
3225 | _context3.t0 = [];
|
3226 |
|
3227 | case 6:
|
3228 | records = _context3.t0;
|
3229 | records.forEach(function (record) {
|
3230 | return _this2.set(type, record, {
|
3231 | isBackgroundOperation: true
|
3232 | });
|
3233 | });
|
3234 | return _context3.abrupt("return", Promise.all(records.map(function (record) {
|
3235 | return _this2.get(type, record.id, {
|
3236 | include: option.include
|
3237 | });
|
3238 | })));
|
3239 |
|
3240 | case 9:
|
3241 | case "end":
|
3242 | return _context3.stop();
|
3243 | }
|
3244 | }
|
3245 | }, _callee3, this);
|
3246 | }));
|
3247 |
|
3248 | return function query(_x4) {
|
3249 | return _query.apply(this, arguments);
|
3250 | };
|
3251 | }()
|
3252 | |
3253 |
|
3254 |
|
3255 |
|
3256 | |
3257 |
|
3258 |
|
3259 |
|
3260 |
|
3261 |
|
3262 |
|
3263 | }, {
|
3264 | key: "subscribe",
|
3265 | value: function subscribe(callback) {
|
3266 | var _this3 = this;
|
3267 |
|
3268 | var id = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Math.random().toString(32).slice(2).substr(0, 5);
|
3269 | this.subscription[id] = callback;
|
3270 | return function () {
|
3271 | return delete _this3.subscription[id];
|
3272 | };
|
3273 | }
|
3274 | |
3275 |
|
3276 |
|
3277 |
|
3278 |
|
3279 | }, {
|
3280 | key: "batch",
|
3281 | value: function batch() {
|
3282 | return new Batch(this);
|
3283 | }
|
3284 | |
3285 |
|
3286 |
|
3287 |
|
3288 |
|
3289 |
|
3290 | }, {
|
3291 | key: "buildInitialState",
|
3292 | value: function buildInitialState() {
|
3293 | var model = this.model;
|
3294 | var state = {};
|
3295 | Object.keys(model).forEach(function (modelKey) {
|
3296 | state[modelKey] = {
|
3297 | isDataComplete: false,
|
3298 | data: {}
|
3299 | };
|
3300 | });
|
3301 | return state;
|
3302 | }
|
3303 | |
3304 |
|
3305 |
|
3306 |
|
3307 |
|
3308 |
|
3309 |
|
3310 |
|
3311 |
|
3312 | }, {
|
3313 | key: "getCachedRecord",
|
3314 | value: function getCachedRecord(type, id) {
|
3315 | var _this4 = this;
|
3316 |
|
3317 | var nestLevel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
3318 |
|
3319 | if (this.state[type].data[id]) {
|
3320 | var cachedRecord = Object.assign({}, this.state[type].data[id]);
|
3321 | var modelForType = this.model[type];
|
3322 | Object.keys(modelForType.relationship).forEach(function (relationshipKey) {
|
3323 | var descriptor = modelForType.relationship[relationshipKey];
|
3324 |
|
3325 | if (descriptor.kind === 'belongsTo' && cachedRecord[relationshipKey]) {
|
3326 | var belongsToId = cachedRecord[relationshipKey];
|
3327 |
|
3328 | if (nestLevel < 1) {
|
3329 | cachedRecord[relationshipKey] = _this4.getCachedRecord(descriptor.type, belongsToId, nestLevel + 1);
|
3330 | } else {
|
3331 | cachedRecord[relationshipKey] = Object.assign({}, _this4.state[descriptor.type].data[belongsToId]);
|
3332 | }
|
3333 | } else if (descriptor.kind === 'hasMany' && cachedRecord[relationshipKey].length > 0) {
|
3334 | cachedRecord[relationshipKey] = cachedRecord[relationshipKey].map(function (hasManyId) {
|
3335 | if (nestLevel < 1) {
|
3336 | return _this4.getCachedRecord(descriptor.type, hasManyId, nestLevel + 1);
|
3337 | }
|
3338 |
|
3339 | return Object.assign({}, _this4.state[descriptor.type].data[hasManyId]);
|
3340 | });
|
3341 | }
|
3342 | });
|
3343 | return cachedRecord;
|
3344 | }
|
3345 |
|
3346 | return null;
|
3347 | }
|
3348 | |
3349 |
|
3350 |
|
3351 |
|
3352 |
|
3353 |
|
3354 |
|
3355 |
|
3356 | }, {
|
3357 | key: "getStateForRecord",
|
3358 | value: function getStateForRecord(type, id) {
|
3359 | return this.state[type].data[id] || null;
|
3360 | }
|
3361 | |
3362 |
|
3363 |
|
3364 |
|
3365 |
|
3366 |
|
3367 |
|
3368 |
|
3369 | }, {
|
3370 | key: "isRecordAttributePopulated",
|
3371 | value: function isRecordAttributePopulated(type, id) {
|
3372 | var currentRecordState = this.getStateForRecord(type, id);
|
3373 |
|
3374 | if (currentRecordState) {
|
3375 | var attributes = this.model[type].attributes;
|
3376 | var populatedAttribute = attributes.find(function (key) {
|
3377 | if (currentRecordState[key] === null || Array.isArray(currentRecordState[key]) && currentRecordState[key].length === 0) {
|
3378 | return false;
|
3379 | }
|
3380 |
|
3381 | return true;
|
3382 | });
|
3383 | return populatedAttribute;
|
3384 | }
|
3385 |
|
3386 | return false;
|
3387 | }
|
3388 | |
3389 |
|
3390 |
|
3391 |
|
3392 |
|
3393 |
|
3394 |
|
3395 |
|
3396 |
|
3397 |
|
3398 | }, {
|
3399 | key: "includeRelationship",
|
3400 | value: function () {
|
3401 | var _includeRelationship = _asyncToGenerator(
|
3402 |
|
3403 | regeneratorRuntime.mark(function _callee4(type, record, option, key, descriptor) {
|
3404 | var _this5 = this;
|
3405 |
|
3406 | var includedData, _includedData, includedDataIds, uniqueHasManyIds;
|
3407 |
|
3408 | return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
3409 | while (1) {
|
3410 | switch (_context4.prev = _context4.next) {
|
3411 | case 0:
|
3412 | if (!(descriptor.kind === 'belongsTo')) {
|
3413 | _context4.next = 9;
|
3414 | break;
|
3415 | }
|
3416 |
|
3417 | if (!(record[key] === null || !this.isRecordAttributePopulated(descriptor.type, record[key]))) {
|
3418 | _context4.next = 7;
|
3419 | break;
|
3420 | }
|
3421 |
|
3422 | _context4.next = 4;
|
3423 | return option.include[key](record);
|
3424 |
|
3425 | case 4:
|
3426 | includedData = _context4.sent;
|
3427 | this.set(descriptor.type, includedData, {
|
3428 | isBackgroundOperation: true
|
3429 | });
|
3430 | this.update(type, record.id, _defineProperty({}, key, includedData.id), {
|
3431 | isBackgroundOperation: true
|
3432 | });
|
3433 |
|
3434 | case 7:
|
3435 | _context4.next = 17;
|
3436 | break;
|
3437 |
|
3438 | case 9:
|
3439 | if (!(descriptor.kind === 'hasMany')) {
|
3440 | _context4.next = 17;
|
3441 | break;
|
3442 | }
|
3443 |
|
3444 | _context4.next = 12;
|
3445 | return option.include[key](record);
|
3446 |
|
3447 | case 12:
|
3448 | _includedData = _context4.sent;
|
3449 |
|
3450 | _includedData.forEach(function (data) {
|
3451 | return _this5.set(descriptor.type, data, {
|
3452 | isBackgroundOperation: true
|
3453 | });
|
3454 | });
|
3455 |
|
3456 | includedDataIds = _includedData.map(function (data) {
|
3457 | return data.id;
|
3458 | });
|
3459 | uniqueHasManyIds = _toConsumableArray(new Set(_toConsumableArray(record[key]).concat(_toConsumableArray(includedDataIds))));
|
3460 | this.update(type, record.id, _defineProperty({}, key, uniqueHasManyIds), {
|
3461 | isBackgroundOperation: true
|
3462 | });
|
3463 |
|
3464 | case 17:
|
3465 | case "end":
|
3466 | return _context4.stop();
|
3467 | }
|
3468 | }
|
3469 | }, _callee4, this);
|
3470 | }));
|
3471 |
|
3472 | return function includeRelationship(_x5, _x6, _x7, _x8, _x9) {
|
3473 | return _includeRelationship.apply(this, arguments);
|
3474 | };
|
3475 | }()
|
3476 | |
3477 |
|
3478 |
|
3479 |
|
3480 |
|
3481 |
|
3482 |
|
3483 |
|
3484 | }, {
|
3485 | key: "includeRelationships",
|
3486 | value: function () {
|
3487 | var _includeRelationships = _asyncToGenerator(
|
3488 |
|
3489 | regeneratorRuntime.mark(function _callee5(type, record, option) {
|
3490 | var _this6 = this;
|
3491 |
|
3492 | var relationship, includes;
|
3493 | return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
3494 | while (1) {
|
3495 | switch (_context5.prev = _context5.next) {
|
3496 | case 0:
|
3497 | relationship = this.model[type].relationship;
|
3498 | includes = [];
|
3499 | Object.keys(relationship).forEach(function (key) {
|
3500 | if (option.include[key]) {
|
3501 | includes.push(_this6.includeRelationship(type, record, option, key, relationship[key]));
|
3502 | }
|
3503 | });
|
3504 | _context5.next = 5;
|
3505 | return Promise.all(includes);
|
3506 |
|
3507 | case 5:
|
3508 | case "end":
|
3509 | return _context5.stop();
|
3510 | }
|
3511 | }
|
3512 | }, _callee5, this);
|
3513 | }));
|
3514 |
|
3515 | return function includeRelationships(_x10, _x11, _x12) {
|
3516 | return _includeRelationships.apply(this, arguments);
|
3517 | };
|
3518 | }()
|
3519 | |
3520 |
|
3521 |
|
3522 |
|
3523 |
|
3524 |
|
3525 |
|
3526 |
|
3527 | }, {
|
3528 | key: "syncAddedBelongsTo",
|
3529 | value: function syncAddedBelongsTo(type, record, belongsToAttribute) {
|
3530 | var cardinality = getCardinality(this.model, type, belongsToAttribute);
|
3531 | var descriptor = this.model[type].relationship[belongsToAttribute];
|
3532 | var recordToSync;
|
3533 |
|
3534 | if (_typeof(record[belongsToAttribute]) === 'object' && record[belongsToAttribute] !== null) {
|
3535 | recordToSync = this.model[descriptor.type].deserialize(record[belongsToAttribute]);
|
3536 | } else {
|
3537 | recordToSync = {
|
3538 | id: record[belongsToAttribute]
|
3539 | };
|
3540 | }
|
3541 |
|
3542 | if (cardinality === 'oneToOne') {
|
3543 | var cachedRecord = this.getStateForRecord(descriptor.type, recordToSync.id);
|
3544 |
|
3545 | if (!cachedRecord || !cachedRecord[descriptor.inverse]) {
|
3546 | var newRecord = Object.assign(recordToSync, _defineProperty({}, descriptor.inverse, record.id));
|
3547 | this.set(descriptor.type, newRecord, {
|
3548 | isBackgroundOperation: true
|
3549 | });
|
3550 | }
|
3551 | } else if (cardinality === 'oneToMany') {
|
3552 | var _cachedRecord = this.getStateForRecord(descriptor.type, recordToSync.id);
|
3553 |
|
3554 | if (!_cachedRecord) {
|
3555 | var _newRecord = Object.assign(recordToSync, _defineProperty({}, descriptor.inverse, [record.id]));
|
3556 |
|
3557 | this.set(descriptor.type, _newRecord, {
|
3558 | isBackgroundOperation: true
|
3559 | });
|
3560 | } else if (!_cachedRecord[descriptor.inverse].find(function (id) {
|
3561 | return id === record.id;
|
3562 | })) {
|
3563 | _cachedRecord[descriptor.inverse].push(record.id);
|
3564 | }
|
3565 | } else {
|
3566 | var _cachedRecord2 = this.getStateForRecord(descriptor.type, recordToSync.id) || {};
|
3567 |
|
3568 | var _newRecord2 = Object.assign(_cachedRecord2, recordToSync);
|
3569 |
|
3570 | this.set(descriptor.type, _newRecord2, {
|
3571 | isBackgroundOperation: true
|
3572 | });
|
3573 | }
|
3574 | }
|
3575 | |
3576 |
|
3577 |
|
3578 |
|
3579 |
|
3580 |
|
3581 |
|
3582 |
|
3583 | }, {
|
3584 | key: "syncAddedHasMany",
|
3585 | value: function syncAddedHasMany(type, record, hasManyAttribute) {
|
3586 | var _this7 = this;
|
3587 |
|
3588 | var recordsToSync = record[hasManyAttribute];
|
3589 |
|
3590 | if (Array.isArray(recordsToSync)) {
|
3591 | recordsToSync.forEach(function (item) {
|
3592 | var cardinality = getCardinality(_this7.model, type, hasManyAttribute);
|
3593 | var descriptor = _this7.model[type].relationship[hasManyAttribute];
|
3594 | var recordToSync;
|
3595 |
|
3596 | if (_typeof(item) === 'object' && item !== null) {
|
3597 | recordToSync = _this7.model[descriptor.type].deserialize(item);
|
3598 | } else {
|
3599 | recordToSync = {
|
3600 | id: item
|
3601 | };
|
3602 | }
|
3603 |
|
3604 | if (cardinality === 'oneToMany') {
|
3605 | var cachedRecord = _this7.getStateForRecord(descriptor.type, recordToSync.id);
|
3606 |
|
3607 | if (!cachedRecord) {
|
3608 | var newRecord = Object.assign(recordToSync, _defineProperty({}, descriptor.inverse, record.id));
|
3609 |
|
3610 | _this7.set(descriptor.type, newRecord, {
|
3611 | isBackgroundOperation: true
|
3612 | });
|
3613 | } else {
|
3614 | cachedRecord[descriptor.inverse] = record.id;
|
3615 | }
|
3616 | } else if (cardinality === 'manyToMany') {
|
3617 | var _cachedRecord3 = _this7.getStateForRecord(descriptor.type, recordToSync.id);
|
3618 |
|
3619 | if (!_cachedRecord3) {
|
3620 | var _newRecord3 = Object.assign(recordToSync, _defineProperty({}, descriptor.inverse, [record.id]));
|
3621 |
|
3622 | _this7.set(descriptor.type, _newRecord3, {
|
3623 | isBackgroundOperation: true
|
3624 | });
|
3625 | } else if (!_cachedRecord3[descriptor.inverse].find(function (id) {
|
3626 | return id === record.id;
|
3627 | })) {
|
3628 | _cachedRecord3[descriptor.inverse].push(record.id);
|
3629 | }
|
3630 | } else {
|
3631 | var _cachedRecord4 = _this7.getStateForRecord(descriptor.type, recordToSync.id) || {};
|
3632 |
|
3633 | var _newRecord4 = Object.assign(_cachedRecord4, recordToSync);
|
3634 |
|
3635 | _this7.set(descriptor.type, _newRecord4, {
|
3636 | isBackgroundOperation: true
|
3637 | });
|
3638 | }
|
3639 | });
|
3640 | }
|
3641 | }
|
3642 | |
3643 |
|
3644 |
|
3645 |
|
3646 |
|
3647 |
|
3648 |
|
3649 |
|
3650 | }, {
|
3651 | key: "syncExistingHasMany",
|
3652 | value: function syncExistingHasMany(type, record, hasManyAttribute) {
|
3653 | var cardinality = getCardinality(this.model, type, hasManyAttribute);
|
3654 | var descriptor = this.model[type].relationship[hasManyAttribute];
|
3655 | var inverseData = this.state[descriptor.type].data;
|
3656 | var recordId = _typeof(record) === 'object' && record !== null ? record.id : record;
|
3657 |
|
3658 | if (cardinality === 'oneToMany') {
|
3659 | var currentHasManyState = this.state[type].data[recordId][hasManyAttribute];
|
3660 | var inverseIds = Object.keys(this.state[descriptor.type].data).filter(function (id) {
|
3661 | return inverseData[id][descriptor.inverse] === recordId;
|
3662 | });
|
3663 | inverseIds.forEach(function (id) {
|
3664 | if (!currentHasManyState.includes(id)) {
|
3665 | currentHasManyState.push(id);
|
3666 | }
|
3667 | });
|
3668 | } else if (cardinality === 'manyToMany') {
|
3669 | var _currentHasManyState = this.state[type].data[recordId][hasManyAttribute];
|
3670 |
|
3671 | var _inverseIds = Object.keys(this.state[descriptor.type].data).filter(function (id) {
|
3672 | return inverseData[id][descriptor.inverse].includes(recordId);
|
3673 | });
|
3674 |
|
3675 | _inverseIds.forEach(function (id) {
|
3676 | if (!_currentHasManyState.includes(id)) {
|
3677 | _currentHasManyState.push(id);
|
3678 | }
|
3679 | });
|
3680 | }
|
3681 | }
|
3682 | |
3683 |
|
3684 |
|
3685 |
|
3686 |
|
3687 |
|
3688 |
|
3689 | }, {
|
3690 | key: "syncAddedRelationships",
|
3691 | value: function syncAddedRelationships(type, record) {
|
3692 | var _this8 = this;
|
3693 |
|
3694 | Object.keys(this.model[type].relationship).forEach(function (relationshipKey) {
|
3695 | var kind = _this8.model[type].relationship[relationshipKey].kind;
|
3696 |
|
3697 | if (record[relationshipKey]) {
|
3698 | if (kind === 'belongsTo') {
|
3699 | _this8.syncAddedBelongsTo(type, record, relationshipKey);
|
3700 | } else {
|
3701 | _this8.syncAddedHasMany(type, record, relationshipKey);
|
3702 | }
|
3703 | } else if (kind === 'hasMany') {
|
3704 | _this8.syncExistingHasMany(type, record, relationshipKey);
|
3705 | }
|
3706 | });
|
3707 | }
|
3708 | |
3709 |
|
3710 |
|
3711 |
|
3712 |
|
3713 |
|
3714 |
|
3715 |
|
3716 |
|
3717 |
|
3718 | }, {
|
3719 | key: "syncRemovedBelongsToRelationship",
|
3720 | value: function syncRemovedBelongsToRelationship(type, currentRecord, oldRecord, key, descriptor) {
|
3721 | if (currentRecord[key] === null && currentRecord[key] !== oldRecord[key]) {
|
3722 | var inverseRecord = this.getStateForRecord(descriptor.type, oldRecord[key]);
|
3723 |
|
3724 | if (inverseRecord) {
|
3725 | var cardinality = getCardinality(this.model, type, key);
|
3726 |
|
3727 | if (cardinality === 'oneToOne') {
|
3728 | inverseRecord[descriptor.inverse] = null;
|
3729 | } else if (cardinality === 'oneToMany') {
|
3730 | inverseRecord[descriptor.inverse] = inverseRecord[descriptor.inverse].filter(function (id) {
|
3731 | return id !== oldRecord.id;
|
3732 | });
|
3733 | }
|
3734 | }
|
3735 | }
|
3736 | }
|
3737 | |
3738 |
|
3739 |
|
3740 |
|
3741 |
|
3742 |
|
3743 |
|
3744 |
|
3745 |
|
3746 |
|
3747 | }, {
|
3748 | key: "syncRemovedHasManyRelationship",
|
3749 | value: function syncRemovedHasManyRelationship(type, currentRecord, oldRecord, key, descriptor) {
|
3750 | var _this9 = this;
|
3751 |
|
3752 | var removedRecords = oldRecord[key].filter(function (record) {
|
3753 | return !currentRecord[key].includes(record);
|
3754 | });
|
3755 | removedRecords.forEach(function (removedRecord) {
|
3756 | var inverseRecord = _this9.getStateForRecord(descriptor.type, removedRecord);
|
3757 |
|
3758 | if (inverseRecord) {
|
3759 | var cardinality = getCardinality(_this9.model, type, key);
|
3760 |
|
3761 | if (cardinality === 'oneToMany') {
|
3762 | inverseRecord[descriptor.inverse] = null;
|
3763 | } else if (cardinality === 'manyToMany') {
|
3764 | inverseRecord[descriptor.inverse] = inverseRecord[descriptor.inverse].filter(function (id) {
|
3765 | return id !== oldRecord.id;
|
3766 | });
|
3767 | }
|
3768 | }
|
3769 | });
|
3770 | }
|
3771 | |
3772 |
|
3773 |
|
3774 |
|
3775 |
|
3776 |
|
3777 |
|
3778 |
|
3779 | }, {
|
3780 | key: "syncRemovedRelationships",
|
3781 | value: function syncRemovedRelationships(type, currentRecord, oldRecord) {
|
3782 | var _this10 = this;
|
3783 |
|
3784 | var model = this.model[type];
|
3785 | Object.keys(model.relationship).forEach(function (attributeKey) {
|
3786 | var descriptor = model.relationship[attributeKey];
|
3787 |
|
3788 | if (descriptor.kind === 'belongsTo') {
|
3789 | _this10.syncRemovedBelongsToRelationship(type, currentRecord, oldRecord, attributeKey, descriptor);
|
3790 | } else if (descriptor.kind === 'hasMany') {
|
3791 | _this10.syncRemovedHasManyRelationship(type, currentRecord, oldRecord, attributeKey, descriptor);
|
3792 | }
|
3793 | });
|
3794 | }
|
3795 | |
3796 |
|
3797 |
|
3798 |
|
3799 |
|
3800 | }, {
|
3801 | key: "triggerSubscriptions",
|
3802 | value: function triggerSubscriptions() {
|
3803 | var _this11 = this;
|
3804 |
|
3805 | Object.keys(this.subscription).forEach(function (key) {
|
3806 | try {
|
3807 | _this11.subscription[key]();
|
3808 | } catch (error) {
|
3809 | delete _this11.subscription[key];
|
3810 | }
|
3811 | });
|
3812 | }
|
3813 | }]);
|
3814 |
|
3815 | return Store;
|
3816 | }();
|
3817 |
|
3818 | export { Model, Store };
|