@dereekb/util 10.1.9 → 10.1.11

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.js CHANGED
@@ -37,21 +37,21 @@ var functionUncurryThis = NATIVE_BIND$3 ? uncurryThisWithBind : function (fn) {
37
37
  };
38
38
  };
39
39
 
40
- var uncurryThis$s = functionUncurryThis;
40
+ var uncurryThis$t = functionUncurryThis;
41
41
 
42
- var toString$e = uncurryThis$s({}.toString);
43
- var stringSlice$a = uncurryThis$s(''.slice);
42
+ var toString$f = uncurryThis$t({}.toString);
43
+ var stringSlice$b = uncurryThis$t(''.slice);
44
44
 
45
45
  var classofRaw$2 = function (it) {
46
- return stringSlice$a(toString$e(it), 8, -1);
46
+ return stringSlice$b(toString$f(it), 8, -1);
47
47
  };
48
48
 
49
- var uncurryThis$r = functionUncurryThis;
49
+ var uncurryThis$s = functionUncurryThis;
50
50
  var fails$n = fails$p;
51
51
  var classof$8 = classofRaw$2;
52
52
 
53
53
  var $Object$4 = Object;
54
- var split = uncurryThis$r(''.split);
54
+ var split = uncurryThis$s(''.split);
55
55
 
56
56
  // fallback for non-array-like ES3 and non-enumerable old V8 strings
