tp-react-elements-dev 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -13154,7 +13154,7 @@ function createFilterOptions(config = {}) {
13154
13154
  }
13155
13155
 
13156
13156
  // To replace with .findIndex() once we stop IE11 support.
13157
- function findIndex$1(array, comp) {
13157
+ function findIndex$2(array, comp) {
13158
13158
  for (let i = 0; i < array.length; i += 1) {
13159
13159
  if (comp(array[i])) {
13160
13160
  return i;
@@ -13502,7 +13502,7 @@ function useAutocomplete(props) {
13502
13502
  if (highlightedIndexRef.current !== -1 && previousProps.filteredOptions && previousProps.filteredOptions.length !== filteredOptions.length && previousProps.inputValue === inputValue && (multiple ? value.length === previousProps.value.length && previousProps.value.every((val, i) => getOptionLabel(value[i]) === getOptionLabel(val)) : isSameValue(previousProps.value, value))) {
13503
13503
  const previousHighlightedOption = previousProps.filteredOptions[highlightedIndexRef.current];
13504
13504
  if (previousHighlightedOption) {
13505
- return findIndex$1(filteredOptions, option => {
13505
+ return findIndex$2(filteredOptions, option => {
13506
13506
  return getOptionLabel(option) === getOptionLabel(previousHighlightedOption);
13507
13507
  });
13508
13508
  }
@@ -13539,10 +13539,10 @@ function useAutocomplete(props) {
13539
13539
  const currentOption = filteredOptions[highlightedIndexRef.current];
13540
13540
 
13541
13541
  // Keep the current highlighted index if possible
13542
- if (multiple && currentOption && findIndex$1(value, val => isOptionEqualToValue(currentOption, val)) !== -1) {
13542
+ if (multiple && currentOption && findIndex$2(value, val => isOptionEqualToValue(currentOption, val)) !== -1) {
13543
13543
  return;
13544
13544
  }
13545
- const itemIndex = findIndex$1(filteredOptions, optionItem => isOptionEqualToValue(optionItem, valueItem));
13545
+ const itemIndex = findIndex$2(filteredOptions, optionItem => isOptionEqualToValue(optionItem, valueItem));
13546
13546
  if (itemIndex === -1) {
13547
13547
  changeHighlightedIndex({
13548
13548
  diff: 'reset'
@@ -13641,7 +13641,7 @@ function useAutocomplete(props) {
13641
13641
  console.error([`MUI: The \`isOptionEqualToValue\` method of ${componentName} does not handle the arguments correctly.`, `The component expects a single value to match a given option but found ${matches.length} matches.`].join('\n'));
13642
13642
  }
13643
13643
  }
13644
- const itemIndex = findIndex$1(newValue, valueItem => isOptionEqualToValue(option, valueItem));
13644
+ const itemIndex = findIndex$2(newValue, valueItem => isOptionEqualToValue(option, valueItem));
13645
13645
  if (itemIndex === -1) {
13646
13646
  newValue.push(option);
13647
13647
  } else if (origin !== 'freeSolo') {
@@ -23360,12 +23360,12 @@ var isDateObject = (value) => value instanceof Date;
23360
23360
  var isNullOrUndefined = (value) => value == null;
23361
23361
 
23362
23362
  const isObjectType = (value) => typeof value === 'object';
23363
- var isObject = (value) => !isNullOrUndefined(value) &&
23363
+ var isObject$1 = (value) => !isNullOrUndefined(value) &&
23364
23364
  !Array.isArray(value) &&
23365
23365
  isObjectType(value) &&
23366
23366
  !isDateObject(value);
23367
23367
 
23368
- var getEventValue = (event) => isObject(event) && event.target
23368
+ var getEventValue = (event) => isObject$1(event) && event.target
23369
23369
  ? isCheckBoxInput(event.target)
23370
23370
  ? event.target.checked
23371
23371
  : event.target.value
@@ -23377,7 +23377,7 @@ var isNameInFieldArray = (names, name) => names.has(getNodeParentName(name));
23377
23377
 
23378
23378
  var isPlainObject = (tempObject) => {
23379
23379
  const prototypeCopy = tempObject.constructor && tempObject.constructor.prototype;
23380
- return (isObject(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf'));
23380
+ return (isObject$1(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf'));
23381
23381
  };
23382
23382
 
23383
23383
  var isWeb = typeof window !== 'undefined' &&
@@ -23394,7 +23394,7 @@ function cloneObject(data) {
23394
23394
  copy = new Set(data);
23395
23395
  }
23396
23396
  else if (!(isWeb && (data instanceof Blob || data instanceof FileList)) &&
23397
- (isArray || isObject(data))) {
23397
+ (isArray || isObject$1(data))) {
23398
23398
  copy = isArray ? [] : {};
23399
23399
  if (!isArray && !isPlainObject(data)) {
23400
23400
  copy = data;
@@ -23418,7 +23418,7 @@ var compact = (value) => Array.isArray(value) ? value.filter(Boolean) : [];
23418
23418
  var isUndefined = (val) => val === undefined;
23419
23419
 
23420
23420
  var get = (object, path, defaultValue) => {
23421
- if (!path || !isObject(object)) {
23421
+ if (!path || !isObject$1(object)) {
23422
23422
  return defaultValue;
23423
23423
  }
23424
23424
  const result = compact(path.split(/[,[\].]+?/)).reduce((result, key) => isNullOrUndefined(result) ? result : result[key], object);
@@ -23446,7 +23446,7 @@ var set = (object, path, value) => {
23446
23446
  if (index !== lastIndex) {
23447
23447
  const objValue = object[key];
23448
23448
  newValue =
23449
- isObject(objValue) || Array.isArray(objValue)
23449
+ isObject$1(objValue) || Array.isArray(objValue)
23450
23450
  ? objValue
23451
23451
  : !isNaN(+tempPath[index + 1])
23452
23452
  ? []
@@ -23526,7 +23526,7 @@ var getProxyFormState = (formState, control, localProxyFormState, isRoot = true)
23526
23526
  return result;
23527
23527
  };
23528
23528
 
23529
- var isEmptyObject = (value) => isObject(value) && !Object.keys(value).length;
23529
+ var isEmptyObject = (value) => isObject$1(value) && !Object.keys(value).length;
23530
23530
 
23531
23531
  var shouldRenderFormState = (formStateData, _proxyFormState, updateFormState, isRoot) => {
23532
23532
  updateFormState(formStateData);
@@ -42181,7 +42181,7 @@ function isSameDay(dateLeft, dateRight) {
42181
42181
  * const result = isDate({})
42182
42182
  * //=> false
42183
42183
  */
42184
- function isDate(value) {
42184
+ function isDate$1(value) {
42185
42185
  return (
42186
42186
  value instanceof Date ||
42187
42187
  (typeof value === "object" &&
@@ -42223,7 +42223,7 @@ function isDate(value) {
42223
42223
  * //=> false
42224
42224
  */
42225
42225
  function isValid(date) {
42226
- if (!isDate(date) && typeof date !== "number") {
42226
+ if (!isDate$1(date) && typeof date !== "number") {
42227
42227
  return false;
42228
42228
  }
42229
42229
  const _date = toDate(date);
@@ -42853,7 +42853,7 @@ function buildMatchFn(args) {
42853
42853
  args.parsePatterns[args.defaultParseWidth];
42854
42854
 
42855
42855
  const key = Array.isArray(parsePatterns)
42856
- ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString))
42856
+ ? findIndex$1(parsePatterns, (pattern) => pattern.test(matchedString))
42857
42857
  : // eslint-disable-next-line @typescript-eslint/no-explicit-any -- I challange you to fix the type
42858
42858
  findKey(parsePatterns, (pattern) => pattern.test(matchedString));
42859
42859
 
@@ -42883,7 +42883,7 @@ function findKey(object, predicate) {
42883
42883
  return undefined;
42884
42884
  }
42885
42885
 
42886
- function findIndex(array, predicate) {
42886
+ function findIndex$1(array, predicate) {
42887
42887
  for (let key = 0; key < array.length; key++) {
42888
42888
  if (predicate(array[key])) {
42889
42889
  return key;
@@ -45894,7 +45894,7 @@ function createRule(name, decl, options) {
45894
45894
  return null;
45895
45895
  }
45896
45896
 
45897
- var join = function join(value, by) {
45897
+ var join$1 = function join(value, by) {
45898
45898
  var result = '';
45899
45899
 
45900
45900
  for (var i = 0; i < value.length; i++) {
@@ -45924,9 +45924,9 @@ var toCssValue = function toCssValue(value) {
45924
45924
  for (var i = 0; i < value.length; i++) {
45925
45925
  if (value[i] === '!important') break;
45926
45926
  if (cssValue) cssValue += ', ';
45927
- cssValue += join(value[i], ' ');
45927
+ cssValue += join$1(value[i], ' ');
45928
45928
  }
45929
- } else cssValue = join(value, ', '); // Add !important, because it was ignored.
45929
+ } else cssValue = join$1(value, ', '); // Add !important, because it was ignored.
45930
45930
 
45931
45931
 
45932
45932
  if (value[value.length - 1] === '!important') {
@@ -48462,7 +48462,7 @@ function convertCase(style) {
48462
48462
  */
48463
48463
 
48464
48464
 
48465
- function camelCase() {
48465
+ function camelCase$1() {
48466
48466
  function onProcessStyle(style) {
48467
48467
  if (Array.isArray(style)) {
48468
48468
  // Handle rules like @font-face, which can have multiple styles in an array
@@ -49425,7 +49425,7 @@ function jssPropsSort() {
49425
49425
  // Subset of jss-preset-default with only the plugins the MUI components are using.
49426
49426
  function jssPreset() {
49427
49427
  return {
49428
- plugins: [functionPlugin(), jssGlobal(), jssNested(), camelCase(), defaultUnit(),
49428
+ plugins: [functionPlugin(), jssGlobal(), jssNested(), camelCase$1(), defaultUnit(),
49429
49429
  // Disable the vendor prefixer server-side, it does nothing.
49430
49430
  // This way, we can get a performance boost.
49431
49431
  // In the documentation, we are using `autoprefixer` to solve this problem.
@@ -50745,5 +50745,2332 @@ const FormRenderWrapper = ({ formArray, name, numberOfColumns = 3, form, }) => {
50745
50745
  }) })) })));
50746
50746
  };
50747
50747
 
50748
- export { Button$1 as Button, FormRenderWrapper as RenderForm };
50748
+ /**
50749
+ * Based on Kendo UI Core expression code <https://github.com/telerik/kendo-ui-core#license-information>
50750
+ */
50751
+
50752
+ function Cache(maxSize) {
50753
+ this._maxSize = maxSize;
50754
+ this.clear();
50755
+ }
50756
+ Cache.prototype.clear = function () {
50757
+ this._size = 0;
50758
+ this._values = Object.create(null);
50759
+ };
50760
+ Cache.prototype.get = function (key) {
50761
+ return this._values[key]
50762
+ };
50763
+ Cache.prototype.set = function (key, value) {
50764
+ this._size >= this._maxSize && this.clear();
50765
+ if (!(key in this._values)) this._size++;
50766
+
50767
+ return (this._values[key] = value)
50768
+ };
50769
+
50770
+ var SPLIT_REGEX = /[^.^\]^[]+|(?=\[\]|\.\.)/g,
50771
+ DIGIT_REGEX = /^\d+$/,
50772
+ LEAD_DIGIT_REGEX = /^\d/,
50773
+ SPEC_CHAR_REGEX = /[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,
50774
+ CLEAN_QUOTES_REGEX = /^\s*(['"]?)(.*?)(\1)\s*$/,
50775
+ MAX_CACHE_SIZE = 512;
50776
+
50777
+ var pathCache = new Cache(MAX_CACHE_SIZE),
50778
+ setCache = new Cache(MAX_CACHE_SIZE),
50779
+ getCache = new Cache(MAX_CACHE_SIZE);
50780
+
50781
+ var propertyExpr = {
50782
+ Cache: Cache,
50783
+
50784
+ split: split,
50785
+
50786
+ normalizePath: normalizePath,
50787
+
50788
+ setter: function (path) {
50789
+ var parts = normalizePath(path);
50790
+
50791
+ return (
50792
+ setCache.get(path) ||
50793
+ setCache.set(path, function setter(obj, value) {
50794
+ var index = 0;
50795
+ var len = parts.length;
50796
+ var data = obj;
50797
+
50798
+ while (index < len - 1) {
50799
+ var part = parts[index];
50800
+ if (
50801
+ part === '__proto__' ||
50802
+ part === 'constructor' ||
50803
+ part === 'prototype'
50804
+ ) {
50805
+ return obj
50806
+ }
50807
+
50808
+ data = data[parts[index++]];
50809
+ }
50810
+ data[parts[index]] = value;
50811
+ })
50812
+ )
50813
+ },
50814
+
50815
+ getter: function (path, safe) {
50816
+ var parts = normalizePath(path);
50817
+ return (
50818
+ getCache.get(path) ||
50819
+ getCache.set(path, function getter(data) {
50820
+ var index = 0,
50821
+ len = parts.length;
50822
+ while (index < len) {
50823
+ if (data != null || !safe) data = data[parts[index++]];
50824
+ else return
50825
+ }
50826
+ return data
50827
+ })
50828
+ )
50829
+ },
50830
+
50831
+ join: function (segments) {
50832
+ return segments.reduce(function (path, part) {
50833
+ return (
50834
+ path +
50835
+ (isQuoted(part) || DIGIT_REGEX.test(part)
50836
+ ? '[' + part + ']'
50837
+ : (path ? '.' : '') + part)
50838
+ )
50839
+ }, '')
50840
+ },
50841
+
50842
+ forEach: function (path, cb, thisArg) {
50843
+ forEach(Array.isArray(path) ? path : split(path), cb, thisArg);
50844
+ },
50845
+ };
50846
+
50847
+ function normalizePath(path) {
50848
+ return (
50849
+ pathCache.get(path) ||
50850
+ pathCache.set(
50851
+ path,
50852
+ split(path).map(function (part) {
50853
+ return part.replace(CLEAN_QUOTES_REGEX, '$2')
50854
+ })
50855
+ )
50856
+ )
50857
+ }
50858
+
50859
+ function split(path) {
50860
+ return path.match(SPLIT_REGEX) || ['']
50861
+ }
50862
+
50863
+ function forEach(parts, iter, thisArg) {
50864
+ var len = parts.length,
50865
+ part,
50866
+ idx,
50867
+ isArray,
50868
+ isBracket;
50869
+
50870
+ for (idx = 0; idx < len; idx++) {
50871
+ part = parts[idx];
50872
+
50873
+ if (part) {
50874
+ if (shouldBeQuoted(part)) {
50875
+ part = '"' + part + '"';
50876
+ }
50877
+
50878
+ isBracket = isQuoted(part);
50879
+ isArray = !isBracket && /^\d+$/.test(part);
50880
+
50881
+ iter.call(thisArg, part, isBracket, isArray, idx, parts);
50882
+ }
50883
+ }
50884
+ }
50885
+
50886
+ function isQuoted(str) {
50887
+ return (
50888
+ typeof str === 'string' && str && ["'", '"'].indexOf(str.charAt(0)) !== -1
50889
+ )
50890
+ }
50891
+
50892
+ function hasLeadingNumber(part) {
50893
+ return part.match(LEAD_DIGIT_REGEX) && !part.match(DIGIT_REGEX)
50894
+ }
50895
+
50896
+ function hasSpecialChars(part) {
50897
+ return SPEC_CHAR_REGEX.test(part)
50898
+ }
50899
+
50900
+ function shouldBeQuoted(part) {
50901
+ return !isQuoted(part) && (hasLeadingNumber(part) || hasSpecialChars(part))
50902
+ }
50903
+
50904
+ const reWords = /[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g;
50905
+
50906
+ const words = (str) => str.match(reWords) || [];
50907
+
50908
+ const upperFirst = (str) => str[0].toUpperCase() + str.slice(1);
50909
+
50910
+ const join = (str, d) => words(str).join(d).toLowerCase();
50911
+
50912
+ const camelCase = (str) =>
50913
+ words(str).reduce(
50914
+ (acc, next) =>
50915
+ `${acc}${
50916
+ !acc
50917
+ ? next.toLowerCase()
50918
+ : next[0].toUpperCase() + next.slice(1).toLowerCase()
50919
+ }`,
50920
+ '',
50921
+ );
50922
+
50923
+ const pascalCase = (str) => upperFirst(camelCase(str));
50924
+
50925
+ const snakeCase = (str) => join(str, '_');
50926
+
50927
+ const kebabCase = (str) => join(str, '-');
50928
+
50929
+ const sentenceCase = (str) => upperFirst(join(str, ' '));
50930
+
50931
+ const titleCase = (str) => words(str).map(upperFirst).join(' ');
50932
+
50933
+ var tinyCase = {
50934
+ words,
50935
+ upperFirst,
50936
+ camelCase,
50937
+ pascalCase,
50938
+ snakeCase,
50939
+ kebabCase,
50940
+ sentenceCase,
50941
+ titleCase,
50942
+ };
50943
+
50944
+ var toposort$2 = {exports: {}};
50945
+
50946
+ /**
50947
+ * Topological sorting function
50948
+ *
50949
+ * @param {Array} edges
50950
+ * @returns {Array}
50951
+ */
50952
+
50953
+ toposort$2.exports = function(edges) {
50954
+ return toposort(uniqueNodes(edges), edges)
50955
+ };
50956
+
50957
+ toposort$2.exports.array = toposort;
50958
+
50959
+ function toposort(nodes, edges) {
50960
+ var cursor = nodes.length
50961
+ , sorted = new Array(cursor)
50962
+ , visited = {}
50963
+ , i = cursor
50964
+ // Better data structures make algorithm much faster.
50965
+ , outgoingEdges = makeOutgoingEdges(edges)
50966
+ , nodesHash = makeNodesHash(nodes);
50967
+
50968
+ // check for unknown nodes
50969
+ edges.forEach(function(edge) {
50970
+ if (!nodesHash.has(edge[0]) || !nodesHash.has(edge[1])) {
50971
+ throw new Error('Unknown node. There is an unknown node in the supplied edges.')
50972
+ }
50973
+ });
50974
+
50975
+ while (i--) {
50976
+ if (!visited[i]) visit(nodes[i], i, new Set());
50977
+ }
50978
+
50979
+ return sorted
50980
+
50981
+ function visit(node, i, predecessors) {
50982
+ if(predecessors.has(node)) {
50983
+ var nodeRep;
50984
+ try {
50985
+ nodeRep = ", node was:" + JSON.stringify(node);
50986
+ } catch(e) {
50987
+ nodeRep = "";
50988
+ }
50989
+ throw new Error('Cyclic dependency' + nodeRep)
50990
+ }
50991
+
50992
+ if (!nodesHash.has(node)) {
50993
+ throw new Error('Found unknown node. Make sure to provided all involved nodes. Unknown node: '+JSON.stringify(node))
50994
+ }
50995
+
50996
+ if (visited[i]) return;
50997
+ visited[i] = true;
50998
+
50999
+ var outgoing = outgoingEdges.get(node) || new Set();
51000
+ outgoing = Array.from(outgoing);
51001
+
51002
+ if (i = outgoing.length) {
51003
+ predecessors.add(node);
51004
+ do {
51005
+ var child = outgoing[--i];
51006
+ visit(child, nodesHash.get(child), predecessors);
51007
+ } while (i)
51008
+ predecessors.delete(node);
51009
+ }
51010
+
51011
+ sorted[--cursor] = node;
51012
+ }
51013
+ }
51014
+
51015
+ function uniqueNodes(arr){
51016
+ var res = new Set();
51017
+ for (var i = 0, len = arr.length; i < len; i++) {
51018
+ var edge = arr[i];
51019
+ res.add(edge[0]);
51020
+ res.add(edge[1]);
51021
+ }
51022
+ return Array.from(res)
51023
+ }
51024
+
51025
+ function makeOutgoingEdges(arr){
51026
+ var edges = new Map();
51027
+ for (var i = 0, len = arr.length; i < len; i++) {
51028
+ var edge = arr[i];
51029
+ if (!edges.has(edge[0])) edges.set(edge[0], new Set());
51030
+ if (!edges.has(edge[1])) edges.set(edge[1], new Set());
51031
+ edges.get(edge[0]).add(edge[1]);
51032
+ }
51033
+ return edges
51034
+ }
51035
+
51036
+ function makeNodesHash(arr){
51037
+ var res = new Map();
51038
+ for (var i = 0, len = arr.length; i < len; i++) {
51039
+ res.set(arr[i], i);
51040
+ }
51041
+ return res
51042
+ }
51043
+
51044
+ var toposortExports = toposort$2.exports;
51045
+ var toposort$1 = /*@__PURE__*/getDefaultExportFromCjs(toposortExports);
51046
+
51047
+ const toString = Object.prototype.toString;
51048
+ const errorToString = Error.prototype.toString;
51049
+ const regExpToString = RegExp.prototype.toString;
51050
+ const symbolToString = typeof Symbol !== 'undefined' ? Symbol.prototype.toString : () => '';
51051
+ const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
51052
+ function printNumber(val) {
51053
+ if (val != +val) return 'NaN';
51054
+ const isNegativeZero = val === 0 && 1 / val < 0;
51055
+ return isNegativeZero ? '-0' : '' + val;
51056
+ }
51057
+ function printSimpleValue(val, quoteStrings = false) {
51058
+ if (val == null || val === true || val === false) return '' + val;
51059
+ const typeOf = typeof val;
51060
+ if (typeOf === 'number') return printNumber(val);
51061
+ if (typeOf === 'string') return quoteStrings ? `"${val}"` : val;
51062
+ if (typeOf === 'function') return '[Function ' + (val.name || 'anonymous') + ']';
51063
+ if (typeOf === 'symbol') return symbolToString.call(val).replace(SYMBOL_REGEXP, 'Symbol($1)');
51064
+ const tag = toString.call(val).slice(8, -1);
51065
+ if (tag === 'Date') return isNaN(val.getTime()) ? '' + val : val.toISOString(val);
51066
+ if (tag === 'Error' || val instanceof Error) return '[' + errorToString.call(val) + ']';
51067
+ if (tag === 'RegExp') return regExpToString.call(val);
51068
+ return null;
51069
+ }
51070
+ function printValue(value, quoteStrings) {
51071
+ let result = printSimpleValue(value, quoteStrings);
51072
+ if (result !== null) return result;
51073
+ return JSON.stringify(value, function (key, value) {
51074
+ let result = printSimpleValue(this[key], quoteStrings);
51075
+ if (result !== null) return result;
51076
+ return value;
51077
+ }, 2);
51078
+ }
51079
+
51080
+ function toArray(value) {
51081
+ return value == null ? [] : [].concat(value);
51082
+ }
51083
+
51084
+ let _Symbol$toStringTag, _Symbol$hasInstance, _Symbol$toStringTag2;
51085
+ let strReg = /\$\{\s*(\w+)\s*\}/g;
51086
+ _Symbol$toStringTag = Symbol.toStringTag;
51087
+ class ValidationErrorNoStack {
51088
+ constructor(errorOrErrors, value, field, type) {
51089
+ this.name = void 0;
51090
+ this.message = void 0;
51091
+ this.value = void 0;
51092
+ this.path = void 0;
51093
+ this.type = void 0;
51094
+ this.params = void 0;
51095
+ this.errors = void 0;
51096
+ this.inner = void 0;
51097
+ this[_Symbol$toStringTag] = 'Error';
51098
+ this.name = 'ValidationError';
51099
+ this.value = value;
51100
+ this.path = field;
51101
+ this.type = type;
51102
+ this.errors = [];
51103
+ this.inner = [];
51104
+ toArray(errorOrErrors).forEach(err => {
51105
+ if (ValidationError.isError(err)) {
51106
+ this.errors.push(...err.errors);
51107
+ const innerErrors = err.inner.length ? err.inner : [err];
51108
+ this.inner.push(...innerErrors);
51109
+ } else {
51110
+ this.errors.push(err);
51111
+ }
51112
+ });
51113
+ this.message = this.errors.length > 1 ? `${this.errors.length} errors occurred` : this.errors[0];
51114
+ }
51115
+ }
51116
+ _Symbol$hasInstance = Symbol.hasInstance;
51117
+ _Symbol$toStringTag2 = Symbol.toStringTag;
51118
+ class ValidationError extends Error {
51119
+ static formatError(message, params) {
51120
+ const path = params.label || params.path || 'this';
51121
+ if (path !== params.path) params = Object.assign({}, params, {
51122
+ path
51123
+ });
51124
+ if (typeof message === 'string') return message.replace(strReg, (_, key) => printValue(params[key]));
51125
+ if (typeof message === 'function') return message(params);
51126
+ return message;
51127
+ }
51128
+ static isError(err) {
51129
+ return err && err.name === 'ValidationError';
51130
+ }
51131
+ constructor(errorOrErrors, value, field, type, disableStack) {
51132
+ const errorNoStack = new ValidationErrorNoStack(errorOrErrors, value, field, type);
51133
+ if (disableStack) {
51134
+ return errorNoStack;
51135
+ }
51136
+ super();
51137
+ this.value = void 0;
51138
+ this.path = void 0;
51139
+ this.type = void 0;
51140
+ this.params = void 0;
51141
+ this.errors = [];
51142
+ this.inner = [];
51143
+ this[_Symbol$toStringTag2] = 'Error';
51144
+ this.name = errorNoStack.name;
51145
+ this.message = errorNoStack.message;
51146
+ this.type = errorNoStack.type;
51147
+ this.value = errorNoStack.value;
51148
+ this.path = errorNoStack.path;
51149
+ this.errors = errorNoStack.errors;
51150
+ this.inner = errorNoStack.inner;
51151
+ if (Error.captureStackTrace) {
51152
+ Error.captureStackTrace(this, ValidationError);
51153
+ }
51154
+ }
51155
+ static [_Symbol$hasInstance](inst) {
51156
+ return ValidationErrorNoStack[Symbol.hasInstance](inst) || super[Symbol.hasInstance](inst);
51157
+ }
51158
+ }
51159
+
51160
+ let mixed = {
51161
+ default: '${path} is invalid',
51162
+ required: '${path} is a required field',
51163
+ defined: '${path} must be defined',
51164
+ notNull: '${path} cannot be null',
51165
+ oneOf: '${path} must be one of the following values: ${values}',
51166
+ notOneOf: '${path} must not be one of the following values: ${values}',
51167
+ notType: ({
51168
+ path,
51169
+ type,
51170
+ value,
51171
+ originalValue
51172
+ }) => {
51173
+ const castMsg = originalValue != null && originalValue !== value ? ` (cast from the value \`${printValue(originalValue, true)}\`).` : '.';
51174
+ return type !== 'mixed' ? `${path} must be a \`${type}\` type, ` + `but the final value was: \`${printValue(value, true)}\`` + castMsg : `${path} must match the configured type. ` + `The validated value was: \`${printValue(value, true)}\`` + castMsg;
51175
+ }
51176
+ };
51177
+ let string = {
51178
+ length: '${path} must be exactly ${length} characters',
51179
+ min: '${path} must be at least ${min} characters',
51180
+ max: '${path} must be at most ${max} characters',
51181
+ matches: '${path} must match the following: "${regex}"',
51182
+ email: '${path} must be a valid email',
51183
+ url: '${path} must be a valid URL',
51184
+ uuid: '${path} must be a valid UUID',
51185
+ datetime: '${path} must be a valid ISO date-time',
51186
+ datetime_precision: '${path} must be a valid ISO date-time with a sub-second precision of exactly ${precision} digits',
51187
+ datetime_offset: '${path} must be a valid ISO date-time with UTC "Z" timezone',
51188
+ trim: '${path} must be a trimmed string',
51189
+ lowercase: '${path} must be a lowercase string',
51190
+ uppercase: '${path} must be a upper case string'
51191
+ };
51192
+ let number = {
51193
+ min: '${path} must be greater than or equal to ${min}',
51194
+ max: '${path} must be less than or equal to ${max}',
51195
+ lessThan: '${path} must be less than ${less}',
51196
+ moreThan: '${path} must be greater than ${more}',
51197
+ positive: '${path} must be a positive number',
51198
+ negative: '${path} must be a negative number',
51199
+ integer: '${path} must be an integer'
51200
+ };
51201
+ let date = {
51202
+ min: '${path} field must be later than ${min}',
51203
+ max: '${path} field must be at earlier than ${max}'
51204
+ };
51205
+ let boolean = {
51206
+ isValue: '${path} field must be ${value}'
51207
+ };
51208
+ let object = {
51209
+ noUnknown: '${path} field has unspecified keys: ${unknown}'
51210
+ };
51211
+ let array = {
51212
+ min: '${path} field must have at least ${min} items',
51213
+ max: '${path} field must have less than or equal to ${max} items',
51214
+ length: '${path} must have ${length} items'
51215
+ };
51216
+ let tuple = {
51217
+ notType: params => {
51218
+ const {
51219
+ path,
51220
+ value,
51221
+ spec
51222
+ } = params;
51223
+ const typeLen = spec.types.length;
51224
+ if (Array.isArray(value)) {
51225
+ if (value.length < typeLen) return `${path} tuple value has too few items, expected a length of ${typeLen} but got ${value.length} for value: \`${printValue(value, true)}\``;
51226
+ if (value.length > typeLen) return `${path} tuple value has too many items, expected a length of ${typeLen} but got ${value.length} for value: \`${printValue(value, true)}\``;
51227
+ }
51228
+ return ValidationError.formatError(mixed.notType, params);
51229
+ }
51230
+ };
51231
+ Object.assign(Object.create(null), {
51232
+ mixed,
51233
+ string,
51234
+ number,
51235
+ date,
51236
+ object,
51237
+ array,
51238
+ boolean,
51239
+ tuple
51240
+ });
51241
+
51242
+ const isSchema = obj => obj && obj.__isYupSchema__;
51243
+
51244
+ class Condition {
51245
+ static fromOptions(refs, config) {
51246
+ if (!config.then && !config.otherwise) throw new TypeError('either `then:` or `otherwise:` is required for `when()` conditions');
51247
+ let {
51248
+ is,
51249
+ then,
51250
+ otherwise
51251
+ } = config;
51252
+ let check = typeof is === 'function' ? is : (...values) => values.every(value => value === is);
51253
+ return new Condition(refs, (values, schema) => {
51254
+ var _branch;
51255
+ let branch = check(...values) ? then : otherwise;
51256
+ return (_branch = branch == null ? void 0 : branch(schema)) != null ? _branch : schema;
51257
+ });
51258
+ }
51259
+ constructor(refs, builder) {
51260
+ this.fn = void 0;
51261
+ this.refs = refs;
51262
+ this.refs = refs;
51263
+ this.fn = builder;
51264
+ }
51265
+ resolve(base, options) {
51266
+ let values = this.refs.map(ref =>
51267
+ // TODO: ? operator here?
51268
+ ref.getValue(options == null ? void 0 : options.value, options == null ? void 0 : options.parent, options == null ? void 0 : options.context));
51269
+ let schema = this.fn(values, base, options);
51270
+ if (schema === undefined ||
51271
+ // @ts-ignore this can be base
51272
+ schema === base) {
51273
+ return base;
51274
+ }
51275
+ if (!isSchema(schema)) throw new TypeError('conditions must return a schema object');
51276
+ return schema.resolve(options);
51277
+ }
51278
+ }
51279
+
51280
+ const prefixes = {
51281
+ context: '$',
51282
+ value: '.'
51283
+ };
51284
+ class Reference {
51285
+ constructor(key, options = {}) {
51286
+ this.key = void 0;
51287
+ this.isContext = void 0;
51288
+ this.isValue = void 0;
51289
+ this.isSibling = void 0;
51290
+ this.path = void 0;
51291
+ this.getter = void 0;
51292
+ this.map = void 0;
51293
+ if (typeof key !== 'string') throw new TypeError('ref must be a string, got: ' + key);
51294
+ this.key = key.trim();
51295
+ if (key === '') throw new TypeError('ref must be a non-empty string');
51296
+ this.isContext = this.key[0] === prefixes.context;
51297
+ this.isValue = this.key[0] === prefixes.value;
51298
+ this.isSibling = !this.isContext && !this.isValue;
51299
+ let prefix = this.isContext ? prefixes.context : this.isValue ? prefixes.value : '';
51300
+ this.path = this.key.slice(prefix.length);
51301
+ this.getter = this.path && propertyExpr.getter(this.path, true);
51302
+ this.map = options.map;
51303
+ }
51304
+ getValue(value, parent, context) {
51305
+ let result = this.isContext ? context : this.isValue ? value : parent;
51306
+ if (this.getter) result = this.getter(result || {});
51307
+ if (this.map) result = this.map(result);
51308
+ return result;
51309
+ }
51310
+
51311
+ /**
51312
+ *
51313
+ * @param {*} value
51314
+ * @param {Object} options
51315
+ * @param {Object=} options.context
51316
+ * @param {Object=} options.parent
51317
+ */
51318
+ cast(value, options) {
51319
+ return this.getValue(value, options == null ? void 0 : options.parent, options == null ? void 0 : options.context);
51320
+ }
51321
+ resolve() {
51322
+ return this;
51323
+ }
51324
+ describe() {
51325
+ return {
51326
+ type: 'ref',
51327
+ key: this.key
51328
+ };
51329
+ }
51330
+ toString() {
51331
+ return `Ref(${this.key})`;
51332
+ }
51333
+ static isRef(value) {
51334
+ return value && value.__isYupRef;
51335
+ }
51336
+ }
51337
+
51338
+ // @ts-ignore
51339
+ Reference.prototype.__isYupRef = true;
51340
+
51341
+ const isAbsent = value => value == null;
51342
+
51343
+ function createValidation(config) {
51344
+ function validate({
51345
+ value,
51346
+ path = '',
51347
+ options,
51348
+ originalValue,
51349
+ schema
51350
+ }, panic, next) {
51351
+ const {
51352
+ name,
51353
+ test,
51354
+ params,
51355
+ message,
51356
+ skipAbsent
51357
+ } = config;
51358
+ let {
51359
+ parent,
51360
+ context,
51361
+ abortEarly = schema.spec.abortEarly,
51362
+ disableStackTrace = schema.spec.disableStackTrace
51363
+ } = options;
51364
+ function resolve(item) {
51365
+ return Reference.isRef(item) ? item.getValue(value, parent, context) : item;
51366
+ }
51367
+ function createError(overrides = {}) {
51368
+ const nextParams = Object.assign({
51369
+ value,
51370
+ originalValue,
51371
+ label: schema.spec.label,
51372
+ path: overrides.path || path,
51373
+ spec: schema.spec,
51374
+ disableStackTrace: overrides.disableStackTrace || disableStackTrace
51375
+ }, params, overrides.params);
51376
+ for (const key of Object.keys(nextParams)) nextParams[key] = resolve(nextParams[key]);
51377
+ const error = new ValidationError(ValidationError.formatError(overrides.message || message, nextParams), value, nextParams.path, overrides.type || name, nextParams.disableStackTrace);
51378
+ error.params = nextParams;
51379
+ return error;
51380
+ }
51381
+ const invalid = abortEarly ? panic : next;
51382
+ let ctx = {
51383
+ path,
51384
+ parent,
51385
+ type: name,
51386
+ from: options.from,
51387
+ createError,
51388
+ resolve,
51389
+ options,
51390
+ originalValue,
51391
+ schema
51392
+ };
51393
+ const handleResult = validOrError => {
51394
+ if (ValidationError.isError(validOrError)) invalid(validOrError);else if (!validOrError) invalid(createError());else next(null);
51395
+ };
51396
+ const handleError = err => {
51397
+ if (ValidationError.isError(err)) invalid(err);else panic(err);
51398
+ };
51399
+ const shouldSkip = skipAbsent && isAbsent(value);
51400
+ if (shouldSkip) {
51401
+ return handleResult(true);
51402
+ }
51403
+ let result;
51404
+ try {
51405
+ var _result;
51406
+ result = test.call(ctx, value, ctx);
51407
+ if (typeof ((_result = result) == null ? void 0 : _result.then) === 'function') {
51408
+ if (options.sync) {
51409
+ throw new Error(`Validation test of type: "${ctx.type}" returned a Promise during a synchronous validate. ` + `This test will finish after the validate call has returned`);
51410
+ }
51411
+ return Promise.resolve(result).then(handleResult, handleError);
51412
+ }
51413
+ } catch (err) {
51414
+ handleError(err);
51415
+ return;
51416
+ }
51417
+ handleResult(result);
51418
+ }
51419
+ validate.OPTIONS = config;
51420
+ return validate;
51421
+ }
51422
+
51423
+ function getIn(schema, path, value, context = value) {
51424
+ let parent, lastPart, lastPartDebug;
51425
+
51426
+ // root path: ''
51427
+ if (!path) return {
51428
+ parent,
51429
+ parentPath: path,
51430
+ schema
51431
+ };
51432
+ propertyExpr.forEach(path, (_part, isBracket, isArray) => {
51433
+ let part = isBracket ? _part.slice(1, _part.length - 1) : _part;
51434
+ schema = schema.resolve({
51435
+ context,
51436
+ parent,
51437
+ value
51438
+ });
51439
+ let isTuple = schema.type === 'tuple';
51440
+ let idx = isArray ? parseInt(part, 10) : 0;
51441
+ if (schema.innerType || isTuple) {
51442
+ if (isTuple && !isArray) throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${lastPartDebug}" must contain an index to the tuple element, e.g. "${lastPartDebug}[0]"`);
51443
+ if (value && idx >= value.length) {
51444
+ throw new Error(`Yup.reach cannot resolve an array item at index: ${_part}, in the path: ${path}. ` + `because there is no value at that index. `);
51445
+ }
51446
+ parent = value;
51447
+ value = value && value[idx];
51448
+ schema = isTuple ? schema.spec.types[idx] : schema.innerType;
51449
+ }
51450
+
51451
+ // sometimes the array index part of a path doesn't exist: "nested.arr.child"
51452
+ // in these cases the current part is the next schema and should be processed
51453
+ // in this iteration. For cases where the index signature is included this
51454
+ // check will fail and we'll handle the `child` part on the next iteration like normal
51455
+ if (!isArray) {
51456
+ if (!schema.fields || !schema.fields[part]) throw new Error(`The schema does not contain the path: ${path}. ` + `(failed at: ${lastPartDebug} which is a type: "${schema.type}")`);
51457
+ parent = value;
51458
+ value = value && value[part];
51459
+ schema = schema.fields[part];
51460
+ }
51461
+ lastPart = part;
51462
+ lastPartDebug = isBracket ? '[' + _part + ']' : '.' + _part;
51463
+ });
51464
+ return {
51465
+ schema,
51466
+ parent,
51467
+ parentPath: lastPart
51468
+ };
51469
+ }
51470
+
51471
+ class ReferenceSet extends Set {
51472
+ describe() {
51473
+ const description = [];
51474
+ for (const item of this.values()) {
51475
+ description.push(Reference.isRef(item) ? item.describe() : item);
51476
+ }
51477
+ return description;
51478
+ }
51479
+ resolveAll(resolve) {
51480
+ let result = [];
51481
+ for (const item of this.values()) {
51482
+ result.push(resolve(item));
51483
+ }
51484
+ return result;
51485
+ }
51486
+ clone() {
51487
+ return new ReferenceSet(this.values());
51488
+ }
51489
+ merge(newItems, removeItems) {
51490
+ const next = this.clone();
51491
+ newItems.forEach(value => next.add(value));
51492
+ removeItems.forEach(value => next.delete(value));
51493
+ return next;
51494
+ }
51495
+ }
51496
+
51497
+ // tweaked from https://github.com/Kelin2025/nanoclone/blob/0abeb7635bda9b68ef2277093f76dbe3bf3948e1/src/index.js
51498
+ function clone(src, seen = new Map()) {
51499
+ if (isSchema(src) || !src || typeof src !== 'object') return src;
51500
+ if (seen.has(src)) return seen.get(src);
51501
+ let copy;
51502
+ if (src instanceof Date) {
51503
+ // Date
51504
+ copy = new Date(src.getTime());
51505
+ seen.set(src, copy);
51506
+ } else if (src instanceof RegExp) {
51507
+ // RegExp
51508
+ copy = new RegExp(src);
51509
+ seen.set(src, copy);
51510
+ } else if (Array.isArray(src)) {
51511
+ // Array
51512
+ copy = new Array(src.length);
51513
+ seen.set(src, copy);
51514
+ for (let i = 0; i < src.length; i++) copy[i] = clone(src[i], seen);
51515
+ } else if (src instanceof Map) {
51516
+ // Map
51517
+ copy = new Map();
51518
+ seen.set(src, copy);
51519
+ for (const [k, v] of src.entries()) copy.set(k, clone(v, seen));
51520
+ } else if (src instanceof Set) {
51521
+ // Set
51522
+ copy = new Set();
51523
+ seen.set(src, copy);
51524
+ for (const v of src) copy.add(clone(v, seen));
51525
+ } else if (src instanceof Object) {
51526
+ // Object
51527
+ copy = {};
51528
+ seen.set(src, copy);
51529
+ for (const [k, v] of Object.entries(src)) copy[k] = clone(v, seen);
51530
+ } else {
51531
+ throw Error(`Unable to clone ${src}`);
51532
+ }
51533
+ return copy;
51534
+ }
51535
+
51536
+ // If `CustomSchemaMeta` isn't extended with any keys, we'll fall back to a
51537
+ // loose Record definition allowing free form usage.
51538
+ class Schema {
51539
+ constructor(options) {
51540
+ this.type = void 0;
51541
+ this.deps = [];
51542
+ this.tests = void 0;
51543
+ this.transforms = void 0;
51544
+ this.conditions = [];
51545
+ this._mutate = void 0;
51546
+ this.internalTests = {};
51547
+ this._whitelist = new ReferenceSet();
51548
+ this._blacklist = new ReferenceSet();
51549
+ this.exclusiveTests = Object.create(null);
51550
+ this._typeCheck = void 0;
51551
+ this.spec = void 0;
51552
+ this.tests = [];
51553
+ this.transforms = [];
51554
+ this.withMutation(() => {
51555
+ this.typeError(mixed.notType);
51556
+ });
51557
+ this.type = options.type;
51558
+ this._typeCheck = options.check;
51559
+ this.spec = Object.assign({
51560
+ strip: false,
51561
+ strict: false,
51562
+ abortEarly: true,
51563
+ recursive: true,
51564
+ disableStackTrace: false,
51565
+ nullable: false,
51566
+ optional: true,
51567
+ coerce: true
51568
+ }, options == null ? void 0 : options.spec);
51569
+ this.withMutation(s => {
51570
+ s.nonNullable();
51571
+ });
51572
+ }
51573
+
51574
+ // TODO: remove
51575
+ get _type() {
51576
+ return this.type;
51577
+ }
51578
+ clone(spec) {
51579
+ if (this._mutate) {
51580
+ if (spec) Object.assign(this.spec, spec);
51581
+ return this;
51582
+ }
51583
+
51584
+ // if the nested value is a schema we can skip cloning, since
51585
+ // they are already immutable
51586
+ const next = Object.create(Object.getPrototypeOf(this));
51587
+
51588
+ // @ts-expect-error this is readonly
51589
+ next.type = this.type;
51590
+ next._typeCheck = this._typeCheck;
51591
+ next._whitelist = this._whitelist.clone();
51592
+ next._blacklist = this._blacklist.clone();
51593
+ next.internalTests = Object.assign({}, this.internalTests);
51594
+ next.exclusiveTests = Object.assign({}, this.exclusiveTests);
51595
+
51596
+ // @ts-expect-error this is readonly
51597
+ next.deps = [...this.deps];
51598
+ next.conditions = [...this.conditions];
51599
+ next.tests = [...this.tests];
51600
+ next.transforms = [...this.transforms];
51601
+ next.spec = clone(Object.assign({}, this.spec, spec));
51602
+ return next;
51603
+ }
51604
+ label(label) {
51605
+ let next = this.clone();
51606
+ next.spec.label = label;
51607
+ return next;
51608
+ }
51609
+ meta(...args) {
51610
+ if (args.length === 0) return this.spec.meta;
51611
+ let next = this.clone();
51612
+ next.spec.meta = Object.assign(next.spec.meta || {}, args[0]);
51613
+ return next;
51614
+ }
51615
+ withMutation(fn) {
51616
+ let before = this._mutate;
51617
+ this._mutate = true;
51618
+ let result = fn(this);
51619
+ this._mutate = before;
51620
+ return result;
51621
+ }
51622
+ concat(schema) {
51623
+ if (!schema || schema === this) return this;
51624
+ if (schema.type !== this.type && this.type !== 'mixed') throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${schema.type}`);
51625
+ let base = this;
51626
+ let combined = schema.clone();
51627
+ const mergedSpec = Object.assign({}, base.spec, combined.spec);
51628
+ combined.spec = mergedSpec;
51629
+ combined.internalTests = Object.assign({}, base.internalTests, combined.internalTests);
51630
+
51631
+ // manually merge the blacklist/whitelist (the other `schema` takes
51632
+ // precedence in case of conflicts)
51633
+ combined._whitelist = base._whitelist.merge(schema._whitelist, schema._blacklist);
51634
+ combined._blacklist = base._blacklist.merge(schema._blacklist, schema._whitelist);
51635
+
51636
+ // start with the current tests
51637
+ combined.tests = base.tests;
51638
+ combined.exclusiveTests = base.exclusiveTests;
51639
+
51640
+ // manually add the new tests to ensure
51641
+ // the deduping logic is consistent
51642
+ combined.withMutation(next => {
51643
+ schema.tests.forEach(fn => {
51644
+ next.test(fn.OPTIONS);
51645
+ });
51646
+ });
51647
+ combined.transforms = [...base.transforms, ...combined.transforms];
51648
+ return combined;
51649
+ }
51650
+ isType(v) {
51651
+ if (v == null) {
51652
+ if (this.spec.nullable && v === null) return true;
51653
+ if (this.spec.optional && v === undefined) return true;
51654
+ return false;
51655
+ }
51656
+ return this._typeCheck(v);
51657
+ }
51658
+ resolve(options) {
51659
+ let schema = this;
51660
+ if (schema.conditions.length) {
51661
+ let conditions = schema.conditions;
51662
+ schema = schema.clone();
51663
+ schema.conditions = [];
51664
+ schema = conditions.reduce((prevSchema, condition) => condition.resolve(prevSchema, options), schema);
51665
+ schema = schema.resolve(options);
51666
+ }
51667
+ return schema;
51668
+ }
51669
+ resolveOptions(options) {
51670
+ var _options$strict, _options$abortEarly, _options$recursive, _options$disableStack;
51671
+ return Object.assign({}, options, {
51672
+ from: options.from || [],
51673
+ strict: (_options$strict = options.strict) != null ? _options$strict : this.spec.strict,
51674
+ abortEarly: (_options$abortEarly = options.abortEarly) != null ? _options$abortEarly : this.spec.abortEarly,
51675
+ recursive: (_options$recursive = options.recursive) != null ? _options$recursive : this.spec.recursive,
51676
+ disableStackTrace: (_options$disableStack = options.disableStackTrace) != null ? _options$disableStack : this.spec.disableStackTrace
51677
+ });
51678
+ }
51679
+
51680
+ /**
51681
+ * Run the configured transform pipeline over an input value.
51682
+ */
51683
+
51684
+ cast(value, options = {}) {
51685
+ let resolvedSchema = this.resolve(Object.assign({
51686
+ value
51687
+ }, options));
51688
+ let allowOptionality = options.assert === 'ignore-optionality';
51689
+ let result = resolvedSchema._cast(value, options);
51690
+ if (options.assert !== false && !resolvedSchema.isType(result)) {
51691
+ if (allowOptionality && isAbsent(result)) {
51692
+ return result;
51693
+ }
51694
+ let formattedValue = printValue(value);
51695
+ let formattedResult = printValue(result);
51696
+ throw new TypeError(`The value of ${options.path || 'field'} could not be cast to a value ` + `that satisfies the schema type: "${resolvedSchema.type}". \n\n` + `attempted value: ${formattedValue} \n` + (formattedResult !== formattedValue ? `result of cast: ${formattedResult}` : ''));
51697
+ }
51698
+ return result;
51699
+ }
51700
+ _cast(rawValue, options) {
51701
+ let value = rawValue === undefined ? rawValue : this.transforms.reduce((prevValue, fn) => fn.call(this, prevValue, rawValue, this), rawValue);
51702
+ if (value === undefined) {
51703
+ value = this.getDefault(options);
51704
+ }
51705
+ return value;
51706
+ }
51707
+ _validate(_value, options = {}, panic, next) {
51708
+ let {
51709
+ path,
51710
+ originalValue = _value,
51711
+ strict = this.spec.strict
51712
+ } = options;
51713
+ let value = _value;
51714
+ if (!strict) {
51715
+ value = this._cast(value, Object.assign({
51716
+ assert: false
51717
+ }, options));
51718
+ }
51719
+ let initialTests = [];
51720
+ for (let test of Object.values(this.internalTests)) {
51721
+ if (test) initialTests.push(test);
51722
+ }
51723
+ this.runTests({
51724
+ path,
51725
+ value,
51726
+ originalValue,
51727
+ options,
51728
+ tests: initialTests
51729
+ }, panic, initialErrors => {
51730
+ // even if we aren't ending early we can't proceed further if the types aren't correct
51731
+ if (initialErrors.length) {
51732
+ return next(initialErrors, value);
51733
+ }
51734
+ this.runTests({
51735
+ path,
51736
+ value,
51737
+ originalValue,
51738
+ options,
51739
+ tests: this.tests
51740
+ }, panic, next);
51741
+ });
51742
+ }
51743
+
51744
+ /**
51745
+ * Executes a set of validations, either schema, produced Tests or a nested
51746
+ * schema validate result.
51747
+ */
51748
+ runTests(runOptions, panic, next) {
51749
+ let fired = false;
51750
+ let {
51751
+ tests,
51752
+ value,
51753
+ originalValue,
51754
+ path,
51755
+ options
51756
+ } = runOptions;
51757
+ let panicOnce = arg => {
51758
+ if (fired) return;
51759
+ fired = true;
51760
+ panic(arg, value);
51761
+ };
51762
+ let nextOnce = arg => {
51763
+ if (fired) return;
51764
+ fired = true;
51765
+ next(arg, value);
51766
+ };
51767
+ let count = tests.length;
51768
+ let nestedErrors = [];
51769
+ if (!count) return nextOnce([]);
51770
+ let args = {
51771
+ value,
51772
+ originalValue,
51773
+ path,
51774
+ options,
51775
+ schema: this
51776
+ };
51777
+ for (let i = 0; i < tests.length; i++) {
51778
+ const test = tests[i];
51779
+ test(args, panicOnce, function finishTestRun(err) {
51780
+ if (err) {
51781
+ Array.isArray(err) ? nestedErrors.push(...err) : nestedErrors.push(err);
51782
+ }
51783
+ if (--count <= 0) {
51784
+ nextOnce(nestedErrors);
51785
+ }
51786
+ });
51787
+ }
51788
+ }
51789
+ asNestedTest({
51790
+ key,
51791
+ index,
51792
+ parent,
51793
+ parentPath,
51794
+ originalParent,
51795
+ options
51796
+ }) {
51797
+ const k = key != null ? key : index;
51798
+ if (k == null) {
51799
+ throw TypeError('Must include `key` or `index` for nested validations');
51800
+ }
51801
+ const isIndex = typeof k === 'number';
51802
+ let value = parent[k];
51803
+ const testOptions = Object.assign({}, options, {
51804
+ // Nested validations fields are always strict:
51805
+ // 1. parent isn't strict so the casting will also have cast inner values
51806
+ // 2. parent is strict in which case the nested values weren't cast either
51807
+ strict: true,
51808
+ parent,
51809
+ value,
51810
+ originalValue: originalParent[k],
51811
+ // FIXME: tests depend on `index` being passed around deeply,
51812
+ // we should not let the options.key/index bleed through
51813
+ key: undefined,
51814
+ // index: undefined,
51815
+ [isIndex ? 'index' : 'key']: k,
51816
+ path: isIndex || k.includes('.') ? `${parentPath || ''}[${isIndex ? k : `"${k}"`}]` : (parentPath ? `${parentPath}.` : '') + key
51817
+ });
51818
+ return (_, panic, next) => this.resolve(testOptions)._validate(value, testOptions, panic, next);
51819
+ }
51820
+ validate(value, options) {
51821
+ var _options$disableStack2;
51822
+ let schema = this.resolve(Object.assign({}, options, {
51823
+ value
51824
+ }));
51825
+ let disableStackTrace = (_options$disableStack2 = options == null ? void 0 : options.disableStackTrace) != null ? _options$disableStack2 : schema.spec.disableStackTrace;
51826
+ return new Promise((resolve, reject) => schema._validate(value, options, (error, parsed) => {
51827
+ if (ValidationError.isError(error)) error.value = parsed;
51828
+ reject(error);
51829
+ }, (errors, validated) => {
51830
+ if (errors.length) reject(new ValidationError(errors, validated, undefined, undefined, disableStackTrace));else resolve(validated);
51831
+ }));
51832
+ }
51833
+ validateSync(value, options) {
51834
+ var _options$disableStack3;
51835
+ let schema = this.resolve(Object.assign({}, options, {
51836
+ value
51837
+ }));
51838
+ let result;
51839
+ let disableStackTrace = (_options$disableStack3 = options == null ? void 0 : options.disableStackTrace) != null ? _options$disableStack3 : schema.spec.disableStackTrace;
51840
+ schema._validate(value, Object.assign({}, options, {
51841
+ sync: true
51842
+ }), (error, parsed) => {
51843
+ if (ValidationError.isError(error)) error.value = parsed;
51844
+ throw error;
51845
+ }, (errors, validated) => {
51846
+ if (errors.length) throw new ValidationError(errors, value, undefined, undefined, disableStackTrace);
51847
+ result = validated;
51848
+ });
51849
+ return result;
51850
+ }
51851
+ isValid(value, options) {
51852
+ return this.validate(value, options).then(() => true, err => {
51853
+ if (ValidationError.isError(err)) return false;
51854
+ throw err;
51855
+ });
51856
+ }
51857
+ isValidSync(value, options) {
51858
+ try {
51859
+ this.validateSync(value, options);
51860
+ return true;
51861
+ } catch (err) {
51862
+ if (ValidationError.isError(err)) return false;
51863
+ throw err;
51864
+ }
51865
+ }
51866
+ _getDefault(options) {
51867
+ let defaultValue = this.spec.default;
51868
+ if (defaultValue == null) {
51869
+ return defaultValue;
51870
+ }
51871
+ return typeof defaultValue === 'function' ? defaultValue.call(this, options) : clone(defaultValue);
51872
+ }
51873
+ getDefault(options
51874
+ // If schema is defaulted we know it's at least not undefined
51875
+ ) {
51876
+ let schema = this.resolve(options || {});
51877
+ return schema._getDefault(options);
51878
+ }
51879
+ default(def) {
51880
+ if (arguments.length === 0) {
51881
+ return this._getDefault();
51882
+ }
51883
+ let next = this.clone({
51884
+ default: def
51885
+ });
51886
+ return next;
51887
+ }
51888
+ strict(isStrict = true) {
51889
+ return this.clone({
51890
+ strict: isStrict
51891
+ });
51892
+ }
51893
+ nullability(nullable, message) {
51894
+ const next = this.clone({
51895
+ nullable
51896
+ });
51897
+ next.internalTests.nullable = createValidation({
51898
+ message,
51899
+ name: 'nullable',
51900
+ test(value) {
51901
+ return value === null ? this.schema.spec.nullable : true;
51902
+ }
51903
+ });
51904
+ return next;
51905
+ }
51906
+ optionality(optional, message) {
51907
+ const next = this.clone({
51908
+ optional
51909
+ });
51910
+ next.internalTests.optionality = createValidation({
51911
+ message,
51912
+ name: 'optionality',
51913
+ test(value) {
51914
+ return value === undefined ? this.schema.spec.optional : true;
51915
+ }
51916
+ });
51917
+ return next;
51918
+ }
51919
+ optional() {
51920
+ return this.optionality(true);
51921
+ }
51922
+ defined(message = mixed.defined) {
51923
+ return this.optionality(false, message);
51924
+ }
51925
+ nullable() {
51926
+ return this.nullability(true);
51927
+ }
51928
+ nonNullable(message = mixed.notNull) {
51929
+ return this.nullability(false, message);
51930
+ }
51931
+ required(message = mixed.required) {
51932
+ return this.clone().withMutation(next => next.nonNullable(message).defined(message));
51933
+ }
51934
+ notRequired() {
51935
+ return this.clone().withMutation(next => next.nullable().optional());
51936
+ }
51937
+ transform(fn) {
51938
+ let next = this.clone();
51939
+ next.transforms.push(fn);
51940
+ return next;
51941
+ }
51942
+
51943
+ /**
51944
+ * Adds a test function to the schema's queue of tests.
51945
+ * tests can be exclusive or non-exclusive.
51946
+ *
51947
+ * - exclusive tests, will replace any existing tests of the same name.
51948
+ * - non-exclusive: can be stacked
51949
+ *
51950
+ * If a non-exclusive test is added to a schema with an exclusive test of the same name
51951
+ * the exclusive test is removed and further tests of the same name will be stacked.
51952
+ *
51953
+ * If an exclusive test is added to a schema with non-exclusive tests of the same name
51954
+ * the previous tests are removed and further tests of the same name will replace each other.
51955
+ */
51956
+
51957
+ test(...args) {
51958
+ let opts;
51959
+ if (args.length === 1) {
51960
+ if (typeof args[0] === 'function') {
51961
+ opts = {
51962
+ test: args[0]
51963
+ };
51964
+ } else {
51965
+ opts = args[0];
51966
+ }
51967
+ } else if (args.length === 2) {
51968
+ opts = {
51969
+ name: args[0],
51970
+ test: args[1]
51971
+ };
51972
+ } else {
51973
+ opts = {
51974
+ name: args[0],
51975
+ message: args[1],
51976
+ test: args[2]
51977
+ };
51978
+ }
51979
+ if (opts.message === undefined) opts.message = mixed.default;
51980
+ if (typeof opts.test !== 'function') throw new TypeError('`test` is a required parameters');
51981
+ let next = this.clone();
51982
+ let validate = createValidation(opts);
51983
+ let isExclusive = opts.exclusive || opts.name && next.exclusiveTests[opts.name] === true;
51984
+ if (opts.exclusive) {
51985
+ if (!opts.name) throw new TypeError('Exclusive tests must provide a unique `name` identifying the test');
51986
+ }
51987
+ if (opts.name) next.exclusiveTests[opts.name] = !!opts.exclusive;
51988
+ next.tests = next.tests.filter(fn => {
51989
+ if (fn.OPTIONS.name === opts.name) {
51990
+ if (isExclusive) return false;
51991
+ if (fn.OPTIONS.test === validate.OPTIONS.test) return false;
51992
+ }
51993
+ return true;
51994
+ });
51995
+ next.tests.push(validate);
51996
+ return next;
51997
+ }
51998
+ when(keys, options) {
51999
+ if (!Array.isArray(keys) && typeof keys !== 'string') {
52000
+ options = keys;
52001
+ keys = '.';
52002
+ }
52003
+ let next = this.clone();
52004
+ let deps = toArray(keys).map(key => new Reference(key));
52005
+ deps.forEach(dep => {
52006
+ // @ts-ignore readonly array
52007
+ if (dep.isSibling) next.deps.push(dep.key);
52008
+ });
52009
+ next.conditions.push(typeof options === 'function' ? new Condition(deps, options) : Condition.fromOptions(deps, options));
52010
+ return next;
52011
+ }
52012
+ typeError(message) {
52013
+ let next = this.clone();
52014
+ next.internalTests.typeError = createValidation({
52015
+ message,
52016
+ name: 'typeError',
52017
+ skipAbsent: true,
52018
+ test(value) {
52019
+ if (!this.schema._typeCheck(value)) return this.createError({
52020
+ params: {
52021
+ type: this.schema.type
52022
+ }
52023
+ });
52024
+ return true;
52025
+ }
52026
+ });
52027
+ return next;
52028
+ }
52029
+ oneOf(enums, message = mixed.oneOf) {
52030
+ let next = this.clone();
52031
+ enums.forEach(val => {
52032
+ next._whitelist.add(val);
52033
+ next._blacklist.delete(val);
52034
+ });
52035
+ next.internalTests.whiteList = createValidation({
52036
+ message,
52037
+ name: 'oneOf',
52038
+ skipAbsent: true,
52039
+ test(value) {
52040
+ let valids = this.schema._whitelist;
52041
+ let resolved = valids.resolveAll(this.resolve);
52042
+ return resolved.includes(value) ? true : this.createError({
52043
+ params: {
52044
+ values: Array.from(valids).join(', '),
52045
+ resolved
52046
+ }
52047
+ });
52048
+ }
52049
+ });
52050
+ return next;
52051
+ }
52052
+ notOneOf(enums, message = mixed.notOneOf) {
52053
+ let next = this.clone();
52054
+ enums.forEach(val => {
52055
+ next._blacklist.add(val);
52056
+ next._whitelist.delete(val);
52057
+ });
52058
+ next.internalTests.blacklist = createValidation({
52059
+ message,
52060
+ name: 'notOneOf',
52061
+ test(value) {
52062
+ let invalids = this.schema._blacklist;
52063
+ let resolved = invalids.resolveAll(this.resolve);
52064
+ if (resolved.includes(value)) return this.createError({
52065
+ params: {
52066
+ values: Array.from(invalids).join(', '),
52067
+ resolved
52068
+ }
52069
+ });
52070
+ return true;
52071
+ }
52072
+ });
52073
+ return next;
52074
+ }
52075
+ strip(strip = true) {
52076
+ let next = this.clone();
52077
+ next.spec.strip = strip;
52078
+ return next;
52079
+ }
52080
+
52081
+ /**
52082
+ * Return a serialized description of the schema including validations, flags, types etc.
52083
+ *
52084
+ * @param options Provide any needed context for resolving runtime schema alterations (lazy, when conditions, etc).
52085
+ */
52086
+ describe(options) {
52087
+ const next = (options ? this.resolve(options) : this).clone();
52088
+ const {
52089
+ label,
52090
+ meta,
52091
+ optional,
52092
+ nullable
52093
+ } = next.spec;
52094
+ const description = {
52095
+ meta,
52096
+ label,
52097
+ optional,
52098
+ nullable,
52099
+ default: next.getDefault(options),
52100
+ type: next.type,
52101
+ oneOf: next._whitelist.describe(),
52102
+ notOneOf: next._blacklist.describe(),
52103
+ tests: next.tests.map(fn => ({
52104
+ name: fn.OPTIONS.name,
52105
+ params: fn.OPTIONS.params
52106
+ })).filter((n, idx, list) => list.findIndex(c => c.name === n.name) === idx)
52107
+ };
52108
+ return description;
52109
+ }
52110
+ }
52111
+ // @ts-expect-error
52112
+ Schema.prototype.__isYupSchema__ = true;
52113
+ for (const method of ['validate', 'validateSync']) Schema.prototype[`${method}At`] = function (path, value, options = {}) {
52114
+ const {
52115
+ parent,
52116
+ parentPath,
52117
+ schema
52118
+ } = getIn(this, path, value, options.context);
52119
+ return schema[method](parent && parent[parentPath], Object.assign({}, options, {
52120
+ parent,
52121
+ path
52122
+ }));
52123
+ };
52124
+ for (const alias of ['equals', 'is']) Schema.prototype[alias] = Schema.prototype.oneOf;
52125
+ for (const alias of ['not', 'nope']) Schema.prototype[alias] = Schema.prototype.notOneOf;
52126
+
52127
+ const returnsTrue = () => true;
52128
+ function create$8(spec) {
52129
+ return new MixedSchema(spec);
52130
+ }
52131
+ class MixedSchema extends Schema {
52132
+ constructor(spec) {
52133
+ super(typeof spec === 'function' ? {
52134
+ type: 'mixed',
52135
+ check: spec
52136
+ } : Object.assign({
52137
+ type: 'mixed',
52138
+ check: returnsTrue
52139
+ }, spec));
52140
+ }
52141
+ }
52142
+ create$8.prototype = MixedSchema.prototype;
52143
+
52144
+ /**
52145
+ * This file is a modified version of the file from the following repository:
52146
+ * Date.parse with progressive enhancement for ISO 8601 <https://github.com/csnover/js-iso8601>
52147
+ * NON-CONFORMANT EDITION.
52148
+ * © 2011 Colin Snover <http://zetafleet.com>
52149
+ * Released under MIT license.
52150
+ */
52151
+
52152
+ // prettier-ignore
52153
+ // 1 YYYY 2 MM 3 DD 4 HH 5 mm 6 ss 7 msec 8 Z 9 ± 10 tzHH 11 tzmm
52154
+ const isoReg = /^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;
52155
+ function parseIsoDate(date) {
52156
+ const struct = parseDateStruct(date);
52157
+ if (!struct) return Date.parse ? Date.parse(date) : Number.NaN;
52158
+
52159
+ // timestamps without timezone identifiers should be considered local time
52160
+ if (struct.z === undefined && struct.plusMinus === undefined) {
52161
+ return new Date(struct.year, struct.month, struct.day, struct.hour, struct.minute, struct.second, struct.millisecond).valueOf();
52162
+ }
52163
+ let totalMinutesOffset = 0;
52164
+ if (struct.z !== 'Z' && struct.plusMinus !== undefined) {
52165
+ totalMinutesOffset = struct.hourOffset * 60 + struct.minuteOffset;
52166
+ if (struct.plusMinus === '+') totalMinutesOffset = 0 - totalMinutesOffset;
52167
+ }
52168
+ return Date.UTC(struct.year, struct.month, struct.day, struct.hour, struct.minute + totalMinutesOffset, struct.second, struct.millisecond);
52169
+ }
52170
+ function parseDateStruct(date) {
52171
+ var _regexResult$7$length, _regexResult$;
52172
+ const regexResult = isoReg.exec(date);
52173
+ if (!regexResult) return null;
52174
+
52175
+ // use of toNumber() avoids NaN timestamps caused by “undefined”
52176
+ // values being passed to Date constructor
52177
+ return {
52178
+ year: toNumber(regexResult[1]),
52179
+ month: toNumber(regexResult[2], 1) - 1,
52180
+ day: toNumber(regexResult[3], 1),
52181
+ hour: toNumber(regexResult[4]),
52182
+ minute: toNumber(regexResult[5]),
52183
+ second: toNumber(regexResult[6]),
52184
+ millisecond: regexResult[7] ?
52185
+ // allow arbitrary sub-second precision beyond milliseconds
52186
+ toNumber(regexResult[7].substring(0, 3)) : 0,
52187
+ precision: (_regexResult$7$length = (_regexResult$ = regexResult[7]) == null ? void 0 : _regexResult$.length) != null ? _regexResult$7$length : undefined,
52188
+ z: regexResult[8] || undefined,
52189
+ plusMinus: regexResult[9] || undefined,
52190
+ hourOffset: toNumber(regexResult[10]),
52191
+ minuteOffset: toNumber(regexResult[11])
52192
+ };
52193
+ }
52194
+ function toNumber(str, defaultValue = 0) {
52195
+ return Number(str) || defaultValue;
52196
+ }
52197
+
52198
+ // Taken from HTML spec: https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
52199
+ let rEmail =
52200
+ // eslint-disable-next-line
52201
+ /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
52202
+ let rUrl =
52203
+ // eslint-disable-next-line
52204
+ /^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i;
52205
+
52206
+ // eslint-disable-next-line
52207
+ let rUUID = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
52208
+ let yearMonthDay = '^\\d{4}-\\d{2}-\\d{2}';
52209
+ let hourMinuteSecond = '\\d{2}:\\d{2}:\\d{2}';
52210
+ let zOrOffset = '(([+-]\\d{2}(:?\\d{2})?)|Z)';
52211
+ let rIsoDateTime = new RegExp(`${yearMonthDay}T${hourMinuteSecond}(\\.\\d+)?${zOrOffset}$`);
52212
+ let isTrimmed = value => isAbsent(value) || value === value.trim();
52213
+ let objStringTag = {}.toString();
52214
+ function create$6() {
52215
+ return new StringSchema();
52216
+ }
52217
+ class StringSchema extends Schema {
52218
+ constructor() {
52219
+ super({
52220
+ type: 'string',
52221
+ check(value) {
52222
+ if (value instanceof String) value = value.valueOf();
52223
+ return typeof value === 'string';
52224
+ }
52225
+ });
52226
+ this.withMutation(() => {
52227
+ this.transform((value, _raw, ctx) => {
52228
+ if (!ctx.spec.coerce || ctx.isType(value)) return value;
52229
+
52230
+ // don't ever convert arrays
52231
+ if (Array.isArray(value)) return value;
52232
+ const strValue = value != null && value.toString ? value.toString() : value;
52233
+
52234
+ // no one wants plain objects converted to [Object object]
52235
+ if (strValue === objStringTag) return value;
52236
+ return strValue;
52237
+ });
52238
+ });
52239
+ }
52240
+ required(message) {
52241
+ return super.required(message).withMutation(schema => schema.test({
52242
+ message: message || mixed.required,
52243
+ name: 'required',
52244
+ skipAbsent: true,
52245
+ test: value => !!value.length
52246
+ }));
52247
+ }
52248
+ notRequired() {
52249
+ return super.notRequired().withMutation(schema => {
52250
+ schema.tests = schema.tests.filter(t => t.OPTIONS.name !== 'required');
52251
+ return schema;
52252
+ });
52253
+ }
52254
+ length(length, message = string.length) {
52255
+ return this.test({
52256
+ message,
52257
+ name: 'length',
52258
+ exclusive: true,
52259
+ params: {
52260
+ length
52261
+ },
52262
+ skipAbsent: true,
52263
+ test(value) {
52264
+ return value.length === this.resolve(length);
52265
+ }
52266
+ });
52267
+ }
52268
+ min(min, message = string.min) {
52269
+ return this.test({
52270
+ message,
52271
+ name: 'min',
52272
+ exclusive: true,
52273
+ params: {
52274
+ min
52275
+ },
52276
+ skipAbsent: true,
52277
+ test(value) {
52278
+ return value.length >= this.resolve(min);
52279
+ }
52280
+ });
52281
+ }
52282
+ max(max, message = string.max) {
52283
+ return this.test({
52284
+ name: 'max',
52285
+ exclusive: true,
52286
+ message,
52287
+ params: {
52288
+ max
52289
+ },
52290
+ skipAbsent: true,
52291
+ test(value) {
52292
+ return value.length <= this.resolve(max);
52293
+ }
52294
+ });
52295
+ }
52296
+ matches(regex, options) {
52297
+ let excludeEmptyString = false;
52298
+ let message;
52299
+ let name;
52300
+ if (options) {
52301
+ if (typeof options === 'object') {
52302
+ ({
52303
+ excludeEmptyString = false,
52304
+ message,
52305
+ name
52306
+ } = options);
52307
+ } else {
52308
+ message = options;
52309
+ }
52310
+ }
52311
+ return this.test({
52312
+ name: name || 'matches',
52313
+ message: message || string.matches,
52314
+ params: {
52315
+ regex
52316
+ },
52317
+ skipAbsent: true,
52318
+ test: value => value === '' && excludeEmptyString || value.search(regex) !== -1
52319
+ });
52320
+ }
52321
+ email(message = string.email) {
52322
+ return this.matches(rEmail, {
52323
+ name: 'email',
52324
+ message,
52325
+ excludeEmptyString: true
52326
+ });
52327
+ }
52328
+ url(message = string.url) {
52329
+ return this.matches(rUrl, {
52330
+ name: 'url',
52331
+ message,
52332
+ excludeEmptyString: true
52333
+ });
52334
+ }
52335
+ uuid(message = string.uuid) {
52336
+ return this.matches(rUUID, {
52337
+ name: 'uuid',
52338
+ message,
52339
+ excludeEmptyString: false
52340
+ });
52341
+ }
52342
+ datetime(options) {
52343
+ let message = '';
52344
+ let allowOffset;
52345
+ let precision;
52346
+ if (options) {
52347
+ if (typeof options === 'object') {
52348
+ ({
52349
+ message = '',
52350
+ allowOffset = false,
52351
+ precision = undefined
52352
+ } = options);
52353
+ } else {
52354
+ message = options;
52355
+ }
52356
+ }
52357
+ return this.matches(rIsoDateTime, {
52358
+ name: 'datetime',
52359
+ message: message || string.datetime,
52360
+ excludeEmptyString: true
52361
+ }).test({
52362
+ name: 'datetime_offset',
52363
+ message: message || string.datetime_offset,
52364
+ params: {
52365
+ allowOffset
52366
+ },
52367
+ skipAbsent: true,
52368
+ test: value => {
52369
+ if (!value || allowOffset) return true;
52370
+ const struct = parseDateStruct(value);
52371
+ if (!struct) return false;
52372
+ return !!struct.z;
52373
+ }
52374
+ }).test({
52375
+ name: 'datetime_precision',
52376
+ message: message || string.datetime_precision,
52377
+ params: {
52378
+ precision
52379
+ },
52380
+ skipAbsent: true,
52381
+ test: value => {
52382
+ if (!value || precision == undefined) return true;
52383
+ const struct = parseDateStruct(value);
52384
+ if (!struct) return false;
52385
+ return struct.precision === precision;
52386
+ }
52387
+ });
52388
+ }
52389
+
52390
+ //-- transforms --
52391
+ ensure() {
52392
+ return this.default('').transform(val => val === null ? '' : val);
52393
+ }
52394
+ trim(message = string.trim) {
52395
+ return this.transform(val => val != null ? val.trim() : val).test({
52396
+ message,
52397
+ name: 'trim',
52398
+ test: isTrimmed
52399
+ });
52400
+ }
52401
+ lowercase(message = string.lowercase) {
52402
+ return this.transform(value => !isAbsent(value) ? value.toLowerCase() : value).test({
52403
+ message,
52404
+ name: 'string_case',
52405
+ exclusive: true,
52406
+ skipAbsent: true,
52407
+ test: value => isAbsent(value) || value === value.toLowerCase()
52408
+ });
52409
+ }
52410
+ uppercase(message = string.uppercase) {
52411
+ return this.transform(value => !isAbsent(value) ? value.toUpperCase() : value).test({
52412
+ message,
52413
+ name: 'string_case',
52414
+ exclusive: true,
52415
+ skipAbsent: true,
52416
+ test: value => isAbsent(value) || value === value.toUpperCase()
52417
+ });
52418
+ }
52419
+ }
52420
+ create$6.prototype = StringSchema.prototype;
52421
+
52422
+ //
52423
+ // String Interfaces
52424
+ //
52425
+
52426
+ let isNaN$1 = value => value != +value;
52427
+ function create$5() {
52428
+ return new NumberSchema();
52429
+ }
52430
+ class NumberSchema extends Schema {
52431
+ constructor() {
52432
+ super({
52433
+ type: 'number',
52434
+ check(value) {
52435
+ if (value instanceof Number) value = value.valueOf();
52436
+ return typeof value === 'number' && !isNaN$1(value);
52437
+ }
52438
+ });
52439
+ this.withMutation(() => {
52440
+ this.transform((value, _raw, ctx) => {
52441
+ if (!ctx.spec.coerce) return value;
52442
+ let parsed = value;
52443
+ if (typeof parsed === 'string') {
52444
+ parsed = parsed.replace(/\s/g, '');
52445
+ if (parsed === '') return NaN;
52446
+ // don't use parseFloat to avoid positives on alpha-numeric strings
52447
+ parsed = +parsed;
52448
+ }
52449
+
52450
+ // null -> NaN isn't useful; treat all nulls as null and let it fail on
52451
+ // nullability check vs TypeErrors
52452
+ if (ctx.isType(parsed) || parsed === null) return parsed;
52453
+ return parseFloat(parsed);
52454
+ });
52455
+ });
52456
+ }
52457
+ min(min, message = number.min) {
52458
+ return this.test({
52459
+ message,
52460
+ name: 'min',
52461
+ exclusive: true,
52462
+ params: {
52463
+ min
52464
+ },
52465
+ skipAbsent: true,
52466
+ test(value) {
52467
+ return value >= this.resolve(min);
52468
+ }
52469
+ });
52470
+ }
52471
+ max(max, message = number.max) {
52472
+ return this.test({
52473
+ message,
52474
+ name: 'max',
52475
+ exclusive: true,
52476
+ params: {
52477
+ max
52478
+ },
52479
+ skipAbsent: true,
52480
+ test(value) {
52481
+ return value <= this.resolve(max);
52482
+ }
52483
+ });
52484
+ }
52485
+ lessThan(less, message = number.lessThan) {
52486
+ return this.test({
52487
+ message,
52488
+ name: 'max',
52489
+ exclusive: true,
52490
+ params: {
52491
+ less
52492
+ },
52493
+ skipAbsent: true,
52494
+ test(value) {
52495
+ return value < this.resolve(less);
52496
+ }
52497
+ });
52498
+ }
52499
+ moreThan(more, message = number.moreThan) {
52500
+ return this.test({
52501
+ message,
52502
+ name: 'min',
52503
+ exclusive: true,
52504
+ params: {
52505
+ more
52506
+ },
52507
+ skipAbsent: true,
52508
+ test(value) {
52509
+ return value > this.resolve(more);
52510
+ }
52511
+ });
52512
+ }
52513
+ positive(msg = number.positive) {
52514
+ return this.moreThan(0, msg);
52515
+ }
52516
+ negative(msg = number.negative) {
52517
+ return this.lessThan(0, msg);
52518
+ }
52519
+ integer(message = number.integer) {
52520
+ return this.test({
52521
+ name: 'integer',
52522
+ message,
52523
+ skipAbsent: true,
52524
+ test: val => Number.isInteger(val)
52525
+ });
52526
+ }
52527
+ truncate() {
52528
+ return this.transform(value => !isAbsent(value) ? value | 0 : value);
52529
+ }
52530
+ round(method) {
52531
+ var _method;
52532
+ let avail = ['ceil', 'floor', 'round', 'trunc'];
52533
+ method = ((_method = method) == null ? void 0 : _method.toLowerCase()) || 'round';
52534
+
52535
+ // this exists for symemtry with the new Math.trunc
52536
+ if (method === 'trunc') return this.truncate();
52537
+ if (avail.indexOf(method.toLowerCase()) === -1) throw new TypeError('Only valid options for round() are: ' + avail.join(', '));
52538
+ return this.transform(value => !isAbsent(value) ? Math[method](value) : value);
52539
+ }
52540
+ }
52541
+ create$5.prototype = NumberSchema.prototype;
52542
+
52543
+ //
52544
+ // Number Interfaces
52545
+ //
52546
+
52547
+ let invalidDate = new Date('');
52548
+ let isDate = obj => Object.prototype.toString.call(obj) === '[object Date]';
52549
+ class DateSchema extends Schema {
52550
+ constructor() {
52551
+ super({
52552
+ type: 'date',
52553
+ check(v) {
52554
+ return isDate(v) && !isNaN(v.getTime());
52555
+ }
52556
+ });
52557
+ this.withMutation(() => {
52558
+ this.transform((value, _raw, ctx) => {
52559
+ // null -> InvalidDate isn't useful; treat all nulls as null and let it fail on
52560
+ // nullability check vs TypeErrors
52561
+ if (!ctx.spec.coerce || ctx.isType(value) || value === null) return value;
52562
+ value = parseIsoDate(value);
52563
+
52564
+ // 0 is a valid timestamp equivalent to 1970-01-01T00:00:00Z(unix epoch) or before.
52565
+ return !isNaN(value) ? new Date(value) : DateSchema.INVALID_DATE;
52566
+ });
52567
+ });
52568
+ }
52569
+ prepareParam(ref, name) {
52570
+ let param;
52571
+ if (!Reference.isRef(ref)) {
52572
+ let cast = this.cast(ref);
52573
+ if (!this._typeCheck(cast)) throw new TypeError(`\`${name}\` must be a Date or a value that can be \`cast()\` to a Date`);
52574
+ param = cast;
52575
+ } else {
52576
+ param = ref;
52577
+ }
52578
+ return param;
52579
+ }
52580
+ min(min, message = date.min) {
52581
+ let limit = this.prepareParam(min, 'min');
52582
+ return this.test({
52583
+ message,
52584
+ name: 'min',
52585
+ exclusive: true,
52586
+ params: {
52587
+ min
52588
+ },
52589
+ skipAbsent: true,
52590
+ test(value) {
52591
+ return value >= this.resolve(limit);
52592
+ }
52593
+ });
52594
+ }
52595
+ max(max, message = date.max) {
52596
+ let limit = this.prepareParam(max, 'max');
52597
+ return this.test({
52598
+ message,
52599
+ name: 'max',
52600
+ exclusive: true,
52601
+ params: {
52602
+ max
52603
+ },
52604
+ skipAbsent: true,
52605
+ test(value) {
52606
+ return value <= this.resolve(limit);
52607
+ }
52608
+ });
52609
+ }
52610
+ }
52611
+ DateSchema.INVALID_DATE = invalidDate;
52612
+ DateSchema.prototype;
52613
+
52614
+ // @ts-expect-error
52615
+ function sortFields(fields, excludedEdges = []) {
52616
+ let edges = [];
52617
+ let nodes = new Set();
52618
+ let excludes = new Set(excludedEdges.map(([a, b]) => `${a}-${b}`));
52619
+ function addNode(depPath, key) {
52620
+ let node = propertyExpr.split(depPath)[0];
52621
+ nodes.add(node);
52622
+ if (!excludes.has(`${key}-${node}`)) edges.push([key, node]);
52623
+ }
52624
+ for (const key of Object.keys(fields)) {
52625
+ let value = fields[key];
52626
+ nodes.add(key);
52627
+ if (Reference.isRef(value) && value.isSibling) addNode(value.path, key);else if (isSchema(value) && 'deps' in value) value.deps.forEach(path => addNode(path, key));
52628
+ }
52629
+ return toposort$1.array(Array.from(nodes), edges).reverse();
52630
+ }
52631
+
52632
+ function findIndex(arr, err) {
52633
+ let idx = Infinity;
52634
+ arr.some((key, ii) => {
52635
+ var _err$path;
52636
+ if ((_err$path = err.path) != null && _err$path.includes(key)) {
52637
+ idx = ii;
52638
+ return true;
52639
+ }
52640
+ });
52641
+ return idx;
52642
+ }
52643
+ function sortByKeyOrder(keys) {
52644
+ return (a, b) => {
52645
+ return findIndex(keys, a) - findIndex(keys, b);
52646
+ };
52647
+ }
52648
+
52649
+ const parseJson = (value, _, ctx) => {
52650
+ if (typeof value !== 'string') {
52651
+ return value;
52652
+ }
52653
+ let parsed = value;
52654
+ try {
52655
+ parsed = JSON.parse(value);
52656
+ } catch (err) {
52657
+ /* */
52658
+ }
52659
+ return ctx.isType(parsed) ? parsed : value;
52660
+ };
52661
+
52662
+ // @ts-ignore
52663
+ function deepPartial(schema) {
52664
+ if ('fields' in schema) {
52665
+ const partial = {};
52666
+ for (const [key, fieldSchema] of Object.entries(schema.fields)) {
52667
+ partial[key] = deepPartial(fieldSchema);
52668
+ }
52669
+ return schema.setFields(partial);
52670
+ }
52671
+ if (schema.type === 'array') {
52672
+ const nextArray = schema.optional();
52673
+ if (nextArray.innerType) nextArray.innerType = deepPartial(nextArray.innerType);
52674
+ return nextArray;
52675
+ }
52676
+ if (schema.type === 'tuple') {
52677
+ return schema.optional().clone({
52678
+ types: schema.spec.types.map(deepPartial)
52679
+ });
52680
+ }
52681
+ if ('optional' in schema) {
52682
+ return schema.optional();
52683
+ }
52684
+ return schema;
52685
+ }
52686
+ const deepHas = (obj, p) => {
52687
+ const path = [...propertyExpr.normalizePath(p)];
52688
+ if (path.length === 1) return path[0] in obj;
52689
+ let last = path.pop();
52690
+ let parent = propertyExpr.getter(propertyExpr.join(path), true)(obj);
52691
+ return !!(parent && last in parent);
52692
+ };
52693
+ let isObject = obj => Object.prototype.toString.call(obj) === '[object Object]';
52694
+ function unknown(ctx, value) {
52695
+ let known = Object.keys(ctx.fields);
52696
+ return Object.keys(value).filter(key => known.indexOf(key) === -1);
52697
+ }
52698
+ const defaultSort = sortByKeyOrder([]);
52699
+ function create$3(spec) {
52700
+ return new ObjectSchema(spec);
52701
+ }
52702
+ class ObjectSchema extends Schema {
52703
+ constructor(spec) {
52704
+ super({
52705
+ type: 'object',
52706
+ check(value) {
52707
+ return isObject(value) || typeof value === 'function';
52708
+ }
52709
+ });
52710
+ this.fields = Object.create(null);
52711
+ this._sortErrors = defaultSort;
52712
+ this._nodes = [];
52713
+ this._excludedEdges = [];
52714
+ this.withMutation(() => {
52715
+ if (spec) {
52716
+ this.shape(spec);
52717
+ }
52718
+ });
52719
+ }
52720
+ _cast(_value, options = {}) {
52721
+ var _options$stripUnknown;
52722
+ let value = super._cast(_value, options);
52723
+
52724
+ //should ignore nulls here
52725
+ if (value === undefined) return this.getDefault(options);
52726
+ if (!this._typeCheck(value)) return value;
52727
+ let fields = this.fields;
52728
+ let strip = (_options$stripUnknown = options.stripUnknown) != null ? _options$stripUnknown : this.spec.noUnknown;
52729
+ let props = [].concat(this._nodes, Object.keys(value).filter(v => !this._nodes.includes(v)));
52730
+ let intermediateValue = {}; // is filled during the transform below
52731
+ let innerOptions = Object.assign({}, options, {
52732
+ parent: intermediateValue,
52733
+ __validating: options.__validating || false
52734
+ });
52735
+ let isChanged = false;
52736
+ for (const prop of props) {
52737
+ let field = fields[prop];
52738
+ let exists = (prop in value);
52739
+ if (field) {
52740
+ let fieldValue;
52741
+ let inputValue = value[prop];
52742
+
52743
+ // safe to mutate since this is fired in sequence
52744
+ innerOptions.path = (options.path ? `${options.path}.` : '') + prop;
52745
+ field = field.resolve({
52746
+ value: inputValue,
52747
+ context: options.context,
52748
+ parent: intermediateValue
52749
+ });
52750
+ let fieldSpec = field instanceof Schema ? field.spec : undefined;
52751
+ let strict = fieldSpec == null ? void 0 : fieldSpec.strict;
52752
+ if (fieldSpec != null && fieldSpec.strip) {
52753
+ isChanged = isChanged || prop in value;
52754
+ continue;
52755
+ }
52756
+ fieldValue = !options.__validating || !strict ?
52757
+ // TODO: use _cast, this is double resolving
52758
+ field.cast(value[prop], innerOptions) : value[prop];
52759
+ if (fieldValue !== undefined) {
52760
+ intermediateValue[prop] = fieldValue;
52761
+ }
52762
+ } else if (exists && !strip) {
52763
+ intermediateValue[prop] = value[prop];
52764
+ }
52765
+ if (exists !== prop in intermediateValue || intermediateValue[prop] !== value[prop]) {
52766
+ isChanged = true;
52767
+ }
52768
+ }
52769
+ return isChanged ? intermediateValue : value;
52770
+ }
52771
+ _validate(_value, options = {}, panic, next) {
52772
+ let {
52773
+ from = [],
52774
+ originalValue = _value,
52775
+ recursive = this.spec.recursive
52776
+ } = options;
52777
+ options.from = [{
52778
+ schema: this,
52779
+ value: originalValue
52780
+ }, ...from];
52781
+ // this flag is needed for handling `strict` correctly in the context of
52782
+ // validation vs just casting. e.g strict() on a field is only used when validating
52783
+ options.__validating = true;
52784
+ options.originalValue = originalValue;
52785
+ super._validate(_value, options, panic, (objectErrors, value) => {
52786
+ if (!recursive || !isObject(value)) {
52787
+ next(objectErrors, value);
52788
+ return;
52789
+ }
52790
+ originalValue = originalValue || value;
52791
+ let tests = [];
52792
+ for (let key of this._nodes) {
52793
+ let field = this.fields[key];
52794
+ if (!field || Reference.isRef(field)) {
52795
+ continue;
52796
+ }
52797
+ tests.push(field.asNestedTest({
52798
+ options,
52799
+ key,
52800
+ parent: value,
52801
+ parentPath: options.path,
52802
+ originalParent: originalValue
52803
+ }));
52804
+ }
52805
+ this.runTests({
52806
+ tests,
52807
+ value,
52808
+ originalValue,
52809
+ options
52810
+ }, panic, fieldErrors => {
52811
+ next(fieldErrors.sort(this._sortErrors).concat(objectErrors), value);
52812
+ });
52813
+ });
52814
+ }
52815
+ clone(spec) {
52816
+ const next = super.clone(spec);
52817
+ next.fields = Object.assign({}, this.fields);
52818
+ next._nodes = this._nodes;
52819
+ next._excludedEdges = this._excludedEdges;
52820
+ next._sortErrors = this._sortErrors;
52821
+ return next;
52822
+ }
52823
+ concat(schema) {
52824
+ let next = super.concat(schema);
52825
+ let nextFields = next.fields;
52826
+ for (let [field, schemaOrRef] of Object.entries(this.fields)) {
52827
+ const target = nextFields[field];
52828
+ nextFields[field] = target === undefined ? schemaOrRef : target;
52829
+ }
52830
+ return next.withMutation(s =>
52831
+ // XXX: excludes here is wrong
52832
+ s.setFields(nextFields, [...this._excludedEdges, ...schema._excludedEdges]));
52833
+ }
52834
+ _getDefault(options) {
52835
+ if ('default' in this.spec) {
52836
+ return super._getDefault(options);
52837
+ }
52838
+
52839
+ // if there is no default set invent one
52840
+ if (!this._nodes.length) {
52841
+ return undefined;
52842
+ }
52843
+ let dft = {};
52844
+ this._nodes.forEach(key => {
52845
+ var _innerOptions;
52846
+ const field = this.fields[key];
52847
+ let innerOptions = options;
52848
+ if ((_innerOptions = innerOptions) != null && _innerOptions.value) {
52849
+ innerOptions = Object.assign({}, innerOptions, {
52850
+ parent: innerOptions.value,
52851
+ value: innerOptions.value[key]
52852
+ });
52853
+ }
52854
+ dft[key] = field && 'getDefault' in field ? field.getDefault(innerOptions) : undefined;
52855
+ });
52856
+ return dft;
52857
+ }
52858
+ setFields(shape, excludedEdges) {
52859
+ let next = this.clone();
52860
+ next.fields = shape;
52861
+ next._nodes = sortFields(shape, excludedEdges);
52862
+ next._sortErrors = sortByKeyOrder(Object.keys(shape));
52863
+ // XXX: this carries over edges which may not be what you want
52864
+ if (excludedEdges) next._excludedEdges = excludedEdges;
52865
+ return next;
52866
+ }
52867
+ shape(additions, excludes = []) {
52868
+ return this.clone().withMutation(next => {
52869
+ let edges = next._excludedEdges;
52870
+ if (excludes.length) {
52871
+ if (!Array.isArray(excludes[0])) excludes = [excludes];
52872
+ edges = [...next._excludedEdges, ...excludes];
52873
+ }
52874
+
52875
+ // XXX: excludes here is wrong
52876
+ return next.setFields(Object.assign(next.fields, additions), edges);
52877
+ });
52878
+ }
52879
+ partial() {
52880
+ const partial = {};
52881
+ for (const [key, schema] of Object.entries(this.fields)) {
52882
+ partial[key] = 'optional' in schema && schema.optional instanceof Function ? schema.optional() : schema;
52883
+ }
52884
+ return this.setFields(partial);
52885
+ }
52886
+ deepPartial() {
52887
+ const next = deepPartial(this);
52888
+ return next;
52889
+ }
52890
+ pick(keys) {
52891
+ const picked = {};
52892
+ for (const key of keys) {
52893
+ if (this.fields[key]) picked[key] = this.fields[key];
52894
+ }
52895
+ return this.setFields(picked, this._excludedEdges.filter(([a, b]) => keys.includes(a) && keys.includes(b)));
52896
+ }
52897
+ omit(keys) {
52898
+ const remaining = [];
52899
+ for (const key of Object.keys(this.fields)) {
52900
+ if (keys.includes(key)) continue;
52901
+ remaining.push(key);
52902
+ }
52903
+ return this.pick(remaining);
52904
+ }
52905
+ from(from, to, alias) {
52906
+ let fromGetter = propertyExpr.getter(from, true);
52907
+ return this.transform(obj => {
52908
+ if (!obj) return obj;
52909
+ let newObj = obj;
52910
+ if (deepHas(obj, from)) {
52911
+ newObj = Object.assign({}, obj);
52912
+ if (!alias) delete newObj[from];
52913
+ newObj[to] = fromGetter(obj);
52914
+ }
52915
+ return newObj;
52916
+ });
52917
+ }
52918
+
52919
+ /** Parse an input JSON string to an object */
52920
+ json() {
52921
+ return this.transform(parseJson);
52922
+ }
52923
+ noUnknown(noAllow = true, message = object.noUnknown) {
52924
+ if (typeof noAllow !== 'boolean') {
52925
+ message = noAllow;
52926
+ noAllow = true;
52927
+ }
52928
+ let next = this.test({
52929
+ name: 'noUnknown',
52930
+ exclusive: true,
52931
+ message: message,
52932
+ test(value) {
52933
+ if (value == null) return true;
52934
+ const unknownKeys = unknown(this.schema, value);
52935
+ return !noAllow || unknownKeys.length === 0 || this.createError({
52936
+ params: {
52937
+ unknown: unknownKeys.join(', ')
52938
+ }
52939
+ });
52940
+ }
52941
+ });
52942
+ next.spec.noUnknown = noAllow;
52943
+ return next;
52944
+ }
52945
+ unknown(allow = true, message = object.noUnknown) {
52946
+ return this.noUnknown(!allow, message);
52947
+ }
52948
+ transformKeys(fn) {
52949
+ return this.transform(obj => {
52950
+ if (!obj) return obj;
52951
+ const result = {};
52952
+ for (const key of Object.keys(obj)) result[fn(key)] = obj[key];
52953
+ return result;
52954
+ });
52955
+ }
52956
+ camelCase() {
52957
+ return this.transformKeys(tinyCase.camelCase);
52958
+ }
52959
+ snakeCase() {
52960
+ return this.transformKeys(tinyCase.snakeCase);
52961
+ }
52962
+ constantCase() {
52963
+ return this.transformKeys(key => tinyCase.snakeCase(key).toUpperCase());
52964
+ }
52965
+ describe(options) {
52966
+ const next = (options ? this.resolve(options) : this).clone();
52967
+ const base = super.describe(options);
52968
+ base.fields = {};
52969
+ for (const [key, value] of Object.entries(next.fields)) {
52970
+ var _innerOptions2;
52971
+ let innerOptions = options;
52972
+ if ((_innerOptions2 = innerOptions) != null && _innerOptions2.value) {
52973
+ innerOptions = Object.assign({}, innerOptions, {
52974
+ parent: innerOptions.value,
52975
+ value: innerOptions.value[key]
52976
+ });
52977
+ }
52978
+ base.fields[key] = value.describe(innerOptions);
52979
+ }
52980
+ return base;
52981
+ }
52982
+ }
52983
+ create$3.prototype = ObjectSchema.prototype;
52984
+
52985
+ const useFormValidatingContext = (formArray) => {
52986
+ const initialValues = {};
52987
+ const validationShape = {};
52988
+ formArray.forEach((field) => {
52989
+ switch (field.inputType) {
52990
+ case "text":
52991
+ initialValues[field.name] = "";
52992
+ if (field.required) {
52993
+ validationShape[field.name] = create$6()
52994
+ .typeError(`Select ${field.label}`)
52995
+ .required(field.errorMessage);
52996
+ }
52997
+ break;
52998
+ case "number":
52999
+ initialValues[field.name] = null;
53000
+ if (field.required) {
53001
+ validationShape[field.name] = create$5()
53002
+ .nullable()
53003
+ .typeError(`Enters ${field.label}`)
53004
+ .required(field.errorMessage);
53005
+ }
53006
+ break;
53007
+ case "password":
53008
+ initialValues[field.name] = "";
53009
+ if (field.required) {
53010
+ validationShape[field.name] = create$5()
53011
+ .nullable()
53012
+ .typeError(`Enters ${field.label}`)
53013
+ .required(field.errorMessage);
53014
+ }
53015
+ break;
53016
+ case "select":
53017
+ initialValues[field.name] = "";
53018
+ if (field.required) {
53019
+ validationShape[field.name] = create$6()
53020
+ .typeError(`Select ${field.label}`)
53021
+ .required(field.errorMessage);
53022
+ }
53023
+ break;
53024
+ case "multiselect":
53025
+ initialValues[field.name] = null;
53026
+ if (field.required) {
53027
+ validationShape[field.name] = validationShape[field.name] =
53028
+ create$6()
53029
+ .typeError(`Select atleast one ${field.label}`)
53030
+ .required(field.errorMessage);
53031
+ }
53032
+ break;
53033
+ case "datepicker":
53034
+ initialValues[field.name] = null;
53035
+ if (field.required) {
53036
+ validationShape[field.name] = validationShape[field.name] =
53037
+ create$6()
53038
+ .typeError(`Select ${field.label}`)
53039
+ .required(field.errorMessage);
53040
+ }
53041
+ break;
53042
+ case "dateRangePicker":
53043
+ const today = new Date();
53044
+ const day = String(today.getDate()).padStart(2, "0");
53045
+ const month = String(today.getMonth() + 1).padStart(2, "0"); // January is 0!
53046
+ const year = today.getFullYear();
53047
+ const formattedDate = `${day}/${month}/${year}`;
53048
+ const threeMonthsAgo = new Date(today);
53049
+ threeMonthsAgo.setMonth(today.getMonth() - 3);
53050
+ const dayBeforeThreeMonths = String(threeMonthsAgo.getDate()).padStart(2, "0");
53051
+ const monthBeforeThreeMonths = String(threeMonthsAgo.getMonth() + 1).padStart(2, "0"); // January is 0!
53052
+ const yearBeforeThreeMonths = threeMonthsAgo.getFullYear();
53053
+ const formattedDateForThreeMonths = `${dayBeforeThreeMonths}/${monthBeforeThreeMonths}/${yearBeforeThreeMonths}`;
53054
+ initialValues["FromDate"] = formattedDateForThreeMonths;
53055
+ initialValues["ToDate"] = formattedDate;
53056
+ if (field.required) {
53057
+ validationShape[field.name] = validationShape[field.name] =
53058
+ create$6()
53059
+ .typeError(`Select ${field.label}`)
53060
+ .required(field.errorMessage);
53061
+ }
53062
+ break;
53063
+ default:
53064
+ initialValues[field.name] = null; // default value if inputType is not recognized
53065
+ if (field.required) {
53066
+ validationShape[field.name] = create$8().required(field.errorMessage);
53067
+ }
53068
+ break;
53069
+ }
53070
+ });
53071
+ const validationSchema = create$3().shape(validationShape);
53072
+ return { validationSchema, initialValues };
53073
+ };
53074
+
53075
+ export { Button$1 as Button, FormRenderWrapper as RenderForm, useFormValidatingContext };
50749
53076
  //# sourceMappingURL=index.esm.js.map