@ninetailed/experience.js-react 4.1.0-beta.0 → 4.1.0-beta.2

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.js CHANGED
@@ -1,13 +1,13 @@
1
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
- import React, { createContext, useContext, useCallback, useMemo, useState, useRef, useEffect, createElement as createElement$1 } from 'react';
3
- import { selectActiveExperiments, Ninetailed, selectVariant, selectDistribution, selectHasExperienceVariants, selectExperience, selectExperienceVariant } from '@ninetailed/experience.js';
1
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
+ import React, { createContext, useContext, useEffect, useState, useRef, useMemo, createElement as createElement$1, useCallback } from 'react';
3
+ import { selectDistribution, selectHasExperienceVariants, selectActiveExperiments, selectExperience, selectExperienceVariant, makeExperienceSelectMiddleware, Ninetailed, selectVariant } from '@ninetailed/experience.js';
4
+ import { useInView } from 'react-intersection-observer';
5
+ import { isBrowser, logger } from '@ninetailed/experience.js-shared';
6
+ import isEqual from 'lodash/isEqual';
7
+ import has$1 from 'lodash/has';
4
8
  import _debounce from 'lodash/debounce';
5
9
  import values$1 from 'lodash/values';
6
- import { logger, isBrowser } from '@ninetailed/experience.js-shared';
7
- import isEqual from 'lodash/isEqual';
8
- import { useInView } from 'react-intersection-observer';
9
10
  import get$1 from 'lodash/get';
10
- import has$1 from 'lodash/has';
11
11
 
12
12
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
13
13
 
@@ -28,7 +28,7 @@ var global$d =
28
28
 
29
29
  var objectGetOwnPropertyDescriptor = {};
30
30
 