57
57
  var indexedObject = fails$n(function () {
@@ -74,17 +74,17 @@ var $TypeError$h = TypeError;
74
74
 
75
75
  // `RequireObjectCoercible` abstract operation
76
76
  // https://tc39.es/ecma262/#sec-requireobjectcoercible
77
- var requireObjectCoercible$a = function (it) {
77
+ var requireObjectCoercible$b = function (it) {
78
78
  if (isNullOrUndefined$6(it)) throw new $TypeError$h("Can't call method on " + it);
79
79
  return it;
80
80
  };
81
81
 
82
82
  // toObject with fallback for non-array-like ES3 strings
83
83
  var IndexedObject$2 = indexedObject;
84
- var requireObjectCoercible$9 = requireObjectCoercible$a;
84
+ var requireObjectCoercible$a = requireObjectCoercible$b;
85
85
 
86
86
  var toIndexedObject$5 = function (it) {
87
- return IndexedObject$2(requireObjectCoercible$9(it));
87
+ return IndexedObject$2(requireObjectCoercible$a(it));
88
88
  };
89
89
 
90
90
  var check = function (it) {
@@ -138,20 +138,20 @@ var store$2 = sharedStore;
138
138
  source: 'https://github.com/zloirock/core-js'
139
139
  });
140
140
 
141
- var requireObjectCoercible$8 = requireObjectCoercible$a;
141
+ var requireObjectCoercible$9 = requireObjectCoercible$b;
142
142
 
143
143
  var $Object$3 = Object;
144
144
 
145
145
  // `ToObject` abstract operation
146
146
  // https://tc39.es/ecma262/#sec-toobject
147
147
  var toObject$7 = function (argument) {
148
- return $Object$3(requireObjectCoercible$8(argument));
148
+ return $Object$3(requireObjectCoercible$9(argument));
149
149
  };
150
150
 
151
- var uncurryThis$q = functionUncurryThis;
151
+ var uncurryThis$r = functionUncurryThis;
152
152
  var toObject$6 = toObject$7;
153
153
 
154
- var hasOwnProperty = uncurryThis$q({}.hasOwnProperty);
154
+ var hasOwnProperty = uncurryThis$r({}.hasOwnProperty);
155
155
 
156
156
  // `HasOwnProperty` abstract operation
157
157
  // https://tc39.es/ecma262/#sec-hasownproperty
@@ -160,20 +160,20 @@ var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
160
160
  return hasOwnProperty(toObject$6(it), key);
161
161
  };
162
162
 
163
- var uncurryThis$p = functionUncurryThis;
163
+ var uncurryThis$q = functionUncurryThis;
164
164
 
165
165
  var id = 0;
166
166
  var postfix = Math.random();
167
- var toString$d = uncurryThis$p(1.0.toString);
167
+ var toString$e = uncurryThis$q(1.0.toString);
168
168
 
169
169
  var uid$2 = function (key) {
170
- return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$d(++id + postfix, 36);
170
+ return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$e(++id + postfix, 36);
171
171
  };
172
172
 
173
173
  var engineUserAgent = typeof navigator != 'undefined' && String(navigator.userAgent) || '';
174
174
 
175
175
  var global$l = global$o;
176
- var userAgent$5 = engineUserAgent;
176
+ var userAgent$6 = engineUserAgent;
177
177
 
178
178
  var process$3 = global$l.process;
179
179
  var Deno$1 = global$l.Deno;
@@ -190,10 +190,10 @@ if (v8) {
190
190
 
191
191
  // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
192
192
  // so check `userAgent` even if `.v8` exists, but 0
193
- if (!version && userAgent$5) {
194
- match = userAgent$5.match(/Edge\/(\d+)/);
193
+ if (!version && userAgent$6) {
194
+ match = userAgent$6.match(/Edge\/(\d+)/);
195
195
  if (!match || match[1] >= 74) {
196
- match = userAgent$5.match(/Chrome\/(\d+)/);
196
+ match = userAgent$6.match(/Chrome\/(\d+)/);
197
197
  if (match) version = +match[1];
198
198
  }
199
199
  }
@@ -341,9 +341,9 @@ var getBuiltIn$7 = function (namespace, method) {
341
341
  return arguments.length < 2 ? aFunction(global$h[namespace]) : global$h[namespace] && global$h[namespace][method];
342
342
  };
343
343
 
344
- var uncurryThis$o = functionUncurryThis;
344
+ var uncurryThis$p = functionUncurryThis;
345
345
 
346
- var objectIsPrototypeOf = uncurryThis$o({}.isPrototypeOf);
346
+ var objectIsPrototypeOf = uncurryThis$p({}.isPrototypeOf);
347
347
 
348
348
  var getBuiltIn$6 = getBuiltIn$7;
349
349
  var isCallable$k = isCallable$n;
@@ -486,7 +486,7 @@ objectDefineProperty.f = DESCRIPTORS$b ? V8_PROTOTYPE_DEFINE_BUG$1 ? function de
486
486
  return O;
487
487
  };
488
488
 
489
- var ceil = Math.ceil;
489
+ var ceil$1 = Math.ceil;
490
490
  var floor$3 = Math.floor;
491
491
 
492
492
  // `Math.trunc` method
@@ -494,7 +494,7 @@ var floor$3 = Math.floor;
494
494
  // eslint-disable-next-line es/no-math-trunc -- safe
495
495
  var mathTrunc = Math.trunc || function trunc(x) {
496
496
  var n = +x;
497
- return (n > 0 ? floor$3 : ceil)(n);
497
+ return (n > 0 ? floor$3 : ceil$1)(n);
498
498
  };
499
499
 
500
500
  var trunc = mathTrunc;
@@ -526,17 +526,17 @@ var min$4 = Math.min;
526
526
 
527
527
  // `ToLength` abstract operation
528
528
  // https://tc39.es/ecma262/#sec-tolength
529
- var toLength$6 = function (argument) {
529
+ var toLength$7 = function (argument) {
530
530
  var len = toIntegerOrInfinity$5(argument);
531
531
  return len > 0 ? min$4(len, 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
532
532
  };
533
533
 
534
- var toLength$5 = toLength$6;
534
+ var toLength$6 = toLength$7;
535
535
 
536
536
  // `LengthOfArrayLike` abstract operation
537
537
  // https://tc39.es/ecma262/#sec-lengthofarraylike
538
538
  var lengthOfArrayLike$6 = function (obj) {
539
- return toLength$5(obj.length);
539
+ return toLength$6(obj.length);
540
540
  };
541
541
 
542
542
  var toIndexedObject$4 = toIndexedObject$5;
@@ -544,7 +544,7 @@ var toAbsoluteIndex = toAbsoluteIndex$1;
544
544
  var lengthOfArrayLike$5 = lengthOfArrayLike$6;
545
545
 
546
546
  // `Array.prototype.{ indexOf, includes }` methods implementation
547
- var createMethod$3 = function (IS_INCLUDES) {
547
+ var createMethod$4 = function (IS_INCLUDES) {
548
548
  return function ($this, el, fromIndex) {
549
549
  var O = toIndexedObject$4($this);
550
550
  var length = lengthOfArrayLike$5(O);
@@ -566,21 +566,21 @@ var createMethod$3 = function (IS_INCLUDES) {
566
566
  var arrayIncludes = {
567
567
  // `Array.prototype.includes` method
568
568
  // https://tc39.es/ecma262/#sec-array.prototype.includes
569
- includes: createMethod$3(true),
569
+ includes: createMethod$4(true),
570
570
  // `Array.prototype.indexOf` method
571
571
  // https://tc39.es/ecma262/#sec-array.prototype.indexof
572
- indexOf: createMethod$3(false)
572
+ indexOf: createMethod$4(false)
573
573
  };
574
574
 
575
575
  var hiddenKeys$4 = {};
576
576
 
577
- var uncurryThis$n = functionUncurryThis;
577
+ var uncurryThis$o = functionUncurryThis;
578
578
  var hasOwn$b = hasOwnProperty_1;
579
579
  var toIndexedObject$3 = toIndexedObject$5;
580
580
  var indexOf$1 = arrayIncludes.indexOf;
581
581
  var hiddenKeys$3 = hiddenKeys$4;
582
582
 
583
- var push$3 = uncurryThis$n([].push);
583
+ var push$3 = uncurryThis$o([].push);
584
584
 
585
585
  var objectKeysInternal = function (object, names) {
586
586
  var O = toIndexedObject$3(object);
@@ -916,11 +916,11 @@ var functionName = {
916
916
  CONFIGURABLE: CONFIGURABLE
917
917
  };
918
918
 
919
- var uncurryThis$m = functionUncurryThis;
919
+ var uncurryThis$n = functionUncurryThis;
920
920
  var isCallable$g = isCallable$n;
921
921
  var store = sharedStore;
922
922
 
923
- var functionToString = uncurryThis$m(Function.toString);
923
+ var functionToString = uncurryThis$n(Function.toString);
924
924
 
925
925
  // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
926
926
  if (!isCallable$g(store.inspectSource)) {
@@ -931,7 +931,7 @@ if (!isCallable$g(store.inspectSource)) {
931
931
 
932
932
  var inspectSource$3 = store.inspectSource;
933
933
 
934
- var uncurryThis$l = functionUncurryThis;
934
+ var uncurryThis$m = functionUncurryThis;
935
935
  var fails$i = fails$p;
936
936
  var isCallable$f = isCallable$n;
937
937
  var hasOwn$7 = hasOwnProperty_1;
@@ -945,9 +945,9 @@ var getInternalState$2 = InternalStateModule$2.get;
945
945
  var $String$3 = String;
946
946
  // eslint-disable-next-line es/no-object-defineproperty -- safe
947
947
  var defineProperty$5 = Object.defineProperty;
948
- var stringSlice$9 = uncurryThis$l(''.slice);
949
- var replace$5 = uncurryThis$l(''.replace);
950
- var join = uncurryThis$l([].join);
948
+ var stringSlice$a = uncurryThis$m(''.slice);
949
+ var replace$5 = uncurryThis$m(''.replace);
950
+ var join = uncurryThis$m([].join);
951
951
 
952
952
  var CONFIGURABLE_LENGTH = DESCRIPTORS$6 && !fails$i(function () {
953
953
  return defineProperty$5(function () { /* empty */ }, 'length', { value: 8 }).length !== 8;
@@ -956,7 +956,7 @@ var CONFIGURABLE_LENGTH = DESCRIPTORS$6 && !fails$i(function () {
956
956
  var TEMPLATE = String(String).split('String');
957
957
 
958
958
  var makeBuiltIn$2 = makeBuiltIn$3.exports = function (value, name, options) {
959
- if (stringSlice$9($String$3(name), 0, 7) === 'Symbol(') {
959
+ if (stringSlice$a($String$3(name), 0, 7) === 'Symbol(') {
960
960
  name = '[' + replace$5($String$3(name), /^Symbol\(([^)]*)\).*$/, '$1') + ']';
961
961
  }
962
962
  if (options && options.getter) name = 'get ' + name;
@@ -1034,12 +1034,12 @@ var objectGetOwnPropertySymbols = {};
1034
1034
  objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
1035
1035
 
1036
1036
  var getBuiltIn$4 = getBuiltIn$7;
1037
- var uncurryThis$k = functionUncurryThis;
1037
+ var uncurryThis$l = functionUncurryThis;
1038
1038
  var getOwnPropertyNamesModule = objectGetOwnPropertyNames;
1039
1039
  var getOwnPropertySymbolsModule$1 = objectGetOwnPropertySymbols;
1040
1040
  var anObject$c = anObject$g;
1041
1041
 
1042
- var concat$2 = uncurryThis$k([].concat);
1042
+ var concat$2 = uncurryThis$l([].concat);
1043
1043
 
1044
1044
  // all object keys, includes non-enumerable and symbols
1045
1045
  var ownKeys$1 = getBuiltIn$4('Reflect', 'ownKeys') || function ownKeys(it) {
@@ -1249,13 +1249,13 @@ var iteratorCreateConstructor = function (IteratorConstructor, NAME, next, ENUME
1249
1249
  return IteratorConstructor;
1250
1250
  };
1251
1251
 
1252
- var uncurryThis$j = functionUncurryThis;
1252
+ var uncurryThis$k = functionUncurryThis;
1253
1253
  var aCallable$8 = aCallable$a;
1254
1254
 
1255
1255
  var functionUncurryThisAccessor = function (object, key, method) {
1256
1256
  try {
1257
1257
  // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
1258
- return uncurryThis$j(aCallable$8(Object.getOwnPropertyDescriptor(object, key)[method]));
1258
+ return uncurryThis$k(aCallable$8(Object.getOwnPropertyDescriptor(object, key)[method]));
1259
1259
  } catch (error) { /* empty */ }
1260
1260
  };
1261
1261
 
@@ -1302,7 +1302,7 @@ var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? functio
1302
1302
  };
1303
1303
  }() : undefined);
1304
1304
 
1305
- var $$h = _export;
1305
+ var $$i = _export;
1306
1306
  var call$f = functionCall;
1307
1307
  var FunctionName = functionName;
1308
1308
  var isCallable$a = isCallable$n;
@@ -1390,7 +1390,7 @@ var iteratorDefine = function (Iterable, NAME, IteratorConstructor, next, DEFAUL
1390
1390
  if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
1391
1391
  defineBuiltIn$5(IterablePrototype, KEY, methods[KEY]);
1392
1392
  }
1393
- } else $$h({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
1393
+ } else $$i({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
1394
1394
  }
1395
1395
 
1396
1396
  // define iterator
@@ -1558,7 +1558,7 @@ var lengthOfArrayLike$4 = lengthOfArrayLike$6;
1558
1558
  var $TypeError$a = TypeError;
1559
1559
 
1560
1560
  // `Array.prototype.{ reduce, reduceRight }` methods implementation
1561
- var createMethod$2 = function (IS_RIGHT) {
1561
+ var createMethod$3 = function (IS_RIGHT) {
1562
1562
  return function (that, callbackfn, argumentsLength, memo) {
1563
1563
  var O = toObject$4(that);
1564
1564
  var self = IndexedObject$1(O);
@@ -1587,10 +1587,10 @@ var createMethod$2 = function (IS_RIGHT) {
1587
1587
  var arrayReduce = {
1588
1588
  // `Array.prototype.reduce` method
1589
1589
  // https://tc39.es/ecma262/#sec-array.prototype.reduce
1590
- left: createMethod$2(false),
1590
+ left: createMethod$3(false),
1591
1591
  // `Array.prototype.reduceRight` method
1592
1592
  // https://tc39.es/ecma262/#sec-array.prototype.reduceright
1593
- right: createMethod$2(true)
1593
+ right: createMethod$3(true)
1594
1594
  };
1595
1595
 
1596
1596
  var fails$e = fails$p;
@@ -1608,7 +1608,7 @@ var classof$7 = classofRaw$2;
1608
1608
 
1609
1609
  var engineIsNode = classof$7(global$c.process) === 'process';
1610
1610
 
1611
- var $$g = _export;
1611
+ var $$h = _export;
1612
1612
  var $reduce = arrayReduce.left;
1613
1613
  var arrayMethodIsStrict$1 = arrayMethodIsStrict$2;
1614
1614
  var CHROME_VERSION = engineV8Version;
@@ -1621,7 +1621,7 @@ var FORCED$2 = CHROME_BUG || !arrayMethodIsStrict$1('reduce');
1621
1621
 
1622
1622
  // `Array.prototype.reduce` method
1623
1623
  // https://tc39.es/ecma262/#sec-array.prototype.reduce
1624
- $$g({ target: 'Array', proto: true, forced: FORCED$2 }, {
1624
+ $$h({ target: 'Array', proto: true, forced: FORCED$2 }, {
1625
1625
  reduce: function reduce(callbackfn /* , initialValue */) {
1626
1626
  var length = arguments.length;
1627
1627
  return $reduce(this, callbackfn, length, length > 1 ? arguments[1] : undefined);
@@ -1891,7 +1891,7 @@ var classof$5 = classof$6;
1891
1891
 
1892
1892
  var $String$1 = String;
1893
1893
 
1894
- var toString$c = function (argument) {
1894
+ var toString$d = function (argument) {
1895
1895
  if (classof$5(argument) === 'Symbol') throw new TypeError('Cannot convert a Symbol value to a string');
1896
1896
  return $String$1(argument);
1897
1897
  };
@@ -1905,14 +1905,14 @@ var defineBuiltInAccessor$2 = function (target, name, descriptor) {
1905
1905
  return defineProperty$2.f(target, name, descriptor);
1906
1906
  };
1907
1907
 
1908
- var $$f = _export;
1908
+ var $$g = _export;
1909
1909
  var DESCRIPTORS$4 = descriptors;
1910
1910
  var global$b = global$o;
1911
- var uncurryThis$i = functionUncurryThis;
1911
+ var uncurryThis$j = functionUncurryThis;
1912
1912
  var hasOwn$3 = hasOwnProperty_1;
1913
1913
  var isCallable$8 = isCallable$n;
1914
1914
  var isPrototypeOf$4 = objectIsPrototypeOf;
1915
- var toString$b = toString$c;
1915
+ var toString$c = toString$d;
1916
1916
  var defineBuiltInAccessor$1 = defineBuiltInAccessor$2;
1917
1917
  var copyConstructorProperties = copyConstructorProperties$2;
1918
1918
 
@@ -1926,7 +1926,7 @@ if (DESCRIPTORS$4 && isCallable$8(NativeSymbol) && (!('description' in SymbolPro
1926
1926
  var EmptyStringDescriptionStore = {};
1927
1927
  // wrap Symbol constructor for correct work with undefined description
1928
1928
  var SymbolWrapper = function Symbol() {
1929
- var description = arguments.length < 1 || arguments[0] === undefined ? undefined : toString$b(arguments[0]);
1929
+ var description = arguments.length < 1 || arguments[0] === undefined ? undefined : toString$c(arguments[0]);
1930
1930
  var result = isPrototypeOf$4(SymbolPrototype, this)
1931
1931
  ? new NativeSymbol(description)
1932
1932
  // in Edge 13, String(Symbol(undefined)) === 'Symbol(undefined)'
@@ -1940,11 +1940,11 @@ if (DESCRIPTORS$4 && isCallable$8(NativeSymbol) && (!('description' in SymbolPro
1940
1940
  SymbolPrototype.constructor = SymbolWrapper;
1941
1941
 
1942
1942
  var NATIVE_SYMBOL = String(NativeSymbol('description detection')) === 'Symbol(description detection)';
1943
- var thisSymbolValue = uncurryThis$i(SymbolPrototype.valueOf);
1944
- var symbolDescriptiveString = uncurryThis$i(SymbolPrototype.toString);
1943
+ var thisSymbolValue = uncurryThis$j(SymbolPrototype.valueOf);
1944
+ var symbolDescriptiveString = uncurryThis$j(SymbolPrototype.toString);
1945
1945
  var regexp = /^Symbol\((.*)\)[^)]+$/;
1946
- var replace$4 = uncurryThis$i(''.replace);
1947
- var stringSlice$8 = uncurryThis$i(''.slice);
1946
+ var replace$4 = uncurryThis$j(''.replace);
1947
+ var stringSlice$9 = uncurryThis$j(''.slice);
1948
1948
 
1949
1949
  defineBuiltInAccessor$1(SymbolPrototype, 'description', {
1950
1950
  configurable: true,
@@ -1952,12 +1952,12 @@ if (DESCRIPTORS$4 && isCallable$8(NativeSymbol) && (!('description' in SymbolPro
1952
1952
  var symbol = thisSymbolValue(this);
1953
1953
  if (hasOwn$3(EmptyStringDescriptionStore, symbol)) return '';
1954
1954
  var string = symbolDescriptiveString(symbol);
1955
- var desc = NATIVE_SYMBOL ? stringSlice$8(string, 7, -1) : replace$4(string, regexp, '$1');
1955
+ var desc = NATIVE_SYMBOL ? stringSlice$9(string, 7, -1) : replace$4(string, regexp, '$1');
1956
1956
  return desc === '' ? undefined : desc;
1957
1957
  }
1958
1958
  });
1959
1959
 
1960
- $$f({ global: true, constructor: true, forced: true }, {
1960
+ $$g({ global: true, constructor: true, forced: true }, {
1961
1961
  Symbol: SymbolWrapper
1962
1962
  });
1963
1963
  }
@@ -1972,6 +1972,15 @@ function asIterable(values, treatStringAsIterable) {
1972
1972
  }
1973
1973
  return iterable;
1974
1974
  }
1975
+ /**
1976
+ * Converts the input IterableOrValue value to an array.
1977
+ *
1978
+ * By default will treat strings as a non-iterable value, using the string as a single value.
1979
+ *
1980
+ * @param values
1981
+ * @param treatStringAsIterable
1982
+ * @returns
1983
+ */
1975
1984
  function iterableToArray(values, treatStringAsIterable) {
1976
1985
  let iterable;
1977
1986
  if (treatStringAsIterable && typeof values === 'string') {
@@ -1983,6 +1992,25 @@ function iterableToArray(values, treatStringAsIterable) {
1983
1992
  }
1984
1993
  return iterable;
1985
1994
  }
1995
+ /**
1996
+ * Converts the input IterableOrValue value to a Set.
1997
+ *
1998
+ * By default will treat strings as a non-iterable value, using the string as a single value.
1999
+ *
2000
+ * @param values
2001
+ * @param treatStringAsIterable
2002
+ * @returns
2003
+ */
2004
+ function iterableToSet(values, treatStringAsIterable = false) {
2005
+ return new Set(iterableToArray(values, treatStringAsIterable));
2006
+ }
2007
+ /**
2008
+ * Converts the input IterableOrValue value to a Map using the input readKey function.
2009
+ *
2010
+ * @param values
2011
+ * @param readKey
2012
+ * @returns
2013
+ */
1986
2014
  function iterableToMap(values, readKey) {
1987
2015
  const map = new Map(iterableToArray(values).map(value => [readKey(value), value]));
1988
2016
  return map;
@@ -2560,7 +2588,7 @@ function setsAreEquivalent(a, b) {
2560
2588
  }
2561
2589
 
2562
2590
  var DESCRIPTORS$3 = descriptors;
2563
- var uncurryThis$h = functionUncurryThis;
2591
+ var uncurryThis$i = functionUncurryThis;
2564
2592
  var call$e = functionCall;
2565
2593
  var fails$d = fails$p;
2566
2594
  var objectKeys = objectKeys$2;
@@ -2573,7 +2601,7 @@ var IndexedObject = indexedObject;
2573
2601
  var $assign = Object.assign;
2574
2602
  // eslint-disable-next-line es/no-object-defineproperty -- required for testing
2575
2603
  var defineProperty$1 = Object.defineProperty;
2576
- var concat$1 = uncurryThis$h([].concat);
2604
+ var concat$1 = uncurryThis$i([].concat);
2577
2605
 
2578
2606
  // `Object.assign` method
2579
2607
  // https://tc39.es/ecma262/#sec-object.assign
@@ -2616,13 +2644,13 @@ var objectAssign = !$assign || fails$d(function () {
2616
2644
  } return T;
2617
2645
  } : $assign;
2618
2646
 
2619
- var $$e = _export;
2647
+ var $$f = _export;
2620
2648
  var assign = objectAssign;
2621
2649
 
2622
2650
  // `Object.assign` method
2623
2651
  // https://tc39.es/ecma262/#sec-object.assign
2624
2652
  // eslint-disable-next-line es/no-object-assign -- required for testing
2625
- $$e({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }, {
2653
+ $$f({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }, {
2626
2654
  assign: assign
2627
2655
  });
2628
2656
 
@@ -3239,9 +3267,9 @@ var deletePropertyOrThrow$1 = function (O, P) {
3239
3267
  if (!delete O[P]) throw new $TypeError$9('Cannot delete property ' + tryToString$3(P) + ' of ' + tryToString$3(O));
3240
3268
  };
3241
3269
 
3242
- var uncurryThis$g = functionUncurryThis;
3270
+ var uncurryThis$h = functionUncurryThis;
3243
3271
 
3244
- var arraySlice$2 = uncurryThis$g([].slice);
3272
+ var arraySlice$2 = uncurryThis$h([].slice);
3245
3273
 
3246
3274
  var arraySlice$1 = arraySlice$2;
3247
3275
 
@@ -3285,9 +3313,9 @@ var sort = function (array, comparefn) {
3285
3313
 
3286
3314
  var arraySort = sort;
3287
3315
 
3288
- var userAgent$4 = engineUserAgent;
3316
+ var userAgent$5 = engineUserAgent;
3289
3317
 
3290
- var firefox = userAgent$4.match(/firefox\/(\d+)/i);
3318
+ var firefox = userAgent$5.match(/firefox\/(\d+)/i);
3291
3319
 
3292
3320
  var engineFfVersion = !!firefox && +firefox[1];
3293
3321
 
@@ -3295,19 +3323,19 @@ var UA = engineUserAgent;
3295
3323
 
3296
3324
  var engineIsIeOrEdge = /MSIE|Trident/.test(UA);
3297
3325
 
3298
- var userAgent$3 = engineUserAgent;
3326
+ var userAgent$4 = engineUserAgent;
3299
3327
 
3300
- var webkit = userAgent$3.match(/AppleWebKit\/(\d+)\./);
3328
+ var webkit = userAgent$4.match(/AppleWebKit\/(\d+)\./);
3301
3329
 
3302
3330
  var engineWebkitVersion = !!webkit && +webkit[1];
3303
3331
 
3304
- var $$d = _export;
3305
- var uncurryThis$f = functionUncurryThis;
3332
+ var $$e = _export;
3333
+ var uncurryThis$g = functionUncurryThis;
3306
3334
  var aCallable$6 = aCallable$a;
3307
3335
  var toObject$2 = toObject$7;
3308
3336
  var lengthOfArrayLike$3 = lengthOfArrayLike$6;
3309
3337
  var deletePropertyOrThrow = deletePropertyOrThrow$1;
3310
- var toString$a = toString$c;
3338
+ var toString$b = toString$d;
3311
3339
  var fails$c = fails$p;
3312
3340
  var internalSort = arraySort;
3313
3341
  var arrayMethodIsStrict = arrayMethodIsStrict$2;
@@ -3317,8 +3345,8 @@ var V8 = engineV8Version;
3317
3345
  var WEBKIT = engineWebkitVersion;
3318
3346
 
3319
3347
  var test$1 = [];
3320
- var nativeSort = uncurryThis$f(test$1.sort);
3321
- var push$2 = uncurryThis$f(test$1.push);
3348
+ var nativeSort = uncurryThis$g(test$1.sort);
3349
+ var push$2 = uncurryThis$g(test$1.push);
3322
3350
 
3323
3351
  // IE8-
3324
3352
  var FAILS_ON_UNDEFINED = fails$c(function () {
@@ -3373,13 +3401,13 @@ var getSortCompare = function (comparefn) {
3373
3401
  if (y === undefined) return -1;
3374
3402
  if (x === undefined) return 1;
3375
3403
  if (comparefn !== undefined) return +comparefn(x, y) || 0;
3376
- return toString$a(x) > toString$a(y) ? 1 : -1;
3404
+ return toString$b(x) > toString$b(y) ? 1 : -1;
3377
3405
  };
3378
3406
  };
3379
3407
 
3380
3408
  // `Array.prototype.sort` method
3381
3409
  // https://tc39.es/ecma262/#sec-array.prototype.sort
3382
- $$d({ target: 'Array', proto: true, forced: FORCED$1 }, {
3410
+ $$e({ target: 'Array', proto: true, forced: FORCED$1 }, {
3383
3411
  sort: function sort(comparefn) {
3384
3412
  if (comparefn !== undefined) aCallable$6(comparefn);
3385
3413
 
@@ -3441,7 +3469,7 @@ var regexpGetFlags = function (R) {
3441
3469
  var PROPER_FUNCTION_NAME$1 = functionName.PROPER;
3442
3470
  var defineBuiltIn$4 = defineBuiltIn$8;
3443
3471
  var anObject$9 = anObject$g;
3444
- var $toString = toString$c;
3472
+ var $toString = toString$d;
3445
3473
  var fails$b = fails$p;
3446
3474
  var getRegExpFlags$1 = regexpGetFlags;
3447
3475
 
@@ -4369,8 +4397,8 @@ var regexpUnsupportedNcg = fails$8(function () {
4369
4397
  /* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */
4370
4398
  /* eslint-disable regexp/no-useless-quantifier -- testing */
4371
4399
  var call$c = functionCall;
4372
- var uncurryThis$e = functionUncurryThis;
4373
- var toString$9 = toString$c;
4400
+ var uncurryThis$f = functionUncurryThis;
4401
+ var toString$a = toString$d;
4374
4402
  var regexpFlags = regexpFlags$1;
4375
4403
  var stickyHelpers$2 = regexpStickyHelpers;
4376
4404
  var shared = shared$4.exports;
@@ -4382,10 +4410,10 @@ var UNSUPPORTED_NCG$1 = regexpUnsupportedNcg;
4382
4410
  var nativeReplace = shared('native-string-replace', String.prototype.replace);
4383
4411
  var nativeExec = RegExp.prototype.exec;
4384
4412
  var patchedExec = nativeExec;
4385
- var charAt$4 = uncurryThis$e(''.charAt);
4386
- var indexOf = uncurryThis$e(''.indexOf);
4387
- var replace$3 = uncurryThis$e(''.replace);
4388
- var stringSlice$7 = uncurryThis$e(''.slice);
4413
+ var charAt$4 = uncurryThis$f(''.charAt);
4414
+ var indexOf = uncurryThis$f(''.indexOf);
4415
+ var replace$3 = uncurryThis$f(''.replace);
4416
+ var stringSlice$8 = uncurryThis$f(''.slice);
4389
4417
 
4390
4418
  var UPDATES_LAST_INDEX_WRONG = (function () {
4391
4419
  var re1 = /a/;
@@ -4406,7 +4434,7 @@ if (PATCH) {
4406
4434
  patchedExec = function exec(string) {
4407
4435
  var re = this;
4408
4436
  var state = getInternalState(re);
4409
- var str = toString$9(string);
4437
+ var str = toString$a(string);
4410
4438
  var raw = state.raw;
4411
4439
  var result, reCopy, lastIndex, match, i, object, group;
4412
4440
 
@@ -4430,7 +4458,7 @@ if (PATCH) {
4430
4458
  flags += 'g';
4431
4459
  }
4432
4460
 
4433
- strCopy = stringSlice$7(str, re.lastIndex);
4461
+ strCopy = stringSlice$8(str, re.lastIndex);
4434
4462
  // Support anchored sticky behavior.
4435
4463
  if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt$4(str, re.lastIndex - 1) !== '\n')) {
4436
4464
  source = '(?: ' + source + ')';
@@ -4451,8 +4479,8 @@ if (PATCH) {
4451
4479
 
4452
4480
  if (sticky) {
4453
4481
  if (match) {
4454
- match.input = stringSlice$7(match.input, charsAdded);
4455
- match[0] = stringSlice$7(match[0], charsAdded);
4482
+ match.input = stringSlice$8(match.input, charsAdded);
4483
+ match[0] = stringSlice$8(match[0], charsAdded);
4456
4484
  match.index = re.lastIndex;
4457
4485
  re.lastIndex += match[0].length;
4458
4486
  } else re.lastIndex = 0;
@@ -4483,31 +4511,31 @@ if (PATCH) {
4483
4511
 
4484
4512
  var regexpExec$2 = patchedExec;
4485
4513
 
4486
- var $$c = _export;
4514
+ var $$d = _export;
4487
4515
  var exec$2 = regexpExec$2;
4488
4516
 
4489
4517
  // `RegExp.prototype.exec` method
4490
4518
  // https://tc39.es/ecma262/#sec-regexp.prototype.exec
4491
- $$c({ target: 'RegExp', proto: true, forced: /./.exec !== exec$2 }, {
4519
+ $$d({ target: 'RegExp', proto: true, forced: /./.exec !== exec$2 }, {
4492
4520
  exec: exec$2
4493
4521
  });
4494
4522
 
4495
- var uncurryThis$d = functionUncurryThis;
4523
+ var uncurryThis$e = functionUncurryThis;
4496
4524
 
4497
4525
  // `thisNumberValue` abstract operation
4498
4526
  // https://tc39.es/ecma262/#sec-thisnumbervalue
4499
- var thisNumberValue$1 = uncurryThis$d(1.0.valueOf);
4527
+ var thisNumberValue$1 = uncurryThis$e(1.0.valueOf);
4500
4528
 
4501
4529
  var toIntegerOrInfinity$4 = toIntegerOrInfinity$7;
4502
- var toString$8 = toString$c;
4503
- var requireObjectCoercible$7 = requireObjectCoercible$a;
4530
+ var toString$9 = toString$d;
4531
+ var requireObjectCoercible$8 = requireObjectCoercible$b;
4504
4532
 
4505
4533
  var $RangeError$1 = RangeError;
4506
4534
 
4507
4535
  // `String.prototype.repeat` method implementation
4508
4536
  // https://tc39.es/ecma262/#sec-string.prototype.repeat
4509
4537
  var stringRepeat = function repeat(count) {
4510
- var str = toString$8(requireObjectCoercible$7(this));
4538
+ var str = toString$9(requireObjectCoercible$8(this));
4511
4539
  var result = '';
4512
4540
  var n = toIntegerOrInfinity$4(count);
4513
4541
  if (n < 0 || n === Infinity) throw new $RangeError$1('Wrong number of repetitions');
@@ -4515,19 +4543,19 @@ var stringRepeat = function repeat(count) {
4515
4543
  return result;
4516
4544
  };
4517
4545
 
4518
- var $$b = _export;
4519
- var uncurryThis$c = functionUncurryThis;
4546
+ var $$c = _export;
4547
+ var uncurryThis$d = functionUncurryThis;
4520
4548
  var toIntegerOrInfinity$3 = toIntegerOrInfinity$7;
4521
4549
  var thisNumberValue = thisNumberValue$1;
4522
- var $repeat = stringRepeat;
4550
+ var $repeat$1 = stringRepeat;
4523
4551
  var fails$7 = fails$p;
4524
4552
 
4525
4553
  var $RangeError = RangeError;
4526
4554
  var $String = String;
4527
4555
  var floor$1 = Math.floor;
4528
- var repeat = uncurryThis$c($repeat);
4529
- var stringSlice$6 = uncurryThis$c(''.slice);
4530
- var nativeToFixed = uncurryThis$c(1.0.toFixed);
4556
+ var repeat$1 = uncurryThis$d($repeat$1);
4557
+ var stringSlice$7 = uncurryThis$d(''.slice);
4558
+ var nativeToFixed = uncurryThis$d(1.0.toFixed);
4531
4559
 
4532
4560
  var pow = function (x, n, acc) {
4533
4561
  return n === 0 ? acc : n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc);
@@ -4572,7 +4600,7 @@ var dataToString = function (data) {
4572
4600
  while (--index >= 0) {
4573
4601
  if (s !== '' || index === 0 || data[index] !== 0) {
4574
4602
  var t = $String(data[index]);
4575
- s = s === '' ? t : s + repeat('0', 7 - t.length) + t;
4603
+ s = s === '' ? t : s + repeat$1('0', 7 - t.length) + t;
4576
4604
  }
4577
4605
  } return s;
4578
4606
  };
@@ -4589,7 +4617,7 @@ var FORCED = fails$7(function () {
4589
4617
 
4590
4618
  // `Number.prototype.toFixed` method
4591
4619
  // https://tc39.es/ecma262/#sec-number.prototype.tofixed
4592
- $$b({ target: 'Number', proto: true, forced: FORCED }, {
4620
+ $$c({ target: 'Number', proto: true, forced: FORCED }, {
4593
4621
  toFixed: function toFixed(fractionDigits) {
4594
4622
  var number = thisNumberValue(this);
4595
4623
  var fractDigits = toIntegerOrInfinity$3(fractionDigits);
@@ -4632,14 +4660,14 @@ $$b({ target: 'Number', proto: true, forced: FORCED }, {
4632
4660
  } else {
4633
4661
  multiply(data, 0, z);
4634
4662
  multiply(data, 1 << -e, 0);
4635
- result = dataToString(data) + repeat('0', fractDigits);
4663
+ result = dataToString(data) + repeat$1('0', fractDigits);
4636
4664
  }
4637
4665
  }
4638
4666
  if (fractDigits > 0) {
4639
4667
  k = result.length;
4640
4668
  result = sign + (k <= fractDigits
4641
- ? '0.' + repeat('0', fractDigits - k) + result
4642
- : stringSlice$6(result, 0, k - fractDigits) + '.' + stringSlice$6(result, k - fractDigits));
4669
+ ? '0.' + repeat$1('0', fractDigits - k) + result
4670
+ : stringSlice$7(result, 0, k - fractDigits) + '.' + stringSlice$7(result, k - fractDigits));
4643
4671
  } else {
4644
4672
  result = sign + result;
4645
4673
  } return result;
@@ -5776,18 +5804,18 @@ var fixRegexpWellKnownSymbolLogic = function (KEY, exec, FORCED, SHAM) {
5776
5804
  if (SHAM) createNonEnumerableProperty$1(RegExpPrototype$1[SYMBOL], 'sham', true);
5777
5805
  };
5778
5806
 
5779
- var uncurryThis$b = functionUncurryThis;
5807
+ var uncurryThis$c = functionUncurryThis;
5780
5808
  var toIntegerOrInfinity$2 = toIntegerOrInfinity$7;
5781
- var toString$7 = toString$c;
5782
- var requireObjectCoercible$6 = requireObjectCoercible$a;
5809
+ var toString$8 = toString$d;
5810
+ var requireObjectCoercible$7 = requireObjectCoercible$b;
5783
5811
 
5784
- var charAt$3 = uncurryThis$b(''.charAt);
5785
- var charCodeAt = uncurryThis$b(''.charCodeAt);
5786
- var stringSlice$5 = uncurryThis$b(''.slice);
5812
+ var charAt$3 = uncurryThis$c(''.charAt);
5813
+ var charCodeAt = uncurryThis$c(''.charCodeAt);
5814
+ var stringSlice$6 = uncurryThis$c(''.slice);
5787
5815
 
5788
- var createMethod$1 = function (CONVERT_TO_STRING) {
5816
+ var createMethod$2 = function (CONVERT_TO_STRING) {
5789
5817
  return function ($this, pos) {
5790
- var S = toString$7(requireObjectCoercible$6($this));
5818
+ var S = toString$8(requireObjectCoercible$7($this));
5791
5819
  var position = toIntegerOrInfinity$2(pos);
5792
5820
  var size = S.length;
5793
5821
  var first, second;
@@ -5799,7 +5827,7 @@ var createMethod$1 = function (CONVERT_TO_STRING) {
5799
5827
  ? charAt$3(S, position)
5800
5828
  : first
5801
5829
  : CONVERT_TO_STRING
5802
- ? stringSlice$5(S, position, position + 2)
5830
+ ? stringSlice$6(S, position, position + 2)
5803
5831
  : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
5804
5832
  };
5805
5833
  };
@@ -5807,10 +5835,10 @@ var createMethod$1 = function (CONVERT_TO_STRING) {
5807
5835
  var stringMultibyte = {
5808
5836
  // `String.prototype.codePointAt` method
5809
5837
  // https://tc39.es/ecma262/#sec-string.prototype.codepointat
5810
- codeAt: createMethod$1(false),
5838
+ codeAt: createMethod$2(false),
5811
5839
  // `String.prototype.at` method
5812
5840
  // https://github.com/mathiasbynens/String.prototype.at
5813
- charAt: createMethod$1(true)
5841
+ charAt: createMethod$2(true)
5814
5842
  };
5815
5843
 
5816
5844
  var charAt$2 = stringMultibyte.charAt;
@@ -5846,9 +5874,9 @@ var call$9 = functionCall;
5846
5874
  var fixRegExpWellKnownSymbolLogic$2 = fixRegexpWellKnownSymbolLogic;
5847
5875
  var anObject$7 = anObject$g;
5848
5876
  var isNullOrUndefined$4 = isNullOrUndefined$7;
5849
- var toLength$4 = toLength$6;
5850
- var toString$6 = toString$c;
5851
- var requireObjectCoercible$5 = requireObjectCoercible$a;
5877
+ var toLength$5 = toLength$7;
5878
+ var toString$7 = toString$d;
5879
+ var requireObjectCoercible$6 = requireObjectCoercible$b;
5852
5880
  var getMethod$4 = getMethod$6;
5853
5881
  var advanceStringIndex$2 = advanceStringIndex$3;
5854
5882
  var regExpExec$2 = regexpExecAbstract;
@@ -5859,15 +5887,15 @@ fixRegExpWellKnownSymbolLogic$2('match', function (MATCH, nativeMatch, maybeCall
5859
5887
  // `String.prototype.match` method
5860
5888
  // https://tc39.es/ecma262/#sec-string.prototype.match
5861
5889
  function match(regexp) {
5862
- var O = requireObjectCoercible$5(this);
5890
+ var O = requireObjectCoercible$6(this);
5863
5891
  var matcher = isNullOrUndefined$4(regexp) ? undefined : getMethod$4(regexp, MATCH);
5864
- return matcher ? call$9(matcher, regexp, O) : new RegExp(regexp)[MATCH](toString$6(O));
5892
+ return matcher ? call$9(matcher, regexp, O) : new RegExp(regexp)[MATCH](toString$7(O));
5865
5893
  },
5866
5894
  // `RegExp.prototype[@@match]` method
5867
5895
  // https://tc39.es/ecma262/#sec-regexp.prototype-@@match
5868
5896
  function (string) {
5869
5897
  var rx = anObject$7(this);
5870
- var S = toString$6(string);
5898
+ var S = toString$7(string);
5871
5899
  var res = maybeCallNative(nativeMatch, rx, S);
5872
5900
 
5873
5901
  if (res.done) return res.value;
@@ -5880,9 +5908,9 @@ fixRegExpWellKnownSymbolLogic$2('match', function (MATCH, nativeMatch, maybeCall
5880
5908
  var n = 0;
5881
5909
  var result;
5882
5910
  while ((result = regExpExec$2(rx, S)) !== null) {
5883
- var matchStr = toString$6(result[0]);
5911
+ var matchStr = toString$7(result[0]);
5884
5912
  A[n] = matchStr;
5885
- if (matchStr === '') rx.lastIndex = advanceStringIndex$2(S, toLength$4(rx.lastIndex), fullUnicode);
5913
+ if (matchStr === '') rx.lastIndex = advanceStringIndex$2(S, toLength$5(rx.lastIndex), fullUnicode);
5886
5914
  n++;
5887
5915
  }
5888
5916
  return n === 0 ? null : A;
@@ -6154,19 +6182,19 @@ function findIndexOfFirstDuplicateValue(values) {
6154
6182
  var whitespaces$2 = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' +
6155
6183
  '\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
6156
6184
 
6157
- var uncurryThis$a = functionUncurryThis;
6158
- var requireObjectCoercible$4 = requireObjectCoercible$a;
6159
- var toString$5 = toString$c;
6185
+ var uncurryThis$b = functionUncurryThis;
6186
+ var requireObjectCoercible$5 = requireObjectCoercible$b;
6187
+ var toString$6 = toString$d;
6160
6188
  var whitespaces$1 = whitespaces$2;
6161
6189
 
6162
- var replace$2 = uncurryThis$a(''.replace);
6190
+ var replace$2 = uncurryThis$b(''.replace);
6163
6191
  var ltrim = RegExp('^[' + whitespaces$1 + ']+');
6164
6192
  var rtrim = RegExp('(^|[^' + whitespaces$1 + '])[' + whitespaces$1 + ']+$');
6165
6193
 
6166
6194
  // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
6167
- var createMethod = function (TYPE) {
6195
+ var createMethod$1 = function (TYPE) {
6168
6196
  return function ($this) {
6169
- var string = toString$5(requireObjectCoercible$4($this));
6197
+ var string = toString$6(requireObjectCoercible$5($this));
6170
6198
  if (TYPE & 1) string = replace$2(string, ltrim, '');
6171
6199
  if (TYPE & 2) string = replace$2(string, rtrim, '$1');
6172
6200
  return string;
@@ -6176,13 +6204,13 @@ var createMethod = function (TYPE) {
6176
6204
  var stringTrim = {
6177
6205
  // `String.prototype.{ trimLeft, trimStart }` methods
6178
6206
  // https://tc39.es/ecma262/#sec-string.prototype.trimstart
6179
- start: createMethod(1),
6207
+ start: createMethod$1(1),
6180
6208
  // `String.prototype.{ trimRight, trimEnd }` methods
6181
6209
  // https://tc39.es/ecma262/#sec-string.prototype.trimend
6182
- end: createMethod(2),
6210
+ end: createMethod$1(2),
6183
6211
  // `String.prototype.trim` method
6184
6212
  // https://tc39.es/ecma262/#sec-string.prototype.trim
6185
- trim: createMethod(3)
6213
+ trim: createMethod$1(3)
6186
6214
  };
6187
6215
 
6188
6216
  var PROPER_FUNCTION_NAME = functionName.PROPER;
@@ -6201,19 +6229,19 @@ var stringTrimForced = function (METHOD_NAME) {
6201
6229
  });
6202
6230
  };
6203
6231
 
6204
- var $$a = _export;
6232
+ var $$b = _export;
6205
6233
  var $trim = stringTrim.trim;
6206
6234
  var forcedStringTrimMethod = stringTrimForced;
6207
6235
 
6208
6236
  // `String.prototype.trim` method
6209
6237
  // https://tc39.es/ecma262/#sec-string.prototype.trim
6210
- $$a({ target: 'String', proto: true, forced: forcedStringTrimMethod('trim') }, {
6238
+ $$b({ target: 'String', proto: true, forced: forcedStringTrimMethod('trim') }, {
6211
6239
  trim: function trim() {
6212
6240
  return $trim(this);
6213
6241
  }
6214
6242
  });
6215
6243
 
6216
- var uncurryThis$9 = functionUncurryThis;
6244
+ var uncurryThis$a = functionUncurryThis;
6217
6245
  var fails$4 = fails$p;
6218
6246
  var isCallable$6 = isCallable$n;
6219
6247
  var classof$3 = classof$6;
@@ -6223,7 +6251,7 @@ var inspectSource$1 = inspectSource$3;
6223
6251
  var noop = function () { /* empty */ };
6224
6252
  var construct = getBuiltIn$3('Reflect', 'construct');
6225
6253
  var constructorRegExp = /^\s*(?:class|function)\b/;
6226
- var exec$1 = uncurryThis$9(constructorRegExp.exec);
6254
+ var exec$1 = uncurryThis$a(constructorRegExp.exec);
6227
6255
  var INCORRECT_TO_STRING = !constructorRegExp.test(noop);
6228
6256
 
6229
6257
  var isConstructorModern = function isConstructor(argument) {
@@ -6292,15 +6320,15 @@ var speciesConstructor$2 = function (O, defaultConstructor) {
6292
6320
  };
6293
6321
 
6294
6322
  var call$8 = functionCall;
6295
- var uncurryThis$8 = functionUncurryThis;
6323
+ var uncurryThis$9 = functionUncurryThis;
6296
6324
  var fixRegExpWellKnownSymbolLogic$1 = fixRegexpWellKnownSymbolLogic;
6297
6325
  var anObject$5 = anObject$g;
6298
6326
  var isNullOrUndefined$2 = isNullOrUndefined$7;
6299
- var requireObjectCoercible$3 = requireObjectCoercible$a;
6327
+ var requireObjectCoercible$4 = requireObjectCoercible$b;
6300
6328
  var speciesConstructor$1 = speciesConstructor$2;
6301
6329
  var advanceStringIndex$1 = advanceStringIndex$3;
6302
- var toLength$3 = toLength$6;
6303
- var toString$4 = toString$c;
6330
+ var toLength$4 = toLength$7;
6331
+ var toString$5 = toString$d;
6304
6332
  var getMethod$3 = getMethod$6;
6305
6333
  var regExpExec$1 = regexpExecAbstract;
6306
6334
  var stickyHelpers$1 = regexpStickyHelpers;
@@ -6309,8 +6337,8 @@ var fails$3 = fails$p;
6309
6337
  var UNSUPPORTED_Y$1 = stickyHelpers$1.UNSUPPORTED_Y;
6310
6338
  var MAX_UINT32 = 0xFFFFFFFF;
6311
6339
  var min$3 = Math.min;
6312
- var push$1 = uncurryThis$8([].push);
6313
- var stringSlice$4 = uncurryThis$8(''.slice);
6340
+ var push$1 = uncurryThis$9([].push);
6341
+ var stringSlice$5 = uncurryThis$9(''.slice);
6314
6342
 
6315
6343
  // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
6316
6344
  // Weex JS has frozen built-in prototypes, so use try / catch wrapper
@@ -6342,11 +6370,11 @@ fixRegExpWellKnownSymbolLogic$1('split', function (SPLIT, nativeSplit, maybeCall
6342
6370
  // `String.prototype.split` method
6343
6371
  // https://tc39.es/ecma262/#sec-string.prototype.split
6344
6372
  function split(separator, limit) {
6345
- var O = requireObjectCoercible$3(this);
6373
+ var O = requireObjectCoercible$4(this);
6346
6374
  var splitter = isNullOrUndefined$2(separator) ? undefined : getMethod$3(separator, SPLIT);
6347
6375
  return splitter
6348
6376
  ? call$8(splitter, separator, O, limit)
6349
- : call$8(internalSplit, toString$4(O), separator, limit);
6377
+ : call$8(internalSplit, toString$5(O), separator, limit);
6350
6378
  },
6351
6379
  // `RegExp.prototype[@@split]` method
6352
6380
  // https://tc39.es/ecma262/#sec-regexp.prototype-@@split
@@ -6355,7 +6383,7 @@ fixRegExpWellKnownSymbolLogic$1('split', function (SPLIT, nativeSplit, maybeCall
6355
6383
  // the 'y' flag.
6356
6384
  function (string, limit) {
6357
6385
  var rx = anObject$5(this);
6358
- var S = toString$4(string);
6386
+ var S = toString$5(string);
6359
6387
 
6360
6388
  if (!BUGGY) {
6361
6389
  var res = maybeCallNative(internalSplit, rx, S, limit, internalSplit !== nativeSplit);
@@ -6379,15 +6407,15 @@ fixRegExpWellKnownSymbolLogic$1('split', function (SPLIT, nativeSplit, maybeCall
6379
6407
  var A = [];
6380
6408
  while (q < S.length) {
6381
6409
  splitter.lastIndex = UNSUPPORTED_Y$1 ? 0 : q;
6382
- var z = regExpExec$1(splitter, UNSUPPORTED_Y$1 ? stringSlice$4(S, q) : S);
6410
+ var z = regExpExec$1(splitter, UNSUPPORTED_Y$1 ? stringSlice$5(S, q) : S);
6383
6411
  var e;
6384
6412
  if (
6385
6413
  z === null ||
6386
- (e = min$3(toLength$3(splitter.lastIndex + (UNSUPPORTED_Y$1 ? q : 0)), S.length)) === p
6414
+ (e = min$3(toLength$4(splitter.lastIndex + (UNSUPPORTED_Y$1 ? q : 0)), S.length)) === p
6387
6415
  ) {
6388
6416
  q = advanceStringIndex$1(S, q, unicodeMatching);
6389
6417
  } else {
6390
- push$1(A, stringSlice$4(S, p, q));
6418
+ push$1(A, stringSlice$5(S, p, q));
6391
6419
  if (A.length === lim) return A;
6392
6420
  for (var i = 1; i <= z.length - 1; i++) {
6393
6421
  push$1(A, z[i]);
@@ -6396,7 +6424,7 @@ fixRegExpWellKnownSymbolLogic$1('split', function (SPLIT, nativeSplit, maybeCall
6396
6424
  q = p = e;
6397
6425
  }
6398
6426
  }
6399
- push$1(A, stringSlice$4(S, p));
6427
+ push$1(A, stringSlice$5(S, p));
6400
6428
  return A;
6401
6429
  }
6402
6430
  ];
@@ -6511,13 +6539,13 @@ function mapIterable(values, fn) {
6511
6539
  }
6512
6540
 
6513
6541
  var classofRaw = classofRaw$2;
6514
- var uncurryThis$7 = functionUncurryThis;
6542
+ var uncurryThis$8 = functionUncurryThis;
6515
6543
 
6516
6544
  var functionUncurryThisClause = function (fn) {
6517
6545
  // Nashorn bug:
6518
6546
  // https://github.com/zloirock/core-js/issues/1128
6519
6547
  // https://github.com/zloirock/core-js/issues/1130
6520
- if (classofRaw(fn) === 'Function') return uncurryThis$7(fn);
6548
+ if (classofRaw(fn) === 'Function') return uncurryThis$8(fn);
6521
6549
  };
6522
6550
 
6523
6551
  var isObject$4 = isObject$c;
@@ -6559,16 +6587,16 @@ var correctIsRegexpLogic = function (METHOD_NAME) {
6559
6587
  } return false;
6560
6588
  };
6561
6589
 
6562
- var $$9 = _export;
6563
- var uncurryThis$6 = functionUncurryThisClause;
6590
+ var $$a = _export;
6591
+ var uncurryThis$7 = functionUncurryThisClause;
6564
6592
  var getOwnPropertyDescriptor$2 = objectGetOwnPropertyDescriptor.f;
6565
- var toLength$2 = toLength$6;
6566
- var toString$3 = toString$c;
6593
+ var toLength$3 = toLength$7;
6594
+ var toString$4 = toString$d;
6567
6595
  var notARegExp$1 = notARegexp;
6568
- var requireObjectCoercible$2 = requireObjectCoercible$a;
6596
+ var requireObjectCoercible$3 = requireObjectCoercible$b;
6569
6597
  var correctIsRegExpLogic$1 = correctIsRegexpLogic;
6570
6598
 
6571
- var stringSlice$3 = uncurryThis$6(''.slice);
6599
+ var stringSlice$4 = uncurryThis$7(''.slice);
6572
6600
  var min$2 = Math.min;
6573
6601
 
6574
6602
  var CORRECT_IS_REGEXP_LOGIC$1 = correctIsRegExpLogic$1('startsWith');
@@ -6580,26 +6608,26 @@ var MDN_POLYFILL_BUG$1 = !CORRECT_IS_REGEXP_LOGIC$1 && !!function () {
6580
6608
 
6581
6609
  // `String.prototype.startsWith` method
6582
6610
  // https://tc39.es/ecma262/#sec-string.prototype.startswith
6583
- $$9({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG$1 && !CORRECT_IS_REGEXP_LOGIC$1 }, {
6611
+ $$a({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG$1 && !CORRECT_IS_REGEXP_LOGIC$1 }, {
6584
6612
  startsWith: function startsWith(searchString /* , position = 0 */) {
6585
- var that = toString$3(requireObjectCoercible$2(this));
6613
+ var that = toString$4(requireObjectCoercible$3(this));
6586
6614
  notARegExp$1(searchString);
6587
- var index = toLength$2(min$2(arguments.length > 1 ? arguments[1] : undefined, that.length));
6588
- var search = toString$3(searchString);
6589
- return stringSlice$3(that, index, index + search.length) === search;
6615
+ var index = toLength$3(min$2(arguments.length > 1 ? arguments[1] : undefined, that.length));
6616
+ var search = toString$4(searchString);
6617
+ return stringSlice$4(that, index, index + search.length) === search;
6590
6618
  }
6591
6619
  });
6592
6620
 
6593
- var $$8 = _export;
6594
- var uncurryThis$5 = functionUncurryThisClause;
6621
+ var $$9 = _export;
6622
+ var uncurryThis$6 = functionUncurryThisClause;
6595
6623
  var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
6596
- var toLength$1 = toLength$6;
6597
- var toString$2 = toString$c;
6624
+ var toLength$2 = toLength$7;
6625
+ var toString$3 = toString$d;
6598
6626
  var notARegExp = notARegexp;
6599
- var requireObjectCoercible$1 = requireObjectCoercible$a;
6627
+ var requireObjectCoercible$2 = requireObjectCoercible$b;
6600
6628
  var correctIsRegExpLogic = correctIsRegexpLogic;
6601
6629
 
6602
- var slice = uncurryThis$5(''.slice);
6630
+ var slice = uncurryThis$6(''.slice);
6603
6631
  var min$1 = Math.min;
6604
6632
 
6605
6633
  var CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('endsWith');
@@ -6611,18 +6639,71 @@ var MDN_POLYFILL_BUG = !CORRECT_IS_REGEXP_LOGIC && !!function () {
6611
6639
 
6612
6640
  // `String.prototype.endsWith` method
6613
6641
  // https://tc39.es/ecma262/#sec-string.prototype.endswith
6614
- $$8({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC }, {
6642
+ $$9({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC }, {
6615
6643
  endsWith: function endsWith(searchString /* , endPosition = @length */) {
6616
- var that = toString$2(requireObjectCoercible$1(this));
6644
+ var that = toString$3(requireObjectCoercible$2(this));
6617
6645
  notARegExp(searchString);
6618
6646
  var endPosition = arguments.length > 1 ? arguments[1] : undefined;
6619
6647
  var len = that.length;
6620
- var end = endPosition === undefined ? len : min$1(toLength$1(endPosition), len);
6621
- var search = toString$2(searchString);
6648
+ var end = endPosition === undefined ? len : min$1(toLength$2(endPosition), len);
6649
+ var search = toString$3(searchString);
6622
6650
  return slice(that, end - search.length, end) === search;
6623
6651
  }
6624
6652
  });
6625
6653
 
6654
+ // https://github.com/tc39/proposal-string-pad-start-end
6655
+ var uncurryThis$5 = functionUncurryThis;
6656
+ var toLength$1 = toLength$7;
6657
+ var toString$2 = toString$d;
6658
+ var $repeat = stringRepeat;
6659
+ var requireObjectCoercible$1 = requireObjectCoercible$b;
6660
+
6661
+ var repeat = uncurryThis$5($repeat);
6662
+ var stringSlice$3 = uncurryThis$5(''.slice);
6663
+ var ceil = Math.ceil;
6664
+
6665
+ // `String.prototype.{ padStart, padEnd }` methods implementation
6666
+ var createMethod = function (IS_END) {
6667
+ return function ($this, maxLength, fillString) {
6668
+ var S = toString$2(requireObjectCoercible$1($this));
6669
+ var intMaxLength = toLength$1(maxLength);
6670
+ var stringLength = S.length;
6671
+ var fillStr = fillString === undefined ? ' ' : toString$2(fillString);
6672
+ var fillLen, stringFiller;
6673
+ if (intMaxLength <= stringLength || fillStr === '') return S;
6674
+ fillLen = intMaxLength - stringLength;
6675
+ stringFiller = repeat(fillStr, ceil(fillLen / fillStr.length));
6676
+ if (stringFiller.length > fillLen) stringFiller = stringSlice$3(stringFiller, 0, fillLen);
6677
+ return IS_END ? S + stringFiller : stringFiller + S;
6678
+ };
6679
+ };
6680
+
6681
+ var stringPad = {
6682
+ // `String.prototype.padStart` method
6683
+ // https://tc39.es/ecma262/#sec-string.prototype.padstart
6684
+ start: createMethod(false),
6685
+ // `String.prototype.padEnd` method
6686
+ // https://tc39.es/ecma262/#sec-string.prototype.padend
6687
+ end: createMethod(true)
6688
+ };
6689
+
6690
+ // https://github.com/zloirock/core-js/issues/280
6691
+ var userAgent$3 = engineUserAgent;
6692
+
6693
+ var stringPadWebkitBug = /Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(userAgent$3);
6694
+
6695
+ var $$8 = _export;
6696
+ var $padStart = stringPad.start;
6697
+ var WEBKIT_BUG = stringPadWebkitBug;
6698
+
6699
+ // `String.prototype.padStart` method
6700
+ // https://tc39.es/ecma262/#sec-string.prototype.padstart
6701
+ $$8({ target: 'String', proto: true, forced: WEBKIT_BUG }, {
6702
+ padStart: function padStart(maxLength /* , fillString = ' ' */) {
6703
+ return $padStart(this, maxLength, arguments.length > 1 ? arguments[1] : undefined);
6704
+ }
6705
+ });
6706
+
6626
6707
  function stringTrimFunction(input) {
6627
6708
  return input.trim();
6628
6709
  }
@@ -6691,6 +6772,15 @@ function addSuffixFunction(suffix) {
6691
6772
  return input.endsWith(suffix) ? input : input + suffix;
6692
6773
  };
6693
6774
  }
6775
+ /**
6776
+ *
6777
+ * @param minLength
6778
+ * @param padCharacter
6779
+ * @returns
6780
+ */
6781
+ function padStartFunction(minLength, padCharacter) {
6782
+ return input => input.padStart(minLength, padCharacter);
6783
+ }
6694
6784
 
6695
6785
  function hasDifferentStringsNoCase(a, b) {
6696
6786
  return hasDifferentValues(a.map(caseInsensitiveString), b.map(caseInsensitiveString));
@@ -7706,7 +7796,7 @@ var create = objectCreate;
7706
7796
  var getOwnPropertyNames = objectGetOwnPropertyNames.f;
7707
7797
  var isPrototypeOf$2 = objectIsPrototypeOf;
7708
7798
  var isRegExp = isRegexp;
7709
- var toString$1 = toString$c;
7799
+ var toString$1 = toString$d;
7710
7800
  var getRegExpFlags = regexpGetFlags;
7711
7801
  var stickyHelpers = regexpStickyHelpers;
7712
7802
  var proxyAccessor = proxyAccessor$1;
@@ -7954,9 +8044,9 @@ var anObject$4 = anObject$g;
7954
8044
  var isCallable$4 = isCallable$n;
7955
8045
  var isNullOrUndefined$1 = isNullOrUndefined$7;
7956
8046
  var toIntegerOrInfinity$1 = toIntegerOrInfinity$7;
7957
- var toLength = toLength$6;
7958
- var toString = toString$c;
7959
- var requireObjectCoercible = requireObjectCoercible$a;
8047
+ var toLength = toLength$7;
8048
+ var toString = toString$d;
8049
+ var requireObjectCoercible = requireObjectCoercible$b;
7960
8050
  var advanceStringIndex = advanceStringIndex$3;
7961
8051
  var getMethod$2 = getMethod$6;
7962
8052
  var getSubstitution = getSubstitution$1;
@@ -8227,6 +8317,22 @@ const UTF_8_START_CHARACTER = '\u0000';
8227
8317
  * https://firebase.google.com/docs/database/rest/retrieve-data#range-queries
8228
8318
  */
8229
8319
  const UTF_PRIVATE_USAGE_AREA_START = '\uf8ff';
8320
+ /**
8321
+ * Takes in a string and returns a Record that has the index value mapped to the property of the character.
8322
+ *
8323
+ * The latest character index is used in collision cases.
8324
+ *
8325
+ * @param chars
8326
+ * @returns
8327
+ */
8328
+ function stringCharactersToIndexRecord(chars) {
8329
+ const record = {};
8330
+ for (let i = 0; i < chars.length; i += 1) {
8331
+ const char = chars[i];
8332
+ record[char] = i;
8333
+ }
8334
+ return record;
8335
+ }
8230
8336
 
8231
8337
  function replaceStringsFunction(config) {
8232
8338
  const {
@@ -9380,1114 +9486,1819 @@ function compareEqualityWithValueFromItemsFunctionFactory(readValues) {
9380
9486
  }
9381
9487
 
9382
9488
  /**
9383
- * Creates a CronExpression for the input number of minutes.
9384
- *
9385
- * Note that if the number of minutes is greater than 60, it will generate an expression that
9386
- * isn't exactly n number of minutes apart from the previous execution, but instead create
9387
- * an expression that is n/60 hours apart and take place on the n%60th minute.
9388
- *
9389
- * @param inputMinutes
9390
- * @returns
9489
+ * TODO: Need to improve to support negative years.
9391
9490
  */
9392
- function cronExpressionRepeatingEveryNMinutes(inputMinutes) {
9393
- let minutes;
9394
- let hours;
9395
- let expression;
9396
- if (inputMinutes >= 60) {
9397
- hours = Math.floor(inputMinutes / 60);
9398
- minutes = inputMinutes % 60;
9399
- expression = `${minutes} */${hours} * * *`; // every nth hour at the given minute
9400
- } else {
9401
- expression = `*/${inputMinutes} * * * *`; // every nth minute
9402
- }
9403
-
9404
- return expression;
9405
- }
9406
-
9407
- function decisionFunction(decision) {
9408
- return () => decision;
9491
+ const ISO_8601_DATE_STRING_REGEX = /(\d{4,})-(\d{2})-(\d{2})T(\d{2})\:(\d{2})\:(\d{2})(Z|[+-](\d{2})\:(\d{2}))?/;
9492
+ function isISO8601DateString(input) {
9493
+ return ISO_8601_DATE_STRING_REGEX.test(input);
9409
9494
  }
9410
9495
  /**
9411
- * Used to invert a decision function by returning the opposite of what it returns.
9496
+ * Match examples:
9412
9497
  *
9413
- * @param filterFn
9414
- * @param invert whether or not to apply the inversion.
9415
- * @returns
9498
+ * Sat, 03 Feb 2001 04:05:06 GMT
9499
+ * Tue, 14 Mar 2023 12:34:56 UTC
9500
+ * Wed, 25 May 2024 20:45:07 EST
9416
9501
  */
9417
- const invertDecision = invertBooleanReturnFunction;
9502
+ const UTC_DATE_STRING_REGEX = /^([a-zA-Z]{3}, [0-9]{2} [a-zA-Z]{3} [0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2} [A-Z]{3})$/;
9503
+ function isUTCDateString(input) {
9504
+ return UTC_DATE_STRING_REGEX.test(input);
9505
+ }
9418
9506
  /**
9419
- * Creates a DecisionFunction from the input.
9507
+ * Returns true only if the inputs have the same timezone, or both do not have a timezone set.
9420
9508
  *
9421
- * @param valueOrFunction
9422
- * @param defaultIfUndefined
9509
+ * @param a
9510
+ * @param b
9423
9511
  * @returns
9424
9512
  */
9425
- function asDecisionFunction(valueOrFunction, defaultIfUndefined = true) {
9426
- const input = valueOrFunction !== null && valueOrFunction !== void 0 ? valueOrFunction : defaultIfUndefined;
9427
- if (typeof input === 'boolean') {
9428
- return () => input;
9429
- } else {
9430
- return input;
9431
- }
9432
- }
9433
- function isEqualToValueDecisionFunction(equalityValue) {
9434
- let equalityValueCheckFunction;
9435
- if (typeof equalityValue === 'function') {
9436
- equalityValueCheckFunction = equalityValue;
9437
- } else {
9438
- equalityValueCheckFunction = x => equalityValue === x;
9439
- }
9440
- return equalityValueCheckFunction;
9513
+ function hasSameTimezone(a, b) {
9514
+ const tzA = a === null || a === void 0 ? void 0 : a.timezone;
9515
+ const tzB = b === null || b === void 0 ? void 0 : b.timezone;
9516
+ return valuesAreBothNullishOrEquivalent(tzA, tzB);
9441
9517
  }
9442
-
9443
9518
  /**
9444
- * Creates an IsEqualContext
9445
- *
9446
- * @param contextValue
9447
- * @param fn
9448
- * @returns
9519
+ * Constant for the UTC timezone string, "UTC".
9449
9520
  */
9450
- function isEqualContext(contextValue, fn) {
9451
- return value => {
9452
- return fn(contextValue, value);
9453
- };
9521
+ const UTC_TIMEZONE_STRING = 'UTC';
9522
+ function isConsideredUtcTimezoneString(timezone) {
9523
+ return timezone == null || timezone === UTC_TIMEZONE_STRING;
9454
9524
  }
9455
9525
  /**
9456
- * Creates an AreEqualContext
9526
+ * Regex for an ISO8601DayString.
9527
+ */
9528
+ const ISO8601_DAY_STRING_REGEX = /^\d{4,}-\d{2}-\d{2}$/;
9529
+ /**
9530
+ * Regex for a string that starts as an ISO8601DayString.
9531
+ */
9532
+ const ISO8601_DAY_STRING_START_REGEX = /^\d{4,}-\d{2}-\d{2}/;
9533
+ /**
9534
+ * Returns the start of the input date's UTC time in UTC.
9457
9535
  *
9458
- * @param contextValue
9459
- * @param fn
9536
+ * I.E. 2022-01-02T04:00:00.000Z in GMT-6 returns 2022-01-02
9537
+ *
9538
+ * @param date
9460
9539
  * @returns
9461
9540
  */
9462
- function areEqualContext(contextValue, fn) {
9463
- const isEqual = isEqualContext(contextValue, fn);
9464
- return input => {
9465
- let areEqual = false;
9466
- if (isIterable(input)) {
9467
- areEqual = !existsInIterable(input, x => !isEqual(x));
9468
- } else {
9469
- areEqual = isEqual(input);
9470
- }
9471
- return areEqual;
9472
- };
9541
+ function startOfDayForUTCDateInUTC(date) {
9542
+ return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()));
9473
9543
  }
9474
9544
  /**
9475
- * Returns true if all input values are equal.
9545
+ * Returns the system's date in UTC.
9476
9546
  *
9477
- * Arrays that are empty or have one value will return true by default.
9547
+ * I.E. 2022-01-02T04:00:00.000Z in GMT-6 (10PM Jan 1st CST) returns 2022-01-01
9478
9548
  *
9479
- * @param values
9480
- * @param fn
9549
+ * @param date
9481
9550
  * @returns
9482
9551
  */
9483
- function allObjectsAreEqual(values, fn) {
9484
- if (isIterable(values)) {
9485
- const firstValues = takeValuesFromIterable(values, 2);
9486
- return firstValues.length > 1 ? areEqualContext(firstValues[0], fn)(values) : true;
9487
- }
9488
- return true;
9552
+ function startOfDayForSystemDateInUTC(date) {
9553
+ return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
9489
9554
  }
9490
-
9491
9555
  /**
9492
- * Creates a new Map of LabeledValue values.
9556
+ * Parses a ISO8601DayString to a Date.
9493
9557
  *
9494
- * @param values
9558
+ * @param inputDateString
9495
9559
  * @returns
9496
9560
  */
9497
- function labeledValueMap(values) {
9498
- return new Map(values.map(x => [x.value, x]));
9499
- }
9500
-
9561
+ function parseISO8601DayStringToUTCDate(inputDateString) {
9562
+ const [yearString, monthString, dateString] = inputDateString.split('-');
9563
+ return new Date(Date.UTC(Number(yearString), Number(monthString) - 1, Number(dateString)));
9564
+ }
9501
9565
  /**
9502
- * Creates a new modifier
9503
- *
9504
- * @param key
9505
- * @param modify
9566
+ * Returns true if the input date is strictly a
9567
+ * @param input
9506
9568
  * @returns
9507
9569
  */
9508
- function modifier(key, modify) {
9509
- return {
9510
- key,
9511
- modify
9512
- };
9570
+ function isISO8601DayString(input) {
9571
+ return ISO8601_DAY_STRING_REGEX.test(input);
9572
+ }
9573
+ function isISO8601DayStringStart(input) {
9574
+ return ISO8601_DAY_STRING_START_REGEX.test(input);
9513
9575
  }
9514
9576
  /**
9515
- * No operation modifier.
9577
+ * Regex for a MonthDaySlashDate.
9516
9578
  */
9517
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
9518
- const NOOP_MODIFIER = () => undefined;
9579
+ const MONTH_DAY_SLASH_DATE_STRING_REGEX = /^\d{1,2}\/\d{1,2}\/\d+$/;
9580
+ function isMonthDaySlashDate(input) {
9581
+ return MONTH_DAY_SLASH_DATE_STRING_REGEX.test(input);
9582
+ }
9519
9583
  /**
9520
- * Adds a modifier to the modifier map and returns the map.
9584
+ * Converts the input MonthDaySlashDate to an ISO8601DayString.
9521
9585
  *
9522
- * @param modifier
9523
- * @param map
9586
+ * @param slashDate
9524
9587
  * @returns
9525
9588
  */
9526
- function addModifiers(modifiers, map) {
9527
- if (!map) {
9528
- map = new Map();
9589
+ function monthDaySlashDateToDateString(slashDate) {
9590
+ let [month, day, year] = slashDate.split('/');
9591
+ if (month.length === 1) {
9592
+ month = `0${month}`;
9529
9593
  }
9530
- forEachWithArray(modifiers, modifier => map.set(modifier.key, modifier));
9531
- return map;
9532
- }
9533
- /**
9534
- * Removes a modifier from the modifier map and returns the map.
9535
- *
9536
- * @param modifier
9537
- * @param map
9538
- */
9539
- function removeModifiers(modifiers, map) {
9540
- if (map) {
9541
- forEachWithArray(modifiers, modifier => map.delete(modifier.key));
9542
- } else {
9543
- map = new Map();
9594
+ if (day.length === 1) {
9595
+ day = `0${day}`;
9544
9596
  }
9545
- return map;
9546
- }
9547
- function modifierMapToFunction(map) {
9548
- var _a;
9549
- return (_a = maybeModifierMapToFunction(map)) !== null && _a !== void 0 ? _a : NOOP_MODIFIER;
9597
+ if (year.length === 2) {
9598
+ year = `20${year}`;
9599
+ }
9600
+ const result = `${year}-${month}-${day}`;
9601
+ return result;
9550
9602
  }
9603
+ const HOURS_IN_DAY = 24;
9604
+ const SECONDS_IN_MINUTE = 60;
9605
+ const MINUTES_IN_DAY = 1440;
9606
+ const MINUTES_IN_HOUR = 60;
9607
+ const MS_IN_SECOND = 1000;
9608
+ const MS_IN_MINUTE = MS_IN_SECOND * 60;
9609
+ const MS_IN_HOUR = MS_IN_MINUTE * 60;
9610
+ const MS_IN_DAY = MS_IN_HOUR * HOURS_IN_DAY;
9551
9611
  /**
9552
- * Converts a ModifierMap to a ModifierFunction if the map is input or has functions. Otherwise returns undefined.
9612
+ * Retrieves the MonthOfYear value from the input Date.
9553
9613
  *
9554
- * @param map
9614
+ * @param date
9555
9615
  * @returns
9556
9616
  */
9557
- function maybeModifierMapToFunction(map) {
9558
- let fn;
9559
- if (map != null) {
9560
- const fns = [];
9561
- map.forEach(x => fns.push(x.modify));
9562
- fn = input => fns.forEach(fn => fn(input));
9563
- }
9564
- return fn;
9617
+ function monthOfYearFromDate(date) {
9618
+ return monthOfYearFromDateMonth(date.getMonth());
9619
+ }
9620
+ function monthOfYearFromDateMonth(dateMonth) {
9621
+ return dateMonth + 1;
9622
+ }
9623
+ function makeDateMonthForMonthOfYear(monthOfYear) {
9624
+ return monthOfYear - 1;
9565
9625
  }
9566
9626
  /**
9567
- * Merges all modifiers into a single function.
9627
+ * Returns true if the value is a date.
9568
9628
  *
9569
- * @param map
9629
+ * @param value
9570
9630
  * @returns
9571
9631
  */
9572
- function mergeModifiers(modifiers) {
9573
- var _a;
9574
- return (_a = maybeMergeModifiers(modifiers)) !== null && _a !== void 0 ? _a : NOOP_MODIFIER;
9632
+ function isDate(value) {
9633
+ return value instanceof Date || typeof value === 'object' && Object.prototype.toString.call(value) === '[object Date]';
9575
9634
  }
9635
+
9636
+ const FRACTIONAL_HOURS_PRECISION_FUNCTION = cutValueToPrecisionFunction(3);
9576
9637
  /**
9577
- * Merges all modifiers into a single function. If not modifier functions are input, returns
9638
+ * Converts the number of minnutes to a fractional hour.
9578
9639
  *
9579
- * @param map
9580
- * @returns
9640
+ * Minutes are rounded down.
9581
9641
  */
9582
- function maybeMergeModifiers(modifiers) {
9583
- let result = undefined;
9584
- if (modifiers != null) {
9585
- switch (modifiers.length) {
9586
- case 1:
9587
- result = modifiers[0];
9588
- break;
9589
- default:
9590
- result = input => modifiers.forEach(fn => fn(input));
9591
- break;
9592
- }
9593
- }
9594
- return result;
9642
+ function minutesToFractionalHours(minutes) {
9643
+ return FRACTIONAL_HOURS_PRECISION_FUNCTION(Math.floor(minutes) / MINUTES_IN_HOUR);
9595
9644
  }
9596
-
9597
9645
  /**
9598
- * Synchronization state enum that defines whether or not an object is synchronized.
9646
+ * Converts the fractional hour to a minute.
9599
9647
  */
9600
- exports.SyncState = void 0;
9601
- (function (SyncState) {
9602
- /**
9603
- * The object is out of sync.
9604
- */
9605
- SyncState[SyncState["OUT_OF_SYNC"] = 0] = "OUT_OF_SYNC";
9606
- /**
9607
- * The object is synced.
9608
- */
9609
- SyncState[SyncState["SYNCED"] = 1] = "SYNCED";
9610
- })(exports.SyncState || (exports.SyncState = {}));
9611
-
9648
+ function fractionalHoursToMinutes(hours) {
9649
+ return Math.round(hours * MINUTES_IN_HOUR);
9650
+ }
9612
9651
  /**
9613
- * Removes any query parameters and hashbang parameters from the input url.
9652
+ * Rounds the input hour to the nearest FractionalHour.
9614
9653
  *
9615
- * @param url
9654
+ * @param hour
9616
9655
  * @returns
9617
9656
  */
9618
- function urlWithoutParameters(url) {
9619
- const queryOpenPosition = url.indexOf('?');
9620
- if (queryOpenPosition !== -1) {
9621
- url = url.substring(0, queryOpenPosition);
9622
- }
9623
- const hashOpenPosition = url.indexOf('#');
9624
- if (hashOpenPosition !== -1) {
9625
- url = url.substring(0, hashOpenPosition);
9626
- }
9627
- return url;
9657
+ function hourToFractionalHour(hour) {
9658
+ return minutesToFractionalHours(fractionalHoursToMinutes(hour));
9628
9659
  }
9629
-
9630
- /******************************************************************************
9631
- Copyright (c) Microsoft Corporation.
9632
-
9633
- Permission to use, copy, modify, and/or distribute this software for any
9634
- purpose with or without fee is hereby granted.
9635
-
9636
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9637
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9638
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
9639
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
9640
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
9641
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
9642
- PERFORMANCE OF THIS SOFTWARE.
9643
- ***************************************************************************** */
9644
-
9645
- function __awaiter(thisArg, _arguments, P, generator) {
9646
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
9647
- return new (P || (P = Promise))(function (resolve, reject) {
9648
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9649
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
9650
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9651
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9652
- });
9653
- }
9654
-
9655
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
9656
- var e = new Error(message);
9657
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
9658
- };
9659
-
9660
- function useValue(input, use, defaultValue) {
9661
- let result;
9662
- if (input != null) {
9663
- result = use(input);
9664
- } else {
9665
- result = getValueFromGetter(defaultValue);
9660
+ function computeNextFractionalHour(input, change) {
9661
+ let result = input;
9662
+ if (change.minutes) {
9663
+ result += minutesToFractionalHours(change.minutes);
9664
+ }
9665
+ if (change.hours) {
9666
+ result += hourToFractionalHour(change.hours);
9666
9667
  }
9667
9668
  return result;
9668
9669
  }
9669
9670
  /**
9670
- * Creates a MappedUseFunction.
9671
+ * Converts the input number of minutes to the equivalent in hours and minutes.
9672
+ *
9673
+ * @param inputMinutes
9674
+ * @returns
9671
9675
  */
9672
- function mappedUseFunction(map) {
9673
- return wrapUseFunction(useValue, map);
9676
+ function minutesToHoursAndMinutes(inputMinutes) {
9677
+ const hour = Math.floor(inputMinutes / 60);
9678
+ const minute = inputMinutes % 60;
9679
+ return {
9680
+ hour,
9681
+ minute
9682
+ };
9674
9683
  }
9675
9684
  /**
9676
- * Wraps another MappedUseFunction and maps the input values.
9685
+ * Reads the hour and minutes of the Date.
9686
+ *
9687
+ * @param date
9688
+ * @returns
9677
9689
  */
9678
- function wrapUseFunction(mappedUseFn, map) {
9679
- return (input, useFn, defaultValue) => {
9680
- return mappedUseFn(input, value => useValue(map(value), useFn, defaultValue), defaultValue);
9690
+ function dateToHoursAndMinutes(date) {
9691
+ const hour = date.getHours();
9692
+ const minute = date.getMinutes();
9693
+ return {
9694
+ hour,
9695
+ minute
9681
9696
  };
9682
9697
  }
9683
9698
  /**
9684
- * Creates a UseContextFunction.
9699
+ * Converts the input hours and minutes to a MinuteOfDay.
9700
+ *
9701
+ * @param hour
9702
+ * @param minute
9703
+ * @returns
9685
9704
  */
9686
- function useContextFunction(use, defaultValue) {
9687
- return input => {
9688
- let result;
9689
- if (input != null) {
9690
- result = use(input);
9691
- } else {
9692
- result = getValueFromGetter(defaultValue);
9693
- }
9694
- return result;
9695
- };
9696
- }
9697
- function useAsync(input, use, defaultValue) {
9698
- return __awaiter(this, void 0, void 0, function* () {
9699
- let result;
9700
- if (input != null) {
9701
- result = yield use(input);
9702
- } else {
9703
- result = yield getValueFromGetter(defaultValue);
9704
- }
9705
- return result;
9706
- });
9705
+ function toMinuteOfDay(hour, minute) {
9706
+ return asMinuteOfDay(hour * 60 + minute);
9707
9707
  }
9708
9708
  /**
9709
- * Creates a MappedUseFunction.
9709
+ * Creates a new date from the minute of the day.
9710
+ *
9711
+ * @param minuteOfDay
9712
+ * @param day
9713
+ * @returns
9710
9714
  */
9711
- function mappedUseAsyncFunction(map) {
9712
- return wrapUseAsyncFunction(useAsync, map);
9715
+ function dateFromMinuteOfDay(minuteOfDay, day) {
9716
+ const date = day || new Date();
9717
+ const {
9718
+ hour,
9719
+ minute
9720
+ } = minutesToHoursAndMinutes(asMinuteOfDay(minuteOfDay));
9721
+ date.setHours(hour, minute, 0, 0);
9722
+ return date;
9713
9723
  }
9714
9724
  /**
9715
- * Wraps another MappedUseFunction or MappedUseAsyncFunction and maps the input values.
9725
+ * Converts a Date to a MinuteOfDay.
9726
+ *
9727
+ * @param date
9728
+ * @returns
9716
9729
  */
9717
- function wrapUseAsyncFunction(mappedUsePromiseFn, map) {
9718
- return (input, useFn, defaultValue) => {
9719
- return mappedUsePromiseFn(input, value => __awaiter(this, void 0, void 0, function* () {
9720
- return useValue(yield map(value), useFn, defaultValue);
9721
- }), defaultValue);
9722
- };
9730
+ function dateToMinuteOfDay(date) {
9731
+ const {
9732
+ hour,
9733
+ minute
9734
+ } = dateToHoursAndMinutes(date);
9735
+ return toMinuteOfDay(hour, minute);
9723
9736
  }
9724
-
9725
- const SLASH_PATH_SEPARATOR = '/';
9726
- const SLASH_PATH_FILE_TYPE_SEPARATOR = '.';
9727
- const DEFAULT_SLASH_PATH_ILLEGAL_CHARACTERS = ['#', '[', ']', '*', '?'];
9728
9737
  /**
9729
- * Default replacement character for illegal characters.
9738
+ * Converts the input minutes to a MinuteOfDay.
9739
+ *
9740
+ * @param minutes
9741
+ * @returns
9730
9742
  */
9731
- const DEFAULT_SLASH_PATH_ILLEGAL_CHARACTER_REPLACEMENT = '_';
9743
+ function asMinuteOfDay(minutes) {
9744
+ return Math.max(0, minutes % MINUTES_IN_DAY);
9745
+ }
9746
+
9732
9747
  /**
9733
- * Returns the SlashPathType for the input.
9748
+ * Creates a CronExpression for the input number of minutes.
9734
9749
  *
9735
- * @param input
9750
+ * Note that if the number of minutes is greater than 60, it will generate an expression that
9751
+ * isn't exactly n number of minutes apart from the previous execution, but instead create
9752
+ * an expression that is n/60 hours apart and take place on the n%60th minute.
9753
+ *
9754
+ * @param inputMinutes
9736
9755
  * @returns
9737
9756
  */
9738
- function slashPathType(input) {
9739
- const dotCount = input.split(SLASH_PATH_FILE_TYPE_SEPARATOR, 3).length - 1;
9740
- let type;
9741
- switch (dotCount) {
9742
- case 0:
9743
- if (input.length === 0) {
9744
- type = 'invalid';
9745
- } else {
9746
- const lastValue = input[input.length - 1];
9747
- if (lastValue === SLASH_PATH_SEPARATOR) {
9748
- type = 'folder';
9749
- } else {
9750
- type = 'file';
9751
- }
9752
- }
9753
- break;
9754
- case 1:
9755
- type = 'typedfile';
9756
- break;
9757
- default:
9758
- type = 'invalid';
9759
- break;
9757
+ function cronExpressionRepeatingEveryNMinutes(inputMinutes) {
9758
+ let expression;
9759
+ if (inputMinutes >= 60) {
9760
+ const {
9761
+ hour,
9762
+ minute
9763
+ } = minutesToHoursAndMinutes(inputMinutes);
9764
+ expression = `${minute} */${hour} * * *`; // every nth hour at the given minute
9765
+ } else {
9766
+ expression = `*/${inputMinutes} * * * *`; // every nth minute
9760
9767
  }
9761
- return type;
9762
- }
9763
- function isSlashPathFile(input) {
9764
- const type = slashPathType(input);
9765
- return type === 'file' || type === 'typedfile';
9768
+
9769
+ return expression;
9766
9770
  }
9767
- function isSlashPathTypedFile(input) {
9768
- const type = slashPathType(input);
9769
- return type === 'typedfile';
9771
+
9772
+ function decisionFunction(decision) {
9773
+ return () => decision;
9770
9774
  }
9771
- function isSlashPathFolder(input) {
9772
- return slashPathType(input) === 'folder';
9775
+ /**
9776
+ * Used to invert a decision function by returning the opposite of what it returns.
9777
+ *
9778
+ * @param filterFn
9779
+ * @param invert whether or not to apply the inversion.
9780
+ * @returns
9781
+ */
9782
+ const invertDecision = invertBooleanReturnFunction;
9783
+ /**
9784
+ * Creates a DecisionFunction from the input.
9785
+ *
9786
+ * @param valueOrFunction
9787
+ * @param defaultIfUndefined
9788
+ * @returns
9789
+ */
9790
+ function asDecisionFunction(valueOrFunction, defaultIfUndefined = true) {
9791
+ const input = valueOrFunction !== null && valueOrFunction !== void 0 ? valueOrFunction : defaultIfUndefined;
9792
+ if (typeof input === 'boolean') {
9793
+ return () => input;
9794
+ } else {
9795
+ return input;
9796
+ }
9773
9797
  }
9774
- function isValidSlashPath(input) {
9775
- return slashPathType(input) !== 'invalid';
9798
+ function isEqualToValueDecisionFunction(equalityValue) {
9799
+ let equalityValueCheckFunction;
9800
+ if (typeof equalityValue === 'function') {
9801
+ equalityValueCheckFunction = equalityValue;
9802
+ } else {
9803
+ equalityValueCheckFunction = x => equalityValue === x;
9804
+ }
9805
+ return equalityValueCheckFunction;
9776
9806
  }
9807
+
9777
9808
  /**
9778
- * Returns the last part of the slash path.
9809
+ * Creates an IsEqualContext
9779
9810
  *
9780
- * @param slashPath
9811
+ * @param contextValue
9812
+ * @param fn
9813
+ * @returns
9781
9814
  */
9782
- function slashPathName(slashPath) {
9783
- const parts = slashPathParts(slashPath);
9784
- return parts[parts.length - 1];
9815
+ function isEqualContext(contextValue, fn) {
9816
+ return value => {
9817
+ return fn(contextValue, value);
9818
+ };
9785
9819
  }
9786
9820
  /**
9787
- * Returns each section of a SlashPath
9821
+ * Creates an AreEqualContext
9788
9822
  *
9789
- * @param slashPath
9823
+ * @param contextValue
9824
+ * @param fn
9790
9825
  * @returns
9791
9826
  */
9792
- function slashPathParts(slashPath) {
9793
- return slashPath.split(SLASH_PATH_SEPARATOR).filter(x => Boolean(x));
9827
+ function areEqualContext(contextValue, fn) {
9828
+ const isEqual = isEqualContext(contextValue, fn);
9829
+ return input => {
9830
+ let areEqual = false;
9831
+ if (isIterable(input)) {
9832
+ areEqual = !existsInIterable(input, x => !isEqual(x));
9833
+ } else {
9834
+ areEqual = isEqual(input);
9835
+ }
9836
+ return areEqual;
9837
+ };
9794
9838
  }
9795
- function slashPathStartTypeFactory(type) {
9796
- let fn;
9797
- switch (type) {
9798
- case 'relative':
9799
- fn = toRelativeSlashPathStartType;
9800
- break;
9801
- case 'absolute':
9802
- fn = toAbsoluteSlashPathStartType;
9803
- break;
9804
- case 'any':
9805
- fn = mapIdentityFunction();
9806
- break;
9839
+ /**
9840
+ * Returns true if all input values are equal.
9841
+ *
9842
+ * Arrays that are empty or have one value will return true by default.
9843
+ *
9844
+ * @param values
9845
+ * @param fn
9846
+ * @returns
9847
+ */
9848
+ function allObjectsAreEqual(values, fn) {
9849
+ if (isIterable(values)) {
9850
+ const firstValues = takeValuesFromIterable(values, 2);
9851
+ return firstValues.length > 1 ? areEqualContext(firstValues[0], fn)(values) : true;
9807
9852
  }
9808
- return fn;
9809
- }
9810
- const LEADING_SLASHES_REGEX = /^\/+/;
9811
- const TRAILING_SLASHES_REGEX = /\/+$/;
9812
- const TRAILING_FILE_TYPE_SEPARATORS_REGEX = /\.+$/;
9813
- const ALL_SLASHES_REGEX = /\/+/g;
9814
- const ALL_DOUBLE_SLASHES_REGEX = /\/{2,}/g;
9815
- const ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
9816
- function toRelativeSlashPathStartType(input) {
9817
- // remove all leading slashes
9818
- return input.replace(LEADING_SLASHES_REGEX, '');
9853
+ return true;
9819
9854
  }
9855
+
9820
9856
  /**
9857
+ * Creates a new Map of LabeledValue values.
9821
9858
  *
9822
- * @param input
9859
+ * @param values
9823
9860
  * @returns
9824
9861
  */
9825
- function toAbsoluteSlashPathStartType(input) {
9826
- // add a leading slash, and remove any multiple slashes if provided
9827
- return input.startsWith(SLASH_PATH_SEPARATOR) ? input.replace(LEADING_SLASHES_REGEX, SLASH_PATH_SEPARATOR) : `${SLASH_PATH_SEPARATOR}${input}`;
9862
+ function labeledValueMap(values) {
9863
+ return new Map(values.map(x => [x.value, x]));
9828
9864
  }
9829
- function fixMultiSlashesInSlashPath(input) {
9830
- return input.replace(ALL_DOUBLE_SLASHES_REGEX, SLASH_PATH_SEPARATOR);
9865
+
9866
+ /**
9867
+ * Creates a new modifier
9868
+ *
9869
+ * @param key
9870
+ * @param modify
9871
+ * @returns
9872
+ */
9873
+ function modifier(key, modify) {
9874
+ return {
9875
+ key,
9876
+ modify
9877
+ };
9831
9878
  }
9832
- function replaceMultipleFilePathsInSlashPath(input) {
9833
- return input.replace(ALL_DOUBLE_SLASHES_REGEX, SLASH_PATH_SEPARATOR);
9879
+ /**
9880
+ * No operation modifier.
9881
+ */
9882
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9883
+ const NOOP_MODIFIER = () => undefined;
9884
+ /**
9885
+ * Adds a modifier to the modifier map and returns the map.
9886
+ *
9887
+ * @param modifier
9888
+ * @param map
9889
+ * @returns
9890
+ */
9891
+ function addModifiers(modifiers, map) {
9892
+ if (!map) {
9893
+ map = new Map();
9894
+ }
9895
+ forEachWithArray(modifiers, modifier => map.set(modifier.key, modifier));
9896
+ return map;
9834
9897
  }
9835
- function removeTrailingSlashes(input) {
9836
- return input.replace(TRAILING_SLASHES_REGEX, '');
9898
+ /**
9899
+ * Removes a modifier from the modifier map and returns the map.
9900
+ *
9901
+ * @param modifier
9902
+ * @param map
9903
+ */
9904
+ function removeModifiers(modifiers, map) {
9905
+ if (map) {
9906
+ forEachWithArray(modifiers, modifier => map.delete(modifier.key));
9907
+ } else {
9908
+ map = new Map();
9909
+ }
9910
+ return map;
9837
9911
  }
9838
- function removeTrailingFileTypeSeparators(input) {
9839
- return input.replace(TRAILING_FILE_TYPE_SEPARATORS_REGEX, '');
9912
+ function modifierMapToFunction(map) {
9913
+ var _a;
9914
+ return (_a = maybeModifierMapToFunction(map)) !== null && _a !== void 0 ? _a : NOOP_MODIFIER;
9840
9915
  }
9841
9916
  /**
9842
- * Replaces all extra and invalidate FilePathTypeSeparator values from the SlashPath, returning a valid SlashPath.
9917
+ * Converts a ModifierMap to a ModifierFunction if the map is input or has functions. Otherwise returns undefined.
9843
9918
  *
9844
- * @param input
9845
- * @param replaceWith
9919
+ * @param map
9846
9920
  * @returns
9847
9921
  */
9848
- function replaceInvalidFilePathTypeSeparatorsInSlashPath(input, replaceWith) {
9849
- return replaceInvalidFilePathTypeSeparatorsInSlashPathFunction(replaceWith)(input);
9922
+ function maybeModifierMapToFunction(map) {
9923
+ let fn;
9924
+ if (map != null) {
9925
+ const fns = [];
9926
+ map.forEach(x => fns.push(x.modify));
9927
+ fn = input => fns.forEach(fn => fn(input));
9928
+ }
9929
+ return fn;
9850
9930
  }
9851
9931
  /**
9852
- * Creates a function that replaces all extra and invalidate FilePathTypeSeparator values from the SlashPath, returning a valid SlashPath.
9932
+ * Merges all modifiers into a single function.
9853
9933
  *
9854
- * @param input
9855
- * @param replaceWith
9934
+ * @param map
9856
9935
  * @returns
9857
9936
  */
9858
- function replaceInvalidFilePathTypeSeparatorsInSlashPathFunction(replaceWith = DEFAULT_SLASH_PATH_ILLEGAL_CHARACTER_REPLACEMENT) {
9859
- return input => {
9860
- const endsOnFileTypeSeparator = input[input.length - 1] === SLASH_PATH_FILE_TYPE_SEPARATOR;
9861
- const inputToEvaluate = endsOnFileTypeSeparator ? removeTrailingFileTypeSeparators(input) : input;
9862
- const {
9863
- first,
9864
- last,
9865
- occurences
9866
- } = firstAndLastCharacterOccurrence(inputToEvaluate, SLASH_PATH_FILE_TYPE_SEPARATOR);
9867
- let fixedPath;
9868
- switch (occurences) {
9869
- case 0:
9870
- fixedPath = inputToEvaluate;
9871
- break;
9937
+ function mergeModifiers(modifiers) {
9938
+ var _a;
9939
+ return (_a = maybeMergeModifiers(modifiers)) !== null && _a !== void 0 ? _a : NOOP_MODIFIER;
9940
+ }
9941
+ /**
9942
+ * Merges all modifiers into a single function. If not modifier functions are input, returns
9943
+ *
9944
+ * @param map
9945
+ * @returns
9946
+ */
9947
+ function maybeMergeModifiers(modifiers) {
9948
+ let result = undefined;
9949
+ if (modifiers != null) {
9950
+ switch (modifiers.length) {
9872
9951
  case 1:
9873
- const lastSlashPosition = inputToEvaluate.lastIndexOf('/');
9874
- if (lastSlashPosition === -1 || lastSlashPosition < last) {
9875
- // valid path
9876
- fixedPath = inputToEvaluate;
9877
- } else {
9878
- // the dot occurs before another slash, so we should replace it
9879
- fixedPath = replaceCharacterAtIndexWith(inputToEvaluate, last, replaceWith);
9880
- }
9952
+ result = modifiers[0];
9881
9953
  break;
9882
9954
  default:
9883
- const [head, tail] = splitStringAtIndex(inputToEvaluate, last, true);
9884
- const headWithReplacedSeparators = head.replace(ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX, replaceWith);
9885
- fixedPath = headWithReplacedSeparators + tail;
9955
+ result = input => modifiers.forEach(fn => fn(input));
9886
9956
  break;
9887
9957
  }
9888
- return fixedPath;
9889
- };
9890
- }
9891
- function slashPathValidationFactory(config) {
9892
- const {
9893
- illegalStrings = DEFAULT_SLASH_PATH_ILLEGAL_CHARACTERS,
9894
- replaceIllegalCharacters: inputReplaceIllegalCharacters = true,
9895
- replaceIllegalDots: inputReplaceIllegalDots = true,
9896
- throwError
9897
- } = config !== null && config !== void 0 ? config : {};
9898
- const fns = [];
9899
- const replaceIllegalCharacters = typeof inputReplaceIllegalCharacters === 'string' ? inputReplaceIllegalCharacters : DEFAULT_SLASH_PATH_ILLEGAL_CHARACTER_REPLACEMENT;
9900
- if (inputReplaceIllegalCharacters != null) {
9901
- fns.push(replaceStringsFunction({
9902
- replace: illegalStrings,
9903
- replaceWith: replaceIllegalCharacters
9904
- }));
9905
9958
  }
9906
- if (inputReplaceIllegalDots != null) {
9907
- const replaceIllegalDotsWith = typeof inputReplaceIllegalDots === 'string' ? inputReplaceIllegalDots : replaceIllegalCharacters;
9908
- fns.push(replaceInvalidFilePathTypeSeparatorsInSlashPathFunction(replaceIllegalDotsWith));
9959
+ return result;
9960
+ }
9961
+
9962
+ /**
9963
+ * Synchronization state enum that defines whether or not an object is synchronized.
9964
+ */
9965
+ exports.SyncState = void 0;
9966
+ (function (SyncState) {
9967
+ /**
9968
+ * The object is out of sync.
9969
+ */
9970
+ SyncState[SyncState["OUT_OF_SYNC"] = 0] = "OUT_OF_SYNC";
9971
+ /**
9972
+ * The object is synced.
9973
+ */
9974
+ SyncState[SyncState["SYNCED"] = 1] = "SYNCED";
9975
+ })(exports.SyncState || (exports.SyncState = {}));
9976
+
9977
+ /**
9978
+ * Removes any query parameters and hashbang parameters from the input url.
9979
+ *
9980
+ * @param url
9981
+ * @returns
9982
+ */
9983
+ function urlWithoutParameters(url) {
9984
+ const queryOpenPosition = url.indexOf('?');
9985
+ if (queryOpenPosition !== -1) {
9986
+ url = url.substring(0, queryOpenPosition);
9909
9987
  }
9910
- if (throwError === true || !(inputReplaceIllegalCharacters || inputReplaceIllegalDots)) {
9911
- fns.push(x => {
9912
- if (!isValidSlashPath(x)) {
9913
- throw slashPathInvalidError();
9914
- }
9915
- return x;
9916
- });
9988
+ const hashOpenPosition = url.indexOf('#');
9989
+ if (hashOpenPosition !== -1) {
9990
+ url = url.substring(0, hashOpenPosition);
9917
9991
  }
9918
- return chainMapSameFunctions(fns);
9919
- }
9920
- function slashPathFactory(config) {
9921
- const {
9922
- startType: type = 'any',
9923
- basePath: inputBasePaths,
9924
- validate = true
9925
- } = config !== null && config !== void 0 ? config : {};
9926
- const basePath = inputBasePaths ? mergeSlashPaths(asArray(inputBasePaths)) : undefined;
9927
- const typeFactory = slashPathStartTypeFactory(type);
9928
- const validationFactory = validate ? typeof validate === 'boolean' ? slashPathValidationFactory() : slashPathValidationFactory(validate) : null;
9929
- const finalizeFn = chainMapFunction(typeFactory, validationFactory);
9930
- return paths => {
9931
- const merged = mergeSlashPaths(pushItemOrArrayItemsIntoArray([basePath], paths));
9932
- return finalizeFn(merged);
9933
- };
9992
+ return url;
9934
9993
  }
9935
- function mergeSlashPaths(paths) {
9936
- const merge = paths.filter(Boolean).join(SLASH_PATH_SEPARATOR);
9937
- return fixMultiSlashesInSlashPath(merge);
9994
+
9995
+ /******************************************************************************
9996
+ Copyright (c) Microsoft Corporation.
9997
+
9998
+ Permission to use, copy, modify, and/or distribute this software for any
9999
+ purpose with or without fee is hereby granted.
10000
+
10001
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10002
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10003
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10004
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
10005
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
10006
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
10007
+ PERFORMANCE OF THIS SOFTWARE.
10008
+ ***************************************************************************** */
10009
+
10010
+ function __awaiter(thisArg, _arguments, P, generator) {
10011
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10012
+ return new (P || (P = Promise))(function (resolve, reject) {
10013
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10014
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10015
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
10016
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10017
+ });
10018
+ }
10019
+
10020
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
10021
+ var e = new Error(message);
10022
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
10023
+ };
10024
+
10025
+ function useValue(input, use, defaultValue) {
10026
+ let result;
10027
+ if (input != null) {
10028
+ result = use(input);
10029
+ } else {
10030
+ result = getValueFromGetter(defaultValue);
10031
+ }
10032
+ return result;
9938
10033
  }
9939
- function slashPathInvalidError() {
9940
- return new Error('The slashPath is invalid.');
10034
+ /**
10035
+ * Creates a MappedUseFunction.
10036
+ */
10037
+ function mappedUseFunction(map) {
10038
+ return wrapUseFunction(useValue, map);
9941
10039
  }
9942
10040
  /**
9943
- * Splits the path and returns the items at the given ranges.
9944
- *
9945
- * @param path
10041
+ * Wraps another MappedUseFunction and maps the input values.
9946
10042
  */
9947
- function isolateSlashPath(path, range) {
9948
- return isolateSlashPathFunction({
9949
- range
9950
- })(path);
10043
+ function wrapUseFunction(mappedUseFn, map) {
10044
+ return (input, useFn, defaultValue) => {
10045
+ return mappedUseFn(input, value => useValue(map(value), useFn, defaultValue), defaultValue);
10046
+ };
9951
10047
  }
9952
10048
  /**
9953
- * Creates an IsolateSlashPathFunction.
9954
- *
9955
- * @param config
9956
- * @returns
10049
+ * Creates a UseContextFunction.
9957
10050
  */
9958
- function isolateSlashPathFunction(config) {
9959
- const {
9960
- startType,
9961
- asFile
9962
- } = config;
9963
- const range = indexRange(config.range);
9964
- const sliceRange = sliceIndexRangeFunction(range);
9965
- return path => {
9966
- const split = toRelativeSlashPathStartType(path).split(SLASH_PATH_SEPARATOR);
9967
- const splitRange = sliceRange(split);
9968
- let joined = splitRange.join(SLASH_PATH_SEPARATOR);
9969
- const isFolder = asFile !== true && split.length > range.maxIndex;
9970
- if (isFolder) {
9971
- joined = joined + SLASH_PATH_SEPARATOR; // end with a slash.
9972
- }
9973
-
9974
- if (startType === 'absolute' || path.startsWith(SLASH_PATH_SEPARATOR)) {
9975
- return toAbsoluteSlashPathStartType(joined);
10051
+ function useContextFunction(use, defaultValue) {
10052
+ return input => {
10053
+ let result;
10054
+ if (input != null) {
10055
+ result = use(input);
9976
10056
  } else {
9977
- return joined;
10057
+ result = getValueFromGetter(defaultValue);
9978
10058
  }
10059
+ return result;
9979
10060
  };
9980
10061
  }
9981
-
10062
+ function useAsync(input, use, defaultValue) {
10063
+ return __awaiter(this, void 0, void 0, function* () {
10064
+ let result;
10065
+ if (input != null) {
10066
+ result = yield use(input);
10067
+ } else {
10068
+ result = yield getValueFromGetter(defaultValue);
10069
+ }
10070
+ return result;
10071
+ });
10072
+ }
9982
10073
  /**
9983
- * Simple website domain regex that looks for a period in the string between the domain and the tld
10074
+ * Creates a MappedUseFunction.
9984
10075
  */
9985
- const HAS_WEBSITE_DOMAIN_NAME_REGEX = /(.+)\.(.+)/;
10076
+ function mappedUseAsyncFunction(map) {
10077
+ return wrapUseAsyncFunction(useAsync, map);
10078
+ }
9986
10079
  /**
9987
- * Returns true if the input probably has a website domain in it.
9988
- *
9989
- * Examples where it will return true:
9990
- * - dereekb.com
9991
- * - https://components.dereekb.com
9992
- * - https://components.dereekb.com/
9993
- * - https://components.dereekb.com/doc/home
9994
- *
9995
- * @param input
9996
- * @returns
10080
+ * Wraps another MappedUseFunction or MappedUseAsyncFunction and maps the input values.
9997
10081
  */
9998
- function hasWebsiteDomain(input) {
9999
- return HAS_WEBSITE_DOMAIN_NAME_REGEX.test(input);
10082
+ function wrapUseAsyncFunction(mappedUsePromiseFn, map) {
10083
+ return (input, useFn, defaultValue) => {
10084
+ return mappedUsePromiseFn(input, value => __awaiter(this, void 0, void 0, function* () {
10085
+ return useValue(yield map(value), useFn, defaultValue);
10086
+ }), defaultValue);
10087
+ };
10000
10088
  }
10089
+
10090
+ const SLASH_PATH_SEPARATOR = '/';
10091
+ const SLASH_PATH_FILE_TYPE_SEPARATOR = '.';
10092
+ const DEFAULT_SLASH_PATH_ILLEGAL_CHARACTERS = ['#', '[', ']', '*', '?'];
10001
10093
  /**
10002
- * Creates a base website url from the input domain or url.
10094
+ * Default replacement character for illegal characters.
10095
+ */
10096
+ const DEFAULT_SLASH_PATH_ILLEGAL_CHARACTER_REPLACEMENT = '_';
10097
+ /**
10098
+ * Returns the SlashPathType for the input.
10003
10099
  *
10004
10100
  * @param input
10005
10101
  * @returns
10006
10102
  */
10007
- function baseWebsiteUrl(input, defaultTld = 'com') {
10008
- let base;
10009
- if (hasHttpPrefix(input)) {
10010
- base = input;
10011
- } else {
10012
- base = addHttpToUrl(input);
10013
- }
10014
- if (!hasWebsiteDomain(base)) {
10015
- base = `${base}.${defaultTld || 'com'}`;
10103
+ function slashPathType(input) {
10104
+ const dotCount = input.split(SLASH_PATH_FILE_TYPE_SEPARATOR, 3).length - 1;
10105
+ let type;
10106
+ switch (dotCount) {
10107
+ case 0:
10108
+ if (input.length === 0) {
10109
+ type = 'invalid';
10110
+ } else {
10111
+ const lastValue = input[input.length - 1];
10112
+ if (lastValue === SLASH_PATH_SEPARATOR) {
10113
+ type = 'folder';
10114
+ } else {
10115
+ type = 'file';
10116
+ }
10117
+ }
10118
+ break;
10119
+ case 1:
10120
+ type = 'typedfile';
10121
+ break;
10122
+ default:
10123
+ type = 'invalid';
10124
+ break;
10016
10125
  }
10017
- return base;
10018
- }
10019
- /**
10020
- * Returns true if the input string is probably a website url.
10021
- *
10022
- * Checks that it has the http/https prefix, has a domain, and the path is a slash path. The query parameters are ignored.
10023
- */
10024
- function isWebsiteUrl(input) {
10025
- const noHttp = removeHttpFromUrl(input);
10026
- const splitPair = websiteDomainAndPathPairFromWebsiteUrl(noHttp);
10027
- const [path, query] = splitStringAtFirstCharacterOccurence(splitPair.path, '?'); // everything after the query is ignored
10028
- const isWebsiteUrl = hasWebsiteDomain(splitPair.domain) && isSlashPathFolder(path + '/');
10029
- return isWebsiteUrl;
10126
+ return type;
10030
10127
  }
10031
- /**
10032
- * Returns true if the input string is probably a website url.
10033
- *
10034
- * Checks that it has the http/https prefix, has a domain, and the path is a slash path. The query parameters are ignored.
10035
- */
10036
- function isWebsiteUrlWithPrefix(input) {
10037
- let isWebsiteUrlWithPrefix = false;
10038
- const hasPrefix = hasHttpPrefix(input);
10039
- if (hasPrefix) {
10040
- isWebsiteUrlWithPrefix = isWebsiteUrl(input);
10041
- }
10042
- return isWebsiteUrlWithPrefix;
10128
+ function isSlashPathFile(input) {
10129
+ const type = slashPathType(input);
10130
+ return type === 'file' || type === 'typedfile';
10043
10131
  }
10044
- /**
10045
- * Creates a WebsiteUrl from the input
10046
- * @param basePath
10047
- * @param paths
10048
- * @returns
10049
- */
10050
- function websiteUrlFromPaths(basePath, paths) {
10051
- const basePathWithoutHttp = removeHttpFromUrl(baseWebsiteUrl(basePath));
10052
- return addHttpToUrl(mergeSlashPaths([basePathWithoutHttp, ...asArray(paths)]));
10132
+ function isSlashPathTypedFile(input) {
10133
+ const type = slashPathType(input);
10134
+ return type === 'typedfile';
10053
10135
  }
10054
- /**
10055
- * Creates a new ExcludeBaseWebsitePathFunction that excludes the base path from the input website path if it exists.
10056
- *
10057
- * @param basePath
10058
- */
10059
- function isolateWebsitePathFunction(config = {}) {
10060
- const {
10061
- removeQueryParameters,
10062
- ignoredBasePath,
10063
- isolatePathComponents,
10064
- removeTrailingSlash
10065
- } = config;
10066
- const basePathRegex = ignoredBasePath ? new RegExp('^' + escapeStringForRegex(toAbsoluteSlashPathStartType(ignoredBasePath))) : undefined;
10067
- const isolateRange = isolatePathComponents != null ? isolateSlashPathFunction({
10068
- range: isolatePathComponents,
10069
- startType: 'absolute'
10070
- }) : undefined;
10071
- const replaceTrailingSlash = removeTrailingSlash === true ? replaceLastCharacterIfIsFunction('', SLASH_PATH_SEPARATOR) : undefined;
10072
- const pathTransform = chainMapSameFunctions([
10073
- // remove any base path
10074
- basePathRegex != null ? inputPath => inputPath.replace(basePathRegex, '') : undefined,
10075
- // remove the query parameters
10076
- removeQueryParameters != null ? inputPath => websitePathAndQueryPair(inputPath).path : undefined,
10077
- // isolate range
10078
- isolateRange != null ? inputPath => {
10079
- let result = isolateRange(inputPath);
10080
- // retain the query if one is available.
10081
- if (removeQueryParameters !== true) {
10082
- const {
10083
- query
10084
- } = websitePathAndQueryPair(inputPath);
10085
- if (query) {
10086
- result = result + query;
10087
- }
10088
- }
10089
- return result;
10090
- } : undefined,
10091
- // remove trailing slash from path
10092
- replaceTrailingSlash != null ? inputPath => {
10093
- const {
10094
- path,
10095
- query
10096
- } = websitePathAndQueryPair(inputPath);
10097
- return replaceTrailingSlash(path) + (query !== null && query !== void 0 ? query : '');
10098
- } : undefined]);
10099
- return input => {
10100
- const path = pathTransform(websitePathFromWebsiteUrl(input));
10101
- return path;
10102
- };
10136
+ function isSlashPathFolder(input) {
10137
+ return slashPathType(input) === 'folder';
10103
10138
  }
10104
- function websitePathAndQueryPair(inputPath) {
10105
- const [path, rawQuery] = inputPath.split('?', 2);
10106
- const query = rawQuery ? fixExtraQueryParameters(rawQuery, true) : undefined;
10107
- return {
10108
- path: path,
10109
- query: query ? `?${query}` : undefined
10110
- };
10139
+ function isValidSlashPath(input) {
10140
+ return slashPathType(input) !== 'invalid';
10111
10141
  }
10112
10142
  /**
10113
- * Replaces any extra query parameter "?" characters with an "&" character.
10114
- *
10115
- * Can also choose to replace all instead, incase the input string should be considered the query without.
10143
+ * Returns the last part of the slash path.
10116
10144
  *
10117
- * @param input
10145
+ * @param slashPath
10118
10146
  */
10119
- function fixExtraQueryParameters(input, replaceAll = false) {
10120
- const questionMarkIndexes = findAllCharacterOccurences(new Set('?'), input);
10121
- let indexesToReplace;
10122
- let fixed = input;
10123
- if (replaceAll && questionMarkIndexes.length) {
10124
- indexesToReplace = questionMarkIndexes;
10125
- } else if (questionMarkIndexes.length > 1) {
10126
- indexesToReplace = questionMarkIndexes.reverse();
10127
- indexesToReplace.pop(); // remove the "first" so it does not get replaced.
10128
- }
10129
-
10130
- if (indexesToReplace === null || indexesToReplace === void 0 ? void 0 : indexesToReplace.length) {
10131
- indexesToReplace.forEach(index => fixed = replaceCharacterAtIndexWith(fixed, index, '&'));
10132
- }
10133
- return fixed;
10147
+ function slashPathName(slashPath) {
10148
+ const parts = slashPathParts(slashPath);
10149
+ return parts[parts.length - 1];
10134
10150
  }
10135
10151
  /**
10136
- * Reads the website path from the input.
10152
+ * Returns each section of a SlashPath
10137
10153
  *
10138
- * @param input
10154
+ * @param slashPath
10139
10155
  * @returns
10140
10156
  */
10141
- function websitePathFromWebsiteUrl(inputUrl) {
10142
- const websiteDomainAndPath = removeHttpFromUrl(inputUrl);
10143
- return websitePathFromWebsiteDomainAndPath(websiteDomainAndPath);
10157
+ function slashPathParts(slashPath) {
10158
+ return slashPath.split(SLASH_PATH_SEPARATOR).filter(x => Boolean(x));
10144
10159
  }
10145
- function websiteDomainAndPathPairFromWebsiteUrl(inputUrl) {
10146
- const websiteDomainAndPath = removeHttpFromUrl(inputUrl);
10147
- return websiteDomainAndPathPair(websiteDomainAndPath);
10160
+ function slashPathStartTypeFactory(type) {
10161
+ let fn;
10162
+ switch (type) {
10163
+ case 'relative':
10164
+ fn = toRelativeSlashPathStartType;
10165
+ break;
10166
+ case 'absolute':
10167
+ fn = toAbsoluteSlashPathStartType;
10168
+ break;
10169
+ case 'any':
10170
+ fn = mapIdentityFunction();
10171
+ break;
10172
+ }
10173
+ return fn;
10174
+ }
10175
+ const LEADING_SLASHES_REGEX = /^\/+/;
10176
+ const TRAILING_SLASHES_REGEX = /\/+$/;
10177
+ const TRAILING_FILE_TYPE_SEPARATORS_REGEX = /\.+$/;
10178
+ const ALL_SLASHES_REGEX = /\/+/g;
10179
+ const ALL_DOUBLE_SLASHES_REGEX = /\/{2,}/g;
10180
+ const ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
10181
+ function toRelativeSlashPathStartType(input) {
10182
+ // remove all leading slashes
10183
+ return input.replace(LEADING_SLASHES_REGEX, '');
10148
10184
  }
10149
10185
  /**
10150
- * Reads the website path from the input WebsiteDomainAndPath.
10151
10186
  *
10152
10187
  * @param input
10153
10188
  * @returns
10154
10189
  */
10155
- function websitePathFromWebsiteDomainAndPath(input) {
10156
- return websiteDomainAndPathPair(input).path;
10190
+ function toAbsoluteSlashPathStartType(input) {
10191
+ // add a leading slash, and remove any multiple slashes if provided
10192
+ return input.startsWith(SLASH_PATH_SEPARATOR) ? input.replace(LEADING_SLASHES_REGEX, SLASH_PATH_SEPARATOR) : `${SLASH_PATH_SEPARATOR}${input}`;
10157
10193
  }
10158
- function websiteDomainAndPathPair(input) {
10159
- const [domain, path] = splitJoinRemainder(input, '/', 2);
10160
- return {
10161
- domain,
10162
- path: toAbsoluteSlashPathStartType(path !== null && path !== void 0 ? path : '/')
10163
- };
10194
+ function fixMultiSlashesInSlashPath(input) {
10195
+ return input.replace(ALL_DOUBLE_SLASHES_REGEX, SLASH_PATH_SEPARATOR);
10164
10196
  }
10165
- const HTTP_OR_HTTPS_REGEX = /^https:\/\/|http:\/\//;
10166
- const WEB_PROTOCOL_PREFIX_REGEX = /^(.)+:\/\//;
10167
- /**
10168
- * Removes any existing protocol and sets the protocol to match the input.
10169
- *
10170
- * @param url
10171
- * @param protocol
10172
- */
10173
- function setWebProtocolPrefix(input, protocol) {
10174
- return `${protocol}://${removeWebProtocolPrefix(input)}`;
10197
+ function replaceMultipleFilePathsInSlashPath(input) {
10198
+ return input.replace(ALL_DOUBLE_SLASHES_REGEX, SLASH_PATH_SEPARATOR);
10175
10199
  }
10176
- /**
10177
- * Removes any existing protocol prefix from the input.
10178
- *
10179
- * @param input
10180
- */
10181
- function removeWebProtocolPrefix(input) {
10182
- return input.replace(WEB_PROTOCOL_PREFIX_REGEX, '');
10200
+ function removeTrailingSlashes(input) {
10201
+ return input.replace(TRAILING_SLASHES_REGEX, '');
10183
10202
  }
10184
- /**
10185
- * Adds both https:// to the url.
10186
- *
10187
- * @param url
10188
- * @returns
10189
- */
10190
- function addHttpToUrl(url, prefix = 'https') {
10191
- return setWebProtocolPrefix(url, prefix);
10203
+ function removeTrailingFileTypeSeparators(input) {
10204
+ return input.replace(TRAILING_FILE_TYPE_SEPARATORS_REGEX, '');
10192
10205
  }
10193
10206
  /**
10194
- * Removes the prefixes http:// and https:// from the url. If these protocols are not used, nothing is removed.
10207
+ * Replaces all extra and invalidate FilePathTypeSeparator values from the SlashPath, returning a valid SlashPath.
10195
10208
  *
10196
- * @param url
10209
+ * @param input
10210
+ * @param replaceWith
10197
10211
  * @returns
10198
10212
  */
10199
- function removeHttpFromUrl(url) {
10200
- return url.replace(HTTP_OR_HTTPS_REGEX, '');
10213
+ function replaceInvalidFilePathTypeSeparatorsInSlashPath(input, replaceWith) {
10214
+ return replaceInvalidFilePathTypeSeparatorsInSlashPathFunction(replaceWith)(input);
10201
10215
  }
10202
10216
  /**
10203
- * Returns true if the input string starts with http/https
10217
+ * Creates a function that replaces all extra and invalidate FilePathTypeSeparator values from the SlashPath, returning a valid SlashPath.
10204
10218
  *
10205
10219
  * @param input
10220
+ * @param replaceWith
10221
+ * @returns
10206
10222
  */
10207
- function hasHttpPrefix(input) {
10208
- return HTTP_OR_HTTPS_REGEX.test(input);
10209
- }
10210
- function mailToUrlString(input) {
10211
- const mailTo = typeof input === 'string' ? {
10212
- email: input
10213
- } : input;
10214
- return `mailto:${mailTo.email}`;
10215
- }
10216
- // MARK: Tel
10217
- function telUrlString(phone) {
10218
- if (isE164PhoneNumber(phone, true)) {
10219
- const pair = e164PhoneNumberExtensionPair(phone);
10220
- return telUrlStringForE164PhoneNumberPair(pair);
10223
+ function replaceInvalidFilePathTypeSeparatorsInSlashPathFunction(replaceWith = DEFAULT_SLASH_PATH_ILLEGAL_CHARACTER_REPLACEMENT) {
10224
+ return input => {
10225
+ const endsOnFileTypeSeparator = input[input.length - 1] === SLASH_PATH_FILE_TYPE_SEPARATOR;
10226
+ const inputToEvaluate = endsOnFileTypeSeparator ? removeTrailingFileTypeSeparators(input) : input;
10227
+ const {
10228
+ first,
10229
+ last,
10230
+ occurences
10231
+ } = firstAndLastCharacterOccurrence(inputToEvaluate, SLASH_PATH_FILE_TYPE_SEPARATOR);
10232
+ let fixedPath;
10233
+ switch (occurences) {
10234
+ case 0:
10235
+ fixedPath = inputToEvaluate;
10236
+ break;
10237
+ case 1:
10238
+ const lastSlashPosition = inputToEvaluate.lastIndexOf('/');
10239
+ if (lastSlashPosition === -1 || lastSlashPosition < last) {
10240
+ // valid path
10241
+ fixedPath = inputToEvaluate;
10242
+ } else {
10243
+ // the dot occurs before another slash, so we should replace it
10244
+ fixedPath = replaceCharacterAtIndexWith(inputToEvaluate, last, replaceWith);
10245
+ }
10246
+ break;
10247
+ default:
10248
+ const [head, tail] = splitStringAtIndex(inputToEvaluate, last, true);
10249
+ const headWithReplacedSeparators = head.replace(ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX, replaceWith);
10250
+ fixedPath = headWithReplacedSeparators + tail;
10251
+ break;
10252
+ }
10253
+ return fixedPath;
10254
+ };
10255
+ }
10256
+ function slashPathValidationFactory(config) {
10257
+ const {
10258
+ illegalStrings = DEFAULT_SLASH_PATH_ILLEGAL_CHARACTERS,
10259
+ replaceIllegalCharacters: inputReplaceIllegalCharacters = true,
10260
+ replaceIllegalDots: inputReplaceIllegalDots = true,
10261
+ throwError
10262
+ } = config !== null && config !== void 0 ? config : {};
10263
+ const fns = [];
10264
+ const replaceIllegalCharacters = typeof inputReplaceIllegalCharacters === 'string' ? inputReplaceIllegalCharacters : DEFAULT_SLASH_PATH_ILLEGAL_CHARACTER_REPLACEMENT;
10265
+ if (inputReplaceIllegalCharacters != null) {
10266
+ fns.push(replaceStringsFunction({
10267
+ replace: illegalStrings,
10268
+ replaceWith: replaceIllegalCharacters
10269
+ }));
10221
10270
  }
10222
- return `tel:${phone}`;
10271
+ if (inputReplaceIllegalDots != null) {
10272
+ const replaceIllegalDotsWith = typeof inputReplaceIllegalDots === 'string' ? inputReplaceIllegalDots : replaceIllegalCharacters;
10273
+ fns.push(replaceInvalidFilePathTypeSeparatorsInSlashPathFunction(replaceIllegalDotsWith));
10274
+ }
10275
+ if (throwError === true || !(inputReplaceIllegalCharacters || inputReplaceIllegalDots)) {
10276
+ fns.push(x => {
10277
+ if (!isValidSlashPath(x)) {
10278
+ throw slashPathInvalidError();
10279
+ }
10280
+ return x;
10281
+ });
10282
+ }
10283
+ return chainMapSameFunctions(fns);
10284
+ }
10285
+ function slashPathFactory(config) {
10286
+ const {
10287
+ startType: type = 'any',
10288
+ basePath: inputBasePaths,
10289
+ validate = true
10290
+ } = config !== null && config !== void 0 ? config : {};
10291
+ const basePath = inputBasePaths ? mergeSlashPaths(asArray(inputBasePaths)) : undefined;
10292
+ const typeFactory = slashPathStartTypeFactory(type);
10293
+ const validationFactory = validate ? typeof validate === 'boolean' ? slashPathValidationFactory() : slashPathValidationFactory(validate) : null;
10294
+ const finalizeFn = chainMapFunction(typeFactory, validationFactory);
10295
+ return paths => {
10296
+ const merged = mergeSlashPaths(pushItemOrArrayItemsIntoArray([basePath], paths));
10297
+ return finalizeFn(merged);
10298
+ };
10299
+ }
10300
+ function mergeSlashPaths(paths) {
10301
+ const merge = paths.filter(Boolean).join(SLASH_PATH_SEPARATOR);
10302
+ return fixMultiSlashesInSlashPath(merge);
10303
+ }
10304
+ function slashPathInvalidError() {
10305
+ return new Error('The slashPath is invalid.');
10223
10306
  }
10224
10307
  /**
10225
- * Creates a tel url string for the input E164PhoneNumberExtensionPair.
10308
+ * Splits the path and returns the items at the given ranges.
10226
10309
  *
10227
- * @param pair
10228
- * @returns
10310
+ * @param path
10229
10311
  */
10230
- function telUrlStringForE164PhoneNumberPair(pair) {
10231
- // https://stackoverflow.com/questions/9482633/how-do-i-include-extensions-in-the-tel-uri
10232
- if (pair.extension) {
10233
- return `tel:${pair.number};${pair.extension}`;
10234
- } else {
10235
- return `tel:${pair.number}`;
10236
- }
10312
+ function isolateSlashPath(path, range) {
10313
+ return isolateSlashPathFunction({
10314
+ range
10315
+ })(path);
10237
10316
  }
10317
+ /**
10318
+ * Creates an IsolateSlashPathFunction.
10319
+ *
10320
+ * @param config
10321
+ * @returns
10322
+ */
10323
+ function isolateSlashPathFunction(config) {
10324
+ const {
10325
+ startType,
10326
+ asFile
10327
+ } = config;
10328
+ const range = indexRange(config.range);
10329
+ const sliceRange = sliceIndexRangeFunction(range);
10330
+ return path => {
10331
+ const split = toRelativeSlashPathStartType(path).split(SLASH_PATH_SEPARATOR);
10332
+ const splitRange = sliceRange(split);
10333
+ let joined = splitRange.join(SLASH_PATH_SEPARATOR);
10334
+ const isFolder = asFile !== true && split.length > range.maxIndex;
10335
+ if (isFolder) {
10336
+ joined = joined + SLASH_PATH_SEPARATOR; // end with a slash.
10337
+ }
10238
10338
 
10239
- function readDomainsFromEmailAddresses(addresses) {
10240
- return uniqueCaseInsensitiveStrings(addresses.map(readDomainFromEmailAddress));
10241
- }
10242
- function readDomainFromEmailAddress(address) {
10243
- const split = address.split('@');
10244
- const domain = split[1];
10245
- return domain.toLowerCase();
10339
+ if (startType === 'absolute' || path.startsWith(SLASH_PATH_SEPARATOR)) {
10340
+ return toAbsoluteSlashPathStartType(joined);
10341
+ } else {
10342
+ return joined;
10343
+ }
10344
+ };
10246
10345
  }
10346
+
10247
10347
  /**
10248
- * Reads a domain from the input that can be formatted as
10348
+ * Simple website domain regex that looks for a period in the string between the domain and the tld
10349
+ */
10350
+ const HAS_WEBSITE_DOMAIN_NAME_REGEX = /(.+)\.(.+)/;
10351
+ /**
10352
+ * Returns true if the input probably has a website domain in it.
10249
10353
  *
10250
- * - A url: www.test.com,
10251
- * - A url with the protocol (://): https://www.test.com
10252
- * - An email address: test@test.com
10253
- * - A domain: test.com
10354
+ * Examples where it will return true:
10355
+ * - dereekb.com
10356
+ * - https://components.dereekb.com
10357
+ * - https://components.dereekb.com/
10358
+ * - https://components.dereekb.com/doc/home
10254
10359
  *
10255
- * @param urlLikeInput
10256
- * @returns The domain
10360
+ * @param input
10361
+ * @returns
10257
10362
  */
10258
- function readEmailDomainFromUrlOrEmailAddress(urlLikeInput) {
10259
- const emailSplit = urlLikeInput.split('@');
10260
- const url = emailSplit[emailSplit.length - 1];
10261
- let domain;
10262
- if (emailSplit.length > 1) {
10263
- domain = url;
10363
+ function hasWebsiteDomain(input) {
10364
+ return HAS_WEBSITE_DOMAIN_NAME_REGEX.test(input);
10365
+ }
10366
+ /**
10367
+ * Creates a base website url from the input domain or url.
10368
+ *
10369
+ * @param input
10370
+ * @returns
10371
+ */
10372
+ function baseWebsiteUrl(input, defaultTld = 'com') {
10373
+ let base;
10374
+ if (hasHttpPrefix(input)) {
10375
+ base = input;
10264
10376
  } else {
10265
- domain = websiteDomainAndPathPairFromWebsiteUrl(url).domain;
10266
- // strip out www. if it is provided, as it is a 'special' domain type,
10267
- // and emails probably don't come from there.
10268
- if (domain.startsWith('www')) {
10269
- domain = domain.split('www.', 2)[1];
10270
- }
10377
+ base = addHttpToUrl(input);
10271
10378
  }
10272
- return domain;
10273
- }
10274
-
10275
- function convertParticipantToEmailParticipantString(participant) {
10276
- var _a, _b;
10277
- return `${(_b = (_a = participant.name) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : ''}<${participant.email}>`;
10379
+ if (!hasWebsiteDomain(base)) {
10380
+ base = `${base}.${defaultTld || 'com'}`;
10381
+ }
10382
+ return base;
10278
10383
  }
10279
- function convertEmailParticipantStringToParticipant(participantString) {
10280
- const split = participantString.split('<');
10281
- const name = split[0] || undefined;
10282
- const email = split[1].substring(0, split[1].length - 1);
10283
- return {
10284
- name,
10285
- email
10286
- };
10384
+ /**
10385
+ * Returns true if the input string is probably a website url.
10386
+ *
10387
+ * Checks that it has the http/https prefix, has a domain, and the path is a slash path. The query parameters are ignored.
10388
+ */
10389
+ function isWebsiteUrl(input) {
10390
+ const noHttp = removeHttpFromUrl(input);
10391
+ const splitPair = websiteDomainAndPathPairFromWebsiteUrl(noHttp);
10392
+ const [path, query] = splitStringAtFirstCharacterOccurence(splitPair.path, '?'); // everything after the query is ignored
10393
+ const isWebsiteUrl = hasWebsiteDomain(splitPair.domain) && isSlashPathFolder(path + '/');
10394
+ return isWebsiteUrl;
10287
10395
  }
10288
- function coerceToEmailParticipants({
10289
- participants = [],
10290
- emails = []
10291
- }) {
10292
- var _a;
10293
- if (!(emails === null || emails === void 0 ? void 0 : emails.length)) {
10294
- return participants;
10295
- } else {
10296
- const participantEmails = (_a = participants === null || participants === void 0 ? void 0 : participants.map(x => x.email)) !== null && _a !== void 0 ? _a : [];
10297
- const emailsWithoutParticipants = excludeValuesFromArray(emails, participantEmails);
10298
- return participants.concat(emailsWithoutParticipants.map(email => ({
10299
- email
10300
- })));
10396
+ /**
10397
+ * Returns true if the input string is probably a website url.
10398
+ *
10399
+ * Checks that it has the http/https prefix, has a domain, and the path is a slash path. The query parameters are ignored.
10400
+ */
10401
+ function isWebsiteUrlWithPrefix(input) {
10402
+ let isWebsiteUrlWithPrefix = false;
10403
+ const hasPrefix = hasHttpPrefix(input);
10404
+ if (hasPrefix) {
10405
+ isWebsiteUrlWithPrefix = isWebsiteUrl(input);
10301
10406
  }
10407
+ return isWebsiteUrlWithPrefix;
10302
10408
  }
10303
-
10304
- const DEFAULT_RANDOM_EMAIL_FACTORY_CONFIG = {
10305
- prefixes: 'email.',
10306
- domains: 'test.dereekb.com',
10307
- numberFactory: incrementingNumberFactory() // use an incrementing number factory for safety in tests
10308
- };
10309
-
10310
- function randomEmailFactory(inputConfig) {
10311
- var _a, _b;
10312
- const config = mergeObjects([DEFAULT_RANDOM_EMAIL_FACTORY_CONFIG, inputConfig], exports.KeyValueTypleValueFilter.FALSY_AND_EMPTY);
10313
- const prefixFactory = randomFromArrayFactory(asArray((_a = config.prefixes) !== null && _a !== void 0 ? _a : ''));
10314
- const domainFactory = randomFromArrayFactory(asArray((_b = config.domains) !== null && _b !== void 0 ? _b : 'test.dereekb.com'));
10315
- const numberFactory = config.numberFactory;
10316
- return () => {
10317
- const prefix = prefixFactory();
10318
- const domain = domainFactory();
10319
- const number = numberFactory();
10320
- const numberString = number >= 0 ? number.toString() : '';
10321
- return `${prefix}${numberString}@${domain}`;
10322
- };
10323
- }
10324
- const DEFAULT_RANDOM_PHONE_NUMBER_FACTORY_CONFIG = {
10325
- internationalAreaCodes: [1210, 1979, 1512, 1303],
10326
- numberFactory: randomNumberFactory({
10327
- min: 2000000,
10328
- max: 10000000,
10329
- round: 'floor'
10330
- })
10331
- };
10332
- function randomPhoneNumberFactory(inputConfig) {
10333
- var _a;
10334
- const config = mergeObjects([DEFAULT_RANDOM_PHONE_NUMBER_FACTORY_CONFIG, inputConfig], exports.KeyValueTypleValueFilter.FALSY_AND_EMPTY);
10335
- const internationalCodeFactory = randomFromArrayFactory(asArray((_a = config.internationalAreaCodes) !== null && _a !== void 0 ? _a : 1210));
10336
- const numberFactory = config.numberFactory;
10337
- return () => {
10338
- const code = internationalCodeFactory();
10339
- const number = numberFactory();
10340
- return `+${code}${number}`;
10409
+ /**
10410
+ * Creates a WebsiteUrl from the input
10411
+ * @param basePath
10412
+ * @param paths
10413
+ * @returns
10414
+ */
10415
+ function websiteUrlFromPaths(basePath, paths) {
10416
+ const basePathWithoutHttp = removeHttpFromUrl(baseWebsiteUrl(basePath));
10417
+ return addHttpToUrl(mergeSlashPaths([basePathWithoutHttp, ...asArray(paths)]));
10418
+ }
10419
+ /**
10420
+ * Creates a new ExcludeBaseWebsitePathFunction that excludes the base path from the input website path if it exists.
10421
+ *
10422
+ * @param basePath
10423
+ */
10424
+ function isolateWebsitePathFunction(config = {}) {
10425
+ const {
10426
+ removeQueryParameters,
10427
+ ignoredBasePath,
10428
+ isolatePathComponents,
10429
+ removeTrailingSlash
10430
+ } = config;
10431
+ const basePathRegex = ignoredBasePath ? new RegExp('^' + escapeStringForRegex(toAbsoluteSlashPathStartType(ignoredBasePath))) : undefined;
10432
+ const isolateRange = isolatePathComponents != null ? isolateSlashPathFunction({
10433
+ range: isolatePathComponents,
10434
+ startType: 'absolute'
10435
+ }) : undefined;
10436
+ const replaceTrailingSlash = removeTrailingSlash === true ? replaceLastCharacterIfIsFunction('', SLASH_PATH_SEPARATOR) : undefined;
10437
+ const pathTransform = chainMapSameFunctions([
10438
+ // remove any base path
10439
+ basePathRegex != null ? inputPath => inputPath.replace(basePathRegex, '') : undefined,
10440
+ // remove the query parameters
10441
+ removeQueryParameters != null ? inputPath => websitePathAndQueryPair(inputPath).path : undefined,
10442
+ // isolate range
10443
+ isolateRange != null ? inputPath => {
10444
+ let result = isolateRange(inputPath);
10445
+ // retain the query if one is available.
10446
+ if (removeQueryParameters !== true) {
10447
+ const {
10448
+ query
10449
+ } = websitePathAndQueryPair(inputPath);
10450
+ if (query) {
10451
+ result = result + query;
10452
+ }
10453
+ }
10454
+ return result;
10455
+ } : undefined,
10456
+ // remove trailing slash from path
10457
+ replaceTrailingSlash != null ? inputPath => {
10458
+ const {
10459
+ path,
10460
+ query
10461
+ } = websitePathAndQueryPair(inputPath);
10462
+ return replaceTrailingSlash(path) + (query !== null && query !== void 0 ? query : '');
10463
+ } : undefined]);
10464
+ return input => {
10465
+ const path = pathTransform(websitePathFromWebsiteUrl(input));
10466
+ return path;
10341
10467
  };
10342
10468
  }
10343
-
10344
- function isServerError(input) {
10345
- return typeof input === 'object' && input.status != null && input.code != null;
10469
+ function websitePathAndQueryPair(inputPath) {
10470
+ const [path, rawQuery] = inputPath.split('?', 2);
10471
+ const query = rawQuery ? fixExtraQueryParameters(rawQuery, true) : undefined;
10472
+ return {
10473
+ path: path,
10474
+ query: query ? `?${query}` : undefined
10475
+ };
10346
10476
  }
10347
- function partialServerError(messageOrError) {
10348
- var _a;
10349
- let serverError;
10350
- if (typeof messageOrError === 'string') {
10351
- serverError = {
10352
- message: messageOrError
10353
- };
10354
- } else {
10355
- serverError = (_a = messageOrError) !== null && _a !== void 0 ? _a : {};
10477
+ /**
10478
+ * Replaces any extra query parameter "?" characters with an "&" character.
10479
+ *
10480
+ * Can also choose to replace all instead, incase the input string should be considered the query without.
10481
+ *
10482
+ * @param input
10483
+ */
10484
+ function fixExtraQueryParameters(input, replaceAll = false) {
10485
+ const questionMarkIndexes = findAllCharacterOccurences(new Set('?'), input);
10486
+ let indexesToReplace;
10487
+ let fixed = input;
10488
+ if (replaceAll && questionMarkIndexes.length) {
10489
+ indexesToReplace = questionMarkIndexes;
10490
+ } else if (questionMarkIndexes.length > 1) {
10491
+ indexesToReplace = questionMarkIndexes.reverse();
10492
+ indexesToReplace.pop(); // remove the "first" so it does not get replaced.
10356
10493
  }
10357
- return serverError;
10358
- }
10359
- function serverError(config) {
10360
- return Object.assign(Object.assign({}, config), {
10361
- data: config.data
10362
- });
10494
+
10495
+ if (indexesToReplace === null || indexesToReplace === void 0 ? void 0 : indexesToReplace.length) {
10496
+ indexesToReplace.forEach(index => fixed = replaceCharacterAtIndexWith(fixed, index, '&'));
10497
+ }
10498
+ return fixed;
10363
10499
  }
10364
10500
  /**
10365
- * Base server-error class.
10501
+ * Reads the website path from the input.
10502
+ *
10503
+ * @param input
10504
+ * @returns
10366
10505
  */
10367
- class ServerErrorResponse {
10368
- constructor({
10369
- code,
10370
- status,
10371
- data,
10372
- message
10373
- }) {
10374
- this.code = code;
10375
- this.message = message;
10376
- this.status = status;
10377
- this.data = data;
10378
- }
10506
+ function websitePathFromWebsiteUrl(inputUrl) {
10507
+ const websiteDomainAndPath = removeHttpFromUrl(inputUrl);
10508
+ return websitePathFromWebsiteDomainAndPath(websiteDomainAndPath);
10379
10509
  }
10380
- class UnauthorizedServerErrorResponse extends ServerErrorResponse {
10381
- constructor({
10382
- code,
10383
- data,
10384
- message
10385
- }) {
10386
- super({
10387
- status: 401,
10388
- message: message !== null && message !== void 0 ? message : 'Unauthorized',
10389
- data,
10390
- code
10391
- });
10392
- }
10510
+ function websiteDomainAndPathPairFromWebsiteUrl(inputUrl) {
10511
+ const websiteDomainAndPath = removeHttpFromUrl(inputUrl);
10512
+ return websiteDomainAndPathPair(websiteDomainAndPath);
10393
10513
  }
10394
-
10395
- const DEFAULT_READABLE_ERROR_CODE = 'ERROR';
10396
- function isDefaultReadableError(error) {
10397
- const code = typeof error === 'object' ? error === null || error === void 0 ? void 0 : error.code : error;
10398
- return !code || code === DEFAULT_READABLE_ERROR_CODE;
10514
+ /**
10515
+ * Reads the website path from the input WebsiteDomainAndPath.
10516
+ *
10517
+ * @param input
10518
+ * @returns
10519
+ */
10520
+ function websitePathFromWebsiteDomainAndPath(input) {
10521
+ return websiteDomainAndPathPair(input).path;
10399
10522
  }
10400
- function readableError(code, message) {
10523
+ function websiteDomainAndPathPair(input) {
10524
+ const [domain, path] = splitJoinRemainder(input, '/', 2);
10401
10525
  return {
10402
- code,
10403
- message
10526
+ domain,
10527
+ path: toAbsoluteSlashPathStartType(path !== null && path !== void 0 ? path : '/')
10404
10528
  };
10405
10529
  }
10406
- function toReadableError(inputError) {
10407
- let error;
10408
- if (inputError) {
10409
- if (inputError.code) {
10410
- error = inputError;
10411
- } else if (inputError.data) {
10412
- error = Object.assign({
10413
- code: DEFAULT_READABLE_ERROR_CODE
10414
- }, inputError.data);
10415
- } else if (inputError instanceof makeError.BaseError) {
10416
- error = {
10417
- code: inputError.name,
10418
- message: inputError.message,
10419
- _error: inputError
10420
- };
10421
- } else {
10422
- error = {
10423
- code: DEFAULT_READABLE_ERROR_CODE,
10424
- message: inputError.message || '',
10425
- _error: inputError
10426
- };
10427
- }
10428
- }
10429
- return error;
10530
+ const HTTP_OR_HTTPS_REGEX = /^https:\/\/|http:\/\//;
10531
+ const WEB_PROTOCOL_PREFIX_REGEX = /^(.)+:\/\//;
10532
+ /**
10533
+ * Removes any existing protocol and sets the protocol to match the input.
10534
+ *
10535
+ * @param url
10536
+ * @param protocol
10537
+ */
10538
+ function setWebProtocolPrefix(input, protocol) {
10539
+ return `${protocol}://${removeWebProtocolPrefix(input)}`;
10430
10540
  }
10431
- function errorMessageContainsString(input, target) {
10432
- return input ? errorMessageContainsStringFunction(target)(input) : false;
10541
+ /**
10542
+ * Removes any existing protocol prefix from the input.
10543
+ *
10544
+ * @param input
10545
+ */
10546
+ function removeWebProtocolPrefix(input) {
10547
+ return input.replace(WEB_PROTOCOL_PREFIX_REGEX, '');
10433
10548
  }
10434
- function errorMessageContainsStringFunction(target) {
10435
- const regex = new RegExp(escapeStringForRegex(target));
10436
- return input => {
10437
- const message = messageFromError(input);
10438
- return message ? regex.test(message) : false;
10439
- };
10549
+ /**
10550
+ * Adds both https:// to the url.
10551
+ *
10552
+ * @param url
10553
+ * @returns
10554
+ */
10555
+ function addHttpToUrl(url, prefix = 'https') {
10556
+ return setWebProtocolPrefix(url, prefix);
10440
10557
  }
10441
- function messageFromError(input) {
10442
- return (typeof input === 'object' ? input.message : input) || input;
10558
+ /**
10559
+ * Removes the prefixes http:// and https:// from the url. If these protocols are not used, nothing is removed.
10560
+ *
10561
+ * @param url
10562
+ * @returns
10563
+ */
10564
+ function removeHttpFromUrl(url) {
10565
+ return url.replace(HTTP_OR_HTTPS_REGEX, '');
10566
+ }
10567
+ /**
10568
+ * Returns true if the input string starts with http/https
10569
+ *
10570
+ * @param input
10571
+ */
10572
+ function hasHttpPrefix(input) {
10573
+ return HTTP_OR_HTTPS_REGEX.test(input);
10574
+ }
10575
+ function mailToUrlString(input) {
10576
+ const mailTo = typeof input === 'string' ? {
10577
+ email: input
10578
+ } : input;
10579
+ return `mailto:${mailTo.email}`;
10580
+ }
10581
+ // MARK: Tel
10582
+ function telUrlString(phone) {
10583
+ if (isE164PhoneNumber(phone, true)) {
10584
+ const pair = e164PhoneNumberExtensionPair(phone);
10585
+ return telUrlStringForE164PhoneNumberPair(pair);
10586
+ }
10587
+ return `tel:${phone}`;
10588
+ }
10589
+ /**
10590
+ * Creates a tel url string for the input E164PhoneNumberExtensionPair.
10591
+ *
10592
+ * @param pair
10593
+ * @returns
10594
+ */
10595
+ function telUrlStringForE164PhoneNumberPair(pair) {
10596
+ // https://stackoverflow.com/questions/9482633/how-do-i-include-extensions-in-the-tel-uri
10597
+ if (pair.extension) {
10598
+ return `tel:${pair.number};${pair.extension}`;
10599
+ } else {
10600
+ return `tel:${pair.number}`;
10601
+ }
10602
+ }
10603
+
10604
+ function readDomainsFromEmailAddresses(addresses) {
10605
+ return uniqueCaseInsensitiveStrings(addresses.map(readDomainFromEmailAddress));
10606
+ }
10607
+ function readDomainFromEmailAddress(address) {
10608
+ const split = address.split('@');
10609
+ const domain = split[1];
10610
+ return domain.toLowerCase();
10611
+ }
10612
+ /**
10613
+ * Reads a domain from the input that can be formatted as
10614
+ *
10615
+ * - A url: www.test.com,
10616
+ * - A url with the protocol (://): https://www.test.com
10617
+ * - An email address: test@test.com
10618
+ * - A domain: test.com
10619
+ *
10620
+ * @param urlLikeInput
10621
+ * @returns The domain
10622
+ */
10623
+ function readEmailDomainFromUrlOrEmailAddress(urlLikeInput) {
10624
+ const emailSplit = urlLikeInput.split('@');
10625
+ const url = emailSplit[emailSplit.length - 1];
10626
+ let domain;
10627
+ if (emailSplit.length > 1) {
10628
+ domain = url;
10629
+ } else {
10630
+ domain = websiteDomainAndPathPairFromWebsiteUrl(url).domain;
10631
+ // strip out www. if it is provided, as it is a 'special' domain type,
10632
+ // and emails probably don't come from there.
10633
+ if (domain.startsWith('www')) {
10634
+ domain = domain.split('www.', 2)[1];
10635
+ }
10636
+ }
10637
+ return domain;
10638
+ }
10639
+
10640
+ function convertParticipantToEmailParticipantString(participant) {
10641
+ var _a, _b;
10642
+ return `${(_b = (_a = participant.name) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : ''}<${participant.email}>`;
10643
+ }
10644
+ function convertEmailParticipantStringToParticipant(participantString) {
10645
+ const split = participantString.split('<');
10646
+ const name = split[0] || undefined;
10647
+ const email = split[1].substring(0, split[1].length - 1);
10648
+ return {
10649
+ name,
10650
+ email
10651
+ };
10652
+ }
10653
+ function coerceToEmailParticipants({
10654
+ participants = [],
10655
+ emails = []
10656
+ }) {
10657
+ var _a;
10658
+ if (!(emails === null || emails === void 0 ? void 0 : emails.length)) {
10659
+ return participants;
10660
+ } else {
10661
+ const participantEmails = (_a = participants === null || participants === void 0 ? void 0 : participants.map(x => x.email)) !== null && _a !== void 0 ? _a : [];
10662
+ const emailsWithoutParticipants = excludeValuesFromArray(emails, participantEmails);
10663
+ return participants.concat(emailsWithoutParticipants.map(email => ({
10664
+ email
10665
+ })));
10666
+ }
10667
+ }
10668
+
10669
+ const DEFAULT_RANDOM_EMAIL_FACTORY_CONFIG = {
10670
+ prefixes: 'email.',
10671
+ domains: 'test.dereekb.com',
10672
+ numberFactory: incrementingNumberFactory() // use an incrementing number factory for safety in tests
10673
+ };
10674
+
10675
+ function randomEmailFactory(inputConfig) {
10676
+ var _a, _b;
10677
+ const config = mergeObjects([DEFAULT_RANDOM_EMAIL_FACTORY_CONFIG, inputConfig], exports.KeyValueTypleValueFilter.FALSY_AND_EMPTY);
10678
+ const prefixFactory = randomFromArrayFactory(asArray((_a = config.prefixes) !== null && _a !== void 0 ? _a : ''));
10679
+ const domainFactory = randomFromArrayFactory(asArray((_b = config.domains) !== null && _b !== void 0 ? _b : 'test.dereekb.com'));
10680
+ const numberFactory = config.numberFactory;
10681
+ return () => {
10682
+ const prefix = prefixFactory();
10683
+ const domain = domainFactory();
10684
+ const number = numberFactory();
10685
+ const numberString = number >= 0 ? number.toString() : '';
10686
+ return `${prefix}${numberString}@${domain}`;
10687
+ };
10688
+ }
10689
+ const DEFAULT_RANDOM_PHONE_NUMBER_FACTORY_CONFIG = {
10690
+ internationalAreaCodes: [1210, 1979, 1512, 1303],
10691
+ numberFactory: randomNumberFactory({
10692
+ min: 2000000,
10693
+ max: 10000000,
10694
+ round: 'floor'
10695
+ })
10696
+ };
10697
+ function randomPhoneNumberFactory(inputConfig) {
10698
+ var _a;
10699
+ const config = mergeObjects([DEFAULT_RANDOM_PHONE_NUMBER_FACTORY_CONFIG, inputConfig], exports.KeyValueTypleValueFilter.FALSY_AND_EMPTY);
10700
+ const internationalCodeFactory = randomFromArrayFactory(asArray((_a = config.internationalAreaCodes) !== null && _a !== void 0 ? _a : 1210));
10701
+ const numberFactory = config.numberFactory;
10702
+ return () => {
10703
+ const code = internationalCodeFactory();
10704
+ const number = numberFactory();
10705
+ return `+${code}${number}`;
10706
+ };
10707
+ }
10708
+
10709
+ function isServerError(input) {
10710
+ return typeof input === 'object' && input.status != null && input.code != null;
10711
+ }
10712
+ function partialServerError(messageOrError) {
10713
+ var _a;
10714
+ let serverError;
10715
+ if (typeof messageOrError === 'string') {
10716
+ serverError = {
10717
+ message: messageOrError
10718
+ };
10719
+ } else {
10720
+ serverError = (_a = messageOrError) !== null && _a !== void 0 ? _a : {};
10721
+ }
10722
+ return serverError;
10723
+ }
10724
+ function serverError(config) {
10725
+ return Object.assign(Object.assign({}, config), {
10726
+ data: config.data
10727
+ });
10728
+ }
10729
+ /**
10730
+ * Base server-error class.
10731
+ */
10732
+ class ServerErrorResponse {
10733
+ constructor({
10734
+ code,
10735
+ status,
10736
+ data,
10737
+ message
10738
+ }) {
10739
+ this.code = code;
10740
+ this.message = message;
10741
+ this.status = status;
10742
+ this.data = data;
10743
+ }
10744
+ }
10745
+ class UnauthorizedServerErrorResponse extends ServerErrorResponse {
10746
+ constructor({
10747
+ code,
10748
+ data,
10749
+ message
10750
+ }) {
10751
+ super({
10752
+ status: 401,
10753
+ message: message !== null && message !== void 0 ? message : 'Unauthorized',
10754
+ data,
10755
+ code
10756
+ });
10757
+ }
10758
+ }
10759
+
10760
+ const DEFAULT_READABLE_ERROR_CODE = 'ERROR';
10761
+ function isDefaultReadableError(error) {
10762
+ const code = typeof error === 'object' ? error === null || error === void 0 ? void 0 : error.code : error;
10763
+ return !code || code === DEFAULT_READABLE_ERROR_CODE;
10764
+ }
10765
+ function readableError(code, message) {
10766
+ return {
10767
+ code,
10768
+ message
10769
+ };
10770
+ }
10771
+ function toReadableError(inputError) {
10772
+ let error;
10773
+ if (inputError) {
10774
+ if (inputError.code) {
10775
+ error = inputError;
10776
+ } else if (inputError.data) {
10777
+ error = Object.assign({
10778
+ code: DEFAULT_READABLE_ERROR_CODE
10779
+ }, inputError.data);
10780
+ } else if (inputError instanceof makeError.BaseError) {
10781
+ error = {
10782
+ code: inputError.name,
10783
+ message: inputError.message,
10784
+ _error: inputError
10785
+ };
10786
+ } else {
10787
+ error = {
10788
+ code: DEFAULT_READABLE_ERROR_CODE,
10789
+ message: inputError.message || '',
10790
+ _error: inputError
10791
+ };
10792
+ }
10793
+ }
10794
+ return error;
10795
+ }
10796
+ function errorMessageContainsString(input, target) {
10797
+ return input ? errorMessageContainsStringFunction(target)(input) : false;
10798
+ }
10799
+ function errorMessageContainsStringFunction(target) {
10800
+ const regex = new RegExp(escapeStringForRegex(target));
10801
+ return input => {
10802
+ const message = messageFromError(input);
10803
+ return message ? regex.test(message) : false;
10804
+ };
10805
+ }
10806
+ function messageFromError(input) {
10807
+ return (typeof input === 'object' ? input.message : input) || input;
10808
+ }
10809
+
10810
+ /*eslint @typescript-eslint/no-explicit-any:"off"*/
10811
+ // any is used with intent here. using unknown can have strange effects in usage of forwardFunction and type capture.
10812
+ /**
10813
+ * Wraps a Getter that returns a function. When the function is invoked, the getter retrieves the function then calls it with the input arguments.
10814
+ *
10815
+ * @param getter
10816
+ * @returns
10817
+ */
10818
+ function forwardFunction(getter) {
10819
+ const fn = (...args) => {
10820
+ const forwardFn = getter();
10821
+ return forwardFn(...args);
10822
+ };
10823
+ return fn;
10824
+ }
10825
+ function defaultForwardFunctionFactory(defaultFn) {
10826
+ return fn => forwardFunction(() => fn !== null && fn !== void 0 ? fn : defaultFn);
10827
+ }
10828
+
10829
+ /**
10830
+ * A function that returns the input value.
10831
+ *
10832
+ * Is an alias of the mapIdentityFunction, so it will return true when passed to isMapIdentityFunction().
10833
+ *
10834
+ * @param input
10835
+ * @returns
10836
+ */
10837
+ const passThrough = MAP_IDENTITY;
10838
+
10839
+ /**
10840
+ * Builds an array from intersection of the input object and input keys that correspond to values that should be part of the result.
10841
+ *
10842
+ * @param object
10843
+ * @param keys
10844
+ * @returns
10845
+ */
10846
+ function mapKeysIntersectionObjectToArray(object, keys) {
10847
+ const keysToApply = Array.from(keys);
10848
+ const applyArray = [];
10849
+ keysToApply.forEach(key => {
10850
+ const values = object[key];
10851
+ if (values != null) {
10852
+ pushItemOrArrayItemsIntoArray(applyArray, values);
10853
+ }
10854
+ });
10855
+ return applyArray;
10856
+ }
10857
+
10858
+ var $TypeError$5 = TypeError;
10859
+ var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; // 2 ** 53 - 1 == 9007199254740991
10860
+
10861
+ var doesNotExceedSafeInteger$1 = function (it) {
10862
+ if (it > MAX_SAFE_INTEGER) throw $TypeError$5('Maximum allowed index exceeded');
10863
+ return it;
10864
+ };
10865
+
10866
+ var uncurryThis = functionUncurryThisClause;
10867
+ var aCallable$5 = aCallable$a;
10868
+ var NATIVE_BIND = functionBindNative;
10869
+
10870
+ var bind$5 = uncurryThis(uncurryThis.bind);
10871
+
10872
+ // optional / simple context binding
10873
+ var functionBindContext = function (fn, that) {
10874
+ aCallable$5(fn);
10875
+ return that === undefined ? fn : NATIVE_BIND ? bind$5(fn, that) : function (/* ...args */) {
10876
+ return fn.apply(that, arguments);
10877
+ };
10878
+ };
10879
+
10880
+ var isArray$1 = isArray$3;
10881
+ var lengthOfArrayLike$2 = lengthOfArrayLike$6;
10882
+ var doesNotExceedSafeInteger = doesNotExceedSafeInteger$1;
10883
+ var bind$4 = functionBindContext;
10884
+
10885
+ // `FlattenIntoArray` abstract operation
10886
+ // https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray
10887
+ var flattenIntoArray$1 = function (target, original, source, sourceLen, start, depth, mapper, thisArg) {
10888
+ var targetIndex = start;
10889
+ var sourceIndex = 0;
10890
+ var mapFn = mapper ? bind$4(mapper, thisArg) : false;
10891
+ var element, elementLen;
10892
+
10893
+ while (sourceIndex < sourceLen) {
10894
+ if (sourceIndex in source) {
10895
+ element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex];
10896
+
10897
+ if (depth > 0 && isArray$1(element)) {
10898
+ elementLen = lengthOfArrayLike$2(element);
10899
+ targetIndex = flattenIntoArray$1(target, original, element, elementLen, targetIndex, depth - 1) - 1;
10900
+ } else {
10901
+ doesNotExceedSafeInteger(targetIndex + 1);
10902
+ target[targetIndex] = element;
10903
+ }
10904
+
10905
+ targetIndex++;
10906
+ }
10907
+ sourceIndex++;
10908
+ }
10909
+ return targetIndex;
10910
+ };
10911
+
10912
+ var flattenIntoArray_1 = flattenIntoArray$1;
10913
+
10914
+ var isArray = isArray$3;
10915
+ var isConstructor = isConstructor$2;
10916
+ var isObject$2 = isObject$c;
10917
+ var wellKnownSymbol$4 = wellKnownSymbol$k;
10918
+
10919
+ var SPECIES$1 = wellKnownSymbol$4('species');
10920
+ var $Array = Array;
10921
+
10922
+ // a part of `ArraySpeciesCreate` abstract operation
10923
+ // https://tc39.es/ecma262/#sec-arrayspeciescreate
10924
+ var arraySpeciesConstructor$1 = function (originalArray) {
10925
+ var C;
10926
+ if (isArray(originalArray)) {
10927
+ C = originalArray.constructor;
10928
+ // cross-realm fallback
10929
+ if (isConstructor(C) && (C === $Array || isArray(C.prototype))) C = undefined;
10930
+ else if (isObject$2(C)) {
10931
+ C = C[SPECIES$1];
10932
+ if (C === null) C = undefined;
10933
+ }
10934
+ } return C === undefined ? $Array : C;
10935
+ };
10936
+
10937
+ var arraySpeciesConstructor = arraySpeciesConstructor$1;
10938
+
10939
+ // `ArraySpeciesCreate` abstract operation
10940
+ // https://tc39.es/ecma262/#sec-arrayspeciescreate
10941
+ var arraySpeciesCreate$1 = function (originalArray, length) {
10942
+ return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
10943
+ };
10944
+
10945
+ var $$6 = _export;
10946
+ var flattenIntoArray = flattenIntoArray_1;
10947
+ var toObject = toObject$7;
10948
+ var lengthOfArrayLike$1 = lengthOfArrayLike$6;
10949
+ var toIntegerOrInfinity = toIntegerOrInfinity$7;
10950
+ var arraySpeciesCreate = arraySpeciesCreate$1;
10951
+
10952
+ // `Array.prototype.flat` method
10953
+ // https://tc39.es/ecma262/#sec-array.prototype.flat
10954
+ $$6({ target: 'Array', proto: true }, {
10955
+ flat: function flat(/* depthArg = 1 */) {
10956
+ var depthArg = arguments.length ? arguments[0] : undefined;
10957
+ var O = toObject(this);
10958
+ var sourceLen = lengthOfArrayLike$1(O);
10959
+ var A = arraySpeciesCreate(O, 0);
10960
+ A.length = flattenIntoArray(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toIntegerOrInfinity(depthArg));
10961
+ return A;
10962
+ }
10963
+ });
10964
+
10965
+ // this method was added to unscopables after implementation
10966
+ // in popular engines, so it's moved to a separate module
10967
+ var addToUnscopables = addToUnscopables$2;
10968
+
10969
+ // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
10970
+ addToUnscopables('flat');
10971
+
10972
+ function performTaskLoop(config) {
10973
+ return __awaiter(this, void 0, void 0, function* () {
10974
+ let result;
10975
+ const initValue = config.initValue;
10976
+ const startLoop = initValue == null || (yield config.checkContinue(initValue, -1));
10977
+ if (startLoop) {
10978
+ let i = 0;
10979
+ let prevValue = initValue;
10980
+ let check;
10981
+ do {
10982
+ prevValue = yield config.next(i, prevValue);
10983
+ i += 1;
10984
+ check = yield config.checkContinue(prevValue, i);
10985
+ } while (check);
10986
+ result = prevValue;
10987
+ } else {
10988
+ result = initValue;
10989
+ }
10990
+ return result;
10991
+ });
10992
+ }
10993
+ function performTaskCountLoop(config) {
10994
+ return performTaskLoop(Object.assign(Object.assign({}, config), {
10995
+ checkContinue: (_, i) => i < config.count
10996
+ }));
10997
+ }
10998
+ function performMakeLoop(config) {
10999
+ return performTaskCountLoop({
11000
+ count: config.count,
11001
+ initValue: [],
11002
+ next: (i, accumulator) => __awaiter(this, void 0, void 0, function* () {
11003
+ const result = yield config.make(i, accumulator);
11004
+ accumulator.push(result);
11005
+ return accumulator;
11006
+ })
11007
+ });
11008
+ }
11009
+ function performBatchLoop(config) {
11010
+ const {
11011
+ make
11012
+ } = config;
11013
+ const calc = batchCalc(config);
11014
+ const {
11015
+ batchCount
11016
+ } = calc;
11017
+ return performMakeLoop({
11018
+ count: batchCount,
11019
+ make: (i, made) => __awaiter(this, void 0, void 0, function* () {
11020
+ const itemsToMake = itemCountForBatchIndex(i, calc);
11021
+ const batch = yield make(itemsToMake, i, made);
11022
+ return batch;
11023
+ })
11024
+ });
11025
+ }
11026
+
11027
+ /**
11028
+ * Creates an IdBatchFactory
11029
+ *
11030
+ * @param config
11031
+ * @returns
11032
+ */
11033
+ function idBatchFactory(config) {
11034
+ const {
11035
+ factory,
11036
+ verifier
11037
+ } = config;
11038
+ const {
11039
+ maxBatchSize: tagsToGeneratePerBatch,
11040
+ filterUnique = x => x,
11041
+ verify: verifyTags
11042
+ } = verifier;
11043
+ const maxUniquenessFailures = 20; // arbitrary failure point, but generally shouldn't occur with proper input.
11044
+ return totalTagIdentifiersToGenerate => __awaiter(this, void 0, void 0, function* () {
11045
+ const uniquenessAccumulator = []; // used for uniqueness checks
11046
+ function generateIdentifiersBatch(batchSize) {
11047
+ return __awaiter(this, void 0, void 0, function* () {
11048
+ let ids = [];
11049
+ let uniquenessFailure = 0;
11050
+ while (ids.length < batchSize) {
11051
+ const countToGenerate = batchSize - ids.length;
11052
+ let newIds = filterUnique(factory(countToGenerate), uniquenessAccumulator);
11053
+ if (newIds.length === 0) {
11054
+ uniquenessFailure += 1;
11055
+ if (uniquenessFailure === maxUniquenessFailures) {
11056
+ throw new Error(`idBatchFactory failed generating unique values "${maxUniquenessFailures}" times. Factory may be insufficient for generating unique values.`);
11057
+ }
11058
+ continue;
11059
+ } else if (newIds.length > countToGenerate) {
11060
+ newIds = newIds.slice(0, countToGenerate); // ignore any extra values the generator may return.
11061
+ }
11062
+ // add to the uniqueness acumulator to prevent further usage
11063
+ mergeArraysIntoArray(uniquenessAccumulator, newIds);
11064
+ const verifiedIds = yield verifyTags(newIds);
11065
+ // concat identifiers
11066
+ ids = ids.concat(verifiedIds);
11067
+ // restart loop if there are still items to be generated.
11068
+ }
11069
+
11070
+ return ids;
11071
+ });
11072
+ }
11073
+ const tagBatches = yield performBatchLoop({
11074
+ totalItems: totalTagIdentifiersToGenerate,
11075
+ itemsPerBatch: tagsToGeneratePerBatch,
11076
+ make: batchSize => __awaiter(this, void 0, void 0, function* () {
11077
+ const result = yield generateIdentifiersBatch(batchSize);
11078
+ return result;
11079
+ })
11080
+ });
11081
+ return tagBatches.flat();
11082
+ });
11083
+ }
11084
+
11085
+ /**
11086
+ * Creates a Map of the PrimativeKeyDencoder values.
11087
+ *
11088
+ * If any repeat values are found, an error will be thrown.
11089
+ *
11090
+ * @param values
11091
+ */
11092
+ function primativeKeyDencoderMap(values) {
11093
+ const map = new Map();
11094
+ let valuesArray;
11095
+ if (!Array.isArray(values)) {
11096
+ valuesArray = [];
11097
+ forEachKeyValue(values, {
11098
+ forEach: pair => {
11099
+ valuesArray.push(pair);
11100
+ },
11101
+ filter: exports.KeyValueTypleValueFilter.UNDEFINED
11102
+ });
11103
+ } else {
11104
+ valuesArray = values;
11105
+ }
11106
+ valuesArray.forEach(value => {
11107
+ const [d, e] = value;
11108
+ if (map.has(d) || map.has(e)) {
11109
+ throw new Error(`primativeKeyDencoderMap() encountered a repeat key/value: ${d}/${e}. Keys and values must be unique.`);
11110
+ }
11111
+ map.set(d, e);
11112
+ map.set(e, d);
11113
+ });
11114
+ map._tuples = valuesArray;
11115
+ return map;
11116
+ }
11117
+ const PRIMATIVE_KEY_DENCODER_VALUE = input => null;
11118
+ /**
11119
+ * Creates a new PrimiativeKeyDencoder.
11120
+ */
11121
+ function primativeKeyDencoder(config) {
11122
+ const {
11123
+ defaultValue = PRIMATIVE_KEY_DENCODER_VALUE
11124
+ } = config;
11125
+ const map = primativeKeyDencoderMap(config.values);
11126
+ const fn = input => {
11127
+ if (Array.isArray(input)) {
11128
+ const values = filterMaybeValues(input.map(x => map.get(x)));
11129
+ return values;
11130
+ } else {
11131
+ let value = map.get(input);
11132
+ if (value == null) {
11133
+ value = defaultValue(input);
11134
+ if (value == null) {
11135
+ throw new Error(`Encountered unknown value ${input} in primativeKeyDencoder.`);
11136
+ }
11137
+ }
11138
+ return value;
11139
+ }
11140
+ };
11141
+ fn._map = map;
11142
+ return fn;
11143
+ }
11144
+ /**
11145
+ * Creates a new PrimativeKeyStringDencoderFunction.
11146
+ *
11147
+ * @param config
11148
+ * @returns
11149
+ */
11150
+ function primativeKeyStringDencoder(config) {
11151
+ const dencoder = typeof config.dencoder === 'function' ? config.dencoder : primativeKeyDencoder(config.dencoder);
11152
+ const {
11153
+ splitter
11154
+ } = config;
11155
+ const {
11156
+ _map: dencoderMap
11157
+ } = dencoder;
11158
+ if (splitter) {
11159
+ dencoderMap._tuples.forEach(x => {
11160
+ if (x[0].toString().indexOf(splitter) !== -1) {
11161
+ throw new Error(`primativeKeyStringDencoder() encountered a value (${x[0]}) that contains the splitter (${splitter}).`);
11162
+ }
11163
+ });
11164
+ } else {
11165
+ // Assert all encoded values are 1 character long max.
11166
+ dencoderMap._tuples.forEach(x => {
11167
+ if (x[0].toString().length !== 1) {
11168
+ throw new Error(`primativeKeyStringDencoder() without a splitter defined cannot use encoded values of a length greater than 1. Encountered encoded "${x[0]}".`);
11169
+ }
11170
+ });
11171
+ }
11172
+ const joiner = splitter || '';
11173
+ const splitEncodedValues = splitter ? encodedValues => encodedValues.split(splitter) : encodedValues => Array.from(encodedValues);
11174
+ return input => {
11175
+ if (typeof input === 'string') {
11176
+ const split = splitEncodedValues(input);
11177
+ return dencoder(split);
11178
+ } else {
11179
+ const encoded = dencoder(input);
11180
+ return encoded.join(joiner);
11181
+ }
11182
+ };
10443
11183
  }
10444
-
10445
- /*eslint @typescript-eslint/no-explicit-any:"off"*/
10446
- // any is used with intent here. using unknown can have strange effects in usage of forwardFunction and type capture.
10447
11184
  /**
10448
- * Wraps a Getter that returns a function. When the function is invoked, the getter retrieves the function then calls it with the input arguments.
11185
+ * Default 64 NumberStringDencoderDigits value.
11186
+ */
11187
+ const NUMBER_STRING_DENCODER_64_DIGITS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_';
11188
+ /**
11189
+ * The default negative prefix for negative numbers.
11190
+ */
11191
+ const NUMBER_STRING_DENCODER_64_DEFAULT_NEGATIVE_PREFIX = '!';
11192
+ /**
11193
+ * Creates an integer-type NumberStringDencoder.
10449
11194
  *
10450
- * @param getter
11195
+ * If the config does not include a negative prefix, any negative number will be treated like a positive number.
11196
+ *
11197
+ * @param config
10451
11198
  * @returns
10452
11199
  */
10453
- function forwardFunction(getter) {
10454
- const fn = (...args) => {
10455
- const forwardFn = getter();
10456
- return forwardFn(...args);
11200
+ function numberStringDencoder(config) {
11201
+ const {
11202
+ negativePrefix,
11203
+ digits
11204
+ } = config;
11205
+ const type = negativePrefix ? 'integer' : 'positive_integer';
11206
+ const log2OfDigits = Math.min(6, Math.floor(Math.log2(digits.length))); // essentially the number of bits. Floor to round. Max of 6=64bits
11207
+ const bitDepth = Math.pow(2, log2OfDigits);
11208
+ const bitMask = bitDepth - 1;
11209
+ const digitsLookup = stringCharactersToIndexRecord(digits);
11210
+ function encodeNumber(number) {
11211
+ let result = '';
11212
+ const isNegativeNumber = number < 0;
11213
+ if (isNegativeNumber) {
11214
+ number = -number;
11215
+ }
11216
+ do {
11217
+ const index = number & bitMask;
11218
+ result = digits[index] + result; // Little-endian
11219
+ number >>>= log2OfDigits;
11220
+ } while (number !== 0);
11221
+ if (isNegativeNumber && negativePrefix) {
11222
+ result = negativePrefix + result;
11223
+ }
11224
+ return result;
11225
+ }
11226
+ function decodeNumber(encodedNumber) {
11227
+ let isNegativeNumber = false;
11228
+ if (encodedNumber[0] === negativePrefix) {
11229
+ isNegativeNumber = true;
11230
+ }
11231
+ const startAtIndex = isNegativeNumber ? 1 : 0;
11232
+ let result = 0;
11233
+ for (let i = startAtIndex; i < encodedNumber.length; i += 1) {
11234
+ result = (result << log2OfDigits) + digitsLookup[encodedNumber[i]];
11235
+ }
11236
+ if (isNegativeNumber) {
11237
+ result = -result;
11238
+ }
11239
+ return result;
11240
+ }
11241
+ return {
11242
+ type,
11243
+ digits,
11244
+ bitDepth,
11245
+ negativePrefix,
11246
+ encodeNumber,
11247
+ decodeNumber
11248
+ };
11249
+ }
11250
+ const NUMBER_STRING_DENCODER_64 = numberStringDencoder({
11251
+ negativePrefix: NUMBER_STRING_DENCODER_64_DEFAULT_NEGATIVE_PREFIX,
11252
+ digits: NUMBER_STRING_DENCODER_64_DIGITS
11253
+ });
11254
+ function numberStringDencoderFunction(dencoder) {
11255
+ const fn = input => {
11256
+ const result = typeof input === 'number' ? dencoder.encodeNumber(input) : dencoder.decodeNumber(input);
11257
+ return result;
10457
11258
  };
10458
11259
  return fn;
10459
11260
  }
10460
- function defaultForwardFunctionFactory(defaultFn) {
10461
- return fn => forwardFunction(() => fn !== null && fn !== void 0 ? fn : defaultFn);
11261
+ function numberStringDencoderEncodedStringValueFunction(dencoder) {
11262
+ return input => {
11263
+ return typeof input === 'number' ? dencoder.encodeNumber(input) : input;
11264
+ };
10462
11265
  }
11266
+ function numberStringDencoderDecodedNumberValueFunction(dencoder) {
11267
+ return input => {
11268
+ return typeof input === 'number' ? input : dencoder.decodeNumber(input);
11269
+ };
11270
+ }
11271
+ // TODO: can add a function that can encode/decode fractions by splitting at the decimal point and encoding twice.
10463
11272
 
10464
11273
  /**
10465
- * A function that returns the input value.
10466
- *
10467
- * Is an alias of the mapIdentityFunction, so it will return true when passed to isMapIdentityFunction().
10468
- *
10469
- * @param input
10470
- * @returns
10471
- */
10472
- const passThrough = MAP_IDENTITY;
10473
-
10474
- /**
10475
- * Builds an array from intersection of the input object and input keys that correspond to values that should be part of the result.
10476
- *
10477
- * @param object
10478
- * @param keys
10479
- * @returns
11274
+ * Creates a ModelIdFactory that generates sequential incrementing encoded NumberStringDencoderString values using the input configuration.
10480
11275
  */
10481
- function mapKeysIntersectionObjectToArray(object, keys) {
10482
- const keysToApply = Array.from(keys);
10483
- const applyArray = [];
10484
- keysToApply.forEach(key => {
10485
- const values = object[key];
10486
- if (values != null) {
10487
- pushItemOrArrayItemsIntoArray(applyArray, values);
10488
- }
11276
+ function sequentialIncrementingNumberStringModelIdFactory(config = {}) {
11277
+ const {
11278
+ transform: inputTranformFunction,
11279
+ dencoder: inputDencoder,
11280
+ currentIndex,
11281
+ startAt: inputStartAt,
11282
+ increaseBy: inputIncreaseBy
11283
+ } = config;
11284
+ if (inputIncreaseBy === 0) {
11285
+ throw new Error('Cannot use 0 for increaseBy.');
11286
+ }
11287
+ const increaseBy = inputIncreaseBy !== null && inputIncreaseBy !== void 0 ? inputIncreaseBy : 1;
11288
+ const dencoder = inputDencoder !== null && inputDencoder !== void 0 ? inputDencoder : NUMBER_STRING_DENCODER_64;
11289
+ const dencoderNumberValue = numberStringDencoderDecodedNumberValueFunction(dencoder);
11290
+ const startAtFromCurrentIndex = currentIndex != null ? dencoderNumberValue(currentIndex) + increaseBy : undefined;
11291
+ const startAt = inputStartAt != null ? dencoderNumberValue(inputStartAt) : startAtFromCurrentIndex !== null && startAtFromCurrentIndex !== void 0 ? startAtFromCurrentIndex : 0;
11292
+ const transform = inputTranformFunction !== null && inputTranformFunction !== void 0 ? inputTranformFunction : mapIdentityFunction();
11293
+ const numberFactory = incrementingNumberFactory({
11294
+ startAt,
11295
+ increaseBy
10489
11296
  });
10490
- return applyArray;
11297
+ return () => {
11298
+ const nextIndex = numberFactory();
11299
+ const next = dencoder.encodeNumber(nextIndex);
11300
+ return transform(next, nextIndex);
11301
+ };
10491
11302
  }
10492
11303
 
10493
11304
  /**
@@ -10801,304 +11612,77 @@ function toModelMapFunctions(input) {
10801
11612
  mapFunctions = makeModelMapFunctions(conversions);
10802
11613
  }
10803
11614
  return mapFunctions;
10804
- }
10805
-
10806
- /**
10807
- * Field conversion that copies the same value across.
10808
- *
10809
- * @param defaultValue
10810
- * @returns
10811
- */
10812
- function copyField(defaultOutput) {
10813
- return {
10814
- from: {
10815
- default: defaultOutput,
10816
- convert: x => x
10817
- },
10818
- to: {
10819
- default: defaultOutput,
10820
- convert: x => x
10821
- }
10822
- };
10823
- }
10824
-
10825
- function maybeMergeModelModifiers(input) {
10826
- const modifiers = asArray(input);
10827
- const allModifyData = filterMaybeValues(modifiers.map(x => x.modifyData));
10828
- const allModifyModel = filterMaybeValues(modifiers.map(x => x.modifyModel));
10829
- const modifyData = maybeMergeModifiers(allModifyData);
10830
- const modifyModel = maybeMergeModifiers(allModifyModel);
10831
- return {
10832
- modifyData,
10833
- modifyModel
10834
- };
10835
- }
10836
- function modifyModelMapFunctions(config) {
10837
- const {
10838
- copy,
10839
- copyModel = copy,
10840
- copyData = copy,
10841
- mapFunctions,
10842
- modifiers
10843
- } = config;
10844
- const {
10845
- from,
10846
- to
10847
- } = mapFunctions;
10848
- const {
10849
- modifyData,
10850
- modifyModel
10851
- } = maybeMergeModelModifiers(modifiers);
10852
- const modifyFrom = modifyModelMapFunction(from, modifyData, copyData);
10853
- const modifyTo = modifyModelMapFunction(to, modifyModel, copyModel);
10854
- return {
10855
- from: modifyFrom,
10856
- to: modifyTo
10857
- };
10858
- }
10859
- /**
10860
- * Merges a ModifierFunction with a ModelMapFunction
10861
- *
10862
- * @param mapFn
10863
- * @param modifyModel
10864
- * @param copy
10865
- * @returns
10866
- */
10867
- function modifyModelMapFunction(mapFn, modifyModel, copy = true) {
10868
- return modifyModel ? (input, target, options) => {
10869
- const inputToMap = copy && input != null ? Object.assign({}, input) : input;
10870
- if (inputToMap != null) {
10871
- modifyModel(inputToMap);
10872
- }
10873
- return mapFn(inputToMap, target, options);
10874
- } : mapFn;
10875
- }
10876
-
10877
- var $TypeError$5 = TypeError;
10878
- var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; // 2 ** 53 - 1 == 9007199254740991
10879
-
10880
- var doesNotExceedSafeInteger$1 = function (it) {
10881
- if (it > MAX_SAFE_INTEGER) throw $TypeError$5('Maximum allowed index exceeded');
10882
- return it;
10883
- };
10884
-
10885
- var uncurryThis = functionUncurryThisClause;
10886
- var aCallable$5 = aCallable$a;
10887
- var NATIVE_BIND = functionBindNative;
10888
-
10889
- var bind$5 = uncurryThis(uncurryThis.bind);
10890
-
10891
- // optional / simple context binding
10892
- var functionBindContext = function (fn, that) {
10893
- aCallable$5(fn);
10894
- return that === undefined ? fn : NATIVE_BIND ? bind$5(fn, that) : function (/* ...args */) {
10895
- return fn.apply(that, arguments);
10896
- };
10897
- };
10898
-
10899
- var isArray$1 = isArray$3;
10900
- var lengthOfArrayLike$2 = lengthOfArrayLike$6;
10901
- var doesNotExceedSafeInteger = doesNotExceedSafeInteger$1;
10902
- var bind$4 = functionBindContext;
10903
-
10904
- // `FlattenIntoArray` abstract operation
10905
- // https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray
10906
- var flattenIntoArray$1 = function (target, original, source, sourceLen, start, depth, mapper, thisArg) {
10907
- var targetIndex = start;
10908
- var sourceIndex = 0;
10909
- var mapFn = mapper ? bind$4(mapper, thisArg) : false;
10910
- var element, elementLen;
10911
-
10912
- while (sourceIndex < sourceLen) {
10913
- if (sourceIndex in source) {
10914
- element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex];
10915
-
10916
- if (depth > 0 && isArray$1(element)) {
10917
- elementLen = lengthOfArrayLike$2(element);
10918
- targetIndex = flattenIntoArray$1(target, original, element, elementLen, targetIndex, depth - 1) - 1;
10919
- } else {
10920
- doesNotExceedSafeInteger(targetIndex + 1);
10921
- target[targetIndex] = element;
10922
- }
10923
-
10924
- targetIndex++;
10925
- }
10926
- sourceIndex++;
10927
- }
10928
- return targetIndex;
10929
- };
10930
-
10931
- var flattenIntoArray_1 = flattenIntoArray$1;
10932
-
10933
- var isArray = isArray$3;
10934
- var isConstructor = isConstructor$2;
10935
- var isObject$2 = isObject$c;
10936
- var wellKnownSymbol$4 = wellKnownSymbol$k;
10937
-
10938
- var SPECIES$1 = wellKnownSymbol$4('species');
10939
- var $Array = Array;
10940
-
10941
- // a part of `ArraySpeciesCreate` abstract operation
10942
- // https://tc39.es/ecma262/#sec-arrayspeciescreate
10943
- var arraySpeciesConstructor$1 = function (originalArray) {
10944
- var C;
10945
- if (isArray(originalArray)) {
10946
- C = originalArray.constructor;
10947
- // cross-realm fallback
10948
- if (isConstructor(C) && (C === $Array || isArray(C.prototype))) C = undefined;
10949
- else if (isObject$2(C)) {
10950
- C = C[SPECIES$1];
10951
- if (C === null) C = undefined;
10952
- }
10953
- } return C === undefined ? $Array : C;
10954
- };
10955
-
10956
- var arraySpeciesConstructor = arraySpeciesConstructor$1;
10957
-
10958
- // `ArraySpeciesCreate` abstract operation
10959
- // https://tc39.es/ecma262/#sec-arrayspeciescreate
10960
- var arraySpeciesCreate$1 = function (originalArray, length) {
10961
- return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
10962
- };
10963
-
10964
- var $$6 = _export;
10965
- var flattenIntoArray = flattenIntoArray_1;
10966
- var toObject = toObject$7;
10967
- var lengthOfArrayLike$1 = lengthOfArrayLike$6;
10968
- var toIntegerOrInfinity = toIntegerOrInfinity$7;
10969
- var arraySpeciesCreate = arraySpeciesCreate$1;
10970
-
10971
- // `Array.prototype.flat` method
10972
- // https://tc39.es/ecma262/#sec-array.prototype.flat
10973
- $$6({ target: 'Array', proto: true }, {
10974
- flat: function flat(/* depthArg = 1 */) {
10975
- var depthArg = arguments.length ? arguments[0] : undefined;
10976
- var O = toObject(this);
10977
- var sourceLen = lengthOfArrayLike$1(O);
10978
- var A = arraySpeciesCreate(O, 0);
10979
- A.length = flattenIntoArray(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toIntegerOrInfinity(depthArg));
10980
- return A;
10981
- }
10982
- });
10983
-
10984
- // this method was added to unscopables after implementation
10985
- // in popular engines, so it's moved to a separate module
10986
- var addToUnscopables = addToUnscopables$2;
10987
-
10988
- // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
10989
- addToUnscopables('flat');
11615
+ }
10990
11616
 
10991
- function performTaskLoop(config) {
10992
- return __awaiter(this, void 0, void 0, function* () {
10993
- let result;
10994
- const initValue = config.initValue;
10995
- const startLoop = initValue == null || (yield config.checkContinue(initValue, -1));
10996
- if (startLoop) {
10997
- let i = 0;
10998
- let prevValue = initValue;
10999
- let check;
11000
- do {
11001
- prevValue = yield config.next(i, prevValue);
11002
- i += 1;
11003
- check = yield config.checkContinue(prevValue, i);
11004
- } while (check);
11005
- result = prevValue;
11006
- } else {
11007
- result = initValue;
11617
+ /**
11618
+ * Field conversion that copies the same value across.
11619
+ *
11620
+ * @param defaultValue
11621
+ * @returns
11622
+ */
11623
+ function copyField(defaultOutput) {
11624
+ return {
11625
+ from: {
11626
+ default: defaultOutput,
11627
+ convert: x => x
11628
+ },
11629
+ to: {
11630
+ default: defaultOutput,
11631
+ convert: x => x
11008
11632
  }
11009
- return result;
11010
- });
11011
- }
11012
- function performTaskCountLoop(config) {
11013
- return performTaskLoop(Object.assign(Object.assign({}, config), {
11014
- checkContinue: (_, i) => i < config.count
11015
- }));
11633
+ };
11016
11634
  }
11017
- function performMakeLoop(config) {
11018
- return performTaskCountLoop({
11019
- count: config.count,
11020
- initValue: [],
11021
- next: (i, accumulator) => __awaiter(this, void 0, void 0, function* () {
11022
- const result = yield config.make(i, accumulator);
11023
- accumulator.push(result);
11024
- return accumulator;
11025
- })
11026
- });
11635
+
11636
+ function maybeMergeModelModifiers(input) {
11637
+ const modifiers = asArray(input);
11638
+ const allModifyData = filterMaybeValues(modifiers.map(x => x.modifyData));
11639
+ const allModifyModel = filterMaybeValues(modifiers.map(x => x.modifyModel));
11640
+ const modifyData = maybeMergeModifiers(allModifyData);
11641
+ const modifyModel = maybeMergeModifiers(allModifyModel);
11642
+ return {
11643
+ modifyData,
11644
+ modifyModel
11645
+ };
11027
11646
  }
11028
- function performBatchLoop(config) {
11647
+ function modifyModelMapFunctions(config) {
11029
11648
  const {
11030
- make
11649
+ copy,
11650
+ copyModel = copy,
11651
+ copyData = copy,
11652
+ mapFunctions,
11653
+ modifiers
11031
11654
  } = config;
11032
- const calc = batchCalc(config);
11033
11655
  const {
11034
- batchCount
11035
- } = calc;
11036
- return performMakeLoop({
11037
- count: batchCount,
11038
- make: (i, made) => __awaiter(this, void 0, void 0, function* () {
11039
- const itemsToMake = itemCountForBatchIndex(i, calc);
11040
- const batch = yield make(itemsToMake, i, made);
11041
- return batch;
11042
- })
11043
- });
11656
+ from,
11657
+ to
11658
+ } = mapFunctions;
11659
+ const {
11660
+ modifyData,
11661
+ modifyModel
11662
+ } = maybeMergeModelModifiers(modifiers);
11663
+ const modifyFrom = modifyModelMapFunction(from, modifyData, copyData);
11664
+ const modifyTo = modifyModelMapFunction(to, modifyModel, copyModel);
11665
+ return {
11666
+ from: modifyFrom,
11667
+ to: modifyTo
11668
+ };
11044
11669
  }
11045
-
11046
11670
  /**
11047
- * Creates an IdBatchFactory
11671
+ * Merges a ModifierFunction with a ModelMapFunction
11048
11672
  *
11049
- * @param config
11673
+ * @param mapFn
11674
+ * @param modifyModel
11675
+ * @param copy
11050
11676
  * @returns
11051
11677
  */
11052
- function idBatchFactory(config) {
11053
- const {
11054
- factory,
11055
- verifier
11056
- } = config;
11057
- const {
11058
- maxBatchSize: tagsToGeneratePerBatch,
11059
- filterUnique = x => x,
11060
- verify: verifyTags
11061
- } = verifier;
11062
- const maxUniquenessFailures = 20; // arbitrary failure point, but generally shouldn't occur with proper input.
11063
- return totalTagIdentifiersToGenerate => __awaiter(this, void 0, void 0, function* () {
11064
- const uniquenessAccumulator = []; // used for uniqueness checks
11065
- function generateIdentifiersBatch(batchSize) {
11066
- return __awaiter(this, void 0, void 0, function* () {
11067
- let ids = [];
11068
- let uniquenessFailure = 0;
11069
- while (ids.length < batchSize) {
11070
- const countToGenerate = batchSize - ids.length;
11071
- let newIds = filterUnique(factory(countToGenerate), uniquenessAccumulator);
11072
- if (newIds.length === 0) {
11073
- uniquenessFailure += 1;
11074
- if (uniquenessFailure === maxUniquenessFailures) {
11075
- throw new Error(`idBatchFactory failed generating unique values "${maxUniquenessFailures}" times. Factory may be insufficient for generating unique values.`);
11076
- }
11077
- continue;
11078
- } else if (newIds.length > countToGenerate) {
11079
- newIds = newIds.slice(0, countToGenerate); // ignore any extra values the generator may return.
11080
- }
11081
- // add to the uniqueness acumulator to prevent further usage
11082
- mergeArraysIntoArray(uniquenessAccumulator, newIds);
11083
- const verifiedIds = yield verifyTags(newIds);
11084
- // concat identifiers
11085
- ids = ids.concat(verifiedIds);
11086
- // restart loop if there are still items to be generated.
11087
- }
11088
-
11089
- return ids;
11090
- });
11678
+ function modifyModelMapFunction(mapFn, modifyModel, copy = true) {
11679
+ return modifyModel ? (input, target, options) => {
11680
+ const inputToMap = copy && input != null ? Object.assign({}, input) : input;
11681
+ if (inputToMap != null) {
11682
+ modifyModel(inputToMap);
11091
11683
  }
11092
- const tagBatches = yield performBatchLoop({
11093
- totalItems: totalTagIdentifiersToGenerate,
11094
- itemsPerBatch: tagsToGeneratePerBatch,
11095
- make: batchSize => __awaiter(this, void 0, void 0, function* () {
11096
- const result = yield generateIdentifiersBatch(batchSize);
11097
- return result;
11098
- })
11099
- });
11100
- return tagBatches.flat();
11101
- });
11684
+ return mapFn(inputToMap, target, options);
11685
+ } : mapFn;
11102
11686
  }
11103
11687
 
11104
11688
  var isPrototypeOf$1 = objectIsPrototypeOf;
@@ -12985,150 +13569,50 @@ class MemoryStorageInstance {
12985
13569
  if (!this.hasKey(key)) {
12986
13570
  this._length = this._length + 1;
12987
13571
  }
12988
- this._storage[key] = String(item);
12989
- }
12990
- }
12991
- removeItem(key) {
12992
- if (this.hasKey(key)) {
12993
- delete this._storage[key]; // Remove the property
12994
- this._length = this._length - 1;
12995
- }
12996
- }
12997
- clear() {
12998
- this._storage = {};
12999
- this._length = 0;
13000
- }
13001
- }
13002
- const SHARED_MEMORY_STORAGE = new MemoryStorageInstance();
13003
-
13004
- /**
13005
- * Limited Class/Interface for storing string values synchronously.
13006
- */
13007
- class SimpleStorageObject {}
13008
- /**
13009
- * Synchronous Class/Interface for storing string values.
13010
- *
13011
- * Has the same interface as localStorage for the web.
13012
- */
13013
- class StorageObject extends SimpleStorageObject {}
13014
- class FullStorageObject extends StorageObject {}
13015
- class StorageObjectUtility {
13016
- static allKeysFromStorageObject(storageObject, prefix) {
13017
- const length = storageObject.length;
13018
- let result;
13019
- if (length > 0) {
13020
- result = range({
13021
- start: 0,
13022
- end: length
13023
- }).map(x => storageObject.key(x)).filter(hasNonNullValue);
13024
- if (prefix) {
13025
- result = result.filter(x => x.startsWith(prefix));
13026
- }
13027
- } else {
13028
- result = [];
13029
- }
13030
- return result;
13031
- }
13032
- }
13033
-
13034
- /**
13035
- * Creates a Map of the PrimativeKeyDencoder values.
13036
- *
13037
- * If any repeat values are found, an error will be thrown.
13038
- *
13039
- * @param values
13040
- */
13041
- function primativeKeyDencoderMap(values) {
13042
- const map = new Map();
13043
- let valuesArray;
13044
- if (!Array.isArray(values)) {
13045
- valuesArray = [];
13046
- forEachKeyValue(values, {
13047
- forEach: pair => {
13048
- valuesArray.push(pair);
13049
- },
13050
- filter: exports.KeyValueTypleValueFilter.UNDEFINED
13051
- });
13052
- } else {
13053
- valuesArray = values;
13054
- }
13055
- valuesArray.forEach(value => {
13056
- const [d, e] = value;
13057
- if (map.has(d) || map.has(e)) {
13058
- throw new Error(`primativeKeyDencoderMap() encountered a repeat key/value: ${d}/${e}. Keys and values must be unique.`);
13059
- }
13060
- map.set(d, e);
13061
- map.set(e, d);
13062
- });
13063
- map._tuples = valuesArray;
13064
- return map;
13065
- }
13066
- const PRIMATIVE_KEY_DENCODER_VALUE = input => null;
13067
- /**
13068
- * Creates a new PrimiativeKeyDencoder.
13069
- */
13070
- function primativeKeyDencoder(config) {
13071
- const {
13072
- defaultValue = PRIMATIVE_KEY_DENCODER_VALUE
13073
- } = config;
13074
- const map = primativeKeyDencoderMap(config.values);
13075
- const fn = input => {
13076
- if (Array.isArray(input)) {
13077
- const values = filterMaybeValues(input.map(x => map.get(x)));
13078
- return values;
13079
- } else {
13080
- let value = map.get(input);
13081
- if (value == null) {
13082
- value = defaultValue(input);
13083
- if (value == null) {
13084
- throw new Error(`Encountered unknown value ${input} in primativeKeyDencoder.`);
13085
- }
13086
- }
13087
- return value;
13572
+ this._storage[key] = String(item);
13088
13573
  }
13089
- };
13090
- fn._map = map;
13091
- return fn;
13574
+ }
13575
+ removeItem(key) {
13576
+ if (this.hasKey(key)) {
13577
+ delete this._storage[key]; // Remove the property
13578
+ this._length = this._length - 1;
13579
+ }
13580
+ }
13581
+ clear() {
13582
+ this._storage = {};
13583
+ this._length = 0;
13584
+ }
13092
13585
  }
13586
+ const SHARED_MEMORY_STORAGE = new MemoryStorageInstance();
13587
+
13093
13588
  /**
13094
- * Creates a new PrimativeKeyStringDencoderFunction.
13589
+ * Limited Class/Interface for storing string values synchronously.
13590
+ */
13591
+ class SimpleStorageObject {}
13592
+ /**
13593
+ * Synchronous Class/Interface for storing string values.
13095
13594
  *
13096
- * @param config
13097
- * @returns
13595
+ * Has the same interface as localStorage for the web.
13098
13596
  */
13099
- function primativeKeyStringDencoder(config) {
13100
- const dencoder = typeof config.dencoder === 'function' ? config.dencoder : primativeKeyDencoder(config.dencoder);
13101
- const {
13102
- splitter
13103
- } = config;
13104
- const {
13105
- _map: dencoderMap
13106
- } = dencoder;
13107
- if (splitter) {
13108
- dencoderMap._tuples.forEach(x => {
13109
- if (x[0].toString().indexOf(splitter) !== -1) {
13110
- throw new Error(`primativeKeyStringDencoder() encountered a value (${x[0]}) that contains the splitter (${splitter}).`);
13111
- }
13112
- });
13113
- } else {
13114
- // Assert all encoded values are 1 character long max.
13115
- dencoderMap._tuples.forEach(x => {
13116
- if (x[0].toString().length !== 1) {
13117
- throw new Error(`primativeKeyStringDencoder() without a splitter defined cannot use encoded values of a length greater than 1. Encountered encoded "${x[0]}".`);
13597
+ class StorageObject extends SimpleStorageObject {}
13598
+ class FullStorageObject extends StorageObject {}
13599
+ class StorageObjectUtility {
13600
+ static allKeysFromStorageObject(storageObject, prefix) {
13601
+ const length = storageObject.length;
13602
+ let result;
13603
+ if (length > 0) {
13604
+ result = range({
13605
+ start: 0,
13606
+ end: length
13607
+ }).map(x => storageObject.key(x)).filter(hasNonNullValue);
13608
+ if (prefix) {
13609
+ result = result.filter(x => x.startsWith(prefix));
13118
13610
  }
13119
- });
13120
- }
13121
- const joiner = splitter || '';
13122
- const splitEncodedValues = splitter ? encodedValues => encodedValues.split(splitter) : encodedValues => Array.from(encodedValues);
13123
- return input => {
13124
- if (typeof input === 'string') {
13125
- const split = splitEncodedValues(input);
13126
- return dencoder(split);
13127
13611
  } else {
13128
- const encoded = dencoder(input);
13129
- return encoded.join(joiner);
13612
+ result = [];
13130
13613
  }
13131
- };
13614
+ return result;
13615
+ }
13132
13616
  }
13133
13617
 
13134
13618
  /**
@@ -13347,154 +13831,6 @@ function randomBoolean(chance = 50) {
13347
13831
  })();
13348
13832
  }
13349
13833
 
13350
- /**
13351
- * TODO: Need to improve to support negative years.
13352
- */
13353
- const ISO_8601_DATE_STRING_REGEX = /(\d{4,})-(\d{2})-(\d{2})T(\d{2})\:(\d{2})\:(\d{2})(Z|[+-](\d{2})\:(\d{2}))?/;
13354
- function isISO8601DateString(input) {
13355
- return ISO_8601_DATE_STRING_REGEX.test(input);
13356
- }
13357
- /**
13358
- * Match examples:
13359
- *
13360
- * Sat, 03 Feb 2001 04:05:06 GMT
13361
- * Tue, 14 Mar 2023 12:34:56 UTC
13362
- * Wed, 25 May 2024 20:45:07 EST
13363
- */
13364
- const UTC_DATE_STRING_REGEX = /^([a-zA-Z]{3}, [0-9]{2} [a-zA-Z]{3} [0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2} [A-Z]{3})$/;
13365
- function isUTCDateString(input) {
13366
- return UTC_DATE_STRING_REGEX.test(input);
13367
- }
13368
- /**
13369
- * Returns true only if the inputs have the same timezone, or both do not have a timezone set.
13370
- *
13371
- * @param a
13372
- * @param b
13373
- * @returns
13374
- */
13375
- function hasSameTimezone(a, b) {
13376
- const tzA = a === null || a === void 0 ? void 0 : a.timezone;
13377
- const tzB = b === null || b === void 0 ? void 0 : b.timezone;
13378
- return valuesAreBothNullishOrEquivalent(tzA, tzB);
13379
- }
13380
- /**
13381
- * Constant for the UTC timezone string, "UTC".
13382
- */
13383
- const UTC_TIMEZONE_STRING = 'UTC';
13384
- function isConsideredUtcTimezoneString(timezone) {
13385
- return timezone == null || timezone === UTC_TIMEZONE_STRING;
13386
- }
13387
- /**
13388
- * Regex for an ISO8601DayString.
13389
- */
13390
- const ISO8601_DAY_STRING_REGEX = /^\d{4,}-\d{2}-\d{2}$/;
13391
- /**
13392
- * Regex for a string that starts as an ISO8601DayString.
13393
- */
13394
- const ISO8601_DAY_STRING_START_REGEX = /^\d{4,}-\d{2}-\d{2}/;
13395
- /**
13396
- * Returns the start of the input date's UTC time in UTC.
13397
- *
13398
- * I.E. 2022-01-02T04:00:00.000Z in GMT-6 returns 2022-01-02
13399
- *
13400
- * @param date
13401
- * @returns
13402
- */
13403
- function startOfDayForUTCDateInUTC(date) {
13404
- return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()));
13405
- }
13406
- /**
13407
- * Returns the system's date in UTC.
13408
- *
13409
- * I.E. 2022-01-02T04:00:00.000Z in GMT-6 (10PM Jan 1st CST) returns 2022-01-01
13410
- *
13411
- * @param date
13412
- * @returns
13413
- */
13414
- function startOfDayForSystemDateInUTC(date) {
13415
- return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
13416
- }
13417
- /**
13418
- * Parses a ISO8601DayString to a Date.
13419
- *
13420
- * @param inputDateString
13421
- * @returns
13422
- */
13423
- function parseISO8601DayStringToUTCDate(inputDateString) {
13424
- const [yearString, monthString, dateString] = inputDateString.split('-');
13425
- return new Date(Date.UTC(Number(yearString), Number(monthString) - 1, Number(dateString)));
13426
- }
13427
- /**
13428
- * Returns true if the input date is strictly a
13429
- * @param input
13430
- * @returns
13431
- */
13432
- function isISO8601DayString(input) {
13433
- return ISO8601_DAY_STRING_REGEX.test(input);
13434
- }
13435
- function isISO8601DayStringStart(input) {
13436
- return ISO8601_DAY_STRING_START_REGEX.test(input);
13437
- }
13438
- /**
13439
- * Regex for a MonthDaySlashDate.
13440
- */
13441
- const MONTH_DAY_SLASH_DATE_STRING_REGEX = /^\d{1,2}\/\d{1,2}\/\d+$/;
13442
- function isMonthDaySlashDate(input) {
13443
- return MONTH_DAY_SLASH_DATE_STRING_REGEX.test(input);
13444
- }
13445
- /**
13446
- * Converts the input MonthDaySlashDate to an ISO8601DayString.
13447
- *
13448
- * @param slashDate
13449
- * @returns
13450
- */
13451
- function monthDaySlashDateToDateString(slashDate) {
13452
- let [month, day, year] = slashDate.split('/');
13453
- if (month.length === 1) {
13454
- month = `0${month}`;
13455
- }
13456
- if (day.length === 1) {
13457
- day = `0${day}`;
13458
- }
13459
- if (year.length === 2) {
13460
- year = `20${year}`;
13461
- }
13462
- const result = `${year}-${month}-${day}`;
13463
- return result;
13464
- }
13465
- const HOURS_IN_DAY = 24;
13466
- const SECONDS_IN_MINUTE = 60;
13467
- const MINUTES_IN_DAY = 1440;
13468
- const MINUTES_IN_HOUR = 60;
13469
- const MS_IN_SECOND = 1000;
13470
- const MS_IN_MINUTE = MS_IN_SECOND * 60;
13471
- const MS_IN_HOUR = MS_IN_MINUTE * 60;
13472
- const MS_IN_DAY = MS_IN_HOUR * HOURS_IN_DAY;
13473
- /**
13474
- * Retrieves the MonthOfYear value from the input Date.
13475
- *
13476
- * @param date
13477
- * @returns
13478
- */
13479
- function monthOfYearFromDate(date) {
13480
- return monthOfYearFromDateMonth(date.getMonth());
13481
- }
13482
- function monthOfYearFromDateMonth(dateMonth) {
13483
- return dateMonth + 1;
13484
- }
13485
- function makeDateMonthForMonthOfYear(monthOfYear) {
13486
- return monthOfYear - 1;
13487
- }
13488
- /**
13489
- * Returns true if the value is a date.
13490
- *
13491
- * @param value
13492
- * @returns
13493
- */
13494
- function isDate(value) {
13495
- return value instanceof Date || typeof value === 'object' && Object.prototype.toString.call(value) === '[object Date]';
13496
- }
13497
-
13498
13834
  /**
13499
13835
  * Returns the day of the week for the input day.
13500
13836
  *
@@ -13652,41 +13988,6 @@ function getNextDay(day, days = 1) {
13652
13988
  return result;
13653
13989
  }
13654
13990
 
13655
- const FRACTIONAL_HOURS_PRECISION_FUNCTION = cutValueToPrecisionFunction(3);
13656
- /**
13657
- * Converts the number of minnutes to a fractional hour.
13658
- *
13659
- * Minutes are rounded down.
13660
- */
13661
- function minutesToFractionalHours(minutes) {
13662
- return FRACTIONAL_HOURS_PRECISION_FUNCTION(Math.floor(minutes) / MINUTES_IN_HOUR);
13663
- }
13664
- /**
13665
- * Converts the fractional hour to a minute.
13666
- */
13667
- function fractionalHoursToMinutes(hours) {
13668
- return Math.round(hours * MINUTES_IN_HOUR);
13669
- }
13670
- /**
13671
- * Rounds the input hour to the nearest FractionalHour.
13672
- *
13673
- * @param hour
13674
- * @returns
13675
- */
13676
- function hourToFractionalHour(hour) {
13677
- return minutesToFractionalHours(fractionalHoursToMinutes(hour));
13678
- }
13679
- function computeNextFractionalHour(input, change) {
13680
- let result = input;
13681
- if (change.minutes) {
13682
- result += minutesToFractionalHours(change.minutes);
13683
- }
13684
- if (change.hours) {
13685
- result += hourToFractionalHour(change.hours);
13686
- }
13687
- return result;
13688
- }
13689
-
13690
13991
  function timePeriodCounter(timePeriodLength, lastTimePeriodStart) {
13691
13992
  function reset(inputStart) {
13692
13993
  const start = inputStart !== null && inputStart !== void 0 ? inputStart : new Date();
@@ -14102,6 +14403,9 @@ exports.MS_IN_SECOND = MS_IN_SECOND;
14102
14403
  exports.MemoryStorageInstance = MemoryStorageInstance;
14103
14404
  exports.ModelRelationUtility = ModelRelationUtility;
14104
14405
  exports.NOOP_MODIFIER = NOOP_MODIFIER;
14406
+ exports.NUMBER_STRING_DENCODER_64 = NUMBER_STRING_DENCODER_64;
14407
+ exports.NUMBER_STRING_DENCODER_64_DEFAULT_NEGATIVE_PREFIX = NUMBER_STRING_DENCODER_64_DEFAULT_NEGATIVE_PREFIX;
14408
+ exports.NUMBER_STRING_DENCODER_64_DIGITS = NUMBER_STRING_DENCODER_64_DIGITS;
14105
14409
  exports.PHONE_EXTENSION_NUMBER_REGEX = PHONE_EXTENSION_NUMBER_REGEX;
14106
14410
  exports.PRIMATIVE_KEY_DENCODER_VALUE = PRIMATIVE_KEY_DENCODER_VALUE;
14107
14411
  exports.PageCalculator = PageCalculator;
@@ -14176,6 +14480,7 @@ exports.asDecisionFunction = asDecisionFunction;
14176
14480
  exports.asGetter = asGetter;
14177
14481
  exports.asIndexRangeCheckFunctionConfig = asIndexRangeCheckFunctionConfig;
14178
14482
  exports.asIterable = asIterable;
14483
+ exports.asMinuteOfDay = asMinuteOfDay;
14179
14484
  exports.asNumber = asNumber;
14180
14485
  exports.asObjectCopyFactory = asObjectCopyFactory;
14181
14486
  exports.asPromise = asPromise;
@@ -14244,6 +14549,9 @@ exports.cutValueToInteger = cutValueToInteger;
14244
14549
  exports.cutValueToPrecision = cutValueToPrecision;
14245
14550
  exports.cutValueToPrecisionFunction = cutValueToPrecisionFunction;
14246
14551
  exports.dateFromLogicalDate = dateFromLogicalDate;
14552
+ exports.dateFromMinuteOfDay = dateFromMinuteOfDay;
14553
+ exports.dateToHoursAndMinutes = dateToHoursAndMinutes;
14554
+ exports.dateToMinuteOfDay = dateToMinuteOfDay;
14247
14555
  exports.dayOfWeek = dayOfWeek;
14248
14556
  exports.daysOfWeekArray = daysOfWeekArray;
14249
14557
  exports.daysOfWeekFromEnabledDays = daysOfWeekFromEnabledDays;
@@ -14469,6 +14777,7 @@ exports.isolateWebsitePathFunction = isolateWebsitePathFunction;
14469
14777
  exports.itemCountForBatchIndex = itemCountForBatchIndex;
14470
14778
  exports.iterableToArray = iterableToArray;
14471
14779
  exports.iterableToMap = iterableToMap;
14780
+ exports.iterableToSet = iterableToSet;
14472
14781
  exports.iterablesAreSetEquivalent = iterablesAreSetEquivalent;
14473
14782
  exports.iterate = iterate;
14474
14783
  exports.iterateFilteredPages = iterateFilteredPages;
@@ -14567,6 +14876,7 @@ exports.minAndMaxIndexFunction = minAndMaxIndexFunction;
14567
14876
  exports.minAndMaxIndexItemsFunction = minAndMaxIndexItemsFunction;
14568
14877
  exports.minAndMaxNumber = minAndMaxNumber;
14569
14878
  exports.minutesToFractionalHours = minutesToFractionalHours;
14879
+ exports.minutesToHoursAndMinutes = minutesToHoursAndMinutes;
14570
14880
  exports.modelFieldConversions = modelFieldConversions;
14571
14881
  exports.modelFieldMapFunction = modelFieldMapFunction;
14572
14882
  exports.modelFieldMapFunctions = modelFieldMapFunctions;
@@ -14582,6 +14892,10 @@ exports.multiKeyValueMapFactory = multiKeyValueMapFactory;
14582
14892
  exports.multiValueMapBuilder = multiValueMapBuilder;
14583
14893
  exports.neMostLatLngPoint = neMostLatLngPoint;
14584
14894
  exports.nearestDivisibleValues = nearestDivisibleValues;
14895
+ exports.numberStringDencoder = numberStringDencoder;
14896
+ exports.numberStringDencoderDecodedNumberValueFunction = numberStringDencoderDecodedNumberValueFunction;
14897
+ exports.numberStringDencoderEncodedStringValueFunction = numberStringDencoderEncodedStringValueFunction;
14898
+ exports.numberStringDencoderFunction = numberStringDencoderFunction;
14585
14899
  exports.objectCopyFactory = objectCopyFactory;
14586
14900
  exports.objectDeltaArrayCompressor = objectDeltaArrayCompressor;
14587
14901
  exports.objectFieldEqualityChecker = objectFieldEqualityChecker;
@@ -14598,6 +14912,7 @@ exports.objectToTuples = objectToTuples;
14598
14912
  exports.overlapsLatLngBoundFunction = overlapsLatLngBoundFunction;
14599
14913
  exports.overrideInObject = overrideInObject;
14600
14914
  exports.overrideInObjectFunctionFactory = overrideInObjectFunctionFactory;
14915
+ exports.padStartFunction = padStartFunction;
14601
14916
  exports.pairGroupValues = pairGroupValues;
14602
14917
  exports.parseISO8601DayStringToUTCDate = parseISO8601DayStringToUTCDate;
14603
14918
  exports.partialServerError = partialServerError;
@@ -14714,6 +15029,7 @@ exports.safeFindBestIndexMatch = safeFindBestIndexMatch;
14714
15029
  exports.searchStringFilterFunction = searchStringFilterFunction;
14715
15030
  exports.separateValues = separateValues;
14716
15031
  exports.separateValuesToSets = separateValuesToSets;
15032
+ exports.sequentialIncrementingNumberStringModelIdFactory = sequentialIncrementingNumberStringModelIdFactory;
14717
15033
  exports.serverError = serverError;
14718
15034
  exports.setContainsAllValues = setContainsAllValues;
14719
15035
  exports.setContainsAnyValue = setContainsAnyValue;
@@ -14758,6 +15074,7 @@ exports.startOfDayForSystemDateInUTC = startOfDayForSystemDateInUTC;
14758
15074
  exports.startOfDayForUTCDateInUTC = startOfDayForUTCDateInUTC;
14759
15075
  exports.stepsFromIndex = stepsFromIndex;
14760
15076
  exports.stepsFromIndexFunction = stepsFromIndexFunction;
15077
+ exports.stringCharactersToIndexRecord = stringCharactersToIndexRecord;
14761
15078
  exports.stringFactoryFromFactory = stringFactoryFromFactory;
14762
15079
  exports.stringToLowercaseFunction = stringToLowercaseFunction;
14763
15080
  exports.stringToUppercaseFunction = stringToUppercaseFunction;
@@ -14778,6 +15095,7 @@ exports.timePeriodCounter = timePeriodCounter;
14778
15095
  exports.timer = timer;
14779
15096
  exports.toAbsoluteSlashPathStartType = toAbsoluteSlashPathStartType;
14780
15097
  exports.toCaseInsensitiveStringArray = toCaseInsensitiveStringArray;
15098
+ exports.toMinuteOfDay = toMinuteOfDay;
14781
15099
  exports.toModelFieldConversions = toModelFieldConversions;
14782
15100
  exports.toModelMapFunctions = toModelMapFunctions;
14783
15101
  exports.toReadableError = toReadableError;