UNPKG

143 kBJavaScriptView Raw
1'use strict';Object.defineProperty(exports,'__esModule',{value:true});var parseUrl=require('peeler-js/es/parseUrl'),logger$4=require('peeler-js/es/logger'),getUA=require('peeler-js/es/getUA'),Request=require('ajax-maker'),storage=require('peeler-js/es/storage'),isType=require('peeler-js/es/isType'),jsBase64=require('js-base64'),require$$0=require('crypto');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var Request__default=/*#__PURE__*/_interopDefaultLegacy(Request);var require$$0__default=/*#__PURE__*/_interopDefaultLegacy(require$$0);var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2
3function createCommonjsModule(fn) {
4 var module = { exports: {} };
5 return fn(module, module.exports), module.exports;
6}
7
8function commonjsRequire (target) {
9 throw new Error('Could not dynamically require "' + target + '". Please configure the dynamicRequireTargets option of @rollup/plugin-commonjs appropriately for this require call to behave properly.');
10}var check = function (it) {
11 return it && it.Math == Math && it;
12};
13
14// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
15var global$1 =
16 /* global globalThis -- safe */
17 check(typeof globalThis == 'object' && globalThis) ||
18 check(typeof window == 'object' && window) ||
19 check(typeof self == 'object' && self) ||
20 check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
21 // eslint-disable-next-line no-new-func -- fallback
22 (function () { return this; })() || Function('return this')();var fails = function (exec) {
23 try {
24 return !!exec();
25 } catch (error) {
26 return true;
27 }
28};// Detect IE8's incomplete defineProperty implementation
29var descriptors = !fails(function () {
30 return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
31});var nativePropertyIsEnumerable = {}.propertyIsEnumerable;
32var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
33
34// Nashorn ~ JDK8 bug
35var NASHORN_BUG = getOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({ 1: 2 }, 1);
36
37// `Object.prototype.propertyIsEnumerable` method implementation
38// https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
39var f = NASHORN_BUG ? function propertyIsEnumerable(V) {
40 var descriptor = getOwnPropertyDescriptor(this, V);
41 return !!descriptor && descriptor.enumerable;
42} : nativePropertyIsEnumerable;
43
44var objectPropertyIsEnumerable = {
45 f: f
46};var createPropertyDescriptor = function (bitmap, value) {
47 return {
48 enumerable: !(bitmap & 1),
49 configurable: !(bitmap & 2),
50 writable: !(bitmap & 4),
51 value: value
52 };
53};var toString = {}.toString;
54
55var classofRaw = function (it) {
56 return toString.call(it).slice(8, -1);
57};var split = ''.split;
58
59// fallback for non-array-like ES3 and non-enumerable old V8 strings
60var indexedObject = fails(function () {
61 // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
62 // eslint-disable-next-line no-prototype-builtins -- safe
63 return !Object('z').propertyIsEnumerable(0);
64}) ? function (it) {
65 return classofRaw(it) == 'String' ? split.call(it, '') : Object(it);
66} : Object;// `RequireObjectCoercible` abstract operation
67// https://tc39.es/ecma262/#sec-requireobjectcoercible
68var requireObjectCoercible = function (it) {
69 if (it == undefined) throw TypeError("Can't call method on " + it);
70 return it;
71};// toObject with fallback for non-array-like ES3 strings
72
73
74
75var toIndexedObject = function (it) {
76 return indexedObject(requireObjectCoercible(it));
77};var isObject = function (it) {
78 return typeof it === 'object' ? it !== null : typeof it === 'function';
79};// `ToPrimitive` abstract operation
80// https://tc39.es/ecma262/#sec-toprimitive
81// instead of the ES6 spec version, we didn't implement @@toPrimitive case
82// and the second argument - flag - preferred type is a string
83var toPrimitive = function (input, PREFERRED_STRING) {
84 if (!isObject(input)) return input;
85 var fn, val;
86 if (PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
87 if (typeof (fn = input.valueOf) == 'function' && !isObject(val = fn.call(input))) return val;
88 if (!PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
89 throw TypeError("Can't convert object to primitive value");
90};var hasOwnProperty = {}.hasOwnProperty;
91
92var has = function (it, key) {
93 return hasOwnProperty.call(it, key);
94};var document$1 = global$1.document;
95// typeof document.createElement is 'object' in old IE
96var EXISTS = isObject(document$1) && isObject(document$1.createElement);
97
98var documentCreateElement = function (it) {
99 return EXISTS ? document$1.createElement(it) : {};
100};// Thank's IE8 for his funny defineProperty
101var ie8DomDefine = !descriptors && !fails(function () {
102 return Object.defineProperty(documentCreateElement('div'), 'a', {
103 get: function () { return 7; }
104 }).a != 7;
105});var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
106
107// `Object.getOwnPropertyDescriptor` method
108// https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
109var f$1 = descriptors ? nativeGetOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
110 O = toIndexedObject(O);
111 P = toPrimitive(P, true);
112 if (ie8DomDefine) try {
113 return nativeGetOwnPropertyDescriptor(O, P);
114 } catch (error) { /* empty */ }
115 if (has(O, P)) return createPropertyDescriptor(!objectPropertyIsEnumerable.f.call(O, P), O[P]);
116};
117
118var objectGetOwnPropertyDescriptor = {
119 f: f$1
120};var replacement = /#|\.prototype\./;
121
122var isForced = function (feature, detection) {
123 var value = data[normalize(feature)];
124 return value == POLYFILL ? true
125 : value == NATIVE ? false
126 : typeof detection == 'function' ? fails(detection)
127 : !!detection;
128};
129
130var normalize = isForced.normalize = function (string) {
131 return String(string).replace(replacement, '.').toLowerCase();
132};
133
134var data = isForced.data = {};
135var NATIVE = isForced.NATIVE = 'N';
136var POLYFILL = isForced.POLYFILL = 'P';
137
138var isForced_1 = isForced;var path = {};var aFunction = function (it) {
139 if (typeof it != 'function') {
140 throw TypeError(String(it) + ' is not a function');
141 } return it;
142};// optional / simple context binding
143var functionBindContext = function (fn, that, length) {
144 aFunction(fn);
145 if (that === undefined) return fn;
146 switch (length) {
147 case 0: return function () {
148 return fn.call(that);
149 };
150 case 1: return function (a) {
151 return fn.call(that, a);
152 };
153 case 2: return function (a, b) {
154 return fn.call(that, a, b);
155 };
156 case 3: return function (a, b, c) {
157 return fn.call(that, a, b, c);
158 };
159 }
160 return function (/* ...args */) {
161 return fn.apply(that, arguments);
162 };
163};var anObject = function (it) {
164 if (!isObject(it)) {
165 throw TypeError(String(it) + ' is not an object');
166 } return it;
167};var nativeDefineProperty = Object.defineProperty;
168
169// `Object.defineProperty` method
170// https://tc39.es/ecma262/#sec-object.defineproperty
171var f$2 = descriptors ? nativeDefineProperty : function defineProperty(O, P, Attributes) {
172 anObject(O);
173 P = toPrimitive(P, true);
174 anObject(Attributes);
175 if (ie8DomDefine) try {
176 return nativeDefineProperty(O, P, Attributes);
177 } catch (error) { /* empty */ }
178 if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
179 if ('value' in Attributes) O[P] = Attributes.value;
180 return O;
181};
182
183var objectDefineProperty = {
184 f: f$2
185};var createNonEnumerableProperty = descriptors ? function (object, key, value) {
186 return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value));
187} : function (object, key, value) {
188 object[key] = value;
189 return object;
190};var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
191
192
193
194
195
196
197var wrapConstructor = function (NativeConstructor) {
198 var Wrapper = function (a, b, c) {
199 if (this instanceof NativeConstructor) {
200 switch (arguments.length) {
201 case 0: return new NativeConstructor();
202 case 1: return new NativeConstructor(a);
203 case 2: return new NativeConstructor(a, b);
204 } return new NativeConstructor(a, b, c);
205 } return NativeConstructor.apply(this, arguments);
206 };
207 Wrapper.prototype = NativeConstructor.prototype;
208 return Wrapper;
209};
210
211/*
212 options.target - name of the target object
213 options.global - target is the global object
214 options.stat - export as static methods of target
215 options.proto - export as prototype methods of target
216 options.real - real prototype method for the `pure` version
217 options.forced - export even if the native feature is available
218 options.bind - bind methods to the target, required for the `pure` version
219 options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
220 options.unsafe - use the simple assignment of property instead of delete + defineProperty
221 options.sham - add a flag to not completely full polyfills
222 options.enumerable - export as enumerable property
223 options.noTargetGet - prevent calling a getter on target
224*/
225var _export = function (options, source) {
226 var TARGET = options.target;
227 var GLOBAL = options.global;
228 var STATIC = options.stat;
229 var PROTO = options.proto;
230
231 var nativeSource = GLOBAL ? global$1 : STATIC ? global$1[TARGET] : (global$1[TARGET] || {}).prototype;
232
233 var target = GLOBAL ? path : path[TARGET] || (path[TARGET] = {});
234 var targetPrototype = target.prototype;
235
236 var FORCED, USE_NATIVE, VIRTUAL_PROTOTYPE;
237 var key, sourceProperty, targetProperty, nativeProperty, resultProperty, descriptor;
238
239 for (key in source) {
240 FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
241 // contains in native
242 USE_NATIVE = !FORCED && nativeSource && has(nativeSource, key);
243
244 targetProperty = target[key];
245
246 if (USE_NATIVE) if (options.noTargetGet) {
247 descriptor = getOwnPropertyDescriptor$1(nativeSource, key);
248 nativeProperty = descriptor && descriptor.value;
249 } else nativeProperty = nativeSource[key];
250
251 // export native or implementation
252 sourceProperty = (USE_NATIVE && nativeProperty) ? nativeProperty : source[key];
253
254 if (USE_NATIVE && typeof targetProperty === typeof sourceProperty) continue;
255
256 // bind timers to global for call from export context
257 if (options.bind && USE_NATIVE) resultProperty = functionBindContext(sourceProperty, global$1);
258 // wrap global constructors for prevent changs in this version
259 else if (options.wrap && USE_NATIVE) resultProperty = wrapConstructor(sourceProperty);
260 // make static versions for prototype methods
261 else if (PROTO && typeof sourceProperty == 'function') resultProperty = functionBindContext(Function.call, sourceProperty);
262 // default case
263 else resultProperty = sourceProperty;
264
265 // add a flag to not completely full polyfills
266 if (options.sham || (sourceProperty && sourceProperty.sham) || (targetProperty && targetProperty.sham)) {
267 createNonEnumerableProperty(resultProperty, 'sham', true);
268 }
269
270 target[key] = resultProperty;
271
272 if (PROTO) {
273 VIRTUAL_PROTOTYPE = TARGET + 'Prototype';
274 if (!has(path, VIRTUAL_PROTOTYPE)) {
275 createNonEnumerableProperty(path, VIRTUAL_PROTOTYPE, {});
276 }
277 // export virtual prototype methods
278 path[VIRTUAL_PROTOTYPE][key] = sourceProperty;
279 // export real prototype methods
280 if (options.real && targetPrototype && !targetPrototype[key]) {
281 createNonEnumerableProperty(targetPrototype, key, sourceProperty);
282 }
283 }
284 }
285};var aFunction$1 = function (variable) {
286 return typeof variable == 'function' ? variable : undefined;
287};
288
289var getBuiltIn = function (namespace, method) {
290 return arguments.length < 2 ? aFunction$1(path[namespace]) || aFunction$1(global$1[namespace])
291 : path[namespace] && path[namespace][method] || global$1[namespace] && global$1[namespace][method];
292};var $stringify = getBuiltIn('JSON', 'stringify');
293var re = /[\uD800-\uDFFF]/g;
294var low = /^[\uD800-\uDBFF]$/;
295var hi = /^[\uDC00-\uDFFF]$/;
296
297var fix = function (match, offset, string) {
298 var prev = string.charAt(offset - 1);
299 var next = string.charAt(offset + 1);
300 if ((low.test(match) && !hi.test(next)) || (hi.test(match) && !low.test(prev))) {
301 return '\\u' + match.charCodeAt(0).toString(16);
302 } return match;
303};
304
305var FORCED = fails(function () {
306 return $stringify('\uDF06\uD834') !== '"\\udf06\\ud834"'
307 || $stringify('\uDEAD') !== '"\\udead"';
308});
309
310if ($stringify) {
311 // `JSON.stringify` method
312 // https://tc39.es/ecma262/#sec-json.stringify
313 // https://github.com/tc39/proposal-well-formed-stringify
314 _export({ target: 'JSON', stat: true, forced: FORCED }, {
315 // eslint-disable-next-line no-unused-vars -- required for `.length`
316 stringify: function stringify(it, replacer, space) {
317 var result = $stringify.apply(null, arguments);
318 return typeof result == 'string' ? result.replace(re, fix) : result;
319 }
320 });
321}if (!path.JSON) path.JSON = { stringify: JSON.stringify };
322
323// eslint-disable-next-line no-unused-vars -- required for `.length`
324var stringify = function stringify(it, replacer, space) {
325 return path.JSON.stringify.apply(null, arguments);
326};var stringify$1 = stringify;var stringify$2 = stringify$1;// `ToObject` abstract operation
327// https://tc39.es/ecma262/#sec-toobject
328var toObject = function (argument) {
329 return Object(requireObjectCoercible(argument));
330};var isPure = true;var setGlobal = function (key, value) {
331 try {
332 createNonEnumerableProperty(global$1, key, value);
333 } catch (error) {
334 global$1[key] = value;
335 } return value;
336};var SHARED = '__core-js_shared__';
337var store = global$1[SHARED] || setGlobal(SHARED, {});
338
339var sharedStore = store;var shared = createCommonjsModule(function (module) {
340(module.exports = function (key, value) {
341 return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {});
342})('versions', []).push({
343 version: '3.9.1',
344 mode: 'pure' ,
345 copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
346});
347});var id = 0;
348var postfix = Math.random();
349
350var uid = function (key) {
351 return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);
352};var keys = shared('keys');
353
354var sharedKey = function (key) {
355 return keys[key] || (keys[key] = uid(key));
356};var correctPrototypeGetter = !fails(function () {
357 function F() { /* empty */ }
358 F.prototype.constructor = null;
359 return Object.getPrototypeOf(new F()) !== F.prototype;
360});var IE_PROTO = sharedKey('IE_PROTO');
361var ObjectPrototype = Object.prototype;
362
363// `Object.getPrototypeOf` method
364// https://tc39.es/ecma262/#sec-object.getprototypeof
365var objectGetPrototypeOf = correctPrototypeGetter ? Object.getPrototypeOf : function (O) {
366 O = toObject(O);
367 if (has(O, IE_PROTO)) return O[IE_PROTO];
368 if (typeof O.constructor == 'function' && O instanceof O.constructor) {
369 return O.constructor.prototype;
370 } return O instanceof Object ? ObjectPrototype : null;
371};var aPossiblePrototype = function (it) {
372 if (!isObject(it) && it !== null) {
373 throw TypeError("Can't set " + String(it) + ' as a prototype');
374 } return it;
375};/* eslint-disable no-proto -- safe */
376
377// `Object.setPrototypeOf` method
378// https://tc39.es/ecma262/#sec-object.setprototypeof
379// Works with __proto__ only. Old v8 can't work with null proto objects.
380var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () {
381 var CORRECT_SETTER = false;
382 var test = {};
383 var setter;
384 try {
385 setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;
386 setter.call(test, []);
387 CORRECT_SETTER = test instanceof Array;
388 } catch (error) { /* empty */ }
389 return function setPrototypeOf(O, proto) {
390 anObject(O);
391 aPossiblePrototype(proto);
392 if (CORRECT_SETTER) setter.call(O, proto);
393 else O.__proto__ = proto;
394 return O;
395 };
396}() : undefined);var ceil = Math.ceil;
397var floor = Math.floor;
398
399// `ToInteger` abstract operation
400// https://tc39.es/ecma262/#sec-tointeger
401var toInteger = function (argument) {
402 return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);
403};var min = Math.min;
404
405// `ToLength` abstract operation
406// https://tc39.es/ecma262/#sec-tolength
407var toLength = function (argument) {
408 return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
409};var max = Math.max;
410var min$1 = Math.min;
411
412// Helper for a popular repeating case of the spec:
413// Let integer be ? ToInteger(index).
414// If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
415var toAbsoluteIndex = function (index, length) {
416 var integer = toInteger(index);
417 return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
418};// `Array.prototype.{ indexOf, includes }` methods implementation
419var createMethod = function (IS_INCLUDES) {
420 return function ($this, el, fromIndex) {
421 var O = toIndexedObject($this);
422 var length = toLength(O.length);
423 var index = toAbsoluteIndex(fromIndex, length);
424 var value;
425 // Array#includes uses SameValueZero equality algorithm
426 // eslint-disable-next-line no-self-compare -- NaN check
427 if (IS_INCLUDES && el != el) while (length > index) {
428 value = O[index++];
429 // eslint-disable-next-line no-self-compare -- NaN check
430 if (value != value) return true;
431 // Array#indexOf ignores holes, Array#includes - not
432 } else for (;length > index; index++) {
433 if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
434 } return !IS_INCLUDES && -1;
435 };
436};
437
438var arrayIncludes = {
439 // `Array.prototype.includes` method
440 // https://tc39.es/ecma262/#sec-array.prototype.includes
441 includes: createMethod(true),
442 // `Array.prototype.indexOf` method
443 // https://tc39.es/ecma262/#sec-array.prototype.indexof
444 indexOf: createMethod(false)
445};var hiddenKeys = {};var indexOf = arrayIncludes.indexOf;
446
447
448var objectKeysInternal = function (object, names) {
449 var O = toIndexedObject(object);
450 var i = 0;
451 var result = [];
452 var key;
453 for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key);
454 // Don't enum bug & hidden keys
455 while (names.length > i) if (has(O, key = names[i++])) {
456 ~indexOf(result, key) || result.push(key);
457 }
458 return result;
459};// IE8- don't enum bug keys
460var enumBugKeys = [
461 'constructor',
462 'hasOwnProperty',
463 'isPrototypeOf',
464 'propertyIsEnumerable',
465 'toLocaleString',
466 'toString',
467 'valueOf'
468];// `Object.keys` method
469// https://tc39.es/ecma262/#sec-object.keys
470var objectKeys = Object.keys || function keys(O) {
471 return objectKeysInternal(O, enumBugKeys);
472};// `Object.defineProperties` method
473// https://tc39.es/ecma262/#sec-object.defineproperties
474var objectDefineProperties = descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
475 anObject(O);
476 var keys = objectKeys(Properties);
477 var length = keys.length;
478 var index = 0;
479 var key;
480 while (length > index) objectDefineProperty.f(O, key = keys[index++], Properties[key]);
481 return O;
482};var html = getBuiltIn('document', 'documentElement');var GT = '>';
483var LT = '<';
484var PROTOTYPE = 'prototype';
485var SCRIPT = 'script';
486var IE_PROTO$1 = sharedKey('IE_PROTO');
487
488var EmptyConstructor = function () { /* empty */ };
489
490var scriptTag = function (content) {
491 return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
492};
493
494// Create object with fake `null` prototype: use ActiveX Object with cleared prototype
495var NullProtoObjectViaActiveX = function (activeXDocument) {
496 activeXDocument.write(scriptTag(''));
497 activeXDocument.close();
498 var temp = activeXDocument.parentWindow.Object;
499 activeXDocument = null; // avoid memory leak
500 return temp;
501};
502
503// Create object with fake `null` prototype: use iframe Object with cleared prototype
504var NullProtoObjectViaIFrame = function () {
505 // Thrash, waste and sodomy: IE GC bug
506 var iframe = documentCreateElement('iframe');
507 var JS = 'java' + SCRIPT + ':';
508 var iframeDocument;
509 iframe.style.display = 'none';
510 html.appendChild(iframe);
511 // https://github.com/zloirock/core-js/issues/475
512 iframe.src = String(JS);
513 iframeDocument = iframe.contentWindow.document;
514 iframeDocument.open();
515 iframeDocument.write(scriptTag('document.F=Object'));
516 iframeDocument.close();
517 return iframeDocument.F;
518};
519
520// Check for document.domain and active x support
521// No need to use active x approach when document.domain is not set
522// see https://github.com/es-shims/es5-shim/issues/150
523// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
524// avoid IE GC bug
525var activeXDocument;
526var NullProtoObject = function () {
527 try {
528 /* global ActiveXObject -- old IE */
529 activeXDocument = document.domain && new ActiveXObject('htmlfile');
530 } catch (error) { /* ignore */ }
531 NullProtoObject = activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) : NullProtoObjectViaIFrame();
532 var length = enumBugKeys.length;
533 while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
534 return NullProtoObject();
535};
536
537hiddenKeys[IE_PROTO$1] = true;
538
539// `Object.create` method
540// https://tc39.es/ecma262/#sec-object.create
541var objectCreate = Object.create || function create(O, Properties) {
542 var result;
543 if (O !== null) {
544 EmptyConstructor[PROTOTYPE] = anObject(O);
545 result = new EmptyConstructor();
546 EmptyConstructor[PROTOTYPE] = null;
547 // add "__proto__" for Object.getPrototypeOf polyfill
548 result[IE_PROTO$1] = O;
549 } else result = NullProtoObject();
550 return Properties === undefined ? result : objectDefineProperties(result, Properties);
551};var engineIsNode = classofRaw(global$1.process) == 'process';var engineUserAgent = getBuiltIn('navigator', 'userAgent') || '';var process = global$1.process;
552var versions = process && process.versions;
553var v8 = versions && versions.v8;
554var match, version;
555
556if (v8) {
557 match = v8.split('.');
558 version = match[0] + match[1];
559} else if (engineUserAgent) {
560 match = engineUserAgent.match(/Edge\/(\d+)/);
561 if (!match || match[1] >= 74) {
562 match = engineUserAgent.match(/Chrome\/(\d+)/);
563 if (match) version = match[1];
564 }
565}
566
567var engineV8Version = version && +version;var nativeSymbol = !!Object.getOwnPropertySymbols && !fails(function () {
568 /* global Symbol -- required for testing */
569 return !Symbol.sham &&
570 // Chrome 38 Symbol has incorrect toString conversion
571 // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
572 (engineIsNode ? engineV8Version === 38 : engineV8Version > 37 && engineV8Version < 41);
573});var useSymbolAsUid = nativeSymbol
574 /* global Symbol -- safe */
575 && !Symbol.sham
576 && typeof Symbol.iterator == 'symbol';var WellKnownSymbolsStore = shared('wks');
577var Symbol$1 = global$1.Symbol;
578var createWellKnownSymbol = useSymbolAsUid ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid;
579
580var wellKnownSymbol = function (name) {
581 if (!has(WellKnownSymbolsStore, name) || !(nativeSymbol || typeof WellKnownSymbolsStore[name] == 'string')) {
582 if (nativeSymbol && has(Symbol$1, name)) {
583 WellKnownSymbolsStore[name] = Symbol$1[name];
584 } else {
585 WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name);
586 }
587 } return WellKnownSymbolsStore[name];
588};var iterators = {};var ITERATOR = wellKnownSymbol('iterator');
589var ArrayPrototype = Array.prototype;
590
591// check on default Array iterator
592var isArrayIteratorMethod = function (it) {
593 return it !== undefined && (iterators.Array === it || ArrayPrototype[ITERATOR] === it);
594};var TO_STRING_TAG = wellKnownSymbol('toStringTag');
595var test = {};
596
597test[TO_STRING_TAG] = 'z';
598
599var toStringTagSupport = String(test) === '[object z]';var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag');
600// ES3 wrong here
601var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
602
603// fallback for IE11 Script Access Denied error
604var tryGet = function (it, key) {
605 try {
606 return it[key];
607 } catch (error) { /* empty */ }
608};
609
610// getting tag from ES6+ `Object.prototype.toString`
611var classof = toStringTagSupport ? classofRaw : function (it) {
612 var O, tag, result;
613 return it === undefined ? 'Undefined' : it === null ? 'Null'
614 // @@toStringTag case
615 : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG$1)) == 'string' ? tag
616 // builtinTag case
617 : CORRECT_ARGUMENTS ? classofRaw(O)
618 // ES3 arguments fallback
619 : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;
620};var ITERATOR$1 = wellKnownSymbol('iterator');
621
622var getIteratorMethod = function (it) {
623 if (it != undefined) return it[ITERATOR$1]
624 || it['@@iterator']
625 || iterators[classof(it)];
626};var iteratorClose = function (iterator) {
627 var returnMethod = iterator['return'];
628 if (returnMethod !== undefined) {
629 return anObject(returnMethod.call(iterator)).value;
630 }
631};var Result = function (stopped, result) {
632 this.stopped = stopped;
633 this.result = result;
634};
635
636var iterate = function (iterable, unboundFunction, options) {
637 var that = options && options.that;
638 var AS_ENTRIES = !!(options && options.AS_ENTRIES);
639 var IS_ITERATOR = !!(options && options.IS_ITERATOR);
640 var INTERRUPTED = !!(options && options.INTERRUPTED);
641 var fn = functionBindContext(unboundFunction, that, 1 + AS_ENTRIES + INTERRUPTED);
642 var iterator, iterFn, index, length, result, next, step;
643
644 var stop = function (condition) {
645 if (iterator) iteratorClose(iterator);
646 return new Result(true, condition);
647 };
648
649 var callFn = function (value) {
650 if (AS_ENTRIES) {
651 anObject(value);
652 return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
653 } return INTERRUPTED ? fn(value, stop) : fn(value);
654 };
655
656 if (IS_ITERATOR) {
657 iterator = iterable;
658 } else {
659 iterFn = getIteratorMethod(iterable);
660 if (typeof iterFn != 'function') throw TypeError('Target is not iterable');
661 // optimisation for array iterators
662 if (isArrayIteratorMethod(iterFn)) {
663 for (index = 0, length = toLength(iterable.length); length > index; index++) {
664 result = callFn(iterable[index]);
665 if (result && result instanceof Result) return result;
666 } return new Result(false);
667 }
668 iterator = iterFn.call(iterable);
669 }
670
671 next = iterator.next;
672 while (!(step = next.call(iterator)).done) {
673 try {
674 result = callFn(step.value);
675 } catch (error) {
676 iteratorClose(iterator);
677 throw error;
678 }
679 if (typeof result == 'object' && result && result instanceof Result) return result;
680 } return new Result(false);
681};var $AggregateError = function AggregateError(errors, message) {
682 var that = this;
683 if (!(that instanceof $AggregateError)) return new $AggregateError(errors, message);
684 if (objectSetPrototypeOf) {
685 // eslint-disable-next-line unicorn/error-message -- expected
686 that = objectSetPrototypeOf(new Error(undefined), objectGetPrototypeOf(that));
687 }
688 if (message !== undefined) createNonEnumerableProperty(that, 'message', String(message));
689 var errorsArray = [];
690 iterate(errors, errorsArray.push, { that: errorsArray });
691 createNonEnumerableProperty(that, 'errors', errorsArray);
692 return that;
693};
694
695$AggregateError.prototype = objectCreate(Error.prototype, {
696 constructor: createPropertyDescriptor(5, $AggregateError),
697 message: createPropertyDescriptor(5, ''),
698 name: createPropertyDescriptor(5, 'AggregateError')
699});
700
701// `AggregateError` constructor
702// https://tc39.es/ecma262/#sec-aggregate-error-constructor
703_export({ global: true }, {
704 AggregateError: $AggregateError
705});var nativePromiseConstructor = global$1.Promise;var redefine = function (target, key, value, options) {
706 if (options && options.enumerable) target[key] = value;
707 else createNonEnumerableProperty(target, key, value);
708};var redefineAll = function (target, src, options) {
709 for (var key in src) {
710 if (options && options.unsafe && target[key]) target[key] = src[key];
711 else redefine(target, key, src[key], options);
712 } return target;
713};// `Object.prototype.toString` method implementation
714// https://tc39.es/ecma262/#sec-object.prototype.tostring
715var objectToString = toStringTagSupport ? {}.toString : function toString() {
716 return '[object ' + classof(this) + ']';
717};var defineProperty = objectDefineProperty.f;
718
719
720
721
722
723var TO_STRING_TAG$2 = wellKnownSymbol('toStringTag');
724
725var setToStringTag = function (it, TAG, STATIC, SET_METHOD) {
726 if (it) {
727 var target = STATIC ? it : it.prototype;
728 if (!has(target, TO_STRING_TAG$2)) {
729 defineProperty(target, TO_STRING_TAG$2, { configurable: true, value: TAG });
730 }
731 if (SET_METHOD && !toStringTagSupport) {
732 createNonEnumerableProperty(target, 'toString', objectToString);
733 }
734 }
735};var SPECIES = wellKnownSymbol('species');
736
737var setSpecies = function (CONSTRUCTOR_NAME) {
738 var Constructor = getBuiltIn(CONSTRUCTOR_NAME);
739 var defineProperty = objectDefineProperty.f;
740
741 if (descriptors && Constructor && !Constructor[SPECIES]) {
742 defineProperty(Constructor, SPECIES, {
743 configurable: true,
744 get: function () { return this; }
745 });
746 }
747};var anInstance = function (it, Constructor, name) {
748 if (!(it instanceof Constructor)) {
749 throw TypeError('Incorrect ' + (name ? name + ' ' : '') + 'invocation');
750 } return it;
751};var functionToString = Function.toString;
752
753// this helper broken in `3.4.1-3.4.4`, so we can't use `shared` helper
754if (typeof sharedStore.inspectSource != 'function') {
755 sharedStore.inspectSource = function (it) {
756 return functionToString.call(it);
757 };
758}
759
760var inspectSource = sharedStore.inspectSource;var ITERATOR$2 = wellKnownSymbol('iterator');
761var SAFE_CLOSING = false;
762
763try {
764 var called = 0;
765 var iteratorWithReturn = {
766 next: function () {
767 return { done: !!called++ };
768 },
769 'return': function () {
770 SAFE_CLOSING = true;
771 }
772 };
773 iteratorWithReturn[ITERATOR$2] = function () {
774 return this;
775 };
776 // eslint-disable-next-line no-throw-literal -- required for testing
777 Array.from(iteratorWithReturn, function () { throw 2; });
778} catch (error) { /* empty */ }
779
780var checkCorrectnessOfIteration = function (exec, SKIP_CLOSING) {
781 if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
782 var ITERATION_SUPPORT = false;
783 try {
784 var object = {};
785 object[ITERATOR$2] = function () {
786 return {
787 next: function () {
788 return { done: ITERATION_SUPPORT = true };
789 }
790 };
791 };
792 exec(object);
793 } catch (error) { /* empty */ }
794 return ITERATION_SUPPORT;
795};var SPECIES$1 = wellKnownSymbol('species');
796
797// `SpeciesConstructor` abstract operation
798// https://tc39.es/ecma262/#sec-speciesconstructor
799var speciesConstructor = function (O, defaultConstructor) {
800 var C = anObject(O).constructor;
801 var S;
802 return C === undefined || (S = anObject(C)[SPECIES$1]) == undefined ? defaultConstructor : aFunction(S);
803};var engineIsIos = /(iphone|ipod|ipad).*applewebkit/i.test(engineUserAgent);var location = global$1.location;
804var set = global$1.setImmediate;
805var clear = global$1.clearImmediate;
806var process$1 = global$1.process;
807var MessageChannel = global$1.MessageChannel;
808var Dispatch = global$1.Dispatch;
809var counter = 0;
810var queue = {};
811var ONREADYSTATECHANGE = 'onreadystatechange';
812var defer, channel, port;
813
814var run = function (id) {
815 // eslint-disable-next-line no-prototype-builtins -- safe
816 if (queue.hasOwnProperty(id)) {
817 var fn = queue[id];
818 delete queue[id];
819 fn();
820 }
821};
822
823var runner = function (id) {
824 return function () {
825 run(id);
826 };
827};
828
829var listener = function (event) {
830 run(event.data);
831};
832
833var post = function (id) {
834 // old engines have not location.origin
835 global$1.postMessage(id + '', location.protocol + '//' + location.host);
836};
837
838// Node.js 0.9+ & IE10+ has setImmediate, otherwise:
839if (!set || !clear) {
840 set = function setImmediate(fn) {
841 var args = [];
842 var i = 1;
843 while (arguments.length > i) args.push(arguments[i++]);
844 queue[++counter] = function () {
845 // eslint-disable-next-line no-new-func -- spec requirement
846 (typeof fn == 'function' ? fn : Function(fn)).apply(undefined, args);
847 };
848 defer(counter);
849 return counter;
850 };
851 clear = function clearImmediate(id) {
852 delete queue[id];
853 };
854 // Node.js 0.8-
855 if (engineIsNode) {
856 defer = function (id) {
857 process$1.nextTick(runner(id));
858 };
859 // Sphere (JS game engine) Dispatch API
860 } else if (Dispatch && Dispatch.now) {
861 defer = function (id) {
862 Dispatch.now(runner(id));
863 };
864 // Browsers with MessageChannel, includes WebWorkers
865 // except iOS - https://github.com/zloirock/core-js/issues/624
866 } else if (MessageChannel && !engineIsIos) {
867 channel = new MessageChannel();
868 port = channel.port2;
869 channel.port1.onmessage = listener;
870 defer = functionBindContext(port.postMessage, port, 1);
871 // Browsers with postMessage, skip WebWorkers
872 // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
873 } else if (
874 global$1.addEventListener &&
875 typeof postMessage == 'function' &&
876 !global$1.importScripts &&
877 location && location.protocol !== 'file:' &&
878 !fails(post)
879 ) {
880 defer = post;
881 global$1.addEventListener('message', listener, false);
882 // IE8-
883 } else if (ONREADYSTATECHANGE in documentCreateElement('script')) {
884 defer = function (id) {
885 html.appendChild(documentCreateElement('script'))[ONREADYSTATECHANGE] = function () {
886 html.removeChild(this);
887 run(id);
888 };
889 };
890 // Rest old browsers
891 } else {
892 defer = function (id) {
893 setTimeout(runner(id), 0);
894 };
895 }
896}
897
898var task = {
899 set: set,
900 clear: clear
901};var engineIsWebosWebkit = /web0s(?!.*chrome)/i.test(engineUserAgent);var getOwnPropertyDescriptor$2 = objectGetOwnPropertyDescriptor.f;
902var macrotask = task.set;
903
904
905
906
907var MutationObserver = global$1.MutationObserver || global$1.WebKitMutationObserver;
908var document$2 = global$1.document;
909var process$2 = global$1.process;
910var Promise = global$1.Promise;
911// Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`
912var queueMicrotaskDescriptor = getOwnPropertyDescriptor$2(global$1, 'queueMicrotask');
913var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
914
915var flush, head, last, notify, toggle, node, promise, then;
916
917// modern engines have queueMicrotask method
918if (!queueMicrotask) {
919 flush = function () {
920 var parent, fn;
921 if (engineIsNode && (parent = process$2.domain)) parent.exit();
922 while (head) {
923 fn = head.fn;
924 head = head.next;
925 try {
926 fn();
927 } catch (error) {
928 if (head) notify();
929 else last = undefined;
930 throw error;
931 }
932 } last = undefined;
933 if (parent) parent.enter();
934 };
935
936 // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339
937 // also except WebOS Webkit https://github.com/zloirock/core-js/issues/898
938 if (!engineIsIos && !engineIsNode && !engineIsWebosWebkit && MutationObserver && document$2) {
939 toggle = true;
940 node = document$2.createTextNode('');
941 new MutationObserver(flush).observe(node, { characterData: true });
942 notify = function () {
943 node.data = toggle = !toggle;
944 };
945 // environments with maybe non-completely correct, but existent Promise
946 } else if (Promise && Promise.resolve) {
947 // Promise.resolve without an argument throws an error in LG WebOS 2
948 promise = Promise.resolve(undefined);
949 then = promise.then;
950 notify = function () {
951 then.call(promise, flush);
952 };
953 // Node.js without promises
954 } else if (engineIsNode) {
955 notify = function () {
956 process$2.nextTick(flush);
957 };
958 // for other environments - macrotask based on:
959 // - setImmediate
960 // - MessageChannel
961 // - window.postMessag
962 // - onreadystatechange
963 // - setTimeout
964 } else {
965 notify = function () {
966 // strange IE + webpack dev server bug - use .call(global)
967 macrotask.call(global$1, flush);
968 };
969 }
970}
971
972var microtask = queueMicrotask || function (fn) {
973 var task = { fn: fn, next: undefined };
974 if (last) last.next = task;
975 if (!head) {
976 head = task;
977 notify();
978 } last = task;
979};var PromiseCapability = function (C) {
980 var resolve, reject;
981 this.promise = new C(function ($$resolve, $$reject) {
982 if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
983 resolve = $$resolve;
984 reject = $$reject;
985 });
986 this.resolve = aFunction(resolve);
987 this.reject = aFunction(reject);
988};
989
990// 25.4.1.5 NewPromiseCapability(C)
991var f$3 = function (C) {
992 return new PromiseCapability(C);
993};
994
995var newPromiseCapability = {
996 f: f$3
997};var promiseResolve = function (C, x) {
998 anObject(C);
999 if (isObject(x) && x.constructor === C) return x;
1000 var promiseCapability = newPromiseCapability.f(C);
1001 var resolve = promiseCapability.resolve;
1002 resolve(x);
1003 return promiseCapability.promise;
1004};var hostReportErrors = function (a, b) {
1005 var console = global$1.console;
1006 if (console && console.error) {
1007 arguments.length === 1 ? console.error(a) : console.error(a, b);
1008 }
1009};var perform = function (exec) {
1010 try {
1011 return { error: false, value: exec() };
1012 } catch (error) {
1013 return { error: true, value: error };
1014 }
1015};var WeakMap = global$1.WeakMap;
1016
1017var nativeWeakMap = typeof WeakMap === 'function' && /native code/.test(inspectSource(WeakMap));var WeakMap$1 = global$1.WeakMap;
1018var set$1, get, has$1;
1019
1020var enforce = function (it) {
1021 return has$1(it) ? get(it) : set$1(it, {});
1022};
1023
1024var getterFor = function (TYPE) {
1025 return function (it) {
1026 var state;
1027 if (!isObject(it) || (state = get(it)).type !== TYPE) {
1028 throw TypeError('Incompatible receiver, ' + TYPE + ' required');
1029 } return state;
1030 };
1031};
1032
1033if (nativeWeakMap) {
1034 var store$1 = sharedStore.state || (sharedStore.state = new WeakMap$1());
1035 var wmget = store$1.get;
1036 var wmhas = store$1.has;
1037 var wmset = store$1.set;
1038 set$1 = function (it, metadata) {
1039 metadata.facade = it;
1040 wmset.call(store$1, it, metadata);
1041 return metadata;
1042 };
1043 get = function (it) {
1044 return wmget.call(store$1, it) || {};
1045 };
1046 has$1 = function (it) {
1047 return wmhas.call(store$1, it);
1048 };
1049} else {
1050 var STATE = sharedKey('state');
1051 hiddenKeys[STATE] = true;
1052 set$1 = function (it, metadata) {
1053 metadata.facade = it;
1054 createNonEnumerableProperty(it, STATE, metadata);
1055 return metadata;
1056 };
1057 get = function (it) {
1058 return has(it, STATE) ? it[STATE] : {};
1059 };
1060 has$1 = function (it) {
1061 return has(it, STATE);
1062 };
1063}
1064
1065var internalState = {
1066 set: set$1,
1067 get: get,
1068 has: has$1,
1069 enforce: enforce,
1070 getterFor: getterFor
1071};var task$1 = task.set;
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083var SPECIES$2 = wellKnownSymbol('species');
1084var PROMISE = 'Promise';
1085var getInternalState = internalState.get;
1086var setInternalState = internalState.set;
1087var getInternalPromiseState = internalState.getterFor(PROMISE);
1088var PromiseConstructor = nativePromiseConstructor;
1089var TypeError$1 = global$1.TypeError;
1090var document$3 = global$1.document;
1091var process$3 = global$1.process;
1092var $fetch = getBuiltIn('fetch');
1093var newPromiseCapability$1 = newPromiseCapability.f;
1094var newGenericPromiseCapability = newPromiseCapability$1;
1095var DISPATCH_EVENT = !!(document$3 && document$3.createEvent && global$1.dispatchEvent);
1096var NATIVE_REJECTION_EVENT = typeof PromiseRejectionEvent == 'function';
1097var UNHANDLED_REJECTION = 'unhandledrejection';
1098var REJECTION_HANDLED = 'rejectionhandled';
1099var PENDING = 0;
1100var FULFILLED = 1;
1101var REJECTED = 2;
1102var HANDLED = 1;
1103var UNHANDLED = 2;
1104var Internal, OwnPromiseCapability, PromiseWrapper;
1105
1106var FORCED$1 = isForced_1(PROMISE, function () {
1107 var GLOBAL_CORE_JS_PROMISE = inspectSource(PromiseConstructor) !== String(PromiseConstructor);
1108 if (!GLOBAL_CORE_JS_PROMISE) {
1109 // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
1110 // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
1111 // We can't detect it synchronously, so just check versions
1112 if (engineV8Version === 66) return true;
1113 // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
1114 if (!engineIsNode && !NATIVE_REJECTION_EVENT) return true;
1115 }
1116 // We need Promise#finally in the pure version for preventing prototype pollution
1117 if ( !PromiseConstructor.prototype['finally']) return true;
1118 // We can't use @@species feature detection in V8 since it causes
1119 // deoptimization and performance degradation
1120 // https://github.com/zloirock/core-js/issues/679
1121 if (engineV8Version >= 51 && /native code/.test(PromiseConstructor)) return false;
1122 // Detect correctness of subclassing with @@species support
1123 var promise = PromiseConstructor.resolve(1);
1124 var FakePromise = function (exec) {
1125 exec(function () { /* empty */ }, function () { /* empty */ });
1126 };
1127 var constructor = promise.constructor = {};
1128 constructor[SPECIES$2] = FakePromise;
1129 return !(promise.then(function () { /* empty */ }) instanceof FakePromise);
1130});
1131
1132var INCORRECT_ITERATION = FORCED$1 || !checkCorrectnessOfIteration(function (iterable) {
1133 PromiseConstructor.all(iterable)['catch'](function () { /* empty */ });
1134});
1135
1136// helpers
1137var isThenable = function (it) {
1138 var then;
1139 return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
1140};
1141
1142var notify$1 = function (state, isReject) {
1143 if (state.notified) return;
1144 state.notified = true;
1145 var chain = state.reactions;
1146 microtask(function () {
1147 var value = state.value;
1148 var ok = state.state == FULFILLED;
1149 var index = 0;
1150 // variable length - can't use forEach
1151 while (chain.length > index) {
1152 var reaction = chain[index++];
1153 var handler = ok ? reaction.ok : reaction.fail;
1154 var resolve = reaction.resolve;
1155 var reject = reaction.reject;
1156 var domain = reaction.domain;
1157 var result, then, exited;
1158 try {
1159 if (handler) {
1160 if (!ok) {
1161 if (state.rejection === UNHANDLED) onHandleUnhandled(state);
1162 state.rejection = HANDLED;
1163 }
1164 if (handler === true) result = value;
1165 else {
1166 if (domain) domain.enter();
1167 result = handler(value); // can throw
1168 if (domain) {
1169 domain.exit();
1170 exited = true;
1171 }
1172 }
1173 if (result === reaction.promise) {
1174 reject(TypeError$1('Promise-chain cycle'));
1175 } else if (then = isThenable(result)) {
1176 then.call(result, resolve, reject);
1177 } else resolve(result);
1178 } else reject(value);
1179 } catch (error) {
1180 if (domain && !exited) domain.exit();
1181 reject(error);
1182 }
1183 }
1184 state.reactions = [];
1185 state.notified = false;
1186 if (isReject && !state.rejection) onUnhandled(state);
1187 });
1188};
1189
1190var dispatchEvent = function (name, promise, reason) {
1191 var event, handler;
1192 if (DISPATCH_EVENT) {
1193 event = document$3.createEvent('Event');
1194 event.promise = promise;
1195 event.reason = reason;
1196 event.initEvent(name, false, true);
1197 global$1.dispatchEvent(event);
1198 } else event = { promise: promise, reason: reason };
1199 if (!NATIVE_REJECTION_EVENT && (handler = global$1['on' + name])) handler(event);
1200 else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason);
1201};
1202
1203var onUnhandled = function (state) {
1204 task$1.call(global$1, function () {
1205 var promise = state.facade;
1206 var value = state.value;
1207 var IS_UNHANDLED = isUnhandled(state);
1208 var result;
1209 if (IS_UNHANDLED) {
1210 result = perform(function () {
1211 if (engineIsNode) {
1212 process$3.emit('unhandledRejection', value, promise);
1213 } else dispatchEvent(UNHANDLED_REJECTION, promise, value);
1214 });
1215 // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
1216 state.rejection = engineIsNode || isUnhandled(state) ? UNHANDLED : HANDLED;
1217 if (result.error) throw result.value;
1218 }
1219 });
1220};
1221
1222var isUnhandled = function (state) {
1223 return state.rejection !== HANDLED && !state.parent;
1224};
1225
1226var onHandleUnhandled = function (state) {
1227 task$1.call(global$1, function () {
1228 var promise = state.facade;
1229 if (engineIsNode) {
1230 process$3.emit('rejectionHandled', promise);
1231 } else dispatchEvent(REJECTION_HANDLED, promise, state.value);
1232 });
1233};
1234
1235var bind = function (fn, state, unwrap) {
1236 return function (value) {
1237 fn(state, value, unwrap);
1238 };
1239};
1240
1241var internalReject = function (state, value, unwrap) {
1242 if (state.done) return;
1243 state.done = true;
1244 if (unwrap) state = unwrap;
1245 state.value = value;
1246 state.state = REJECTED;
1247 notify$1(state, true);
1248};
1249
1250var internalResolve = function (state, value, unwrap) {
1251 if (state.done) return;
1252 state.done = true;
1253 if (unwrap) state = unwrap;
1254 try {
1255 if (state.facade === value) throw TypeError$1("Promise can't be resolved itself");
1256 var then = isThenable(value);
1257 if (then) {
1258 microtask(function () {
1259 var wrapper = { done: false };
1260 try {
1261 then.call(value,
1262 bind(internalResolve, wrapper, state),
1263 bind(internalReject, wrapper, state)
1264 );
1265 } catch (error) {
1266 internalReject(wrapper, error, state);
1267 }
1268 });
1269 } else {
1270 state.value = value;
1271 state.state = FULFILLED;
1272 notify$1(state, false);
1273 }
1274 } catch (error) {
1275 internalReject({ done: false }, error, state);
1276 }
1277};
1278
1279// constructor polyfill
1280if (FORCED$1) {
1281 // 25.4.3.1 Promise(executor)
1282 PromiseConstructor = function Promise(executor) {
1283 anInstance(this, PromiseConstructor, PROMISE);
1284 aFunction(executor);
1285 Internal.call(this);
1286 var state = getInternalState(this);
1287 try {
1288 executor(bind(internalResolve, state), bind(internalReject, state));
1289 } catch (error) {
1290 internalReject(state, error);
1291 }
1292 };
1293 // eslint-disable-next-line no-unused-vars -- required for `.length`
1294 Internal = function Promise(executor) {
1295 setInternalState(this, {
1296 type: PROMISE,
1297 done: false,
1298 notified: false,
1299 parent: false,
1300 reactions: [],
1301 rejection: false,
1302 state: PENDING,
1303 value: undefined
1304 });
1305 };
1306 Internal.prototype = redefineAll(PromiseConstructor.prototype, {
1307 // `Promise.prototype.then` method
1308 // https://tc39.es/ecma262/#sec-promise.prototype.then
1309 then: function then(onFulfilled, onRejected) {
1310 var state = getInternalPromiseState(this);
1311 var reaction = newPromiseCapability$1(speciesConstructor(this, PromiseConstructor));
1312 reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
1313 reaction.fail = typeof onRejected == 'function' && onRejected;
1314 reaction.domain = engineIsNode ? process$3.domain : undefined;
1315 state.parent = true;
1316 state.reactions.push(reaction);
1317 if (state.state != PENDING) notify$1(state, false);
1318 return reaction.promise;
1319 },
1320 // `Promise.prototype.catch` method
1321 // https://tc39.es/ecma262/#sec-promise.prototype.catch
1322 'catch': function (onRejected) {
1323 return this.then(undefined, onRejected);
1324 }
1325 });
1326 OwnPromiseCapability = function () {
1327 var promise = new Internal();
1328 var state = getInternalState(promise);
1329 this.promise = promise;
1330 this.resolve = bind(internalResolve, state);
1331 this.reject = bind(internalReject, state);
1332 };
1333 newPromiseCapability.f = newPromiseCapability$1 = function (C) {
1334 return C === PromiseConstructor || C === PromiseWrapper
1335 ? new OwnPromiseCapability(C)
1336 : newGenericPromiseCapability(C);
1337 };
1338}
1339
1340_export({ global: true, wrap: true, forced: FORCED$1 }, {
1341 Promise: PromiseConstructor
1342});
1343
1344setToStringTag(PromiseConstructor, PROMISE, false, true);
1345setSpecies(PROMISE);
1346
1347PromiseWrapper = getBuiltIn(PROMISE);
1348
1349// statics
1350_export({ target: PROMISE, stat: true, forced: FORCED$1 }, {
1351 // `Promise.reject` method
1352 // https://tc39.es/ecma262/#sec-promise.reject
1353 reject: function reject(r) {
1354 var capability = newPromiseCapability$1(this);
1355 capability.reject.call(undefined, r);
1356 return capability.promise;
1357 }
1358});
1359
1360_export({ target: PROMISE, stat: true, forced: isPure }, {
1361 // `Promise.resolve` method
1362 // https://tc39.es/ecma262/#sec-promise.resolve
1363 resolve: function resolve(x) {
1364 return promiseResolve( this === PromiseWrapper ? PromiseConstructor : this, x);
1365 }
1366});
1367
1368_export({ target: PROMISE, stat: true, forced: INCORRECT_ITERATION }, {
1369 // `Promise.all` method
1370 // https://tc39.es/ecma262/#sec-promise.all
1371 all: function all(iterable) {
1372 var C = this;
1373 var capability = newPromiseCapability$1(C);
1374 var resolve = capability.resolve;
1375 var reject = capability.reject;
1376 var result = perform(function () {
1377 var $promiseResolve = aFunction(C.resolve);
1378 var values = [];
1379 var counter = 0;
1380 var remaining = 1;
1381 iterate(iterable, function (promise) {
1382 var index = counter++;
1383 var alreadyCalled = false;
1384 values.push(undefined);
1385 remaining++;
1386 $promiseResolve.call(C, promise).then(function (value) {
1387 if (alreadyCalled) return;
1388 alreadyCalled = true;
1389 values[index] = value;
1390 --remaining || resolve(values);
1391 }, reject);
1392 });
1393 --remaining || resolve(values);
1394 });
1395 if (result.error) reject(result.value);
1396 return capability.promise;
1397 },
1398 // `Promise.race` method
1399 // https://tc39.es/ecma262/#sec-promise.race
1400 race: function race(iterable) {
1401 var C = this;
1402 var capability = newPromiseCapability$1(C);
1403 var reject = capability.reject;
1404 var result = perform(function () {
1405 var $promiseResolve = aFunction(C.resolve);
1406 iterate(iterable, function (promise) {
1407 $promiseResolve.call(C, promise).then(capability.resolve, reject);
1408 });
1409 });
1410 if (result.error) reject(result.value);
1411 return capability.promise;
1412 }
1413});// `Promise.allSettled` method
1414// https://tc39.es/ecma262/#sec-promise.allsettled
1415_export({ target: 'Promise', stat: true }, {
1416 allSettled: function allSettled(iterable) {
1417 var C = this;
1418 var capability = newPromiseCapability.f(C);
1419 var resolve = capability.resolve;
1420 var reject = capability.reject;
1421 var result = perform(function () {
1422 var promiseResolve = aFunction(C.resolve);
1423 var values = [];
1424 var counter = 0;
1425 var remaining = 1;
1426 iterate(iterable, function (promise) {
1427 var index = counter++;
1428 var alreadyCalled = false;
1429 values.push(undefined);
1430 remaining++;
1431 promiseResolve.call(C, promise).then(function (value) {
1432 if (alreadyCalled) return;
1433 alreadyCalled = true;
1434 values[index] = { status: 'fulfilled', value: value };
1435 --remaining || resolve(values);
1436 }, function (error) {
1437 if (alreadyCalled) return;
1438 alreadyCalled = true;
1439 values[index] = { status: 'rejected', reason: error };
1440 --remaining || resolve(values);
1441 });
1442 });
1443 --remaining || resolve(values);
1444 });
1445 if (result.error) reject(result.value);
1446 return capability.promise;
1447 }
1448});var PROMISE_ANY_ERROR = 'No one promise resolved';
1449
1450// `Promise.any` method
1451// https://tc39.es/ecma262/#sec-promise.any
1452_export({ target: 'Promise', stat: true }, {
1453 any: function any(iterable) {
1454 var C = this;
1455 var capability = newPromiseCapability.f(C);
1456 var resolve = capability.resolve;
1457 var reject = capability.reject;
1458 var result = perform(function () {
1459 var promiseResolve = aFunction(C.resolve);
1460 var errors = [];
1461 var counter = 0;
1462 var remaining = 1;
1463 var alreadyResolved = false;
1464 iterate(iterable, function (promise) {
1465 var index = counter++;
1466 var alreadyRejected = false;
1467 errors.push(undefined);
1468 remaining++;
1469 promiseResolve.call(C, promise).then(function (value) {
1470 if (alreadyRejected || alreadyResolved) return;
1471 alreadyResolved = true;
1472 resolve(value);
1473 }, function (error) {
1474 if (alreadyRejected || alreadyResolved) return;
1475 alreadyRejected = true;
1476 errors[index] = error;
1477 --remaining || reject(new (getBuiltIn('AggregateError'))(errors, PROMISE_ANY_ERROR));
1478 });
1479 });
1480 --remaining || reject(new (getBuiltIn('AggregateError'))(errors, PROMISE_ANY_ERROR));
1481 });
1482 if (result.error) reject(result.value);
1483 return capability.promise;
1484 }
1485});// Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829
1486var NON_GENERIC = !!nativePromiseConstructor && fails(function () {
1487 nativePromiseConstructor.prototype['finally'].call({ then: function () { /* empty */ } }, function () { /* empty */ });
1488});
1489
1490// `Promise.prototype.finally` method
1491// https://tc39.es/ecma262/#sec-promise.prototype.finally
1492_export({ target: 'Promise', proto: true, real: true, forced: NON_GENERIC }, {
1493 'finally': function (onFinally) {
1494 var C = speciesConstructor(this, getBuiltIn('Promise'));
1495 var isFunction = typeof onFinally == 'function';
1496 return this.then(
1497 isFunction ? function (x) {
1498 return promiseResolve(C, onFinally()).then(function () { return x; });
1499 } : onFinally,
1500 isFunction ? function (e) {
1501 return promiseResolve(C, onFinally()).then(function () { throw e; });
1502 } : onFinally
1503 );
1504 }
1505});// `String.prototype.{ codePointAt, at }` methods implementation
1506var createMethod$1 = function (CONVERT_TO_STRING) {
1507 return function ($this, pos) {
1508 var S = String(requireObjectCoercible($this));
1509 var position = toInteger(pos);
1510 var size = S.length;
1511 var first, second;
1512 if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
1513 first = S.charCodeAt(position);
1514 return first < 0xD800 || first > 0xDBFF || position + 1 === size
1515 || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF
1516 ? CONVERT_TO_STRING ? S.charAt(position) : first
1517 : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
1518 };
1519};
1520
1521var stringMultibyte = {
1522 // `String.prototype.codePointAt` method
1523 // https://tc39.es/ecma262/#sec-string.prototype.codepointat
1524 codeAt: createMethod$1(false),
1525 // `String.prototype.at` method
1526 // https://github.com/mathiasbynens/String.prototype.at
1527 charAt: createMethod$1(true)
1528};var ITERATOR$3 = wellKnownSymbol('iterator');
1529var BUGGY_SAFARI_ITERATORS = false;
1530
1531var returnThis = function () { return this; };
1532
1533// `%IteratorPrototype%` object
1534// https://tc39.es/ecma262/#sec-%iteratorprototype%-object
1535var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
1536
1537if ([].keys) {
1538 arrayIterator = [].keys();
1539 // Safari 8 has buggy iterators w/o `next`
1540 if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;
1541 else {
1542 PrototypeOfArrayIteratorPrototype = objectGetPrototypeOf(objectGetPrototypeOf(arrayIterator));
1543 if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;
1544 }
1545}
1546
1547var NEW_ITERATOR_PROTOTYPE = IteratorPrototype == undefined || fails(function () {
1548 var test = {};
1549 // FF44- legacy iterators case
1550 return IteratorPrototype[ITERATOR$3].call(test) !== test;
1551});
1552
1553if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {};
1554
1555// 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
1556if (( NEW_ITERATOR_PROTOTYPE) && !has(IteratorPrototype, ITERATOR$3)) {
1557 createNonEnumerableProperty(IteratorPrototype, ITERATOR$3, returnThis);
1558}
1559
1560var iteratorsCore = {
1561 IteratorPrototype: IteratorPrototype,
1562 BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
1563};var IteratorPrototype$1 = iteratorsCore.IteratorPrototype;
1564
1565
1566
1567
1568
1569var returnThis$1 = function () { return this; };
1570
1571var createIteratorConstructor = function (IteratorConstructor, NAME, next) {
1572 var TO_STRING_TAG = NAME + ' Iterator';
1573 IteratorConstructor.prototype = objectCreate(IteratorPrototype$1, { next: createPropertyDescriptor(1, next) });
1574 setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true);
1575 iterators[TO_STRING_TAG] = returnThis$1;
1576 return IteratorConstructor;
1577};var IteratorPrototype$2 = iteratorsCore.IteratorPrototype;
1578var BUGGY_SAFARI_ITERATORS$1 = iteratorsCore.BUGGY_SAFARI_ITERATORS;
1579var ITERATOR$4 = wellKnownSymbol('iterator');
1580var KEYS = 'keys';
1581var VALUES = 'values';
1582var ENTRIES = 'entries';
1583
1584var returnThis$2 = function () { return this; };
1585
1586var defineIterator = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
1587 createIteratorConstructor(IteratorConstructor, NAME, next);
1588
1589 var getIterationMethod = function (KIND) {
1590 if (KIND === DEFAULT && defaultIterator) return defaultIterator;
1591 if (!BUGGY_SAFARI_ITERATORS$1 && KIND in IterablePrototype) return IterablePrototype[KIND];
1592 switch (KIND) {
1593 case KEYS: return function keys() { return new IteratorConstructor(this, KIND); };
1594 case VALUES: return function values() { return new IteratorConstructor(this, KIND); };
1595 case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); };
1596 } return function () { return new IteratorConstructor(this); };
1597 };
1598
1599 var TO_STRING_TAG = NAME + ' Iterator';
1600 var INCORRECT_VALUES_NAME = false;
1601 var IterablePrototype = Iterable.prototype;
1602 var nativeIterator = IterablePrototype[ITERATOR$4]
1603 || IterablePrototype['@@iterator']
1604 || DEFAULT && IterablePrototype[DEFAULT];
1605 var defaultIterator = !BUGGY_SAFARI_ITERATORS$1 && nativeIterator || getIterationMethod(DEFAULT);
1606 var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
1607 var CurrentIteratorPrototype, methods, KEY;
1608
1609 // fix native
1610 if (anyNativeIterator) {
1611 CurrentIteratorPrototype = objectGetPrototypeOf(anyNativeIterator.call(new Iterable()));
1612 if (IteratorPrototype$2 !== Object.prototype && CurrentIteratorPrototype.next) {
1613 // Set @@toStringTag to native iterators
1614 setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true);
1615 iterators[TO_STRING_TAG] = returnThis$2;
1616 }
1617 }
1618
1619 // fix Array#{values, @@iterator}.name in V8 / FF
1620 if (DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
1621 INCORRECT_VALUES_NAME = true;
1622 defaultIterator = function values() { return nativeIterator.call(this); };
1623 }
1624
1625 // define iterator
1626 if (( FORCED) && IterablePrototype[ITERATOR$4] !== defaultIterator) {
1627 createNonEnumerableProperty(IterablePrototype, ITERATOR$4, defaultIterator);
1628 }
1629 iterators[NAME] = defaultIterator;
1630
1631 // export additional methods
1632 if (DEFAULT) {
1633 methods = {
1634 values: getIterationMethod(VALUES),
1635 keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
1636 entries: getIterationMethod(ENTRIES)
1637 };
1638 if (FORCED) for (KEY in methods) {
1639 if (BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
1640 redefine(IterablePrototype, KEY, methods[KEY]);
1641 }
1642 } else _export({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME }, methods);
1643 }
1644
1645 return methods;
1646};var charAt = stringMultibyte.charAt;
1647
1648
1649
1650var STRING_ITERATOR = 'String Iterator';
1651var setInternalState$1 = internalState.set;
1652var getInternalState$1 = internalState.getterFor(STRING_ITERATOR);
1653
1654// `String.prototype[@@iterator]` method
1655// https://tc39.es/ecma262/#sec-string.prototype-@@iterator
1656defineIterator(String, 'String', function (iterated) {
1657 setInternalState$1(this, {
1658 type: STRING_ITERATOR,
1659 string: String(iterated),
1660 index: 0
1661 });
1662// `%StringIteratorPrototype%.next` method
1663// https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next
1664}, function next() {
1665 var state = getInternalState$1(this);
1666 var string = state.string;
1667 var index = state.index;
1668 var point;
1669 if (index >= string.length) return { value: undefined, done: true };
1670 point = charAt(string, index);
1671 state.index += point.length;
1672 return { value: point, done: false };
1673});var ARRAY_ITERATOR = 'Array Iterator';
1674var setInternalState$2 = internalState.set;
1675var getInternalState$2 = internalState.getterFor(ARRAY_ITERATOR);
1676
1677// `Array.prototype.entries` method
1678// https://tc39.es/ecma262/#sec-array.prototype.entries
1679// `Array.prototype.keys` method
1680// https://tc39.es/ecma262/#sec-array.prototype.keys
1681// `Array.prototype.values` method
1682// https://tc39.es/ecma262/#sec-array.prototype.values
1683// `Array.prototype[@@iterator]` method
1684// https://tc39.es/ecma262/#sec-array.prototype-@@iterator
1685// `CreateArrayIterator` internal method
1686// https://tc39.es/ecma262/#sec-createarrayiterator
1687var es_array_iterator = defineIterator(Array, 'Array', function (iterated, kind) {
1688 setInternalState$2(this, {
1689 type: ARRAY_ITERATOR,
1690 target: toIndexedObject(iterated), // target
1691 index: 0, // next index
1692 kind: kind // kind
1693 });
1694// `%ArrayIteratorPrototype%.next` method
1695// https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next
1696}, function () {
1697 var state = getInternalState$2(this);
1698 var target = state.target;
1699 var kind = state.kind;
1700 var index = state.index++;
1701 if (!target || index >= target.length) {
1702 state.target = undefined;
1703 return { value: undefined, done: true };
1704 }
1705 if (kind == 'keys') return { value: index, done: false };
1706 if (kind == 'values') return { value: target[index], done: false };
1707 return { value: [index, target[index]], done: false };
1708}, 'values');
1709
1710// argumentsList[@@iterator] is %ArrayProto_values%
1711// https://tc39.es/ecma262/#sec-createunmappedargumentsobject
1712// https://tc39.es/ecma262/#sec-createmappedargumentsobject
1713iterators.Arguments = iterators.Array;// iterable DOM collections
1714// flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
1715var domIterables = {
1716 CSSRuleList: 0,
1717 CSSStyleDeclaration: 0,
1718 CSSValueList: 0,
1719 ClientRectList: 0,
1720 DOMRectList: 0,
1721 DOMStringList: 0,
1722 DOMTokenList: 1,
1723 DataTransferItemList: 0,
1724 FileList: 0,
1725 HTMLAllCollection: 0,
1726 HTMLCollection: 0,
1727 HTMLFormElement: 0,
1728 HTMLSelectElement: 0,
1729 MediaList: 0,
1730 MimeTypeArray: 0,
1731 NamedNodeMap: 0,
1732 NodeList: 1,
1733 PaintRequestList: 0,
1734 Plugin: 0,
1735 PluginArray: 0,
1736 SVGLengthList: 0,
1737 SVGNumberList: 0,
1738 SVGPathSegList: 0,
1739 SVGPointList: 0,
1740 SVGStringList: 0,
1741 SVGTransformList: 0,
1742 SourceBufferList: 0,
1743 StyleSheetList: 0,
1744 TextTrackCueList: 0,
1745 TextTrackList: 0,
1746 TouchList: 0
1747};var TO_STRING_TAG$3 = wellKnownSymbol('toStringTag');
1748
1749for (var COLLECTION_NAME in domIterables) {
1750 var Collection = global$1[COLLECTION_NAME];
1751 var CollectionPrototype = Collection && Collection.prototype;
1752 if (CollectionPrototype && classof(CollectionPrototype) !== TO_STRING_TAG$3) {
1753 createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG$3, COLLECTION_NAME);
1754 }
1755 iterators[COLLECTION_NAME] = iterators.Array;
1756}var promise$1 = path.Promise;var promise$2 = promise$1;var promise$3 = promise$2;var FAILS_ON_PRIMITIVES = fails(function () { objectKeys(1); });
1757
1758// `Object.keys` method
1759// https://tc39.es/ecma262/#sec-object.keys
1760_export({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {
1761 keys: function keys(it) {
1762 return objectKeys(toObject(it));
1763 }
1764});var keys$1 = path.Object.keys;var keys$2 = keys$1;var keys$3 = keys$2;// `IsArray` abstract operation
1765// https://tc39.es/ecma262/#sec-isarray
1766var isArray = Array.isArray || function isArray(arg) {
1767 return classofRaw(arg) == 'Array';
1768};var SPECIES$3 = wellKnownSymbol('species');
1769
1770// `ArraySpeciesCreate` abstract operation
1771// https://tc39.es/ecma262/#sec-arrayspeciescreate
1772var arraySpeciesCreate = function (originalArray, length) {
1773 var C;
1774 if (isArray(originalArray)) {
1775 C = originalArray.constructor;
1776 // cross-realm fallback
1777 if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
1778 else if (isObject(C)) {
1779 C = C[SPECIES$3];
1780 if (C === null) C = undefined;
1781 }
1782 } return new (C === undefined ? Array : C)(length === 0 ? 0 : length);
1783};var push = [].push;
1784
1785// `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterOut }` methods implementation
1786var createMethod$2 = function (TYPE) {
1787 var IS_MAP = TYPE == 1;
1788 var IS_FILTER = TYPE == 2;
1789 var IS_SOME = TYPE == 3;
1790 var IS_EVERY = TYPE == 4;
1791 var IS_FIND_INDEX = TYPE == 6;
1792 var IS_FILTER_OUT = TYPE == 7;
1793 var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
1794 return function ($this, callbackfn, that, specificCreate) {
1795 var O = toObject($this);
1796 var self = indexedObject(O);
1797 var boundFunction = functionBindContext(callbackfn, that, 3);
1798 var length = toLength(self.length);
1799 var index = 0;
1800 var create = specificCreate || arraySpeciesCreate;
1801 var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_OUT ? create($this, 0) : undefined;
1802 var value, result;
1803 for (;length > index; index++) if (NO_HOLES || index in self) {
1804 value = self[index];
1805 result = boundFunction(value, index, O);
1806 if (TYPE) {
1807 if (IS_MAP) target[index] = result; // map
1808 else if (result) switch (TYPE) {
1809 case 3: return true; // some
1810 case 5: return value; // find
1811 case 6: return index; // findIndex
1812 case 2: push.call(target, value); // filter
1813 } else switch (TYPE) {
1814 case 4: return false; // every
1815 case 7: push.call(target, value); // filterOut
1816 }
1817 }
1818 }
1819 return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
1820 };
1821};
1822
1823var arrayIteration = {
1824 // `Array.prototype.forEach` method
1825 // https://tc39.es/ecma262/#sec-array.prototype.foreach
1826 forEach: createMethod$2(0),
1827 // `Array.prototype.map` method
1828 // https://tc39.es/ecma262/#sec-array.prototype.map
1829 map: createMethod$2(1),
1830 // `Array.prototype.filter` method
1831 // https://tc39.es/ecma262/#sec-array.prototype.filter
1832 filter: createMethod$2(2),
1833 // `Array.prototype.some` method
1834 // https://tc39.es/ecma262/#sec-array.prototype.some
1835 some: createMethod$2(3),
1836 // `Array.prototype.every` method
1837 // https://tc39.es/ecma262/#sec-array.prototype.every
1838 every: createMethod$2(4),
1839 // `Array.prototype.find` method
1840 // https://tc39.es/ecma262/#sec-array.prototype.find
1841 find: createMethod$2(5),
1842 // `Array.prototype.findIndex` method
1843 // https://tc39.es/ecma262/#sec-array.prototype.findIndex
1844 findIndex: createMethod$2(6),
1845 // `Array.prototype.filterOut` method
1846 // https://github.com/tc39/proposal-array-filtering
1847 filterOut: createMethod$2(7)
1848};var arrayMethodIsStrict = function (METHOD_NAME, argument) {
1849 var method = [][METHOD_NAME];
1850 return !!method && fails(function () {
1851 // eslint-disable-next-line no-useless-call,no-throw-literal -- required for testing
1852 method.call(null, argument || function () { throw 1; }, 1);
1853 });
1854};var $forEach = arrayIteration.forEach;
1855
1856
1857var STRICT_METHOD = arrayMethodIsStrict('forEach');
1858
1859// `Array.prototype.forEach` method implementation
1860// https://tc39.es/ecma262/#sec-array.prototype.foreach
1861var arrayForEach = !STRICT_METHOD ? function forEach(callbackfn /* , thisArg */) {
1862 return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
1863} : [].forEach;// `Array.prototype.forEach` method
1864// https://tc39.es/ecma262/#sec-array.prototype.foreach
1865_export({ target: 'Array', proto: true, forced: [].forEach != arrayForEach }, {
1866 forEach: arrayForEach
1867});var entryVirtual = function (CONSTRUCTOR) {
1868 return path[CONSTRUCTOR + 'Prototype'];
1869};var forEach = entryVirtual('Array').forEach;var forEach$1 = forEach;var ArrayPrototype$1 = Array.prototype;
1870
1871var DOMIterables = {
1872 DOMTokenList: true,
1873 NodeList: true
1874};
1875
1876var forEach_1 = function (it) {
1877 var own = it.forEach;
1878 return it === ArrayPrototype$1 || (it instanceof Array && own === ArrayPrototype$1.forEach)
1879 // eslint-disable-next-line no-prototype-builtins -- safe
1880 || DOMIterables.hasOwnProperty(classof(it)) ? forEach$1 : own;
1881};var forEach$2 = forEach_1;var f$4 = Object.getOwnPropertySymbols;
1882
1883var objectGetOwnPropertySymbols = {
1884 f: f$4
1885};var nativeAssign = Object.assign;
1886var defineProperty$1 = Object.defineProperty;
1887
1888// `Object.assign` method
1889// https://tc39.es/ecma262/#sec-object.assign
1890var objectAssign = !nativeAssign || fails(function () {
1891 // should have correct order of operations (Edge bug)
1892 if (descriptors && nativeAssign({ b: 1 }, nativeAssign(defineProperty$1({}, 'a', {
1893 enumerable: true,
1894 get: function () {
1895 defineProperty$1(this, 'b', {
1896 value: 3,
1897 enumerable: false
1898 });
1899 }
1900 }), { b: 2 })).b !== 1) return true;
1901 // should work with symbols and should have deterministic property order (V8 bug)
1902 var A = {};
1903 var B = {};
1904 /* global Symbol -- required for testing */
1905 var symbol = Symbol();
1906 var alphabet = 'abcdefghijklmnopqrst';
1907 A[symbol] = 7;
1908 alphabet.split('').forEach(function (chr) { B[chr] = chr; });
1909 return nativeAssign({}, A)[symbol] != 7 || objectKeys(nativeAssign({}, B)).join('') != alphabet;
1910}) ? function assign(target, source) { // eslint-disable-line no-unused-vars -- required for `.length`
1911 var T = toObject(target);
1912 var argumentsLength = arguments.length;
1913 var index = 1;
1914 var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
1915 var propertyIsEnumerable = objectPropertyIsEnumerable.f;
1916 while (argumentsLength > index) {
1917 var S = indexedObject(arguments[index++]);
1918 var keys = getOwnPropertySymbols ? objectKeys(S).concat(getOwnPropertySymbols(S)) : objectKeys(S);
1919 var length = keys.length;
1920 var j = 0;
1921 var key;
1922 while (length > j) {
1923 key = keys[j++];
1924 if (!descriptors || propertyIsEnumerable.call(S, key)) T[key] = S[key];
1925 }
1926 } return T;
1927} : nativeAssign;// `Object.assign` method
1928// https://tc39.es/ecma262/#sec-object.assign
1929_export({ target: 'Object', stat: true, forced: Object.assign !== objectAssign }, {
1930 assign: objectAssign
1931});var assign = path.Object.assign;var assign$1 = assign;var assign$2 = assign$1;var slice = [].slice;
1932var factories = {};
1933
1934var construct = function (C, argsLength, args) {
1935 if (!(argsLength in factories)) {
1936 for (var list = [], i = 0; i < argsLength; i++) list[i] = 'a[' + i + ']';
1937 // eslint-disable-next-line no-new-func -- we have no proper alternatives, IE8- only
1938 factories[argsLength] = Function('C,a', 'return new C(' + list.join(',') + ')');
1939 } return factories[argsLength](C, args);
1940};
1941
1942// `Function.prototype.bind` method implementation
1943// https://tc39.es/ecma262/#sec-function.prototype.bind
1944var functionBind = Function.bind || function bind(that /* , ...args */) {
1945 var fn = aFunction(this);
1946 var partArgs = slice.call(arguments, 1);
1947 var boundFunction = function bound(/* args... */) {
1948 var args = partArgs.concat(slice.call(arguments));
1949 return this instanceof boundFunction ? construct(fn, args.length, args) : fn.apply(that, args);
1950 };
1951 if (isObject(fn.prototype)) boundFunction.prototype = fn.prototype;
1952 return boundFunction;
1953};// `Function.prototype.bind` method
1954// https://tc39.es/ecma262/#sec-function.prototype.bind
1955_export({ target: 'Function', proto: true }, {
1956 bind: functionBind
1957});var bind$1 = entryVirtual('Function').bind;var FunctionPrototype = Function.prototype;
1958
1959var bind_1 = function (it) {
1960 var own = it.bind;
1961 return it === FunctionPrototype || (it instanceof Function && own === FunctionPrototype.bind) ? bind$1 : own;
1962};var bind$2 = bind_1;var bind$3 = bind$2;function _classCallCheck(instance, Constructor) {
1963 if (!(instance instanceof Constructor)) {
1964 throw new TypeError("Cannot call a class as a function");
1965 }
1966}
1967
1968var classCallCheck = _classCallCheck;// `Object.defineProperty` method
1969// https://tc39.es/ecma262/#sec-object.defineproperty
1970_export({ target: 'Object', stat: true, forced: !descriptors, sham: !descriptors }, {
1971 defineProperty: objectDefineProperty.f
1972});var defineProperty_1 = createCommonjsModule(function (module) {
1973var Object = path.Object;
1974
1975var defineProperty = module.exports = function defineProperty(it, key, desc) {
1976 return Object.defineProperty(it, key, desc);
1977};
1978
1979if (Object.defineProperty.sham) defineProperty.sham = true;
1980});var defineProperty$2 = defineProperty_1;var defineProperty$3 = defineProperty$2;function _defineProperties(target, props) {
1981 for (var i = 0; i < props.length; i++) {
1982 var descriptor = props[i];
1983 descriptor.enumerable = descriptor.enumerable || false;
1984 descriptor.configurable = true;
1985 if ("value" in descriptor) descriptor.writable = true;
1986
1987 defineProperty$3(target, descriptor.key, descriptor);
1988 }
1989}
1990
1991function _createClass(Constructor, protoProps, staticProps) {
1992 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
1993 if (staticProps) _defineProperties(Constructor, staticProps);
1994 return Constructor;
1995}
1996
1997var createClass = _createClass;// a string of all valid unicode whitespaces
1998var whitespaces = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' +
1999 '\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';var whitespace = '[' + whitespaces + ']';
2000var ltrim = RegExp('^' + whitespace + whitespace + '*');
2001var rtrim = RegExp(whitespace + whitespace + '*$');
2002
2003// `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
2004var createMethod$3 = function (TYPE) {
2005 return function ($this) {
2006 var string = String(requireObjectCoercible($this));
2007 if (TYPE & 1) string = string.replace(ltrim, '');
2008 if (TYPE & 2) string = string.replace(rtrim, '');
2009 return string;
2010 };
2011};
2012
2013var stringTrim = {
2014 // `String.prototype.{ trimLeft, trimStart }` methods
2015 // https://tc39.es/ecma262/#sec-string.prototype.trimstart
2016 start: createMethod$3(1),
2017 // `String.prototype.{ trimRight, trimEnd }` methods
2018 // https://tc39.es/ecma262/#sec-string.prototype.trimend
2019 end: createMethod$3(2),
2020 // `String.prototype.trim` method
2021 // https://tc39.es/ecma262/#sec-string.prototype.trim
2022 trim: createMethod$3(3)
2023};var trim = stringTrim.trim;
2024
2025
2026var $parseInt = global$1.parseInt;
2027var hex = /^[+-]?0[Xx]/;
2028var FORCED$2 = $parseInt(whitespaces + '08') !== 8 || $parseInt(whitespaces + '0x16') !== 22;
2029
2030// `parseInt` method
2031// https://tc39.es/ecma262/#sec-parseint-string-radix
2032var numberParseInt = FORCED$2 ? function parseInt(string, radix) {
2033 var S = trim(String(string));
2034 return $parseInt(S, (radix >>> 0) || (hex.test(S) ? 16 : 10));
2035} : $parseInt;// `parseInt` method
2036// https://tc39.es/ecma262/#sec-parseint-string-radix
2037_export({ global: true, forced: parseInt != numberParseInt }, {
2038 parseInt: numberParseInt
2039});var createProperty = function (object, key, value) {
2040 var propertyKey = toPrimitive(key);
2041 if (propertyKey in object) objectDefineProperty.f(object, propertyKey, createPropertyDescriptor(0, value));
2042 else object[propertyKey] = value;
2043};var SPECIES$4 = wellKnownSymbol('species');
2044
2045var arrayMethodHasSpeciesSupport = function (METHOD_NAME) {
2046 // We can't use this feature detection in V8 since it causes
2047 // deoptimization and serious performance degradation
2048 // https://github.com/zloirock/core-js/issues/677
2049 return engineV8Version >= 51 || !fails(function () {
2050 var array = [];
2051 var constructor = array.constructor = {};
2052 constructor[SPECIES$4] = function () {
2053 return { foo: 1 };
2054 };
2055 return array[METHOD_NAME](Boolean).foo !== 1;
2056 });
2057};var IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable');
2058var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
2059var MAXIMUM_ALLOWED_INDEX_EXCEEDED = 'Maximum allowed index exceeded';
2060
2061// We can't use this feature detection in V8 since it causes
2062// deoptimization and serious performance degradation
2063// https://github.com/zloirock/core-js/issues/679
2064var IS_CONCAT_SPREADABLE_SUPPORT = engineV8Version >= 51 || !fails(function () {
2065 var array = [];
2066 array[IS_CONCAT_SPREADABLE] = false;
2067 return array.concat()[0] !== array;
2068});
2069
2070var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('concat');
2071
2072var isConcatSpreadable = function (O) {
2073 if (!isObject(O)) return false;
2074 var spreadable = O[IS_CONCAT_SPREADABLE];
2075 return spreadable !== undefined ? !!spreadable : isArray(O);
2076};
2077
2078var FORCED$3 = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT;
2079
2080// `Array.prototype.concat` method
2081// https://tc39.es/ecma262/#sec-array.prototype.concat
2082// with adding support of @@isConcatSpreadable and @@species
2083_export({ target: 'Array', proto: true, forced: FORCED$3 }, {
2084 // eslint-disable-next-line no-unused-vars -- required for `.length`
2085 concat: function concat(arg) {
2086 var O = toObject(this);
2087 var A = arraySpeciesCreate(O, 0);
2088 var n = 0;
2089 var i, k, length, len, E;
2090 for (i = -1, length = arguments.length; i < length; i++) {
2091 E = i === -1 ? O : arguments[i];
2092 if (isConcatSpreadable(E)) {
2093 len = toLength(E.length);
2094 if (n + len > MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
2095 for (k = 0; k < len; k++, n++) if (k in E) createProperty(A, n, E[k]);
2096 } else {
2097 if (n >= MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
2098 createProperty(A, n++, E);
2099 }
2100 }
2101 A.length = n;
2102 return A;
2103 }
2104});var concat = entryVirtual('Array').concat;var ArrayPrototype$2 = Array.prototype;
2105
2106var concat_1 = function (it) {
2107 var own = it.concat;
2108 return it === ArrayPrototype$2 || (it instanceof Array && own === ArrayPrototype$2.concat) ? concat : own;
2109};var concat$1 = concat_1;var concat$2 = concat$1;var logger = new logger$4.Logger({
2110 debug: true,
2111 logLevel: 'detail',
2112 logPrefix: getPrefix()
2113});
2114
2115function getPrefix(scope, suffix) {
2116 var str = 'Mixin-JSBridge';
2117
2118 if (scope && suffix) {
2119 var _context, _context2;
2120
2121 str = concat$2(_context = concat$2(_context2 = "".concat(str, " ")).call(_context2, scope, "-")).call(_context, suffix);
2122 } else if (scope) {
2123 var _context3;
2124
2125 str = concat$2(_context3 = "".concat(str, " ")).call(_context3, scope);
2126 } else if (suffix) {
2127 var _context4;
2128
2129 str = concat$2(_context4 = "".concat(str, " ")).call(_context4, suffix);
2130 }
2131
2132 return str;
2133}
2134
2135function getLogger(scope) {
2136 return function (suffix) {
2137 return logger.setPrefix(getPrefix(scope, suffix));
2138 };
2139}function env() {
2140 var _a;
2141
2142 var ua = (_a = window === null || window === void 0 ? void 0 : window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent;
2143 return assign$2({}, getUA.getUA(ua));
2144}function parseError(err) {
2145 var _a, _b, _c;
2146
2147 var name = err === null || err === void 0 ? void 0 : err.name;
2148 var message = (_c = (_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : (_b = err === null || err === void 0 ? void 0 : err.toString) === null || _b === void 0 ? void 0 : _b.call(err)) !== null && _c !== void 0 ? _c : err;
2149 var stack = err === null || err === void 0 ? void 0 : err.stack;
2150 return {
2151 name: name,
2152 message: message,
2153 stack: stack
2154 };
2155}var _Request = new Request__default['default']({
2156 codeMap: {
2157 suc_code: 200,
2158 err_code: -1
2159 },
2160 codeField: 'code'
2161}),
2162 request = _Request.request;var storageType = 'localStorage';
2163var logger$1 = getLogger('storage');
2164var store$2 = {
2165 get: function get(key) {
2166 return storage.storage.get(key, storageType);
2167 },
2168 set: function set(key, val) {
2169 try {
2170 if (typeof val !== 'string') {
2171 val = stringify$2(val);
2172 }
2173
2174 return storage.storage.set(key, val, storageType);
2175 } catch (err) {
2176 logger$1().warn('set storage error', err);
2177 return false;
2178 }
2179 },
2180 clear: function clear(key) {
2181 return storage.storage.clear(key, storageType);
2182 }
2183};function isObject$1(val) {
2184 return isType.isType('object')(val);
2185}function uuid() {
2186 var d = new Date().getTime();
2187 var uuid = 'xxxxxxxx-yyyy-yyyy-yyyy-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
2188 var r = (d + Math.random() * 16) % 16 | 0;
2189 d = Math.floor(d / 16);
2190 return (c === 'x' ? r : r & 0x7 | 0x8).toString(16);
2191 });
2192 return uuid;
2193}var logger$2 = getLogger('messager');
2194function messager(type) {
2195 var _context;
2196
2197 var _a, _b, _c, _d, _e, _f, _g;
2198
2199 var envInfo = env();
2200 var handler = envInfo.isIOS ? type === 'getContext' ? function () {
2201 return JSON.parse(prompt('MixinContext.getContext()'));
2202 } : (_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b[type]) === null || _c === void 0 ? void 0 : bind$3(_context = _c.postMessage).call(_context, (_e = (_d = window === null || window === void 0 ? void 0 : window.webkit) === null || _d === void 0 ? void 0 : _d.messageHandlers) === null || _e === void 0 ? void 0 : _e[type]) : (_g = (_f = window === null || window === void 0 ? void 0 : window.MixinContext) === null || _f === void 0 ? void 0 : _f[type]) === null || _g === void 0 ? void 0 : bind$3(_g).call(_g, window === null || window === void 0 ? void 0 : window.MixinContext);
2203 return handler !== null && handler !== void 0 ? handler : function () {
2204 return logger$2().warn("The messager \"".concat(type, "\" is not support yet!"));
2205 };
2206}var core = createCommonjsModule(function (module, exports) {
2207(function (root, factory) {
2208 {
2209 // CommonJS
2210 module.exports = exports = factory();
2211 }
2212}(commonjsGlobal, function () {
2213
2214 /*globals window, global, require*/
2215
2216 /**
2217 * CryptoJS core components.
2218 */
2219 var CryptoJS = CryptoJS || (function (Math, undefined$1) {
2220
2221 var crypto;
2222
2223 // Native crypto from window (Browser)
2224 if (typeof window !== 'undefined' && window.crypto) {
2225 crypto = window.crypto;
2226 }
2227
2228 // Native (experimental IE 11) crypto from window (Browser)
2229 if (!crypto && typeof window !== 'undefined' && window.msCrypto) {
2230 crypto = window.msCrypto;
2231 }
2232
2233 // Native crypto from global (NodeJS)
2234 if (!crypto && typeof commonjsGlobal !== 'undefined' && commonjsGlobal.crypto) {
2235 crypto = commonjsGlobal.crypto;
2236 }
2237
2238 // Native crypto import via require (NodeJS)
2239 if (!crypto && typeof commonjsRequire === 'function') {
2240 try {
2241 crypto = require$$0__default['default'];
2242 } catch (err) {}
2243 }
2244
2245 /*
2246 * Cryptographically secure pseudorandom number generator
2247 *
2248 * As Math.random() is cryptographically not safe to use
2249 */
2250 var cryptoSecureRandomInt = function () {
2251 if (crypto) {
2252 // Use getRandomValues method (Browser)
2253 if (typeof crypto.getRandomValues === 'function') {
2254 try {
2255 return crypto.getRandomValues(new Uint32Array(1))[0];
2256 } catch (err) {}
2257 }
2258
2259 // Use randomBytes method (NodeJS)
2260 if (typeof crypto.randomBytes === 'function') {
2261 try {
2262 return crypto.randomBytes(4).readInt32LE();
2263 } catch (err) {}
2264 }
2265 }
2266
2267 throw new Error('Native crypto module could not be used to get secure random number.');
2268 };
2269
2270 /*
2271 * Local polyfill of Object.create
2272
2273 */
2274 var create = Object.create || (function () {
2275 function F() {}
2276
2277 return function (obj) {
2278 var subtype;
2279
2280 F.prototype = obj;
2281
2282 subtype = new F();
2283
2284 F.prototype = null;
2285
2286 return subtype;
2287 };
2288 }());
2289
2290 /**
2291 * CryptoJS namespace.
2292 */
2293 var C = {};
2294
2295 /**
2296 * Library namespace.
2297 */
2298 var C_lib = C.lib = {};
2299
2300 /**
2301 * Base object for prototypal inheritance.
2302 */
2303 var Base = C_lib.Base = (function () {
2304
2305
2306 return {
2307 /**
2308 * Creates a new object that inherits from this object.
2309 *
2310 * @param {Object} overrides Properties to copy into the new object.
2311 *
2312 * @return {Object} The new object.
2313 *
2314 * @static
2315 *
2316 * @example
2317 *
2318 * var MyType = CryptoJS.lib.Base.extend({
2319 * field: 'value',
2320 *
2321 * method: function () {
2322 * }
2323 * });
2324 */
2325 extend: function (overrides) {
2326 // Spawn
2327 var subtype = create(this);
2328
2329 // Augment
2330 if (overrides) {
2331 subtype.mixIn(overrides);
2332 }
2333
2334 // Create default initializer
2335 if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
2336 subtype.init = function () {
2337 subtype.$super.init.apply(this, arguments);
2338 };
2339 }
2340
2341 // Initializer's prototype is the subtype object
2342 subtype.init.prototype = subtype;
2343
2344 // Reference supertype
2345 subtype.$super = this;
2346
2347 return subtype;
2348 },
2349
2350 /**
2351 * Extends this object and runs the init method.
2352 * Arguments to create() will be passed to init().
2353 *
2354 * @return {Object} The new object.
2355 *
2356 * @static
2357 *
2358 * @example
2359 *
2360 * var instance = MyType.create();
2361 */
2362 create: function () {
2363 var instance = this.extend();
2364 instance.init.apply(instance, arguments);
2365
2366 return instance;
2367 },
2368
2369 /**
2370 * Initializes a newly created object.
2371 * Override this method to add some logic when your objects are created.
2372 *
2373 * @example
2374 *
2375 * var MyType = CryptoJS.lib.Base.extend({
2376 * init: function () {
2377 * // ...
2378 * }
2379 * });
2380 */
2381 init: function () {
2382 },
2383
2384 /**
2385 * Copies properties into this object.
2386 *
2387 * @param {Object} properties The properties to mix in.
2388 *
2389 * @example
2390 *
2391 * MyType.mixIn({
2392 * field: 'value'
2393 * });
2394 */
2395 mixIn: function (properties) {
2396 for (var propertyName in properties) {
2397 if (properties.hasOwnProperty(propertyName)) {
2398 this[propertyName] = properties[propertyName];
2399 }
2400 }
2401
2402 // IE won't copy toString using the loop above
2403 if (properties.hasOwnProperty('toString')) {
2404 this.toString = properties.toString;
2405 }
2406 },
2407
2408 /**
2409 * Creates a copy of this object.
2410 *
2411 * @return {Object} The clone.
2412 *
2413 * @example
2414 *
2415 * var clone = instance.clone();
2416 */
2417 clone: function () {
2418 return this.init.prototype.extend(this);
2419 }
2420 };
2421 }());
2422
2423 /**
2424 * An array of 32-bit words.
2425 *
2426 * @property {Array} words The array of 32-bit words.
2427 * @property {number} sigBytes The number of significant bytes in this word array.
2428 */
2429 var WordArray = C_lib.WordArray = Base.extend({
2430 /**
2431 * Initializes a newly created word array.
2432 *
2433 * @param {Array} words (Optional) An array of 32-bit words.
2434 * @param {number} sigBytes (Optional) The number of significant bytes in the words.
2435 *
2436 * @example
2437 *
2438 * var wordArray = CryptoJS.lib.WordArray.create();
2439 * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
2440 * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
2441 */
2442 init: function (words, sigBytes) {
2443 words = this.words = words || [];
2444
2445 if (sigBytes != undefined$1) {
2446 this.sigBytes = sigBytes;
2447 } else {
2448 this.sigBytes = words.length * 4;
2449 }
2450 },
2451
2452 /**
2453 * Converts this word array to a string.
2454 *
2455 * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
2456 *
2457 * @return {string} The stringified word array.
2458 *
2459 * @example
2460 *
2461 * var string = wordArray + '';
2462 * var string = wordArray.toString();
2463 * var string = wordArray.toString(CryptoJS.enc.Utf8);
2464 */
2465 toString: function (encoder) {
2466 return (encoder || Hex).stringify(this);
2467 },
2468
2469 /**
2470 * Concatenates a word array to this word array.
2471 *
2472 * @param {WordArray} wordArray The word array to append.
2473 *
2474 * @return {WordArray} This word array.
2475 *
2476 * @example
2477 *
2478 * wordArray1.concat(wordArray2);
2479 */
2480 concat: function (wordArray) {
2481 // Shortcuts
2482 var thisWords = this.words;
2483 var thatWords = wordArray.words;
2484 var thisSigBytes = this.sigBytes;
2485 var thatSigBytes = wordArray.sigBytes;
2486
2487 // Clamp excess bits
2488 this.clamp();
2489
2490 // Concat
2491 if (thisSigBytes % 4) {
2492 // Copy one byte at a time
2493 for (var i = 0; i < thatSigBytes; i++) {
2494 var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
2495 thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
2496 }
2497 } else {
2498 // Copy one word at a time
2499 for (var i = 0; i < thatSigBytes; i += 4) {
2500 thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];
2501 }
2502 }
2503 this.sigBytes += thatSigBytes;
2504
2505 // Chainable
2506 return this;
2507 },
2508
2509 /**
2510 * Removes insignificant bits.
2511 *
2512 * @example
2513 *
2514 * wordArray.clamp();
2515 */
2516 clamp: function () {
2517 // Shortcuts
2518 var words = this.words;
2519 var sigBytes = this.sigBytes;
2520
2521 // Clamp
2522 words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
2523 words.length = Math.ceil(sigBytes / 4);
2524 },
2525
2526 /**
2527 * Creates a copy of this word array.
2528 *
2529 * @return {WordArray} The clone.
2530 *
2531 * @example
2532 *
2533 * var clone = wordArray.clone();
2534 */
2535 clone: function () {
2536 var clone = Base.clone.call(this);
2537 clone.words = this.words.slice(0);
2538
2539 return clone;
2540 },
2541
2542 /**
2543 * Creates a word array filled with random bytes.
2544 *
2545 * @param {number} nBytes The number of random bytes to generate.
2546 *
2547 * @return {WordArray} The random word array.
2548 *
2549 * @static
2550 *
2551 * @example
2552 *
2553 * var wordArray = CryptoJS.lib.WordArray.random(16);
2554 */
2555 random: function (nBytes) {
2556 var words = [];
2557
2558 for (var i = 0; i < nBytes; i += 4) {
2559 words.push(cryptoSecureRandomInt());
2560 }
2561
2562 return new WordArray.init(words, nBytes);
2563 }
2564 });
2565
2566 /**
2567 * Encoder namespace.
2568 */
2569 var C_enc = C.enc = {};
2570
2571 /**
2572 * Hex encoding strategy.
2573 */
2574 var Hex = C_enc.Hex = {
2575 /**
2576 * Converts a word array to a hex string.
2577 *
2578 * @param {WordArray} wordArray The word array.
2579 *
2580 * @return {string} The hex string.
2581 *
2582 * @static
2583 *
2584 * @example
2585 *
2586 * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
2587 */
2588 stringify: function (wordArray) {
2589 // Shortcuts
2590 var words = wordArray.words;
2591 var sigBytes = wordArray.sigBytes;
2592
2593 // Convert
2594 var hexChars = [];
2595 for (var i = 0; i < sigBytes; i++) {
2596 var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
2597 hexChars.push((bite >>> 4).toString(16));
2598 hexChars.push((bite & 0x0f).toString(16));
2599 }
2600
2601 return hexChars.join('');
2602 },
2603
2604 /**
2605 * Converts a hex string to a word array.
2606 *
2607 * @param {string} hexStr The hex string.
2608 *
2609 * @return {WordArray} The word array.
2610 *
2611 * @static
2612 *
2613 * @example
2614 *
2615 * var wordArray = CryptoJS.enc.Hex.parse(hexString);
2616 */
2617 parse: function (hexStr) {
2618 // Shortcut
2619 var hexStrLength = hexStr.length;
2620
2621 // Convert
2622 var words = [];
2623 for (var i = 0; i < hexStrLength; i += 2) {
2624 words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
2625 }
2626
2627 return new WordArray.init(words, hexStrLength / 2);
2628 }
2629 };
2630
2631 /**
2632 * Latin1 encoding strategy.
2633 */
2634 var Latin1 = C_enc.Latin1 = {
2635 /**
2636 * Converts a word array to a Latin1 string.
2637 *
2638 * @param {WordArray} wordArray The word array.
2639 *
2640 * @return {string} The Latin1 string.
2641 *
2642 * @static
2643 *
2644 * @example
2645 *
2646 * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
2647 */
2648 stringify: function (wordArray) {
2649 // Shortcuts
2650 var words = wordArray.words;
2651 var sigBytes = wordArray.sigBytes;
2652
2653 // Convert
2654 var latin1Chars = [];
2655 for (var i = 0; i < sigBytes; i++) {
2656 var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
2657 latin1Chars.push(String.fromCharCode(bite));
2658 }
2659
2660 return latin1Chars.join('');
2661 },
2662
2663 /**
2664 * Converts a Latin1 string to a word array.
2665 *
2666 * @param {string} latin1Str The Latin1 string.
2667 *
2668 * @return {WordArray} The word array.
2669 *
2670 * @static
2671 *
2672 * @example
2673 *
2674 * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
2675 */
2676 parse: function (latin1Str) {
2677 // Shortcut
2678 var latin1StrLength = latin1Str.length;
2679
2680 // Convert
2681 var words = [];
2682 for (var i = 0; i < latin1StrLength; i++) {
2683 words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
2684 }
2685
2686 return new WordArray.init(words, latin1StrLength);
2687 }
2688 };
2689
2690 /**
2691 * UTF-8 encoding strategy.
2692 */
2693 var Utf8 = C_enc.Utf8 = {
2694 /**
2695 * Converts a word array to a UTF-8 string.
2696 *
2697 * @param {WordArray} wordArray The word array.
2698 *
2699 * @return {string} The UTF-8 string.
2700 *
2701 * @static
2702 *
2703 * @example
2704 *
2705 * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
2706 */
2707 stringify: function (wordArray) {
2708 try {
2709 return decodeURIComponent(escape(Latin1.stringify(wordArray)));
2710 } catch (e) {
2711 throw new Error('Malformed UTF-8 data');
2712 }
2713 },
2714
2715 /**
2716 * Converts a UTF-8 string to a word array.
2717 *
2718 * @param {string} utf8Str The UTF-8 string.
2719 *
2720 * @return {WordArray} The word array.
2721 *
2722 * @static
2723 *
2724 * @example
2725 *
2726 * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
2727 */
2728 parse: function (utf8Str) {
2729 return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
2730 }
2731 };
2732
2733 /**
2734 * Abstract buffered block algorithm template.
2735 *
2736 * The property blockSize must be implemented in a concrete subtype.
2737 *
2738 * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
2739 */
2740 var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
2741 /**
2742 * Resets this block algorithm's data buffer to its initial state.
2743 *
2744 * @example
2745 *
2746 * bufferedBlockAlgorithm.reset();
2747 */
2748 reset: function () {
2749 // Initial values
2750 this._data = new WordArray.init();
2751 this._nDataBytes = 0;
2752 },
2753
2754 /**
2755 * Adds new data to this block algorithm's buffer.
2756 *
2757 * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
2758 *
2759 * @example
2760 *
2761 * bufferedBlockAlgorithm._append('data');
2762 * bufferedBlockAlgorithm._append(wordArray);
2763 */
2764 _append: function (data) {
2765 // Convert string to WordArray, else assume WordArray already
2766 if (typeof data == 'string') {
2767 data = Utf8.parse(data);
2768 }
2769
2770 // Append
2771 this._data.concat(data);
2772 this._nDataBytes += data.sigBytes;
2773 },
2774
2775 /**
2776 * Processes available data blocks.
2777 *
2778 * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
2779 *
2780 * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
2781 *
2782 * @return {WordArray} The processed data.
2783 *
2784 * @example
2785 *
2786 * var processedData = bufferedBlockAlgorithm._process();
2787 * var processedData = bufferedBlockAlgorithm._process(!!'flush');
2788 */
2789 _process: function (doFlush) {
2790 var processedWords;
2791
2792 // Shortcuts
2793 var data = this._data;
2794 var dataWords = data.words;
2795 var dataSigBytes = data.sigBytes;
2796 var blockSize = this.blockSize;
2797 var blockSizeBytes = blockSize * 4;
2798
2799 // Count blocks ready
2800 var nBlocksReady = dataSigBytes / blockSizeBytes;
2801 if (doFlush) {
2802 // Round up to include partial blocks
2803 nBlocksReady = Math.ceil(nBlocksReady);
2804 } else {
2805 // Round down to include only full blocks,
2806 // less the number of blocks that must remain in the buffer
2807 nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
2808 }
2809
2810 // Count words ready
2811 var nWordsReady = nBlocksReady * blockSize;
2812
2813 // Count bytes ready
2814 var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
2815
2816 // Process blocks
2817 if (nWordsReady) {
2818 for (var offset = 0; offset < nWordsReady; offset += blockSize) {
2819 // Perform concrete-algorithm logic
2820 this._doProcessBlock(dataWords, offset);
2821 }
2822
2823 // Remove processed words
2824 processedWords = dataWords.splice(0, nWordsReady);
2825 data.sigBytes -= nBytesReady;
2826 }
2827
2828 // Return processed words
2829 return new WordArray.init(processedWords, nBytesReady);
2830 },
2831
2832 /**
2833 * Creates a copy of this object.
2834 *
2835 * @return {Object} The clone.
2836 *
2837 * @example
2838 *
2839 * var clone = bufferedBlockAlgorithm.clone();
2840 */
2841 clone: function () {
2842 var clone = Base.clone.call(this);
2843 clone._data = this._data.clone();
2844
2845 return clone;
2846 },
2847
2848 _minBufferSize: 0
2849 });
2850
2851 /**
2852 * Abstract hasher template.
2853 *
2854 * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
2855 */
2856 var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
2857 /**
2858 * Configuration options.
2859 */
2860 cfg: Base.extend(),
2861
2862 /**
2863 * Initializes a newly created hasher.
2864 *
2865 * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
2866 *
2867 * @example
2868 *
2869 * var hasher = CryptoJS.algo.SHA256.create();
2870 */
2871 init: function (cfg) {
2872 // Apply config defaults
2873 this.cfg = this.cfg.extend(cfg);
2874
2875 // Set initial values
2876 this.reset();
2877 },
2878
2879 /**
2880 * Resets this hasher to its initial state.
2881 *
2882 * @example
2883 *
2884 * hasher.reset();
2885 */
2886 reset: function () {
2887 // Reset data buffer
2888 BufferedBlockAlgorithm.reset.call(this);
2889
2890 // Perform concrete-hasher logic
2891 this._doReset();
2892 },
2893
2894 /**
2895 * Updates this hasher with a message.
2896 *
2897 * @param {WordArray|string} messageUpdate The message to append.
2898 *
2899 * @return {Hasher} This hasher.
2900 *
2901 * @example
2902 *
2903 * hasher.update('message');
2904 * hasher.update(wordArray);
2905 */
2906 update: function (messageUpdate) {
2907 // Append
2908 this._append(messageUpdate);
2909
2910 // Update the hash
2911 this._process();
2912
2913 // Chainable
2914 return this;
2915 },
2916
2917 /**
2918 * Finalizes the hash computation.
2919 * Note that the finalize operation is effectively a destructive, read-once operation.
2920 *
2921 * @param {WordArray|string} messageUpdate (Optional) A final message update.
2922 *
2923 * @return {WordArray} The hash.
2924 *
2925 * @example
2926 *
2927 * var hash = hasher.finalize();
2928 * var hash = hasher.finalize('message');
2929 * var hash = hasher.finalize(wordArray);
2930 */
2931 finalize: function (messageUpdate) {
2932 // Final message update
2933 if (messageUpdate) {
2934 this._append(messageUpdate);
2935 }
2936
2937 // Perform concrete-hasher logic
2938 var hash = this._doFinalize();
2939
2940 return hash;
2941 },
2942
2943 blockSize: 512/32,
2944
2945 /**
2946 * Creates a shortcut function to a hasher's object interface.
2947 *
2948 * @param {Hasher} hasher The hasher to create a helper for.
2949 *
2950 * @return {Function} The shortcut function.
2951 *
2952 * @static
2953 *
2954 * @example
2955 *
2956 * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
2957 */
2958 _createHelper: function (hasher) {
2959 return function (message, cfg) {
2960 return new hasher.init(cfg).finalize(message);
2961 };
2962 },
2963
2964 /**
2965 * Creates a shortcut function to the HMAC's object interface.
2966 *
2967 * @param {Hasher} hasher The hasher to use in this HMAC helper.
2968 *
2969 * @return {Function} The shortcut function.
2970 *
2971 * @static
2972 *
2973 * @example
2974 *
2975 * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
2976 */
2977 _createHmacHelper: function (hasher) {
2978 return function (message, key) {
2979 return new C_algo.HMAC.init(hasher, key).finalize(message);
2980 };
2981 }
2982 });
2983
2984 /**
2985 * Algorithm namespace.
2986 */
2987 var C_algo = C.algo = {};
2988
2989 return C;
2990 }(Math));
2991
2992
2993 return CryptoJS;
2994
2995}));
2996});var encBase64 = createCommonjsModule(function (module, exports) {
2997(function (root, factory) {
2998 {
2999 // CommonJS
3000 module.exports = exports = factory(core);
3001 }
3002}(commonjsGlobal, function (CryptoJS) {
3003
3004 (function () {
3005 // Shortcuts
3006 var C = CryptoJS;
3007 var C_lib = C.lib;
3008 var WordArray = C_lib.WordArray;
3009 var C_enc = C.enc;
3010
3011 /**
3012 * Base64 encoding strategy.
3013 */
3014 var Base64 = C_enc.Base64 = {
3015 /**
3016 * Converts a word array to a Base64 string.
3017 *
3018 * @param {WordArray} wordArray The word array.
3019 *
3020 * @return {string} The Base64 string.
3021 *
3022 * @static
3023 *
3024 * @example
3025 *
3026 * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
3027 */
3028 stringify: function (wordArray) {
3029 // Shortcuts
3030 var words = wordArray.words;
3031 var sigBytes = wordArray.sigBytes;
3032 var map = this._map;
3033
3034 // Clamp excess bits
3035 wordArray.clamp();
3036
3037 // Convert
3038 var base64Chars = [];
3039 for (var i = 0; i < sigBytes; i += 3) {
3040 var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
3041 var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
3042 var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
3043
3044 var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
3045
3046 for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
3047 base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
3048 }
3049 }
3050
3051 // Add padding
3052 var paddingChar = map.charAt(64);
3053 if (paddingChar) {
3054 while (base64Chars.length % 4) {
3055 base64Chars.push(paddingChar);
3056 }
3057 }
3058
3059 return base64Chars.join('');
3060 },
3061
3062 /**
3063 * Converts a Base64 string to a word array.
3064 *
3065 * @param {string} base64Str The Base64 string.
3066 *
3067 * @return {WordArray} The word array.
3068 *
3069 * @static
3070 *
3071 * @example
3072 *
3073 * var wordArray = CryptoJS.enc.Base64.parse(base64String);
3074 */
3075 parse: function (base64Str) {
3076 // Shortcuts
3077 var base64StrLength = base64Str.length;
3078 var map = this._map;
3079 var reverseMap = this._reverseMap;
3080
3081 if (!reverseMap) {
3082 reverseMap = this._reverseMap = [];
3083 for (var j = 0; j < map.length; j++) {
3084 reverseMap[map.charCodeAt(j)] = j;
3085 }
3086 }
3087
3088 // Ignore padding
3089 var paddingChar = map.charAt(64);
3090 if (paddingChar) {
3091 var paddingIndex = base64Str.indexOf(paddingChar);
3092 if (paddingIndex !== -1) {
3093 base64StrLength = paddingIndex;
3094 }
3095 }
3096
3097 // Convert
3098 return parseLoop(base64Str, base64StrLength, reverseMap);
3099
3100 },
3101
3102 _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
3103 };
3104
3105 function parseLoop(base64Str, base64StrLength, reverseMap) {
3106 var words = [];
3107 var nBytes = 0;
3108 for (var i = 0; i < base64StrLength; i++) {
3109 if (i % 4) {
3110 var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
3111 var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
3112 var bitsCombined = bits1 | bits2;
3113 words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8);
3114 nBytes++;
3115 }
3116 }
3117 return WordArray.create(words, nBytes);
3118 }
3119 }());
3120
3121
3122 return CryptoJS.enc.Base64;
3123
3124}));
3125});var sha256 = createCommonjsModule(function (module, exports) {
3126(function (root, factory) {
3127 {
3128 // CommonJS
3129 module.exports = exports = factory(core);
3130 }
3131}(commonjsGlobal, function (CryptoJS) {
3132
3133 (function (Math) {
3134 // Shortcuts
3135 var C = CryptoJS;
3136 var C_lib = C.lib;
3137 var WordArray = C_lib.WordArray;
3138 var Hasher = C_lib.Hasher;
3139 var C_algo = C.algo;
3140
3141 // Initialization and round constants tables
3142 var H = [];
3143 var K = [];
3144
3145 // Compute constants
3146 (function () {
3147 function isPrime(n) {
3148 var sqrtN = Math.sqrt(n);
3149 for (var factor = 2; factor <= sqrtN; factor++) {
3150 if (!(n % factor)) {
3151 return false;
3152 }
3153 }
3154
3155 return true;
3156 }
3157
3158 function getFractionalBits(n) {
3159 return ((n - (n | 0)) * 0x100000000) | 0;
3160 }
3161
3162 var n = 2;
3163 var nPrime = 0;
3164 while (nPrime < 64) {
3165 if (isPrime(n)) {
3166 if (nPrime < 8) {
3167 H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
3168 }
3169 K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
3170
3171 nPrime++;
3172 }
3173
3174 n++;
3175 }
3176 }());
3177
3178 // Reusable object
3179 var W = [];
3180
3181 /**
3182 * SHA-256 hash algorithm.
3183 */
3184 var SHA256 = C_algo.SHA256 = Hasher.extend({
3185 _doReset: function () {
3186 this._hash = new WordArray.init(H.slice(0));
3187 },
3188
3189 _doProcessBlock: function (M, offset) {
3190 // Shortcut
3191 var H = this._hash.words;
3192
3193 // Working variables
3194 var a = H[0];
3195 var b = H[1];
3196 var c = H[2];
3197 var d = H[3];
3198 var e = H[4];
3199 var f = H[5];
3200 var g = H[6];
3201 var h = H[7];
3202
3203 // Computation
3204 for (var i = 0; i < 64; i++) {
3205 if (i < 16) {
3206 W[i] = M[offset + i] | 0;
3207 } else {
3208 var gamma0x = W[i - 15];
3209 var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^
3210 ((gamma0x << 14) | (gamma0x >>> 18)) ^
3211 (gamma0x >>> 3);
3212
3213 var gamma1x = W[i - 2];
3214 var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^
3215 ((gamma1x << 13) | (gamma1x >>> 19)) ^
3216 (gamma1x >>> 10);
3217
3218 W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
3219 }
3220
3221 var ch = (e & f) ^ (~e & g);
3222 var maj = (a & b) ^ (a & c) ^ (b & c);
3223
3224 var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
3225 var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));
3226
3227 var t1 = h + sigma1 + ch + K[i] + W[i];
3228 var t2 = sigma0 + maj;
3229
3230 h = g;
3231 g = f;
3232 f = e;
3233 e = (d + t1) | 0;
3234 d = c;
3235 c = b;
3236 b = a;
3237 a = (t1 + t2) | 0;
3238 }
3239
3240 // Intermediate hash value
3241 H[0] = (H[0] + a) | 0;
3242 H[1] = (H[1] + b) | 0;
3243 H[2] = (H[2] + c) | 0;
3244 H[3] = (H[3] + d) | 0;
3245 H[4] = (H[4] + e) | 0;
3246 H[5] = (H[5] + f) | 0;
3247 H[6] = (H[6] + g) | 0;
3248 H[7] = (H[7] + h) | 0;
3249 },
3250
3251 _doFinalize: function () {
3252 // Shortcuts
3253 var data = this._data;
3254 var dataWords = data.words;
3255
3256 var nBitsTotal = this._nDataBytes * 8;
3257 var nBitsLeft = data.sigBytes * 8;
3258
3259 // Add padding
3260 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
3261 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
3262 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
3263 data.sigBytes = dataWords.length * 4;
3264
3265 // Hash final blocks
3266 this._process();
3267
3268 // Return final computed hash
3269 return this._hash;
3270 },
3271
3272 clone: function () {
3273 var clone = Hasher.clone.call(this);
3274 clone._hash = this._hash.clone();
3275
3276 return clone;
3277 }
3278 });
3279
3280 /**
3281 * Shortcut function to the hasher's object interface.
3282 *
3283 * @param {WordArray|string} message The message to hash.
3284 *
3285 * @return {WordArray} The hash.
3286 *
3287 * @static
3288 *
3289 * @example
3290 *
3291 * var hash = CryptoJS.SHA256('message');
3292 * var hash = CryptoJS.SHA256(wordArray);
3293 */
3294 C.SHA256 = Hasher._createHelper(SHA256);
3295
3296 /**
3297 * Shortcut function to the HMAC's object interface.
3298 *
3299 * @param {WordArray|string} message The message to hash.
3300 * @param {WordArray|string} key The secret key.
3301 *
3302 * @return {WordArray} The HMAC.
3303 *
3304 * @static
3305 *
3306 * @example
3307 *
3308 * var hmac = CryptoJS.HmacSHA256(message, key);
3309 */
3310 C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
3311 }(Math));
3312
3313
3314 return CryptoJS.SHA256;
3315
3316}));
3317});var AUTHSCOPE = {
3318 phone: 'PHONE:READ',
3319 profile: 'PROFILE:READ',
3320 contacts: 'CONTACTS:READ',
3321 assets: 'ASSETS:READ',
3322 snapshots: 'SNAPSHOTS:READ',
3323 messages: 'MESSAGES:REPRESENT'
3324};
3325
3326function base64URLEncode(str) {
3327 return str.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
3328}
3329
3330function generateRandomString(len) {
3331 var text = '';
3332 var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
3333
3334 for (var i = 0; i < len; i++) {
3335 text += possible.charAt(Math.floor(Math.random() * possible.length));
3336 }
3337
3338 return text;
3339}
3340
3341function getAccessCode(params) {
3342 var _context, _context2, _context3, _context4, _context5;
3343
3344 // eslint-disable-next-line prefer-const
3345 var client_id = params.client_id,
3346 _params$oauth_url = params.oauth_url,
3347 oauth_url = _params$oauth_url === void 0 ? 'https://mixin.one/oauth/authorize' : _params$oauth_url,
3348 _params$redirect_url = params.redirect_url,
3349 redirect_url = _params$redirect_url === void 0 ? window.location.href : _params$redirect_url,
3350 state = params.state,
3351 _params$auth = params.auth,
3352 auth = _params$auth === void 0 ? {} : _params$auth,
3353 _params$code_challeng = params.code_challenge,
3354 code_challenge = _params$code_challeng === void 0 ? true : _params$code_challeng;
3355 var randomCode = generateRandomString(32);
3356 var verifier = base64URLEncode(jsBase64.Base64.encode(randomCode));
3357 var challenge = base64URLEncode(sha256(randomCode).toString(encBase64));
3358 verifier && store$2.set('$_mixin-code-verifier', verifier);
3359 var SCOPESTR = '';
3360
3361 forEach$2(_context = keys$3(auth)).call(_context, function (scope) {
3362 if (!auth[scope]) return;
3363 var scopeValue = AUTHSCOPE[scope];
3364 if (!SCOPESTR) SCOPESTR = scopeValue;else SCOPESTR += "+".concat(scopeValue);
3365 });
3366
3367 client_id = client_id ? "&client_id=".concat(client_id) : '';
3368 redirect_url = redirect_url ? "&redirect_url=".concat(encodeURIComponent(redirect_url)) : '';
3369 SCOPESTR = SCOPESTR ? "&scope=".concat(SCOPESTR) : '';
3370 challenge = code_challenge && challenge ? "&code_challenge=".concat(challenge) : '';
3371
3372 var url = concat$2(_context2 = concat$2(_context3 = concat$2(_context4 = concat$2(_context5 = "".concat(oauth_url, "/?response_type=code")).call(_context5, client_id)).call(_context4, redirect_url)).call(_context3, SCOPESTR)).call(_context2, challenge);
3373
3374 if (state) {
3375 var str = encodeURIComponent(state);
3376 url += "&state=".concat(str);
3377 }
3378
3379 window.location.href = url;
3380}
3381function getAccessToken(params) {
3382 var data = assign$2({}, params);
3383
3384 return request({
3385 url: 'https://mixin-api.zeromesh.net/oauth/token',
3386 method: 'POST',
3387 data: data,
3388 withCredentials: false
3389 }).then(function (res) {
3390 return res.data.access_token;
3391 });
3392}/*! *****************************************************************************
3393Copyright (c) Microsoft Corporation.
3394
3395Permission to use, copy, modify, and/or distribute this software for any
3396purpose with or without fee is hereby granted.
3397
3398THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
3399REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
3400AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
3401INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
3402LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
3403OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
3404PERFORMANCE OF THIS SOFTWARE.
3405***************************************************************************** */
3406
3407function __rest(s, e) {
3408 var t = {};
3409 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
3410 t[p] = s[p];
3411 if (s != null && typeof Object.getOwnPropertySymbols === "function")
3412 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
3413 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
3414 t[p[i]] = s[p[i]];
3415 }
3416 return t;
3417}var logger$3 = getLogger('scheme');
3418var SCHEME = {
3419 prefix: 'mixin',
3420 loadScheme: function loadScheme(url, open) {
3421 if (!url) {
3422 logger$3('loadScheme').error('The URL cannot be a falsy value!');
3423 return;
3424 }
3425
3426 if (open) {
3427 window.open(url);
3428 } else {
3429 window.location.href = url;
3430 }
3431
3432 return url;
3433 },
3434 getQuery: function getQuery(query) {
3435 if (!query) {
3436 return '';
3437 }
3438
3439 var res = '';
3440
3441 for (var k in query) {
3442 var _context;
3443
3444 var val = query[k];
3445 if (val === null || val === undefined) continue;
3446 res += concat$2(_context = "&".concat(k, "=")).call(_context, val);
3447 }
3448
3449 return res.replace(/^&?/, '?');
3450 },
3451 pay: function pay(params) {
3452 var _context2;
3453
3454 var _params = this.getQuery(params);
3455
3456 var _url = concat$2(_context2 = "".concat(this.prefix, "://pay")).call(_context2, _params);
3457
3458 logger$3('pay').log(_url);
3459 return this.loadScheme(_url);
3460 },
3461 transfer: function transfer(recipient) {
3462 var _context3;
3463
3464 var _url = concat$2(_context3 = "".concat(this.prefix, "://transfer/")).call(_context3, recipient);
3465
3466 logger$3('transfer').log(_url);
3467 return this.loadScheme(_url);
3468 },
3469 snapshots: function snapshots(params) {
3470 var _context4;
3471
3472 var trace_id = params.trace_id,
3473 snapshot_id = params.snapshot_id;
3474
3475 if (!trace_id && !snapshot_id) {
3476 logger$3('snapshots').error('Must contain "trace_id" or "snapshot_id"!');
3477 return;
3478 }
3479
3480 var _url = concat$2(_context4 = "".concat(this.prefix, "://snapshots")).call(_context4, trace_id ? "?trace=".concat(trace_id) : "/".concat(snapshot_id));
3481
3482 logger$3('snapshots').log(_url);
3483 return this.loadScheme(_url);
3484 },
3485 withdrawal: function withdrawal(params) {
3486 var _context5;
3487
3488 var _params = this.getQuery(params);
3489
3490 var _url = concat$2(_context5 = "".concat(this.prefix, "://withdrawal")).call(_context5, _params);
3491
3492 logger$3('withdrawal').log(_url);
3493 return this.loadScheme(_url);
3494 },
3495 address: function address(params) {
3496 var _context6;
3497
3498 var _params = this.getQuery(params);
3499
3500 var _url = concat$2(_context6 = "".concat(this.prefix, "://address")).call(_context6, _params);
3501
3502 logger$3('address').log(_url);
3503 return this.loadScheme(_url);
3504 },
3505 send: function send(params) {
3506 var _context7;
3507
3508 var data = encodeURIComponent(jsBase64.Base64.encode(typeof params.data === 'string' ? params.data : stringify$2(params.data)));
3509
3510 var _params = this.getQuery(assign$2(assign$2({}, params), {
3511 data: data
3512 }));
3513
3514 var _url = concat$2(_context7 = "".concat(this.prefix, "://send")).call(_context7, _params);
3515
3516 logger$3('send').log(_url);
3517 return this.loadScheme(_url, true);
3518 },
3519 users: function users(user_id) {
3520 var _context8;
3521
3522 var _url = concat$2(_context8 = "".concat(this.prefix, "://users/")).call(_context8, user_id);
3523
3524 logger$3('users').log(_url);
3525 return this.loadScheme(_url);
3526 },
3527 apps: function apps(app_id, params) {
3528 var _context9, _context10;
3529
3530 var _params = this.getQuery(params);
3531
3532 var _url = concat$2(_context9 = concat$2(_context10 = "".concat(this.prefix, "://apps/")).call(_context10, app_id)).call(_context9, _params);
3533
3534 logger$3('apps').log(_url);
3535 return this.loadScheme(_url);
3536 },
3537 conversations: function conversations(conversation_id) {
3538 var _context11;
3539
3540 var _url = concat$2(_context11 = "".concat(this.prefix, "://conversations/")).call(_context11, conversation_id);
3541
3542 logger$3('conversations').log(_url);
3543 return this.loadScheme(_url);
3544 }
3545};
3546var scheme = {
3547 prefix: SCHEME.prefix,
3548 pay: function pay(params) {
3549 if (!params.recipient || !params.asset || !params.amount) {
3550 logger$3('pay').error('The "recipient", "asset" and "amount" is required!');
3551 return;
3552 }
3553
3554 try {
3555 if (!params.trace) params.trace = uuid();
3556
3557 if (params.memo) {
3558 if (isObject$1(params.memo)) {
3559 params.memo = stringify$2(params.memo);
3560 }
3561
3562 params.memo = jsBase64.Base64.encode(params.memo);
3563
3564 if (params.memo.length > 140) {
3565 logger$3('pay').warn('The memo max length is 140!');
3566 }
3567 }
3568
3569 return {
3570 url: SCHEME.pay(params),
3571 params: params
3572 };
3573 } catch (err) {
3574 logger$3('pay').error(err);
3575 }
3576 },
3577 transfer: function transfer(recipient) {
3578 if (!recipient) {
3579 logger$3('transfer').error('The "recipient" is required!');
3580 return;
3581 }
3582
3583 try {
3584 return SCHEME.transfer(recipient);
3585 } catch (err) {
3586 logger$3('transfer').error(err);
3587 }
3588 },
3589 snapshot: function snapshot(params) {
3590 try {
3591 return SCHEME.snapshots(params);
3592 } catch (err) {
3593 logger$3('snapshot').error(err);
3594 }
3595 },
3596 withdrawal: function withdrawal(params) {
3597 try {
3598 if (!params.trace) params.trace = uuid();
3599
3600 if (params.memo) {
3601 if (isObject$1(params.memo)) {
3602 params.memo = stringify$2(params.memo);
3603 }
3604
3605 params.memo = jsBase64.Base64.encode(params.memo);
3606
3607 if (params.memo.length > 140) {
3608 logger$3('withdrawal').warn('The memo max length is 140!');
3609 }
3610 }
3611
3612 return {
3613 url: SCHEME.withdrawal(params),
3614 params: params
3615 };
3616 } catch (err) {
3617 logger$3('withdrawal').error(err);
3618 }
3619 },
3620 addWithdrawalAddress: function addWithdrawalAddress(params) {
3621 if (!params.asset || !params.label || !params.destination) {
3622 logger$3('addWithdrawalAddress').error('The "asset", "label" and "destination" is required!');
3623 return;
3624 }
3625
3626 try {
3627 return SCHEME.address(params);
3628 } catch (err) {
3629 logger$3('addWithdrawalAddress').error(err);
3630 }
3631 },
3632 delWithdrawalAddress: function delWithdrawalAddress(params) {
3633 if (!params.asset || !params.address) {
3634 logger$3('delWithdrawalAddress').error('The "asset" and "address" is required!');
3635 return;
3636 }
3637
3638 try {
3639 return SCHEME.address(assign$2(assign$2({}, params), {
3640 action: 'delete'
3641 }));
3642 } catch (err) {
3643 logger$3('delWithdrawalAddress').error(err);
3644 }
3645 },
3646 shareText: function shareText(txt) {
3647 if (!txt) {
3648 logger$3('shareText').error('The share text is required!');
3649 return;
3650 }
3651
3652 try {
3653 return SCHEME.send({
3654 category: 'text',
3655 data: txt
3656 });
3657 } catch (err) {
3658 logger$3('shareText').error(err);
3659 }
3660 },
3661 shareImage: function shareImage(url) {
3662 if (!url) {
3663 logger$3('shareImage').error('The share image url is required!');
3664 return;
3665 }
3666
3667 try {
3668 return SCHEME.send({
3669 category: 'image',
3670 data: {
3671 url: url
3672 }
3673 });
3674 } catch (err) {
3675 logger$3('shareImage').error(err);
3676 }
3677 },
3678 shareContact: function shareContact(user_id) {
3679 if (!user_id) {
3680 logger$3('shareContact').error('The "user_id" is required!');
3681 return;
3682 }
3683
3684 try {
3685 return SCHEME.send({
3686 category: 'contact',
3687 data: {
3688 user_id: user_id
3689 }
3690 });
3691 } catch (err) {
3692 logger$3('shareContact').error(err);
3693 }
3694 },
3695 shareCard: function shareCard(data) {
3696 if (!data.action || !data.app_id) {
3697 logger$3('shareCard').error('The "action" and "app_id" is required!');
3698 return;
3699 }
3700
3701 try {
3702 return SCHEME.send({
3703 category: 'app_card',
3704 data: data
3705 });
3706 } catch (err) {
3707 logger$3('shareCard').error(err);
3708 }
3709 },
3710 shareLive: function shareLive(data) {
3711 if (!data.url) {
3712 logger$3('shareLive').error('The "url" is required!');
3713 return;
3714 }
3715
3716 try {
3717 if (!data.height) data.height = 720;
3718 if (!data.width) data.width = 1280;
3719 return SCHEME.send({
3720 category: 'live',
3721 data: data
3722 });
3723 } catch (err) {
3724 logger$3('shareLive').error(err);
3725 }
3726 },
3727 sharePost: function sharePost(content) {
3728 if (!content) {
3729 logger$3('sharePost').error('The share content is required!');
3730 return;
3731 }
3732
3733 try {
3734 return SCHEME.send({
3735 category: 'post',
3736 data: content
3737 });
3738 } catch (err) {
3739 logger$3('sharePost').error(err);
3740 }
3741 },
3742 popupUser: function popupUser(user_id) {
3743 if (!user_id) {
3744 logger$3('popupUser').error('The "user_id" is required!');
3745 return;
3746 }
3747
3748 try {
3749 return SCHEME.users(user_id);
3750 } catch (err) {
3751 logger$3('popupUser').error(err);
3752 }
3753 },
3754 popupBot: function popupBot(params) {
3755 var app_id = params.app_id,
3756 rest = __rest(params, ["app_id"]);
3757
3758 if (!app_id) {
3759 logger$3('popupBot').error('The "app_id" is required!');
3760 return;
3761 }
3762
3763 try {
3764 return SCHEME.apps(app_id, rest);
3765 } catch (err) {
3766 logger$3('popupBot').error(err);
3767 }
3768 },
3769 conversation: function conversation(conversation_id) {
3770 if (!conversation_id) {
3771 logger$3('conversation').error('The "conversation_id" is required!');
3772 return;
3773 }
3774
3775 try {
3776 return SCHEME.conversations(conversation_id);
3777 } catch (err) {
3778 logger$3('conversation').error(err);
3779 }
3780 }
3781};var SUPPORT_APIS = {
3782 address_add: false,
3783 address_del: false,
3784 conversation: false,
3785 getContext: false,
3786 getUserInfo: true,
3787 login: true,
3788 logout: true,
3789 payment: false,
3790 playlist: false,
3791 popup_user: false,
3792 popup_bot: false,
3793 reloadTheme: false,
3794 requestToken: true,
3795 share_text: false,
3796 share_image: false,
3797 share_contact: false,
3798 share_app_card: false,
3799 share_live: false,
3800 share_post: false,
3801 showToast: false,
3802 snapshot: false,
3803 transfer: false,
3804 withdrawal: false
3805};
3806var Bridge = /*#__PURE__*/function () {
3807 function Bridge(config) {
3808 var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9;
3809
3810 classCallCheck(this, Bridge);
3811
3812 var _ref = config || {},
3813 debug = _ref.debug,
3814 logLevel = _ref.logLevel;
3815
3816 if (debug !== void 0) logger.setDebug(debug);
3817 if (logLevel !== void 0) logger.setLevel(logLevel);
3818 this.config = config;
3819 this._token = void 0;
3820 this._userInfo = void 0;
3821 this.logger = getLogger(); // public
3822
3823 this.getContext = bind$3(_context = this.getContext).call(_context, this);
3824 this.reloadTheme = bind$3(_context2 = this.reloadTheme).call(_context2, this);
3825 this.playlist = bind$3(_context3 = this.playlist).call(_context3, this);
3826 this.login = bind$3(_context4 = this.login).call(_context4, this);
3827 this.logout = bind$3(_context5 = this.logout).call(_context5, this);
3828 this.requestToken = bind$3(_context6 = this.requestToken).call(_context6, this);
3829 this.getUserInfo = bind$3(_context7 = this.getUserInfo).call(_context7, this); // private
3830
3831 this.getCode = bind$3(_context8 = this.getCode).call(_context8, this);
3832 this.handlerError = bind$3(_context9 = this.handlerError).call(_context9, this);
3833 }
3834 /**
3835 * get the app version
3836 */
3837
3838
3839 createClass(Bridge, [{
3840 key: "version",
3841 get: function get() {
3842 var app;
3843
3844 try {
3845 app = this.getContext();
3846 } catch (err) {
3847 this.logger('version').info(err);
3848 }
3849
3850 return app === null || app === void 0 ? void 0 : app.app_version;
3851 }
3852 /**
3853 * get the code which be used to get access-token
3854 */
3855
3856 }, {
3857 key: "code",
3858 get: function get() {
3859 return this.getCode();
3860 }
3861 /**
3862 * get the code-verifier which be used to get access-token
3863 */
3864
3865 }, {
3866 key: "codeVerifier",
3867 get: function get() {
3868 return store$2.get('$_mixin-code-verifier');
3869 }
3870 /**
3871 * get conversation id
3872 */
3873
3874 }, {
3875 key: "conversationId",
3876 get: function get() {
3877 var _a, _b;
3878
3879 return (_b = (_a = this.getContext()) === null || _a === void 0 ? void 0 : _a.conversation_id) !== null && _b !== void 0 ? _b : void 0;
3880 }
3881 /**
3882 * get API support info
3883 */
3884
3885 }, {
3886 key: "supportAPIs",
3887 get: function get() {
3888 var res = assign$2({}, SUPPORT_APIS);
3889
3890 if (this.isMixin) {
3891 var _context10;
3892
3893 var featVersion = {
3894 mixin: {
3895 address_add: 0,
3896 address_del: 0,
3897 conversation: 311,
3898 getContext: 0,
3899 getUserInfo: 0,
3900 login: 0,
3901 logout: 0,
3902 payment: 0,
3903 playlist: 300,
3904 popup_user: 0,
3905 popup_bot: 290,
3906 reloadTheme: 0,
3907 requestToken: 0,
3908 share_text: 0,
3909 share_image: 0,
3910 share_contact: 0,
3911 share_app_card: 0,
3912 share_live: 0,
3913 share_post: 0,
3914 showToast: 0,
3915 snapshot: 0,
3916 transfer: 0,
3917 withdrawal: 0
3918 },
3919 reborn: {
3920 address_add: 0,
3921 address_del: 0,
3922 conversation: 1121,
3923 getContext: 0,
3924 getUserInfo: 0,
3925 login: 0,
3926 logout: 0,
3927 payment: 0,
3928 playlist: 1100,
3929 popup_user: 0,
3930 popup_bot: 1100,
3931 reloadTheme: 0,
3932 requestToken: 0,
3933 share_text: 0,
3934 share_image: 0,
3935 share_contact: 0,
3936 share_app_card: 0,
3937 share_live: 0,
3938 share_post: 0,
3939 showToast: 0,
3940 snapshot: 0,
3941 transfer: 0,
3942 withdrawal: 0
3943 }
3944 };
3945 var verNum = +this.version.split('.').join('');
3946 var featList = featVersion[this.isReborn ? 'reborn' : 'mixin'];
3947
3948 forEach$2(_context10 = keys$3(featList)).call(_context10, function (feat) {
3949 res[feat] = verNum >= featList[feat];
3950 });
3951 }
3952
3953 return res;
3954 }
3955 /**
3956 * judgement whether or not in mixin or reborn app
3957 */
3958
3959 }, {
3960 key: "isMixin",
3961 get: function get() {
3962 var _a, _b, _c;
3963
3964 var isIOS = env().isIOS;
3965 return !!(isIOS ? (_b = (_a = window === null || window === void 0 ? void 0 : window.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b.MixinContext : (window === null || window === void 0 ? void 0 : window.MixinContext) && typeof ((_c = window === null || window === void 0 ? void 0 : window.MixinContext) === null || _c === void 0 ? void 0 : _c.getContext) === 'function');
3966 }
3967 /**
3968 * judgement whether or not in reborn app
3969 */
3970
3971 }, {
3972 key: "isReborn",
3973 get: function get() {
3974 return /XUEXI/.test(navigator.userAgent);
3975 }
3976 /**
3977 * get access token
3978 */
3979
3980 }, {
3981 key: "token",
3982 get: function get() {
3983 var _a;
3984
3985 return (_a = this._token) !== null && _a !== void 0 ? _a : store$2.get('$_mixin-token');
3986 }
3987 /**
3988 * get mixin app context
3989 */
3990
3991 }, {
3992 key: "getContext",
3993 value: function getContext() {
3994 if (!this.isMixin) {
3995 this.logger('getContext').log('Please call in reborn or mixin app!');
3996 return;
3997 }
3998
3999 try {
4000 var ctx = messager('getContext')();
4001
4002 if (typeof ctx === 'string') {
4003 try {
4004 ctx = JSON.parse(ctx);
4005 } catch (err) {
4006 this.logger('getContext').info(err);
4007 }
4008 }
4009
4010 if (ctx) ctx.platform = (ctx === null || ctx === void 0 ? void 0 : ctx.platform) || (env().isIOS ? 'iOS' : 'Android');
4011 return ctx;
4012 } catch (err) {
4013 this.handlerError(err, 'getContext');
4014 return;
4015 }
4016 }
4017 /**
4018 * reload the theme according to theme-color
4019 */
4020
4021 }, {
4022 key: "reloadTheme",
4023 value: function reloadTheme() {
4024 if (!this.isMixin) {
4025 this.logger('reloadTheme').log('Please call in reborn or mixin app!');
4026 return;
4027 }
4028
4029 try {
4030 var reloadTheme = messager('reloadTheme');
4031 env().isIOS ? reloadTheme('') : reloadTheme();
4032 } catch (err) {
4033 this.handlerError(err, 'reloadTheme');
4034 }
4035 }
4036 /**
4037 * call native message window
4038 * Android Only
4039 */
4040
4041 }, {
4042 key: "showToast",
4043 value: function showToast(msg) {
4044 if (!this.isMixin) {
4045 this.logger('showToast').log('Please call in reborn or mixin app!');
4046 return;
4047 }
4048
4049 try {
4050 messager('showToast')(msg);
4051 } catch (err) {
4052 this.handlerError(err, 'showToast');
4053 }
4054 }
4055 /**
4056 * play audio by mixin native player
4057 */
4058
4059 }, {
4060 key: "playlist",
4061 value: function playlist(src) {
4062 if (!this.isMixin) {
4063 this.logger('playlist').log('Please call in reborn or mixin app!');
4064 return;
4065 }
4066
4067 try {
4068 messager('playlist')(src);
4069 } catch (err) {
4070 this.handlerError(err, 'playlist');
4071 }
4072 }
4073 /**
4074 * go login page
4075 * @type { phone?: boolean | number; profile?: boolean | number; contacts?: boolean | number; assets?: boolean | number; snapshots?: boolean | number; messages?: boolean | number; code_challenge?: boolean; } AUTH
4076 */
4077
4078 }, {
4079 key: "login",
4080 value: function login(auth, params) {
4081 var _ref2 = this.config || {},
4082 client_id = _ref2.client_id;
4083
4084 var cid = (params === null || params === void 0 ? void 0 : params.client_id) || client_id;
4085
4086 if (!cid) {
4087 this.logger('login').warn('Please pass client_id first!');
4088 return;
4089 }
4090
4091 getAccessCode(assign$2(assign$2({}, params), {
4092 client_id: cid,
4093 auth: auth
4094 }));
4095 }
4096 /**
4097 * do logout
4098 * @param reload whether reload the page
4099 */
4100
4101 }, {
4102 key: "logout",
4103 value: function logout() {
4104 var reload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
4105 store$2.clear('$_mixin-token');
4106 store$2.clear('$_mixin-code-verifier');
4107 store$2.clear('$_mixin-user-info');
4108 if (reload) window.location.reload();
4109 }
4110 /**
4111 * request access-token by code
4112 * @param params request params
4113 * @param persistence whether persist the code
4114 * @returns
4115 */
4116
4117 }, {
4118 key: "requestToken",
4119 value: function requestToken(params) {
4120 var _this = this;
4121
4122 var persistence = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
4123
4124 var _ref3 = this.config || {},
4125 client_id_config = _ref3.client_id;
4126
4127 var _ref4 = params || {},
4128 code_params = _ref4.code,
4129 code_verifier_params = _ref4.code_verifier,
4130 client_id_params = _ref4.client_id;
4131
4132 var client_id = client_id_params || client_id_config;
4133 var code = code_params || this.getCode();
4134 var code_verifier = code_verifier_params || store$2.get('$_mixin-code-verifier');
4135
4136 if (!client_id || !code_verifier || !code) {
4137 this.logger('requestToken').warn('The request parameters which contain client_id, access_code and code_verifier is not correct!');
4138 return promise$3.resolve(null);
4139 }
4140
4141 return new promise$3(function (resolve, reject) {
4142 getAccessToken({
4143 code: code,
4144 code_verifier: code_verifier,
4145 client_id: client_id
4146 }).then(function (token) {
4147 _this._token = token;
4148 if (persistence) store$2.set('$_mixin-token', token);
4149 resolve(token);
4150 })["catch"](function (err) {
4151 _this.handlerError(err, 'requestToken', 'get token failed!');
4152
4153 reject(err);
4154 });
4155 });
4156 }
4157 /**
4158 * get user infomations by request https://api.mixin.one/me API
4159 */
4160
4161 }, {
4162 key: "getUserInfo",
4163 value: function getUserInfo(token) {
4164 var _this2 = this;
4165
4166 var _a, _b;
4167
4168 if (token === void 0) {
4169 token = (_a = this.token) !== null && _a !== void 0 ? _a : '';
4170 }
4171
4172 if (!token) {
4173 this.logger('getUserInfo').warn('The access_token is invalid!');
4174 return promise$3.resolve(null);
4175 }
4176
4177 try {
4178 var cache = store$2.get('$_mixin-user-info');
4179 var userInfo = ((_b = this._userInfo) !== null && _b !== void 0 ? _b : cache) ? JSON.parse(cache) : '';
4180
4181 if (userInfo) {
4182 this.logger('getUserInfo').log('through cache!');
4183 return promise$3.resolve(userInfo);
4184 }
4185 } catch (err) {
4186 this.logger('getUserInfo').info(err);
4187 }
4188
4189 this.logger('getUserInfo').log('http request!');
4190 return request({
4191 url: 'https://api.mixin.one/me',
4192 method: 'GET',
4193 headers: {
4194 'Content-Type': 'application/json',
4195 Authorization: "Bearer ".concat(token)
4196 },
4197 withCredentials: false
4198 }).then(function (res) {
4199 var data = res.data;
4200
4201 if (data) {
4202 _this2._userInfo = data;
4203 store$2.set('$_mixin-user-info', stringify$2(data));
4204 }
4205
4206 return data;
4207 });
4208 }
4209 /**
4210 * evoke payment checkout by generate pay scheme-url
4211 * @type { recipient: string; asset: string; amount: string; trace?: string; memo?: string | Record<string, string>; } PARAMS_PAYMENT
4212 */
4213
4214 }, {
4215 key: "payment",
4216 value: function payment(params) {
4217 return scheme.pay(params);
4218 }
4219 /**
4220 * evoke transfer checkout by generate pay scheme-url
4221 * @param recipient recipient id
4222 */
4223
4224 }, {
4225 key: "transfer",
4226 value: function transfer(recipient) {
4227 return scheme.transfer(recipient);
4228 }
4229 /**
4230 * evoke transfer detail by generate snapshots scheme-url
4231 * @type { trace_id?: string; snapshot_id?: string; } PARAMS_SNAPSHOTS
4232 */
4233
4234 }, {
4235 key: "snapshot",
4236 value: function snapshot(params) {
4237 return scheme.snapshot(params);
4238 }
4239 /**
4240 * evoke withdrawal of an asset by generate withdrawal scheme-url
4241 * @type { address: string; asset: string; amount: string; trace?: string; memo?: string | Record<string, string>; } PARAMS_WITHDRAWAL
4242 */
4243
4244 }, {
4245 key: "withdrawal",
4246 value: function withdrawal(params) {
4247 return scheme.withdrawal(params);
4248 }
4249 }, {
4250 key: "address",
4251 value: function address(type, params) {
4252 switch (type) {
4253 case 'add':
4254 return scheme.addWithdrawalAddress(params);
4255
4256 case 'del':
4257 return scheme.delWithdrawalAddress(params);
4258 }
4259 }
4260 }, {
4261 key: "share",
4262 value: function share(category, params) {
4263 var shareAction;
4264
4265 switch (category) {
4266 case 'text':
4267 shareAction = scheme.shareText;
4268 break;
4269
4270 case 'post':
4271 shareAction = scheme.sharePost;
4272 break;
4273
4274 case 'live':
4275 shareAction = scheme.shareLive;
4276 break;
4277
4278 case 'image':
4279 shareAction = scheme.shareImage;
4280 break;
4281
4282 case 'app_card':
4283 shareAction = scheme.shareCard;
4284 break;
4285
4286 case 'contact':
4287 shareAction = scheme.shareContact;
4288 break;
4289 }
4290
4291 return shareAction === null || shareAction === void 0 ? void 0 : shareAction(params);
4292 }
4293 }, {
4294 key: "popup",
4295 value: function popup(type, params) {
4296 switch (type) {
4297 case 'user':
4298 return scheme.popupUser(params);
4299
4300 case 'bot':
4301 return scheme.popupBot(params);
4302 }
4303 }
4304 /**
4305 * evoke conversation by generate conversations scheme-url
4306 * @param recipient conversation id
4307 */
4308
4309 }, {
4310 key: "conversation",
4311 value: function conversation(conversation_id) {
4312 return scheme.conversation(conversation_id);
4313 }
4314 }, {
4315 key: "getCode",
4316 value: function getCode() {
4317 var _a, _b, _c;
4318
4319 var parseData = parseUrl.parseUrl(window.location.href);
4320
4321 if (typeof parseData !== 'string') {
4322 var hash = parseData.hash,
4323 search = parseData.search;
4324 var regExp = /code=([^&#]*)/g;
4325 var code = (_b = (_a = regExp.exec(search)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : (_c = regExp.exec(hash)) === null || _c === void 0 ? void 0 : _c[1];
4326 return code;
4327 }
4328 }
4329 }, {
4330 key: "handlerError",
4331 value: function handlerError(err) {
4332 var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
4333 var msg = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'oops! some error has ocurred!';
4334
4335 var _parseError = parseError(err),
4336 _parseError$message = _parseError.message,
4337 message = _parseError$message === void 0 ? '' : _parseError$message,
4338 _parseError$stack = _parseError.stack,
4339 stack = _parseError$stack === void 0 ? '' : _parseError$stack,
4340 _parseError$name = _parseError.name,
4341 name = _parseError$name === void 0 ? '' : _parseError$name;
4342
4343 if (name) name = "(".concat(name, "): ");
4344 if (stack) stack = " at ".concat(stack);
4345 this.logger(prefix).error("\uD83D\uDC47 ".concat(msg, " \u274C"), '\n', name, message, stack);
4346 }
4347 }]);
4348
4349 return Bridge;
4350}();exports.Bridge=Bridge;exports.default=Bridge;
\No newline at end of file