@ninetailed/experience.js 3.0.1-beta.4 → 3.0.2-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs ADDED
@@ -0,0 +1,4343 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var unionBy = require('lodash/unionBy');
6
+ var experience_jsShared = require('@ninetailed/experience.js-shared');
7
+ var Analytics = require('analytics');
8
+ var experience_jsPluginAnalytics = require('@ninetailed/experience.js-plugin-analytics');
9
+ var flatten = require('lodash/flatten');
10
+ var find = require('lodash/find');
11
+ var includes = require('lodash/includes');
12
+ var pickBy = require('lodash/pickBy');
13
+ var murmurhashJs = require('murmurhash-js');
14
+
15
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
16
+
17
+ var unionBy__default = /*#__PURE__*/_interopDefaultLegacy(unionBy);
18
+ var Analytics__default = /*#__PURE__*/_interopDefaultLegacy(Analytics);
19
+ var flatten__default = /*#__PURE__*/_interopDefaultLegacy(flatten);
20
+ var find__default = /*#__PURE__*/_interopDefaultLegacy(find);
21
+ var includes__default = /*#__PURE__*/_interopDefaultLegacy(includes);
22
+ var pickBy__default = /*#__PURE__*/_interopDefaultLegacy(pickBy);
23
+
24
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
25
+
26
+ var check = function (it) {
27
+ return it && it.Math == Math && it;
28
+ };
29
+
30
+ // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
31
+ var global$n =
32
+ // eslint-disable-next-line es/no-global-this -- safe
33
+ check(typeof globalThis == 'object' && globalThis) ||
34
+ check(typeof window == 'object' && window) ||
35
+ // eslint-disable-next-line no-restricted-globals -- safe
36
+ check(typeof self == 'object' && self) ||
37
+ check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
38
+ // eslint-disable-next-line no-new-func -- fallback
39
+ (function () { return this; })() || Function('return this')();
40
+
41
+ var objectGetOwnPropertyDescriptor = {};
42
+
43
+ var fails$m = function (exec) {
44
+ try {
45
+ return !!exec();
46
+ } catch (error) {
47
+ return true;
48
+ }
49
+ };
50
+
51
+ var fails$l = fails$m;
52
+
53
+ // Detect IE8's incomplete defineProperty implementation
54
+ var descriptors = !fails$l(function () {
55
+ // eslint-disable-next-line es/no-object-defineproperty -- required for testing
56
+ return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
57
+ });
58
+
59
+ var fails$k = fails$m;
60
+
61
+ var functionBindNative = !fails$k(function () {
62
+ // eslint-disable-next-line es/no-function-prototype-bind -- safe
63
+ var test = (function () { /* empty */ }).bind();
64
+ // eslint-disable-next-line no-prototype-builtins -- safe
65
+ return typeof test != 'function' || test.hasOwnProperty('prototype');
66
+ });
67
+
68
+ var NATIVE_BIND$3 = functionBindNative;
69
+
70
+ var call$i = Function.prototype.call;
71
+
72
+ var functionCall = NATIVE_BIND$3 ? call$i.bind(call$i) : function () {
73
+ return call$i.apply(call$i, arguments);
74
+ };
75
+
76
+ var objectPropertyIsEnumerable = {};
77
+
78
+ var $propertyIsEnumerable = {}.propertyIsEnumerable;
79
+ // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
80
+ var getOwnPropertyDescriptor$3 = Object.getOwnPropertyDescriptor;
81
+
82
+ // Nashorn ~ JDK8 bug
83
+ var NASHORN_BUG = getOwnPropertyDescriptor$3 && !$propertyIsEnumerable.call({ 1: 2 }, 1);
84
+
85
+ // `Object.prototype.propertyIsEnumerable` method implementation
86
+ // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
87
+ objectPropertyIsEnumerable.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
88
+ var descriptor = getOwnPropertyDescriptor$3(this, V);
89
+ return !!descriptor && descriptor.enumerable;
90
+ } : $propertyIsEnumerable;
91
+
92
+ var createPropertyDescriptor$3 = function (bitmap, value) {
93
+ return {
94
+ enumerable: !(bitmap & 1),
95
+ configurable: !(bitmap & 2),
96
+ writable: !(bitmap & 4),
97
+ value: value
98
+ };
99
+ };
100
+
101
+ var NATIVE_BIND$2 = functionBindNative;
102
+
103
+ var FunctionPrototype$2 = Function.prototype;
104
+ var call$h = FunctionPrototype$2.call;
105
+ var uncurryThisWithBind = NATIVE_BIND$2 && FunctionPrototype$2.bind.bind(call$h, call$h);
106
+
107
+ var functionUncurryThis = NATIVE_BIND$2 ? uncurryThisWithBind : function (fn) {
108
+ return function () {
109
+ return call$h.apply(fn, arguments);
110
+ };
111
+ };
112
+
113
+ var uncurryThis$m = functionUncurryThis;
114
+
115
+ var toString$9 = uncurryThis$m({}.toString);
116
+ var stringSlice$5 = uncurryThis$m(''.slice);
117
+
118
+ var classofRaw$2 = function (it) {
119
+ return stringSlice$5(toString$9(it), 8, -1);
120
+ };
121
+
122
+ var uncurryThis$l = functionUncurryThis;
123
+ var fails$j = fails$m;
124
+ var classof$7 = classofRaw$2;
125
+
126
+ var $Object$4 = Object;
127
+ var split = uncurryThis$l(''.split);
128
+
129
+ // fallback for non-array-like ES3 and non-enumerable old V8 strings
130
+ var indexedObject = fails$j(function () {
131
+ // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
132
+ // eslint-disable-next-line no-prototype-builtins -- safe
133
+ return !$Object$4('z').propertyIsEnumerable(0);
134
+ }) ? function (it) {
135
+ return classof$7(it) == 'String' ? split(it, '') : $Object$4(it);
136
+ } : $Object$4;
137
+
138
+ // we can't use just `it == null` since of `document.all` special case
139
+ // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-aec
140
+ var isNullOrUndefined$5 = function (it) {
141
+ return it === null || it === undefined;
142
+ };
143
+
144
+ var isNullOrUndefined$4 = isNullOrUndefined$5;
145
+
146
+ var $TypeError$f = TypeError;
147
+
148
+ // `RequireObjectCoercible` abstract operation
149
+ // https://tc39.es/ecma262/#sec-requireobjectcoercible
150
+ var requireObjectCoercible$7 = function (it) {
151
+ if (isNullOrUndefined$4(it)) throw $TypeError$f("Can't call method on " + it);
152
+ return it;
153
+ };
154
+
155
+ // toObject with fallback for non-array-like ES3 strings
156
+ var IndexedObject$2 = indexedObject;
157
+ var requireObjectCoercible$6 = requireObjectCoercible$7;
158
+
159
+ var toIndexedObject$5 = function (it) {
160
+ return IndexedObject$2(requireObjectCoercible$6(it));
161
+ };
162
+
163
+ var documentAll$2 = typeof document == 'object' && document.all;
164
+
165
+ // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
166
+ var IS_HTMLDDA = typeof documentAll$2 == 'undefined' && documentAll$2 !== undefined;
167
+
168
+ var documentAll_1 = {
169
+ all: documentAll$2,
170
+ IS_HTMLDDA: IS_HTMLDDA
171
+ };
172
+
173
+ var $documentAll$1 = documentAll_1;
174
+
175
+ var documentAll$1 = $documentAll$1.all;
176
+
177
+ // `IsCallable` abstract operation
178
+ // https://tc39.es/ecma262/#sec-iscallable
179
+ var isCallable$m = $documentAll$1.IS_HTMLDDA ? function (argument) {
180
+ return typeof argument == 'function' || argument === documentAll$1;
181
+ } : function (argument) {
182
+ return typeof argument == 'function';
183
+ };
184
+
185
+ var isCallable$l = isCallable$m;
186
+ var $documentAll = documentAll_1;
187
+
188
+ var documentAll = $documentAll.all;
189
+
190
+ var isObject$9 = $documentAll.IS_HTMLDDA ? function (it) {
191
+ return typeof it == 'object' ? it !== null : isCallable$l(it) || it === documentAll;
192
+ } : function (it) {
193
+ return typeof it == 'object' ? it !== null : isCallable$l(it);
194
+ };
195
+
196
+ var global$m = global$n;
197
+ var isCallable$k = isCallable$m;
198
+
199
+ var aFunction = function (argument) {
200
+ return isCallable$k(argument) ? argument : undefined;
201
+ };
202
+
203
+ var getBuiltIn$8 = function (namespace, method) {
204
+ return arguments.length < 2 ? aFunction(global$m[namespace]) : global$m[namespace] && global$m[namespace][method];
205
+ };
206
+
207
+ var uncurryThis$k = functionUncurryThis;
208
+
209
+ var objectIsPrototypeOf = uncurryThis$k({}.isPrototypeOf);
210
+
211
+ var getBuiltIn$7 = getBuiltIn$8;
212
+
213
+ var engineUserAgent = getBuiltIn$7('navigator', 'userAgent') || '';
214
+
215
+ var global$l = global$n;
216
+ var userAgent$3 = engineUserAgent;
217
+
218
+ var process$3 = global$l.process;
219
+ var Deno$1 = global$l.Deno;
220
+ var versions = process$3 && process$3.versions || Deno$1 && Deno$1.version;
221
+ var v8 = versions && versions.v8;
222
+ var match, version;
223
+
224
+ if (v8) {
225
+ match = v8.split('.');
226
+ // in old Chrome, versions of V8 isn't V8 = Chrome / 10
227
+ // but their correct versions are not interesting for us
228
+ version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
229
+ }
230
+
231
+ // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
232
+ // so check `userAgent` even if `.v8` exists, but 0
233
+ if (!version && userAgent$3) {
234
+ match = userAgent$3.match(/Edge\/(\d+)/);
235
+ if (!match || match[1] >= 74) {
236
+ match = userAgent$3.match(/Chrome\/(\d+)/);
237
+ if (match) version = +match[1];
238
+ }
239
+ }
240
+
241
+ var engineV8Version = version;
242
+
243
+ /* eslint-disable es/no-symbol -- required for testing */
244
+
245
+ var V8_VERSION$1 = engineV8Version;
246
+ var fails$i = fails$m;
247
+
248
+ // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
249
+ var symbolConstructorDetection = !!Object.getOwnPropertySymbols && !fails$i(function () {
250
+ var symbol = Symbol();
251
+ // Chrome 38 Symbol has incorrect toString conversion
252
+ // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
253
+ return !String(symbol) || !(Object(symbol) instanceof Symbol) ||
254
+ // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
255
+ !Symbol.sham && V8_VERSION$1 && V8_VERSION$1 < 41;
256
+ });
257
+
258
+ /* eslint-disable es/no-symbol -- required for testing */
259
+
260
+ var NATIVE_SYMBOL$1 = symbolConstructorDetection;
261
+
262
+ var useSymbolAsUid = NATIVE_SYMBOL$1
263
+ && !Symbol.sham
264
+ && typeof Symbol.iterator == 'symbol';
265
+
266
+ var getBuiltIn$6 = getBuiltIn$8;
267
+ var isCallable$j = isCallable$m;
268
+ var isPrototypeOf$3 = objectIsPrototypeOf;
269
+ var USE_SYMBOL_AS_UID$1 = useSymbolAsUid;
270
+
271
+ var $Object$3 = Object;
272
+
273
+ var isSymbol$2 = USE_SYMBOL_AS_UID$1 ? function (it) {
274
+ return typeof it == 'symbol';
275
+ } : function (it) {
276
+ var $Symbol = getBuiltIn$6('Symbol');
277
+ return isCallable$j($Symbol) && isPrototypeOf$3($Symbol.prototype, $Object$3(it));
278
+ };
279
+
280
+ var $String$3 = String;
281
+
282
+ var tryToString$4 = function (argument) {
283
+ try {
284
+ return $String$3(argument);
285
+ } catch (error) {
286
+ return 'Object';
287
+ }
288
+ };
289
+
290
+ var isCallable$i = isCallable$m;
291
+ var tryToString$3 = tryToString$4;
292
+
293
+ var $TypeError$e = TypeError;
294
+
295
+ // `Assert: IsCallable(argument) is true`
296
+ var aCallable$8 = function (argument) {
297
+ if (isCallable$i(argument)) return argument;
298
+ throw $TypeError$e(tryToString$3(argument) + ' is not a function');
299
+ };
300
+
301
+ var aCallable$7 = aCallable$8;
302
+ var isNullOrUndefined$3 = isNullOrUndefined$5;
303
+
304
+ // `GetMethod` abstract operation
305
+ // https://tc39.es/ecma262/#sec-getmethod
306
+ var getMethod$4 = function (V, P) {
307
+ var func = V[P];
308
+ return isNullOrUndefined$3(func) ? undefined : aCallable$7(func);
309
+ };
310
+
311
+ var call$g = functionCall;
312
+ var isCallable$h = isCallable$m;
313
+ var isObject$8 = isObject$9;
314
+
315
+ var $TypeError$d = TypeError;
316
+
317
+ // `OrdinaryToPrimitive` abstract operation
318
+ // https://tc39.es/ecma262/#sec-ordinarytoprimitive
319
+ var ordinaryToPrimitive$1 = function (input, pref) {
320
+ var fn, val;
321
+ if (pref === 'string' && isCallable$h(fn = input.toString) && !isObject$8(val = call$g(fn, input))) return val;
322
+ if (isCallable$h(fn = input.valueOf) && !isObject$8(val = call$g(fn, input))) return val;
323
+ if (pref !== 'string' && isCallable$h(fn = input.toString) && !isObject$8(val = call$g(fn, input))) return val;
324
+ throw $TypeError$d("Can't convert object to primitive value");
325
+ };
326
+
327
+ var shared$4 = {exports: {}};
328
+
329
+ var global$k = global$n;
330
+
331
+ // eslint-disable-next-line es/no-object-defineproperty -- safe
332
+ var defineProperty$5 = Object.defineProperty;
333
+
334
+ var defineGlobalProperty$3 = function (key, value) {
335
+ try {
336
+ defineProperty$5(global$k, key, { value: value, configurable: true, writable: true });
337
+ } catch (error) {
338
+ global$k[key] = value;
339
+ } return value;
340
+ };
341
+
342
+ var global$j = global$n;
343
+ var defineGlobalProperty$2 = defineGlobalProperty$3;
344
+
345
+ var SHARED = '__core-js_shared__';
346
+ var store$3 = global$j[SHARED] || defineGlobalProperty$2(SHARED, {});
347
+
348
+ var sharedStore = store$3;
349
+
350
+ var store$2 = sharedStore;
351
+
352
+ (shared$4.exports = function (key, value) {
353
+ return store$2[key] || (store$2[key] = value !== undefined ? value : {});
354
+ })('versions', []).push({
355
+ version: '3.26.1',
356
+ mode: 'global',
357
+ copyright: '© 2014-2022 Denis Pushkarev (zloirock.ru)',
358
+ license: 'https://github.com/zloirock/core-js/blob/v3.26.1/LICENSE',
359
+ source: 'https://github.com/zloirock/core-js'
360
+ });
361
+
362
+ var requireObjectCoercible$5 = requireObjectCoercible$7;
363
+
364
+ var $Object$2 = Object;
365
+
366
+ // `ToObject` abstract operation
367
+ // https://tc39.es/ecma262/#sec-toobject
368
+ var toObject$5 = function (argument) {
369
+ return $Object$2(requireObjectCoercible$5(argument));
370
+ };
371
+
372
+ var uncurryThis$j = functionUncurryThis;
373
+ var toObject$4 = toObject$5;
374
+
375
+ var hasOwnProperty = uncurryThis$j({}.hasOwnProperty);
376
+
377
+ // `HasOwnProperty` abstract operation
378
+ // https://tc39.es/ecma262/#sec-hasownproperty
379
+ // eslint-disable-next-line es/no-object-hasown -- safe
380
+ var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
381
+ return hasOwnProperty(toObject$4(it), key);
382
+ };
383
+
384
+ var uncurryThis$i = functionUncurryThis;
385
+
386
+ var id = 0;
387
+ var postfix = Math.random();
388
+ var toString$8 = uncurryThis$i(1.0.toString);
389
+
390
+ var uid$2 = function (key) {
391
+ return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$8(++id + postfix, 36);
392
+ };
393
+
394
+ var global$i = global$n;
395
+ var shared$3 = shared$4.exports;
396
+ var hasOwn$a = hasOwnProperty_1;
397
+ var uid$1 = uid$2;
398
+ var NATIVE_SYMBOL = symbolConstructorDetection;
399
+ var USE_SYMBOL_AS_UID = useSymbolAsUid;
400
+
401
+ var WellKnownSymbolsStore = shared$3('wks');
402
+ var Symbol$2 = global$i.Symbol;
403
+ var symbolFor = Symbol$2 && Symbol$2['for'];
404
+ var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$2 : Symbol$2 && Symbol$2.withoutSetter || uid$1;
405
+
406
+ var wellKnownSymbol$i = function (name) {
407
+ if (!hasOwn$a(WellKnownSymbolsStore, name) || !(NATIVE_SYMBOL || typeof WellKnownSymbolsStore[name] == 'string')) {
408
+ var description = 'Symbol.' + name;
409
+ if (NATIVE_SYMBOL && hasOwn$a(Symbol$2, name)) {
410
+ WellKnownSymbolsStore[name] = Symbol$2[name];
411
+ } else if (USE_SYMBOL_AS_UID && symbolFor) {
412
+ WellKnownSymbolsStore[name] = symbolFor(description);
413
+ } else {
414
+ WellKnownSymbolsStore[name] = createWellKnownSymbol(description);
415
+ }
416
+ } return WellKnownSymbolsStore[name];
417
+ };
418
+
419
+ var call$f = functionCall;
420
+ var isObject$7 = isObject$9;
421
+ var isSymbol$1 = isSymbol$2;
422
+ var getMethod$3 = getMethod$4;
423
+ var ordinaryToPrimitive = ordinaryToPrimitive$1;
424
+ var wellKnownSymbol$h = wellKnownSymbol$i;
425
+
426
+ var $TypeError$c = TypeError;
427
+ var TO_PRIMITIVE = wellKnownSymbol$h('toPrimitive');
428
+
429
+ // `ToPrimitive` abstract operation
430
+ // https://tc39.es/ecma262/#sec-toprimitive
431
+ var toPrimitive$1 = function (input, pref) {
432
+ if (!isObject$7(input) || isSymbol$1(input)) return input;
433
+ var exoticToPrim = getMethod$3(input, TO_PRIMITIVE);
434
+ var result;
435
+ if (exoticToPrim) {
436
+ if (pref === undefined) pref = 'default';
437
+ result = call$f(exoticToPrim, input, pref);
438
+ if (!isObject$7(result) || isSymbol$1(result)) return result;
439
+ throw $TypeError$c("Can't convert object to primitive value");
440
+ }
441
+ if (pref === undefined) pref = 'number';
442
+ return ordinaryToPrimitive(input, pref);
443
+ };
444
+
445
+ var toPrimitive = toPrimitive$1;
446
+ var isSymbol = isSymbol$2;
447
+
448
+ // `ToPropertyKey` abstract operation
449
+ // https://tc39.es/ecma262/#sec-topropertykey
450
+ var toPropertyKey$2 = function (argument) {
451
+ var key = toPrimitive(argument, 'string');
452
+ return isSymbol(key) ? key : key + '';
453
+ };
454
+
455
+ var global$h = global$n;
456
+ var isObject$6 = isObject$9;
457
+
458
+ var document$3 = global$h.document;
459
+ // typeof document.createElement is 'object' in old IE
460
+ var EXISTS$1 = isObject$6(document$3) && isObject$6(document$3.createElement);
461
+
462
+ var documentCreateElement$2 = function (it) {
463
+ return EXISTS$1 ? document$3.createElement(it) : {};
464
+ };
465
+
466
+ var DESCRIPTORS$a = descriptors;
467
+ var fails$h = fails$m;
468
+ var createElement$1 = documentCreateElement$2;
469
+
470
+ // Thanks to IE8 for its funny defineProperty
471
+ var ie8DomDefine = !DESCRIPTORS$a && !fails$h(function () {
472
+ // eslint-disable-next-line es/no-object-defineproperty -- required for testing
473
+ return Object.defineProperty(createElement$1('div'), 'a', {
474
+ get: function () { return 7; }
475
+ }).a != 7;
476
+ });
477
+
478
+ var DESCRIPTORS$9 = descriptors;
479
+ var call$e = functionCall;
480
+ var propertyIsEnumerableModule$1 = objectPropertyIsEnumerable;
481
+ var createPropertyDescriptor$2 = createPropertyDescriptor$3;
482
+ var toIndexedObject$4 = toIndexedObject$5;
483
+ var toPropertyKey$1 = toPropertyKey$2;
484
+ var hasOwn$9 = hasOwnProperty_1;
485
+ var IE8_DOM_DEFINE$1 = ie8DomDefine;
486
+
487
+ // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
488
+ var $getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
489
+
490
+ // `Object.getOwnPropertyDescriptor` method
491
+ // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
492
+ objectGetOwnPropertyDescriptor.f = DESCRIPTORS$9 ? $getOwnPropertyDescriptor$1 : function getOwnPropertyDescriptor(O, P) {
493
+ O = toIndexedObject$4(O);
494
+ P = toPropertyKey$1(P);
495
+ if (IE8_DOM_DEFINE$1) try {
496
+ return $getOwnPropertyDescriptor$1(O, P);
497
+ } catch (error) { /* empty */ }
498
+ if (hasOwn$9(O, P)) return createPropertyDescriptor$2(!call$e(propertyIsEnumerableModule$1.f, O, P), O[P]);
499
+ };
500
+
501
+ var objectDefineProperty = {};
502
+
503
+ var DESCRIPTORS$8 = descriptors;
504
+ var fails$g = fails$m;
505
+
506
+ // V8 ~ Chrome 36-
507
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3334
508
+ var v8PrototypeDefineBug = DESCRIPTORS$8 && fails$g(function () {
509
+ // eslint-disable-next-line es/no-object-defineproperty -- required for testing
510
+ return Object.defineProperty(function () { /* empty */ }, 'prototype', {
511
+ value: 42,
512
+ writable: false
513
+ }).prototype != 42;
514
+ });
515
+
516
+ var isObject$5 = isObject$9;
517
+
518
+ var $String$2 = String;
519
+ var $TypeError$b = TypeError;
520
+
521
+ // `Assert: Type(argument) is Object`
522
+ var anObject$e = function (argument) {
523
+ if (isObject$5(argument)) return argument;
524
+ throw $TypeError$b($String$2(argument) + ' is not an object');
525
+ };
526
+
527
+ var DESCRIPTORS$7 = descriptors;
528
+ var IE8_DOM_DEFINE = ie8DomDefine;
529
+ var V8_PROTOTYPE_DEFINE_BUG$1 = v8PrototypeDefineBug;
530
+ var anObject$d = anObject$e;
531
+ var toPropertyKey = toPropertyKey$2;
532
+
533
+ var $TypeError$a = TypeError;
534
+ // eslint-disable-next-line es/no-object-defineproperty -- safe
535
+ var $defineProperty = Object.defineProperty;
536
+ // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
537
+ var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
538
+ var ENUMERABLE = 'enumerable';
539
+ var CONFIGURABLE$1 = 'configurable';
540
+ var WRITABLE = 'writable';
541
+
542
+ // `Object.defineProperty` method
543
+ // https://tc39.es/ecma262/#sec-object.defineproperty
544
+ objectDefineProperty.f = DESCRIPTORS$7 ? V8_PROTOTYPE_DEFINE_BUG$1 ? function defineProperty(O, P, Attributes) {
545
+ anObject$d(O);
546
+ P = toPropertyKey(P);
547
+ anObject$d(Attributes);
548
+ if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
549
+ var current = $getOwnPropertyDescriptor(O, P);
550
+ if (current && current[WRITABLE]) {
551
+ O[P] = Attributes.value;
552
+ Attributes = {
553
+ configurable: CONFIGURABLE$1 in Attributes ? Attributes[CONFIGURABLE$1] : current[CONFIGURABLE$1],
554
+ enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
555
+ writable: false
556
+ };
557
+ }
558
+ } return $defineProperty(O, P, Attributes);
559
+ } : $defineProperty : function defineProperty(O, P, Attributes) {
560
+ anObject$d(O);
561
+ P = toPropertyKey(P);
562
+ anObject$d(Attributes);
563
+ if (IE8_DOM_DEFINE) try {
564
+ return $defineProperty(O, P, Attributes);
565
+ } catch (error) { /* empty */ }
566
+ if ('get' in Attributes || 'set' in Attributes) throw $TypeError$a('Accessors not supported');
567
+ if ('value' in Attributes) O[P] = Attributes.value;
568
+ return O;
569
+ };
570
+
571
+ var DESCRIPTORS$6 = descriptors;
572
+ var definePropertyModule$4 = objectDefineProperty;
573
+ var createPropertyDescriptor$1 = createPropertyDescriptor$3;
574
+
575
+ var createNonEnumerableProperty$5 = DESCRIPTORS$6 ? function (object, key, value) {
576
+ return definePropertyModule$4.f(object, key, createPropertyDescriptor$1(1, value));
577
+ } : function (object, key, value) {
578
+ object[key] = value;
579
+ return object;
580
+ };
581
+
582
+ var makeBuiltIn$2 = {exports: {}};
583
+
584
+ var DESCRIPTORS$5 = descriptors;
585
+ var hasOwn$8 = hasOwnProperty_1;
586
+
587
+ var FunctionPrototype$1 = Function.prototype;
588
+ // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
589
+ var getDescriptor = DESCRIPTORS$5 && Object.getOwnPropertyDescriptor;
590
+
591
+ var EXISTS = hasOwn$8(FunctionPrototype$1, 'name');
592
+ // additional protection from minified / mangled / dropped function names
593
+ var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
594
+ var CONFIGURABLE = EXISTS && (!DESCRIPTORS$5 || (DESCRIPTORS$5 && getDescriptor(FunctionPrototype$1, 'name').configurable));
595
+
596
+ var functionName = {
597
+ EXISTS: EXISTS,
598
+ PROPER: PROPER,
599
+ CONFIGURABLE: CONFIGURABLE
600
+ };
601
+
602
+ var uncurryThis$h = functionUncurryThis;
603
+ var isCallable$g = isCallable$m;
604
+ var store$1 = sharedStore;
605
+
606
+ var functionToString = uncurryThis$h(Function.toString);
607
+
608
+ // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
609
+ if (!isCallable$g(store$1.inspectSource)) {
610
+ store$1.inspectSource = function (it) {
611
+ return functionToString(it);
612
+ };
613
+ }
614
+
615
+ var inspectSource$3 = store$1.inspectSource;
616
+
617
+ var global$g = global$n;
618
+ var isCallable$f = isCallable$m;
619
+
620
+ var WeakMap$1 = global$g.WeakMap;
621
+
622
+ var weakMapBasicDetection = isCallable$f(WeakMap$1) && /native code/.test(String(WeakMap$1));
623
+
624
+ var shared$2 = shared$4.exports;
625
+ var uid = uid$2;
626
+
627
+ var keys = shared$2('keys');
628
+
629
+ var sharedKey$3 = function (key) {
630
+ return keys[key] || (keys[key] = uid(key));
631
+ };
632
+
633
+ var hiddenKeys$4 = {};
634
+
635
+ var NATIVE_WEAK_MAP = weakMapBasicDetection;
636
+ var global$f = global$n;
637
+ var isObject$4 = isObject$9;
638
+ var createNonEnumerableProperty$4 = createNonEnumerableProperty$5;
639
+ var hasOwn$7 = hasOwnProperty_1;
640
+ var shared$1 = sharedStore;
641
+ var sharedKey$2 = sharedKey$3;
642
+ var hiddenKeys$3 = hiddenKeys$4;
643
+
644
+ var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
645
+ var TypeError$2 = global$f.TypeError;
646
+ var WeakMap = global$f.WeakMap;
647
+ var set$1, get, has;
648
+
649
+ var enforce = function (it) {
650
+ return has(it) ? get(it) : set$1(it, {});
651
+ };
652
+
653
+ var getterFor = function (TYPE) {
654
+ return function (it) {
655
+ var state;
656
+ if (!isObject$4(it) || (state = get(it)).type !== TYPE) {
657
+ throw TypeError$2('Incompatible receiver, ' + TYPE + ' required');
658
+ } return state;
659
+ };
660
+ };
661
+
662
+ if (NATIVE_WEAK_MAP || shared$1.state) {
663
+ var store = shared$1.state || (shared$1.state = new WeakMap());
664
+ /* eslint-disable no-self-assign -- prototype methods protection */
665
+ store.get = store.get;
666
+ store.has = store.has;
667
+ store.set = store.set;
668
+ /* eslint-enable no-self-assign -- prototype methods protection */
669
+ set$1 = function (it, metadata) {
670
+ if (store.has(it)) throw TypeError$2(OBJECT_ALREADY_INITIALIZED);
671
+ metadata.facade = it;
672
+ store.set(it, metadata);
673
+ return metadata;
674
+ };
675
+ get = function (it) {
676
+ return store.get(it) || {};
677
+ };
678
+ has = function (it) {
679
+ return store.has(it);
680
+ };
681
+ } else {
682
+ var STATE = sharedKey$2('state');
683
+ hiddenKeys$3[STATE] = true;
684
+ set$1 = function (it, metadata) {
685
+ if (hasOwn$7(it, STATE)) throw TypeError$2(OBJECT_ALREADY_INITIALIZED);
686
+ metadata.facade = it;
687
+ createNonEnumerableProperty$4(it, STATE, metadata);
688
+ return metadata;
689
+ };
690
+ get = function (it) {
691
+ return hasOwn$7(it, STATE) ? it[STATE] : {};
692
+ };
693
+ has = function (it) {
694
+ return hasOwn$7(it, STATE);
695
+ };
696
+ }
697
+
698
+ var internalState = {
699
+ set: set$1,
700
+ get: get,
701
+ has: has,
702
+ enforce: enforce,
703
+ getterFor: getterFor
704
+ };
705
+
706
+ var fails$f = fails$m;
707
+ var isCallable$e = isCallable$m;
708
+ var hasOwn$6 = hasOwnProperty_1;
709
+ var DESCRIPTORS$4 = descriptors;
710
+ var CONFIGURABLE_FUNCTION_NAME$1 = functionName.CONFIGURABLE;
711
+ var inspectSource$2 = inspectSource$3;
712
+ var InternalStateModule$2 = internalState;
713
+
714
+ var enforceInternalState = InternalStateModule$2.enforce;
715
+ var getInternalState$2 = InternalStateModule$2.get;
716
+ // eslint-disable-next-line es/no-object-defineproperty -- safe
717
+ var defineProperty$4 = Object.defineProperty;
718
+
719
+ var CONFIGURABLE_LENGTH = DESCRIPTORS$4 && !fails$f(function () {
720
+ return defineProperty$4(function () { /* empty */ }, 'length', { value: 8 }).length !== 8;
721
+ });
722
+
723
+ var TEMPLATE = String(String).split('String');
724
+
725
+ var makeBuiltIn$1 = makeBuiltIn$2.exports = function (value, name, options) {
726
+ if (String(name).slice(0, 7) === 'Symbol(') {
727
+ name = '[' + String(name).replace(/^Symbol\(([^)]*)\)/, '$1') + ']';
728
+ }
729
+ if (options && options.getter) name = 'get ' + name;
730
+ if (options && options.setter) name = 'set ' + name;
731
+ if (!hasOwn$6(value, 'name') || (CONFIGURABLE_FUNCTION_NAME$1 && value.name !== name)) {
732
+ if (DESCRIPTORS$4) defineProperty$4(value, 'name', { value: name, configurable: true });
733
+ else value.name = name;
734
+ }
735
+ if (CONFIGURABLE_LENGTH && options && hasOwn$6(options, 'arity') && value.length !== options.arity) {
736
+ defineProperty$4(value, 'length', { value: options.arity });
737
+ }
738
+ try {
739
+ if (options && hasOwn$6(options, 'constructor') && options.constructor) {
740
+ if (DESCRIPTORS$4) defineProperty$4(value, 'prototype', { writable: false });
741
+ // in V8 ~ Chrome 53, prototypes of some methods, like `Array.prototype.values`, are non-writable
742
+ } else if (value.prototype) value.prototype = undefined;
743
+ } catch (error) { /* empty */ }
744
+ var state = enforceInternalState(value);
745
+ if (!hasOwn$6(state, 'source')) {
746
+ state.source = TEMPLATE.join(typeof name == 'string' ? name : '');
747
+ } return value;
748
+ };
749
+
750
+ // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
751
+ // eslint-disable-next-line no-extend-native -- required
752
+ Function.prototype.toString = makeBuiltIn$1(function toString() {
753
+ return isCallable$e(this) && getInternalState$2(this).source || inspectSource$2(this);
754
+ }, 'toString');
755
+
756
+ var isCallable$d = isCallable$m;
757
+ var definePropertyModule$3 = objectDefineProperty;
758
+ var makeBuiltIn = makeBuiltIn$2.exports;
759
+ var defineGlobalProperty$1 = defineGlobalProperty$3;
760
+
761
+ var defineBuiltIn$7 = function (O, key, value, options) {
762
+ if (!options) options = {};
763
+ var simple = options.enumerable;
764
+ var name = options.name !== undefined ? options.name : key;
765
+ if (isCallable$d(value)) makeBuiltIn(value, name, options);
766
+ if (options.global) {
767
+ if (simple) O[key] = value;
768
+ else defineGlobalProperty$1(key, value);
769
+ } else {
770
+ try {
771
+ if (!options.unsafe) delete O[key];
772
+ else if (O[key]) simple = true;
773
+ } catch (error) { /* empty */ }
774
+ if (simple) O[key] = value;
775
+ else definePropertyModule$3.f(O, key, {
776
+ value: value,
777
+ enumerable: false,
778
+ configurable: !options.nonConfigurable,
779
+ writable: !options.nonWritable
780
+ });
781
+ } return O;
782
+ };
783
+
784
+ var objectGetOwnPropertyNames = {};
785
+
786
+ var ceil = Math.ceil;
787
+ var floor$1 = Math.floor;
788
+
789
+ // `Math.trunc` method
790
+ // https://tc39.es/ecma262/#sec-math.trunc
791
+ // eslint-disable-next-line es/no-math-trunc -- safe
792
+ var mathTrunc = Math.trunc || function trunc(x) {
793
+ var n = +x;
794
+ return (n > 0 ? floor$1 : ceil)(n);
795
+ };
796
+
797
+ var trunc = mathTrunc;
798
+
799
+ // `ToIntegerOrInfinity` abstract operation
800
+ // https://tc39.es/ecma262/#sec-tointegerorinfinity
801
+ var toIntegerOrInfinity$4 = function (argument) {
802
+ var number = +argument;
803
+ // eslint-disable-next-line no-self-compare -- NaN check
804
+ return number !== number || number === 0 ? 0 : trunc(number);
805
+ };
806
+
807
+ var toIntegerOrInfinity$3 = toIntegerOrInfinity$4;
808
+
809
+ var max$1 = Math.max;
810
+ var min$3 = Math.min;
811
+
812
+ // Helper for a popular repeating case of the spec:
813
+ // Let integer be ? ToInteger(index).
814
+ // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
815
+ var toAbsoluteIndex$1 = function (index, length) {
816
+ var integer = toIntegerOrInfinity$3(index);
817
+ return integer < 0 ? max$1(integer + length, 0) : min$3(integer, length);
818
+ };
819
+
820
+ var toIntegerOrInfinity$2 = toIntegerOrInfinity$4;
821
+
822
+ var min$2 = Math.min;
823
+
824
+ // `ToLength` abstract operation
825
+ // https://tc39.es/ecma262/#sec-tolength
826
+ var toLength$3 = function (argument) {
827
+ return argument > 0 ? min$2(toIntegerOrInfinity$2(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
828
+ };
829
+
830
+ var toLength$2 = toLength$3;
831
+
832
+ // `LengthOfArrayLike` abstract operation
833
+ // https://tc39.es/ecma262/#sec-lengthofarraylike
834
+ var lengthOfArrayLike$3 = function (obj) {
835
+ return toLength$2(obj.length);
836
+ };
837
+
838
+ var toIndexedObject$3 = toIndexedObject$5;
839
+ var toAbsoluteIndex = toAbsoluteIndex$1;
840
+ var lengthOfArrayLike$2 = lengthOfArrayLike$3;
841
+
842
+ // `Array.prototype.{ indexOf, includes }` methods implementation
843
+ var createMethod$3 = function (IS_INCLUDES) {
844
+ return function ($this, el, fromIndex) {
845
+ var O = toIndexedObject$3($this);
846
+ var length = lengthOfArrayLike$2(O);
847
+ var index = toAbsoluteIndex(fromIndex, length);
848
+ var value;
849
+ // Array#includes uses SameValueZero equality algorithm
850
+ // eslint-disable-next-line no-self-compare -- NaN check
851
+ if (IS_INCLUDES && el != el) while (length > index) {
852
+ value = O[index++];
853
+ // eslint-disable-next-line no-self-compare -- NaN check
854
+ if (value != value) return true;
855
+ // Array#indexOf ignores holes, Array#includes - not
856
+ } else for (;length > index; index++) {
857
+ if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
858
+ } return !IS_INCLUDES && -1;
859
+ };
860
+ };
861
+
862
+ var arrayIncludes = {
863
+ // `Array.prototype.includes` method
864
+ // https://tc39.es/ecma262/#sec-array.prototype.includes
865
+ includes: createMethod$3(true),
866
+ // `Array.prototype.indexOf` method
867
+ // https://tc39.es/ecma262/#sec-array.prototype.indexof
868
+ indexOf: createMethod$3(false)
869
+ };
870
+
871
+ var uncurryThis$g = functionUncurryThis;
872
+ var hasOwn$5 = hasOwnProperty_1;
873
+ var toIndexedObject$2 = toIndexedObject$5;
874
+ var indexOf$1 = arrayIncludes.indexOf;
875
+ var hiddenKeys$2 = hiddenKeys$4;
876
+
877
+ var push$1 = uncurryThis$g([].push);
878
+
879
+ var objectKeysInternal = function (object, names) {
880
+ var O = toIndexedObject$2(object);
881
+ var i = 0;
882
+ var result = [];
883
+ var key;
884
+ for (key in O) !hasOwn$5(hiddenKeys$2, key) && hasOwn$5(O, key) && push$1(result, key);
885
+ // Don't enum bug & hidden keys
886
+ while (names.length > i) if (hasOwn$5(O, key = names[i++])) {
887
+ ~indexOf$1(result, key) || push$1(result, key);
888
+ }
889
+ return result;
890
+ };
891
+
892
+ // IE8- don't enum bug keys
893
+ var enumBugKeys$3 = [
894
+ 'constructor',
895
+ 'hasOwnProperty',
896
+ 'isPrototypeOf',
897
+ 'propertyIsEnumerable',
898
+ 'toLocaleString',
899
+ 'toString',
900
+ 'valueOf'
901
+ ];
902
+
903
+ var internalObjectKeys$1 = objectKeysInternal;
904
+ var enumBugKeys$2 = enumBugKeys$3;
905
+
906
+ var hiddenKeys$1 = enumBugKeys$2.concat('length', 'prototype');
907
+
908
+ // `Object.getOwnPropertyNames` method
909
+ // https://tc39.es/ecma262/#sec-object.getownpropertynames
910
+ // eslint-disable-next-line es/no-object-getownpropertynames -- safe
911
+ objectGetOwnPropertyNames.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
912
+ return internalObjectKeys$1(O, hiddenKeys$1);
913
+ };
914
+
915
+ var objectGetOwnPropertySymbols = {};
916
+
917
+ // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
918
+ objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
919
+
920
+ var getBuiltIn$5 = getBuiltIn$8;
921
+ var uncurryThis$f = functionUncurryThis;
922
+ var getOwnPropertyNamesModule = objectGetOwnPropertyNames;
923
+ var getOwnPropertySymbolsModule$1 = objectGetOwnPropertySymbols;
924
+ var anObject$c = anObject$e;
925
+
926
+ var concat$2 = uncurryThis$f([].concat);
927
+
928
+ // all object keys, includes non-enumerable and symbols
929
+ var ownKeys$1 = getBuiltIn$5('Reflect', 'ownKeys') || function ownKeys(it) {
930
+ var keys = getOwnPropertyNamesModule.f(anObject$c(it));
931
+ var getOwnPropertySymbols = getOwnPropertySymbolsModule$1.f;
932
+ return getOwnPropertySymbols ? concat$2(keys, getOwnPropertySymbols(it)) : keys;
933
+ };
934
+
935
+ var hasOwn$4 = hasOwnProperty_1;
936
+ var ownKeys = ownKeys$1;
937
+ var getOwnPropertyDescriptorModule = objectGetOwnPropertyDescriptor;
938
+ var definePropertyModule$2 = objectDefineProperty;
939
+
940
+ var copyConstructorProperties$1 = function (target, source, exceptions) {
941
+ var keys = ownKeys(source);
942
+ var defineProperty = definePropertyModule$2.f;
943
+ var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
944
+ for (var i = 0; i < keys.length; i++) {
945
+ var key = keys[i];
946
+ if (!hasOwn$4(target, key) && !(exceptions && hasOwn$4(exceptions, key))) {
947
+ defineProperty(target, key, getOwnPropertyDescriptor(source, key));
948
+ }
949
+ }
950
+ };
951
+
952
+ var fails$e = fails$m;
953
+ var isCallable$c = isCallable$m;
954
+
955
+ var replacement = /#|\.prototype\./;
956
+
957
+ var isForced$2 = function (feature, detection) {
958
+ var value = data[normalize$1(feature)];
959
+ return value == POLYFILL ? true
960
+ : value == NATIVE ? false
961
+ : isCallable$c(detection) ? fails$e(detection)
962
+ : !!detection;
963
+ };
964
+
965
+ var normalize$1 = isForced$2.normalize = function (string) {
966
+ return String(string).replace(replacement, '.').toLowerCase();
967
+ };
968
+
969
+ var data = isForced$2.data = {};
970
+ var NATIVE = isForced$2.NATIVE = 'N';
971
+ var POLYFILL = isForced$2.POLYFILL = 'P';
972
+
973
+ var isForced_1 = isForced$2;
974
+
975
+ var global$e = global$n;
976
+ var getOwnPropertyDescriptor$2 = objectGetOwnPropertyDescriptor.f;
977
+ var createNonEnumerableProperty$3 = createNonEnumerableProperty$5;
978
+ var defineBuiltIn$6 = defineBuiltIn$7;
979
+ var defineGlobalProperty = defineGlobalProperty$3;
980
+ var copyConstructorProperties = copyConstructorProperties$1;
981
+ var isForced$1 = isForced_1;
982
+
983
+ /*
984
+ options.target - name of the target object
985
+ options.global - target is the global object
986
+ options.stat - export as static methods of target
987
+ options.proto - export as prototype methods of target
988
+ options.real - real prototype method for the `pure` version
989
+ options.forced - export even if the native feature is available
990
+ options.bind - bind methods to the target, required for the `pure` version
991
+ options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
992
+ options.unsafe - use the simple assignment of property instead of delete + defineProperty
993
+ options.sham - add a flag to not completely full polyfills
994
+ options.enumerable - export as enumerable property
995
+ options.dontCallGetSet - prevent calling a getter on target
996
+ options.name - the .name of the function if it does not match the key
997
+ */
998
+ var _export = function (options, source) {
999
+ var TARGET = options.target;
1000
+ var GLOBAL = options.global;
1001
+ var STATIC = options.stat;
1002
+ var FORCED, target, key, targetProperty, sourceProperty, descriptor;
1003
+ if (GLOBAL) {
1004
+ target = global$e;
1005
+ } else if (STATIC) {
1006
+ target = global$e[TARGET] || defineGlobalProperty(TARGET, {});
1007
+ } else {
1008
+ target = (global$e[TARGET] || {}).prototype;
1009
+ }
1010
+ if (target) for (key in source) {
1011
+ sourceProperty = source[key];
1012
+ if (options.dontCallGetSet) {
1013
+ descriptor = getOwnPropertyDescriptor$2(target, key);
1014
+ targetProperty = descriptor && descriptor.value;
1015
+ } else targetProperty = target[key];
1016
+ FORCED = isForced$1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
1017
+ // contained in target
1018
+ if (!FORCED && targetProperty !== undefined) {
1019
+ if (typeof sourceProperty == typeof targetProperty) continue;
1020
+ copyConstructorProperties(sourceProperty, targetProperty);
1021
+ }
1022
+ // add a flag to not completely full polyfills
1023
+ if (options.sham || (targetProperty && targetProperty.sham)) {
1024
+ createNonEnumerableProperty$3(sourceProperty, 'sham', true);
1025
+ }
1026
+ defineBuiltIn$6(target, key, sourceProperty, options);
1027
+ }
1028
+ };
1029
+
1030
+ var classof$6 = classofRaw$2;
1031
+ var global$d = global$n;
1032
+
1033
+ var engineIsNode = classof$6(global$d.process) == 'process';
1034
+
1035
+ var isCallable$b = isCallable$m;
1036
+
1037
+ var $String$1 = String;
1038
+ var $TypeError$9 = TypeError;
1039
+
1040
+ var aPossiblePrototype$1 = function (argument) {
1041
+ if (typeof argument == 'object' || isCallable$b(argument)) return argument;
1042
+ throw $TypeError$9("Can't set " + $String$1(argument) + ' as a prototype');
1043
+ };
1044
+
1045
+ /* eslint-disable no-proto -- safe */
1046
+
1047
+ var uncurryThis$e = functionUncurryThis;
1048
+ var anObject$b = anObject$e;
1049
+ var aPossiblePrototype = aPossiblePrototype$1;
1050
+
1051
+ // `Object.setPrototypeOf` method
1052
+ // https://tc39.es/ecma262/#sec-object.setprototypeof
1053
+ // Works with __proto__ only. Old v8 can't work with null proto objects.
1054
+ // eslint-disable-next-line es/no-object-setprototypeof -- safe
1055
+ var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () {
1056
+ var CORRECT_SETTER = false;
1057
+ var test = {};
1058
+ var setter;
1059
+ try {
1060
+ // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
1061
+ setter = uncurryThis$e(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set);
1062
+ setter(test, []);
1063
+ CORRECT_SETTER = test instanceof Array;
1064
+ } catch (error) { /* empty */ }
1065
+ return function setPrototypeOf(O, proto) {
1066
+ anObject$b(O);
1067
+ aPossiblePrototype(proto);
1068
+ if (CORRECT_SETTER) setter(O, proto);
1069
+ else O.__proto__ = proto;
1070
+ return O;
1071
+ };
1072
+ }() : undefined);
1073
+
1074
+ var defineProperty$3 = objectDefineProperty.f;
1075
+ var hasOwn$3 = hasOwnProperty_1;
1076
+ var wellKnownSymbol$g = wellKnownSymbol$i;
1077
+
1078
+ var TO_STRING_TAG$3 = wellKnownSymbol$g('toStringTag');
1079
+
1080
+ var setToStringTag$3 = function (target, TAG, STATIC) {
1081
+ if (target && !STATIC) target = target.prototype;
1082
+ if (target && !hasOwn$3(target, TO_STRING_TAG$3)) {
1083
+ defineProperty$3(target, TO_STRING_TAG$3, { configurable: true, value: TAG });
1084
+ }
1085
+ };
1086
+
1087
+ var getBuiltIn$4 = getBuiltIn$8;
1088
+ var definePropertyModule$1 = objectDefineProperty;
1089
+ var wellKnownSymbol$f = wellKnownSymbol$i;
1090
+ var DESCRIPTORS$3 = descriptors;
1091
+
1092
+ var SPECIES$3 = wellKnownSymbol$f('species');
1093
+
1094
+ var setSpecies$1 = function (CONSTRUCTOR_NAME) {
1095
+ var Constructor = getBuiltIn$4(CONSTRUCTOR_NAME);
1096
+ var defineProperty = definePropertyModule$1.f;
1097
+
1098
+ if (DESCRIPTORS$3 && Constructor && !Constructor[SPECIES$3]) {
1099
+ defineProperty(Constructor, SPECIES$3, {
1100
+ configurable: true,
1101
+ get: function () { return this; }
1102
+ });
1103
+ }
1104
+ };
1105
+
1106
+ var isPrototypeOf$2 = objectIsPrototypeOf;
1107
+
1108
+ var $TypeError$8 = TypeError;
1109
+
1110
+ var anInstance$1 = function (it, Prototype) {
1111
+ if (isPrototypeOf$2(Prototype, it)) return it;
1112
+ throw $TypeError$8('Incorrect invocation');
1113
+ };
1114
+
1115
+ var wellKnownSymbol$e = wellKnownSymbol$i;
1116
+
1117
+ var TO_STRING_TAG$2 = wellKnownSymbol$e('toStringTag');
1118
+ var test = {};
1119
+
1120
+ test[TO_STRING_TAG$2] = 'z';
1121
+
1122
+ var toStringTagSupport = String(test) === '[object z]';
1123
+
1124
+ var TO_STRING_TAG_SUPPORT = toStringTagSupport;
1125
+ var isCallable$a = isCallable$m;
1126
+ var classofRaw$1 = classofRaw$2;
1127
+ var wellKnownSymbol$d = wellKnownSymbol$i;
1128
+
1129
+ var TO_STRING_TAG$1 = wellKnownSymbol$d('toStringTag');
1130
+ var $Object$1 = Object;
1131
+
1132
+ // ES3 wrong here
1133
+ var CORRECT_ARGUMENTS = classofRaw$1(function () { return arguments; }()) == 'Arguments';
1134
+
1135
+ // fallback for IE11 Script Access Denied error
1136
+ var tryGet = function (it, key) {
1137
+ try {
1138
+ return it[key];
1139
+ } catch (error) { /* empty */ }
1140
+ };
1141
+
1142
+ // getting tag from ES6+ `Object.prototype.toString`
1143
+ var classof$5 = TO_STRING_TAG_SUPPORT ? classofRaw$1 : function (it) {
1144
+ var O, tag, result;
1145
+ return it === undefined ? 'Undefined' : it === null ? 'Null'
1146
+ // @@toStringTag case
1147
+ : typeof (tag = tryGet(O = $Object$1(it), TO_STRING_TAG$1)) == 'string' ? tag
1148
+ // builtinTag case
1149
+ : CORRECT_ARGUMENTS ? classofRaw$1(O)
1150
+ // ES3 arguments fallback
1151
+ : (result = classofRaw$1(O)) == 'Object' && isCallable$a(O.callee) ? 'Arguments' : result;
1152
+ };
1153
+
1154
+ var uncurryThis$d = functionUncurryThis;
1155
+ var fails$d = fails$m;
1156
+ var isCallable$9 = isCallable$m;
1157
+ var classof$4 = classof$5;
1158
+ var getBuiltIn$3 = getBuiltIn$8;
1159
+ var inspectSource$1 = inspectSource$3;
1160
+
1161
+ var noop = function () { /* empty */ };
1162
+ var empty = [];
1163
+ var construct = getBuiltIn$3('Reflect', 'construct');
1164
+ var constructorRegExp = /^\s*(?:class|function)\b/;
1165
+ var exec$2 = uncurryThis$d(constructorRegExp.exec);
1166
+ var INCORRECT_TO_STRING = !constructorRegExp.exec(noop);
1167
+
1168
+ var isConstructorModern = function isConstructor(argument) {
1169
+ if (!isCallable$9(argument)) return false;
1170
+ try {
1171
+ construct(noop, empty, argument);
1172
+ return true;
1173
+ } catch (error) {
1174
+ return false;
1175
+ }
1176
+ };
1177
+
1178
+ var isConstructorLegacy = function isConstructor(argument) {
1179
+ if (!isCallable$9(argument)) return false;
1180
+ switch (classof$4(argument)) {
1181
+ case 'AsyncFunction':
1182
+ case 'GeneratorFunction':
1183
+ case 'AsyncGeneratorFunction': return false;
1184
+ }
1185
+ try {
1186
+ // we can't check .prototype since constructors produced by .bind haven't it
1187
+ // `Function#toString` throws on some built-it function in some legacy engines
1188
+ // (for example, `DOMQuad` and similar in FF41-)
1189
+ return INCORRECT_TO_STRING || !!exec$2(constructorRegExp, inspectSource$1(argument));
1190
+ } catch (error) {
1191
+ return true;
1192
+ }
1193
+ };
1194
+
1195
+ isConstructorLegacy.sham = true;
1196
+
1197
+ // `IsConstructor` abstract operation
1198
+ // https://tc39.es/ecma262/#sec-isconstructor
1199
+ var isConstructor$1 = !construct || fails$d(function () {
1200
+ var called;
1201
+ return isConstructorModern(isConstructorModern.call)
1202
+ || !isConstructorModern(Object)
1203
+ || !isConstructorModern(function () { called = true; })
1204
+ || called;
1205
+ }) ? isConstructorLegacy : isConstructorModern;
1206
+
1207
+ var isConstructor = isConstructor$1;
1208
+ var tryToString$2 = tryToString$4;
1209
+
1210
+ var $TypeError$7 = TypeError;
1211
+
1212
+ // `Assert: IsConstructor(argument) is true`
1213
+ var aConstructor$1 = function (argument) {
1214
+ if (isConstructor(argument)) return argument;
1215
+ throw $TypeError$7(tryToString$2(argument) + ' is not a constructor');
1216
+ };
1217
+
1218
+ var anObject$a = anObject$e;
1219
+ var aConstructor = aConstructor$1;
1220
+ var isNullOrUndefined$2 = isNullOrUndefined$5;
1221
+ var wellKnownSymbol$c = wellKnownSymbol$i;
1222
+
1223
+ var SPECIES$2 = wellKnownSymbol$c('species');
1224
+
1225
+ // `SpeciesConstructor` abstract operation
1226
+ // https://tc39.es/ecma262/#sec-speciesconstructor
1227
+ var speciesConstructor$1 = function (O, defaultConstructor) {
1228
+ var C = anObject$a(O).constructor;
1229
+ var S;
1230
+ return C === undefined || isNullOrUndefined$2(S = anObject$a(C)[SPECIES$2]) ? defaultConstructor : aConstructor(S);
1231
+ };
1232
+
1233
+ var NATIVE_BIND$1 = functionBindNative;
1234
+
1235
+ var FunctionPrototype = Function.prototype;
1236
+ var apply$2 = FunctionPrototype.apply;
1237
+ var call$d = FunctionPrototype.call;
1238
+
1239
+ // eslint-disable-next-line es/no-reflect -- safe
1240
+ var functionApply = typeof Reflect == 'object' && Reflect.apply || (NATIVE_BIND$1 ? call$d.bind(apply$2) : function () {
1241
+ return call$d.apply(apply$2, arguments);
1242
+ });
1243
+
1244
+ var classofRaw = classofRaw$2;
1245
+ var uncurryThis$c = functionUncurryThis;
1246
+
1247
+ var functionUncurryThisClause = function (fn) {
1248
+ // Nashorn bug:
1249
+ // https://github.com/zloirock/core-js/issues/1128
1250
+ // https://github.com/zloirock/core-js/issues/1130
1251
+ if (classofRaw(fn) === 'Function') return uncurryThis$c(fn);
1252
+ };
1253
+
1254
+ var uncurryThis$b = functionUncurryThisClause;
1255
+ var aCallable$6 = aCallable$8;
1256
+ var NATIVE_BIND = functionBindNative;
1257
+
1258
+ var bind$4 = uncurryThis$b(uncurryThis$b.bind);
1259
+
1260
+ // optional / simple context binding
1261
+ var functionBindContext = function (fn, that) {
1262
+ aCallable$6(fn);
1263
+ return that === undefined ? fn : NATIVE_BIND ? bind$4(fn, that) : function (/* ...args */) {
1264
+ return fn.apply(that, arguments);
1265
+ };
1266
+ };
1267
+
1268
+ var getBuiltIn$2 = getBuiltIn$8;
1269
+
1270
+ var html$2 = getBuiltIn$2('document', 'documentElement');
1271
+
1272
+ var uncurryThis$a = functionUncurryThis;
1273
+
1274
+ var arraySlice$1 = uncurryThis$a([].slice);
1275
+
1276
+ var $TypeError$6 = TypeError;
1277
+
1278
+ var validateArgumentsLength$1 = function (passed, required) {
1279
+ if (passed < required) throw $TypeError$6('Not enough arguments');
1280
+ return passed;
1281
+ };
1282
+
1283
+ var userAgent$2 = engineUserAgent;
1284
+
1285
+ var engineIsIos = /(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent$2);
1286
+
1287
+ var global$c = global$n;
1288
+ var apply$1 = functionApply;
1289
+ var bind$3 = functionBindContext;
1290
+ var isCallable$8 = isCallable$m;
1291
+ var hasOwn$2 = hasOwnProperty_1;
1292
+ var fails$c = fails$m;
1293
+ var html$1 = html$2;
1294
+ var arraySlice = arraySlice$1;
1295
+ var createElement = documentCreateElement$2;
1296
+ var validateArgumentsLength = validateArgumentsLength$1;
1297
+ var IS_IOS$1 = engineIsIos;
1298
+ var IS_NODE$4 = engineIsNode;
1299
+
1300
+ var set = global$c.setImmediate;
1301
+ var clear = global$c.clearImmediate;
1302
+ var process$2 = global$c.process;
1303
+ var Dispatch = global$c.Dispatch;
1304
+ var Function$1 = global$c.Function;
1305
+ var MessageChannel = global$c.MessageChannel;
1306
+ var String$1 = global$c.String;
1307
+ var counter = 0;
1308
+ var queue$1 = {};
1309
+ var ONREADYSTATECHANGE = 'onreadystatechange';
1310
+ var $location, defer, channel, port;
1311
+
1312
+ try {
1313
+ // Deno throws a ReferenceError on `location` access without `--location` flag
1314
+ $location = global$c.location;
1315
+ } catch (error) { /* empty */ }
1316
+
1317
+ var run = function (id) {
1318
+ if (hasOwn$2(queue$1, id)) {
1319
+ var fn = queue$1[id];
1320
+ delete queue$1[id];
1321
+ fn();
1322
+ }
1323
+ };
1324
+
1325
+ var runner = function (id) {
1326
+ return function () {
1327
+ run(id);
1328
+ };
1329
+ };
1330
+
1331
+ var listener = function (event) {
1332
+ run(event.data);
1333
+ };
1334
+
1335
+ var post = function (id) {
1336
+ // old engines have not location.origin
1337
+ global$c.postMessage(String$1(id), $location.protocol + '//' + $location.host);
1338
+ };
1339
+
1340
+ // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
1341
+ if (!set || !clear) {
1342
+ set = function setImmediate(handler) {
1343
+ validateArgumentsLength(arguments.length, 1);
1344
+ var fn = isCallable$8(handler) ? handler : Function$1(handler);
1345
+ var args = arraySlice(arguments, 1);
1346
+ queue$1[++counter] = function () {
1347
+ apply$1(fn, undefined, args);
1348
+ };
1349
+ defer(counter);
1350
+ return counter;
1351
+ };
1352
+ clear = function clearImmediate(id) {
1353
+ delete queue$1[id];
1354
+ };
1355
+ // Node.js 0.8-
1356
+ if (IS_NODE$4) {
1357
+ defer = function (id) {
1358
+ process$2.nextTick(runner(id));
1359
+ };
1360
+ // Sphere (JS game engine) Dispatch API
1361
+ } else if (Dispatch && Dispatch.now) {
1362
+ defer = function (id) {
1363
+ Dispatch.now(runner(id));
1364
+ };
1365
+ // Browsers with MessageChannel, includes WebWorkers
1366
+ // except iOS - https://github.com/zloirock/core-js/issues/624
1367
+ } else if (MessageChannel && !IS_IOS$1) {
1368
+ channel = new MessageChannel();
1369
+ port = channel.port2;
1370
+ channel.port1.onmessage = listener;
1371
+ defer = bind$3(port.postMessage, port);
1372
+ // Browsers with postMessage, skip WebWorkers
1373
+ // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
1374
+ } else if (
1375
+ global$c.addEventListener &&
1376
+ isCallable$8(global$c.postMessage) &&
1377
+ !global$c.importScripts &&
1378
+ $location && $location.protocol !== 'file:' &&
1379
+ !fails$c(post)
1380
+ ) {
1381
+ defer = post;
1382
+ global$c.addEventListener('message', listener, false);
1383
+ // IE8-
1384
+ } else if (ONREADYSTATECHANGE in createElement('script')) {
1385
+ defer = function (id) {
1386
+ html$1.appendChild(createElement('script'))[ONREADYSTATECHANGE] = function () {
1387
+ html$1.removeChild(this);
1388
+ run(id);
1389
+ };
1390
+ };
1391
+ // Rest old browsers
1392
+ } else {
1393
+ defer = function (id) {
1394
+ setTimeout(runner(id), 0);
1395
+ };
1396
+ }
1397
+ }
1398
+
1399
+ var task$1 = {
1400
+ set: set,
1401
+ clear: clear
1402
+ };
1403
+
1404
+ var userAgent$1 = engineUserAgent;
1405
+ var global$b = global$n;
1406
+
1407
+ var engineIsIosPebble = /ipad|iphone|ipod/i.test(userAgent$1) && global$b.Pebble !== undefined;
1408
+
1409
+ var userAgent = engineUserAgent;
1410
+
1411
+ var engineIsWebosWebkit = /web0s(?!.*chrome)/i.test(userAgent);
1412
+
1413
+ var global$a = global$n;
1414
+ var bind$2 = functionBindContext;
1415
+ var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
1416
+ var macrotask = task$1.set;
1417
+ var IS_IOS = engineIsIos;
1418
+ var IS_IOS_PEBBLE = engineIsIosPebble;
1419
+ var IS_WEBOS_WEBKIT = engineIsWebosWebkit;
1420
+ var IS_NODE$3 = engineIsNode;
1421
+
1422
+ var MutationObserver = global$a.MutationObserver || global$a.WebKitMutationObserver;
1423
+ var document$2 = global$a.document;
1424
+ var process$1 = global$a.process;
1425
+ var Promise$1 = global$a.Promise;
1426
+ // Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`
1427
+ var queueMicrotaskDescriptor = getOwnPropertyDescriptor$1(global$a, 'queueMicrotask');
1428
+ var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
1429
+
1430
+ var flush, head, last, notify$1, toggle, node, promise, then;
1431
+
1432
+ // modern engines have queueMicrotask method
1433
+ if (!queueMicrotask) {
1434
+ flush = function () {
1435
+ var parent, fn;
1436
+ if (IS_NODE$3 && (parent = process$1.domain)) parent.exit();
1437
+ while (head) {
1438
+ fn = head.fn;
1439
+ head = head.next;
1440
+ try {
1441
+ fn();
1442
+ } catch (error) {
1443
+ if (head) notify$1();
1444
+ else last = undefined;
1445
+ throw error;
1446
+ }
1447
+ } last = undefined;
1448
+ if (parent) parent.enter();
1449
+ };
1450
+
1451
+ // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339
1452
+ // also except WebOS Webkit https://github.com/zloirock/core-js/issues/898
1453
+ if (!IS_IOS && !IS_NODE$3 && !IS_WEBOS_WEBKIT && MutationObserver && document$2) {
1454
+ toggle = true;
1455
+ node = document$2.createTextNode('');
1456
+ new MutationObserver(flush).observe(node, { characterData: true });
1457
+ notify$1 = function () {
1458
+ node.data = toggle = !toggle;
1459
+ };
1460
+ // environments with maybe non-completely correct, but existent Promise
1461
+ } else if (!IS_IOS_PEBBLE && Promise$1 && Promise$1.resolve) {
1462
+ // Promise.resolve without an argument throws an error in LG WebOS 2
1463
+ promise = Promise$1.resolve(undefined);
1464
+ // workaround of WebKit ~ iOS Safari 10.1 bug
1465
+ promise.constructor = Promise$1;
1466
+ then = bind$2(promise.then, promise);
1467
+ notify$1 = function () {
1468
+ then(flush);
1469
+ };
1470
+ // Node.js without promises
1471
+ } else if (IS_NODE$3) {
1472
+ notify$1 = function () {
1473
+ process$1.nextTick(flush);
1474
+ };
1475
+ // for other environments - macrotask based on:
1476
+ // - setImmediate
1477
+ // - MessageChannel
1478
+ // - window.postMessage
1479
+ // - onreadystatechange
1480
+ // - setTimeout
1481
+ } else {
1482
+ // strange IE + webpack dev server bug - use .bind(global)
1483
+ macrotask = bind$2(macrotask, global$a);
1484
+ notify$1 = function () {
1485
+ macrotask(flush);
1486
+ };
1487
+ }
1488
+ }
1489
+
1490
+ var microtask$1 = queueMicrotask || function (fn) {
1491
+ var task = { fn: fn, next: undefined };
1492
+ if (last) last.next = task;
1493
+ if (!head) {
1494
+ head = task;
1495
+ notify$1();
1496
+ } last = task;
1497
+ };
1498
+
1499
+ var global$9 = global$n;
1500
+
1501
+ var hostReportErrors$1 = function (a, b) {
1502
+ var console = global$9.console;
1503
+ if (console && console.error) {
1504
+ arguments.length == 1 ? console.error(a) : console.error(a, b);
1505
+ }
1506
+ };
1507
+
1508
+ var perform$3 = function (exec) {
1509
+ try {
1510
+ return { error: false, value: exec() };
1511
+ } catch (error) {
1512
+ return { error: true, value: error };
1513
+ }
1514
+ };
1515
+
1516
+ var Queue$1 = function () {
1517
+ this.head = null;
1518
+ this.tail = null;
1519
+ };
1520
+
1521
+ Queue$1.prototype = {
1522
+ add: function (item) {
1523
+ var entry = { item: item, next: null };
1524
+ if (this.head) this.tail.next = entry;
1525
+ else this.head = entry;
1526
+ this.tail = entry;
1527
+ },
1528
+ get: function () {
1529
+ var entry = this.head;
1530
+ if (entry) {
1531
+ this.head = entry.next;
1532
+ if (this.tail === entry) this.tail = null;
1533
+ return entry.item;
1534
+ }
1535
+ }
1536
+ };
1537
+
1538
+ var queue = Queue$1;
1539
+
1540
+ var global$8 = global$n;
1541
+
1542
+ var promiseNativeConstructor = global$8.Promise;
1543
+
1544
+ /* global Deno -- Deno case */
1545
+
1546
+ var engineIsDeno = typeof Deno == 'object' && Deno && typeof Deno.version == 'object';
1547
+
1548
+ var IS_DENO$1 = engineIsDeno;
1549
+ var IS_NODE$2 = engineIsNode;
1550
+
1551
+ var engineIsBrowser = !IS_DENO$1 && !IS_NODE$2
1552
+ && typeof window == 'object'
1553
+ && typeof document == 'object';
1554
+
1555
+ var global$7 = global$n;
1556
+ var NativePromiseConstructor$3 = promiseNativeConstructor;
1557
+ var isCallable$7 = isCallable$m;
1558
+ var isForced = isForced_1;
1559
+ var inspectSource = inspectSource$3;
1560
+ var wellKnownSymbol$b = wellKnownSymbol$i;
1561
+ var IS_BROWSER = engineIsBrowser;
1562
+ var IS_DENO = engineIsDeno;
1563
+ var V8_VERSION = engineV8Version;
1564
+
1565
+ NativePromiseConstructor$3 && NativePromiseConstructor$3.prototype;
1566
+ var SPECIES$1 = wellKnownSymbol$b('species');
1567
+ var SUBCLASSING = false;
1568
+ var NATIVE_PROMISE_REJECTION_EVENT$1 = isCallable$7(global$7.PromiseRejectionEvent);
1569
+
1570
+ var FORCED_PROMISE_CONSTRUCTOR$5 = isForced('Promise', function () {
1571
+ var PROMISE_CONSTRUCTOR_SOURCE = inspectSource(NativePromiseConstructor$3);
1572
+ var GLOBAL_CORE_JS_PROMISE = PROMISE_CONSTRUCTOR_SOURCE !== String(NativePromiseConstructor$3);
1573
+ // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
1574
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
1575
+ // We can't detect it synchronously, so just check versions
1576
+ if (!GLOBAL_CORE_JS_PROMISE && V8_VERSION === 66) return true;
1577
+ // We can't use @@species feature detection in V8 since it causes
1578
+ // deoptimization and performance degradation
1579
+ // https://github.com/zloirock/core-js/issues/679
1580
+ if (!V8_VERSION || V8_VERSION < 51 || !/native code/.test(PROMISE_CONSTRUCTOR_SOURCE)) {
1581
+ // Detect correctness of subclassing with @@species support
1582
+ var promise = new NativePromiseConstructor$3(function (resolve) { resolve(1); });
1583
+ var FakePromise = function (exec) {
1584
+ exec(function () { /* empty */ }, function () { /* empty */ });
1585
+ };
1586
+ var constructor = promise.constructor = {};
1587
+ constructor[SPECIES$1] = FakePromise;
1588
+ SUBCLASSING = promise.then(function () { /* empty */ }) instanceof FakePromise;
1589
+ if (!SUBCLASSING) return true;
1590
+ // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
1591
+ } return !GLOBAL_CORE_JS_PROMISE && (IS_BROWSER || IS_DENO) && !NATIVE_PROMISE_REJECTION_EVENT$1;
1592
+ });
1593
+
1594
+ var promiseConstructorDetection = {
1595
+ CONSTRUCTOR: FORCED_PROMISE_CONSTRUCTOR$5,
1596
+ REJECTION_EVENT: NATIVE_PROMISE_REJECTION_EVENT$1,
1597
+ SUBCLASSING: SUBCLASSING
1598
+ };
1599
+
1600
+ var newPromiseCapability$2 = {};
1601
+
1602
+ var aCallable$5 = aCallable$8;
1603
+
1604
+ var $TypeError$5 = TypeError;
1605
+
1606
+ var PromiseCapability = function (C) {
1607
+ var resolve, reject;
1608
+ this.promise = new C(function ($$resolve, $$reject) {
1609
+ if (resolve !== undefined || reject !== undefined) throw $TypeError$5('Bad Promise constructor');
1610
+ resolve = $$resolve;
1611
+ reject = $$reject;
1612
+ });
1613
+ this.resolve = aCallable$5(resolve);
1614
+ this.reject = aCallable$5(reject);
1615
+ };
1616
+
1617
+ // `NewPromiseCapability` abstract operation
1618
+ // https://tc39.es/ecma262/#sec-newpromisecapability
1619
+ newPromiseCapability$2.f = function (C) {
1620
+ return new PromiseCapability(C);
1621
+ };
1622
+
1623
+ var $$d = _export;
1624
+ var IS_NODE$1 = engineIsNode;
1625
+ var global$6 = global$n;
1626
+ var call$c = functionCall;
1627
+ var defineBuiltIn$5 = defineBuiltIn$7;
1628
+ var setPrototypeOf$1 = objectSetPrototypeOf;
1629
+ var setToStringTag$2 = setToStringTag$3;
1630
+ var setSpecies = setSpecies$1;
1631
+ var aCallable$4 = aCallable$8;
1632
+ var isCallable$6 = isCallable$m;
1633
+ var isObject$3 = isObject$9;
1634
+ var anInstance = anInstance$1;
1635
+ var speciesConstructor = speciesConstructor$1;
1636
+ var task = task$1.set;
1637
+ var microtask = microtask$1;
1638
+ var hostReportErrors = hostReportErrors$1;
1639
+ var perform$2 = perform$3;
1640
+ var Queue = queue;
1641
+ var InternalStateModule$1 = internalState;
1642
+ var NativePromiseConstructor$2 = promiseNativeConstructor;
1643
+ var PromiseConstructorDetection = promiseConstructorDetection;
1644
+ var newPromiseCapabilityModule$3 = newPromiseCapability$2;
1645
+
1646
+ var PROMISE = 'Promise';
1647
+ var FORCED_PROMISE_CONSTRUCTOR$4 = PromiseConstructorDetection.CONSTRUCTOR;
1648
+ var NATIVE_PROMISE_REJECTION_EVENT = PromiseConstructorDetection.REJECTION_EVENT;
1649
+ var NATIVE_PROMISE_SUBCLASSING = PromiseConstructorDetection.SUBCLASSING;
1650
+ var getInternalPromiseState = InternalStateModule$1.getterFor(PROMISE);
1651
+ var setInternalState$1 = InternalStateModule$1.set;
1652
+ var NativePromisePrototype$1 = NativePromiseConstructor$2 && NativePromiseConstructor$2.prototype;
1653
+ var PromiseConstructor = NativePromiseConstructor$2;
1654
+ var PromisePrototype = NativePromisePrototype$1;
1655
+ var TypeError$1 = global$6.TypeError;
1656
+ var document$1 = global$6.document;
1657
+ var process = global$6.process;
1658
+ var newPromiseCapability$1 = newPromiseCapabilityModule$3.f;
1659
+ var newGenericPromiseCapability = newPromiseCapability$1;
1660
+
1661
+ var DISPATCH_EVENT = !!(document$1 && document$1.createEvent && global$6.dispatchEvent);
1662
+ var UNHANDLED_REJECTION = 'unhandledrejection';
1663
+ var REJECTION_HANDLED = 'rejectionhandled';
1664
+ var PENDING = 0;
1665
+ var FULFILLED = 1;
1666
+ var REJECTED = 2;
1667
+ var HANDLED = 1;
1668
+ var UNHANDLED = 2;
1669
+
1670
+ var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;
1671
+
1672
+ // helpers
1673
+ var isThenable = function (it) {
1674
+ var then;
1675
+ return isObject$3(it) && isCallable$6(then = it.then) ? then : false;
1676
+ };
1677
+
1678
+ var callReaction = function (reaction, state) {
1679
+ var value = state.value;
1680
+ var ok = state.state == FULFILLED;
1681
+ var handler = ok ? reaction.ok : reaction.fail;
1682
+ var resolve = reaction.resolve;
1683
+ var reject = reaction.reject;
1684
+ var domain = reaction.domain;
1685
+ var result, then, exited;
1686
+ try {
1687
+ if (handler) {
1688
+ if (!ok) {
1689
+ if (state.rejection === UNHANDLED) onHandleUnhandled(state);
1690
+ state.rejection = HANDLED;
1691
+ }
1692
+ if (handler === true) result = value;
1693
+ else {
1694
+ if (domain) domain.enter();
1695
+ result = handler(value); // can throw
1696
+ if (domain) {
1697
+ domain.exit();
1698
+ exited = true;
1699
+ }
1700
+ }
1701
+ if (result === reaction.promise) {
1702
+ reject(TypeError$1('Promise-chain cycle'));
1703
+ } else if (then = isThenable(result)) {
1704
+ call$c(then, result, resolve, reject);
1705
+ } else resolve(result);
1706
+ } else reject(value);
1707
+ } catch (error) {
1708
+ if (domain && !exited) domain.exit();
1709
+ reject(error);
1710
+ }
1711
+ };
1712
+
1713
+ var notify = function (state, isReject) {
1714
+ if (state.notified) return;
1715
+ state.notified = true;
1716
+ microtask(function () {
1717
+ var reactions = state.reactions;
1718
+ var reaction;
1719
+ while (reaction = reactions.get()) {
1720
+ callReaction(reaction, state);
1721
+ }
1722
+ state.notified = false;
1723
+ if (isReject && !state.rejection) onUnhandled(state);
1724
+ });
1725
+ };
1726
+
1727
+ var dispatchEvent = function (name, promise, reason) {
1728
+ var event, handler;
1729
+ if (DISPATCH_EVENT) {
1730
+ event = document$1.createEvent('Event');
1731
+ event.promise = promise;
1732
+ event.reason = reason;
1733
+ event.initEvent(name, false, true);
1734
+ global$6.dispatchEvent(event);
1735
+ } else event = { promise: promise, reason: reason };
1736
+ if (!NATIVE_PROMISE_REJECTION_EVENT && (handler = global$6['on' + name])) handler(event);
1737
+ else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason);
1738
+ };
1739
+
1740
+ var onUnhandled = function (state) {
1741
+ call$c(task, global$6, function () {
1742
+ var promise = state.facade;
1743
+ var value = state.value;
1744
+ var IS_UNHANDLED = isUnhandled(state);
1745
+ var result;
1746
+ if (IS_UNHANDLED) {
1747
+ result = perform$2(function () {
1748
+ if (IS_NODE$1) {
1749
+ process.emit('unhandledRejection', value, promise);
1750
+ } else dispatchEvent(UNHANDLED_REJECTION, promise, value);
1751
+ });
1752
+ // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
1753
+ state.rejection = IS_NODE$1 || isUnhandled(state) ? UNHANDLED : HANDLED;
1754
+ if (result.error) throw result.value;
1755
+ }
1756
+ });
1757
+ };
1758
+
1759
+ var isUnhandled = function (state) {
1760
+ return state.rejection !== HANDLED && !state.parent;
1761
+ };
1762
+
1763
+ var onHandleUnhandled = function (state) {
1764
+ call$c(task, global$6, function () {
1765
+ var promise = state.facade;
1766
+ if (IS_NODE$1) {
1767
+ process.emit('rejectionHandled', promise);
1768
+ } else dispatchEvent(REJECTION_HANDLED, promise, state.value);
1769
+ });
1770
+ };
1771
+
1772
+ var bind$1 = function (fn, state, unwrap) {
1773
+ return function (value) {
1774
+ fn(state, value, unwrap);
1775
+ };
1776
+ };
1777
+
1778
+ var internalReject = function (state, value, unwrap) {
1779
+ if (state.done) return;
1780
+ state.done = true;
1781
+ if (unwrap) state = unwrap;
1782
+ state.value = value;
1783
+ state.state = REJECTED;
1784
+ notify(state, true);
1785
+ };
1786
+
1787
+ var internalResolve = function (state, value, unwrap) {
1788
+ if (state.done) return;
1789
+ state.done = true;
1790
+ if (unwrap) state = unwrap;
1791
+ try {
1792
+ if (state.facade === value) throw TypeError$1("Promise can't be resolved itself");
1793
+ var then = isThenable(value);
1794
+ if (then) {
1795
+ microtask(function () {
1796
+ var wrapper = { done: false };
1797
+ try {
1798
+ call$c(then, value,
1799
+ bind$1(internalResolve, wrapper, state),
1800
+ bind$1(internalReject, wrapper, state)
1801
+ );
1802
+ } catch (error) {
1803
+ internalReject(wrapper, error, state);
1804
+ }
1805
+ });
1806
+ } else {
1807
+ state.value = value;
1808
+ state.state = FULFILLED;
1809
+ notify(state, false);
1810
+ }
1811
+ } catch (error) {
1812
+ internalReject({ done: false }, error, state);
1813
+ }
1814
+ };
1815
+
1816
+ // constructor polyfill
1817
+ if (FORCED_PROMISE_CONSTRUCTOR$4) {
1818
+ // 25.4.3.1 Promise(executor)
1819
+ PromiseConstructor = function Promise(executor) {
1820
+ anInstance(this, PromisePrototype);
1821
+ aCallable$4(executor);
1822
+ call$c(Internal, this);
1823
+ var state = getInternalPromiseState(this);
1824
+ try {
1825
+ executor(bind$1(internalResolve, state), bind$1(internalReject, state));
1826
+ } catch (error) {
1827
+ internalReject(state, error);
1828
+ }
1829
+ };
1830
+
1831
+ PromisePrototype = PromiseConstructor.prototype;
1832
+
1833
+ // eslint-disable-next-line no-unused-vars -- required for `.length`
1834
+ Internal = function Promise(executor) {
1835
+ setInternalState$1(this, {
1836
+ type: PROMISE,
1837
+ done: false,
1838
+ notified: false,
1839
+ parent: false,
1840
+ reactions: new Queue(),
1841
+ rejection: false,
1842
+ state: PENDING,
1843
+ value: undefined
1844
+ });
1845
+ };
1846
+
1847
+ // `Promise.prototype.then` method
1848
+ // https://tc39.es/ecma262/#sec-promise.prototype.then
1849
+ Internal.prototype = defineBuiltIn$5(PromisePrototype, 'then', function then(onFulfilled, onRejected) {
1850
+ var state = getInternalPromiseState(this);
1851
+ var reaction = newPromiseCapability$1(speciesConstructor(this, PromiseConstructor));
1852
+ state.parent = true;
1853
+ reaction.ok = isCallable$6(onFulfilled) ? onFulfilled : true;
1854
+ reaction.fail = isCallable$6(onRejected) && onRejected;
1855
+ reaction.domain = IS_NODE$1 ? process.domain : undefined;
1856
+ if (state.state == PENDING) state.reactions.add(reaction);
1857
+ else microtask(function () {
1858
+ callReaction(reaction, state);
1859
+ });
1860
+ return reaction.promise;
1861
+ });
1862
+
1863
+ OwnPromiseCapability = function () {
1864
+ var promise = new Internal();
1865
+ var state = getInternalPromiseState(promise);
1866
+ this.promise = promise;
1867
+ this.resolve = bind$1(internalResolve, state);
1868
+ this.reject = bind$1(internalReject, state);
1869
+ };
1870
+
1871
+ newPromiseCapabilityModule$3.f = newPromiseCapability$1 = function (C) {
1872
+ return C === PromiseConstructor || C === PromiseWrapper
1873
+ ? new OwnPromiseCapability(C)
1874
+ : newGenericPromiseCapability(C);
1875
+ };
1876
+
1877
+ if (isCallable$6(NativePromiseConstructor$2) && NativePromisePrototype$1 !== Object.prototype) {
1878
+ nativeThen = NativePromisePrototype$1.then;
1879
+
1880
+ if (!NATIVE_PROMISE_SUBCLASSING) {
1881
+ // make `Promise#then` return a polyfilled `Promise` for native promise-based APIs
1882
+ defineBuiltIn$5(NativePromisePrototype$1, 'then', function then(onFulfilled, onRejected) {
1883
+ var that = this;
1884
+ return new PromiseConstructor(function (resolve, reject) {
1885
+ call$c(nativeThen, that, resolve, reject);
1886
+ }).then(onFulfilled, onRejected);
1887
+ // https://github.com/zloirock/core-js/issues/640
1888
+ }, { unsafe: true });
1889
+ }
1890
+
1891
+ // make `.constructor === Promise` work for native promise-based APIs
1892
+ try {
1893
+ delete NativePromisePrototype$1.constructor;
1894
+ } catch (error) { /* empty */ }
1895
+
1896
+ // make `instanceof Promise` work for native promise-based APIs
1897
+ if (setPrototypeOf$1) {
1898
+ setPrototypeOf$1(NativePromisePrototype$1, PromisePrototype);
1899
+ }
1900
+ }
1901
+ }
1902
+
1903
+ $$d({ global: true, constructor: true, wrap: true, forced: FORCED_PROMISE_CONSTRUCTOR$4 }, {
1904
+ Promise: PromiseConstructor
1905
+ });
1906
+
1907
+ setToStringTag$2(PromiseConstructor, PROMISE, false);
1908
+ setSpecies(PROMISE);
1909
+
1910
+ var iterators = {};
1911
+
1912
+ var wellKnownSymbol$a = wellKnownSymbol$i;
1913
+ var Iterators$4 = iterators;
1914
+
1915
+ var ITERATOR$6 = wellKnownSymbol$a('iterator');
1916
+ var ArrayPrototype$1 = Array.prototype;
1917
+
1918
+ // check on default Array iterator
1919
+ var isArrayIteratorMethod$1 = function (it) {
1920
+ return it !== undefined && (Iterators$4.Array === it || ArrayPrototype$1[ITERATOR$6] === it);
1921
+ };
1922
+
1923
+ var classof$3 = classof$5;
1924
+ var getMethod$2 = getMethod$4;
1925
+ var isNullOrUndefined$1 = isNullOrUndefined$5;
1926
+ var Iterators$3 = iterators;
1927
+ var wellKnownSymbol$9 = wellKnownSymbol$i;
1928
+
1929
+ var ITERATOR$5 = wellKnownSymbol$9('iterator');
1930
+
1931
+ var getIteratorMethod$2 = function (it) {
1932
+ if (!isNullOrUndefined$1(it)) return getMethod$2(it, ITERATOR$5)
1933
+ || getMethod$2(it, '@@iterator')
1934
+ || Iterators$3[classof$3(it)];
1935
+ };
1936
+
1937
+ var call$b = functionCall;
1938
+ var aCallable$3 = aCallable$8;
1939
+ var anObject$9 = anObject$e;
1940
+ var tryToString$1 = tryToString$4;
1941
+ var getIteratorMethod$1 = getIteratorMethod$2;
1942
+
1943
+ var $TypeError$4 = TypeError;
1944
+
1945
+ var getIterator$1 = function (argument, usingIterator) {
1946
+ var iteratorMethod = arguments.length < 2 ? getIteratorMethod$1(argument) : usingIterator;
1947
+ if (aCallable$3(iteratorMethod)) return anObject$9(call$b(iteratorMethod, argument));
1948
+ throw $TypeError$4(tryToString$1(argument) + ' is not iterable');
1949
+ };
1950
+
1951
+ var call$a = functionCall;
1952
+ var anObject$8 = anObject$e;
1953
+ var getMethod$1 = getMethod$4;
1954
+
1955
+ var iteratorClose$1 = function (iterator, kind, value) {
1956
+ var innerResult, innerError;
1957
+ anObject$8(iterator);
1958
+ try {
1959
+ innerResult = getMethod$1(iterator, 'return');
1960
+ if (!innerResult) {
1961
+ if (kind === 'throw') throw value;
1962
+ return value;
1963
+ }
1964
+ innerResult = call$a(innerResult, iterator);
1965
+ } catch (error) {
1966
+ innerError = true;
1967
+ innerResult = error;
1968
+ }
1969
+ if (kind === 'throw') throw value;
1970
+ if (innerError) throw innerResult;
1971
+ anObject$8(innerResult);
1972
+ return value;
1973
+ };
1974
+
1975
+ var bind = functionBindContext;
1976
+ var call$9 = functionCall;
1977
+ var anObject$7 = anObject$e;
1978
+ var tryToString = tryToString$4;
1979
+ var isArrayIteratorMethod = isArrayIteratorMethod$1;
1980
+ var lengthOfArrayLike$1 = lengthOfArrayLike$3;
1981
+ var isPrototypeOf$1 = objectIsPrototypeOf;
1982
+ var getIterator = getIterator$1;
1983
+ var getIteratorMethod = getIteratorMethod$2;
1984
+ var iteratorClose = iteratorClose$1;
1985
+
1986
+ var $TypeError$3 = TypeError;
1987
+
1988
+ var Result = function (stopped, result) {
1989
+ this.stopped = stopped;
1990
+ this.result = result;
1991
+ };
1992
+
1993
+ var ResultPrototype = Result.prototype;
1994
+
1995
+ var iterate$2 = function (iterable, unboundFunction, options) {
1996
+ var that = options && options.that;
1997
+ var AS_ENTRIES = !!(options && options.AS_ENTRIES);
1998
+ var IS_RECORD = !!(options && options.IS_RECORD);
1999
+ var IS_ITERATOR = !!(options && options.IS_ITERATOR);
2000
+ var INTERRUPTED = !!(options && options.INTERRUPTED);
2001
+ var fn = bind(unboundFunction, that);
2002
+ var iterator, iterFn, index, length, result, next, step;
2003
+
2004
+ var stop = function (condition) {
2005
+ if (iterator) iteratorClose(iterator, 'normal', condition);
2006
+ return new Result(true, condition);
2007
+ };
2008
+
2009
+ var callFn = function (value) {
2010
+ if (AS_ENTRIES) {
2011
+ anObject$7(value);
2012
+ return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
2013
+ } return INTERRUPTED ? fn(value, stop) : fn(value);
2014
+ };
2015
+
2016
+ if (IS_RECORD) {
2017
+ iterator = iterable.iterator;
2018
+ } else if (IS_ITERATOR) {
2019
+ iterator = iterable;
2020
+ } else {
2021
+ iterFn = getIteratorMethod(iterable);
2022
+ if (!iterFn) throw $TypeError$3(tryToString(iterable) + ' is not iterable');
2023
+ // optimisation for array iterators
2024
+ if (isArrayIteratorMethod(iterFn)) {
2025
+ for (index = 0, length = lengthOfArrayLike$1(iterable); length > index; index++) {
2026
+ result = callFn(iterable[index]);
2027
+ if (result && isPrototypeOf$1(ResultPrototype, result)) return result;
2028
+ } return new Result(false);
2029
+ }
2030
+ iterator = getIterator(iterable, iterFn);
2031
+ }
2032
+
2033
+ next = IS_RECORD ? iterable.next : iterator.next;
2034
+ while (!(step = call$9(next, iterator)).done) {
2035
+ try {
2036
+ result = callFn(step.value);
2037
+ } catch (error) {
2038
+ iteratorClose(iterator, 'throw', error);
2039
+ }
2040
+ if (typeof result == 'object' && result && isPrototypeOf$1(ResultPrototype, result)) return result;
2041
+ } return new Result(false);
2042
+ };
2043
+
2044
+ var wellKnownSymbol$8 = wellKnownSymbol$i;
2045
+
2046
+ var ITERATOR$4 = wellKnownSymbol$8('iterator');
2047
+ var SAFE_CLOSING = false;
2048
+
2049
+ try {
2050
+ var called = 0;
2051
+ var iteratorWithReturn = {
2052
+ next: function () {
2053
+ return { done: !!called++ };
2054
+ },
2055
+ 'return': function () {
2056
+ SAFE_CLOSING = true;
2057
+ }
2058
+ };
2059
+ iteratorWithReturn[ITERATOR$4] = function () {
2060
+ return this;
2061
+ };
2062
+ // eslint-disable-next-line es/no-array-from, no-throw-literal -- required for testing
2063
+ Array.from(iteratorWithReturn, function () { throw 2; });
2064
+ } catch (error) { /* empty */ }
2065
+
2066
+ var checkCorrectnessOfIteration$1 = function (exec, SKIP_CLOSING) {
2067
+ if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
2068
+ var ITERATION_SUPPORT = false;
2069
+ try {
2070
+ var object = {};
2071
+ object[ITERATOR$4] = function () {
2072
+ return {
2073
+ next: function () {
2074
+ return { done: ITERATION_SUPPORT = true };
2075
+ }
2076
+ };
2077
+ };
2078
+ exec(object);
2079
+ } catch (error) { /* empty */ }
2080
+ return ITERATION_SUPPORT;
2081
+ };
2082
+
2083
+ var NativePromiseConstructor$1 = promiseNativeConstructor;
2084
+ var checkCorrectnessOfIteration = checkCorrectnessOfIteration$1;
2085
+ var FORCED_PROMISE_CONSTRUCTOR$3 = promiseConstructorDetection.CONSTRUCTOR;
2086
+
2087
+ var promiseStaticsIncorrectIteration = FORCED_PROMISE_CONSTRUCTOR$3 || !checkCorrectnessOfIteration(function (iterable) {
2088
+ NativePromiseConstructor$1.all(iterable).then(undefined, function () { /* empty */ });
2089
+ });
2090
+
2091
+ var $$c = _export;
2092
+ var call$8 = functionCall;
2093
+ var aCallable$2 = aCallable$8;
2094
+ var newPromiseCapabilityModule$2 = newPromiseCapability$2;
2095
+ var perform$1 = perform$3;
2096
+ var iterate$1 = iterate$2;
2097
+ var PROMISE_STATICS_INCORRECT_ITERATION$1 = promiseStaticsIncorrectIteration;
2098
+
2099
+ // `Promise.all` method
2100
+ // https://tc39.es/ecma262/#sec-promise.all
2101
+ $$c({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION$1 }, {
2102
+ all: function all(iterable) {
2103
+ var C = this;
2104
+ var capability = newPromiseCapabilityModule$2.f(C);
2105
+ var resolve = capability.resolve;
2106
+ var reject = capability.reject;
2107
+ var result = perform$1(function () {
2108
+ var $promiseResolve = aCallable$2(C.resolve);
2109
+ var values = [];
2110
+ var counter = 0;
2111
+ var remaining = 1;
2112
+ iterate$1(iterable, function (promise) {
2113
+ var index = counter++;
2114
+ var alreadyCalled = false;
2115
+ remaining++;
2116
+ call$8($promiseResolve, C, promise).then(function (value) {
2117
+ if (alreadyCalled) return;
2118
+ alreadyCalled = true;
2119
+ values[index] = value;
2120
+ --remaining || resolve(values);
2121
+ }, reject);
2122
+ });
2123
+ --remaining || resolve(values);
2124
+ });
2125
+ if (result.error) reject(result.value);
2126
+ return capability.promise;
2127
+ }
2128
+ });
2129
+
2130
+ var $$b = _export;
2131
+ var FORCED_PROMISE_CONSTRUCTOR$2 = promiseConstructorDetection.CONSTRUCTOR;
2132
+ var NativePromiseConstructor = promiseNativeConstructor;
2133
+ var getBuiltIn$1 = getBuiltIn$8;
2134
+ var isCallable$5 = isCallable$m;
2135
+ var defineBuiltIn$4 = defineBuiltIn$7;
2136
+
2137
+ var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
2138
+
2139
+ // `Promise.prototype.catch` method
2140
+ // https://tc39.es/ecma262/#sec-promise.prototype.catch
2141
+ $$b({ target: 'Promise', proto: true, forced: FORCED_PROMISE_CONSTRUCTOR$2, real: true }, {
2142
+ 'catch': function (onRejected) {
2143
+ return this.then(undefined, onRejected);
2144
+ }
2145
+ });
2146
+
2147
+ // makes sure that native promise-based APIs `Promise#catch` properly works with patched `Promise#then`
2148
+ if (isCallable$5(NativePromiseConstructor)) {
2149
+ var method = getBuiltIn$1('Promise').prototype['catch'];
2150
+ if (NativePromisePrototype['catch'] !== method) {
2151
+ defineBuiltIn$4(NativePromisePrototype, 'catch', method, { unsafe: true });
2152
+ }
2153
+ }
2154
+
2155
+ var $$a = _export;
2156
+ var call$7 = functionCall;
2157
+ var aCallable$1 = aCallable$8;
2158
+ var newPromiseCapabilityModule$1 = newPromiseCapability$2;
2159
+ var perform = perform$3;
2160
+ var iterate = iterate$2;
2161
+ var PROMISE_STATICS_INCORRECT_ITERATION = promiseStaticsIncorrectIteration;
2162
+
2163
+ // `Promise.race` method
2164
+ // https://tc39.es/ecma262/#sec-promise.race
2165
+ $$a({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION }, {
2166
+ race: function race(iterable) {
2167
+ var C = this;
2168
+ var capability = newPromiseCapabilityModule$1.f(C);
2169
+ var reject = capability.reject;
2170
+ var result = perform(function () {
2171
+ var $promiseResolve = aCallable$1(C.resolve);
2172
+ iterate(iterable, function (promise) {
2173
+ call$7($promiseResolve, C, promise).then(capability.resolve, reject);
2174
+ });
2175
+ });
2176
+ if (result.error) reject(result.value);
2177
+ return capability.promise;
2178
+ }
2179
+ });
2180
+
2181
+ var $$9 = _export;
2182
+ var call$6 = functionCall;
2183
+ var newPromiseCapabilityModule = newPromiseCapability$2;
2184
+ var FORCED_PROMISE_CONSTRUCTOR$1 = promiseConstructorDetection.CONSTRUCTOR;
2185
+
2186
+ // `Promise.reject` method
2187
+ // https://tc39.es/ecma262/#sec-promise.reject
2188
+ $$9({ target: 'Promise', stat: true, forced: FORCED_PROMISE_CONSTRUCTOR$1 }, {
2189
+ reject: function reject(r) {
2190
+ var capability = newPromiseCapabilityModule.f(this);
2191
+ call$6(capability.reject, undefined, r);
2192
+ return capability.promise;
2193
+ }
2194
+ });
2195
+
2196
+ var anObject$6 = anObject$e;
2197
+ var isObject$2 = isObject$9;
2198
+ var newPromiseCapability = newPromiseCapability$2;
2199
+
2200
+ var promiseResolve$1 = function (C, x) {
2201
+ anObject$6(C);
2202
+ if (isObject$2(x) && x.constructor === C) return x;
2203
+ var promiseCapability = newPromiseCapability.f(C);
2204
+ var resolve = promiseCapability.resolve;
2205
+ resolve(x);
2206
+ return promiseCapability.promise;
2207
+ };
2208
+
2209
+ var $$8 = _export;
2210
+ var getBuiltIn = getBuiltIn$8;
2211
+ var FORCED_PROMISE_CONSTRUCTOR = promiseConstructorDetection.CONSTRUCTOR;
2212
+ var promiseResolve = promiseResolve$1;
2213
+
2214
+ getBuiltIn('Promise');
2215
+
2216
+ // `Promise.resolve` method
2217
+ // https://tc39.es/ecma262/#sec-promise.resolve
2218
+ $$8({ target: 'Promise', stat: true, forced: FORCED_PROMISE_CONSTRUCTOR }, {
2219
+ resolve: function resolve(x) {
2220
+ return promiseResolve(this, x);
2221
+ }
2222
+ });
2223
+
2224
+ var internalObjectKeys = objectKeysInternal;
2225
+ var enumBugKeys$1 = enumBugKeys$3;
2226
+
2227
+ // `Object.keys` method
2228
+ // https://tc39.es/ecma262/#sec-object.keys
2229
+ // eslint-disable-next-line es/no-object-keys -- safe
2230
+ var objectKeys$2 = Object.keys || function keys(O) {
2231
+ return internalObjectKeys(O, enumBugKeys$1);
2232
+ };
2233
+
2234
+ var DESCRIPTORS$2 = descriptors;
2235
+ var uncurryThis$9 = functionUncurryThis;
2236
+ var call$5 = functionCall;
2237
+ var fails$b = fails$m;
2238
+ var objectKeys$1 = objectKeys$2;
2239
+ var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
2240
+ var propertyIsEnumerableModule = objectPropertyIsEnumerable;
2241
+ var toObject$3 = toObject$5;
2242
+ var IndexedObject$1 = indexedObject;
2243
+
2244
+ // eslint-disable-next-line es/no-object-assign -- safe
2245
+ var $assign = Object.assign;
2246
+ // eslint-disable-next-line es/no-object-defineproperty -- required for testing
2247
+ var defineProperty$2 = Object.defineProperty;
2248
+ var concat$1 = uncurryThis$9([].concat);
2249
+
2250
+ // `Object.assign` method
2251
+ // https://tc39.es/ecma262/#sec-object.assign
2252
+ var objectAssign = !$assign || fails$b(function () {
2253
+ // should have correct order of operations (Edge bug)
2254
+ if (DESCRIPTORS$2 && $assign({ b: 1 }, $assign(defineProperty$2({}, 'a', {
2255
+ enumerable: true,
2256
+ get: function () {
2257
+ defineProperty$2(this, 'b', {
2258
+ value: 3,
2259
+ enumerable: false
2260
+ });
2261
+ }
2262
+ }), { b: 2 })).b !== 1) return true;
2263
+ // should work with symbols and should have deterministic property order (V8 bug)
2264
+ var A = {};
2265
+ var B = {};
2266
+ // eslint-disable-next-line es/no-symbol -- safe
2267
+ var symbol = Symbol();
2268
+ var alphabet = 'abcdefghijklmnopqrst';
2269
+ A[symbol] = 7;
2270
+ alphabet.split('').forEach(function (chr) { B[chr] = chr; });
2271
+ return $assign({}, A)[symbol] != 7 || objectKeys$1($assign({}, B)).join('') != alphabet;
2272
+ }) ? function assign(target, source) { // eslint-disable-line no-unused-vars -- required for `.length`
2273
+ var T = toObject$3(target);
2274
+ var argumentsLength = arguments.length;
2275
+ var index = 1;
2276
+ var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
2277
+ var propertyIsEnumerable = propertyIsEnumerableModule.f;
2278
+ while (argumentsLength > index) {
2279
+ var S = IndexedObject$1(arguments[index++]);
2280
+ var keys = getOwnPropertySymbols ? concat$1(objectKeys$1(S), getOwnPropertySymbols(S)) : objectKeys$1(S);
2281
+ var length = keys.length;
2282
+ var j = 0;
2283
+ var key;
2284
+ while (length > j) {
2285
+ key = keys[j++];
2286
+ if (!DESCRIPTORS$2 || call$5(propertyIsEnumerable, S, key)) T[key] = S[key];
2287
+ }
2288
+ } return T;
2289
+ } : $assign;
2290
+
2291
+ var $$7 = _export;
2292
+ var assign = objectAssign;
2293
+
2294
+ // `Object.assign` method
2295
+ // https://tc39.es/ecma262/#sec-object.assign
2296
+ // eslint-disable-next-line es/no-object-assign -- required for testing
2297
+ $$7({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }, {
2298
+ assign: assign
2299
+ });
2300
+
2301
+ var objectDefineProperties = {};
2302
+
2303
+ var DESCRIPTORS$1 = descriptors;
2304
+ var V8_PROTOTYPE_DEFINE_BUG = v8PrototypeDefineBug;
2305
+ var definePropertyModule = objectDefineProperty;
2306
+ var anObject$5 = anObject$e;
2307
+ var toIndexedObject$1 = toIndexedObject$5;
2308
+ var objectKeys = objectKeys$2;
2309
+
2310
+ // `Object.defineProperties` method
2311
+ // https://tc39.es/ecma262/#sec-object.defineproperties
2312
+ // eslint-disable-next-line es/no-object-defineproperties -- safe
2313
+ objectDefineProperties.f = DESCRIPTORS$1 && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) {
2314
+ anObject$5(O);
2315
+ var props = toIndexedObject$1(Properties);
2316
+ var keys = objectKeys(Properties);
2317
+ var length = keys.length;
2318
+ var index = 0;
2319
+ var key;
2320
+ while (length > index) definePropertyModule.f(O, key = keys[index++], props[key]);
2321
+ return O;
2322
+ };
2323
+
2324
+ /* global ActiveXObject -- old IE, WSH */
2325
+
2326
+ var anObject$4 = anObject$e;
2327
+ var definePropertiesModule = objectDefineProperties;
2328
+ var enumBugKeys = enumBugKeys$3;
2329
+ var hiddenKeys = hiddenKeys$4;
2330
+ var html = html$2;
2331
+ var documentCreateElement$1 = documentCreateElement$2;
2332
+ var sharedKey$1 = sharedKey$3;
2333
+
2334
+ var GT = '>';
2335
+ var LT = '<';
2336
+ var PROTOTYPE = 'prototype';
2337
+ var SCRIPT = 'script';
2338
+ var IE_PROTO$1 = sharedKey$1('IE_PROTO');
2339
+
2340
+ var EmptyConstructor = function () { /* empty */ };
2341
+
2342
+ var scriptTag = function (content) {
2343
+ return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
2344
+ };
2345
+
2346
+ // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
2347
+ var NullProtoObjectViaActiveX = function (activeXDocument) {
2348
+ activeXDocument.write(scriptTag(''));
2349
+ activeXDocument.close();
2350
+ var temp = activeXDocument.parentWindow.Object;
2351
+ activeXDocument = null; // avoid memory leak
2352
+ return temp;
2353
+ };
2354
+
2355
+ // Create object with fake `null` prototype: use iframe Object with cleared prototype
2356
+ var NullProtoObjectViaIFrame = function () {
2357
+ // Thrash, waste and sodomy: IE GC bug
2358
+ var iframe = documentCreateElement$1('iframe');
2359
+ var JS = 'java' + SCRIPT + ':';
2360
+ var iframeDocument;
2361
+ iframe.style.display = 'none';
2362
+ html.appendChild(iframe);
2363
+ // https://github.com/zloirock/core-js/issues/475
2364
+ iframe.src = String(JS);
2365
+ iframeDocument = iframe.contentWindow.document;
2366
+ iframeDocument.open();
2367
+ iframeDocument.write(scriptTag('document.F=Object'));
2368
+ iframeDocument.close();
2369
+ return iframeDocument.F;
2370
+ };
2371
+
2372
+ // Check for document.domain and active x support
2373
+ // No need to use active x approach when document.domain is not set
2374
+ // see https://github.com/es-shims/es5-shim/issues/150
2375
+ // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
2376
+ // avoid IE GC bug
2377
+ var activeXDocument;
2378
+ var NullProtoObject = function () {
2379
+ try {
2380
+ activeXDocument = new ActiveXObject('htmlfile');
2381
+ } catch (error) { /* ignore */ }
2382
+ NullProtoObject = typeof document != 'undefined'
2383
+ ? document.domain && activeXDocument
2384
+ ? NullProtoObjectViaActiveX(activeXDocument) // old IE
2385
+ : NullProtoObjectViaIFrame()
2386
+ : NullProtoObjectViaActiveX(activeXDocument); // WSH
2387
+ var length = enumBugKeys.length;
2388
+ while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
2389
+ return NullProtoObject();
2390
+ };
2391
+
2392
+ hiddenKeys[IE_PROTO$1] = true;
2393
+
2394
+ // `Object.create` method
2395
+ // https://tc39.es/ecma262/#sec-object.create
2396
+ // eslint-disable-next-line es/no-object-create -- safe
2397
+ var objectCreate = Object.create || function create(O, Properties) {
2398
+ var result;
2399
+ if (O !== null) {
2400
+ EmptyConstructor[PROTOTYPE] = anObject$4(O);
2401
+ result = new EmptyConstructor();
2402
+ EmptyConstructor[PROTOTYPE] = null;
2403
+ // add "__proto__" for Object.getPrototypeOf polyfill
2404
+ result[IE_PROTO$1] = O;
2405
+ } else result = NullProtoObject();
2406
+ return Properties === undefined ? result : definePropertiesModule.f(result, Properties);
2407
+ };
2408
+
2409
+ var wellKnownSymbol$7 = wellKnownSymbol$i;
2410
+ var create$2 = objectCreate;
2411
+ var defineProperty$1 = objectDefineProperty.f;
2412
+
2413
+ var UNSCOPABLES = wellKnownSymbol$7('unscopables');
2414
+ var ArrayPrototype = Array.prototype;
2415
+
2416
+ // Array.prototype[@@unscopables]
2417
+ // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
2418
+ if (ArrayPrototype[UNSCOPABLES] == undefined) {
2419
+ defineProperty$1(ArrayPrototype, UNSCOPABLES, {
2420
+ configurable: true,
2421
+ value: create$2(null)
2422
+ });
2423
+ }
2424
+
2425
+ // add a key to Array.prototype[@@unscopables]
2426
+ var addToUnscopables$2 = function (key) {
2427
+ ArrayPrototype[UNSCOPABLES][key] = true;
2428
+ };
2429
+
2430
+ var $$6 = _export;
2431
+ var $includes = arrayIncludes.includes;
2432
+ var fails$a = fails$m;
2433
+ var addToUnscopables$1 = addToUnscopables$2;
2434
+
2435
+ // FF99+ bug
2436
+ var BROKEN_ON_SPARSE = fails$a(function () {
2437
+ return !Array(1).includes();
2438
+ });
2439
+
2440
+ // `Array.prototype.includes` method
2441
+ // https://tc39.es/ecma262/#sec-array.prototype.includes
2442
+ $$6({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
2443
+ includes: function includes(el /* , fromIndex = 0 */) {
2444
+ return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
2445
+ }
2446
+ });
2447
+
2448
+ // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
2449
+ addToUnscopables$1('includes');
2450
+
2451
+ var isObject$1 = isObject$9;
2452
+ var classof$2 = classofRaw$2;
2453
+ var wellKnownSymbol$6 = wellKnownSymbol$i;
2454
+
2455
+ var MATCH$1 = wellKnownSymbol$6('match');
2456
+
2457
+ // `IsRegExp` abstract operation
2458
+ // https://tc39.es/ecma262/#sec-isregexp
2459
+ var isRegexp = function (it) {
2460
+ var isRegExp;
2461
+ return isObject$1(it) && ((isRegExp = it[MATCH$1]) !== undefined ? !!isRegExp : classof$2(it) == 'RegExp');
2462
+ };
2463
+
2464
+ var isRegExp = isRegexp;
2465
+
2466
+ var $TypeError$2 = TypeError;
2467
+
2468
+ var notARegexp = function (it) {
2469
+ if (isRegExp(it)) {
2470
+ throw $TypeError$2("The method doesn't accept regular expressions");
2471
+ } return it;
2472
+ };
2473
+
2474
+ var classof$1 = classof$5;
2475
+
2476
+ var $String = String;
2477
+
2478
+ var toString$7 = function (argument) {
2479
+ if (classof$1(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
2480
+ return $String(argument);
2481
+ };
2482
+
2483
+ var wellKnownSymbol$5 = wellKnownSymbol$i;
2484
+
2485
+ var MATCH = wellKnownSymbol$5('match');
2486
+
2487
+ var correctIsRegexpLogic = function (METHOD_NAME) {
2488
+ var regexp = /./;
2489
+ try {
2490
+ '/./'[METHOD_NAME](regexp);
2491
+ } catch (error1) {
2492
+ try {
2493
+ regexp[MATCH] = false;
2494
+ return '/./'[METHOD_NAME](regexp);
2495
+ } catch (error2) { /* empty */ }
2496
+ } return false;
2497
+ };
2498
+
2499
+ var $$5 = _export;
2500
+ var uncurryThis$8 = functionUncurryThis;
2501
+ var notARegExp$1 = notARegexp;
2502
+ var requireObjectCoercible$4 = requireObjectCoercible$7;
2503
+ var toString$6 = toString$7;
2504
+ var correctIsRegExpLogic$1 = correctIsRegexpLogic;
2505
+
2506
+ var stringIndexOf$1 = uncurryThis$8(''.indexOf);
2507
+
2508
+ // `String.prototype.includes` method
2509
+ // https://tc39.es/ecma262/#sec-string.prototype.includes
2510
+ $$5({ target: 'String', proto: true, forced: !correctIsRegExpLogic$1('includes') }, {
2511
+ includes: function includes(searchString /* , position = 0 */) {
2512
+ return !!~stringIndexOf$1(
2513
+ toString$6(requireObjectCoercible$4(this)),
2514
+ toString$6(notARegExp$1(searchString)),
2515
+ arguments.length > 1 ? arguments[1] : undefined
2516
+ );
2517
+ }
2518
+ });
2519
+
2520
+ /******************************************************************************
2521
+ Copyright (c) Microsoft Corporation.
2522
+
2523
+ Permission to use, copy, modify, and/or distribute this software for any
2524
+ purpose with or without fee is hereby granted.
2525
+
2526
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
2527
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
2528
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
2529
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
2530
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
2531
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2532
+ PERFORMANCE OF THIS SOFTWARE.
2533
+ ***************************************************************************** */
2534
+
2535
+ function __awaiter(thisArg, _arguments, P, generator) {
2536
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
2537
+ return new (P || (P = Promise))(function (resolve, reject) {
2538
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
2539
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
2540
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
2541
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
2542
+ });
2543
+ }
2544
+
2545
+ const buildClientLocale = () => navigator.languages && navigator.languages.length ? navigator.languages[0] : navigator.language;
2546
+
2547
+ const buildClientNinetailedRequestContext = () => ({
2548
+ url: window.location.href,
2549
+ referrer: document.referrer,
2550
+ locale: buildClientLocale(),
2551
+ userAgent: navigator.userAgent,
2552
+ document: {
2553
+ title: document.title
2554
+ }
2555
+ });
2556
+
2557
+ /**
2558
+ * Similar to _.throttle but waits for the promise to resolve. There is no
2559
+ * wait time because you can simply await `Promise.timeout` inside `fn`
2560
+ * to wait some time before the next call.
2561
+ */
2562
+ function asyncThrottle(fn) {
2563
+ let runningPromise;
2564
+ let queuedPromise;
2565
+ let nextArgs;
2566
+ return args => __awaiter(this, void 0, void 0, function* () {
2567
+ if (runningPromise) {
2568
+ nextArgs = args;
2569
+ if (queuedPromise) {
2570
+ return queuedPromise;
2571
+ } else {
2572
+ queuedPromise = runningPromise.then(() => {
2573
+ queuedPromise = undefined;
2574
+ runningPromise = fn(nextArgs);
2575
+ return runningPromise;
2576
+ });
2577
+ return queuedPromise;
2578
+ }
2579
+ } else {
2580
+ runningPromise = fn(args);
2581
+ return runningPromise;
2582
+ }
2583
+ });
2584
+ }
2585
+
2586
+ const LEGACY_ANONYMOUS_ID = '__anon_id';
2587
+ const ANONYMOUS_ID = '__nt_anonymous_id__';
2588
+ const DEBUG_FLAG = '__nt_debug__';
2589
+ const PROFILE_FALLBACK_CACHE = '__nt_profile__';
2590
+ const PROFILE_CHANGE = 'profile-change';
2591
+ const PROFILE_RESET = 'profile-reset';
2592
+
2593
+ const PLUGIN_NAME = 'ninetailed';
2594
+ const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
2595
+ const ninetailedPlugin = ({
2596
+ apiClient,
2597
+ profile,
2598
+ locale,
2599
+ ninetailed
2600
+ }) => {
2601
+ let _instance;
2602
+ let queue = [];
2603
+ const flush = () => __awaiter(void 0, void 0, void 0, function* () {
2604
+ const events = Object.assign([], queue);
2605
+ experience_jsShared.logger.info('Start flushing events.');
2606
+ queue = [];
2607
+ if (!events.length) {
2608
+ return {
2609
+ success: true
2610
+ };
2611
+ }
2612
+ try {
2613
+ const anonymousId = _instance.storage.getItem(ANONYMOUS_ID);
2614
+ const profile = yield apiClient.upsertProfile({
2615
+ profileId: anonymousId,
2616
+ events
2617
+ }, {
2618
+ locale
2619
+ });
2620
+ _instance.storage.setItem(ANONYMOUS_ID, profile.id);
2621
+ _instance.storage.setItem(PROFILE_FALLBACK_CACHE, profile);
2622
+ experience_jsShared.logger.debug('Profile from api: ', profile);
2623
+ _instance.dispatch({
2624
+ type: PROFILE_CHANGE,
2625
+ profile
2626
+ });
2627
+ yield delay(20);
2628
+ return {
2629
+ success: true
2630
+ };
2631
+ } catch (error) {
2632
+ experience_jsShared.logger.debug('An error occurred during flushing the events: ', error);
2633
+ const fallbackProfile = _instance.storage.getItem(PROFILE_FALLBACK_CACHE);
2634
+ if (fallbackProfile) {
2635
+ experience_jsShared.logger.debug('Found a fallback profile - will use this.');
2636
+ _instance.dispatch({
2637
+ type: PROFILE_CHANGE,
2638
+ profile: fallbackProfile
2639
+ });
2640
+ return {
2641
+ success: false
2642
+ };
2643
+ } else {
2644
+ experience_jsShared.logger.debug('No fallback profile found - setting profile to null.');
2645
+ _instance.dispatch({
2646
+ type: PROFILE_CHANGE,
2647
+ // TODO is it a good idea to set the profile to null?
2648
+ profile: null,
2649
+ error
2650
+ });
2651
+ return {
2652
+ success: false
2653
+ };
2654
+ }
2655
+ }
2656
+ });
2657
+ const enqueueEvent = event => __awaiter(void 0, void 0, void 0, function* () {
2658
+ queue = unionBy__default["default"]([event], queue, 'messageId');
2659
+ });
2660
+ const abortNonClientEvents = ({
2661
+ abort,
2662
+ payload
2663
+ }) => {
2664
+ if (typeof window !== 'object') {
2665
+ return abort();
2666
+ }
2667
+ return payload;
2668
+ };
2669
+ return {
2670
+ name: 'ninetailed',
2671
+ config: {},
2672
+ initialize: ({
2673
+ instance
2674
+ }) => {
2675
+ _instance = instance;
2676
+ if (instance.storage.getItem(DEBUG_FLAG)) {
2677
+ experience_jsShared.logger.addSink(new experience_jsShared.ConsoleLogSink());
2678
+ experience_jsShared.logger.info('Ninetailed Debug Mode is enabled.');
2679
+ }
2680
+ // legacy support for the old anonymousId
2681
+ const legacyAnonymousId = instance.storage.getItem(LEGACY_ANONYMOUS_ID);
2682
+ if (legacyAnonymousId) {
2683
+ experience_jsShared.logger.debug('Found legacy anonymousId, migrating to new one.', legacyAnonymousId);
2684
+ instance.storage.setItem(ANONYMOUS_ID, legacyAnonymousId);
2685
+ instance.storage.removeItem(LEGACY_ANONYMOUS_ID);
2686
+ }
2687
+ if (profile) {
2688
+ instance.storage.setItem(ANONYMOUS_ID, profile.id);
2689
+ }
2690
+ experience_jsShared.logger.debug('Ninetailed Core plugin initialized.');
2691
+ },
2692
+ flush: asyncThrottle(flush),
2693
+ pageStart: params => {
2694
+ return abortNonClientEvents(params);
2695
+ },
2696
+ page: ({
2697
+ payload
2698
+ }) => __awaiter(void 0, void 0, void 0, function* () {
2699
+ experience_jsShared.logger.info('Sending Page event.');
2700
+ const ctx = buildClientNinetailedRequestContext();
2701
+ return enqueueEvent(experience_jsShared.buildPageEvent({
2702
+ messageId: payload.meta.rid,
2703
+ timestamp: payload.meta.ts,
2704
+ properties: payload.properties,
2705
+ ctx
2706
+ }));
2707
+ }),
2708
+ trackStart: params => {
2709
+ return abortNonClientEvents(params);
2710
+ },
2711
+ track: ({
2712
+ payload
2713
+ }) => __awaiter(void 0, void 0, void 0, function* () {
2714
+ experience_jsShared.logger.info('Sending Track event.');
2715
+ const ctx = buildClientNinetailedRequestContext();
2716
+ return enqueueEvent(experience_jsShared.buildTrackEvent({
2717
+ messageId: payload.meta.rid,
2718
+ timestamp: payload.meta.ts,
2719
+ event: payload.event,
2720
+ properties: payload.properties,
2721
+ ctx
2722
+ }));
2723
+ }),
2724
+ identifyStart: params => {
2725
+ return abortNonClientEvents(params);
2726
+ },
2727
+ identify: ({
2728
+ payload
2729
+ }) => __awaiter(void 0, void 0, void 0, function* () {
2730
+ experience_jsShared.logger.info('Sending Identify event.');
2731
+ const ctx = buildClientNinetailedRequestContext();
2732
+ if (payload.userId === '' && (!payload.traits || typeof payload.traits === 'object' && Object.keys(payload.traits).length === 0)) {
2733
+ experience_jsShared.logger.info('Skipping Identify event as no userId and no traits are set.');
2734
+ return;
2735
+ }
2736
+ return enqueueEvent(experience_jsShared.buildIdentifyEvent({
2737
+ // doing this here as the anonymous id is set to late from init
2738
+ messageId: payload.meta.rid,
2739
+ timestamp: payload.meta.ts,
2740
+ traits: payload.traits,
2741
+ userId: payload.userId,
2742
+ ctx
2743
+ }));
2744
+ }),
2745
+ setItemStart: ({
2746
+ abort,
2747
+ payload
2748
+ }) => {
2749
+ if (![ANONYMOUS_ID, DEBUG_FLAG, PROFILE_FALLBACK_CACHE].includes(payload.key)) {
2750
+ return abort();
2751
+ }
2752
+ return payload;
2753
+ },
2754
+ methods: {
2755
+ reset: (...args) => __awaiter(void 0, void 0, void 0, function* () {
2756
+ // TODO it seems reset gets called during Next.js SSR builds. Need to verify that.
2757
+ experience_jsShared.logger.debug('Resetting profile.');
2758
+ const instance = args[args.length - 1];
2759
+ instance.dispatch({
2760
+ type: PROFILE_RESET
2761
+ });
2762
+ instance.storage.removeItem(ANONYMOUS_ID);
2763
+ instance.storage.removeItem(PROFILE_FALLBACK_CACHE);
2764
+ experience_jsShared.logger.debug('Removed old profile data from localstorage.');
2765
+ yield ninetailed.track('nt_reset');
2766
+ experience_jsShared.logger.info('Profile reset successful.');
2767
+ yield delay(10);
2768
+ }),
2769
+ debug: (...args) => __awaiter(void 0, void 0, void 0, function* () {
2770
+ const enabled = args[0];
2771
+ const instance = args[args.length - 1];
2772
+ const consoleLogSink = new experience_jsShared.ConsoleLogSink();
2773
+ if (enabled) {
2774
+ instance.storage.setItem(DEBUG_FLAG, true);
2775
+ experience_jsShared.logger.addSink(consoleLogSink);
2776
+ experience_jsShared.logger.info('Debug mode enabled.');
2777
+ } else {
2778
+ instance.storage.removeItem(DEBUG_FLAG);
2779
+ experience_jsShared.logger.info('Debug mode disabled.');
2780
+ experience_jsShared.logger.removeSink(consoleLogSink.name);
2781
+ }
2782
+ })
2783
+ }
2784
+ };
2785
+ };
2786
+
2787
+ var anObject$3 = anObject$e;
2788
+
2789
+ // `RegExp.prototype.flags` getter implementation
2790
+ // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags
2791
+ var regexpFlags$1 = function () {
2792
+ var that = anObject$3(this);
2793
+ var result = '';
2794
+ if (that.hasIndices) result += 'd';
2795
+ if (that.global) result += 'g';
2796
+ if (that.ignoreCase) result += 'i';
2797
+ if (that.multiline) result += 'm';
2798
+ if (that.dotAll) result += 's';
2799
+ if (that.unicode) result += 'u';
2800
+ if (that.unicodeSets) result += 'v';
2801
+ if (that.sticky) result += 'y';
2802
+ return result;
2803
+ };
2804
+
2805
+ var call$4 = functionCall;
2806
+ var hasOwn$1 = hasOwnProperty_1;
2807
+ var isPrototypeOf = objectIsPrototypeOf;
2808
+ var regExpFlags = regexpFlags$1;
2809
+
2810
+ var RegExpPrototype$2 = RegExp.prototype;
2811
+
2812
+ var regexpGetFlags = function (R) {
2813
+ var flags = R.flags;
2814
+ return flags === undefined && !('flags' in RegExpPrototype$2) && !hasOwn$1(R, 'flags') && isPrototypeOf(RegExpPrototype$2, R)
2815
+ ? call$4(regExpFlags, R) : flags;
2816
+ };
2817
+
2818
+ var PROPER_FUNCTION_NAME$1 = functionName.PROPER;
2819
+ var defineBuiltIn$3 = defineBuiltIn$7;
2820
+ var anObject$2 = anObject$e;
2821
+ var $toString = toString$7;
2822
+ var fails$9 = fails$m;
2823
+ var getRegExpFlags = regexpGetFlags;
2824
+
2825
+ var TO_STRING = 'toString';
2826
+ var RegExpPrototype$1 = RegExp.prototype;
2827
+ var nativeToString = RegExpPrototype$1[TO_STRING];
2828
+
2829
+ var NOT_GENERIC = fails$9(function () { return nativeToString.call({ source: 'a', flags: 'b' }) != '/a/b'; });
2830
+ // FF44- RegExp#toString has a wrong name
2831
+ var INCORRECT_NAME = PROPER_FUNCTION_NAME$1 && nativeToString.name != TO_STRING;
2832
+
2833
+ // `RegExp.prototype.toString` method
2834
+ // https://tc39.es/ecma262/#sec-regexp.prototype.tostring
2835
+ if (NOT_GENERIC || INCORRECT_NAME) {
2836
+ defineBuiltIn$3(RegExp.prototype, TO_STRING, function toString() {
2837
+ var R = anObject$2(this);
2838
+ var pattern = $toString(R.source);
2839
+ var flags = $toString(getRegExpFlags(R));
2840
+ return '/' + pattern + '/' + flags;
2841
+ }, { unsafe: true });
2842
+ }
2843
+
2844
+ var fails$8 = fails$m;
2845
+
2846
+ var correctPrototypeGetter = !fails$8(function () {
2847
+ function F() { /* empty */ }
2848
+ F.prototype.constructor = null;
2849
+ // eslint-disable-next-line es/no-object-getprototypeof -- required for testing
2850
+ return Object.getPrototypeOf(new F()) !== F.prototype;
2851
+ });
2852
+
2853
+ var hasOwn = hasOwnProperty_1;
2854
+ var isCallable$4 = isCallable$m;
2855
+ var toObject$2 = toObject$5;
2856
+ var sharedKey = sharedKey$3;
2857
+ var CORRECT_PROTOTYPE_GETTER = correctPrototypeGetter;
2858
+
2859
+ var IE_PROTO = sharedKey('IE_PROTO');
2860
+ var $Object = Object;
2861
+ var ObjectPrototype = $Object.prototype;
2862
+
2863
+ // `Object.getPrototypeOf` method
2864
+ // https://tc39.es/ecma262/#sec-object.getprototypeof
2865
+ // eslint-disable-next-line es/no-object-getprototypeof -- safe
2866
+ var objectGetPrototypeOf = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : function (O) {
2867
+ var object = toObject$2(O);
2868
+ if (hasOwn(object, IE_PROTO)) return object[IE_PROTO];
2869
+ var constructor = object.constructor;
2870
+ if (isCallable$4(constructor) && object instanceof constructor) {
2871
+ return constructor.prototype;
2872
+ } return object instanceof $Object ? ObjectPrototype : null;
2873
+ };
2874
+
2875
+ var fails$7 = fails$m;
2876
+ var isCallable$3 = isCallable$m;
2877
+ var isObject = isObject$9;
2878
+ var getPrototypeOf$1 = objectGetPrototypeOf;
2879
+ var defineBuiltIn$2 = defineBuiltIn$7;
2880
+ var wellKnownSymbol$4 = wellKnownSymbol$i;
2881
+
2882
+ var ITERATOR$3 = wellKnownSymbol$4('iterator');
2883
+ var BUGGY_SAFARI_ITERATORS$1 = false;
2884
+
2885
+ // `%IteratorPrototype%` object
2886
+ // https://tc39.es/ecma262/#sec-%iteratorprototype%-object
2887
+ var IteratorPrototype$2, PrototypeOfArrayIteratorPrototype, arrayIterator;
2888
+
2889
+ /* eslint-disable es/no-array-prototype-keys -- safe */
2890
+ if ([].keys) {
2891
+ arrayIterator = [].keys();
2892
+ // Safari 8 has buggy iterators w/o `next`
2893
+ if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS$1 = true;
2894
+ else {
2895
+ PrototypeOfArrayIteratorPrototype = getPrototypeOf$1(getPrototypeOf$1(arrayIterator));
2896
+ if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype$2 = PrototypeOfArrayIteratorPrototype;
2897
+ }
2898
+ }
2899
+
2900
+ var NEW_ITERATOR_PROTOTYPE = !isObject(IteratorPrototype$2) || fails$7(function () {
2901
+ var test = {};
2902
+ // FF44- legacy iterators case
2903
+ return IteratorPrototype$2[ITERATOR$3].call(test) !== test;
2904
+ });
2905
+
2906
+ if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype$2 = {};
2907
+
2908
+ // `%IteratorPrototype%[@@iterator]()` method
2909
+ // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator
2910
+ if (!isCallable$3(IteratorPrototype$2[ITERATOR$3])) {
2911
+ defineBuiltIn$2(IteratorPrototype$2, ITERATOR$3, function () {
2912
+ return this;
2913
+ });
2914
+ }
2915
+
2916
+ var iteratorsCore = {
2917
+ IteratorPrototype: IteratorPrototype$2,
2918
+ BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS$1
2919
+ };
2920
+
2921
+ var IteratorPrototype$1 = iteratorsCore.IteratorPrototype;
2922
+ var create$1 = objectCreate;
2923
+ var createPropertyDescriptor = createPropertyDescriptor$3;
2924
+ var setToStringTag$1 = setToStringTag$3;
2925
+ var Iterators$2 = iterators;
2926
+
2927
+ var returnThis$1 = function () { return this; };
2928
+
2929
+ var iteratorCreateConstructor = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) {
2930
+ var TO_STRING_TAG = NAME + ' Iterator';
2931
+ IteratorConstructor.prototype = create$1(IteratorPrototype$1, { next: createPropertyDescriptor(+!ENUMERABLE_NEXT, next) });
2932
+ setToStringTag$1(IteratorConstructor, TO_STRING_TAG, false);
2933
+ Iterators$2[TO_STRING_TAG] = returnThis$1;
2934
+ return IteratorConstructor;
2935
+ };
2936
+
2937
+ var $$4 = _export;
2938
+ var call$3 = functionCall;
2939
+ var FunctionName = functionName;
2940
+ var isCallable$2 = isCallable$m;
2941
+ var createIteratorConstructor = iteratorCreateConstructor;
2942
+ var getPrototypeOf = objectGetPrototypeOf;
2943
+ var setPrototypeOf = objectSetPrototypeOf;
2944
+ var setToStringTag = setToStringTag$3;
2945
+ var createNonEnumerableProperty$2 = createNonEnumerableProperty$5;
2946
+ var defineBuiltIn$1 = defineBuiltIn$7;
2947
+ var wellKnownSymbol$3 = wellKnownSymbol$i;
2948
+ var Iterators$1 = iterators;
2949
+ var IteratorsCore = iteratorsCore;
2950
+
2951
+ var PROPER_FUNCTION_NAME = FunctionName.PROPER;
2952
+ var CONFIGURABLE_FUNCTION_NAME = FunctionName.CONFIGURABLE;
2953
+ var IteratorPrototype = IteratorsCore.IteratorPrototype;
2954
+ var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;
2955
+ var ITERATOR$2 = wellKnownSymbol$3('iterator');
2956
+ var KEYS = 'keys';
2957
+ var VALUES = 'values';
2958
+ var ENTRIES = 'entries';
2959
+
2960
+ var returnThis = function () { return this; };
2961
+
2962
+ var iteratorDefine = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
2963
+ createIteratorConstructor(IteratorConstructor, NAME, next);
2964
+
2965
+ var getIterationMethod = function (KIND) {
2966
+ if (KIND === DEFAULT && defaultIterator) return defaultIterator;
2967
+ if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND];
2968
+ switch (KIND) {
2969
+ case KEYS: return function keys() { return new IteratorConstructor(this, KIND); };
2970
+ case VALUES: return function values() { return new IteratorConstructor(this, KIND); };
2971
+ case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); };
2972
+ } return function () { return new IteratorConstructor(this); };
2973
+ };
2974
+
2975
+ var TO_STRING_TAG = NAME + ' Iterator';
2976
+ var INCORRECT_VALUES_NAME = false;
2977
+ var IterablePrototype = Iterable.prototype;
2978
+ var nativeIterator = IterablePrototype[ITERATOR$2]
2979
+ || IterablePrototype['@@iterator']
2980
+ || DEFAULT && IterablePrototype[DEFAULT];
2981
+ var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);
2982
+ var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
2983
+ var CurrentIteratorPrototype, methods, KEY;
2984
+
2985
+ // fix native
2986
+ if (anyNativeIterator) {
2987
+ CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable()));
2988
+ if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {
2989
+ if (getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {
2990
+ if (setPrototypeOf) {
2991
+ setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);
2992
+ } else if (!isCallable$2(CurrentIteratorPrototype[ITERATOR$2])) {
2993
+ defineBuiltIn$1(CurrentIteratorPrototype, ITERATOR$2, returnThis);
2994
+ }
2995
+ }
2996
+ // Set @@toStringTag to native iterators
2997
+ setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true);
2998
+ }
2999
+ }
3000
+
3001
+ // fix Array.prototype.{ values, @@iterator }.name in V8 / FF
3002
+ if (PROPER_FUNCTION_NAME && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
3003
+ if (CONFIGURABLE_FUNCTION_NAME) {
3004
+ createNonEnumerableProperty$2(IterablePrototype, 'name', VALUES);
3005
+ } else {
3006
+ INCORRECT_VALUES_NAME = true;
3007
+ defaultIterator = function values() { return call$3(nativeIterator, this); };
3008
+ }
3009
+ }
3010
+
3011
+ // export additional methods
3012
+ if (DEFAULT) {
3013
+ methods = {
3014
+ values: getIterationMethod(VALUES),
3015
+ keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
3016
+ entries: getIterationMethod(ENTRIES)
3017
+ };
3018
+ if (FORCED) for (KEY in methods) {
3019
+ if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
3020
+ defineBuiltIn$1(IterablePrototype, KEY, methods[KEY]);
3021
+ }
3022
+ } else $$4({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
3023
+ }
3024
+
3025
+ // define iterator
3026
+ if (IterablePrototype[ITERATOR$2] !== defaultIterator) {
3027
+ defineBuiltIn$1(IterablePrototype, ITERATOR$2, defaultIterator, { name: DEFAULT });
3028
+ }
3029
+ Iterators$1[NAME] = defaultIterator;
3030
+
3031
+ return methods;
3032
+ };
3033
+
3034
+ // `CreateIterResultObject` abstract operation
3035
+ // https://tc39.es/ecma262/#sec-createiterresultobject
3036
+ var createIterResultObject$1 = function (value, done) {
3037
+ return { value: value, done: done };
3038
+ };
3039
+
3040
+ var toIndexedObject = toIndexedObject$5;
3041
+ var addToUnscopables = addToUnscopables$2;
3042
+ var Iterators = iterators;
3043
+ var InternalStateModule = internalState;
3044
+ var defineProperty = objectDefineProperty.f;
3045
+ var defineIterator = iteratorDefine;
3046
+ var createIterResultObject = createIterResultObject$1;
3047
+ var DESCRIPTORS = descriptors;
3048
+
3049
+ var ARRAY_ITERATOR = 'Array Iterator';
3050
+ var setInternalState = InternalStateModule.set;
3051
+ var getInternalState$1 = InternalStateModule.getterFor(ARRAY_ITERATOR);
3052
+
3053
+ // `Array.prototype.entries` method
3054
+ // https://tc39.es/ecma262/#sec-array.prototype.entries
3055
+ // `Array.prototype.keys` method
3056
+ // https://tc39.es/ecma262/#sec-array.prototype.keys
3057
+ // `Array.prototype.values` method
3058
+ // https://tc39.es/ecma262/#sec-array.prototype.values
3059
+ // `Array.prototype[@@iterator]` method
3060
+ // https://tc39.es/ecma262/#sec-array.prototype-@@iterator
3061
+ // `CreateArrayIterator` internal method
3062
+ // https://tc39.es/ecma262/#sec-createarrayiterator
3063
+ var es_array_iterator = defineIterator(Array, 'Array', function (iterated, kind) {
3064
+ setInternalState(this, {
3065
+ type: ARRAY_ITERATOR,
3066
+ target: toIndexedObject(iterated), // target
3067
+ index: 0, // next index
3068
+ kind: kind // kind
3069
+ });
3070
+ // `%ArrayIteratorPrototype%.next` method
3071
+ // https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next
3072
+ }, function () {
3073
+ var state = getInternalState$1(this);
3074
+ var target = state.target;
3075
+ var kind = state.kind;
3076
+ var index = state.index++;
3077
+ if (!target || index >= target.length) {
3078
+ state.target = undefined;
3079
+ return createIterResultObject(undefined, true);
3080
+ }
3081
+ if (kind == 'keys') return createIterResultObject(index, false);
3082
+ if (kind == 'values') return createIterResultObject(target[index], false);
3083
+ return createIterResultObject([index, target[index]], false);
3084
+ }, 'values');
3085
+
3086
+ // argumentsList[@@iterator] is %ArrayProto_values%
3087
+ // https://tc39.es/ecma262/#sec-createunmappedargumentsobject
3088
+ // https://tc39.es/ecma262/#sec-createmappedargumentsobject
3089
+ var values = Iterators.Arguments = Iterators.Array;
3090
+
3091
+ // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
3092
+ addToUnscopables('keys');
3093
+ addToUnscopables('values');
3094
+ addToUnscopables('entries');
3095
+
3096
+ // V8 ~ Chrome 45- bug
3097
+ if (DESCRIPTORS && values.name !== 'values') try {
3098
+ defineProperty(values, 'name', { value: 'values' });
3099
+ } catch (error) { /* empty */ }
3100
+
3101
+ // iterable DOM collections
3102
+ // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
3103
+ var domIterables = {
3104
+ CSSRuleList: 0,
3105
+ CSSStyleDeclaration: 0,
3106
+ CSSValueList: 0,
3107
+ ClientRectList: 0,
3108
+ DOMRectList: 0,
3109
+ DOMStringList: 0,
3110
+ DOMTokenList: 1,
3111
+ DataTransferItemList: 0,
3112
+ FileList: 0,
3113
+ HTMLAllCollection: 0,
3114
+ HTMLCollection: 0,
3115
+ HTMLFormElement: 0,
3116
+ HTMLSelectElement: 0,
3117
+ MediaList: 0,
3118
+ MimeTypeArray: 0,
3119
+ NamedNodeMap: 0,
3120
+ NodeList: 1,
3121
+ PaintRequestList: 0,
3122
+ Plugin: 0,
3123
+ PluginArray: 0,
3124
+ SVGLengthList: 0,
3125
+ SVGNumberList: 0,
3126
+ SVGPathSegList: 0,
3127
+ SVGPointList: 0,
3128
+ SVGStringList: 0,
3129
+ SVGTransformList: 0,
3130
+ SourceBufferList: 0,
3131
+ StyleSheetList: 0,
3132
+ TextTrackCueList: 0,
3133
+ TextTrackList: 0,
3134
+ TouchList: 0
3135
+ };
3136
+
3137
+ // in old WebKit versions, `element.classList` is not an instance of global `DOMTokenList`
3138
+ var documentCreateElement = documentCreateElement$2;
3139
+
3140
+ var classList = documentCreateElement('span').classList;
3141
+ var DOMTokenListPrototype$1 = classList && classList.constructor && classList.constructor.prototype;
3142
+
3143
+ var domTokenListPrototype = DOMTokenListPrototype$1 === Object.prototype ? undefined : DOMTokenListPrototype$1;
3144
+
3145
+ var global$5 = global$n;
3146
+ var DOMIterables = domIterables;
3147
+ var DOMTokenListPrototype = domTokenListPrototype;
3148
+ var ArrayIteratorMethods = es_array_iterator;
3149
+ var createNonEnumerableProperty$1 = createNonEnumerableProperty$5;
3150
+ var wellKnownSymbol$2 = wellKnownSymbol$i;
3151
+
3152
+ var ITERATOR$1 = wellKnownSymbol$2('iterator');
3153
+ var TO_STRING_TAG = wellKnownSymbol$2('toStringTag');
3154
+ var ArrayValues = ArrayIteratorMethods.values;
3155
+
3156
+ var handlePrototype = function (CollectionPrototype, COLLECTION_NAME) {
3157
+ if (CollectionPrototype) {
3158
+ // some Chrome versions have non-configurable methods on DOMTokenList
3159
+ if (CollectionPrototype[ITERATOR$1] !== ArrayValues) try {
3160
+ createNonEnumerableProperty$1(CollectionPrototype, ITERATOR$1, ArrayValues);
3161
+ } catch (error) {
3162
+ CollectionPrototype[ITERATOR$1] = ArrayValues;
3163
+ }
3164
+ if (!CollectionPrototype[TO_STRING_TAG]) {
3165
+ createNonEnumerableProperty$1(CollectionPrototype, TO_STRING_TAG, COLLECTION_NAME);
3166
+ }
3167
+ if (DOMIterables[COLLECTION_NAME]) for (var METHOD_NAME in ArrayIteratorMethods) {
3168
+ // some Chrome versions have non-configurable methods on DOMTokenList
3169
+ if (CollectionPrototype[METHOD_NAME] !== ArrayIteratorMethods[METHOD_NAME]) try {
3170
+ createNonEnumerableProperty$1(CollectionPrototype, METHOD_NAME, ArrayIteratorMethods[METHOD_NAME]);
3171
+ } catch (error) {
3172
+ CollectionPrototype[METHOD_NAME] = ArrayIteratorMethods[METHOD_NAME];
3173
+ }
3174
+ }
3175
+ }
3176
+ };
3177
+
3178
+ for (var COLLECTION_NAME in DOMIterables) {
3179
+ handlePrototype(global$5[COLLECTION_NAME] && global$5[COLLECTION_NAME].prototype, COLLECTION_NAME);
3180
+ }
3181
+
3182
+ handlePrototype(DOMTokenListPrototype, 'DOMTokenList');
3183
+
3184
+ class Ninetailed {
3185
+ constructor(ninetailedApiClientInstanceOrOptions, {
3186
+ plugins,
3187
+ url,
3188
+ profile,
3189
+ locale,
3190
+ requestTimeout,
3191
+ onLog,
3192
+ onError
3193
+ } = {}) {
3194
+ this.isInitialized = false;
3195
+ this.page = (data, options) => __awaiter(this, void 0, void 0, function* () {
3196
+ try {
3197
+ const result = experience_jsShared.PageviewProperties.partial().default({}).safeParse(data);
3198
+ if (!result.success) {
3199
+ throw new Error(`[Validation Error] "page" was called with invalid params. Page data is not valid: ${result.error.format()}`);
3200
+ }
3201
+ yield this.waitUntilInitialized();
3202
+ yield this.instance.page(data, this.buildOptions(options));
3203
+ return this.eventQueue.flush();
3204
+ } catch (error) {
3205
+ experience_jsShared.logger.error(error);
3206
+ if (error instanceof RangeError) {
3207
+ throw new Error(`[Validation Error] "page" was called with invalid params. Could not validate due to "RangeError: Maximum call stack size exceeded". This can be caused by passing a cyclic data structure as a parameter. Refrain from passing a cyclic data structure or sanitize it beforehand.`);
3208
+ }
3209
+ throw error;
3210
+ }
3211
+ });
3212
+ this.track = (event, properties, options) => __awaiter(this, void 0, void 0, function* () {
3213
+ try {
3214
+ const result = experience_jsShared.Properties.default({}).safeParse(properties);
3215
+ if (!result.success) {
3216
+ throw new Error(`[Validation Error] "track" was called with invalid params. Properties are no valid json object: ${result.error.format()}`);
3217
+ }
3218
+ yield this.waitUntilInitialized();
3219
+ yield this.instance.track(event.toString(), result.data, this.buildOptions(options));
3220
+ return this.eventQueue.flush();
3221
+ } catch (error) {
3222
+ experience_jsShared.logger.error(error);
3223
+ if (error instanceof RangeError) {
3224
+ throw new Error(`[Validation Error] "track" was called with invalid params. Could not validate due to "RangeError: Maximum call stack size exceeded". This can be caused by passing a cyclic data structure as a parameter. Refrain from passing a cyclic data structure or sanitize it beforehand.`);
3225
+ }
3226
+ throw error;
3227
+ }
3228
+ });
3229
+ this.trackHasSeenComponent = properties => __awaiter(this, void 0, void 0, function* () {
3230
+ return this.instance.dispatch(Object.assign(Object.assign({}, properties), {
3231
+ type: experience_jsPluginAnalytics.HAS_SEEN_COMPONENT
3232
+ }));
3233
+ });
3234
+ this.trackHasSeenExperience = properties => {
3235
+ return this.instance.dispatch(Object.assign(Object.assign({}, properties), {
3236
+ type: experience_jsPluginAnalytics.HAS_SEEN_EXPERIENCE
3237
+ }));
3238
+ };
3239
+ this.identify = (uid, traits, options) => __awaiter(this, void 0, void 0, function* () {
3240
+ try {
3241
+ const result = experience_jsShared.Traits.default({}).safeParse(traits);
3242
+ if (!result.success) {
3243
+ throw new Error(`[Validation Error] "identify" was called with invalid params. Traits are no valid json: ${result.error.format()}`);
3244
+ }
3245
+ yield this.waitUntilInitialized();
3246
+ yield this.instance.identify(uid.toString(), result.data, this.buildOptions(options));
3247
+ return this.eventQueue.flush();
3248
+ } catch (error) {
3249
+ experience_jsShared.logger.error(error);
3250
+ if (error instanceof RangeError) {
3251
+ throw new Error(`[Validation Error] "identify" was called with invalid params. Could not validate due to "RangeError: Maximum call stack size exceeded". This can be caused by passing a cyclic data structure as a parameter. Refrain from passing a cyclic data structure or sanitize it beforehand.`);
3252
+ }
3253
+ throw error;
3254
+ }
3255
+ });
3256
+ this.reset = () => __awaiter(this, void 0, void 0, function* () {
3257
+ yield this.waitUntilInitialized();
3258
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3259
+ // @ts-ignore
3260
+ this.instance.plugins[PLUGIN_NAME].reset();
3261
+ });
3262
+ this.debug = enabled => __awaiter(this, void 0, void 0, function* () {
3263
+ yield this.waitUntilInitialized();
3264
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3265
+ // @ts-ignore
3266
+ this.instance.plugins[PLUGIN_NAME].debug(enabled);
3267
+ });
3268
+ this.onProfileChange = cb => {
3269
+ cb(this.profileState);
3270
+ return this.instance.on(PROFILE_CHANGE, ({
3271
+ payload
3272
+ }) => {
3273
+ if (payload.error) {
3274
+ cb(Object.assign(Object.assign({}, this._profileState), {
3275
+ status: 'error',
3276
+ profile: payload.profile,
3277
+ error: payload.error
3278
+ }));
3279
+ } else {
3280
+ cb(Object.assign(Object.assign({}, this._profileState), {
3281
+ status: 'success',
3282
+ profile: payload.profile,
3283
+ error: null
3284
+ }));
3285
+ }
3286
+ });
3287
+ };
3288
+ this.onIsInitialized = onIsInitialized => {
3289
+ if (typeof onIsInitialized === 'function') {
3290
+ if (this.isInitialized) {
3291
+ onIsInitialized();
3292
+ } else {
3293
+ const detachOnReadyListener = this.instance.on('ready', () => {
3294
+ this.isInitialized = true;
3295
+ onIsInitialized();
3296
+ detachOnReadyListener();
3297
+ });
3298
+ }
3299
+ }
3300
+ };
3301
+ this.waitUntilInitialized = () => {
3302
+ return new Promise(resolve => {
3303
+ this.onIsInitialized(resolve);
3304
+ });
3305
+ };
3306
+ if (ninetailedApiClientInstanceOrOptions instanceof experience_jsShared.NinetailedApiClient) {
3307
+ this.apiClient = ninetailedApiClientInstanceOrOptions;
3308
+ } else {
3309
+ const {
3310
+ clientId,
3311
+ environment,
3312
+ preview
3313
+ } = ninetailedApiClientInstanceOrOptions;
3314
+ this.apiClient = new experience_jsShared.NinetailedApiClient({
3315
+ clientId,
3316
+ environment,
3317
+ url,
3318
+ preview
3319
+ });
3320
+ }
3321
+ this.plugins = flatten__default["default"](plugins || []);
3322
+ if (profile) {
3323
+ this._profileState = {
3324
+ status: 'success',
3325
+ profile,
3326
+ error: null,
3327
+ from: 'hydrated'
3328
+ };
3329
+ } else {
3330
+ this._profileState = {
3331
+ status: 'loading',
3332
+ profile: null,
3333
+ error: null,
3334
+ from: 'api'
3335
+ };
3336
+ }
3337
+ if (typeof onLog === 'function') {
3338
+ experience_jsShared.logger.addSink(new experience_jsShared.OnLogLogSink(onLog));
3339
+ }
3340
+ if (typeof onError === 'function') {
3341
+ experience_jsShared.logger.addSink(new experience_jsShared.OnErrorLogSink(onError));
3342
+ }
3343
+ this.logger = experience_jsShared.logger;
3344
+ this.eventQueue = ninetailedPlugin({
3345
+ apiClient: this.apiClient,
3346
+ profile,
3347
+ locale,
3348
+ requestTimeout,
3349
+ ninetailed: this
3350
+ });
3351
+ this.instance = Analytics__default["default"]({
3352
+ app: 'ninetailed',
3353
+ plugins: [...this.plugins, this.eventQueue]
3354
+ });
3355
+ const detachOnReadyListener = this.instance.on('ready', () => {
3356
+ this.isInitialized = true;
3357
+ experience_jsShared.logger.info('Ninetailed Experience.js SDK is completely initialized.');
3358
+ detachOnReadyListener();
3359
+ });
3360
+ // put in private method
3361
+ this.onProfileChange(profileState => {
3362
+ this._profileState = profileState;
3363
+ if (typeof window !== 'undefined') {
3364
+ window.ninetailed = Object.assign({}, window.ninetailed, {
3365
+ profile: this.profileState.profile
3366
+ });
3367
+ }
3368
+ });
3369
+ this.registerWindowHandlers();
3370
+ }
3371
+ get profileState() {
3372
+ return this._profileState;
3373
+ }
3374
+ buildOptions(options = {}) {
3375
+ return Object.assign({}, options);
3376
+ }
3377
+ registerWindowHandlers() {
3378
+ if (typeof window !== 'undefined') {
3379
+ window.ninetailed = Object.assign({}, window.ninetailed, {
3380
+ page: this.page.bind(this),
3381
+ track: this.track.bind(this),
3382
+ trackHasSeenComponent: this.trackHasSeenComponent.bind(this),
3383
+ trackHasSeenExperience: this.trackHasSeenExperience.bind(this),
3384
+ identify: this.identify.bind(this),
3385
+ reset: this.reset.bind(this),
3386
+ debug: this.debug.bind(this),
3387
+ profile: this.profileState.profile
3388
+ });
3389
+ }
3390
+ }
3391
+ }
3392
+
3393
+ const selectVariant$1 = (baseline, variants, {
3394
+ status,
3395
+ profile,
3396
+ error
3397
+ }, options = {
3398
+ holdout: -1
3399
+ }) => {
3400
+ if (status === 'loading') {
3401
+ return {
3402
+ loading: true,
3403
+ variant: Object.assign(Object.assign({}, baseline), {
3404
+ id: 'baseline',
3405
+ audience: {
3406
+ id: 'baseline'
3407
+ }
3408
+ }),
3409
+ audience: {
3410
+ id: 'baseline'
3411
+ },
3412
+ isPersonalized: false,
3413
+ error: null
3414
+ };
3415
+ }
3416
+ if (status === 'error') {
3417
+ return {
3418
+ loading: false,
3419
+ variant: Object.assign(Object.assign({}, baseline), {
3420
+ id: 'baseline',
3421
+ audience: {
3422
+ id: 'baseline'
3423
+ }
3424
+ }),
3425
+ audience: {
3426
+ id: 'baseline'
3427
+ },
3428
+ isPersonalized: false,
3429
+ error: error
3430
+ };
3431
+ }
3432
+ const variant = find__default["default"](variants, variant => {
3433
+ var _a;
3434
+ return includes__default["default"](profile === null || profile === void 0 ? void 0 : profile.audiences, (_a = variant.audience) === null || _a === void 0 ? void 0 : _a.id);
3435
+ });
3436
+ if (variant) {
3437
+ if ((options === null || options === void 0 ? void 0 : options.holdout) || -1 > (profile === null || profile === void 0 ? void 0 : profile.random)) {
3438
+ return {
3439
+ loading: false,
3440
+ variant: Object.assign(Object.assign({}, baseline), {
3441
+ audience: {
3442
+ id: 'baseline'
3443
+ }
3444
+ }),
3445
+ audience: Object.assign(Object.assign({}, variant.audience), {
3446
+ id: variant.audience.id
3447
+ }),
3448
+ isPersonalized: false,
3449
+ error: null
3450
+ };
3451
+ }
3452
+ return {
3453
+ loading: false,
3454
+ variant,
3455
+ audience: Object.assign(Object.assign({}, variant.audience), {
3456
+ id: variant.audience.id
3457
+ }),
3458
+ isPersonalized: true,
3459
+ error: null
3460
+ };
3461
+ }
3462
+ /**
3463
+ * There was no matching audience found.
3464
+ */
3465
+ return {
3466
+ loading: false,
3467
+ variant: Object.assign(Object.assign({}, baseline), {
3468
+ id: 'baseline',
3469
+ audience: {
3470
+ id: 'baseline'
3471
+ }
3472
+ }),
3473
+ audience: {
3474
+ id: 'baseline'
3475
+ },
3476
+ isPersonalized: false,
3477
+ error: null
3478
+ };
3479
+ };
3480
+
3481
+ const EXPERIENCE_TRAIT_PREFIX = 'nt_experiment_';
3482
+
3483
+ const selectBaselineWithVariants = (experience, baseline) => {
3484
+ var _a;
3485
+ return (_a = experience.components.find(baselineWithVariants => baselineWithVariants.baseline.id === baseline.id)) !== null && _a !== void 0 ? _a : null;
3486
+ };
3487
+
3488
+ const selectVariants = (experience, baseline) => {
3489
+ const baselineWithVariants = selectBaselineWithVariants(experience, baseline);
3490
+ if (!baselineWithVariants) {
3491
+ return [];
3492
+ }
3493
+ return baselineWithVariants.variants;
3494
+ };
3495
+
3496
+ const selectHasVariants = (experience, baseline) => {
3497
+ const variants = selectVariants(experience, baseline);
3498
+ return variants.length > 0;
3499
+ };
3500
+
3501
+ var $$3 = _export;
3502
+ var uncurryThis$7 = functionUncurryThisClause;
3503
+ var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
3504
+ var toLength$1 = toLength$3;
3505
+ var toString$5 = toString$7;
3506
+ var notARegExp = notARegexp;
3507
+ var requireObjectCoercible$3 = requireObjectCoercible$7;
3508
+ var correctIsRegExpLogic = correctIsRegexpLogic;
3509
+
3510
+ // eslint-disable-next-line es/no-string-prototype-startswith -- safe
3511
+ var nativeStartsWith = uncurryThis$7(''.startsWith);
3512
+ var stringSlice$4 = uncurryThis$7(''.slice);
3513
+ var min$1 = Math.min;
3514
+
3515
+ var CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('startsWith');
3516
+ // https://github.com/zloirock/core-js/pull/702
3517
+ var MDN_POLYFILL_BUG = !CORRECT_IS_REGEXP_LOGIC && !!function () {
3518
+ var descriptor = getOwnPropertyDescriptor(String.prototype, 'startsWith');
3519
+ return descriptor && !descriptor.writable;
3520
+ }();
3521
+
3522
+ // `String.prototype.startsWith` method
3523
+ // https://tc39.es/ecma262/#sec-string.prototype.startswith
3524
+ $$3({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC }, {
3525
+ startsWith: function startsWith(searchString /* , position = 0 */) {
3526
+ var that = toString$5(requireObjectCoercible$3(this));
3527
+ notARegExp(searchString);
3528
+ var index = toLength$1(min$1(arguments.length > 1 ? arguments[1] : undefined, that.length));
3529
+ var search = toString$5(searchString);
3530
+ return nativeStartsWith
3531
+ ? nativeStartsWith(that, search, index)
3532
+ : stringSlice$4(that, index, index + search.length) === search;
3533
+ }
3534
+ });
3535
+
3536
+ var fails$6 = fails$m;
3537
+ var global$4 = global$n;
3538
+
3539
+ // babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError
3540
+ var $RegExp$2 = global$4.RegExp;
3541
+
3542
+ var UNSUPPORTED_Y$1 = fails$6(function () {
3543
+ var re = $RegExp$2('a', 'y');
3544
+ re.lastIndex = 2;
3545
+ return re.exec('abcd') != null;
3546
+ });
3547
+
3548
+ // UC Browser bug
3549
+ // https://github.com/zloirock/core-js/issues/1008
3550
+ var MISSED_STICKY = UNSUPPORTED_Y$1 || fails$6(function () {
3551
+ return !$RegExp$2('a', 'y').sticky;
3552
+ });
3553
+
3554
+ var BROKEN_CARET = UNSUPPORTED_Y$1 || fails$6(function () {
3555
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=773687
3556
+ var re = $RegExp$2('^r', 'gy');
3557
+ re.lastIndex = 2;
3558
+ return re.exec('str') != null;
3559
+ });
3560
+
3561
+ var regexpStickyHelpers = {
3562
+ BROKEN_CARET: BROKEN_CARET,
3563
+ MISSED_STICKY: MISSED_STICKY,
3564
+ UNSUPPORTED_Y: UNSUPPORTED_Y$1
3565
+ };
3566
+
3567
+ var fails$5 = fails$m;
3568
+ var global$3 = global$n;
3569
+
3570
+ // babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError
3571
+ var $RegExp$1 = global$3.RegExp;
3572
+
3573
+ var regexpUnsupportedDotAll = fails$5(function () {
3574
+ var re = $RegExp$1('.', 's');
3575
+ return !(re.dotAll && re.exec('\n') && re.flags === 's');
3576
+ });
3577
+
3578
+ var fails$4 = fails$m;
3579
+ var global$2 = global$n;
3580
+
3581
+ // babel-minify and Closure Compiler transpiles RegExp('(?<a>b)', 'g') -> /(?<a>b)/g and it causes SyntaxError
3582
+ var $RegExp = global$2.RegExp;
3583
+
3584
+ var regexpUnsupportedNcg = fails$4(function () {
3585
+ var re = $RegExp('(?<a>b)', 'g');
3586
+ return re.exec('b').groups.a !== 'b' ||
3587
+ 'b'.replace(re, '$<a>c') !== 'bc';
3588
+ });
3589
+
3590
+ /* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */
3591
+ /* eslint-disable regexp/no-useless-quantifier -- testing */
3592
+ var call$2 = functionCall;
3593
+ var uncurryThis$6 = functionUncurryThis;
3594
+ var toString$4 = toString$7;
3595
+ var regexpFlags = regexpFlags$1;
3596
+ var stickyHelpers = regexpStickyHelpers;
3597
+ var shared = shared$4.exports;
3598
+ var create = objectCreate;
3599
+ var getInternalState = internalState.get;
3600
+ var UNSUPPORTED_DOT_ALL = regexpUnsupportedDotAll;
3601
+ var UNSUPPORTED_NCG = regexpUnsupportedNcg;
3602
+
3603
+ var nativeReplace = shared('native-string-replace', String.prototype.replace);
3604
+ var nativeExec = RegExp.prototype.exec;
3605
+ var patchedExec = nativeExec;
3606
+ var charAt$3 = uncurryThis$6(''.charAt);
3607
+ var indexOf = uncurryThis$6(''.indexOf);
3608
+ var replace$2 = uncurryThis$6(''.replace);
3609
+ var stringSlice$3 = uncurryThis$6(''.slice);
3610
+
3611
+ var UPDATES_LAST_INDEX_WRONG = (function () {
3612
+ var re1 = /a/;
3613
+ var re2 = /b*/g;
3614
+ call$2(nativeExec, re1, 'a');
3615
+ call$2(nativeExec, re2, 'a');
3616
+ return re1.lastIndex !== 0 || re2.lastIndex !== 0;
3617
+ })();
3618
+
3619
+ var UNSUPPORTED_Y = stickyHelpers.BROKEN_CARET;
3620
+
3621
+ // nonparticipating capturing group, copied from es5-shim's String#split patch.
3622
+ var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
3623
+
3624
+ var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y || UNSUPPORTED_DOT_ALL || UNSUPPORTED_NCG;
3625
+
3626
+ if (PATCH) {
3627
+ patchedExec = function exec(string) {
3628
+ var re = this;
3629
+ var state = getInternalState(re);
3630
+ var str = toString$4(string);
3631
+ var raw = state.raw;
3632
+ var result, reCopy, lastIndex, match, i, object, group;
3633
+
3634
+ if (raw) {
3635
+ raw.lastIndex = re.lastIndex;
3636
+ result = call$2(patchedExec, raw, str);
3637
+ re.lastIndex = raw.lastIndex;
3638
+ return result;
3639
+ }
3640
+
3641
+ var groups = state.groups;
3642
+ var sticky = UNSUPPORTED_Y && re.sticky;
3643
+ var flags = call$2(regexpFlags, re);
3644
+ var source = re.source;
3645
+ var charsAdded = 0;
3646
+ var strCopy = str;
3647
+
3648
+ if (sticky) {
3649
+ flags = replace$2(flags, 'y', '');
3650
+ if (indexOf(flags, 'g') === -1) {
3651
+ flags += 'g';
3652
+ }
3653
+
3654
+ strCopy = stringSlice$3(str, re.lastIndex);
3655
+ // Support anchored sticky behavior.
3656
+ if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt$3(str, re.lastIndex - 1) !== '\n')) {
3657
+ source = '(?: ' + source + ')';
3658
+ strCopy = ' ' + strCopy;
3659
+ charsAdded++;
3660
+ }
3661
+ // ^(? + rx + ) is needed, in combination with some str slicing, to
3662
+ // simulate the 'y' flag.
3663
+ reCopy = new RegExp('^(?:' + source + ')', flags);
3664
+ }
3665
+
3666
+ if (NPCG_INCLUDED) {
3667
+ reCopy = new RegExp('^' + source + '$(?!\\s)', flags);
3668
+ }
3669
+ if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;
3670
+
3671
+ match = call$2(nativeExec, sticky ? reCopy : re, strCopy);
3672
+
3673
+ if (sticky) {
3674
+ if (match) {
3675
+ match.input = stringSlice$3(match.input, charsAdded);
3676
+ match[0] = stringSlice$3(match[0], charsAdded);
3677
+ match.index = re.lastIndex;
3678
+ re.lastIndex += match[0].length;
3679
+ } else re.lastIndex = 0;
3680
+ } else if (UPDATES_LAST_INDEX_WRONG && match) {
3681
+ re.lastIndex = re.global ? match.index + match[0].length : lastIndex;
3682
+ }
3683
+ if (NPCG_INCLUDED && match && match.length > 1) {
3684
+ // Fix browsers whose `exec` methods don't consistently return `undefined`
3685
+ // for NPCG, like IE8. NOTE: This doesn't work for /(.?)?/
3686
+ call$2(nativeReplace, match[0], reCopy, function () {
3687
+ for (i = 1; i < arguments.length - 2; i++) {
3688
+ if (arguments[i] === undefined) match[i] = undefined;
3689
+ }
3690
+ });
3691
+ }
3692
+
3693
+ if (match && groups) {
3694
+ match.groups = object = create(null);
3695
+ for (i = 0; i < groups.length; i++) {
3696
+ group = groups[i];
3697
+ object[group[0]] = match[group[1]];
3698
+ }
3699
+ }
3700
+
3701
+ return match;
3702
+ };
3703
+ }
3704
+
3705
+ var regexpExec$2 = patchedExec;
3706
+
3707
+ var $$2 = _export;
3708
+ var exec$1 = regexpExec$2;
3709
+
3710
+ // `RegExp.prototype.exec` method
3711
+ // https://tc39.es/ecma262/#sec-regexp.prototype.exec
3712
+ $$2({ target: 'RegExp', proto: true, forced: /./.exec !== exec$1 }, {
3713
+ exec: exec$1
3714
+ });
3715
+
3716
+ // TODO: Remove from `core-js@4` since it's moved to entry points
3717
+
3718
+ var uncurryThis$5 = functionUncurryThisClause;
3719
+ var defineBuiltIn = defineBuiltIn$7;
3720
+ var regexpExec$1 = regexpExec$2;
3721
+ var fails$3 = fails$m;
3722
+ var wellKnownSymbol$1 = wellKnownSymbol$i;
3723
+ var createNonEnumerableProperty = createNonEnumerableProperty$5;
3724
+
3725
+ var SPECIES = wellKnownSymbol$1('species');
3726
+ var RegExpPrototype = RegExp.prototype;
3727
+
3728
+ var fixRegexpWellKnownSymbolLogic = function (KEY, exec, FORCED, SHAM) {
3729
+ var SYMBOL = wellKnownSymbol$1(KEY);
3730
+
3731
+ var DELEGATES_TO_SYMBOL = !fails$3(function () {
3732
+ // String methods call symbol-named RegEp methods
3733
+ var O = {};
3734
+ O[SYMBOL] = function () { return 7; };
3735
+ return ''[KEY](O) != 7;
3736
+ });
3737
+
3738
+ var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails$3(function () {
3739
+ // Symbol-named RegExp methods call .exec
3740
+ var execCalled = false;
3741
+ var re = /a/;
3742
+
3743
+ if (KEY === 'split') {
3744
+ // We can't use real regex here since it causes deoptimization
3745
+ // and serious performance degradation in V8
3746
+ // https://github.com/zloirock/core-js/issues/306
3747
+ re = {};
3748
+ // RegExp[@@split] doesn't call the regex's exec method, but first creates
3749
+ // a new one. We need to return the patched regex when creating the new one.
3750
+ re.constructor = {};
3751
+ re.constructor[SPECIES] = function () { return re; };
3752
+ re.flags = '';
3753
+ re[SYMBOL] = /./[SYMBOL];
3754
+ }
3755
+
3756
+ re.exec = function () { execCalled = true; return null; };
3757
+
3758
+ re[SYMBOL]('');
3759
+ return !execCalled;
3760
+ });
3761
+
3762
+ if (
3763
+ !DELEGATES_TO_SYMBOL ||
3764
+ !DELEGATES_TO_EXEC ||
3765
+ FORCED
3766
+ ) {
3767
+ var uncurriedNativeRegExpMethod = uncurryThis$5(/./[SYMBOL]);
3768
+ var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {
3769
+ var uncurriedNativeMethod = uncurryThis$5(nativeMethod);
3770
+ var $exec = regexp.exec;
3771
+ if ($exec === regexpExec$1 || $exec === RegExpPrototype.exec) {
3772
+ if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
3773
+ // The native String method already delegates to @@method (this
3774
+ // polyfilled function), leasing to infinite recursion.
3775
+ // We avoid it by directly calling the native @@method method.
3776
+ return { done: true, value: uncurriedNativeRegExpMethod(regexp, str, arg2) };
3777
+ }
3778
+ return { done: true, value: uncurriedNativeMethod(str, regexp, arg2) };
3779
+ }
3780
+ return { done: false };
3781
+ });
3782
+
3783
+ defineBuiltIn(String.prototype, KEY, methods[0]);
3784
+ defineBuiltIn(RegExpPrototype, SYMBOL, methods[1]);
3785
+ }
3786
+
3787
+ if (SHAM) createNonEnumerableProperty(RegExpPrototype[SYMBOL], 'sham', true);
3788
+ };
3789
+
3790
+ var uncurryThis$4 = functionUncurryThis;
3791
+ var toIntegerOrInfinity$1 = toIntegerOrInfinity$4;
3792
+ var toString$3 = toString$7;
3793
+ var requireObjectCoercible$2 = requireObjectCoercible$7;
3794
+
3795
+ var charAt$2 = uncurryThis$4(''.charAt);
3796
+ var charCodeAt = uncurryThis$4(''.charCodeAt);
3797
+ var stringSlice$2 = uncurryThis$4(''.slice);
3798
+
3799
+ var createMethod$2 = function (CONVERT_TO_STRING) {
3800
+ return function ($this, pos) {
3801
+ var S = toString$3(requireObjectCoercible$2($this));
3802
+ var position = toIntegerOrInfinity$1(pos);
3803
+ var size = S.length;
3804
+ var first, second;
3805
+ if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
3806
+ first = charCodeAt(S, position);
3807
+ return first < 0xD800 || first > 0xDBFF || position + 1 === size
3808
+ || (second = charCodeAt(S, position + 1)) < 0xDC00 || second > 0xDFFF
3809
+ ? CONVERT_TO_STRING
3810
+ ? charAt$2(S, position)
3811
+ : first
3812
+ : CONVERT_TO_STRING
3813
+ ? stringSlice$2(S, position, position + 2)
3814
+ : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
3815
+ };
3816
+ };
3817
+
3818
+ var stringMultibyte = {
3819
+ // `String.prototype.codePointAt` method
3820
+ // https://tc39.es/ecma262/#sec-string.prototype.codepointat
3821
+ codeAt: createMethod$2(false),
3822
+ // `String.prototype.at` method
3823
+ // https://github.com/mathiasbynens/String.prototype.at
3824
+ charAt: createMethod$2(true)
3825
+ };
3826
+
3827
+ var charAt$1 = stringMultibyte.charAt;
3828
+
3829
+ // `AdvanceStringIndex` abstract operation
3830
+ // https://tc39.es/ecma262/#sec-advancestringindex
3831
+ var advanceStringIndex$1 = function (S, index, unicode) {
3832
+ return index + (unicode ? charAt$1(S, index).length : 1);
3833
+ };
3834
+
3835
+ var uncurryThis$3 = functionUncurryThis;
3836
+ var toObject$1 = toObject$5;
3837
+
3838
+ var floor = Math.floor;
3839
+ var charAt = uncurryThis$3(''.charAt);
3840
+ var replace$1 = uncurryThis$3(''.replace);
3841
+ var stringSlice$1 = uncurryThis$3(''.slice);
3842
+ var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d{1,2}|<[^>]*>)/g;
3843
+ var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d{1,2})/g;
3844
+
3845
+ // `GetSubstitution` abstract operation
3846
+ // https://tc39.es/ecma262/#sec-getsubstitution
3847
+ var getSubstitution$1 = function (matched, str, position, captures, namedCaptures, replacement) {
3848
+ var tailPos = position + matched.length;
3849
+ var m = captures.length;
3850
+ var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;
3851
+ if (namedCaptures !== undefined) {
3852
+ namedCaptures = toObject$1(namedCaptures);
3853
+ symbols = SUBSTITUTION_SYMBOLS;
3854
+ }
3855
+ return replace$1(replacement, symbols, function (match, ch) {
3856
+ var capture;
3857
+ switch (charAt(ch, 0)) {
3858
+ case '$': return '$';
3859
+ case '&': return matched;
3860
+ case '`': return stringSlice$1(str, 0, position);
3861
+ case "'": return stringSlice$1(str, tailPos);
3862
+ case '<':
3863
+ capture = namedCaptures[stringSlice$1(ch, 1, -1)];
3864
+ break;
3865
+ default: // \d\d?
3866
+ var n = +ch;
3867
+ if (n === 0) return match;
3868
+ if (n > m) {
3869
+ var f = floor(n / 10);
3870
+ if (f === 0) return match;
3871
+ if (f <= m) return captures[f - 1] === undefined ? charAt(ch, 1) : captures[f - 1] + charAt(ch, 1);
3872
+ return match;
3873
+ }
3874
+ capture = captures[n - 1];
3875
+ }
3876
+ return capture === undefined ? '' : capture;
3877
+ });
3878
+ };
3879
+
3880
+ var call$1 = functionCall;
3881
+ var anObject$1 = anObject$e;
3882
+ var isCallable$1 = isCallable$m;
3883
+ var classof = classofRaw$2;
3884
+ var regexpExec = regexpExec$2;
3885
+
3886
+ var $TypeError$1 = TypeError;
3887
+
3888
+ // `RegExpExec` abstract operation
3889
+ // https://tc39.es/ecma262/#sec-regexpexec
3890
+ var regexpExecAbstract = function (R, S) {
3891
+ var exec = R.exec;
3892
+ if (isCallable$1(exec)) {
3893
+ var result = call$1(exec, R, S);
3894
+ if (result !== null) anObject$1(result);
3895
+ return result;
3896
+ }
3897
+ if (classof(R) === 'RegExp') return call$1(regexpExec, R, S);
3898
+ throw $TypeError$1('RegExp#exec called on incompatible receiver');
3899
+ };
3900
+
3901
+ var apply = functionApply;
3902
+ var call = functionCall;
3903
+ var uncurryThis$2 = functionUncurryThis;
3904
+ var fixRegExpWellKnownSymbolLogic = fixRegexpWellKnownSymbolLogic;
3905
+ var fails$2 = fails$m;
3906
+ var anObject = anObject$e;
3907
+ var isCallable = isCallable$m;
3908
+ var isNullOrUndefined = isNullOrUndefined$5;
3909
+ var toIntegerOrInfinity = toIntegerOrInfinity$4;
3910
+ var toLength = toLength$3;
3911
+ var toString$2 = toString$7;
3912
+ var requireObjectCoercible$1 = requireObjectCoercible$7;
3913
+ var advanceStringIndex = advanceStringIndex$1;
3914
+ var getMethod = getMethod$4;
3915
+ var getSubstitution = getSubstitution$1;
3916
+ var regExpExec = regexpExecAbstract;
3917
+ var wellKnownSymbol = wellKnownSymbol$i;
3918
+
3919
+ var REPLACE = wellKnownSymbol('replace');
3920
+ var max = Math.max;
3921
+ var min = Math.min;
3922
+ var concat = uncurryThis$2([].concat);
3923
+ var push = uncurryThis$2([].push);
3924
+ var stringIndexOf = uncurryThis$2(''.indexOf);
3925
+ var stringSlice = uncurryThis$2(''.slice);
3926
+
3927
+ var maybeToString = function (it) {
3928
+ return it === undefined ? it : String(it);
3929
+ };
3930
+
3931
+ // IE <= 11 replaces $0 with the whole match, as if it was $&
3932
+ // https://stackoverflow.com/questions/6024666/getting-ie-to-replace-a-regex-with-the-literal-string-0
3933
+ var REPLACE_KEEPS_$0 = (function () {
3934
+ // eslint-disable-next-line regexp/prefer-escape-replacement-dollar-char -- required for testing
3935
+ return 'a'.replace(/./, '$0') === '$0';
3936
+ })();
3937
+
3938
+ // Safari <= 13.0.3(?) substitutes nth capture where n>m with an empty string
3939
+ var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = (function () {
3940
+ if (/./[REPLACE]) {
3941
+ return /./[REPLACE]('a', '$0') === '';
3942
+ }
3943
+ return false;
3944
+ })();
3945
+
3946
+ var REPLACE_SUPPORTS_NAMED_GROUPS = !fails$2(function () {
3947
+ var re = /./;
3948
+ re.exec = function () {
3949
+ var result = [];
3950
+ result.groups = { a: '7' };
3951
+ return result;
3952
+ };
3953
+ // eslint-disable-next-line regexp/no-useless-dollar-replacements -- false positive
3954
+ return ''.replace(re, '$<a>') !== '7';
3955
+ });
3956
+
3957
+ // @@replace logic
3958
+ fixRegExpWellKnownSymbolLogic('replace', function (_, nativeReplace, maybeCallNative) {
3959
+ var UNSAFE_SUBSTITUTE = REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE ? '$' : '$0';
3960
+
3961
+ return [
3962
+ // `String.prototype.replace` method
3963
+ // https://tc39.es/ecma262/#sec-string.prototype.replace
3964
+ function replace(searchValue, replaceValue) {
3965
+ var O = requireObjectCoercible$1(this);
3966
+ var replacer = isNullOrUndefined(searchValue) ? undefined : getMethod(searchValue, REPLACE);
3967
+ return replacer
3968
+ ? call(replacer, searchValue, O, replaceValue)
3969
+ : call(nativeReplace, toString$2(O), searchValue, replaceValue);
3970
+ },
3971
+ // `RegExp.prototype[@@replace]` method
3972
+ // https://tc39.es/ecma262/#sec-regexp.prototype-@@replace
3973
+ function (string, replaceValue) {
3974
+ var rx = anObject(this);
3975
+ var S = toString$2(string);
3976
+
3977
+ if (
3978
+ typeof replaceValue == 'string' &&
3979
+ stringIndexOf(replaceValue, UNSAFE_SUBSTITUTE) === -1 &&
3980
+ stringIndexOf(replaceValue, '$<') === -1
3981
+ ) {
3982
+ var res = maybeCallNative(nativeReplace, rx, S, replaceValue);
3983
+ if (res.done) return res.value;
3984
+ }
3985
+
3986
+ var functionalReplace = isCallable(replaceValue);
3987
+ if (!functionalReplace) replaceValue = toString$2(replaceValue);
3988
+
3989
+ var global = rx.global;
3990
+ if (global) {
3991
+ var fullUnicode = rx.unicode;
3992
+ rx.lastIndex = 0;
3993
+ }
3994
+ var results = [];
3995
+ while (true) {
3996
+ var result = regExpExec(rx, S);
3997
+ if (result === null) break;
3998
+
3999
+ push(results, result);
4000
+ if (!global) break;
4001
+
4002
+ var matchStr = toString$2(result[0]);
4003
+ if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
4004
+ }
4005
+
4006
+ var accumulatedResult = '';
4007
+ var nextSourcePosition = 0;
4008
+ for (var i = 0; i < results.length; i++) {
4009
+ result = results[i];
4010
+
4011
+ var matched = toString$2(result[0]);
4012
+ var position = max(min(toIntegerOrInfinity(result.index), S.length), 0);
4013
+ var captures = [];
4014
+ // NOTE: This is equivalent to
4015
+ // captures = result.slice(1).map(maybeToString)
4016
+ // but for some reason `nativeSlice.call(result, 1, result.length)` (called in
4017
+ // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and
4018
+ // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it.
4019
+ for (var j = 1; j < result.length; j++) push(captures, maybeToString(result[j]));
4020
+ var namedCaptures = result.groups;
4021
+ if (functionalReplace) {
4022
+ var replacerArgs = concat([matched], captures, position, S);
4023
+ if (namedCaptures !== undefined) push(replacerArgs, namedCaptures);
4024
+ var replacement = toString$2(apply(replaceValue, undefined, replacerArgs));
4025
+ } else {
4026
+ replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);
4027
+ }
4028
+ if (position >= nextSourcePosition) {
4029
+ accumulatedResult += stringSlice(S, nextSourcePosition, position) + replacement;
4030
+ nextSourcePosition = position + matched.length;
4031
+ }
4032
+ }
4033
+ return accumulatedResult + stringSlice(S, nextSourcePosition);
4034
+ }
4035
+ ];
4036
+ }, !REPLACE_SUPPORTS_NAMED_GROUPS || !REPLACE_KEEPS_$0 || REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE);
4037
+
4038
+ const selectActiveExperiments = (experiments, profile) => {
4039
+ const experimentTraits = pickBy__default["default"](profile.traits, (value, key) => key.startsWith(EXPERIENCE_TRAIT_PREFIX) && value === true);
4040
+ const experimentTraitsIds = Object.keys(experimentTraits).map(id => id.replace(EXPERIENCE_TRAIT_PREFIX, ''));
4041
+ // a experiment is active when the use has it set as a true value on the traits and the experiment config is still active
4042
+ const activeExperiments = experiments.filter(experiment => includes__default["default"](experimentTraitsIds, experiment.id));
4043
+ return activeExperiments;
4044
+ };
4045
+
4046
+ /**
4047
+ * We can use any personalization as eligible experience
4048
+ * When going for an experiment we can only select a active experiment when 1 or more experiments are active
4049
+ * If the profile is not in any active experiments, we can select any expermiment
4050
+ */
4051
+ const selectEligibleExperiences = ({
4052
+ experiences,
4053
+ activeExperiments
4054
+ }) => {
4055
+ return experiences.filter(experience => experience.type === 'nt_personalization' || activeExperiments.length === 0 || find__default["default"](activeExperiments, {
4056
+ id: experience.id
4057
+ }));
4058
+ };
4059
+
4060
+ const LOWER_BOUND = 0;
4061
+ const UPPER_BOUND = 4294967295;
4062
+ const normalize = (val, min, max) => (val - min) / (max - min);
4063
+ const getRandom = text => {
4064
+ const hash = murmurhashJs.murmur3(text, 0);
4065
+ const random = normalize(hash, LOWER_BOUND, UPPER_BOUND);
4066
+ return random;
4067
+ };
4068
+ const getTrafficRandom = (profile, experience) => getRandom(`traffic-${experience.id}-${profile.id}`);
4069
+ const getDistributionRandom = (profile, experience) => getRandom(`distribution-${experience.id}-${profile.id}`);
4070
+
4071
+ const isExperienceMatch = ({
4072
+ experience,
4073
+ activeExperiments,
4074
+ profile
4075
+ }) => {
4076
+ const trafficRandom = getTrafficRandom(profile, experience);
4077
+ /*console.log('has no audience', experience.id, !experience.audience);*/
4078
+ experience_jsShared.logger.info(`The traffic random factor for experience ${experience.id} is ${trafficRandom}. It's traffic allocation is set to ${experience.trafficAllocation}.`);
4079
+ const isInTrafficRange = experience.trafficAllocation > trafficRandom;
4080
+ const matchesAudience = !experience.audience || includes__default["default"](profile.audiences, experience.audience.id);
4081
+ const hasActiveExperiment = !!find__default["default"](activeExperiments, {
4082
+ id: experience.id
4083
+ });
4084
+ experience_jsShared.logger.info(`Is the profile in traffic allocation range? ${isInTrafficRange ? 'yes' : 'no'}.\n
4085
+ Does the profile match the audience of the experience? ${matchesAudience ? 'yes' : 'no'}.\n
4086
+ Is there an active experiment for this profile? ${hasActiveExperiment ? 'yes' : 'no'}.`);
4087
+ return isInTrafficRange && (matchesAudience ||
4088
+ // if the expriment is active already then it's selectible without further contraints to be fullfilled
4089
+ hasActiveExperiment);
4090
+ };
4091
+
4092
+ const selectExperience = ({
4093
+ experiences,
4094
+ activeExperiments,
4095
+ profile
4096
+ }) => {
4097
+ const eligibleExperiences = selectEligibleExperiences({
4098
+ experiences,
4099
+ activeExperiments
4100
+ });
4101
+ const selectedExperience = eligibleExperiences.find(experience => isExperienceMatch({
4102
+ experience,
4103
+ activeExperiments,
4104
+ profile
4105
+ }));
4106
+ return selectedExperience !== null && selectedExperience !== void 0 ? selectedExperience : null;
4107
+ };
4108
+
4109
+ const selectDistribution = ({
4110
+ experience,
4111
+ profile
4112
+ }) => {
4113
+ const distributionRandom = getDistributionRandom(profile, experience);
4114
+ experience_jsShared.logger.log(`The distribution random factor for experience ${experience.id} is ${distributionRandom}. It's distribution is set to ${JSON.stringify(experience.distribution, null, 2)}.`);
4115
+ const distribution = find__default["default"](experience.distribution, ({
4116
+ start,
4117
+ end
4118
+ }) => distributionRandom >= start && distributionRandom <= end // this overlaps on one value for each boundary but we just find the first match
4119
+ );
4120
+
4121
+ if (!distribution) {
4122
+ // This should never happen. If it happens then the distribution is not configured correctly. So we just return the baseline.
4123
+ return {
4124
+ index: 0,
4125
+ start: 0,
4126
+ end: 1
4127
+ };
4128
+ }
4129
+ return distribution;
4130
+ };
4131
+
4132
+ const selectVariant = ({
4133
+ baseline,
4134
+ experience,
4135
+ profile
4136
+ }) => {
4137
+ const variants = selectVariants(experience, baseline);
4138
+ if (!variants.length) {
4139
+ return null;
4140
+ }
4141
+ const distribution = selectDistribution({
4142
+ experience,
4143
+ profile
4144
+ });
4145
+ if (!distribution) {
4146
+ return null;
4147
+ }
4148
+ if (distribution.index === 0) {
4149
+ return Object.assign(Object.assign({}, baseline), {
4150
+ hidden: false
4151
+ });
4152
+ }
4153
+ const correctedVariantIndex = distribution.index - 1;
4154
+ if (variants.length <= correctedVariantIndex) {
4155
+ console.warn("A distribution for a variant was selected but it's metadata could not be found.");
4156
+ return null;
4157
+ }
4158
+ const variant = variants[correctedVariantIndex];
4159
+ if (!variant) {
4160
+ console.warn("A distribution for a variant was selected but it's metadata could not be found.");
4161
+ return null;
4162
+ }
4163
+ return variant;
4164
+ };
4165
+
4166
+ var aCallable = aCallable$8;
4167
+ var toObject = toObject$5;
4168
+ var IndexedObject = indexedObject;
4169
+ var lengthOfArrayLike = lengthOfArrayLike$3;
4170
+
4171
+ var $TypeError = TypeError;
4172
+
4173
+ // `Array.prototype.{ reduce, reduceRight }` methods implementation
4174
+ var createMethod$1 = function (IS_RIGHT) {
4175
+ return function (that, callbackfn, argumentsLength, memo) {
4176
+ aCallable(callbackfn);
4177
+ var O = toObject(that);
4178
+ var self = IndexedObject(O);
4179
+ var length = lengthOfArrayLike(O);
4180
+ var index = IS_RIGHT ? length - 1 : 0;
4181
+ var i = IS_RIGHT ? -1 : 1;
4182
+ if (argumentsLength < 2) while (true) {
4183
+ if (index in self) {
4184
+ memo = self[index];
4185
+ index += i;
4186
+ break;
4187
+ }
4188
+ index += i;
4189
+ if (IS_RIGHT ? index < 0 : length <= index) {
4190
+ throw $TypeError('Reduce of empty array with no initial value');
4191
+ }
4192
+ }
4193
+ for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {
4194
+ memo = callbackfn(memo, self[index], index, O);
4195
+ }
4196
+ return memo;
4197
+ };
4198
+ };
4199
+
4200
+ var arrayReduce = {
4201
+ // `Array.prototype.reduce` method
4202
+ // https://tc39.es/ecma262/#sec-array.prototype.reduce
4203
+ left: createMethod$1(false),
4204
+ // `Array.prototype.reduceRight` method
4205
+ // https://tc39.es/ecma262/#sec-array.prototype.reduceright
4206
+ right: createMethod$1(true)
4207
+ };
4208
+
4209
+ var fails$1 = fails$m;
4210
+
4211
+ var arrayMethodIsStrict$1 = function (METHOD_NAME, argument) {
4212
+ var method = [][METHOD_NAME];
4213
+ return !!method && fails$1(function () {
4214
+ // eslint-disable-next-line no-useless-call -- required for testing
4215
+ method.call(null, argument || function () { return 1; }, 1);
4216
+ });
4217
+ };
4218
+
4219
+ var $$1 = _export;
4220
+ var $reduce = arrayReduce.left;
4221
+ var arrayMethodIsStrict = arrayMethodIsStrict$1;
4222
+ var CHROME_VERSION = engineV8Version;
4223
+ var IS_NODE = engineIsNode;
4224
+
4225
+ var STRICT_METHOD = arrayMethodIsStrict('reduce');
4226
+ // Chrome 80-82 has a critical bug
4227
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=1049982
4228
+ var CHROME_BUG = !IS_NODE && CHROME_VERSION > 79 && CHROME_VERSION < 83;
4229
+
4230
+ // `Array.prototype.reduce` method
4231
+ // https://tc39.es/ecma262/#sec-array.prototype.reduce
4232
+ $$1({ target: 'Array', proto: true, forced: !STRICT_METHOD || CHROME_BUG }, {
4233
+ reduce: function reduce(callbackfn /* , initialValue */) {
4234
+ var length = arguments.length;
4235
+ return $reduce(this, callbackfn, length, length > 1 ? arguments[1] : undefined);
4236
+ }
4237
+ });
4238
+
4239
+ // a string of all valid unicode whitespaces
4240
+ var whitespaces$2 = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' +
4241
+ '\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
4242
+
4243
+ var uncurryThis$1 = functionUncurryThis;
4244
+ var requireObjectCoercible = requireObjectCoercible$7;
4245
+ var toString$1 = toString$7;
4246
+ var whitespaces$1 = whitespaces$2;
4247
+
4248
+ var replace = uncurryThis$1(''.replace);
4249
+ var whitespace = '[' + whitespaces$1 + ']';
4250
+ var ltrim = RegExp('^' + whitespace + whitespace + '*');
4251
+ var rtrim = RegExp(whitespace + whitespace + '*$');
4252
+
4253
+ // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
4254
+ var createMethod = function (TYPE) {
4255
+ return function ($this) {
4256
+ var string = toString$1(requireObjectCoercible($this));
4257
+ if (TYPE & 1) string = replace(string, ltrim, '');
4258
+ if (TYPE & 2) string = replace(string, rtrim, '');
4259
+ return string;
4260
+ };
4261
+ };
4262
+
4263
+ var stringTrim = {
4264
+ // `String.prototype.{ trimLeft, trimStart }` methods
4265
+ // https://tc39.es/ecma262/#sec-string.prototype.trimstart
4266
+ start: createMethod(1),
4267
+ // `String.prototype.{ trimRight, trimEnd }` methods
4268
+ // https://tc39.es/ecma262/#sec-string.prototype.trimend
4269
+ end: createMethod(2),
4270
+ // `String.prototype.trim` method
4271
+ // https://tc39.es/ecma262/#sec-string.prototype.trim
4272
+ trim: createMethod(3)
4273
+ };
4274
+
4275
+ var global$1 = global$n;
4276
+ var fails = fails$m;
4277
+ var uncurryThis = functionUncurryThis;
4278
+ var toString = toString$7;
4279
+ var trim = stringTrim.trim;
4280
+ var whitespaces = whitespaces$2;
4281
+
4282
+ var $parseInt$1 = global$1.parseInt;
4283
+ var Symbol$1 = global$1.Symbol;
4284
+ var ITERATOR = Symbol$1 && Symbol$1.iterator;
4285
+ var hex = /^[+-]?0x/i;
4286
+ var exec = uncurryThis(hex.exec);
4287
+ var FORCED = $parseInt$1(whitespaces + '08') !== 8 || $parseInt$1(whitespaces + '0x16') !== 22
4288
+ // MS Edge 18- broken with boxed symbols
4289
+ || (ITERATOR && !fails(function () { $parseInt$1(Object(ITERATOR)); }));
4290
+
4291
+ // `parseInt` method
4292
+ // https://tc39.es/ecma262/#sec-parseint-string-radix
4293
+ var numberParseInt = FORCED ? function parseInt(string, radix) {
4294
+ var S = trim(toString(string));
4295
+ return $parseInt$1(S, (radix >>> 0) || (exec(hex, S) ? 16 : 10));
4296
+ } : $parseInt$1;
4297
+
4298
+ var $ = _export;
4299
+ var $parseInt = numberParseInt;
4300
+
4301
+ // `parseInt` method
4302
+ // https://tc39.es/ecma262/#sec-parseint-string-radix
4303
+ $({ global: true, forced: parseInt != $parseInt }, {
4304
+ parseInt: $parseInt
4305
+ });
4306
+
4307
+ const decodeExperienceVariantsMap = encodedExperienceVariantsMap => {
4308
+ return encodedExperienceVariantsMap.split(',').map(experienceIdWithVariant => {
4309
+ const [experienceId, _variantIndex] = experienceIdWithVariant.split('=');
4310
+ const variantIndex = parseInt(_variantIndex);
4311
+ if (!experienceId || !variantIndex) {
4312
+ return null;
4313
+ }
4314
+ return {
4315
+ experienceId,
4316
+ variantIndex
4317
+ };
4318
+ }).filter(x => !!x).reduce((acc, curr) => Object.assign(Object.assign({}, acc), {
4319
+ [curr.experienceId]: curr.variantIndex
4320
+ }), {});
4321
+ };
4322
+
4323
+ exports.ANONYMOUS_ID = ANONYMOUS_ID;
4324
+ exports.DEBUG_FLAG = DEBUG_FLAG;
4325
+ exports.EXPERIENCE_TRAIT_PREFIX = EXPERIENCE_TRAIT_PREFIX;
4326
+ exports.LEGACY_ANONYMOUS_ID = LEGACY_ANONYMOUS_ID;
4327
+ exports.Ninetailed = Ninetailed;
4328
+ exports.PLUGIN_NAME = PLUGIN_NAME;
4329
+ exports.PROFILE_CHANGE = PROFILE_CHANGE;
4330
+ exports.PROFILE_FALLBACK_CACHE = PROFILE_FALLBACK_CACHE;
4331
+ exports.PROFILE_RESET = PROFILE_RESET;
4332
+ exports.decodeExperienceVariantsMap = decodeExperienceVariantsMap;
4333
+ exports.isExperienceMatch = isExperienceMatch;
4334
+ exports.ninetailedPlugin = ninetailedPlugin;
4335
+ exports.selectActiveExperiments = selectActiveExperiments;
4336
+ exports.selectDistribution = selectDistribution;
4337
+ exports.selectEligibleExperiences = selectEligibleExperiences;
4338
+ exports.selectExperience = selectExperience;
4339
+ exports.selectExperienceBaselineWithVariants = selectBaselineWithVariants;
4340
+ exports.selectExperienceVariant = selectVariant;
4341
+ exports.selectExperienceVariants = selectVariants;
4342
+ exports.selectHasExperienceVariants = selectHasVariants;
4343
+ exports.selectVariant = selectVariant$1;