31
- var fails$d = function (exec) {
31
+ var fails$c = function (exec) {
32
32
  try {
33
33
  return !!exec();
34
34
  } catch (error) {
@@ -36,28 +36,28 @@ var fails$d = function (exec) {
36
36
  }
37
37
  };
38
38
 
39
- var fails$c = fails$d;
39
+ var fails$b = fails$c;
40
40
 
41
41
  // Detect IE8's incomplete defineProperty implementation
42
- var descriptors = !fails$c(function () {
42
+ var descriptors = !fails$b(function () {
43
43
  // eslint-disable-next-line es/no-object-defineproperty -- required for testing
44
44
  return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
45
45
  });
46
46
 
47
- var fails$b = fails$d;
47
+ var fails$a = fails$c;
48
48
 
49
- var functionBindNative = !fails$b(function () {
49
+ var functionBindNative = !fails$a(function () {
50
50
  // eslint-disable-next-line es/no-function-prototype-bind -- safe
51
51
  var test = (function () { /* empty */ }).bind();
52
52
  // eslint-disable-next-line no-prototype-builtins -- safe
53
53
  return typeof test != 'function' || test.hasOwnProperty('prototype');
54
54
  });
55
55
 
56
- var NATIVE_BIND$2 = functionBindNative;
56
+ var NATIVE_BIND$1 = functionBindNative;
57
57
 
58
58
  var call$6 = Function.prototype.call;
59
59
 
60
- var functionCall = NATIVE_BIND$2 ? call$6.bind(call$6) : function () {
60
+ var functionCall = NATIVE_BIND$1 ? call$6.bind(call$6) : function () {
61
61
  return call$6.apply(call$6, arguments);
62
62
  };
63
63
 
@@ -86,41 +86,41 @@ var createPropertyDescriptor$3 = function (bitmap, value) {
86
86
  };
87
87
  };
88
88
 
89
- var NATIVE_BIND$1 = functionBindNative;
89
+ var NATIVE_BIND = functionBindNative;
90
90
 
91
91
  var FunctionPrototype$1 = Function.prototype;
92
92
  var call$5 = FunctionPrototype$1.call;
93
- var uncurryThisWithBind = NATIVE_BIND$1 && FunctionPrototype$1.bind.bind(call$5, call$5);
93
+ var uncurryThisWithBind = NATIVE_BIND && FunctionPrototype$1.bind.bind(call$5, call$5);
94
94
 
95
- var functionUncurryThis = NATIVE_BIND$1 ? uncurryThisWithBind : function (fn) {
95
+ var functionUncurryThis = NATIVE_BIND ? uncurryThisWithBind : function (fn) {
96
96
  return function () {
97
97
  return call$5.apply(fn, arguments);
98
98
  };
99
99
  };
100
100
 
101
- var uncurryThis$d = functionUncurryThis;
101
+ var uncurryThis$a = functionUncurryThis;
102
102
 
103
- var toString$3 = uncurryThis$d({}.toString);
104
- var stringSlice$1 = uncurryThis$d(''.slice);
103
+ var toString$3 = uncurryThis$a({}.toString);
104
+ var stringSlice$1 = uncurryThis$a(''.slice);
105
105
 
106
- var classofRaw$2 = function (it) {
106
+ var classofRaw$1 = function (it) {
107
107
  return stringSlice$1(toString$3(it), 8, -1);
108
108
  };
109
109
 
110
- var uncurryThis$c = functionUncurryThis;
111
- var fails$a = fails$d;
112
- var classof$5 = classofRaw$2;
110
+ var uncurryThis$9 = functionUncurryThis;
111
+ var fails$9 = fails$c;
112
+ var classof$3 = classofRaw$1;
113
113
 
114
114
  var $Object$4 = Object;
115
- var split = uncurryThis$c(''.split);
115
+ var split = uncurryThis$9(''.split);
116
116
 
117
117
  // fallback for non-array-like ES3 and non-enumerable old V8 strings
118
- var indexedObject = fails$a(function () {
118
+ var indexedObject = fails$9(function () {
119
119
  // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
120
120
  // eslint-disable-next-line no-prototype-builtins -- safe
121
121
  return !$Object$4('z').propertyIsEnumerable(0);
122
122
  }) ? function (it) {
123
- return classof$5(it) == 'String' ? split(it, '') : $Object$4(it);
123
+ return classof$3(it) == 'String' ? split(it, '') : $Object$4(it);
124
124
  } : $Object$4;
125
125
 
126
126
  // we can't use just `it == null` since of `document.all` special case
@@ -131,12 +131,12 @@ var isNullOrUndefined$2 = function (it) {
131
131
 
132
132
  var isNullOrUndefined$1 = isNullOrUndefined$2;
133
133
 
134
- var $TypeError$8 = TypeError;
134
+ var $TypeError$7 = TypeError;
135
135
 
136
136
  // `RequireObjectCoercible` abstract operation
137
137
  // https://tc39.es/ecma262/#sec-requireobjectcoercible
138
138
  var requireObjectCoercible$2 = function (it) {
139
- if (isNullOrUndefined$1(it)) throw $TypeError$8("Can't call method on " + it);
139
+ if (isNullOrUndefined$1(it)) throw $TypeError$7("Can't call method on " + it);
140
140
  return it;
141
141
  };
142
142
 
@@ -164,41 +164,41 @@ var documentAll$1 = $documentAll$1.all;
164
164
 
165
165
  // `IsCallable` abstract operation
166
166
  // https://tc39.es/ecma262/#sec-iscallable
167
- var isCallable$h = $documentAll$1.IS_HTMLDDA ? function (argument) {
167
+ var isCallable$g = $documentAll$1.IS_HTMLDDA ? function (argument) {
168
168
  return typeof argument == 'function' || argument === documentAll$1;
169
169
  } : function (argument) {
170
170
  return typeof argument == 'function';
171
171
  };
172
172
 
173
- var isCallable$g = isCallable$h;
173
+ var isCallable$f = isCallable$g;
174
174
  var $documentAll = documentAll_1;
175
175
 
176
176
  var documentAll = $documentAll.all;
177
177
 
178
- var isObject$7 = $documentAll.IS_HTMLDDA ? function (it) {
179
- return typeof it == 'object' ? it !== null : isCallable$g(it) || it === documentAll;
178
+ var isObject$6 = $documentAll.IS_HTMLDDA ? function (it) {
179
+ return typeof it == 'object' ? it !== null : isCallable$f(it) || it === documentAll;
180
180
  } : function (it) {
181
- return typeof it == 'object' ? it !== null : isCallable$g(it);
181
+ return typeof it == 'object' ? it !== null : isCallable$f(it);
182
182
  };
183
183
 
184
184
  var global$c = global$d;
185
- var isCallable$f = isCallable$h;
185
+ var isCallable$e = isCallable$g;
186
186
 
187
187
  var aFunction = function (argument) {
188
- return isCallable$f(argument) ? argument : undefined;
188
+ return isCallable$e(argument) ? argument : undefined;
189
189
  };
190
190
 
191
- var getBuiltIn$5 = function (namespace, method) {
191
+ var getBuiltIn$4 = function (namespace, method) {
192
192
  return arguments.length < 2 ? aFunction(global$c[namespace]) : global$c[namespace] && global$c[namespace][method];
193
193
  };
194
194
 
195
- var uncurryThis$b = functionUncurryThis;
195
+ var uncurryThis$8 = functionUncurryThis;
196
196
 
197
- var objectIsPrototypeOf = uncurryThis$b({}.isPrototypeOf);
197
+ var objectIsPrototypeOf = uncurryThis$8({}.isPrototypeOf);
198
198
 
199
- var getBuiltIn$4 = getBuiltIn$5;
199
+ var getBuiltIn$3 = getBuiltIn$4;
200
200
 
201
- var engineUserAgent = getBuiltIn$4('navigator', 'userAgent') || '';
201
+ var engineUserAgent = getBuiltIn$3('navigator', 'userAgent') || '';
202
202
 
203
203
  var global$b = global$d;
204
204
  var userAgent = engineUserAgent;
@@ -231,10 +231,10 @@ var engineV8Version = version;
231
231
  /* eslint-disable es/no-symbol -- required for testing */
232
232
 
233
233
  var V8_VERSION = engineV8Version;
234
- var fails$9 = fails$d;
234
+ var fails$8 = fails$c;
235
235
 
236
236
  // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
237
- var symbolConstructorDetection = !!Object.getOwnPropertySymbols && !fails$9(function () {
237
+ var symbolConstructorDetection = !!Object.getOwnPropertySymbols && !fails$8(function () {
238
238
  var symbol = Symbol();
239
239
  // Chrome 38 Symbol has incorrect toString conversion
240
240
  // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
@@ -251,8 +251,8 @@ var useSymbolAsUid = NATIVE_SYMBOL$2
251
251
  && !Symbol.sham
252
252
  && typeof Symbol.iterator == 'symbol';
253
253
 
254
- var getBuiltIn$3 = getBuiltIn$5;
255
- var isCallable$e = isCallable$h;
254
+ var getBuiltIn$2 = getBuiltIn$4;
255
+ var isCallable$d = isCallable$g;
256
256
  var isPrototypeOf$1 = objectIsPrototypeOf;
257
257
  var USE_SYMBOL_AS_UID$1 = useSymbolAsUid;
258
258
 
@@ -261,8 +261,8 @@ var $Object$3 = Object;
261
261
  var isSymbol$2 = USE_SYMBOL_AS_UID$1 ? function (it) {
262
262
  return typeof it == 'symbol';
263
263
  } : function (it) {
264
- var $Symbol = getBuiltIn$3('Symbol');
265
- return isCallable$e($Symbol) && isPrototypeOf$1($Symbol.prototype, $Object$3(it));
264
+ var $Symbol = getBuiltIn$2('Symbol');
265
+ return isCallable$d($Symbol) && isPrototypeOf$1($Symbol.prototype, $Object$3(it));
266
266
  };
267
267
 
268
268
  var $String$3 = String;
@@ -275,41 +275,41 @@ var tryToString$1 = function (argument) {
275
275
  }
276
276
  };
277
277
 
278
- var isCallable$d = isCallable$h;
278
+ var isCallable$c = isCallable$g;
279
279
  var tryToString = tryToString$1;
280
280
 
281
- var $TypeError$7 = TypeError;
281
+ var $TypeError$6 = TypeError;
282
282
 
283
283
  // `Assert: IsCallable(argument) is true`
284
- var aCallable$3 = function (argument) {
285
- if (isCallable$d(argument)) return argument;
286
- throw $TypeError$7(tryToString(argument) + ' is not a function');
284
+ var aCallable$2 = function (argument) {
285
+ if (isCallable$c(argument)) return argument;
286
+ throw $TypeError$6(tryToString(argument) + ' is not a function');
287
287
  };
288
288
 
289
- var aCallable$2 = aCallable$3;
289
+ var aCallable$1 = aCallable$2;
290
290
  var isNullOrUndefined = isNullOrUndefined$2;
291
291
 
292
292
  // `GetMethod` abstract operation
293
293
  // https://tc39.es/ecma262/#sec-getmethod
294
294
  var getMethod$1 = function (V, P) {
295
295
  var func = V[P];
296
- return isNullOrUndefined(func) ? undefined : aCallable$2(func);
296
+ return isNullOrUndefined(func) ? undefined : aCallable$1(func);
297
297
  };
298
298
 
299
299
  var call$4 = functionCall;
300
- var isCallable$c = isCallable$h;
301
- var isObject$6 = isObject$7;
300
+ var isCallable$b = isCallable$g;
301
+ var isObject$5 = isObject$6;
302
302
 
303
- var $TypeError$6 = TypeError;
303
+ var $TypeError$5 = TypeError;
304
304
 
305
305
  // `OrdinaryToPrimitive` abstract operation
306
306
  // https://tc39.es/ecma262/#sec-ordinarytoprimitive
307
307
  var ordinaryToPrimitive$1 = function (input, pref) {
308
308
  var fn, val;
309
- if (pref === 'string' && isCallable$c(fn = input.toString) && !isObject$6(val = call$4(fn, input))) return val;
310
- if (isCallable$c(fn = input.valueOf) && !isObject$6(val = call$4(fn, input))) return val;
311
- if (pref !== 'string' && isCallable$c(fn = input.toString) && !isObject$6(val = call$4(fn, input))) return val;
312
- throw $TypeError$6("Can't convert object to primitive value");
309
+ if (pref === 'string' && isCallable$b(fn = input.toString) && !isObject$5(val = call$4(fn, input))) return val;
310
+ if (isCallable$b(fn = input.valueOf) && !isObject$5(val = call$4(fn, input))) return val;
311
+ if (pref !== 'string' && isCallable$b(fn = input.toString) && !isObject$5(val = call$4(fn, input))) return val;
312
+ throw $TypeError$5("Can't convert object to primitive value");
313
313
  };
314
314
 
315
315
  var shared$3 = {exports: {}};
@@ -353,27 +353,27 @@ var $Object$2 = Object;
353
353
 
354
354
  // `ToObject` abstract operation
355
355
  // https://tc39.es/ecma262/#sec-toobject
356
- var toObject$5 = function (argument) {
356
+ var toObject$4 = function (argument) {
357
357
  return $Object$2(requireObjectCoercible(argument));
358
358
  };
359
359
 
360
- var uncurryThis$a = functionUncurryThis;
361
- var toObject$4 = toObject$5;
360
+ var uncurryThis$7 = functionUncurryThis;
361
+ var toObject$3 = toObject$4;
362
362
 
363
- var hasOwnProperty = uncurryThis$a({}.hasOwnProperty);
363
+ var hasOwnProperty = uncurryThis$7({}.hasOwnProperty);
364
364
 
365
365
  // `HasOwnProperty` abstract operation
366
366
  // https://tc39.es/ecma262/#sec-hasownproperty
367
367
  // eslint-disable-next-line es/no-object-hasown -- safe
368
368
  var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
369
- return hasOwnProperty(toObject$4(it), key);
369
+ return hasOwnProperty(toObject$3(it), key);
370
370
  };
371
371
 
372
- var uncurryThis$9 = functionUncurryThis;
372
+ var uncurryThis$6 = functionUncurryThis;
373
373
 
374
374
  var id = 0;
375
375
  var postfix = Math.random();
376
- var toString$2 = uncurryThis$9(1.0.toString);
376
+ var toString$2 = uncurryThis$6(1.0.toString);
377
377
 
378
378
  var uid$2 = function (key) {
379
379
  return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$2(++id + postfix, 36);
@@ -391,7 +391,7 @@ var Symbol$1 = global$8.Symbol;
391
391
  var symbolFor = Symbol$1 && Symbol$1['for'];
392
392
  var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid$1;
393
393
 
394
- var wellKnownSymbol$9 = function (name) {
394
+ var wellKnownSymbol$8 = function (name) {
395
395
  if (!hasOwn$9(WellKnownSymbolsStore, name) || !(NATIVE_SYMBOL$1 || typeof WellKnownSymbolsStore[name] == 'string')) {
396
396
  var description = 'Symbol.' + name;
397
397
  if (NATIVE_SYMBOL$1 && hasOwn$9(Symbol$1, name)) {
@@ -405,26 +405,26 @@ var wellKnownSymbol$9 = function (name) {
405
405
  };
406
406
 
407
407
  var call$3 = functionCall;
408
- var isObject$5 = isObject$7;
408
+ var isObject$4 = isObject$6;
409
409
  var isSymbol$1 = isSymbol$2;
410
410
  var getMethod = getMethod$1;
411
411
  var ordinaryToPrimitive = ordinaryToPrimitive$1;
412
- var wellKnownSymbol$8 = wellKnownSymbol$9;
412
+ var wellKnownSymbol$7 = wellKnownSymbol$8;
413
413
 
414
- var $TypeError$5 = TypeError;
415
- var TO_PRIMITIVE = wellKnownSymbol$8('toPrimitive');
414
+ var $TypeError$4 = TypeError;
415
+ var TO_PRIMITIVE = wellKnownSymbol$7('toPrimitive');
416
416
 
417
417
  // `ToPrimitive` abstract operation
418
418
  // https://tc39.es/ecma262/#sec-toprimitive
419
419
  var toPrimitive$1 = function (input, pref) {
420
- if (!isObject$5(input) || isSymbol$1(input)) return input;
420
+ if (!isObject$4(input) || isSymbol$1(input)) return input;
421
421
  var exoticToPrim = getMethod(input, TO_PRIMITIVE);
422
422
  var result;
423
423
  if (exoticToPrim) {
424
424
  if (pref === undefined) pref = 'default';
425
425
  result = call$3(exoticToPrim, input, pref);
426
- if (!isObject$5(result) || isSymbol$1(result)) return result;
427
- throw $TypeError$5("Can't convert object to primitive value");
426
+ if (!isObject$4(result) || isSymbol$1(result)) return result;
427
+ throw $TypeError$4("Can't convert object to primitive value");
428
428
  }
429
429
  if (pref === undefined) pref = 'number';
430
430
  return ordinaryToPrimitive(input, pref);
@@ -441,22 +441,22 @@ var toPropertyKey$2 = function (argument) {
441
441
  };
442
442
 
443
443
  var global$7 = global$d;
444
- var isObject$4 = isObject$7;
444
+ var isObject$3 = isObject$6;
445
445
 
446
446
  var document$1 = global$7.document;
447
447
  // typeof document.createElement is 'object' in old IE
448
- var EXISTS$1 = isObject$4(document$1) && isObject$4(document$1.createElement);
448
+ var EXISTS$1 = isObject$3(document$1) && isObject$3(document$1.createElement);
449
449
 
450
450
  var documentCreateElement$2 = function (it) {
451
451
  return EXISTS$1 ? document$1.createElement(it) : {};
452
452
  };
453
453
 
454
454
  var DESCRIPTORS$a = descriptors;
455
- var fails$8 = fails$d;
455
+ var fails$7 = fails$c;
456
456
  var createElement = documentCreateElement$2;
457
457
 
458
458
  // Thanks to IE8 for its funny defineProperty
459
- var ie8DomDefine = !DESCRIPTORS$a && !fails$8(function () {
459
+ var ie8DomDefine = !DESCRIPTORS$a && !fails$7(function () {
460
460
  // eslint-disable-next-line es/no-object-defineproperty -- required for testing
461
461
  return Object.defineProperty(createElement('div'), 'a', {
462
462
  get: function () { return 7; }
@@ -489,11 +489,11 @@ objectGetOwnPropertyDescriptor.f = DESCRIPTORS$9 ? $getOwnPropertyDescriptor$1 :
489
489
  var objectDefineProperty = {};
490
490
 
491
491
  var DESCRIPTORS$8 = descriptors;
492
- var fails$7 = fails$d;
492
+ var fails$6 = fails$c;
493
493
 
494
494
  // V8 ~ Chrome 36-
495
495
  // https://bugs.chromium.org/p/v8/issues/detail?id=3334
496
- var v8PrototypeDefineBug = DESCRIPTORS$8 && fails$7(function () {
496
+ var v8PrototypeDefineBug = DESCRIPTORS$8 && fails$6(function () {
497
497
  // eslint-disable-next-line es/no-object-defineproperty -- required for testing
498
498
  return Object.defineProperty(function () { /* empty */ }, 'prototype', {
499
499
  value: 42,
@@ -501,15 +501,15 @@ var v8PrototypeDefineBug = DESCRIPTORS$8 && fails$7(function () {
501
501
  }).prototype != 42;
502
502
  });
503
503
 
504
- var isObject$3 = isObject$7;
504
+ var isObject$2 = isObject$6;
505
505
 
506
506
  var $String$2 = String;
507
- var $TypeError$4 = TypeError;
507
+ var $TypeError$3 = TypeError;
508
508
 
509
509
  // `Assert: Type(argument) is Object`
510
510
  var anObject$5 = function (argument) {
511
- if (isObject$3(argument)) return argument;
512
- throw $TypeError$4($String$2(argument) + ' is not an object');
511
+ if (isObject$2(argument)) return argument;
512
+ throw $TypeError$3($String$2(argument) + ' is not an object');
513
513
  };
514
514
 
515
515
  var DESCRIPTORS$7 = descriptors;
@@ -518,7 +518,7 @@ var V8_PROTOTYPE_DEFINE_BUG$1 = v8PrototypeDefineBug;
518
518
  var anObject$4 = anObject$5;
519
519
  var toPropertyKey = toPropertyKey$2;
520
520
 
521
- var $TypeError$3 = TypeError;
521
+ var $TypeError$2 = TypeError;
522
522
  // eslint-disable-next-line es/no-object-defineproperty -- safe
523
523
  var $defineProperty = Object.defineProperty;
524
524
  // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
@@ -551,7 +551,7 @@ objectDefineProperty.f = DESCRIPTORS$7 ? V8_PROTOTYPE_DEFINE_BUG$1 ? function de
551
551
  if (IE8_DOM_DEFINE) try {
552
552
  return $defineProperty(O, P, Attributes);
553
553
  } catch (error) { /* empty */ }
554
- if ('get' in Attributes || 'set' in Attributes) throw $TypeError$3('Accessors not supported');
554
+ if ('get' in Attributes || 'set' in Attributes) throw $TypeError$2('Accessors not supported');
555
555
  if ('value' in Attributes) O[P] = Attributes.value;
556
556
  return O;
557
557
  };
@@ -587,27 +587,27 @@ var functionName = {
587
587
  CONFIGURABLE: CONFIGURABLE
588
588
  };
589
589
 
590
- var uncurryThis$8 = functionUncurryThis;
591
- var isCallable$b = isCallable$h;
590
+ var uncurryThis$5 = functionUncurryThis;
591
+ var isCallable$a = isCallable$g;
592
592
  var store$1 = sharedStore;
593
593
 
594
- var functionToString = uncurryThis$8(Function.toString);
594
+ var functionToString = uncurryThis$5(Function.toString);
595
595
 
596
596
  // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
597
- if (!isCallable$b(store$1.inspectSource)) {
597
+ if (!isCallable$a(store$1.inspectSource)) {
598
598
  store$1.inspectSource = function (it) {
599
599
  return functionToString(it);
600
600
  };
601
601
  }
602
602
 
603
- var inspectSource$2 = store$1.inspectSource;
603
+ var inspectSource$1 = store$1.inspectSource;
604
604
 
605
605
  var global$6 = global$d;
606
- var isCallable$a = isCallable$h;
606
+ var isCallable$9 = isCallable$g;
607
607
 
608
608
  var WeakMap$1 = global$6.WeakMap;
609
609
 
610
- var weakMapBasicDetection = isCallable$a(WeakMap$1) && /native code/.test(String(WeakMap$1));
610
+ var weakMapBasicDetection = isCallable$9(WeakMap$1) && /native code/.test(String(WeakMap$1));
611
611
 
612
612
  var shared$1 = shared$3.exports;
613
613
  var uid = uid$2;
@@ -622,7 +622,7 @@ var hiddenKeys$4 = {};
622
622
 
623
623
  var NATIVE_WEAK_MAP = weakMapBasicDetection;
624
624
  var global$5 = global$d;
625
- var isObject$2 = isObject$7;
625
+ var isObject$1 = isObject$6;
626
626
  var createNonEnumerableProperty$3 = createNonEnumerableProperty$4;
627
627
  var hasOwn$6 = hasOwnProperty_1;
628
628
  var shared = sharedStore;
@@ -641,7 +641,7 @@ var enforce = function (it) {
641
641
  var getterFor = function (TYPE) {
642
642
  return function (it) {
643
643
  var state;
644
- if (!isObject$2(it) || (state = get(it)).type !== TYPE) {
644
+ if (!isObject$1(it) || (state = get(it)).type !== TYPE) {
645
645
  throw TypeError$1('Incompatible receiver, ' + TYPE + ' required');
646
646
  } return state;
647
647
  };
@@ -691,12 +691,12 @@ var internalState = {
691
691
  getterFor: getterFor
692
692
  };
693
693
 
694
- var fails$6 = fails$d;
695
- var isCallable$9 = isCallable$h;
694
+ var fails$5 = fails$c;
695
+ var isCallable$8 = isCallable$g;
696
696
  var hasOwn$5 = hasOwnProperty_1;
697
697
  var DESCRIPTORS$4 = descriptors;
698
698
  var CONFIGURABLE_FUNCTION_NAME$1 = functionName.CONFIGURABLE;
699
- var inspectSource$1 = inspectSource$2;
699
+ var inspectSource = inspectSource$1;
700
700
  var InternalStateModule$1 = internalState;
701
701
 
702
702
  var enforceInternalState = InternalStateModule$1.enforce;
@@ -704,7 +704,7 @@ var getInternalState$1 = InternalStateModule$1.get;
704
704
  // eslint-disable-next-line es/no-object-defineproperty -- safe
705
705
  var defineProperty$5 = Object.defineProperty;
706
706
 
707
- var CONFIGURABLE_LENGTH = DESCRIPTORS$4 && !fails$6(function () {
707
+ var CONFIGURABLE_LENGTH = DESCRIPTORS$4 && !fails$5(function () {
708
708
  return defineProperty$5(function () { /* empty */ }, 'length', { value: 8 }).length !== 8;
709
709
  });
710
710
 
@@ -738,10 +738,10 @@ var makeBuiltIn$1 = makeBuiltIn$2.exports = function (value, name, options) {
738
738
  // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
739
739
  // eslint-disable-next-line no-extend-native -- required
740
740
  Function.prototype.toString = makeBuiltIn$1(function toString() {
741
- return isCallable$9(this) && getInternalState$1(this).source || inspectSource$1(this);
741
+ return isCallable$8(this) && getInternalState$1(this).source || inspectSource(this);
742
742
  }, 'toString');
743
743
 
744
- var isCallable$8 = isCallable$h;
744
+ var isCallable$7 = isCallable$g;
745
745
  var definePropertyModule$2 = objectDefineProperty;
746
746
  var makeBuiltIn = makeBuiltIn$2.exports;
747
747
  var defineGlobalProperty$1 = defineGlobalProperty$3;
@@ -750,7 +750,7 @@ var defineBuiltIn$3 = function (O, key, value, options) {
750
750
  if (!options) options = {};
751
751
  var simple = options.enumerable;
752
752
  var name = options.name !== undefined ? options.name : key;
753
- if (isCallable$8(value)) makeBuiltIn(value, name, options);
753
+ if (isCallable$7(value)) makeBuiltIn(value, name, options);
754
754
  if (options.global) {
755
755
  if (simple) O[key] = value;
756
756
  else defineGlobalProperty$1(key, value);
@@ -786,13 +786,13 @@ var trunc = mathTrunc;
786
786
 
787
787
  // `ToIntegerOrInfinity` abstract operation
788
788
  // https://tc39.es/ecma262/#sec-tointegerorinfinity
789
- var toIntegerOrInfinity$3 = function (argument) {
789
+ var toIntegerOrInfinity$2 = function (argument) {
790
790
  var number = +argument;
791
791
  // eslint-disable-next-line no-self-compare -- NaN check
792
792
  return number !== number || number === 0 ? 0 : trunc(number);
793
793
  };
794
794
 
795
- var toIntegerOrInfinity$2 = toIntegerOrInfinity$3;
795
+ var toIntegerOrInfinity$1 = toIntegerOrInfinity$2;
796
796
 
797
797
  var max = Math.max;
798
798
  var min$1 = Math.min;
@@ -801,37 +801,37 @@ var min$1 = Math.min;
801
801
  // Let integer be ? ToInteger(index).
802
802
  // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
803
803
  var toAbsoluteIndex$1 = function (index, length) {
804
- var integer = toIntegerOrInfinity$2(index);
804
+ var integer = toIntegerOrInfinity$1(index);
805
805
  return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
806
806
  };
807
807
 
808
- var toIntegerOrInfinity$1 = toIntegerOrInfinity$3;
808
+ var toIntegerOrInfinity = toIntegerOrInfinity$2;
809
809
 
810
810
  var min = Math.min;
811
811
 
812
812
  // `ToLength` abstract operation
813
813
  // https://tc39.es/ecma262/#sec-tolength
814
814
  var toLength$1 = function (argument) {
815
- return argument > 0 ? min(toIntegerOrInfinity$1(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
815
+ return argument > 0 ? min(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
816
816
  };
817
817
 
818
818
  var toLength = toLength$1;
819
819
 
820
820
  // `LengthOfArrayLike` abstract operation
821
821
  // https://tc39.es/ecma262/#sec-lengthofarraylike
822
- var lengthOfArrayLike$4 = function (obj) {
822
+ var lengthOfArrayLike$2 = function (obj) {
823
823
  return toLength(obj.length);
824
824
  };
825
825
 
826
826
  var toIndexedObject$3 = toIndexedObject$5;
827
827
  var toAbsoluteIndex = toAbsoluteIndex$1;
828
- var lengthOfArrayLike$3 = lengthOfArrayLike$4;
828
+ var lengthOfArrayLike$1 = lengthOfArrayLike$2;
829
829
 
830
830
  // `Array.prototype.{ indexOf, includes }` methods implementation
831
831
  var createMethod$1 = function (IS_INCLUDES) {
832
832
  return function ($this, el, fromIndex) {
833
833
  var O = toIndexedObject$3($this);
834
- var length = lengthOfArrayLike$3(O);
834
+ var length = lengthOfArrayLike$1(O);
835
835
  var index = toAbsoluteIndex(fromIndex, length);
836
836
  var value;
837
837
  // Array#includes uses SameValueZero equality algorithm
@@ -856,13 +856,13 @@ var arrayIncludes = {
856
856
  indexOf: createMethod$1(false)
857
857
  };
858
858
 
859
- var uncurryThis$7 = functionUncurryThis;
859
+ var uncurryThis$4 = functionUncurryThis;
860
860
  var hasOwn$4 = hasOwnProperty_1;
861
861
  var toIndexedObject$2 = toIndexedObject$5;
862
862
  var indexOf = arrayIncludes.indexOf;
863
863
  var hiddenKeys$2 = hiddenKeys$4;
864
864
 
865
- var push = uncurryThis$7([].push);
865
+ var push = uncurryThis$4([].push);
866
866
 
867
867
  var objectKeysInternal = function (object, names) {
868
868
  var O = toIndexedObject$2(object);
@@ -905,16 +905,16 @@ var objectGetOwnPropertySymbols = {};
905
905
  // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
906
906
  objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
907
907
 
908
- var getBuiltIn$2 = getBuiltIn$5;
909
- var uncurryThis$6 = functionUncurryThis;
908
+ var getBuiltIn$1 = getBuiltIn$4;
909
+ var uncurryThis$3 = functionUncurryThis;
910
910
  var getOwnPropertyNamesModule = objectGetOwnPropertyNames;
911
911
  var getOwnPropertySymbolsModule$1 = objectGetOwnPropertySymbols;
912
912
  var anObject$3 = anObject$5;
913
913
 
914
- var concat$1 = uncurryThis$6([].concat);
914
+ var concat$1 = uncurryThis$3([].concat);
915
915
 
916
916
  // all object keys, includes non-enumerable and symbols
917
- var ownKeys$1 = getBuiltIn$2('Reflect', 'ownKeys') || function ownKeys(it) {
917
+ var ownKeys$1 = getBuiltIn$1('Reflect', 'ownKeys') || function ownKeys(it) {
918
918
  var keys = getOwnPropertyNamesModule.f(anObject$3(it));
919
919
  var getOwnPropertySymbols = getOwnPropertySymbolsModule$1.f;
920
920
  return getOwnPropertySymbols ? concat$1(keys, getOwnPropertySymbols(it)) : keys;
@@ -937,8 +937,8 @@ var copyConstructorProperties$2 = function (target, source, exceptions) {
937
937
  }
938
938
  };
939
939
 
940
- var fails$5 = fails$d;
941
- var isCallable$7 = isCallable$h;
940
+ var fails$4 = fails$c;
941
+ var isCallable$6 = isCallable$g;
942
942
 
943
943
  var replacement = /#|\.prototype\./;
944
944
 
@@ -946,7 +946,7 @@ var isForced$1 = function (feature, detection) {
946
946
  var value = data[normalize(feature)];
947
947
  return value == POLYFILL ? true
948
948
  : value == NATIVE ? false
949
- : isCallable$7(detection) ? fails$5(detection)
949
+ : isCallable$6(detection) ? fails$4(detection)
950
950
  : !!detection;
951
951
  };
952
952
 
@@ -1026,24 +1026,24 @@ var objectKeys$2 = Object.keys || function keys(O) {
1026
1026
  };
1027
1027
 
1028
1028
  var DESCRIPTORS$3 = descriptors;
1029
- var uncurryThis$5 = functionUncurryThis;
1029
+ var uncurryThis$2 = functionUncurryThis;
1030
1030
  var call$1 = functionCall;
1031
- var fails$4 = fails$d;
1031
+ var fails$3 = fails$c;
1032
1032
  var objectKeys$1 = objectKeys$2;
1033
1033
  var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
1034
1034
  var propertyIsEnumerableModule = objectPropertyIsEnumerable;
1035
- var toObject$3 = toObject$5;
1035
+ var toObject$2 = toObject$4;
1036
1036
  var IndexedObject$1 = indexedObject;
1037
1037
 
1038
1038
  // eslint-disable-next-line es/no-object-assign -- safe
1039
1039
  var $assign = Object.assign;
1040
1040
  // eslint-disable-next-line es/no-object-defineproperty -- required for testing
1041
1041
  var defineProperty$4 = Object.defineProperty;
1042
- var concat = uncurryThis$5([].concat);
1042
+ var concat = uncurryThis$2([].concat);
1043
1043
 
1044
1044
  // `Object.assign` method
1045
1045
  // https://tc39.es/ecma262/#sec-object.assign
1046
- var objectAssign = !$assign || fails$4(function () {
1046
+ var objectAssign = !$assign || fails$3(function () {
1047
1047
  // should have correct order of operations (Edge bug)
1048
1048
  if (DESCRIPTORS$3 && $assign({ b: 1 }, $assign(defineProperty$4({}, 'a', {
1049
1049
  enumerable: true,
@@ -1064,7 +1064,7 @@ var objectAssign = !$assign || fails$4(function () {
1064
1064
  alphabet.split('').forEach(function (chr) { B[chr] = chr; });
1065
1065
  return $assign({}, A)[symbol] != 7 || objectKeys$1($assign({}, B)).join('') != alphabet;
1066
1066
  }) ? function assign(target, source) { // eslint-disable-line no-unused-vars -- required for `.length`
1067
- var T = toObject$3(target);
1067
+ var T = toObject$2(target);
1068
1068
  var argumentsLength = arguments.length;
1069
1069
  var index = 1;
1070
1070
  var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
@@ -1082,98 +1082,18 @@ var objectAssign = !$assign || fails$4(function () {
1082
1082
  } return T;
1083
1083
  } : $assign;
1084
1084
 
1085
- var $$4 = _export;
1085
+ var $$3 = _export;
1086
1086
  var assign = objectAssign;
1087
1087
 
1088
1088
  // `Object.assign` method
1089
1089
  // https://tc39.es/ecma262/#sec-object.assign
1090
1090
  // eslint-disable-next-line es/no-object-assign -- required for testing
1091
- $$4({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }, {
1091
+ $$3({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }, {
1092
1092
  assign: assign
1093
1093
  });
1094
1094
 
1095
1095
  const NinetailedContext = /*#__PURE__*/createContext(undefined);
1096
1096
 
1097
- const ExperimentsContext = /*#__PURE__*/createContext(undefined);
1098
-
1099
- var aCallable$1 = aCallable$3;
1100
- var toObject$2 = toObject$5;
1101
- var IndexedObject = indexedObject;
1102
- var lengthOfArrayLike$2 = lengthOfArrayLike$4;
1103
-
1104
- var $TypeError$2 = TypeError;
1105
-
1106
- // `Array.prototype.{ reduce, reduceRight }` methods implementation
1107
- var createMethod = function (IS_RIGHT) {
1108
- return function (that, callbackfn, argumentsLength, memo) {
1109
- aCallable$1(callbackfn);
1110
- var O = toObject$2(that);
1111
- var self = IndexedObject(O);
1112
- var length = lengthOfArrayLike$2(O);
1113
- var index = IS_RIGHT ? length - 1 : 0;
1114
- var i = IS_RIGHT ? -1 : 1;
1115
- if (argumentsLength < 2) while (true) {
1116
- if (index in self) {
1117
- memo = self[index];
1118
- index += i;
1119
- break;
1120
- }
1121
- index += i;
1122
- if (IS_RIGHT ? index < 0 : length <= index) {
1123
- throw $TypeError$2('Reduce of empty array with no initial value');
1124
- }
1125
- }
1126
- for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {
1127
- memo = callbackfn(memo, self[index], index, O);
1128
- }
1129
- return memo;
1130
- };
1131
- };
1132
-
1133
- var arrayReduce = {
1134
- // `Array.prototype.reduce` method
1135
- // https://tc39.es/ecma262/#sec-array.prototype.reduce
1136
- left: createMethod(false),
1137
- // `Array.prototype.reduceRight` method
1138
- // https://tc39.es/ecma262/#sec-array.prototype.reduceright
1139
- right: createMethod(true)
1140
- };
1141
-
1142
- var fails$3 = fails$d;
1143
-
1144
- var arrayMethodIsStrict$1 = function (METHOD_NAME, argument) {
1145
- var method = [][METHOD_NAME];
1146
- return !!method && fails$3(function () {
1147
- // eslint-disable-next-line no-useless-call -- required for testing
1148
- method.call(null, argument || function () { return 1; }, 1);
1149
- });
1150
- };
1151
-
1152
- var classof$4 = classofRaw$2;
1153
- var global$3 = global$d;
1154
-
1155
- var engineIsNode = classof$4(global$3.process) == 'process';
1156
-
1157
- var $$3 = _export;
1158
- var $reduce = arrayReduce.left;
1159
- var arrayMethodIsStrict = arrayMethodIsStrict$1;
1160
- var CHROME_VERSION = engineV8Version;
1161
- var IS_NODE = engineIsNode;
1162
-
1163
- var STRICT_METHOD = arrayMethodIsStrict('reduce');
1164
- // Chrome 80-82 has a critical bug
1165
- // https://bugs.chromium.org/p/chromium/issues/detail?id=1049982
1166
- var CHROME_BUG = !IS_NODE && CHROME_VERSION > 79 && CHROME_VERSION < 83;
1167
-
1168
- // `Array.prototype.reduce` method
1169
- // https://tc39.es/ecma262/#sec-array.prototype.reduce
1170
- $$3({ target: 'Array', proto: true, forced: !STRICT_METHOD || CHROME_BUG }, {
1171
- reduce: function reduce(callbackfn /* , initialValue */) {
1172
- var length = arguments.length;
1173
- return $reduce(this, callbackfn, length, length > 1 ? arguments[1] : undefined);
1174
- }
1175
- });
1176
-
1177
1097
  var objectDefineProperties = {};
1178
1098
 
1179
1099
  var DESCRIPTORS$2 = descriptors;
@@ -1197,9 +1117,9 @@ objectDefineProperties.f = DESCRIPTORS$2 && !V8_PROTOTYPE_DEFINE_BUG ? Object.de
1197
1117
  return O;
1198
1118
  };
1199
1119
 
1200
- var getBuiltIn$1 = getBuiltIn$5;
1120
+ var getBuiltIn = getBuiltIn$4;
1201
1121
 
1202
- var html$1 = getBuiltIn$1('document', 'documentElement');
1122
+ var html$1 = getBuiltIn('document', 'documentElement');
1203
1123
 
1204
1124
  /* global ActiveXObject -- old IE, WSH */
1205
1125
 
@@ -1286,11 +1206,11 @@ var objectCreate = Object.create || function create(O, Properties) {
1286
1206
  return Properties === undefined ? result : definePropertiesModule.f(result, Properties);
1287
1207
  };
1288
1208
 
1289
- var wellKnownSymbol$7 = wellKnownSymbol$9;
1209
+ var wellKnownSymbol$6 = wellKnownSymbol$8;
1290
1210
  var create$1 = objectCreate;
1291
1211
  var defineProperty$3 = objectDefineProperty.f;
1292
1212
 
1293
- var UNSCOPABLES = wellKnownSymbol$7('unscopables');
1213
+ var UNSCOPABLES = wellKnownSymbol$6('unscopables');
1294
1214
  var ArrayPrototype = Array.prototype;
1295
1215
 
1296
1216
  // Array.prototype[@@unscopables]
@@ -1303,13 +1223,13 @@ if (ArrayPrototype[UNSCOPABLES] == undefined) {
1303
1223
  }
1304
1224
 
1305
1225
  // add a key to Array.prototype[@@unscopables]
1306
- var addToUnscopables$2 = function (key) {
1226
+ var addToUnscopables$1 = function (key) {
1307
1227
  ArrayPrototype[UNSCOPABLES][key] = true;
1308
1228
  };
1309
1229
 
1310
1230
  var iterators = {};
1311
1231
 
1312
- var fails$2 = fails$d;
1232
+ var fails$2 = fails$c;
1313
1233
 
1314
1234
  var correctPrototypeGetter = !fails$2(function () {
1315
1235
  function F() { /* empty */ }
@@ -1319,8 +1239,8 @@ var correctPrototypeGetter = !fails$2(function () {
1319
1239
  });
1320
1240
 
1321
1241
  var hasOwn$2 = hasOwnProperty_1;
1322
- var isCallable$6 = isCallable$h;
1323
- var toObject$1 = toObject$5;
1242
+ var isCallable$5 = isCallable$g;
1243
+ var toObject$1 = toObject$4;
1324
1244
  var sharedKey = sharedKey$3;
1325
1245
  var CORRECT_PROTOTYPE_GETTER = correctPrototypeGetter;
1326
1246
 
@@ -1335,19 +1255,19 @@ var objectGetPrototypeOf = CORRECT_PROTOTYPE_GETTER ? $Object$1.getPrototypeOf :
1335
1255
  var object = toObject$1(O);
1336
1256
  if (hasOwn$2(object, IE_PROTO)) return object[IE_PROTO];
1337
1257
  var constructor = object.constructor;
1338
- if (isCallable$6(constructor) && object instanceof constructor) {
1258
+ if (isCallable$5(constructor) && object instanceof constructor) {
1339
1259
  return constructor.prototype;
1340
1260
  } return object instanceof $Object$1 ? ObjectPrototype : null;
1341
1261
  };
1342
1262
 
1343
- var fails$1 = fails$d;
1344
- var isCallable$5 = isCallable$h;
1345
- var isObject$1 = isObject$7;
1263
+ var fails$1 = fails$c;
1264
+ var isCallable$4 = isCallable$g;
1265
+ var isObject = isObject$6;
1346
1266
  var getPrototypeOf$1 = objectGetPrototypeOf;
1347
1267
  var defineBuiltIn$1 = defineBuiltIn$3;
1348
- var wellKnownSymbol$6 = wellKnownSymbol$9;
1268
+ var wellKnownSymbol$5 = wellKnownSymbol$8;
1349
1269
 
1350
- var ITERATOR$2 = wellKnownSymbol$6('iterator');
1270
+ var ITERATOR$2 = wellKnownSymbol$5('iterator');
1351
1271
  var BUGGY_SAFARI_ITERATORS$1 = false;
1352
1272
 
1353
1273
  // `%IteratorPrototype%` object
@@ -1365,7 +1285,7 @@ if ([].keys) {
1365
1285
  }
1366
1286
  }
1367
1287
 
1368
- var NEW_ITERATOR_PROTOTYPE = !isObject$1(IteratorPrototype$2) || fails$1(function () {
1288
+ var NEW_ITERATOR_PROTOTYPE = !isObject(IteratorPrototype$2) || fails$1(function () {
1369
1289
  var test = {};
1370
1290
  // FF44- legacy iterators case
1371
1291
  return IteratorPrototype$2[ITERATOR$2].call(test) !== test;
@@ -1375,7 +1295,7 @@ if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype$2 = {};
1375
1295
 
1376
1296
  // `%IteratorPrototype%[@@iterator]()` method
1377
1297
  // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator
1378
- if (!isCallable$5(IteratorPrototype$2[ITERATOR$2])) {
1298
+ if (!isCallable$4(IteratorPrototype$2[ITERATOR$2])) {
1379
1299
  defineBuiltIn$1(IteratorPrototype$2, ITERATOR$2, function () {
1380
1300
  return this;
1381
1301
  });
@@ -1388,9 +1308,9 @@ var iteratorsCore = {
1388
1308
 
1389
1309
  var defineProperty$2 = objectDefineProperty.f;
1390
1310
  var hasOwn$1 = hasOwnProperty_1;
1391
- var wellKnownSymbol$5 = wellKnownSymbol$9;
1311
+ var wellKnownSymbol$4 = wellKnownSymbol$8;
1392
1312
 
1393
- var TO_STRING_TAG$3 = wellKnownSymbol$5('toStringTag');
1313
+ var TO_STRING_TAG$3 = wellKnownSymbol$4('toStringTag');
1394
1314
 
1395
1315
  var setToStringTag$2 = function (target, TAG, STATIC) {
1396
1316
  if (target && !STATIC) target = target.prototype;
@@ -1415,19 +1335,19 @@ var iteratorCreateConstructor = function (IteratorConstructor, NAME, next, ENUME
1415
1335
  return IteratorConstructor;
1416
1336
  };
1417
1337
 
1418
- var isCallable$4 = isCallable$h;
1338
+ var isCallable$3 = isCallable$g;
1419
1339
 
1420
1340
  var $String$1 = String;
1421
1341
  var $TypeError$1 = TypeError;
1422
1342
 
1423
1343
  var aPossiblePrototype$1 = function (argument) {
1424
- if (typeof argument == 'object' || isCallable$4(argument)) return argument;
1344
+ if (typeof argument == 'object' || isCallable$3(argument)) return argument;
1425
1345
  throw $TypeError$1("Can't set " + $String$1(argument) + ' as a prototype');
1426
1346
  };
1427
1347
 
1428
1348
  /* eslint-disable no-proto -- safe */
1429
1349
 
1430
- var uncurryThis$4 = functionUncurryThis;
1350
+ var uncurryThis$1 = functionUncurryThis;
1431
1351
  var anObject = anObject$5;
1432
1352
  var aPossiblePrototype = aPossiblePrototype$1;
1433
1353
 
@@ -1441,7 +1361,7 @@ var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? functio
1441
1361
  var setter;
1442
1362
  try {
1443
1363
  // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
1444
- setter = uncurryThis$4(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set);
1364
+ setter = uncurryThis$1(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set);
1445
1365
  setter(test, []);
1446
1366
  CORRECT_SETTER = test instanceof Array;
1447
1367
  } catch (error) { /* empty */ }
@@ -1457,14 +1377,14 @@ var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? functio
1457
1377
  var $$2 = _export;
1458
1378
  var call = functionCall;
1459
1379
  var FunctionName = functionName;
1460
- var isCallable$3 = isCallable$h;
1380
+ var isCallable$2 = isCallable$g;
1461
1381
  var createIteratorConstructor = iteratorCreateConstructor;
1462
1382
  var getPrototypeOf = objectGetPrototypeOf;
1463
1383
  var setPrototypeOf = objectSetPrototypeOf;
1464
1384
  var setToStringTag = setToStringTag$2;
1465
1385
  var createNonEnumerableProperty$1 = createNonEnumerableProperty$4;
1466
1386
  var defineBuiltIn = defineBuiltIn$3;
1467
- var wellKnownSymbol$4 = wellKnownSymbol$9;
1387
+ var wellKnownSymbol$3 = wellKnownSymbol$8;
1468
1388
  var Iterators$1 = iterators;
1469
1389
  var IteratorsCore = iteratorsCore;
1470
1390
 
@@ -1472,7 +1392,7 @@ var PROPER_FUNCTION_NAME = FunctionName.PROPER;
1472
1392
  var CONFIGURABLE_FUNCTION_NAME = FunctionName.CONFIGURABLE;
1473
1393
  var IteratorPrototype = IteratorsCore.IteratorPrototype;
1474
1394
  var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;
1475
- var ITERATOR$1 = wellKnownSymbol$4('iterator');
1395
+ var ITERATOR$1 = wellKnownSymbol$3('iterator');
1476
1396
  var KEYS = 'keys';
1477
1397
  var VALUES = 'values';
1478
1398
  var ENTRIES = 'entries';
@@ -1509,7 +1429,7 @@ var iteratorDefine = function (Iterable, NAME, IteratorConstructor, next, DEFAUL
1509
1429
  if (getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {
1510
1430
  if (setPrototypeOf) {
1511
1431
  setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);
1512
- } else if (!isCallable$3(CurrentIteratorPrototype[ITERATOR$1])) {
1432
+ } else if (!isCallable$2(CurrentIteratorPrototype[ITERATOR$1])) {
1513
1433
  defineBuiltIn(CurrentIteratorPrototype, ITERATOR$1, returnThis);
1514
1434
  }
1515
1435
  }
@@ -1558,7 +1478,7 @@ var createIterResultObject$1 = function (value, done) {
1558
1478
  };
1559
1479
 
1560
1480
  var toIndexedObject = toIndexedObject$5;
1561
- var addToUnscopables$1 = addToUnscopables$2;
1481
+ var addToUnscopables = addToUnscopables$1;
1562
1482
  var Iterators = iterators;
1563
1483
  var InternalStateModule = internalState;
1564
1484
  var defineProperty$1 = objectDefineProperty.f;
@@ -1609,9 +1529,9 @@ var es_array_iterator = defineIterator(Array, 'Array', function (iterated, kind)
1609
1529
  var values = Iterators.Arguments = Iterators.Array;
1610
1530
 
1611
1531
  // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
1612
- addToUnscopables$1('keys');
1613
- addToUnscopables$1('values');
1614
- addToUnscopables$1('entries');
1532
+ addToUnscopables('keys');
1533
+ addToUnscopables('values');
1534
+ addToUnscopables('entries');
1615
1535
 
1616
1536
  // V8 ~ Chrome 45- bug
1617
1537
  if (DESCRIPTORS$1 && values.name !== 'values') try {
@@ -1662,15 +1582,15 @@ var DOMTokenListPrototype$1 = classList && classList.constructor && classList.co
1662
1582
 
1663
1583
  var domTokenListPrototype = DOMTokenListPrototype$1 === Object.prototype ? undefined : DOMTokenListPrototype$1;
1664
1584
 
1665
- var global$2 = global$d;
1585
+ var global$3 = global$d;
1666
1586
  var DOMIterables = domIterables;
1667
1587
  var DOMTokenListPrototype = domTokenListPrototype;
1668
1588
  var ArrayIteratorMethods = es_array_iterator;
1669
1589
  var createNonEnumerableProperty = createNonEnumerableProperty$4;
1670
- var wellKnownSymbol$3 = wellKnownSymbol$9;
1590
+ var wellKnownSymbol$2 = wellKnownSymbol$8;
1671
1591
 
1672
- var ITERATOR = wellKnownSymbol$3('iterator');
1673
- var TO_STRING_TAG$2 = wellKnownSymbol$3('toStringTag');
1592
+ var ITERATOR = wellKnownSymbol$2('iterator');
1593
+ var TO_STRING_TAG$2 = wellKnownSymbol$2('toStringTag');
1674
1594
  var ArrayValues = ArrayIteratorMethods.values;
1675
1595
 
1676
1596
  var handlePrototype = function (CollectionPrototype, COLLECTION_NAME) {
@@ -1696,7 +1616,7 @@ var handlePrototype = function (CollectionPrototype, COLLECTION_NAME) {
1696
1616
  };
1697
1617
 
1698
1618
  for (var COLLECTION_NAME in DOMIterables) {
1699
- handlePrototype(global$2[COLLECTION_NAME] && global$2[COLLECTION_NAME].prototype, COLLECTION_NAME);
1619
+ handlePrototype(global$3[COLLECTION_NAME] && global$3[COLLECTION_NAME].prototype, COLLECTION_NAME);
1700
1620
  }
1701
1621
 
1702
1622
  handlePrototype(DOMTokenListPrototype, 'DOMTokenList');
@@ -1738,7 +1658,110 @@ function __awaiter(thisArg, _arguments, P, generator) {
1738
1658
  });
1739
1659
  }
1740
1660
 
1741
- const EXPERIENCE_TRAIT_PREFIX = 'nt_experiment_';
1661
+ var wellKnownSymbol$1 = wellKnownSymbol$8;
1662
+
1663
+ var TO_STRING_TAG$1 = wellKnownSymbol$1('toStringTag');
1664
+ var test = {};
1665
+
1666
+ test[TO_STRING_TAG$1] = 'z';
1667
+
1668
+ var toStringTagSupport = String(test) === '[object z]';
1669
+
1670
+ var TO_STRING_TAG_SUPPORT = toStringTagSupport;
1671
+ var isCallable$1 = isCallable$g;
1672
+ var classofRaw = classofRaw$1;
1673
+ var wellKnownSymbol = wellKnownSymbol$8;
1674
+
1675
+ var TO_STRING_TAG = wellKnownSymbol('toStringTag');
1676
+ var $Object = Object;
1677
+
1678
+ // ES3 wrong here
1679
+ var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
1680
+
1681
+ // fallback for IE11 Script Access Denied error
1682
+ var tryGet = function (it, key) {
1683
+ try {
1684
+ return it[key];
1685
+ } catch (error) { /* empty */ }
1686
+ };
1687
+
1688
+ // getting tag from ES6+ `Object.prototype.toString`
1689
+ var classof$2 = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
1690
+ var O, tag, result;
1691
+ return it === undefined ? 'Undefined' : it === null ? 'Null'
1692
+ // @@toStringTag case
1693
+ : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag
1694
+ // builtinTag case
1695
+ : CORRECT_ARGUMENTS ? classofRaw(O)
1696
+ // ES3 arguments fallback
1697
+ : (result = classofRaw(O)) == 'Object' && isCallable$1(O.callee) ? 'Arguments' : result;
1698
+ };
1699
+
1700
+ var classof$1 = classof$2;
1701
+
1702
+ var $String = String;
1703
+
1704
+ var toString$1 = function (argument) {
1705
+ if (classof$1(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
1706
+ return $String(argument);
1707
+ };
1708
+
1709
+ var $$1 = _export;
1710
+ var DESCRIPTORS = descriptors;
1711
+ var global$2 = global$d;
1712
+ var uncurryThis = functionUncurryThis;
1713
+ var hasOwn = hasOwnProperty_1;
1714
+ var isCallable = isCallable$g;
1715
+ var isPrototypeOf = objectIsPrototypeOf;
1716
+ var toString = toString$1;
1717
+ var defineProperty = objectDefineProperty.f;
1718
+ var copyConstructorProperties = copyConstructorProperties$2;
1719
+
1720
+ var NativeSymbol = global$2.Symbol;
1721
+ var SymbolPrototype = NativeSymbol && NativeSymbol.prototype;
1722
+
1723
+ if (DESCRIPTORS && isCallable(NativeSymbol) && (!('description' in SymbolPrototype) ||
1724
+ // Safari 12 bug
1725
+ NativeSymbol().description !== undefined
1726
+ )) {
1727
+ var EmptyStringDescriptionStore = {};
1728
+ // wrap Symbol constructor for correct work with undefined description
1729
+ var SymbolWrapper = function Symbol() {
1730
+ var description = arguments.length < 1 || arguments[0] === undefined ? undefined : toString(arguments[0]);
1731
+ var result = isPrototypeOf(SymbolPrototype, this)
1732
+ ? new NativeSymbol(description)
1733
+ // in Edge 13, String(Symbol(undefined)) === 'Symbol(undefined)'
1734
+ : description === undefined ? NativeSymbol() : NativeSymbol(description);
1735
+ if (description === '') EmptyStringDescriptionStore[result] = true;
1736
+ return result;
1737
+ };
1738
+
1739
+ copyConstructorProperties(SymbolWrapper, NativeSymbol);
1740
+ SymbolWrapper.prototype = SymbolPrototype;
1741
+ SymbolPrototype.constructor = SymbolWrapper;
1742
+
1743
+ var NATIVE_SYMBOL = String(NativeSymbol('test')) == 'Symbol(test)';
1744
+ var thisSymbolValue = uncurryThis(SymbolPrototype.valueOf);
1745
+ var symbolDescriptiveString = uncurryThis(SymbolPrototype.toString);
1746
+ var regexp = /^Symbol\((.*)\)[^)]+$/;
1747
+ var replace = uncurryThis(''.replace);
1748
+ var stringSlice = uncurryThis(''.slice);
1749
+
1750
+ defineProperty(SymbolPrototype, 'description', {
1751
+ configurable: true,
1752
+ get: function description() {
1753
+ var symbol = thisSymbolValue(this);
1754
+ if (hasOwn(EmptyStringDescriptionStore, symbol)) return '';
1755
+ var string = symbolDescriptiveString(symbol);
1756
+ var desc = NATIVE_SYMBOL ? stringSlice(string, 7, -1) : replace(string, regexp, '$1');
1757
+ return desc === '' ? undefined : desc;
1758
+ }
1759
+ });
1760
+
1761
+ $$1({ global: true, constructor: true, forced: true }, {
1762
+ Symbol: SymbolWrapper
1763
+ });
1764
+ }
1742
1765
 
1743
1766
  const useNinetailed = () => {
1744
1767
  const ninetailed = useContext(NinetailedContext);
@@ -1748,115 +1771,124 @@ const useNinetailed = () => {
1748
1771
  return ninetailed;
1749
1772
  };
1750
1773
 
1751
- const debounce = (fn, wait, options) => {
1752
- let debouncedArgs = [];
1753
- const debouncedFn = _debounce(() => {
1754
- fn.call(undefined, debouncedArgs);
1755
- debouncedArgs = [];
1756
- }, wait, options);
1757
- return (...args) => {
1758
- debouncedArgs.push(values$1(args));
1759
- debouncedFn();
1760
- };
1761
- };
1762
- const useProvideJoinExperiment = ({
1763
- experiments,
1764
- maximumActiveExperiments: _maximumActiveExperiments = 1
1774
+ const TrackExperience = ({
1775
+ children,
1776
+ experience,
1777
+ variant,
1778
+ profile
1765
1779
  }) => {
1780
+ const ninetailed = useNinetailed();
1766
1781
  const {
1767
- identify
1768
- } = useNinetailed();
1769
- const joinExperimentIdentify = debounce(args => {
1770
- const traits = args.slice(0, _maximumActiveExperiments).reduce((traits, [experimentJoinTraits]) => {
1771
- return Object.assign(Object.assign({}, experimentJoinTraits), traits);
1772
- }, {});
1773
- identify('', traits);
1782
+ ref,
1783
+ inView
1784
+ } = useInView({
1785
+ triggerOnce: true
1774
1786
  });
1775
- return useCallback(data => __awaiter(void 0, void 0, void 0, function* () {
1776
- const {
1777
- experiment,
1778
- profile
1779
- } = data;
1780
- const isExperiment = experiment.type === 'nt_experiment';
1781
- if (!isExperiment) {
1782
- logger.warn(`The experience ${experiment.id}, which you tried to join, is not an experiment.`);
1783
- return;
1784
- }
1785
- const activeExperiments = selectActiveExperiments(experiments, profile);
1786
- if (activeExperiments.length >= _maximumActiveExperiments) {
1787
- logger.warn(`The maximum number of active experiments (${_maximumActiveExperiments}) has been reached.`);
1788
- return;
1787
+ useEffect(() => {
1788
+ if (isBrowser() && inView) {
1789
+ const distribution = selectDistribution({
1790
+ experience,
1791
+ profile
1792
+ });
1793
+ ninetailed.trackHasSeenExperience({
1794
+ experience: {
1795
+ id: experience.id,
1796
+ type: experience.type,
1797
+ name: experience.name || '',
1798
+ description: experience.description || ''
1799
+ },
1800
+ audience: experience.audience,
1801
+ selectedVariant: variant,
1802
+ selectedVariantIndex: distribution.index
1803
+ });
1789
1804
  }
1790
- if (activeExperiments.some(activeExperiment => activeExperiment.id === experiment.id)) {
1791
- logger.debug(`The user is already part of experiment ${experiment.id}. Won't join again.`);
1792
- return;
1793
- }
1794
- joinExperimentIdentify({
1795
- [`${EXPERIENCE_TRAIT_PREFIX}${experiment.id}`]: true
1796
- });
1797
- logger.debug(`Sent event to join experiment ${experiment.id}.`);
1798
- }), []);
1805
+ }, [inView]);
1806
+ return jsxs(Fragment, {
1807
+ children: [jsx("div", {
1808
+ ref: ref,
1809
+ id: "nt-experience-handle"
1810
+ }), children]
1811
+ });
1799
1812
  };
1800
1813
 
1801
- const ExperimentsProvider = ({
1802
- experiments,
1803
- maximumActiveExperiments: _maximumActiveExperiments = 1,
1804
- children
1805
- }) => {
1806
- const joinExperiment = useProvideJoinExperiment({
1807
- experiments,
1808
- maximumActiveExperiments: _maximumActiveExperiments
1809
- });
1810
- return jsx(ExperimentsContext.Provider, Object.assign({
1811
- value: {
1812
- experiments,
1813
- joinExperiment
1814
+ var aCallable = aCallable$2;
1815
+ var toObject = toObject$4;
1816
+ var IndexedObject = indexedObject;
1817
+ var lengthOfArrayLike = lengthOfArrayLike$2;
1818
+
1819
+ var $TypeError = TypeError;
1820
+
1821
+ // `Array.prototype.{ reduce, reduceRight }` methods implementation
1822
+ var createMethod = function (IS_RIGHT) {
1823
+ return function (that, callbackfn, argumentsLength, memo) {
1824
+ aCallable(callbackfn);
1825
+ var O = toObject(that);
1826
+ var self = IndexedObject(O);
1827
+ var length = lengthOfArrayLike(O);
1828
+ var index = IS_RIGHT ? length - 1 : 0;
1829
+ var i = IS_RIGHT ? -1 : 1;
1830
+ if (argumentsLength < 2) while (true) {
1831
+ if (index in self) {
1832
+ memo = self[index];
1833
+ index += i;
1834
+ break;
1835
+ }
1836
+ index += i;
1837
+ if (IS_RIGHT ? index < 0 : length <= index) {
1838
+ throw $TypeError('Reduce of empty array with no initial value');
1839
+ }
1814
1840
  }
1815
- }, {
1816
- children: children
1817
- }));
1841
+ for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {
1842
+ memo = callbackfn(memo, self[index], index, O);
1843
+ }
1844
+ return memo;
1845
+ };
1818
1846
  };
1819
1847
 
1820
- const NinetailedProvider = ({
1821
- children,
1822
- clientId,
1823
- experiments: _experiments = [],
1824
- maximumActiveExperiments,
1825
- environment,
1826
- preview,
1827
- url,
1828
- profile,
1829
- locale,
1830
- requestTimeout,
1831
- plugins: _plugins = [],
1832
- onLog,
1833
- onError
1834
- }) => {
1835
- const ninetailed = useMemo(() => new Ninetailed({
1836
- clientId,
1837
- environment,
1838
- preview
1839
- }, {
1840
- url,
1841
- plugins: _plugins,
1842
- profile,
1843
- locale,
1844
- requestTimeout,
1845
- onLog,
1846
- onError
1847
- }), []);
1848
- return jsx(NinetailedContext.Provider, Object.assign({
1849
- value: ninetailed
1850
- }, {
1851
- children: jsx(ExperimentsProvider, Object.assign({
1852
- experiments: _experiments,
1853
- maximumActiveExperiments: maximumActiveExperiments
1854
- }, {
1855
- children: children
1856
- }))
1857
- }));
1848
+ var arrayReduce = {
1849
+ // `Array.prototype.reduce` method
1850
+ // https://tc39.es/ecma262/#sec-array.prototype.reduce
1851
+ left: createMethod(false),
1852
+ // `Array.prototype.reduceRight` method
1853
+ // https://tc39.es/ecma262/#sec-array.prototype.reduceright
1854
+ right: createMethod(true)
1855
+ };
1856
+
1857
+ var fails = fails$c;
1858
+
1859
+ var arrayMethodIsStrict$1 = function (METHOD_NAME, argument) {
1860
+ var method = [][METHOD_NAME];
1861
+ return !!method && fails(function () {
1862
+ // eslint-disable-next-line no-useless-call -- required for testing
1863
+ method.call(null, argument || function () { return 1; }, 1);
1864
+ });
1858
1865
  };
1859
1866
 
1867
+ var classof = classofRaw$1;
1868
+ var global$1 = global$d;
1869
+
1870
+ var engineIsNode = classof(global$1.process) == 'process';
1871
+
1872
+ var $ = _export;
1873
+ var $reduce = arrayReduce.left;
1874
+ var arrayMethodIsStrict = arrayMethodIsStrict$1;
1875
+ var CHROME_VERSION = engineV8Version;
1876
+ var IS_NODE = engineIsNode;
1877
+
1878
+ var STRICT_METHOD = arrayMethodIsStrict('reduce');
1879
+ // Chrome 80-82 has a critical bug
1880
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=1049982
1881
+ var CHROME_BUG = !IS_NODE && CHROME_VERSION > 79 && CHROME_VERSION < 83;
1882
+
1883
+ // `Array.prototype.reduce` method
1884
+ // https://tc39.es/ecma262/#sec-array.prototype.reduce
1885
+ $({ target: 'Array', proto: true, forced: !STRICT_METHOD || CHROME_BUG }, {
1886
+ reduce: function reduce(callbackfn /* , initialValue */) {
1887
+ var length = arguments.length;
1888
+ return $reduce(this, callbackfn, length, length > 1 ? arguments[1] : undefined);
1889
+ }
1890
+ });
1891
+
1860
1892
  const useProfile = () => {
1861
1893
  const ninetailed = useNinetailed();
1862
1894
  const [profileState, setProfileState] = useState(ninetailed.profileState);
@@ -1893,275 +1925,7 @@ const useProfile = () => {
1893
1925
  });
1894
1926
  };
1895
1927
 
1896
- const usePersonalize = (baseline, variants, options = {
1897
- holdout: -1
1898
- }) => {
1899
- const profile = useProfile();
1900
- return selectVariant(baseline, variants, profile, options);
1901
- };
1902
-
1903
- const TrackHasSeenComponent = ({
1904
- children,
1905
- variant,
1906
- audience,
1907
- isPersonalized
1908
- }) => {
1909
- const ninetailed = useNinetailed();
1910
- const {
1911
- ref,
1912
- inView
1913
- } = useInView({
1914
- triggerOnce: true
1915
- });
1916
- useEffect(() => {
1917
- if (isBrowser() && inView) {
1918
- ninetailed.trackHasSeenComponent({
1919
- variant,
1920
- audience,
1921
- isPersonalized
1922
- });
1923
- }
1924
- }, [inView]);
1925
- return jsxs(Fragment, {
1926
- children: [jsx("div", {
1927
- ref: ref
1928
- }), children]
1929
- });
1930
- };
1931
-
1932
- const Personalize = _a => {
1933
- var {
1934
- component: Component,
1935
- loadingComponent: LoadingComponent,
1936
- variants = [],
1937
- holdout = -1
1938
- } = _a,
1939
- baseline = __rest(_a, ["component", "loadingComponent", "variants", "holdout"]);
1940
- const {
1941
- loading,
1942
- variant,
1943
- isPersonalized,
1944
- audience
1945
- } = usePersonalize(baseline, variants, {
1946
- holdout
1947
- });
1948
- const hasVariants = variants.length > 0;
1949
- if (!hasVariants) {
1950
- return jsx(Component, Object.assign({}, baseline, {
1951
- ninetailed: {
1952
- isPersonalized,
1953
- audience
1954
- }
1955
- }));
1956
- }
1957
- if (loading) {
1958
- if (LoadingComponent) {
1959
- return jsx(LoadingComponent, {});
1960
- }
1961
- return jsx("div", Object.assign({
1962
- style: {
1963
- opacity: 0
1964
- }
1965
- }, {
1966
- children: jsx(Component, Object.assign({}, variant, {
1967
- ninetailed: {
1968
- isPersonalized,
1969
- audience
1970
- }
1971
- }))
1972
- }), "hide");
1973
- }
1974
- return jsx(TrackHasSeenComponent, Object.assign({
1975
- variant: variant,
1976
- audience: audience,
1977
- isPersonalized: isPersonalized
1978
- }, {
1979
- children: /*#__PURE__*/createElement$1(Component, Object.assign({}, variant, {
1980
- key: `${audience.id}-${variant.id}`,
1981
- ninetailed: {
1982
- isPersonalized,
1983
- audience
1984
- }
1985
- }))
1986
- }));
1987
- };
1988
-
1989
- const generateSelectors = id => {
1990
- return id.split('_').map((path, index, paths) => {
1991
- const dotPath = paths.slice(0, index).join('.');
1992
- const underScorePath = paths.slice(index).join('_');
1993
- return [dotPath, underScorePath].filter(path => path !== '').join('.');
1994
- });
1995
- };
1996
- const selectValueFromProfile = (profile, id) => {
1997
- const selectors = generateSelectors(id);
1998
- const matchingSelector = selectors.find(selector => get$1(profile, selector));
1999
- if (!matchingSelector) {
2000
- return null;
2001
- }
2002
- return get$1(profile, matchingSelector);
2003
- };
2004
- const MergeTag = ({
2005
- id
2006
- }) => {
2007
- const {
2008
- loading,
2009
- profile
2010
- } = useProfile();
2011
- if (loading || !profile) {
2012
- return null;
2013
- }
2014
- const value = selectValueFromProfile(profile, id);
2015
- // DON'T CHANGE
2016
- return jsx(Fragment, {
2017
- children: value
2018
- });
2019
- };
2020
-
2021
- var wellKnownSymbol$2 = wellKnownSymbol$9;
2022
-
2023
- var TO_STRING_TAG$1 = wellKnownSymbol$2('toStringTag');
2024
- var test = {};
2025
-
2026
- test[TO_STRING_TAG$1] = 'z';
2027
-
2028
- var toStringTagSupport = String(test) === '[object z]';
2029
-
2030
- var TO_STRING_TAG_SUPPORT = toStringTagSupport;
2031
- var isCallable$2 = isCallable$h;
2032
- var classofRaw$1 = classofRaw$2;
2033
- var wellKnownSymbol$1 = wellKnownSymbol$9;
2034
-
2035
- var TO_STRING_TAG = wellKnownSymbol$1('toStringTag');
2036
- var $Object = Object;
2037
-
2038
- // ES3 wrong here
2039
- var CORRECT_ARGUMENTS = classofRaw$1(function () { return arguments; }()) == 'Arguments';
2040
-
2041
- // fallback for IE11 Script Access Denied error
2042
- var tryGet = function (it, key) {
2043
- try {
2044
- return it[key];
2045
- } catch (error) { /* empty */ }
2046
- };
2047
-
2048
- // getting tag from ES6+ `Object.prototype.toString`
2049
- var classof$3 = TO_STRING_TAG_SUPPORT ? classofRaw$1 : function (it) {
2050
- var O, tag, result;
2051
- return it === undefined ? 'Undefined' : it === null ? 'Null'
2052
- // @@toStringTag case
2053
- : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag
2054
- // builtinTag case
2055
- : CORRECT_ARGUMENTS ? classofRaw$1(O)
2056
- // ES3 arguments fallback
2057
- : (result = classofRaw$1(O)) == 'Object' && isCallable$2(O.callee) ? 'Arguments' : result;
2058
- };
2059
-
2060
- var classof$2 = classof$3;
2061
-
2062
- var $String = String;
2063
-
2064
- var toString$1 = function (argument) {
2065
- if (classof$2(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
2066
- return $String(argument);
2067
- };
2068
-
2069
- var $$1 = _export;
2070
- var DESCRIPTORS = descriptors;
2071
- var global$1 = global$d;
2072
- var uncurryThis$3 = functionUncurryThis;
2073
- var hasOwn = hasOwnProperty_1;
2074
- var isCallable$1 = isCallable$h;
2075
- var isPrototypeOf = objectIsPrototypeOf;
2076
- var toString = toString$1;
2077
- var defineProperty = objectDefineProperty.f;
2078
- var copyConstructorProperties = copyConstructorProperties$2;
2079
-
2080
- var NativeSymbol = global$1.Symbol;
2081
- var SymbolPrototype = NativeSymbol && NativeSymbol.prototype;
2082
-
2083
- if (DESCRIPTORS && isCallable$1(NativeSymbol) && (!('description' in SymbolPrototype) ||
2084
- // Safari 12 bug
2085
- NativeSymbol().description !== undefined
2086
- )) {
2087
- var EmptyStringDescriptionStore = {};
2088
- // wrap Symbol constructor for correct work with undefined description
2089
- var SymbolWrapper = function Symbol() {
2090
- var description = arguments.length < 1 || arguments[0] === undefined ? undefined : toString(arguments[0]);
2091
- var result = isPrototypeOf(SymbolPrototype, this)
2092
- ? new NativeSymbol(description)
2093
- // in Edge 13, String(Symbol(undefined)) === 'Symbol(undefined)'
2094
- : description === undefined ? NativeSymbol() : NativeSymbol(description);
2095
- if (description === '') EmptyStringDescriptionStore[result] = true;
2096
- return result;
2097
- };
2098
-
2099
- copyConstructorProperties(SymbolWrapper, NativeSymbol);
2100
- SymbolWrapper.prototype = SymbolPrototype;
2101
- SymbolPrototype.constructor = SymbolWrapper;
2102
-
2103
- var NATIVE_SYMBOL = String(NativeSymbol('test')) == 'Symbol(test)';
2104
- var thisSymbolValue = uncurryThis$3(SymbolPrototype.valueOf);
2105
- var symbolDescriptiveString = uncurryThis$3(SymbolPrototype.toString);
2106
- var regexp = /^Symbol\((.*)\)[^)]+$/;
2107
- var replace = uncurryThis$3(''.replace);
2108
- var stringSlice = uncurryThis$3(''.slice);
2109
-
2110
- defineProperty(SymbolPrototype, 'description', {
2111
- configurable: true,
2112
- get: function description() {
2113
- var symbol = thisSymbolValue(this);
2114
- if (hasOwn(EmptyStringDescriptionStore, symbol)) return '';
2115
- var string = symbolDescriptiveString(symbol);
2116
- var desc = NATIVE_SYMBOL ? stringSlice(string, 7, -1) : replace(string, regexp, '$1');
2117
- return desc === '' ? undefined : desc;
2118
- }
2119
- });
2120
-
2121
- $$1({ global: true, constructor: true, forced: true }, {
2122
- Symbol: SymbolWrapper
2123
- });
2124
- }
2125
-
2126
- const TrackExperience = ({
2127
- children,
2128
- experience,
2129
- variant,
2130
- profile
2131
- }) => {
2132
- const ninetailed = useNinetailed();
2133
- const {
2134
- ref,
2135
- inView
2136
- } = useInView({
2137
- triggerOnce: true
2138
- });
2139
- useEffect(() => {
2140
- if (isBrowser() && inView) {
2141
- const distribution = selectDistribution({
2142
- experience,
2143
- profile
2144
- });
2145
- ninetailed.trackHasSeenExperience({
2146
- experience: {
2147
- id: experience.id,
2148
- type: experience.type,
2149
- name: experience.name || '',
2150
- description: experience.description || ''
2151
- },
2152
- audience: experience.audience,
2153
- selectedVariant: variant,
2154
- selectedVariantIndex: distribution.index
2155
- });
2156
- }
2157
- }, [inView]);
2158
- return jsxs(Fragment, {
2159
- children: [jsx("div", {
2160
- ref: ref,
2161
- id: "nt-experience-handle"
2162
- }), children]
2163
- });
2164
- };
1928
+ const ExperimentsContext = /*#__PURE__*/createContext(undefined);
2165
1929
 
2166
1930
  const useExperimentsContext = () => {
2167
1931
  const context = useContext(ExperimentsContext);
@@ -2226,7 +1990,9 @@ const useExperience = ({
2226
1990
  if (!experience) {
2227
1991
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2228
1992
  // @ts-ignore
2229
- return emptyReturn;
1993
+ return Object.assign(Object.assign({}, emptyReturn), {
1994
+ profile
1995
+ });
2230
1996
  }
2231
1997
  const audience = experience.audience;
2232
1998
  const variant = selectExperienceVariant({
@@ -2263,231 +2029,6 @@ const useJoinExperiment = () => {
2263
2029
  return context.joinExperiment;
2264
2030
  };
2265
2031
 
2266
- var classof$1 = classofRaw$2;
2267
-
2268
- // `IsArray` abstract operation
2269
- // https://tc39.es/ecma262/#sec-isarray
2270
- // eslint-disable-next-line es/no-array-isarray -- safe
2271
- var isArray$2 = Array.isArray || function isArray(argument) {
2272
- return classof$1(argument) == 'Array';
2273
- };
2274
-
2275
- var $TypeError = TypeError;
2276
- var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; // 2 ** 53 - 1 == 9007199254740991
2277
-
2278
- var doesNotExceedSafeInteger$1 = function (it) {
2279
- if (it > MAX_SAFE_INTEGER) throw $TypeError('Maximum allowed index exceeded');
2280
- return it;
2281
- };
2282
-
2283
- var classofRaw = classofRaw$2;
2284
- var uncurryThis$2 = functionUncurryThis;
2285
-
2286
- var functionUncurryThisClause = function (fn) {
2287
- // Nashorn bug:
2288
- // https://github.com/zloirock/core-js/issues/1128
2289
- // https://github.com/zloirock/core-js/issues/1130
2290
- if (classofRaw(fn) === 'Function') return uncurryThis$2(fn);
2291
- };
2292
-
2293
- var uncurryThis$1 = functionUncurryThisClause;
2294
- var aCallable = aCallable$3;
2295
- var NATIVE_BIND = functionBindNative;
2296
-
2297
- var bind$1 = uncurryThis$1(uncurryThis$1.bind);
2298
-
2299
- // optional / simple context binding
2300
- var functionBindContext = function (fn, that) {
2301
- aCallable(fn);
2302
- return that === undefined ? fn : NATIVE_BIND ? bind$1(fn, that) : function (/* ...args */) {
2303
- return fn.apply(that, arguments);
2304
- };
2305
- };
2306
-
2307
- var isArray$1 = isArray$2;
2308
- var lengthOfArrayLike$1 = lengthOfArrayLike$4;
2309
- var doesNotExceedSafeInteger = doesNotExceedSafeInteger$1;
2310
- var bind = functionBindContext;
2311
-
2312
- // `FlattenIntoArray` abstract operation
2313
- // https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray
2314
- var flattenIntoArray$1 = function (target, original, source, sourceLen, start, depth, mapper, thisArg) {
2315
- var targetIndex = start;
2316
- var sourceIndex = 0;
2317
- var mapFn = mapper ? bind(mapper, thisArg) : false;
2318
- var element, elementLen;
2319
-
2320
- while (sourceIndex < sourceLen) {
2321
- if (sourceIndex in source) {
2322
- element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex];
2323
-
2324
- if (depth > 0 && isArray$1(element)) {
2325
- elementLen = lengthOfArrayLike$1(element);
2326
- targetIndex = flattenIntoArray$1(target, original, element, elementLen, targetIndex, depth - 1) - 1;
2327
- } else {
2328
- doesNotExceedSafeInteger(targetIndex + 1);
2329
- target[targetIndex] = element;
2330
- }
2331
-
2332
- targetIndex++;
2333
- }
2334
- sourceIndex++;
2335
- }
2336
- return targetIndex;
2337
- };
2338
-
2339
- var flattenIntoArray_1 = flattenIntoArray$1;
2340
-
2341
- var uncurryThis = functionUncurryThis;
2342
- var fails = fails$d;
2343
- var isCallable = isCallable$h;
2344
- var classof = classof$3;
2345
- var getBuiltIn = getBuiltIn$5;
2346
- var inspectSource = inspectSource$2;
2347
-
2348
- var noop = function () { /* empty */ };
2349
- var empty = [];
2350
- var construct = getBuiltIn('Reflect', 'construct');
2351
- var constructorRegExp = /^\s*(?:class|function)\b/;
2352
- var exec = uncurryThis(constructorRegExp.exec);
2353
- var INCORRECT_TO_STRING = !constructorRegExp.exec(noop);
2354
-
2355
- var isConstructorModern = function isConstructor(argument) {
2356
- if (!isCallable(argument)) return false;
2357
- try {
2358
- construct(noop, empty, argument);
2359
- return true;
2360
- } catch (error) {
2361
- return false;
2362
- }
2363
- };
2364
-
2365
- var isConstructorLegacy = function isConstructor(argument) {
2366
- if (!isCallable(argument)) return false;
2367
- switch (classof(argument)) {
2368
- case 'AsyncFunction':
2369
- case 'GeneratorFunction':
2370
- case 'AsyncGeneratorFunction': return false;
2371
- }
2372
- try {
2373
- // we can't check .prototype since constructors produced by .bind haven't it
2374
- // `Function#toString` throws on some built-it function in some legacy engines
2375
- // (for example, `DOMQuad` and similar in FF41-)
2376
- return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument));
2377
- } catch (error) {
2378
- return true;
2379
- }
2380
- };
2381
-
2382
- isConstructorLegacy.sham = true;
2383
-
2384
- // `IsConstructor` abstract operation
2385
- // https://tc39.es/ecma262/#sec-isconstructor
2386
- var isConstructor$1 = !construct || fails(function () {
2387
- var called;
2388
- return isConstructorModern(isConstructorModern.call)
2389
- || !isConstructorModern(Object)
2390
- || !isConstructorModern(function () { called = true; })
2391
- || called;
2392
- }) ? isConstructorLegacy : isConstructorModern;
2393
-
2394
- var isArray = isArray$2;
2395
- var isConstructor = isConstructor$1;
2396
- var isObject = isObject$7;
2397
- var wellKnownSymbol = wellKnownSymbol$9;
2398
-
2399
- var SPECIES = wellKnownSymbol('species');
2400
- var $Array = Array;
2401
-
2402
- // a part of `ArraySpeciesCreate` abstract operation
2403
- // https://tc39.es/ecma262/#sec-arrayspeciescreate
2404
- var arraySpeciesConstructor$1 = function (originalArray) {
2405
- var C;
2406
- if (isArray(originalArray)) {
2407
- C = originalArray.constructor;
2408
- // cross-realm fallback
2409
- if (isConstructor(C) && (C === $Array || isArray(C.prototype))) C = undefined;
2410
- else if (isObject(C)) {
2411
- C = C[SPECIES];
2412
- if (C === null) C = undefined;
2413
- }
2414
- } return C === undefined ? $Array : C;
2415
- };
2416
-
2417
- var arraySpeciesConstructor = arraySpeciesConstructor$1;
2418
-
2419
- // `ArraySpeciesCreate` abstract operation
2420
- // https://tc39.es/ecma262/#sec-arrayspeciescreate
2421
- var arraySpeciesCreate$1 = function (originalArray, length) {
2422
- return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
2423
- };
2424
-
2425
- var $ = _export;
2426
- var flattenIntoArray = flattenIntoArray_1;
2427
- var toObject = toObject$5;
2428
- var lengthOfArrayLike = lengthOfArrayLike$4;
2429
- var toIntegerOrInfinity = toIntegerOrInfinity$3;
2430
- var arraySpeciesCreate = arraySpeciesCreate$1;
2431
-
2432
- // `Array.prototype.flat` method
2433
- // https://tc39.es/ecma262/#sec-array.prototype.flat
2434
- $({ target: 'Array', proto: true }, {
2435
- flat: function flat(/* depthArg = 1 */) {
2436
- var depthArg = arguments.length ? arguments[0] : undefined;
2437
- var O = toObject(this);
2438
- var sourceLen = lengthOfArrayLike(O);
2439
- var A = arraySpeciesCreate(O, 0);
2440
- A.length = flattenIntoArray(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toIntegerOrInfinity(depthArg));
2441
- return A;
2442
- }
2443
- });
2444
-
2445
- // this method was added to unscopables after implementation
2446
- // in popular engines, so it's moved to a separate module
2447
- var addToUnscopables = addToUnscopables$2;
2448
-
2449
- // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
2450
- addToUnscopables('flat');
2451
-
2452
- function isRenderPlugin(plugin) {
2453
- return typeof plugin['getRenderWrapper'] === 'function';
2454
- }
2455
-
2456
- const ComponentWrapper = _a => {
2457
- var {
2458
- children
2459
- } = _a,
2460
- props = __rest(_a, ["children"]);
2461
- const {
2462
- plugins
2463
- } = useNinetailed();
2464
- const renderPlugins = plugins.flat().filter(isRenderPlugin).map(plugin => plugin.getRenderWrapper());
2465
- // Initialized as empty object to not override the props of the component by default
2466
- const [enhancedComponentProps, setEnhancedComponentProps] = useState({});
2467
- // If there are no render plugins, we can skip the wrapping of the component
2468
- if (!renderPlugins.length) {
2469
- console.info('No Render-Plugins detected.');
2470
- return jsx(Fragment, {
2471
- children: children
2472
- });
2473
- }
2474
- // Recursively wrap the component with the render plugins. The props are drilled down to the component through each wrapper.
2475
- return jsx(Fragment, {
2476
- children: renderPlugins.reduce((component, WrapperComponent) => jsx(WrapperComponent, Object.assign({}, props, {
2477
- setComponentProps: setEnhancedComponentProps
2478
- }, {
2479
- children: component
2480
- })), jsx(Fragment, {
2481
- children: React.Children.map(children, child => {
2482
- if ( /*#__PURE__*/React.isValidElement(child)) {
2483
- return /*#__PURE__*/React.cloneElement(child, enhancedComponentProps);
2484
- }
2485
- return null;
2486
- })
2487
- }))
2488
- });
2489
- };
2490
-
2491
2032
  /**
2492
2033
  * This component is used to conditionally render Experiences which may include empty variants.
2493
2034
  * It is essential to intercept the props within the ComponentWrapper to be able to get the current variant.
@@ -2511,6 +2052,35 @@ const ConditionalRenderComponent = _a => {
2511
2052
  });
2512
2053
  };
2513
2054
 
2055
+ const useExperienceSelectionMiddleware = ({
2056
+ experiences,
2057
+ baseline,
2058
+ profile
2059
+ }) => {
2060
+ const {
2061
+ plugins
2062
+ } = useNinetailed();
2063
+ const [_, setCurrentTime] = useState(Date.now());
2064
+ const {
2065
+ addListeners,
2066
+ removeListeners,
2067
+ middleware
2068
+ } = useMemo(() => makeExperienceSelectMiddleware({
2069
+ plugins,
2070
+ experiences,
2071
+ baseline,
2072
+ profile,
2073
+ onChange: () => setCurrentTime(Date.now())
2074
+ }), [plugins, experiences, baseline, profile]);
2075
+ useEffect(() => {
2076
+ addListeners();
2077
+ return () => {
2078
+ removeListeners();
2079
+ };
2080
+ }, [addListeners, removeListeners]);
2081
+ return middleware;
2082
+ };
2083
+
2514
2084
  const DefaultExperienceLoadingComponent = _a => {
2515
2085
  var {
2516
2086
  component: Component,
@@ -2568,8 +2138,8 @@ const Experience = _a => {
2568
2138
  const {
2569
2139
  status,
2570
2140
  hasVariants,
2571
- experience,
2572
- variant,
2141
+ experience: originalExperience,
2142
+ variant: originalVariant,
2573
2143
  audience,
2574
2144
  isPersonalized,
2575
2145
  profile
@@ -2577,6 +2147,18 @@ const Experience = _a => {
2577
2147
  baseline,
2578
2148
  experiences
2579
2149
  });
2150
+ const experienceSelectionMiddleware = useExperienceSelectionMiddleware({
2151
+ experiences,
2152
+ baseline,
2153
+ profile
2154
+ });
2155
+ const {
2156
+ experience,
2157
+ variant
2158
+ } = experienceSelectionMiddleware({
2159
+ experience: originalExperience,
2160
+ variant: originalVariant
2161
+ });
2580
2162
  const joinExperiment = useJoinExperiment();
2581
2163
  useEffect(() => {
2582
2164
  if (status === 'success' && experience && profile) {
@@ -2601,19 +2183,14 @@ const Experience = _a => {
2601
2183
  }));
2602
2184
  }
2603
2185
  if (!experience) {
2604
- return jsx(ComponentWrapper, Object.assign({
2605
- experiences: experiences,
2606
- baseline: baseline
2607
- }, {
2608
- children: jsx(Component, Object.assign({}, passthroughProps, baseline, {
2609
- ninetailed: {
2610
- isPersonalized: false,
2611
- audience: {
2612
- id: 'baseline'
2613
- }
2186
+ return jsx(Component, Object.assign({}, passthroughProps, baseline, {
2187
+ ninetailed: {
2188
+ isPersonalized: false,
2189
+ audience: {
2190
+ id: 'baseline'
2614
2191
  }
2615
- }))
2616
- }), baseline.id);
2192
+ }
2193
+ }));
2617
2194
  }
2618
2195
  if (!variant) {
2619
2196
  return jsx(TrackExperience, Object.assign({
@@ -2622,18 +2199,13 @@ const Experience = _a => {
2622
2199
  // the profile is definitely defined, otherwise there wouldn't be an experience selected
2623
2200
  profile: profile
2624
2201
  }, {
2625
- children: jsx(ComponentWrapper, Object.assign({
2626
- experiences: experiences,
2627
- baseline: baseline
2628
- }, {
2629
- children: jsx(Component, Object.assign({}, passthroughProps, baseline, {
2630
- ninetailed: {
2631
- isPersonalized: false,
2632
- audience: {
2633
- id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
2634
- }
2202
+ children: jsx(Component, Object.assign({}, passthroughProps, baseline, {
2203
+ ninetailed: {
2204
+ isPersonalized: false,
2205
+ audience: {
2206
+ id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
2635
2207
  }
2636
- }))
2208
+ }
2637
2209
  }))
2638
2210
  }), baseline.id);
2639
2211
  }
@@ -2643,22 +2215,17 @@ const Experience = _a => {
2643
2215
  // the profile is definitely defined, otherwise there wouldn't be an experience selected
2644
2216
  profile: profile
2645
2217
  }, {
2646
- children: jsx(ComponentWrapper, Object.assign({
2647
- experiences: experiences,
2648
- baseline: baseline
2649
- }, {
2650
- children: jsx(ConditionalRenderComponent, {
2651
- children: /*#__PURE__*/createElement$1(Component, Object.assign({}, Object.assign(Object.assign({}, passthroughProps), variant), {
2652
- key: `${experience.id}-${variant.id}`,
2653
- ninetailed: {
2654
- isPersonalized,
2655
- audience: {
2656
- id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
2657
- }
2218
+ children: jsx(ConditionalRenderComponent, {
2219
+ children: /*#__PURE__*/createElement$1(Component, Object.assign({}, Object.assign(Object.assign({}, passthroughProps), variant), {
2220
+ key: `${experience.id}-${variant.id}`,
2221
+ ninetailed: {
2222
+ isPersonalized,
2223
+ audience: {
2224
+ id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
2658
2225
  }
2659
- }))
2660
- })
2661
- }))
2226
+ }
2227
+ }))
2228
+ })
2662
2229
  }));
2663
2230
  };
2664
2231
 
@@ -2747,4 +2314,240 @@ const ESRLoadingComponent = _a => {
2747
2314
  }));
2748
2315
  };
2749
2316
 
2317
+ const EXPERIENCE_TRAIT_PREFIX = 'nt_experiment_';
2318
+
2319
+ const debounce = (fn, wait, options) => {
2320
+ let debouncedArgs = [];
2321
+ const debouncedFn = _debounce(() => {
2322
+ fn.call(undefined, debouncedArgs);
2323
+ debouncedArgs = [];
2324
+ }, wait, options);
2325
+ return (...args) => {
2326
+ debouncedArgs.push(values$1(args));
2327
+ debouncedFn();
2328
+ };
2329
+ };
2330
+ const useProvideJoinExperiment = ({
2331
+ experiments,
2332
+ maximumActiveExperiments: _maximumActiveExperiments = 1
2333
+ }) => {
2334
+ const {
2335
+ identify
2336
+ } = useNinetailed();
2337
+ const joinExperimentIdentify = debounce(args => {
2338
+ const traits = args.slice(0, _maximumActiveExperiments).reduce((traits, [experimentJoinTraits]) => {
2339
+ return Object.assign(Object.assign({}, experimentJoinTraits), traits);
2340
+ }, {});
2341
+ identify('', traits);
2342
+ });
2343
+ return useCallback(data => __awaiter(void 0, void 0, void 0, function* () {
2344
+ const {
2345
+ experiment,
2346
+ profile
2347
+ } = data;
2348
+ const isExperiment = experiment.type === 'nt_experiment';
2349
+ if (!isExperiment) {
2350
+ logger.warn(`The experience ${experiment.id}, which you tried to join, is not an experiment.`);
2351
+ return;
2352
+ }
2353
+ const activeExperiments = selectActiveExperiments(experiments, profile);
2354
+ if (activeExperiments.length >= _maximumActiveExperiments) {
2355
+ logger.warn(`The maximum number of active experiments (${_maximumActiveExperiments}) has been reached.`);
2356
+ return;
2357
+ }
2358
+ if (activeExperiments.some(activeExperiment => activeExperiment.id === experiment.id)) {
2359
+ logger.debug(`The user is already part of experiment ${experiment.id}. Won't join again.`);
2360
+ return;
2361
+ }
2362
+ joinExperimentIdentify({
2363
+ [`${EXPERIENCE_TRAIT_PREFIX}${experiment.id}`]: true
2364
+ });
2365
+ logger.debug(`Sent event to join experiment ${experiment.id}.`);
2366
+ }), []);
2367
+ };
2368
+
2369
+ const ExperimentsProvider = ({
2370
+ experiments,
2371
+ maximumActiveExperiments: _maximumActiveExperiments = 1,
2372
+ children
2373
+ }) => {
2374
+ const joinExperiment = useProvideJoinExperiment({
2375
+ experiments,
2376
+ maximumActiveExperiments: _maximumActiveExperiments
2377
+ });
2378
+ return jsx(ExperimentsContext.Provider, Object.assign({
2379
+ value: {
2380
+ experiments,
2381
+ joinExperiment
2382
+ }
2383
+ }, {
2384
+ children: children
2385
+ }));
2386
+ };
2387
+
2388
+ const NinetailedProvider = ({
2389
+ children,
2390
+ clientId,
2391
+ experiments: _experiments = [],
2392
+ maximumActiveExperiments,
2393
+ environment,
2394
+ preview,
2395
+ url,
2396
+ profile,
2397
+ locale,
2398
+ requestTimeout,
2399
+ plugins: _plugins = [],
2400
+ onLog,
2401
+ onError
2402
+ }) => {
2403
+ const ninetailed = useMemo(() => new Ninetailed({
2404
+ clientId,
2405
+ environment,
2406
+ preview
2407
+ }, {
2408
+ url,
2409
+ plugins: _plugins,
2410
+ profile,
2411
+ locale,
2412
+ requestTimeout,
2413
+ onLog,
2414
+ onError
2415
+ }), []);
2416
+ return jsx(NinetailedContext.Provider, Object.assign({
2417
+ value: ninetailed
2418
+ }, {
2419
+ children: jsx(ExperimentsProvider, Object.assign({
2420
+ experiments: _experiments,
2421
+ maximumActiveExperiments: maximumActiveExperiments
2422
+ }, {
2423
+ children: children
2424
+ }))
2425
+ }));
2426
+ };
2427
+
2428
+ const usePersonalize = (baseline, variants, options = {
2429
+ holdout: -1
2430
+ }) => {
2431
+ const profile = useProfile();
2432
+ return selectVariant(baseline, variants, profile, options);
2433
+ };
2434
+
2435
+ const TrackHasSeenComponent = ({
2436
+ children,
2437
+ variant,
2438
+ audience,
2439
+ isPersonalized
2440
+ }) => {
2441
+ const ninetailed = useNinetailed();
2442
+ const {
2443
+ ref,
2444
+ inView
2445
+ } = useInView({
2446
+ triggerOnce: true
2447
+ });
2448
+ useEffect(() => {
2449
+ if (isBrowser() && inView) {
2450
+ ninetailed.trackHasSeenComponent({
2451
+ variant,
2452
+ audience,
2453
+ isPersonalized
2454
+ });
2455
+ }
2456
+ }, [inView]);
2457
+ return jsxs(Fragment, {
2458
+ children: [jsx("div", {
2459
+ ref: ref
2460
+ }), children]
2461
+ });
2462
+ };
2463
+
2464
+ const Personalize = _a => {
2465
+ var {
2466
+ component: Component,
2467
+ loadingComponent: LoadingComponent,
2468
+ variants = [],
2469
+ holdout = -1
2470
+ } = _a,
2471
+ baseline = __rest(_a, ["component", "loadingComponent", "variants", "holdout"]);
2472
+ const {
2473
+ loading,
2474
+ variant,
2475
+ isPersonalized,
2476
+ audience
2477
+ } = usePersonalize(baseline, variants, {
2478
+ holdout
2479
+ });
2480
+ const hasVariants = variants.length > 0;
2481
+ if (!hasVariants) {
2482
+ return jsx(Component, Object.assign({}, baseline, {
2483
+ ninetailed: {
2484
+ isPersonalized,
2485
+ audience
2486
+ }
2487
+ }));
2488
+ }
2489
+ if (loading) {
2490
+ if (LoadingComponent) {
2491
+ return jsx(LoadingComponent, {});
2492
+ }
2493
+ return jsx("div", Object.assign({
2494
+ style: {
2495
+ opacity: 0
2496
+ }
2497
+ }, {
2498
+ children: jsx(Component, Object.assign({}, variant, {
2499
+ ninetailed: {
2500
+ isPersonalized,
2501
+ audience
2502
+ }
2503
+ }))
2504
+ }), "hide");
2505
+ }
2506
+ return jsx(TrackHasSeenComponent, Object.assign({
2507
+ variant: variant,
2508
+ audience: audience,
2509
+ isPersonalized: isPersonalized
2510
+ }, {
2511
+ children: /*#__PURE__*/createElement$1(Component, Object.assign({}, variant, {
2512
+ key: `${audience.id}-${variant.id}`,
2513
+ ninetailed: {
2514
+ isPersonalized,
2515
+ audience
2516
+ }
2517
+ }))
2518
+ }));
2519
+ };
2520
+
2521
+ const generateSelectors = id => {
2522
+ return id.split('_').map((path, index, paths) => {
2523
+ const dotPath = paths.slice(0, index).join('.');
2524
+ const underScorePath = paths.slice(index).join('_');
2525
+ return [dotPath, underScorePath].filter(path => path !== '').join('.');
2526
+ });
2527
+ };
2528
+ const selectValueFromProfile = (profile, id) => {
2529
+ const selectors = generateSelectors(id);
2530
+ const matchingSelector = selectors.find(selector => get$1(profile, selector));
2531
+ if (!matchingSelector) {
2532
+ return null;
2533
+ }
2534
+ return get$1(profile, matchingSelector);
2535
+ };
2536
+ const MergeTag = ({
2537
+ id
2538
+ }) => {
2539
+ const {
2540
+ loading,
2541
+ profile
2542
+ } = useProfile();
2543
+ if (loading || !profile) {
2544
+ return null;
2545
+ }
2546
+ const value = selectValueFromProfile(profile, id);
2547
+ // DON'T CHANGE
2548
+ return jsx(Fragment, {
2549
+ children: value
2550
+ });
2551
+ };
2552
+
2750
2553
  export { DefaultExperienceLoadingComponent, ESRLoadingComponent, ESRProvider, Experience, ExperimentsProvider, MergeTag, NinetailedProvider, Personalize, TrackExperience, TrackHasSeenComponent, useExperience, useExperiments, useJoinExperiment, useNinetailed, usePersonalize, useProfile };