@me1a/ui 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/{hook-forms/index → example}/hook-forms/index.d.ts +2 -0
  2. package/dist/example/index.cjs.js.map +1 -0
  3. package/dist/example/index.es.js.map +1 -0
  4. package/dist/{index → hook-forms}/hook-forms/index.d.ts +2 -0
  5. package/dist/hook-forms/{index/index.cjs.js → index.cjs.js} +2780 -21
  6. package/dist/hook-forms/index.cjs.js.map +1 -0
  7. package/dist/hook-forms/{index/index.es.js → index.es.js} +2779 -22
  8. package/dist/hook-forms/index.es.js.map +1 -0
  9. package/dist/{index/index.cjs.js → index.cjs.js} +2780 -21
  10. package/dist/index.cjs.js.map +1 -0
  11. package/dist/{index/index.es.js → index.es.js} +2779 -22
  12. package/dist/index.es.js.map +1 -0
  13. package/package.json +21 -2
  14. package/dist/example/index/hook-forms/index.d.ts +0 -9
  15. package/dist/example/index/index.cjs.js.map +0 -1
  16. package/dist/example/index/index.es.js.map +0 -1
  17. package/dist/hook-forms/index/index.cjs.js.map +0 -1
  18. package/dist/hook-forms/index/index.es.js.map +0 -1
  19. package/dist/index/example/index.d.ts +0 -1
  20. package/dist/index/index.cjs.js.map +0 -1
  21. package/dist/index/index.es.js.map +0 -1
  22. /package/dist/example/{index/example → example}/index.d.ts +0 -0
  23. /package/dist/example/{index/example → example}/simple.d.ts +0 -0
  24. /package/dist/example/{index/hook-forms → hook-forms}/form-provider.d.ts +0 -0
  25. /package/dist/example/{index/hook-forms → hook-forms}/rhf-autocomplete.d.ts +0 -0
  26. /package/dist/example/{index/hook-forms → hook-forms}/rhf-checkbox.d.ts +0 -0
  27. /package/dist/example/{index/hook-forms → hook-forms}/rhf-radio-group.d.ts +0 -0
  28. /package/dist/example/{index/hook-forms → hook-forms}/rhf-select.d.ts +0 -0
  29. /package/dist/example/{index/hook-forms → hook-forms}/rhf-slider.d.ts +0 -0
  30. /package/dist/example/{index/hook-forms → hook-forms}/rhf-switch.d.ts +0 -0
  31. /package/dist/example/{index/hook-forms → hook-forms}/rhf-text-field.d.ts +0 -0
  32. /package/dist/example/{index/index.cjs.js → index.cjs.js} +0 -0
  33. /package/dist/example/{index/index.d.ts → index.d.ts} +0 -0
  34. /package/dist/example/{index/index.es.js → index.es.js} +0 -0
  35. /package/dist/{hook-forms/index/example → example}/simple.d.ts +0 -0
  36. /package/dist/hook-forms/{index/example → example}/index.d.ts +0 -0
  37. /package/dist/{index → hook-forms}/example/simple.d.ts +0 -0
  38. /package/dist/hook-forms/{index/hook-forms/form-provider.d.ts → form-provider.d.ts} +0 -0
  39. /package/dist/{index → hook-forms}/hook-forms/form-provider.d.ts +0 -0
  40. /package/dist/hook-forms/{index/hook-forms → hook-forms}/rhf-autocomplete.d.ts +0 -0
  41. /package/dist/hook-forms/{index/hook-forms → hook-forms}/rhf-checkbox.d.ts +0 -0
  42. /package/dist/hook-forms/{index/hook-forms → hook-forms}/rhf-radio-group.d.ts +0 -0
  43. /package/dist/hook-forms/{index/hook-forms → hook-forms}/rhf-select.d.ts +0 -0
  44. /package/dist/hook-forms/{index/hook-forms → hook-forms}/rhf-slider.d.ts +0 -0
  45. /package/dist/hook-forms/{index/hook-forms → hook-forms}/rhf-switch.d.ts +0 -0
  46. /package/dist/hook-forms/{index/hook-forms → hook-forms}/rhf-text-field.d.ts +0 -0
  47. /package/dist/hook-forms/{index/index.d.ts → index.d.ts} +0 -0
  48. /package/dist/{index/hook-forms → hook-forms}/rhf-autocomplete.d.ts +0 -0
  49. /package/dist/{index/hook-forms → hook-forms}/rhf-checkbox.d.ts +0 -0
  50. /package/dist/{index/hook-forms → hook-forms}/rhf-radio-group.d.ts +0 -0
  51. /package/dist/{index/hook-forms → hook-forms}/rhf-select.d.ts +0 -0
  52. /package/dist/{index/hook-forms → hook-forms}/rhf-slider.d.ts +0 -0
  53. /package/dist/{index/hook-forms → hook-forms}/rhf-switch.d.ts +0 -0
  54. /package/dist/{index/hook-forms → hook-forms}/rhf-text-field.d.ts +0 -0
  55. /package/dist/{index/index.d.ts → index.d.ts} +0 -0
@@ -1409,12 +1409,12 @@ var isDateObject = (value) => value instanceof Date;
1409
1409
  var isNullOrUndefined = (value) => value == null;
1410
1410
 
1411
1411
  const isObjectType = (value) => typeof value === 'object';
1412
- var isObject = (value) => !isNullOrUndefined(value) &&
1412
+ var isObject$1 = (value) => !isNullOrUndefined(value) &&
1413
1413
  !Array.isArray(value) &&
1414
1414
  isObjectType(value) &&
1415
1415
  !isDateObject(value);
1416
1416
 
1417
- var getEventValue = (event) => isObject(event) && event.target
1417
+ var getEventValue = (event) => isObject$1(event) && event.target
1418
1418
  ? isCheckBoxInput(event.target)
1419
1419
  ? event.target.checked
1420
1420
  : event.target.value
@@ -1426,7 +1426,7 @@ var isNameInFieldArray = (names, name) => names.has(getNodeParentName(name));
1426
1426
 
1427
1427
  var isPlainObject$1 = (tempObject) => {
1428
1428
  const prototypeCopy = tempObject.constructor && tempObject.constructor.prototype;
1429
- return (isObject(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf'));
1429
+ return (isObject$1(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf'));
1430
1430
  };
1431
1431
 
1432
1432
  var isWeb = typeof window !== 'undefined' &&
@@ -1443,7 +1443,7 @@ function cloneObject(data) {
1443
1443
  copy = new Set(data);
1444
1444
  }
1445
1445
  else if (!(isWeb && (data instanceof Blob || data instanceof FileList)) &&
1446
- (isArray || isObject(data))) {
1446
+ (isArray || isObject$1(data))) {
1447
1447
  copy = isArray ? [] : {};
1448
1448
  if (!isArray && !isPlainObject$1(data)) {
1449
1449
  copy = data;
@@ -1467,7 +1467,7 @@ var compact = (value) => Array.isArray(value) ? value.filter(Boolean) : [];
1467
1467
  var isUndefined = (val) => val === undefined;
1468
1468
 
1469
1469
  var get = (object, path, defaultValue) => {
1470
- if (!path || !isObject(object)) {
1470
+ if (!path || !isObject$1(object)) {
1471
1471
  return defaultValue;
1472
1472
  }
1473
1473
  const result = compact(path.split(/[,[\].]+?/)).reduce((result, key) => isNullOrUndefined(result) ? result : result[key], object);
@@ -1495,7 +1495,7 @@ var set = (object, path, value) => {
1495
1495
  if (index !== lastIndex) {
1496
1496
  const objValue = object[key];
1497
1497
  newValue =
1498
- isObject(objValue) || Array.isArray(objValue)
1498
+ isObject$1(objValue) || Array.isArray(objValue)
1499
1499
  ? objValue
1500
1500
  : !isNaN(+tempPath[index + 1])
1501
1501
  ? []
@@ -1618,7 +1618,7 @@ var getProxyFormState = (formState, control, localProxyFormState, isRoot = true)
1618
1618
  return result;
1619
1619
  };
1620
1620
 
1621
- var isEmptyObject = (value) => isObject(value) && !Object.keys(value).length;
1621
+ var isEmptyObject = (value) => isObject$1(value) && !Object.keys(value).length;
1622
1622
 
1623
1623
  var shouldRenderFormState = (formStateData, _proxyFormState, updateFormState, isRoot) => {
1624
1624
  updateFormState(formStateData);
@@ -2123,7 +2123,7 @@ const iterateFieldsByAction = (fields, action, fieldsNames, abortEarly) => {
2123
2123
  }
2124
2124
  }
2125
2125
  }
2126
- else if (isObject(currentField)) {
2126
+ else if (isObject$1(currentField)) {
2127
2127
  if (iterateFieldsByAction(currentField, action)) {
2128
2128
  break;
2129
2129
  }
@@ -2209,7 +2209,7 @@ function getValidateError(result, ref, type = 'validate') {
2209
2209
  }
2210
2210
  }
2211
2211
 
2212
- var getValueAndMessage = (validationData) => isObject(validationData) && !isRegex(validationData)
2212
+ var getValueAndMessage = (validationData) => isObject$1(validationData) && !isRegex(validationData)
2213
2213
  ? validationData
2214
2214
  : {
2215
2215
  value: validationData,
@@ -2362,7 +2362,7 @@ var validateField = async (field, formValues, validateAllFieldCriteria, shouldUs
2362
2362
  }
2363
2363
  }
2364
2364
  }
2365
- else if (isObject(validate)) {
2365
+ else if (isObject$1(validate)) {
2366
2366
  let validationResult = {};
2367
2367
  for (const key in validate) {
2368
2368
  if (!isEmptyObject(validationResult) && !validateAllFieldCriteria) {
@@ -2472,7 +2472,7 @@ function unset(object, path) {
2472
2472
  delete childObject[key];
2473
2473
  }
2474
2474
  if (index !== 0 &&
2475
- ((isObject(childObject) && isEmptyObject(childObject)) ||
2475
+ ((isObject$1(childObject) && isEmptyObject(childObject)) ||
2476
2476
  (Array.isArray(childObject) && isEmptyArray(childObject)))) {
2477
2477
  unset(object, paths.slice(0, -1));
2478
2478
  }
@@ -2765,7 +2765,7 @@ function deepEqual(object1, object2) {
2765
2765
  if (key !== 'ref') {
2766
2766
  const val2 = object2[key];
2767
2767
  if ((isDateObject(val1) && isDateObject(val2)) ||
2768
- (isObject(val1) && isObject(val2)) ||
2768
+ (isObject$1(val1) && isObject$1(val2)) ||
2769
2769
  (Array.isArray(val1) && Array.isArray(val2))
2770
2770
  ? !deepEqual(val1, val2)
2771
2771
  : val1 !== val2) {
@@ -2793,10 +2793,10 @@ var objectHasFunction = (data) => {
2793
2793
 
2794
2794
  function markFieldsDirty(data, fields = {}) {
2795
2795
  const isParentNodeArray = Array.isArray(data);
2796
- if (isObject(data) || isParentNodeArray) {
2796
+ if (isObject$1(data) || isParentNodeArray) {
2797
2797
  for (const key in data) {
2798
2798
  if (Array.isArray(data[key]) ||
2799
- (isObject(data[key]) && !objectHasFunction(data[key]))) {
2799
+ (isObject$1(data[key]) && !objectHasFunction(data[key]))) {
2800
2800
  fields[key] = Array.isArray(data[key]) ? [] : {};
2801
2801
  markFieldsDirty(data[key], fields[key]);
2802
2802
  }
@@ -2809,10 +2809,10 @@ function markFieldsDirty(data, fields = {}) {
2809
2809
  }
2810
2810
  function getDirtyFieldsFromDefaultValues(data, formValues, dirtyFieldsFromValues) {
2811
2811
  const isParentNodeArray = Array.isArray(data);
2812
- if (isObject(data) || isParentNodeArray) {
2812
+ if (isObject$1(data) || isParentNodeArray) {
2813
2813
  for (const key in data) {
2814
2814
  if (Array.isArray(data[key]) ||
2815
- (isObject(data[key]) && !objectHasFunction(data[key]))) {
2815
+ (isObject$1(data[key]) && !objectHasFunction(data[key]))) {
2816
2816
  if (isUndefined(formValues) ||
2817
2817
  isPrimitive(dirtyFieldsFromValues[key])) {
2818
2818
  dirtyFieldsFromValues[key] = Array.isArray(data[key])
@@ -2884,7 +2884,7 @@ var getRuleValue = (rule) => isUndefined(rule)
2884
2884
  ? rule
2885
2885
  : isRegex(rule)
2886
2886
  ? rule.source
2887
- : isObject(rule)
2887
+ : isObject$1(rule)
2888
2888
  ? isRegex(rule.value)
2889
2889
  ? rule.value.source
2890
2890
  : rule.value
@@ -2894,7 +2894,7 @@ const ASYNC_FUNCTION = 'AsyncFunction';
2894
2894
  var hasPromiseValidation = (fieldReference) => (!fieldReference || !fieldReference.validate) &&
2895
2895
  !!((isFunction(fieldReference.validate) &&
2896
2896
  fieldReference.validate.constructor.name === ASYNC_FUNCTION) ||
2897
- (isObject(fieldReference.validate) &&
2897
+ (isObject$1(fieldReference.validate) &&
2898
2898
  Object.values(fieldReference.validate).find((validateFunction) => validateFunction.constructor.name === ASYNC_FUNCTION)));
2899
2899
 
2900
2900
  var hasValidation = (options) => options.mount &&
@@ -2979,7 +2979,7 @@ function createFormControl(props = {}) {
2979
2979
  disabled: _options.disabled || false,
2980
2980
  };
2981
2981
  let _fields = {};
2982
- let _defaultValues = isObject(_options.defaultValues) || isObject(_options.values)
2982
+ let _defaultValues = isObject$1(_options.defaultValues) || isObject$1(_options.values)
2983
2983
  ? cloneObject(_options.defaultValues || _options.values) || {}
2984
2984
  : {};
2985
2985
  let _formValues = _options.shouldUnregister
@@ -3314,7 +3314,7 @@ function createFormControl(props = {}) {
3314
3314
  const fieldName = `${name}.${fieldKey}`;
3315
3315
  const field = get(_fields, fieldName);
3316
3316
  (_names.array.has(name) ||
3317
- isObject(fieldValue) ||
3317
+ isObject$1(fieldValue) ||
3318
3318
  (field && !field._f)) &&
3319
3319
  !isDateObject(fieldValue)
3320
3320
  ? setValues(fieldName, fieldValue, options)
@@ -5249,7 +5249,7 @@ function requirePropTypes () {
5249
5249
  var propTypesExports = /*@__PURE__*/ requirePropTypes();
5250
5250
  var PropTypes = /*@__PURE__*/getDefaultExportFromCjs(propTypesExports);
5251
5251
 
5252
- function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
5252
+ function r$1(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r$1(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r$1(e))&&(n&&(n+=" "),n+=t);return n}
5253
5253
 
5254
5254
  /* eslint no-restricted-syntax: 0, prefer-template: 0, guard-for-in: 0
5255
5255
  ---
@@ -27248,6 +27248,2763 @@ function FormProvider({
27248
27248
  });
27249
27249
  }
27250
27250
 
27251
+ const s=(e,s,o)=>{if(e&&"reportValidity"in e){const r=get(o,s);e.setCustomValidity(r&&r.message||""),e.reportValidity();}},o$1=(t,e)=>{for(const o in e.fields){const r=e.fields[o];r&&r.ref&&"reportValidity"in r.ref?s(r.ref,o,t):r.refs&&r.refs.forEach(e=>s(e,o,t));}},r=(s,r)=>{r.shouldUseNativeValidation&&o$1(s,r);const f={};for(const o in s){const n=get(r.fields,o),a=Object.assign(s[o]||{},{ref:n&&n.ref});if(i(r.names||Object.keys(s),o)){const s=Object.assign({},get(f,o));set(s,"root",a),set(f,o,s);}else set(f,o,a);}return f},i=(t,e)=>t.some(t=>t.startsWith(e+"."));
27252
+
27253
+ function o(o,n,a){return void 0===n&&(n={}),void 0===a&&(a={}),function(s,i,c){try{return Promise.resolve(function(t,r){try{var u=(n.context&&"development"===process.env.NODE_ENV&&console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead"),Promise.resolve(o["sync"===a.mode?"validateSync":"validate"](s,Object.assign({abortEarly:!1},n,{context:i}))).then(function(t){return c.shouldUseNativeValidation&&o$1({},c),{values:a.raw?s:t,errors:{}}}));}catch(e){return r(e)}return u&&u.then?u.then(void 0,r):u}(0,function(e){if(!e.inner)throw e;return {values:{},errors:r((o=e,n=!c.shouldUseNativeValidation&&"all"===c.criteriaMode,(o.inner||[]).reduce(function(e,t){if(e[t.path]||(e[t.path]={message:t.message,type:t.type}),n){var o=e[t.path].types,a=o&&o[t.type];e[t.path]=appendErrors(t.path,n,e,t.type,a?[].concat(a,t.message):t.message);}return e},{})),c)};var o,n;}))}catch(e){return Promise.reject(e)}}}
27254
+
27255
+ /**
27256
+ * Based on Kendo UI Core expression code <https://github.com/telerik/kendo-ui-core#license-information>
27257
+ */
27258
+
27259
+ var propertyExpr;
27260
+ var hasRequiredPropertyExpr;
27261
+
27262
+ function requirePropertyExpr () {
27263
+ if (hasRequiredPropertyExpr) return propertyExpr;
27264
+ hasRequiredPropertyExpr = 1;
27265
+
27266
+ function Cache(maxSize) {
27267
+ this._maxSize = maxSize;
27268
+ this.clear();
27269
+ }
27270
+ Cache.prototype.clear = function () {
27271
+ this._size = 0;
27272
+ this._values = Object.create(null);
27273
+ };
27274
+ Cache.prototype.get = function (key) {
27275
+ return this._values[key]
27276
+ };
27277
+ Cache.prototype.set = function (key, value) {
27278
+ this._size >= this._maxSize && this.clear();
27279
+ if (!(key in this._values)) this._size++;
27280
+
27281
+ return (this._values[key] = value)
27282
+ };
27283
+
27284
+ var SPLIT_REGEX = /[^.^\]^[]+|(?=\[\]|\.\.)/g,
27285
+ DIGIT_REGEX = /^\d+$/,
27286
+ LEAD_DIGIT_REGEX = /^\d/,
27287
+ SPEC_CHAR_REGEX = /[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,
27288
+ CLEAN_QUOTES_REGEX = /^\s*(['"]?)(.*?)(\1)\s*$/,
27289
+ MAX_CACHE_SIZE = 512;
27290
+
27291
+ var pathCache = new Cache(MAX_CACHE_SIZE),
27292
+ setCache = new Cache(MAX_CACHE_SIZE),
27293
+ getCache = new Cache(MAX_CACHE_SIZE);
27294
+
27295
+ propertyExpr = {
27296
+ Cache: Cache,
27297
+
27298
+ split: split,
27299
+
27300
+ normalizePath: normalizePath,
27301
+
27302
+ setter: function (path) {
27303
+ var parts = normalizePath(path);
27304
+
27305
+ return (
27306
+ setCache.get(path) ||
27307
+ setCache.set(path, function setter(obj, value) {
27308
+ var index = 0;
27309
+ var len = parts.length;
27310
+ var data = obj;
27311
+
27312
+ while (index < len - 1) {
27313
+ var part = parts[index];
27314
+ if (
27315
+ part === '__proto__' ||
27316
+ part === 'constructor' ||
27317
+ part === 'prototype'
27318
+ ) {
27319
+ return obj
27320
+ }
27321
+
27322
+ data = data[parts[index++]];
27323
+ }
27324
+ data[parts[index]] = value;
27325
+ })
27326
+ )
27327
+ },
27328
+
27329
+ getter: function (path, safe) {
27330
+ var parts = normalizePath(path);
27331
+ return (
27332
+ getCache.get(path) ||
27333
+ getCache.set(path, function getter(data) {
27334
+ var index = 0,
27335
+ len = parts.length;
27336
+ while (index < len) {
27337
+ if (data != null || !safe) data = data[parts[index++]];
27338
+ else return
27339
+ }
27340
+ return data
27341
+ })
27342
+ )
27343
+ },
27344
+
27345
+ join: function (segments) {
27346
+ return segments.reduce(function (path, part) {
27347
+ return (
27348
+ path +
27349
+ (isQuoted(part) || DIGIT_REGEX.test(part)
27350
+ ? '[' + part + ']'
27351
+ : (path ? '.' : '') + part)
27352
+ )
27353
+ }, '')
27354
+ },
27355
+
27356
+ forEach: function (path, cb, thisArg) {
27357
+ forEach(Array.isArray(path) ? path : split(path), cb, thisArg);
27358
+ },
27359
+ };
27360
+
27361
+ function normalizePath(path) {
27362
+ return (
27363
+ pathCache.get(path) ||
27364
+ pathCache.set(
27365
+ path,
27366
+ split(path).map(function (part) {
27367
+ return part.replace(CLEAN_QUOTES_REGEX, '$2')
27368
+ })
27369
+ )
27370
+ )
27371
+ }
27372
+
27373
+ function split(path) {
27374
+ return path.match(SPLIT_REGEX) || ['']
27375
+ }
27376
+
27377
+ function forEach(parts, iter, thisArg) {
27378
+ var len = parts.length,
27379
+ part,
27380
+ idx,
27381
+ isArray,
27382
+ isBracket;
27383
+
27384
+ for (idx = 0; idx < len; idx++) {
27385
+ part = parts[idx];
27386
+
27387
+ if (part) {
27388
+ if (shouldBeQuoted(part)) {
27389
+ part = '"' + part + '"';
27390
+ }
27391
+
27392
+ isBracket = isQuoted(part);
27393
+ isArray = !isBracket && /^\d+$/.test(part);
27394
+
27395
+ iter.call(thisArg, part, isBracket, isArray, idx, parts);
27396
+ }
27397
+ }
27398
+ }
27399
+
27400
+ function isQuoted(str) {
27401
+ return (
27402
+ typeof str === 'string' && str && ["'", '"'].indexOf(str.charAt(0)) !== -1
27403
+ )
27404
+ }
27405
+
27406
+ function hasLeadingNumber(part) {
27407
+ return part.match(LEAD_DIGIT_REGEX) && !part.match(DIGIT_REGEX)
27408
+ }
27409
+
27410
+ function hasSpecialChars(part) {
27411
+ return SPEC_CHAR_REGEX.test(part)
27412
+ }
27413
+
27414
+ function shouldBeQuoted(part) {
27415
+ return !isQuoted(part) && (hasLeadingNumber(part) || hasSpecialChars(part))
27416
+ }
27417
+ return propertyExpr;
27418
+ }
27419
+
27420
+ var propertyExprExports = requirePropertyExpr();
27421
+
27422
+ var tinyCase;
27423
+ var hasRequiredTinyCase;
27424
+
27425
+ function requireTinyCase () {
27426
+ if (hasRequiredTinyCase) return tinyCase;
27427
+ hasRequiredTinyCase = 1;
27428
+ 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;
27429
+
27430
+ const words = (str) => str.match(reWords) || [];
27431
+
27432
+ const upperFirst = (str) => str[0].toUpperCase() + str.slice(1);
27433
+
27434
+ const join = (str, d) => words(str).join(d).toLowerCase();
27435
+
27436
+ const camelCase = (str) =>
27437
+ words(str).reduce(
27438
+ (acc, next) =>
27439
+ `${acc}${
27440
+ !acc
27441
+ ? next.toLowerCase()
27442
+ : next[0].toUpperCase() + next.slice(1).toLowerCase()
27443
+ }`,
27444
+ '',
27445
+ );
27446
+
27447
+ const pascalCase = (str) => upperFirst(camelCase(str));
27448
+
27449
+ const snakeCase = (str) => join(str, '_');
27450
+
27451
+ const kebabCase = (str) => join(str, '-');
27452
+
27453
+ const sentenceCase = (str) => upperFirst(join(str, ' '));
27454
+
27455
+ const titleCase = (str) => words(str).map(upperFirst).join(' ');
27456
+
27457
+ tinyCase = {
27458
+ words,
27459
+ upperFirst,
27460
+ camelCase,
27461
+ pascalCase,
27462
+ snakeCase,
27463
+ kebabCase,
27464
+ sentenceCase,
27465
+ titleCase,
27466
+ };
27467
+ return tinyCase;
27468
+ }
27469
+
27470
+ var tinyCaseExports = requireTinyCase();
27471
+
27472
+ var toposort$1 = {exports: {}};
27473
+
27474
+ var hasRequiredToposort;
27475
+
27476
+ function requireToposort () {
27477
+ if (hasRequiredToposort) return toposort$1.exports;
27478
+ hasRequiredToposort = 1;
27479
+ /**
27480
+ * Topological sorting function
27481
+ *
27482
+ * @param {Array} edges
27483
+ * @returns {Array}
27484
+ */
27485
+
27486
+ toposort$1.exports = function(edges) {
27487
+ return toposort(uniqueNodes(edges), edges)
27488
+ };
27489
+
27490
+ toposort$1.exports.array = toposort;
27491
+
27492
+ function toposort(nodes, edges) {
27493
+ var cursor = nodes.length
27494
+ , sorted = new Array(cursor)
27495
+ , visited = {}
27496
+ , i = cursor
27497
+ // Better data structures make algorithm much faster.
27498
+ , outgoingEdges = makeOutgoingEdges(edges)
27499
+ , nodesHash = makeNodesHash(nodes);
27500
+
27501
+ // check for unknown nodes
27502
+ edges.forEach(function(edge) {
27503
+ if (!nodesHash.has(edge[0]) || !nodesHash.has(edge[1])) {
27504
+ throw new Error('Unknown node. There is an unknown node in the supplied edges.')
27505
+ }
27506
+ });
27507
+
27508
+ while (i--) {
27509
+ if (!visited[i]) visit(nodes[i], i, new Set());
27510
+ }
27511
+
27512
+ return sorted
27513
+
27514
+ function visit(node, i, predecessors) {
27515
+ if(predecessors.has(node)) {
27516
+ var nodeRep;
27517
+ try {
27518
+ nodeRep = ", node was:" + JSON.stringify(node);
27519
+ } catch(e) {
27520
+ nodeRep = "";
27521
+ }
27522
+ throw new Error('Cyclic dependency' + nodeRep)
27523
+ }
27524
+
27525
+ if (!nodesHash.has(node)) {
27526
+ throw new Error('Found unknown node. Make sure to provided all involved nodes. Unknown node: '+JSON.stringify(node))
27527
+ }
27528
+
27529
+ if (visited[i]) return;
27530
+ visited[i] = true;
27531
+
27532
+ var outgoing = outgoingEdges.get(node) || new Set();
27533
+ outgoing = Array.from(outgoing);
27534
+
27535
+ if (i = outgoing.length) {
27536
+ predecessors.add(node);
27537
+ do {
27538
+ var child = outgoing[--i];
27539
+ visit(child, nodesHash.get(child), predecessors);
27540
+ } while (i)
27541
+ predecessors.delete(node);
27542
+ }
27543
+
27544
+ sorted[--cursor] = node;
27545
+ }
27546
+ }
27547
+
27548
+ function uniqueNodes(arr){
27549
+ var res = new Set();
27550
+ for (var i = 0, len = arr.length; i < len; i++) {
27551
+ var edge = arr[i];
27552
+ res.add(edge[0]);
27553
+ res.add(edge[1]);
27554
+ }
27555
+ return Array.from(res)
27556
+ }
27557
+
27558
+ function makeOutgoingEdges(arr){
27559
+ var edges = new Map();
27560
+ for (var i = 0, len = arr.length; i < len; i++) {
27561
+ var edge = arr[i];
27562
+ if (!edges.has(edge[0])) edges.set(edge[0], new Set());
27563
+ if (!edges.has(edge[1])) edges.set(edge[1], new Set());
27564
+ edges.get(edge[0]).add(edge[1]);
27565
+ }
27566
+ return edges
27567
+ }
27568
+
27569
+ function makeNodesHash(arr){
27570
+ var res = new Map();
27571
+ for (var i = 0, len = arr.length; i < len; i++) {
27572
+ res.set(arr[i], i);
27573
+ }
27574
+ return res
27575
+ }
27576
+ return toposort$1.exports;
27577
+ }
27578
+
27579
+ var toposortExports = requireToposort();
27580
+ var toposort = /*@__PURE__*/getDefaultExportFromCjs(toposortExports);
27581
+
27582
+ const toString = Object.prototype.toString;
27583
+ const errorToString = Error.prototype.toString;
27584
+ const regExpToString = RegExp.prototype.toString;
27585
+ const symbolToString = typeof Symbol !== 'undefined' ? Symbol.prototype.toString : () => '';
27586
+ const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
27587
+ function printNumber(val) {
27588
+ if (val != +val) return 'NaN';
27589
+ const isNegativeZero = val === 0 && 1 / val < 0;
27590
+ return isNegativeZero ? '-0' : '' + val;
27591
+ }
27592
+ function printSimpleValue(val, quoteStrings = false) {
27593
+ if (val == null || val === true || val === false) return '' + val;
27594
+ const typeOf = typeof val;
27595
+ if (typeOf === 'number') return printNumber(val);
27596
+ if (typeOf === 'string') return quoteStrings ? `"${val}"` : val;
27597
+ if (typeOf === 'function') return '[Function ' + (val.name || 'anonymous') + ']';
27598
+ if (typeOf === 'symbol') return symbolToString.call(val).replace(SYMBOL_REGEXP, 'Symbol($1)');
27599
+ const tag = toString.call(val).slice(8, -1);
27600
+ if (tag === 'Date') return isNaN(val.getTime()) ? '' + val : val.toISOString(val);
27601
+ if (tag === 'Error' || val instanceof Error) return '[' + errorToString.call(val) + ']';
27602
+ if (tag === 'RegExp') return regExpToString.call(val);
27603
+ return null;
27604
+ }
27605
+ function printValue(value, quoteStrings) {
27606
+ let result = printSimpleValue(value, quoteStrings);
27607
+ if (result !== null) return result;
27608
+ return JSON.stringify(value, function (key, value) {
27609
+ let result = printSimpleValue(this[key], quoteStrings);
27610
+ if (result !== null) return result;
27611
+ return value;
27612
+ }, 2);
27613
+ }
27614
+
27615
+ function toArray(value) {
27616
+ return value == null ? [] : [].concat(value);
27617
+ }
27618
+
27619
+ let _Symbol$toStringTag, _Symbol$hasInstance, _Symbol$toStringTag2;
27620
+ let strReg = /\$\{\s*(\w+)\s*\}/g;
27621
+ _Symbol$toStringTag = Symbol.toStringTag;
27622
+ class ValidationErrorNoStack {
27623
+ constructor(errorOrErrors, value, field, type) {
27624
+ this.name = void 0;
27625
+ this.message = void 0;
27626
+ this.value = void 0;
27627
+ this.path = void 0;
27628
+ this.type = void 0;
27629
+ this.params = void 0;
27630
+ this.errors = void 0;
27631
+ this.inner = void 0;
27632
+ this[_Symbol$toStringTag] = 'Error';
27633
+ this.name = 'ValidationError';
27634
+ this.value = value;
27635
+ this.path = field;
27636
+ this.type = type;
27637
+ this.errors = [];
27638
+ this.inner = [];
27639
+ toArray(errorOrErrors).forEach(err => {
27640
+ if (ValidationError.isError(err)) {
27641
+ this.errors.push(...err.errors);
27642
+ const innerErrors = err.inner.length ? err.inner : [err];
27643
+ this.inner.push(...innerErrors);
27644
+ } else {
27645
+ this.errors.push(err);
27646
+ }
27647
+ });
27648
+ this.message = this.errors.length > 1 ? `${this.errors.length} errors occurred` : this.errors[0];
27649
+ }
27650
+ }
27651
+ _Symbol$hasInstance = Symbol.hasInstance;
27652
+ _Symbol$toStringTag2 = Symbol.toStringTag;
27653
+ class ValidationError extends Error {
27654
+ static formatError(message, params) {
27655
+ const path = params.label || params.path || 'this';
27656
+ if (path !== params.path) params = Object.assign({}, params, {
27657
+ path
27658
+ });
27659
+ if (typeof message === 'string') return message.replace(strReg, (_, key) => printValue(params[key]));
27660
+ if (typeof message === 'function') return message(params);
27661
+ return message;
27662
+ }
27663
+ static isError(err) {
27664
+ return err && err.name === 'ValidationError';
27665
+ }
27666
+ constructor(errorOrErrors, value, field, type, disableStack) {
27667
+ const errorNoStack = new ValidationErrorNoStack(errorOrErrors, value, field, type);
27668
+ if (disableStack) {
27669
+ return errorNoStack;
27670
+ }
27671
+ super();
27672
+ this.value = void 0;
27673
+ this.path = void 0;
27674
+ this.type = void 0;
27675
+ this.params = void 0;
27676
+ this.errors = [];
27677
+ this.inner = [];
27678
+ this[_Symbol$toStringTag2] = 'Error';
27679
+ this.name = errorNoStack.name;
27680
+ this.message = errorNoStack.message;
27681
+ this.type = errorNoStack.type;
27682
+ this.value = errorNoStack.value;
27683
+ this.path = errorNoStack.path;
27684
+ this.errors = errorNoStack.errors;
27685
+ this.inner = errorNoStack.inner;
27686
+ if (Error.captureStackTrace) {
27687
+ Error.captureStackTrace(this, ValidationError);
27688
+ }
27689
+ }
27690
+ static [_Symbol$hasInstance](inst) {
27691
+ return ValidationErrorNoStack[Symbol.hasInstance](inst) || super[Symbol.hasInstance](inst);
27692
+ }
27693
+ }
27694
+
27695
+ let mixed = {
27696
+ default: '${path} is invalid',
27697
+ required: '${path} is a required field',
27698
+ defined: '${path} must be defined',
27699
+ notNull: '${path} cannot be null',
27700
+ oneOf: '${path} must be one of the following values: ${values}',
27701
+ notOneOf: '${path} must not be one of the following values: ${values}',
27702
+ notType: ({
27703
+ path,
27704
+ type,
27705
+ value,
27706
+ originalValue
27707
+ }) => {
27708
+ const castMsg = originalValue != null && originalValue !== value ? ` (cast from the value \`${printValue(originalValue, true)}\`).` : '.';
27709
+ 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;
27710
+ }
27711
+ };
27712
+ let string = {
27713
+ length: '${path} must be exactly ${length} characters',
27714
+ min: '${path} must be at least ${min} characters',
27715
+ max: '${path} must be at most ${max} characters',
27716
+ matches: '${path} must match the following: "${regex}"',
27717
+ email: '${path} must be a valid email',
27718
+ url: '${path} must be a valid URL',
27719
+ uuid: '${path} must be a valid UUID',
27720
+ datetime: '${path} must be a valid ISO date-time',
27721
+ datetime_precision: '${path} must be a valid ISO date-time with a sub-second precision of exactly ${precision} digits',
27722
+ datetime_offset: '${path} must be a valid ISO date-time with UTC "Z" timezone',
27723
+ trim: '${path} must be a trimmed string',
27724
+ lowercase: '${path} must be a lowercase string',
27725
+ uppercase: '${path} must be a upper case string'
27726
+ };
27727
+ let number = {
27728
+ min: '${path} must be greater than or equal to ${min}',
27729
+ max: '${path} must be less than or equal to ${max}',
27730
+ lessThan: '${path} must be less than ${less}',
27731
+ moreThan: '${path} must be greater than ${more}',
27732
+ positive: '${path} must be a positive number',
27733
+ negative: '${path} must be a negative number',
27734
+ integer: '${path} must be an integer'
27735
+ };
27736
+ let date = {
27737
+ min: '${path} field must be later than ${min}',
27738
+ max: '${path} field must be at earlier than ${max}'
27739
+ };
27740
+ let boolean = {
27741
+ isValue: '${path} field must be ${value}'
27742
+ };
27743
+ let object = {
27744
+ noUnknown: '${path} field has unspecified keys: ${unknown}'
27745
+ };
27746
+ let array = {
27747
+ min: '${path} field must have at least ${min} items',
27748
+ max: '${path} field must have less than or equal to ${max} items',
27749
+ length: '${path} must have ${length} items'
27750
+ };
27751
+ let tuple = {
27752
+ notType: params => {
27753
+ const {
27754
+ path,
27755
+ value,
27756
+ spec
27757
+ } = params;
27758
+ const typeLen = spec.types.length;
27759
+ if (Array.isArray(value)) {
27760
+ 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)}\``;
27761
+ 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)}\``;
27762
+ }
27763
+ return ValidationError.formatError(mixed.notType, params);
27764
+ }
27765
+ };
27766
+ var locale = Object.assign(Object.create(null), {
27767
+ mixed,
27768
+ string,
27769
+ number,
27770
+ date,
27771
+ object,
27772
+ array,
27773
+ boolean,
27774
+ tuple
27775
+ });
27776
+
27777
+ const isSchema = obj => obj && obj.__isYupSchema__;
27778
+
27779
+ class Condition {
27780
+ static fromOptions(refs, config) {
27781
+ if (!config.then && !config.otherwise) throw new TypeError('either `then:` or `otherwise:` is required for `when()` conditions');
27782
+ let {
27783
+ is,
27784
+ then,
27785
+ otherwise
27786
+ } = config;
27787
+ let check = typeof is === 'function' ? is : (...values) => values.every(value => value === is);
27788
+ return new Condition(refs, (values, schema) => {
27789
+ var _branch;
27790
+ let branch = check(...values) ? then : otherwise;
27791
+ return (_branch = branch == null ? void 0 : branch(schema)) != null ? _branch : schema;
27792
+ });
27793
+ }
27794
+ constructor(refs, builder) {
27795
+ this.fn = void 0;
27796
+ this.refs = refs;
27797
+ this.refs = refs;
27798
+ this.fn = builder;
27799
+ }
27800
+ resolve(base, options) {
27801
+ let values = this.refs.map(ref =>
27802
+ // TODO: ? operator here?
27803
+ ref.getValue(options == null ? void 0 : options.value, options == null ? void 0 : options.parent, options == null ? void 0 : options.context));
27804
+ let schema = this.fn(values, base, options);
27805
+ if (schema === undefined ||
27806
+ // @ts-ignore this can be base
27807
+ schema === base) {
27808
+ return base;
27809
+ }
27810
+ if (!isSchema(schema)) throw new TypeError('conditions must return a schema object');
27811
+ return schema.resolve(options);
27812
+ }
27813
+ }
27814
+
27815
+ const prefixes = {
27816
+ context: '$',
27817
+ value: '.'
27818
+ };
27819
+ function create$9(key, options) {
27820
+ return new Reference(key, options);
27821
+ }
27822
+ class Reference {
27823
+ constructor(key, options = {}) {
27824
+ this.key = void 0;
27825
+ this.isContext = void 0;
27826
+ this.isValue = void 0;
27827
+ this.isSibling = void 0;
27828
+ this.path = void 0;
27829
+ this.getter = void 0;
27830
+ this.map = void 0;
27831
+ if (typeof key !== 'string') throw new TypeError('ref must be a string, got: ' + key);
27832
+ this.key = key.trim();
27833
+ if (key === '') throw new TypeError('ref must be a non-empty string');
27834
+ this.isContext = this.key[0] === prefixes.context;
27835
+ this.isValue = this.key[0] === prefixes.value;
27836
+ this.isSibling = !this.isContext && !this.isValue;
27837
+ let prefix = this.isContext ? prefixes.context : this.isValue ? prefixes.value : '';
27838
+ this.path = this.key.slice(prefix.length);
27839
+ this.getter = this.path && propertyExprExports.getter(this.path, true);
27840
+ this.map = options.map;
27841
+ }
27842
+ getValue(value, parent, context) {
27843
+ let result = this.isContext ? context : this.isValue ? value : parent;
27844
+ if (this.getter) result = this.getter(result || {});
27845
+ if (this.map) result = this.map(result);
27846
+ return result;
27847
+ }
27848
+
27849
+ /**
27850
+ *
27851
+ * @param {*} value
27852
+ * @param {Object} options
27853
+ * @param {Object=} options.context
27854
+ * @param {Object=} options.parent
27855
+ */
27856
+ cast(value, options) {
27857
+ return this.getValue(value, options == null ? void 0 : options.parent, options == null ? void 0 : options.context);
27858
+ }
27859
+ resolve() {
27860
+ return this;
27861
+ }
27862
+ describe() {
27863
+ return {
27864
+ type: 'ref',
27865
+ key: this.key
27866
+ };
27867
+ }
27868
+ toString() {
27869
+ return `Ref(${this.key})`;
27870
+ }
27871
+ static isRef(value) {
27872
+ return value && value.__isYupRef;
27873
+ }
27874
+ }
27875
+
27876
+ // @ts-ignore
27877
+ Reference.prototype.__isYupRef = true;
27878
+
27879
+ const isAbsent = value => value == null;
27880
+
27881
+ function createValidation(config) {
27882
+ function validate({
27883
+ value,
27884
+ path = '',
27885
+ options,
27886
+ originalValue,
27887
+ schema
27888
+ }, panic, next) {
27889
+ const {
27890
+ name,
27891
+ test,
27892
+ params,
27893
+ message,
27894
+ skipAbsent
27895
+ } = config;
27896
+ let {
27897
+ parent,
27898
+ context,
27899
+ abortEarly = schema.spec.abortEarly,
27900
+ disableStackTrace = schema.spec.disableStackTrace
27901
+ } = options;
27902
+ function resolve(item) {
27903
+ return Reference.isRef(item) ? item.getValue(value, parent, context) : item;
27904
+ }
27905
+ function createError(overrides = {}) {
27906
+ const nextParams = Object.assign({
27907
+ value,
27908
+ originalValue,
27909
+ label: schema.spec.label,
27910
+ path: overrides.path || path,
27911
+ spec: schema.spec,
27912
+ disableStackTrace: overrides.disableStackTrace || disableStackTrace
27913
+ }, params, overrides.params);
27914
+ for (const key of Object.keys(nextParams)) nextParams[key] = resolve(nextParams[key]);
27915
+ const error = new ValidationError(ValidationError.formatError(overrides.message || message, nextParams), value, nextParams.path, overrides.type || name, nextParams.disableStackTrace);
27916
+ error.params = nextParams;
27917
+ return error;
27918
+ }
27919
+ const invalid = abortEarly ? panic : next;
27920
+ let ctx = {
27921
+ path,
27922
+ parent,
27923
+ type: name,
27924
+ from: options.from,
27925
+ createError,
27926
+ resolve,
27927
+ options,
27928
+ originalValue,
27929
+ schema
27930
+ };
27931
+ const handleResult = validOrError => {
27932
+ if (ValidationError.isError(validOrError)) invalid(validOrError);else if (!validOrError) invalid(createError());else next(null);
27933
+ };
27934
+ const handleError = err => {
27935
+ if (ValidationError.isError(err)) invalid(err);else panic(err);
27936
+ };
27937
+ const shouldSkip = skipAbsent && isAbsent(value);
27938
+ if (shouldSkip) {
27939
+ return handleResult(true);
27940
+ }
27941
+ let result;
27942
+ try {
27943
+ var _result;
27944
+ result = test.call(ctx, value, ctx);
27945
+ if (typeof ((_result = result) == null ? void 0 : _result.then) === 'function') {
27946
+ if (options.sync) {
27947
+ 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`);
27948
+ }
27949
+ return Promise.resolve(result).then(handleResult, handleError);
27950
+ }
27951
+ } catch (err) {
27952
+ handleError(err);
27953
+ return;
27954
+ }
27955
+ handleResult(result);
27956
+ }
27957
+ validate.OPTIONS = config;
27958
+ return validate;
27959
+ }
27960
+
27961
+ function getIn(schema, path, value, context = value) {
27962
+ let parent, lastPart, lastPartDebug;
27963
+
27964
+ // root path: ''
27965
+ if (!path) return {
27966
+ parent,
27967
+ parentPath: path,
27968
+ schema
27969
+ };
27970
+ propertyExprExports.forEach(path, (_part, isBracket, isArray) => {
27971
+ let part = isBracket ? _part.slice(1, _part.length - 1) : _part;
27972
+ schema = schema.resolve({
27973
+ context,
27974
+ parent,
27975
+ value
27976
+ });
27977
+ let isTuple = schema.type === 'tuple';
27978
+ let idx = isArray ? parseInt(part, 10) : 0;
27979
+ if (schema.innerType || isTuple) {
27980
+ 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]"`);
27981
+ if (value && idx >= value.length) {
27982
+ 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. `);
27983
+ }
27984
+ parent = value;
27985
+ value = value && value[idx];
27986
+ schema = isTuple ? schema.spec.types[idx] : schema.innerType;
27987
+ }
27988
+
27989
+ // sometimes the array index part of a path doesn't exist: "nested.arr.child"
27990
+ // in these cases the current part is the next schema and should be processed
27991
+ // in this iteration. For cases where the index signature is included this
27992
+ // check will fail and we'll handle the `child` part on the next iteration like normal
27993
+ if (!isArray) {
27994
+ 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}")`);
27995
+ parent = value;
27996
+ value = value && value[part];
27997
+ schema = schema.fields[part];
27998
+ }
27999
+ lastPart = part;
28000
+ lastPartDebug = isBracket ? '[' + _part + ']' : '.' + _part;
28001
+ });
28002
+ return {
28003
+ schema,
28004
+ parent,
28005
+ parentPath: lastPart
28006
+ };
28007
+ }
28008
+ function reach(obj, path, value, context) {
28009
+ return getIn(obj, path, value, context).schema;
28010
+ }
28011
+
28012
+ class ReferenceSet extends Set {
28013
+ describe() {
28014
+ const description = [];
28015
+ for (const item of this.values()) {
28016
+ description.push(Reference.isRef(item) ? item.describe() : item);
28017
+ }
28018
+ return description;
28019
+ }
28020
+ resolveAll(resolve) {
28021
+ let result = [];
28022
+ for (const item of this.values()) {
28023
+ result.push(resolve(item));
28024
+ }
28025
+ return result;
28026
+ }
28027
+ clone() {
28028
+ return new ReferenceSet(this.values());
28029
+ }
28030
+ merge(newItems, removeItems) {
28031
+ const next = this.clone();
28032
+ newItems.forEach(value => next.add(value));
28033
+ removeItems.forEach(value => next.delete(value));
28034
+ return next;
28035
+ }
28036
+ }
28037
+
28038
+ // tweaked from https://github.com/Kelin2025/nanoclone/blob/0abeb7635bda9b68ef2277093f76dbe3bf3948e1/src/index.js
28039
+ function clone(src, seen = new Map()) {
28040
+ if (isSchema(src) || !src || typeof src !== 'object') return src;
28041
+ if (seen.has(src)) return seen.get(src);
28042
+ let copy;
28043
+ if (src instanceof Date) {
28044
+ // Date
28045
+ copy = new Date(src.getTime());
28046
+ seen.set(src, copy);
28047
+ } else if (src instanceof RegExp) {
28048
+ // RegExp
28049
+ copy = new RegExp(src);
28050
+ seen.set(src, copy);
28051
+ } else if (Array.isArray(src)) {
28052
+ // Array
28053
+ copy = new Array(src.length);
28054
+ seen.set(src, copy);
28055
+ for (let i = 0; i < src.length; i++) copy[i] = clone(src[i], seen);
28056
+ } else if (src instanceof Map) {
28057
+ // Map
28058
+ copy = new Map();
28059
+ seen.set(src, copy);
28060
+ for (const [k, v] of src.entries()) copy.set(k, clone(v, seen));
28061
+ } else if (src instanceof Set) {
28062
+ // Set
28063
+ copy = new Set();
28064
+ seen.set(src, copy);
28065
+ for (const v of src) copy.add(clone(v, seen));
28066
+ } else if (src instanceof Object) {
28067
+ // Object
28068
+ copy = {};
28069
+ seen.set(src, copy);
28070
+ for (const [k, v] of Object.entries(src)) copy[k] = clone(v, seen);
28071
+ } else {
28072
+ throw Error(`Unable to clone ${src}`);
28073
+ }
28074
+ return copy;
28075
+ }
28076
+
28077
+ // If `CustomSchemaMeta` isn't extended with any keys, we'll fall back to a
28078
+ // loose Record definition allowing free form usage.
28079
+ class Schema {
28080
+ constructor(options) {
28081
+ this.type = void 0;
28082
+ this.deps = [];
28083
+ this.tests = void 0;
28084
+ this.transforms = void 0;
28085
+ this.conditions = [];
28086
+ this._mutate = void 0;
28087
+ this.internalTests = {};
28088
+ this._whitelist = new ReferenceSet();
28089
+ this._blacklist = new ReferenceSet();
28090
+ this.exclusiveTests = Object.create(null);
28091
+ this._typeCheck = void 0;
28092
+ this.spec = void 0;
28093
+ this.tests = [];
28094
+ this.transforms = [];
28095
+ this.withMutation(() => {
28096
+ this.typeError(mixed.notType);
28097
+ });
28098
+ this.type = options.type;
28099
+ this._typeCheck = options.check;
28100
+ this.spec = Object.assign({
28101
+ strip: false,
28102
+ strict: false,
28103
+ abortEarly: true,
28104
+ recursive: true,
28105
+ disableStackTrace: false,
28106
+ nullable: false,
28107
+ optional: true,
28108
+ coerce: true
28109
+ }, options == null ? void 0 : options.spec);
28110
+ this.withMutation(s => {
28111
+ s.nonNullable();
28112
+ });
28113
+ }
28114
+
28115
+ // TODO: remove
28116
+ get _type() {
28117
+ return this.type;
28118
+ }
28119
+ clone(spec) {
28120
+ if (this._mutate) {
28121
+ if (spec) Object.assign(this.spec, spec);
28122
+ return this;
28123
+ }
28124
+
28125
+ // if the nested value is a schema we can skip cloning, since
28126
+ // they are already immutable
28127
+ const next = Object.create(Object.getPrototypeOf(this));
28128
+
28129
+ // @ts-expect-error this is readonly
28130
+ next.type = this.type;
28131
+ next._typeCheck = this._typeCheck;
28132
+ next._whitelist = this._whitelist.clone();
28133
+ next._blacklist = this._blacklist.clone();
28134
+ next.internalTests = Object.assign({}, this.internalTests);
28135
+ next.exclusiveTests = Object.assign({}, this.exclusiveTests);
28136
+
28137
+ // @ts-expect-error this is readonly
28138
+ next.deps = [...this.deps];
28139
+ next.conditions = [...this.conditions];
28140
+ next.tests = [...this.tests];
28141
+ next.transforms = [...this.transforms];
28142
+ next.spec = clone(Object.assign({}, this.spec, spec));
28143
+ return next;
28144
+ }
28145
+ label(label) {
28146
+ let next = this.clone();
28147
+ next.spec.label = label;
28148
+ return next;
28149
+ }
28150
+ meta(...args) {
28151
+ if (args.length === 0) return this.spec.meta;
28152
+ let next = this.clone();
28153
+ next.spec.meta = Object.assign(next.spec.meta || {}, args[0]);
28154
+ return next;
28155
+ }
28156
+ withMutation(fn) {
28157
+ let before = this._mutate;
28158
+ this._mutate = true;
28159
+ let result = fn(this);
28160
+ this._mutate = before;
28161
+ return result;
28162
+ }
28163
+ concat(schema) {
28164
+ if (!schema || schema === this) return this;
28165
+ if (schema.type !== this.type && this.type !== 'mixed') throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${schema.type}`);
28166
+ let base = this;
28167
+ let combined = schema.clone();
28168
+ const mergedSpec = Object.assign({}, base.spec, combined.spec);
28169
+ combined.spec = mergedSpec;
28170
+ combined.internalTests = Object.assign({}, base.internalTests, combined.internalTests);
28171
+
28172
+ // manually merge the blacklist/whitelist (the other `schema` takes
28173
+ // precedence in case of conflicts)
28174
+ combined._whitelist = base._whitelist.merge(schema._whitelist, schema._blacklist);
28175
+ combined._blacklist = base._blacklist.merge(schema._blacklist, schema._whitelist);
28176
+
28177
+ // start with the current tests
28178
+ combined.tests = base.tests;
28179
+ combined.exclusiveTests = base.exclusiveTests;
28180
+
28181
+ // manually add the new tests to ensure
28182
+ // the deduping logic is consistent
28183
+ combined.withMutation(next => {
28184
+ schema.tests.forEach(fn => {
28185
+ next.test(fn.OPTIONS);
28186
+ });
28187
+ });
28188
+ combined.transforms = [...base.transforms, ...combined.transforms];
28189
+ return combined;
28190
+ }
28191
+ isType(v) {
28192
+ if (v == null) {
28193
+ if (this.spec.nullable && v === null) return true;
28194
+ if (this.spec.optional && v === undefined) return true;
28195
+ return false;
28196
+ }
28197
+ return this._typeCheck(v);
28198
+ }
28199
+ resolve(options) {
28200
+ let schema = this;
28201
+ if (schema.conditions.length) {
28202
+ let conditions = schema.conditions;
28203
+ schema = schema.clone();
28204
+ schema.conditions = [];
28205
+ schema = conditions.reduce((prevSchema, condition) => condition.resolve(prevSchema, options), schema);
28206
+ schema = schema.resolve(options);
28207
+ }
28208
+ return schema;
28209
+ }
28210
+ resolveOptions(options) {
28211
+ var _options$strict, _options$abortEarly, _options$recursive, _options$disableStack;
28212
+ return Object.assign({}, options, {
28213
+ from: options.from || [],
28214
+ strict: (_options$strict = options.strict) != null ? _options$strict : this.spec.strict,
28215
+ abortEarly: (_options$abortEarly = options.abortEarly) != null ? _options$abortEarly : this.spec.abortEarly,
28216
+ recursive: (_options$recursive = options.recursive) != null ? _options$recursive : this.spec.recursive,
28217
+ disableStackTrace: (_options$disableStack = options.disableStackTrace) != null ? _options$disableStack : this.spec.disableStackTrace
28218
+ });
28219
+ }
28220
+
28221
+ /**
28222
+ * Run the configured transform pipeline over an input value.
28223
+ */
28224
+
28225
+ cast(value, options = {}) {
28226
+ let resolvedSchema = this.resolve(Object.assign({
28227
+ value
28228
+ }, options));
28229
+ let allowOptionality = options.assert === 'ignore-optionality';
28230
+ let result = resolvedSchema._cast(value, options);
28231
+ if (options.assert !== false && !resolvedSchema.isType(result)) {
28232
+ if (allowOptionality && isAbsent(result)) {
28233
+ return result;
28234
+ }
28235
+ let formattedValue = printValue(value);
28236
+ let formattedResult = printValue(result);
28237
+ 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}` : ''));
28238
+ }
28239
+ return result;
28240
+ }
28241
+ _cast(rawValue, options) {
28242
+ let value = rawValue === undefined ? rawValue : this.transforms.reduce((prevValue, fn) => fn.call(this, prevValue, rawValue, this), rawValue);
28243
+ if (value === undefined) {
28244
+ value = this.getDefault(options);
28245
+ }
28246
+ return value;
28247
+ }
28248
+ _validate(_value, options = {}, panic, next) {
28249
+ let {
28250
+ path,
28251
+ originalValue = _value,
28252
+ strict = this.spec.strict
28253
+ } = options;
28254
+ let value = _value;
28255
+ if (!strict) {
28256
+ value = this._cast(value, Object.assign({
28257
+ assert: false
28258
+ }, options));
28259
+ }
28260
+ let initialTests = [];
28261
+ for (let test of Object.values(this.internalTests)) {
28262
+ if (test) initialTests.push(test);
28263
+ }
28264
+ this.runTests({
28265
+ path,
28266
+ value,
28267
+ originalValue,
28268
+ options,
28269
+ tests: initialTests
28270
+ }, panic, initialErrors => {
28271
+ // even if we aren't ending early we can't proceed further if the types aren't correct
28272
+ if (initialErrors.length) {
28273
+ return next(initialErrors, value);
28274
+ }
28275
+ this.runTests({
28276
+ path,
28277
+ value,
28278
+ originalValue,
28279
+ options,
28280
+ tests: this.tests
28281
+ }, panic, next);
28282
+ });
28283
+ }
28284
+
28285
+ /**
28286
+ * Executes a set of validations, either schema, produced Tests or a nested
28287
+ * schema validate result.
28288
+ */
28289
+ runTests(runOptions, panic, next) {
28290
+ let fired = false;
28291
+ let {
28292
+ tests,
28293
+ value,
28294
+ originalValue,
28295
+ path,
28296
+ options
28297
+ } = runOptions;
28298
+ let panicOnce = arg => {
28299
+ if (fired) return;
28300
+ fired = true;
28301
+ panic(arg, value);
28302
+ };
28303
+ let nextOnce = arg => {
28304
+ if (fired) return;
28305
+ fired = true;
28306
+ next(arg, value);
28307
+ };
28308
+ let count = tests.length;
28309
+ let nestedErrors = [];
28310
+ if (!count) return nextOnce([]);
28311
+ let args = {
28312
+ value,
28313
+ originalValue,
28314
+ path,
28315
+ options,
28316
+ schema: this
28317
+ };
28318
+ for (let i = 0; i < tests.length; i++) {
28319
+ const test = tests[i];
28320
+ test(args, panicOnce, function finishTestRun(err) {
28321
+ if (err) {
28322
+ Array.isArray(err) ? nestedErrors.push(...err) : nestedErrors.push(err);
28323
+ }
28324
+ if (--count <= 0) {
28325
+ nextOnce(nestedErrors);
28326
+ }
28327
+ });
28328
+ }
28329
+ }
28330
+ asNestedTest({
28331
+ key,
28332
+ index,
28333
+ parent,
28334
+ parentPath,
28335
+ originalParent,
28336
+ options
28337
+ }) {
28338
+ const k = key != null ? key : index;
28339
+ if (k == null) {
28340
+ throw TypeError('Must include `key` or `index` for nested validations');
28341
+ }
28342
+ const isIndex = typeof k === 'number';
28343
+ let value = parent[k];
28344
+ const testOptions = Object.assign({}, options, {
28345
+ // Nested validations fields are always strict:
28346
+ // 1. parent isn't strict so the casting will also have cast inner values
28347
+ // 2. parent is strict in which case the nested values weren't cast either
28348
+ strict: true,
28349
+ parent,
28350
+ value,
28351
+ originalValue: originalParent[k],
28352
+ // FIXME: tests depend on `index` being passed around deeply,
28353
+ // we should not let the options.key/index bleed through
28354
+ key: undefined,
28355
+ // index: undefined,
28356
+ [isIndex ? 'index' : 'key']: k,
28357
+ path: isIndex || k.includes('.') ? `${parentPath || ''}[${isIndex ? k : `"${k}"`}]` : (parentPath ? `${parentPath}.` : '') + key
28358
+ });
28359
+ return (_, panic, next) => this.resolve(testOptions)._validate(value, testOptions, panic, next);
28360
+ }
28361
+ validate(value, options) {
28362
+ var _options$disableStack2;
28363
+ let schema = this.resolve(Object.assign({}, options, {
28364
+ value
28365
+ }));
28366
+ let disableStackTrace = (_options$disableStack2 = options == null ? void 0 : options.disableStackTrace) != null ? _options$disableStack2 : schema.spec.disableStackTrace;
28367
+ return new Promise((resolve, reject) => schema._validate(value, options, (error, parsed) => {
28368
+ if (ValidationError.isError(error)) error.value = parsed;
28369
+ reject(error);
28370
+ }, (errors, validated) => {
28371
+ if (errors.length) reject(new ValidationError(errors, validated, undefined, undefined, disableStackTrace));else resolve(validated);
28372
+ }));
28373
+ }
28374
+ validateSync(value, options) {
28375
+ var _options$disableStack3;
28376
+ let schema = this.resolve(Object.assign({}, options, {
28377
+ value
28378
+ }));
28379
+ let result;
28380
+ let disableStackTrace = (_options$disableStack3 = options == null ? void 0 : options.disableStackTrace) != null ? _options$disableStack3 : schema.spec.disableStackTrace;
28381
+ schema._validate(value, Object.assign({}, options, {
28382
+ sync: true
28383
+ }), (error, parsed) => {
28384
+ if (ValidationError.isError(error)) error.value = parsed;
28385
+ throw error;
28386
+ }, (errors, validated) => {
28387
+ if (errors.length) throw new ValidationError(errors, value, undefined, undefined, disableStackTrace);
28388
+ result = validated;
28389
+ });
28390
+ return result;
28391
+ }
28392
+ isValid(value, options) {
28393
+ return this.validate(value, options).then(() => true, err => {
28394
+ if (ValidationError.isError(err)) return false;
28395
+ throw err;
28396
+ });
28397
+ }
28398
+ isValidSync(value, options) {
28399
+ try {
28400
+ this.validateSync(value, options);
28401
+ return true;
28402
+ } catch (err) {
28403
+ if (ValidationError.isError(err)) return false;
28404
+ throw err;
28405
+ }
28406
+ }
28407
+ _getDefault(options) {
28408
+ let defaultValue = this.spec.default;
28409
+ if (defaultValue == null) {
28410
+ return defaultValue;
28411
+ }
28412
+ return typeof defaultValue === 'function' ? defaultValue.call(this, options) : clone(defaultValue);
28413
+ }
28414
+ getDefault(options
28415
+ // If schema is defaulted we know it's at least not undefined
28416
+ ) {
28417
+ let schema = this.resolve(options || {});
28418
+ return schema._getDefault(options);
28419
+ }
28420
+ default(def) {
28421
+ if (arguments.length === 0) {
28422
+ return this._getDefault();
28423
+ }
28424
+ let next = this.clone({
28425
+ default: def
28426
+ });
28427
+ return next;
28428
+ }
28429
+ strict(isStrict = true) {
28430
+ return this.clone({
28431
+ strict: isStrict
28432
+ });
28433
+ }
28434
+ nullability(nullable, message) {
28435
+ const next = this.clone({
28436
+ nullable
28437
+ });
28438
+ next.internalTests.nullable = createValidation({
28439
+ message,
28440
+ name: 'nullable',
28441
+ test(value) {
28442
+ return value === null ? this.schema.spec.nullable : true;
28443
+ }
28444
+ });
28445
+ return next;
28446
+ }
28447
+ optionality(optional, message) {
28448
+ const next = this.clone({
28449
+ optional
28450
+ });
28451
+ next.internalTests.optionality = createValidation({
28452
+ message,
28453
+ name: 'optionality',
28454
+ test(value) {
28455
+ return value === undefined ? this.schema.spec.optional : true;
28456
+ }
28457
+ });
28458
+ return next;
28459
+ }
28460
+ optional() {
28461
+ return this.optionality(true);
28462
+ }
28463
+ defined(message = mixed.defined) {
28464
+ return this.optionality(false, message);
28465
+ }
28466
+ nullable() {
28467
+ return this.nullability(true);
28468
+ }
28469
+ nonNullable(message = mixed.notNull) {
28470
+ return this.nullability(false, message);
28471
+ }
28472
+ required(message = mixed.required) {
28473
+ return this.clone().withMutation(next => next.nonNullable(message).defined(message));
28474
+ }
28475
+ notRequired() {
28476
+ return this.clone().withMutation(next => next.nullable().optional());
28477
+ }
28478
+ transform(fn) {
28479
+ let next = this.clone();
28480
+ next.transforms.push(fn);
28481
+ return next;
28482
+ }
28483
+
28484
+ /**
28485
+ * Adds a test function to the schema's queue of tests.
28486
+ * tests can be exclusive or non-exclusive.
28487
+ *
28488
+ * - exclusive tests, will replace any existing tests of the same name.
28489
+ * - non-exclusive: can be stacked
28490
+ *
28491
+ * If a non-exclusive test is added to a schema with an exclusive test of the same name
28492
+ * the exclusive test is removed and further tests of the same name will be stacked.
28493
+ *
28494
+ * If an exclusive test is added to a schema with non-exclusive tests of the same name
28495
+ * the previous tests are removed and further tests of the same name will replace each other.
28496
+ */
28497
+
28498
+ test(...args) {
28499
+ let opts;
28500
+ if (args.length === 1) {
28501
+ if (typeof args[0] === 'function') {
28502
+ opts = {
28503
+ test: args[0]
28504
+ };
28505
+ } else {
28506
+ opts = args[0];
28507
+ }
28508
+ } else if (args.length === 2) {
28509
+ opts = {
28510
+ name: args[0],
28511
+ test: args[1]
28512
+ };
28513
+ } else {
28514
+ opts = {
28515
+ name: args[0],
28516
+ message: args[1],
28517
+ test: args[2]
28518
+ };
28519
+ }
28520
+ if (opts.message === undefined) opts.message = mixed.default;
28521
+ if (typeof opts.test !== 'function') throw new TypeError('`test` is a required parameters');
28522
+ let next = this.clone();
28523
+ let validate = createValidation(opts);
28524
+ let isExclusive = opts.exclusive || opts.name && next.exclusiveTests[opts.name] === true;
28525
+ if (opts.exclusive) {
28526
+ if (!opts.name) throw new TypeError('Exclusive tests must provide a unique `name` identifying the test');
28527
+ }
28528
+ if (opts.name) next.exclusiveTests[opts.name] = !!opts.exclusive;
28529
+ next.tests = next.tests.filter(fn => {
28530
+ if (fn.OPTIONS.name === opts.name) {
28531
+ if (isExclusive) return false;
28532
+ if (fn.OPTIONS.test === validate.OPTIONS.test) return false;
28533
+ }
28534
+ return true;
28535
+ });
28536
+ next.tests.push(validate);
28537
+ return next;
28538
+ }
28539
+ when(keys, options) {
28540
+ if (!Array.isArray(keys) && typeof keys !== 'string') {
28541
+ options = keys;
28542
+ keys = '.';
28543
+ }
28544
+ let next = this.clone();
28545
+ let deps = toArray(keys).map(key => new Reference(key));
28546
+ deps.forEach(dep => {
28547
+ // @ts-ignore readonly array
28548
+ if (dep.isSibling) next.deps.push(dep.key);
28549
+ });
28550
+ next.conditions.push(typeof options === 'function' ? new Condition(deps, options) : Condition.fromOptions(deps, options));
28551
+ return next;
28552
+ }
28553
+ typeError(message) {
28554
+ let next = this.clone();
28555
+ next.internalTests.typeError = createValidation({
28556
+ message,
28557
+ name: 'typeError',
28558
+ skipAbsent: true,
28559
+ test(value) {
28560
+ if (!this.schema._typeCheck(value)) return this.createError({
28561
+ params: {
28562
+ type: this.schema.type
28563
+ }
28564
+ });
28565
+ return true;
28566
+ }
28567
+ });
28568
+ return next;
28569
+ }
28570
+ oneOf(enums, message = mixed.oneOf) {
28571
+ let next = this.clone();
28572
+ enums.forEach(val => {
28573
+ next._whitelist.add(val);
28574
+ next._blacklist.delete(val);
28575
+ });
28576
+ next.internalTests.whiteList = createValidation({
28577
+ message,
28578
+ name: 'oneOf',
28579
+ skipAbsent: true,
28580
+ test(value) {
28581
+ let valids = this.schema._whitelist;
28582
+ let resolved = valids.resolveAll(this.resolve);
28583
+ return resolved.includes(value) ? true : this.createError({
28584
+ params: {
28585
+ values: Array.from(valids).join(', '),
28586
+ resolved
28587
+ }
28588
+ });
28589
+ }
28590
+ });
28591
+ return next;
28592
+ }
28593
+ notOneOf(enums, message = mixed.notOneOf) {
28594
+ let next = this.clone();
28595
+ enums.forEach(val => {
28596
+ next._blacklist.add(val);
28597
+ next._whitelist.delete(val);
28598
+ });
28599
+ next.internalTests.blacklist = createValidation({
28600
+ message,
28601
+ name: 'notOneOf',
28602
+ test(value) {
28603
+ let invalids = this.schema._blacklist;
28604
+ let resolved = invalids.resolveAll(this.resolve);
28605
+ if (resolved.includes(value)) return this.createError({
28606
+ params: {
28607
+ values: Array.from(invalids).join(', '),
28608
+ resolved
28609
+ }
28610
+ });
28611
+ return true;
28612
+ }
28613
+ });
28614
+ return next;
28615
+ }
28616
+ strip(strip = true) {
28617
+ let next = this.clone();
28618
+ next.spec.strip = strip;
28619
+ return next;
28620
+ }
28621
+
28622
+ /**
28623
+ * Return a serialized description of the schema including validations, flags, types etc.
28624
+ *
28625
+ * @param options Provide any needed context for resolving runtime schema alterations (lazy, when conditions, etc).
28626
+ */
28627
+ describe(options) {
28628
+ const next = (options ? this.resolve(options) : this).clone();
28629
+ const {
28630
+ label,
28631
+ meta,
28632
+ optional,
28633
+ nullable
28634
+ } = next.spec;
28635
+ const description = {
28636
+ meta,
28637
+ label,
28638
+ optional,
28639
+ nullable,
28640
+ default: next.getDefault(options),
28641
+ type: next.type,
28642
+ oneOf: next._whitelist.describe(),
28643
+ notOneOf: next._blacklist.describe(),
28644
+ tests: next.tests.map(fn => ({
28645
+ name: fn.OPTIONS.name,
28646
+ params: fn.OPTIONS.params
28647
+ })).filter((n, idx, list) => list.findIndex(c => c.name === n.name) === idx)
28648
+ };
28649
+ return description;
28650
+ }
28651
+ }
28652
+ // @ts-expect-error
28653
+ Schema.prototype.__isYupSchema__ = true;
28654
+ for (const method of ['validate', 'validateSync']) Schema.prototype[`${method}At`] = function (path, value, options = {}) {
28655
+ const {
28656
+ parent,
28657
+ parentPath,
28658
+ schema
28659
+ } = getIn(this, path, value, options.context);
28660
+ return schema[method](parent && parent[parentPath], Object.assign({}, options, {
28661
+ parent,
28662
+ path
28663
+ }));
28664
+ };
28665
+ for (const alias of ['equals', 'is']) Schema.prototype[alias] = Schema.prototype.oneOf;
28666
+ for (const alias of ['not', 'nope']) Schema.prototype[alias] = Schema.prototype.notOneOf;
28667
+
28668
+ const returnsTrue = () => true;
28669
+ function create$8(spec) {
28670
+ return new MixedSchema(spec);
28671
+ }
28672
+ class MixedSchema extends Schema {
28673
+ constructor(spec) {
28674
+ super(typeof spec === 'function' ? {
28675
+ type: 'mixed',
28676
+ check: spec
28677
+ } : Object.assign({
28678
+ type: 'mixed',
28679
+ check: returnsTrue
28680
+ }, spec));
28681
+ }
28682
+ }
28683
+ create$8.prototype = MixedSchema.prototype;
28684
+
28685
+ function create$7() {
28686
+ return new BooleanSchema();
28687
+ }
28688
+ class BooleanSchema extends Schema {
28689
+ constructor() {
28690
+ super({
28691
+ type: 'boolean',
28692
+ check(v) {
28693
+ if (v instanceof Boolean) v = v.valueOf();
28694
+ return typeof v === 'boolean';
28695
+ }
28696
+ });
28697
+ this.withMutation(() => {
28698
+ this.transform((value, _raw, ctx) => {
28699
+ if (ctx.spec.coerce && !ctx.isType(value)) {
28700
+ if (/^(true|1)$/i.test(String(value))) return true;
28701
+ if (/^(false|0)$/i.test(String(value))) return false;
28702
+ }
28703
+ return value;
28704
+ });
28705
+ });
28706
+ }
28707
+ isTrue(message = boolean.isValue) {
28708
+ return this.test({
28709
+ message,
28710
+ name: 'is-value',
28711
+ exclusive: true,
28712
+ params: {
28713
+ value: 'true'
28714
+ },
28715
+ test(value) {
28716
+ return isAbsent(value) || value === true;
28717
+ }
28718
+ });
28719
+ }
28720
+ isFalse(message = boolean.isValue) {
28721
+ return this.test({
28722
+ message,
28723
+ name: 'is-value',
28724
+ exclusive: true,
28725
+ params: {
28726
+ value: 'false'
28727
+ },
28728
+ test(value) {
28729
+ return isAbsent(value) || value === false;
28730
+ }
28731
+ });
28732
+ }
28733
+ default(def) {
28734
+ return super.default(def);
28735
+ }
28736
+ defined(msg) {
28737
+ return super.defined(msg);
28738
+ }
28739
+ optional() {
28740
+ return super.optional();
28741
+ }
28742
+ required(msg) {
28743
+ return super.required(msg);
28744
+ }
28745
+ notRequired() {
28746
+ return super.notRequired();
28747
+ }
28748
+ nullable() {
28749
+ return super.nullable();
28750
+ }
28751
+ nonNullable(msg) {
28752
+ return super.nonNullable(msg);
28753
+ }
28754
+ strip(v) {
28755
+ return super.strip(v);
28756
+ }
28757
+ }
28758
+ create$7.prototype = BooleanSchema.prototype;
28759
+
28760
+ /**
28761
+ * This file is a modified version of the file from the following repository:
28762
+ * Date.parse with progressive enhancement for ISO 8601 <https://github.com/csnover/js-iso8601>
28763
+ * NON-CONFORMANT EDITION.
28764
+ * © 2011 Colin Snover <http://zetafleet.com>
28765
+ * Released under MIT license.
28766
+ */
28767
+
28768
+ // prettier-ignore
28769
+ // 1 YYYY 2 MM 3 DD 4 HH 5 mm 6 ss 7 msec 8 Z 9 ± 10 tzHH 11 tzmm
28770
+ const isoReg = /^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;
28771
+ function parseIsoDate(date) {
28772
+ const struct = parseDateStruct(date);
28773
+ if (!struct) return Date.parse ? Date.parse(date) : Number.NaN;
28774
+
28775
+ // timestamps without timezone identifiers should be considered local time
28776
+ if (struct.z === undefined && struct.plusMinus === undefined) {
28777
+ return new Date(struct.year, struct.month, struct.day, struct.hour, struct.minute, struct.second, struct.millisecond).valueOf();
28778
+ }
28779
+ let totalMinutesOffset = 0;
28780
+ if (struct.z !== 'Z' && struct.plusMinus !== undefined) {
28781
+ totalMinutesOffset = struct.hourOffset * 60 + struct.minuteOffset;
28782
+ if (struct.plusMinus === '+') totalMinutesOffset = 0 - totalMinutesOffset;
28783
+ }
28784
+ return Date.UTC(struct.year, struct.month, struct.day, struct.hour, struct.minute + totalMinutesOffset, struct.second, struct.millisecond);
28785
+ }
28786
+ function parseDateStruct(date) {
28787
+ var _regexResult$7$length, _regexResult$;
28788
+ const regexResult = isoReg.exec(date);
28789
+ if (!regexResult) return null;
28790
+
28791
+ // use of toNumber() avoids NaN timestamps caused by “undefined”
28792
+ // values being passed to Date constructor
28793
+ return {
28794
+ year: toNumber(regexResult[1]),
28795
+ month: toNumber(regexResult[2], 1) - 1,
28796
+ day: toNumber(regexResult[3], 1),
28797
+ hour: toNumber(regexResult[4]),
28798
+ minute: toNumber(regexResult[5]),
28799
+ second: toNumber(regexResult[6]),
28800
+ millisecond: regexResult[7] ?
28801
+ // allow arbitrary sub-second precision beyond milliseconds
28802
+ toNumber(regexResult[7].substring(0, 3)) : 0,
28803
+ precision: (_regexResult$7$length = (_regexResult$ = regexResult[7]) == null ? void 0 : _regexResult$.length) != null ? _regexResult$7$length : undefined,
28804
+ z: regexResult[8] || undefined,
28805
+ plusMinus: regexResult[9] || undefined,
28806
+ hourOffset: toNumber(regexResult[10]),
28807
+ minuteOffset: toNumber(regexResult[11])
28808
+ };
28809
+ }
28810
+ function toNumber(str, defaultValue = 0) {
28811
+ return Number(str) || defaultValue;
28812
+ }
28813
+
28814
+ // Taken from HTML spec: https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
28815
+ let rEmail =
28816
+ // eslint-disable-next-line
28817
+ /^[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])?)*$/;
28818
+ let rUrl =
28819
+ // eslint-disable-next-line
28820
+ /^((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;
28821
+
28822
+ // eslint-disable-next-line
28823
+ 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;
28824
+ let yearMonthDay = '^\\d{4}-\\d{2}-\\d{2}';
28825
+ let hourMinuteSecond = '\\d{2}:\\d{2}:\\d{2}';
28826
+ let zOrOffset = '(([+-]\\d{2}(:?\\d{2})?)|Z)';
28827
+ let rIsoDateTime = new RegExp(`${yearMonthDay}T${hourMinuteSecond}(\\.\\d+)?${zOrOffset}$`);
28828
+ let isTrimmed = value => isAbsent(value) || value === value.trim();
28829
+ let objStringTag = {}.toString();
28830
+ function create$6() {
28831
+ return new StringSchema();
28832
+ }
28833
+ class StringSchema extends Schema {
28834
+ constructor() {
28835
+ super({
28836
+ type: 'string',
28837
+ check(value) {
28838
+ if (value instanceof String) value = value.valueOf();
28839
+ return typeof value === 'string';
28840
+ }
28841
+ });
28842
+ this.withMutation(() => {
28843
+ this.transform((value, _raw, ctx) => {
28844
+ if (!ctx.spec.coerce || ctx.isType(value)) return value;
28845
+
28846
+ // don't ever convert arrays
28847
+ if (Array.isArray(value)) return value;
28848
+ const strValue = value != null && value.toString ? value.toString() : value;
28849
+
28850
+ // no one wants plain objects converted to [Object object]
28851
+ if (strValue === objStringTag) return value;
28852
+ return strValue;
28853
+ });
28854
+ });
28855
+ }
28856
+ required(message) {
28857
+ return super.required(message).withMutation(schema => schema.test({
28858
+ message: message || mixed.required,
28859
+ name: 'required',
28860
+ skipAbsent: true,
28861
+ test: value => !!value.length
28862
+ }));
28863
+ }
28864
+ notRequired() {
28865
+ return super.notRequired().withMutation(schema => {
28866
+ schema.tests = schema.tests.filter(t => t.OPTIONS.name !== 'required');
28867
+ return schema;
28868
+ });
28869
+ }
28870
+ length(length, message = string.length) {
28871
+ return this.test({
28872
+ message,
28873
+ name: 'length',
28874
+ exclusive: true,
28875
+ params: {
28876
+ length
28877
+ },
28878
+ skipAbsent: true,
28879
+ test(value) {
28880
+ return value.length === this.resolve(length);
28881
+ }
28882
+ });
28883
+ }
28884
+ min(min, message = string.min) {
28885
+ return this.test({
28886
+ message,
28887
+ name: 'min',
28888
+ exclusive: true,
28889
+ params: {
28890
+ min
28891
+ },
28892
+ skipAbsent: true,
28893
+ test(value) {
28894
+ return value.length >= this.resolve(min);
28895
+ }
28896
+ });
28897
+ }
28898
+ max(max, message = string.max) {
28899
+ return this.test({
28900
+ name: 'max',
28901
+ exclusive: true,
28902
+ message,
28903
+ params: {
28904
+ max
28905
+ },
28906
+ skipAbsent: true,
28907
+ test(value) {
28908
+ return value.length <= this.resolve(max);
28909
+ }
28910
+ });
28911
+ }
28912
+ matches(regex, options) {
28913
+ let excludeEmptyString = false;
28914
+ let message;
28915
+ let name;
28916
+ if (options) {
28917
+ if (typeof options === 'object') {
28918
+ ({
28919
+ excludeEmptyString = false,
28920
+ message,
28921
+ name
28922
+ } = options);
28923
+ } else {
28924
+ message = options;
28925
+ }
28926
+ }
28927
+ return this.test({
28928
+ name: name || 'matches',
28929
+ message: message || string.matches,
28930
+ params: {
28931
+ regex
28932
+ },
28933
+ skipAbsent: true,
28934
+ test: value => value === '' && excludeEmptyString || value.search(regex) !== -1
28935
+ });
28936
+ }
28937
+ email(message = string.email) {
28938
+ return this.matches(rEmail, {
28939
+ name: 'email',
28940
+ message,
28941
+ excludeEmptyString: true
28942
+ });
28943
+ }
28944
+ url(message = string.url) {
28945
+ return this.matches(rUrl, {
28946
+ name: 'url',
28947
+ message,
28948
+ excludeEmptyString: true
28949
+ });
28950
+ }
28951
+ uuid(message = string.uuid) {
28952
+ return this.matches(rUUID, {
28953
+ name: 'uuid',
28954
+ message,
28955
+ excludeEmptyString: false
28956
+ });
28957
+ }
28958
+ datetime(options) {
28959
+ let message = '';
28960
+ let allowOffset;
28961
+ let precision;
28962
+ if (options) {
28963
+ if (typeof options === 'object') {
28964
+ ({
28965
+ message = '',
28966
+ allowOffset = false,
28967
+ precision = undefined
28968
+ } = options);
28969
+ } else {
28970
+ message = options;
28971
+ }
28972
+ }
28973
+ return this.matches(rIsoDateTime, {
28974
+ name: 'datetime',
28975
+ message: message || string.datetime,
28976
+ excludeEmptyString: true
28977
+ }).test({
28978
+ name: 'datetime_offset',
28979
+ message: message || string.datetime_offset,
28980
+ params: {
28981
+ allowOffset
28982
+ },
28983
+ skipAbsent: true,
28984
+ test: value => {
28985
+ if (!value || allowOffset) return true;
28986
+ const struct = parseDateStruct(value);
28987
+ if (!struct) return false;
28988
+ return !!struct.z;
28989
+ }
28990
+ }).test({
28991
+ name: 'datetime_precision',
28992
+ message: message || string.datetime_precision,
28993
+ params: {
28994
+ precision
28995
+ },
28996
+ skipAbsent: true,
28997
+ test: value => {
28998
+ if (!value || precision == undefined) return true;
28999
+ const struct = parseDateStruct(value);
29000
+ if (!struct) return false;
29001
+ return struct.precision === precision;
29002
+ }
29003
+ });
29004
+ }
29005
+
29006
+ //-- transforms --
29007
+ ensure() {
29008
+ return this.default('').transform(val => val === null ? '' : val);
29009
+ }
29010
+ trim(message = string.trim) {
29011
+ return this.transform(val => val != null ? val.trim() : val).test({
29012
+ message,
29013
+ name: 'trim',
29014
+ test: isTrimmed
29015
+ });
29016
+ }
29017
+ lowercase(message = string.lowercase) {
29018
+ return this.transform(value => !isAbsent(value) ? value.toLowerCase() : value).test({
29019
+ message,
29020
+ name: 'string_case',
29021
+ exclusive: true,
29022
+ skipAbsent: true,
29023
+ test: value => isAbsent(value) || value === value.toLowerCase()
29024
+ });
29025
+ }
29026
+ uppercase(message = string.uppercase) {
29027
+ return this.transform(value => !isAbsent(value) ? value.toUpperCase() : value).test({
29028
+ message,
29029
+ name: 'string_case',
29030
+ exclusive: true,
29031
+ skipAbsent: true,
29032
+ test: value => isAbsent(value) || value === value.toUpperCase()
29033
+ });
29034
+ }
29035
+ }
29036
+ create$6.prototype = StringSchema.prototype;
29037
+
29038
+ //
29039
+ // String Interfaces
29040
+ //
29041
+
29042
+ let isNaN$1 = value => value != +value;
29043
+ function create$5() {
29044
+ return new NumberSchema();
29045
+ }
29046
+ class NumberSchema extends Schema {
29047
+ constructor() {
29048
+ super({
29049
+ type: 'number',
29050
+ check(value) {
29051
+ if (value instanceof Number) value = value.valueOf();
29052
+ return typeof value === 'number' && !isNaN$1(value);
29053
+ }
29054
+ });
29055
+ this.withMutation(() => {
29056
+ this.transform((value, _raw, ctx) => {
29057
+ if (!ctx.spec.coerce) return value;
29058
+ let parsed = value;
29059
+ if (typeof parsed === 'string') {
29060
+ parsed = parsed.replace(/\s/g, '');
29061
+ if (parsed === '') return NaN;
29062
+ // don't use parseFloat to avoid positives on alpha-numeric strings
29063
+ parsed = +parsed;
29064
+ }
29065
+
29066
+ // null -> NaN isn't useful; treat all nulls as null and let it fail on
29067
+ // nullability check vs TypeErrors
29068
+ if (ctx.isType(parsed) || parsed === null) return parsed;
29069
+ return parseFloat(parsed);
29070
+ });
29071
+ });
29072
+ }
29073
+ min(min, message = number.min) {
29074
+ return this.test({
29075
+ message,
29076
+ name: 'min',
29077
+ exclusive: true,
29078
+ params: {
29079
+ min
29080
+ },
29081
+ skipAbsent: true,
29082
+ test(value) {
29083
+ return value >= this.resolve(min);
29084
+ }
29085
+ });
29086
+ }
29087
+ max(max, message = number.max) {
29088
+ return this.test({
29089
+ message,
29090
+ name: 'max',
29091
+ exclusive: true,
29092
+ params: {
29093
+ max
29094
+ },
29095
+ skipAbsent: true,
29096
+ test(value) {
29097
+ return value <= this.resolve(max);
29098
+ }
29099
+ });
29100
+ }
29101
+ lessThan(less, message = number.lessThan) {
29102
+ return this.test({
29103
+ message,
29104
+ name: 'max',
29105
+ exclusive: true,
29106
+ params: {
29107
+ less
29108
+ },
29109
+ skipAbsent: true,
29110
+ test(value) {
29111
+ return value < this.resolve(less);
29112
+ }
29113
+ });
29114
+ }
29115
+ moreThan(more, message = number.moreThan) {
29116
+ return this.test({
29117
+ message,
29118
+ name: 'min',
29119
+ exclusive: true,
29120
+ params: {
29121
+ more
29122
+ },
29123
+ skipAbsent: true,
29124
+ test(value) {
29125
+ return value > this.resolve(more);
29126
+ }
29127
+ });
29128
+ }
29129
+ positive(msg = number.positive) {
29130
+ return this.moreThan(0, msg);
29131
+ }
29132
+ negative(msg = number.negative) {
29133
+ return this.lessThan(0, msg);
29134
+ }
29135
+ integer(message = number.integer) {
29136
+ return this.test({
29137
+ name: 'integer',
29138
+ message,
29139
+ skipAbsent: true,
29140
+ test: val => Number.isInteger(val)
29141
+ });
29142
+ }
29143
+ truncate() {
29144
+ return this.transform(value => !isAbsent(value) ? value | 0 : value);
29145
+ }
29146
+ round(method) {
29147
+ var _method;
29148
+ let avail = ['ceil', 'floor', 'round', 'trunc'];
29149
+ method = ((_method = method) == null ? void 0 : _method.toLowerCase()) || 'round';
29150
+
29151
+ // this exists for symemtry with the new Math.trunc
29152
+ if (method === 'trunc') return this.truncate();
29153
+ if (avail.indexOf(method.toLowerCase()) === -1) throw new TypeError('Only valid options for round() are: ' + avail.join(', '));
29154
+ return this.transform(value => !isAbsent(value) ? Math[method](value) : value);
29155
+ }
29156
+ }
29157
+ create$5.prototype = NumberSchema.prototype;
29158
+
29159
+ //
29160
+ // Number Interfaces
29161
+ //
29162
+
29163
+ let invalidDate = new Date('');
29164
+ let isDate = obj => Object.prototype.toString.call(obj) === '[object Date]';
29165
+ function create$4() {
29166
+ return new DateSchema();
29167
+ }
29168
+ class DateSchema extends Schema {
29169
+ constructor() {
29170
+ super({
29171
+ type: 'date',
29172
+ check(v) {
29173
+ return isDate(v) && !isNaN(v.getTime());
29174
+ }
29175
+ });
29176
+ this.withMutation(() => {
29177
+ this.transform((value, _raw, ctx) => {
29178
+ // null -> InvalidDate isn't useful; treat all nulls as null and let it fail on
29179
+ // nullability check vs TypeErrors
29180
+ if (!ctx.spec.coerce || ctx.isType(value) || value === null) return value;
29181
+ value = parseIsoDate(value);
29182
+
29183
+ // 0 is a valid timestamp equivalent to 1970-01-01T00:00:00Z(unix epoch) or before.
29184
+ return !isNaN(value) ? new Date(value) : DateSchema.INVALID_DATE;
29185
+ });
29186
+ });
29187
+ }
29188
+ prepareParam(ref, name) {
29189
+ let param;
29190
+ if (!Reference.isRef(ref)) {
29191
+ let cast = this.cast(ref);
29192
+ if (!this._typeCheck(cast)) throw new TypeError(`\`${name}\` must be a Date or a value that can be \`cast()\` to a Date`);
29193
+ param = cast;
29194
+ } else {
29195
+ param = ref;
29196
+ }
29197
+ return param;
29198
+ }
29199
+ min(min, message = date.min) {
29200
+ let limit = this.prepareParam(min, 'min');
29201
+ return this.test({
29202
+ message,
29203
+ name: 'min',
29204
+ exclusive: true,
29205
+ params: {
29206
+ min
29207
+ },
29208
+ skipAbsent: true,
29209
+ test(value) {
29210
+ return value >= this.resolve(limit);
29211
+ }
29212
+ });
29213
+ }
29214
+ max(max, message = date.max) {
29215
+ let limit = this.prepareParam(max, 'max');
29216
+ return this.test({
29217
+ message,
29218
+ name: 'max',
29219
+ exclusive: true,
29220
+ params: {
29221
+ max
29222
+ },
29223
+ skipAbsent: true,
29224
+ test(value) {
29225
+ return value <= this.resolve(limit);
29226
+ }
29227
+ });
29228
+ }
29229
+ }
29230
+ DateSchema.INVALID_DATE = invalidDate;
29231
+ create$4.prototype = DateSchema.prototype;
29232
+ create$4.INVALID_DATE = invalidDate;
29233
+
29234
+ // @ts-expect-error
29235
+ function sortFields(fields, excludedEdges = []) {
29236
+ let edges = [];
29237
+ let nodes = new Set();
29238
+ let excludes = new Set(excludedEdges.map(([a, b]) => `${a}-${b}`));
29239
+ function addNode(depPath, key) {
29240
+ let node = propertyExprExports.split(depPath)[0];
29241
+ nodes.add(node);
29242
+ if (!excludes.has(`${key}-${node}`)) edges.push([key, node]);
29243
+ }
29244
+ for (const key of Object.keys(fields)) {
29245
+ let value = fields[key];
29246
+ nodes.add(key);
29247
+ if (Reference.isRef(value) && value.isSibling) addNode(value.path, key);else if (isSchema(value) && 'deps' in value) value.deps.forEach(path => addNode(path, key));
29248
+ }
29249
+ return toposort.array(Array.from(nodes), edges).reverse();
29250
+ }
29251
+
29252
+ function findIndex(arr, err) {
29253
+ let idx = Infinity;
29254
+ arr.some((key, ii) => {
29255
+ var _err$path;
29256
+ if ((_err$path = err.path) != null && _err$path.includes(key)) {
29257
+ idx = ii;
29258
+ return true;
29259
+ }
29260
+ });
29261
+ return idx;
29262
+ }
29263
+ function sortByKeyOrder(keys) {
29264
+ return (a, b) => {
29265
+ return findIndex(keys, a) - findIndex(keys, b);
29266
+ };
29267
+ }
29268
+
29269
+ const parseJson = (value, _, ctx) => {
29270
+ if (typeof value !== 'string') {
29271
+ return value;
29272
+ }
29273
+ let parsed = value;
29274
+ try {
29275
+ parsed = JSON.parse(value);
29276
+ } catch (err) {
29277
+ /* */
29278
+ }
29279
+ return ctx.isType(parsed) ? parsed : value;
29280
+ };
29281
+
29282
+ // @ts-ignore
29283
+ function deepPartial(schema) {
29284
+ if ('fields' in schema) {
29285
+ const partial = {};
29286
+ for (const [key, fieldSchema] of Object.entries(schema.fields)) {
29287
+ partial[key] = deepPartial(fieldSchema);
29288
+ }
29289
+ return schema.setFields(partial);
29290
+ }
29291
+ if (schema.type === 'array') {
29292
+ const nextArray = schema.optional();
29293
+ if (nextArray.innerType) nextArray.innerType = deepPartial(nextArray.innerType);
29294
+ return nextArray;
29295
+ }
29296
+ if (schema.type === 'tuple') {
29297
+ return schema.optional().clone({
29298
+ types: schema.spec.types.map(deepPartial)
29299
+ });
29300
+ }
29301
+ if ('optional' in schema) {
29302
+ return schema.optional();
29303
+ }
29304
+ return schema;
29305
+ }
29306
+ const deepHas = (obj, p) => {
29307
+ const path = [...propertyExprExports.normalizePath(p)];
29308
+ if (path.length === 1) return path[0] in obj;
29309
+ let last = path.pop();
29310
+ let parent = propertyExprExports.getter(propertyExprExports.join(path), true)(obj);
29311
+ return !!(parent && last in parent);
29312
+ };
29313
+ let isObject = obj => Object.prototype.toString.call(obj) === '[object Object]';
29314
+ function unknown(ctx, value) {
29315
+ let known = Object.keys(ctx.fields);
29316
+ return Object.keys(value).filter(key => known.indexOf(key) === -1);
29317
+ }
29318
+ const defaultSort = sortByKeyOrder([]);
29319
+ function create$3(spec) {
29320
+ return new ObjectSchema(spec);
29321
+ }
29322
+ class ObjectSchema extends Schema {
29323
+ constructor(spec) {
29324
+ super({
29325
+ type: 'object',
29326
+ check(value) {
29327
+ return isObject(value) || typeof value === 'function';
29328
+ }
29329
+ });
29330
+ this.fields = Object.create(null);
29331
+ this._sortErrors = defaultSort;
29332
+ this._nodes = [];
29333
+ this._excludedEdges = [];
29334
+ this.withMutation(() => {
29335
+ if (spec) {
29336
+ this.shape(spec);
29337
+ }
29338
+ });
29339
+ }
29340
+ _cast(_value, options = {}) {
29341
+ var _options$stripUnknown;
29342
+ let value = super._cast(_value, options);
29343
+
29344
+ //should ignore nulls here
29345
+ if (value === undefined) return this.getDefault(options);
29346
+ if (!this._typeCheck(value)) return value;
29347
+ let fields = this.fields;
29348
+ let strip = (_options$stripUnknown = options.stripUnknown) != null ? _options$stripUnknown : this.spec.noUnknown;
29349
+ let props = [].concat(this._nodes, Object.keys(value).filter(v => !this._nodes.includes(v)));
29350
+ let intermediateValue = {}; // is filled during the transform below
29351
+ let innerOptions = Object.assign({}, options, {
29352
+ parent: intermediateValue,
29353
+ __validating: options.__validating || false
29354
+ });
29355
+ let isChanged = false;
29356
+ for (const prop of props) {
29357
+ let field = fields[prop];
29358
+ let exists = (prop in value);
29359
+ if (field) {
29360
+ let fieldValue;
29361
+ let inputValue = value[prop];
29362
+
29363
+ // safe to mutate since this is fired in sequence
29364
+ innerOptions.path = (options.path ? `${options.path}.` : '') + prop;
29365
+ field = field.resolve({
29366
+ value: inputValue,
29367
+ context: options.context,
29368
+ parent: intermediateValue
29369
+ });
29370
+ let fieldSpec = field instanceof Schema ? field.spec : undefined;
29371
+ let strict = fieldSpec == null ? void 0 : fieldSpec.strict;
29372
+ if (fieldSpec != null && fieldSpec.strip) {
29373
+ isChanged = isChanged || prop in value;
29374
+ continue;
29375
+ }
29376
+ fieldValue = !options.__validating || !strict ?
29377
+ // TODO: use _cast, this is double resolving
29378
+ field.cast(value[prop], innerOptions) : value[prop];
29379
+ if (fieldValue !== undefined) {
29380
+ intermediateValue[prop] = fieldValue;
29381
+ }
29382
+ } else if (exists && !strip) {
29383
+ intermediateValue[prop] = value[prop];
29384
+ }
29385
+ if (exists !== prop in intermediateValue || intermediateValue[prop] !== value[prop]) {
29386
+ isChanged = true;
29387
+ }
29388
+ }
29389
+ return isChanged ? intermediateValue : value;
29390
+ }
29391
+ _validate(_value, options = {}, panic, next) {
29392
+ let {
29393
+ from = [],
29394
+ originalValue = _value,
29395
+ recursive = this.spec.recursive
29396
+ } = options;
29397
+ options.from = [{
29398
+ schema: this,
29399
+ value: originalValue
29400
+ }, ...from];
29401
+ // this flag is needed for handling `strict` correctly in the context of
29402
+ // validation vs just casting. e.g strict() on a field is only used when validating
29403
+ options.__validating = true;
29404
+ options.originalValue = originalValue;
29405
+ super._validate(_value, options, panic, (objectErrors, value) => {
29406
+ if (!recursive || !isObject(value)) {
29407
+ next(objectErrors, value);
29408
+ return;
29409
+ }
29410
+ originalValue = originalValue || value;
29411
+ let tests = [];
29412
+ for (let key of this._nodes) {
29413
+ let field = this.fields[key];
29414
+ if (!field || Reference.isRef(field)) {
29415
+ continue;
29416
+ }
29417
+ tests.push(field.asNestedTest({
29418
+ options,
29419
+ key,
29420
+ parent: value,
29421
+ parentPath: options.path,
29422
+ originalParent: originalValue
29423
+ }));
29424
+ }
29425
+ this.runTests({
29426
+ tests,
29427
+ value,
29428
+ originalValue,
29429
+ options
29430
+ }, panic, fieldErrors => {
29431
+ next(fieldErrors.sort(this._sortErrors).concat(objectErrors), value);
29432
+ });
29433
+ });
29434
+ }
29435
+ clone(spec) {
29436
+ const next = super.clone(spec);
29437
+ next.fields = Object.assign({}, this.fields);
29438
+ next._nodes = this._nodes;
29439
+ next._excludedEdges = this._excludedEdges;
29440
+ next._sortErrors = this._sortErrors;
29441
+ return next;
29442
+ }
29443
+ concat(schema) {
29444
+ let next = super.concat(schema);
29445
+ let nextFields = next.fields;
29446
+ for (let [field, schemaOrRef] of Object.entries(this.fields)) {
29447
+ const target = nextFields[field];
29448
+ nextFields[field] = target === undefined ? schemaOrRef : target;
29449
+ }
29450
+ return next.withMutation(s =>
29451
+ // XXX: excludes here is wrong
29452
+ s.setFields(nextFields, [...this._excludedEdges, ...schema._excludedEdges]));
29453
+ }
29454
+ _getDefault(options) {
29455
+ if ('default' in this.spec) {
29456
+ return super._getDefault(options);
29457
+ }
29458
+
29459
+ // if there is no default set invent one
29460
+ if (!this._nodes.length) {
29461
+ return undefined;
29462
+ }
29463
+ let dft = {};
29464
+ this._nodes.forEach(key => {
29465
+ var _innerOptions;
29466
+ const field = this.fields[key];
29467
+ let innerOptions = options;
29468
+ if ((_innerOptions = innerOptions) != null && _innerOptions.value) {
29469
+ innerOptions = Object.assign({}, innerOptions, {
29470
+ parent: innerOptions.value,
29471
+ value: innerOptions.value[key]
29472
+ });
29473
+ }
29474
+ dft[key] = field && 'getDefault' in field ? field.getDefault(innerOptions) : undefined;
29475
+ });
29476
+ return dft;
29477
+ }
29478
+ setFields(shape, excludedEdges) {
29479
+ let next = this.clone();
29480
+ next.fields = shape;
29481
+ next._nodes = sortFields(shape, excludedEdges);
29482
+ next._sortErrors = sortByKeyOrder(Object.keys(shape));
29483
+ // XXX: this carries over edges which may not be what you want
29484
+ if (excludedEdges) next._excludedEdges = excludedEdges;
29485
+ return next;
29486
+ }
29487
+ shape(additions, excludes = []) {
29488
+ return this.clone().withMutation(next => {
29489
+ let edges = next._excludedEdges;
29490
+ if (excludes.length) {
29491
+ if (!Array.isArray(excludes[0])) excludes = [excludes];
29492
+ edges = [...next._excludedEdges, ...excludes];
29493
+ }
29494
+
29495
+ // XXX: excludes here is wrong
29496
+ return next.setFields(Object.assign(next.fields, additions), edges);
29497
+ });
29498
+ }
29499
+ partial() {
29500
+ const partial = {};
29501
+ for (const [key, schema] of Object.entries(this.fields)) {
29502
+ partial[key] = 'optional' in schema && schema.optional instanceof Function ? schema.optional() : schema;
29503
+ }
29504
+ return this.setFields(partial);
29505
+ }
29506
+ deepPartial() {
29507
+ const next = deepPartial(this);
29508
+ return next;
29509
+ }
29510
+ pick(keys) {
29511
+ const picked = {};
29512
+ for (const key of keys) {
29513
+ if (this.fields[key]) picked[key] = this.fields[key];
29514
+ }
29515
+ return this.setFields(picked, this._excludedEdges.filter(([a, b]) => keys.includes(a) && keys.includes(b)));
29516
+ }
29517
+ omit(keys) {
29518
+ const remaining = [];
29519
+ for (const key of Object.keys(this.fields)) {
29520
+ if (keys.includes(key)) continue;
29521
+ remaining.push(key);
29522
+ }
29523
+ return this.pick(remaining);
29524
+ }
29525
+ from(from, to, alias) {
29526
+ let fromGetter = propertyExprExports.getter(from, true);
29527
+ return this.transform(obj => {
29528
+ if (!obj) return obj;
29529
+ let newObj = obj;
29530
+ if (deepHas(obj, from)) {
29531
+ newObj = Object.assign({}, obj);
29532
+ if (!alias) delete newObj[from];
29533
+ newObj[to] = fromGetter(obj);
29534
+ }
29535
+ return newObj;
29536
+ });
29537
+ }
29538
+
29539
+ /** Parse an input JSON string to an object */
29540
+ json() {
29541
+ return this.transform(parseJson);
29542
+ }
29543
+ noUnknown(noAllow = true, message = object.noUnknown) {
29544
+ if (typeof noAllow !== 'boolean') {
29545
+ message = noAllow;
29546
+ noAllow = true;
29547
+ }
29548
+ let next = this.test({
29549
+ name: 'noUnknown',
29550
+ exclusive: true,
29551
+ message: message,
29552
+ test(value) {
29553
+ if (value == null) return true;
29554
+ const unknownKeys = unknown(this.schema, value);
29555
+ return !noAllow || unknownKeys.length === 0 || this.createError({
29556
+ params: {
29557
+ unknown: unknownKeys.join(', ')
29558
+ }
29559
+ });
29560
+ }
29561
+ });
29562
+ next.spec.noUnknown = noAllow;
29563
+ return next;
29564
+ }
29565
+ unknown(allow = true, message = object.noUnknown) {
29566
+ return this.noUnknown(!allow, message);
29567
+ }
29568
+ transformKeys(fn) {
29569
+ return this.transform(obj => {
29570
+ if (!obj) return obj;
29571
+ const result = {};
29572
+ for (const key of Object.keys(obj)) result[fn(key)] = obj[key];
29573
+ return result;
29574
+ });
29575
+ }
29576
+ camelCase() {
29577
+ return this.transformKeys(tinyCaseExports.camelCase);
29578
+ }
29579
+ snakeCase() {
29580
+ return this.transformKeys(tinyCaseExports.snakeCase);
29581
+ }
29582
+ constantCase() {
29583
+ return this.transformKeys(key => tinyCaseExports.snakeCase(key).toUpperCase());
29584
+ }
29585
+ describe(options) {
29586
+ const next = (options ? this.resolve(options) : this).clone();
29587
+ const base = super.describe(options);
29588
+ base.fields = {};
29589
+ for (const [key, value] of Object.entries(next.fields)) {
29590
+ var _innerOptions2;
29591
+ let innerOptions = options;
29592
+ if ((_innerOptions2 = innerOptions) != null && _innerOptions2.value) {
29593
+ innerOptions = Object.assign({}, innerOptions, {
29594
+ parent: innerOptions.value,
29595
+ value: innerOptions.value[key]
29596
+ });
29597
+ }
29598
+ base.fields[key] = value.describe(innerOptions);
29599
+ }
29600
+ return base;
29601
+ }
29602
+ }
29603
+ create$3.prototype = ObjectSchema.prototype;
29604
+
29605
+ function create$2(type) {
29606
+ return new ArraySchema(type);
29607
+ }
29608
+ class ArraySchema extends Schema {
29609
+ constructor(type) {
29610
+ super({
29611
+ type: 'array',
29612
+ spec: {
29613
+ types: type
29614
+ },
29615
+ check(v) {
29616
+ return Array.isArray(v);
29617
+ }
29618
+ });
29619
+
29620
+ // `undefined` specifically means uninitialized, as opposed to "no subtype"
29621
+ this.innerType = void 0;
29622
+ this.innerType = type;
29623
+ }
29624
+ _cast(_value, _opts) {
29625
+ const value = super._cast(_value, _opts);
29626
+
29627
+ // should ignore nulls here
29628
+ if (!this._typeCheck(value) || !this.innerType) {
29629
+ return value;
29630
+ }
29631
+ let isChanged = false;
29632
+ const castArray = value.map((v, idx) => {
29633
+ const castElement = this.innerType.cast(v, Object.assign({}, _opts, {
29634
+ path: `${_opts.path || ''}[${idx}]`
29635
+ }));
29636
+ if (castElement !== v) {
29637
+ isChanged = true;
29638
+ }
29639
+ return castElement;
29640
+ });
29641
+ return isChanged ? castArray : value;
29642
+ }
29643
+ _validate(_value, options = {}, panic, next) {
29644
+ var _options$recursive;
29645
+ // let sync = options.sync;
29646
+ // let path = options.path;
29647
+ let innerType = this.innerType;
29648
+ // let endEarly = options.abortEarly ?? this.spec.abortEarly;
29649
+ let recursive = (_options$recursive = options.recursive) != null ? _options$recursive : this.spec.recursive;
29650
+ options.originalValue != null ? options.originalValue : _value;
29651
+ super._validate(_value, options, panic, (arrayErrors, value) => {
29652
+ var _options$originalValu2;
29653
+ if (!recursive || !innerType || !this._typeCheck(value)) {
29654
+ next(arrayErrors, value);
29655
+ return;
29656
+ }
29657
+
29658
+ // #950 Ensure that sparse array empty slots are validated
29659
+ let tests = new Array(value.length);
29660
+ for (let index = 0; index < value.length; index++) {
29661
+ var _options$originalValu;
29662
+ tests[index] = innerType.asNestedTest({
29663
+ options,
29664
+ index,
29665
+ parent: value,
29666
+ parentPath: options.path,
29667
+ originalParent: (_options$originalValu = options.originalValue) != null ? _options$originalValu : _value
29668
+ });
29669
+ }
29670
+ this.runTests({
29671
+ value,
29672
+ tests,
29673
+ originalValue: (_options$originalValu2 = options.originalValue) != null ? _options$originalValu2 : _value,
29674
+ options
29675
+ }, panic, innerTypeErrors => next(innerTypeErrors.concat(arrayErrors), value));
29676
+ });
29677
+ }
29678
+ clone(spec) {
29679
+ const next = super.clone(spec);
29680
+ // @ts-expect-error readonly
29681
+ next.innerType = this.innerType;
29682
+ return next;
29683
+ }
29684
+
29685
+ /** Parse an input JSON string to an object */
29686
+ json() {
29687
+ return this.transform(parseJson);
29688
+ }
29689
+ concat(schema) {
29690
+ let next = super.concat(schema);
29691
+
29692
+ // @ts-expect-error readonly
29693
+ next.innerType = this.innerType;
29694
+ if (schema.innerType)
29695
+ // @ts-expect-error readonly
29696
+ next.innerType = next.innerType ?
29697
+ // @ts-expect-error Lazy doesn't have concat and will break
29698
+ next.innerType.concat(schema.innerType) : schema.innerType;
29699
+ return next;
29700
+ }
29701
+ of(schema) {
29702
+ // FIXME: this should return a new instance of array without the default to be
29703
+ let next = this.clone();
29704
+ if (!isSchema(schema)) throw new TypeError('`array.of()` sub-schema must be a valid yup schema not: ' + printValue(schema));
29705
+
29706
+ // @ts-expect-error readonly
29707
+ next.innerType = schema;
29708
+ next.spec = Object.assign({}, next.spec, {
29709
+ types: schema
29710
+ });
29711
+ return next;
29712
+ }
29713
+ length(length, message = array.length) {
29714
+ return this.test({
29715
+ message,
29716
+ name: 'length',
29717
+ exclusive: true,
29718
+ params: {
29719
+ length
29720
+ },
29721
+ skipAbsent: true,
29722
+ test(value) {
29723
+ return value.length === this.resolve(length);
29724
+ }
29725
+ });
29726
+ }
29727
+ min(min, message) {
29728
+ message = message || array.min;
29729
+ return this.test({
29730
+ message,
29731
+ name: 'min',
29732
+ exclusive: true,
29733
+ params: {
29734
+ min
29735
+ },
29736
+ skipAbsent: true,
29737
+ // FIXME(ts): Array<typeof T>
29738
+ test(value) {
29739
+ return value.length >= this.resolve(min);
29740
+ }
29741
+ });
29742
+ }
29743
+ max(max, message) {
29744
+ message = message || array.max;
29745
+ return this.test({
29746
+ message,
29747
+ name: 'max',
29748
+ exclusive: true,
29749
+ params: {
29750
+ max
29751
+ },
29752
+ skipAbsent: true,
29753
+ test(value) {
29754
+ return value.length <= this.resolve(max);
29755
+ }
29756
+ });
29757
+ }
29758
+ ensure() {
29759
+ return this.default(() => []).transform((val, original) => {
29760
+ // We don't want to return `null` for nullable schema
29761
+ if (this._typeCheck(val)) return val;
29762
+ return original == null ? [] : [].concat(original);
29763
+ });
29764
+ }
29765
+ compact(rejector) {
29766
+ let reject = !rejector ? v => !!v : (v, i, a) => !rejector(v, i, a);
29767
+ return this.transform(values => values != null ? values.filter(reject) : values);
29768
+ }
29769
+ describe(options) {
29770
+ const next = (options ? this.resolve(options) : this).clone();
29771
+ const base = super.describe(options);
29772
+ if (next.innerType) {
29773
+ var _innerOptions;
29774
+ let innerOptions = options;
29775
+ if ((_innerOptions = innerOptions) != null && _innerOptions.value) {
29776
+ innerOptions = Object.assign({}, innerOptions, {
29777
+ parent: innerOptions.value,
29778
+ value: innerOptions.value[0]
29779
+ });
29780
+ }
29781
+ base.innerType = next.innerType.describe(innerOptions);
29782
+ }
29783
+ return base;
29784
+ }
29785
+ }
29786
+ create$2.prototype = ArraySchema.prototype;
29787
+
29788
+ // @ts-ignore
29789
+ function create$1(schemas) {
29790
+ return new TupleSchema(schemas);
29791
+ }
29792
+ class TupleSchema extends Schema {
29793
+ constructor(schemas) {
29794
+ super({
29795
+ type: 'tuple',
29796
+ spec: {
29797
+ types: schemas
29798
+ },
29799
+ check(v) {
29800
+ const types = this.spec.types;
29801
+ return Array.isArray(v) && v.length === types.length;
29802
+ }
29803
+ });
29804
+ this.withMutation(() => {
29805
+ this.typeError(tuple.notType);
29806
+ });
29807
+ }
29808
+ _cast(inputValue, options) {
29809
+ const {
29810
+ types
29811
+ } = this.spec;
29812
+ const value = super._cast(inputValue, options);
29813
+ if (!this._typeCheck(value)) {
29814
+ return value;
29815
+ }
29816
+ let isChanged = false;
29817
+ const castArray = types.map((type, idx) => {
29818
+ const castElement = type.cast(value[idx], Object.assign({}, options, {
29819
+ path: `${options.path || ''}[${idx}]`
29820
+ }));
29821
+ if (castElement !== value[idx]) isChanged = true;
29822
+ return castElement;
29823
+ });
29824
+ return isChanged ? castArray : value;
29825
+ }
29826
+ _validate(_value, options = {}, panic, next) {
29827
+ let itemTypes = this.spec.types;
29828
+ super._validate(_value, options, panic, (tupleErrors, value) => {
29829
+ var _options$originalValu2;
29830
+ // intentionally not respecting recursive
29831
+ if (!this._typeCheck(value)) {
29832
+ next(tupleErrors, value);
29833
+ return;
29834
+ }
29835
+ let tests = [];
29836
+ for (let [index, itemSchema] of itemTypes.entries()) {
29837
+ var _options$originalValu;
29838
+ tests[index] = itemSchema.asNestedTest({
29839
+ options,
29840
+ index,
29841
+ parent: value,
29842
+ parentPath: options.path,
29843
+ originalParent: (_options$originalValu = options.originalValue) != null ? _options$originalValu : _value
29844
+ });
29845
+ }
29846
+ this.runTests({
29847
+ value,
29848
+ tests,
29849
+ originalValue: (_options$originalValu2 = options.originalValue) != null ? _options$originalValu2 : _value,
29850
+ options
29851
+ }, panic, innerTypeErrors => next(innerTypeErrors.concat(tupleErrors), value));
29852
+ });
29853
+ }
29854
+ describe(options) {
29855
+ const next = (options ? this.resolve(options) : this).clone();
29856
+ const base = super.describe(options);
29857
+ base.innerType = next.spec.types.map((schema, index) => {
29858
+ var _innerOptions;
29859
+ let innerOptions = options;
29860
+ if ((_innerOptions = innerOptions) != null && _innerOptions.value) {
29861
+ innerOptions = Object.assign({}, innerOptions, {
29862
+ parent: innerOptions.value,
29863
+ value: innerOptions.value[index]
29864
+ });
29865
+ }
29866
+ return schema.describe(innerOptions);
29867
+ });
29868
+ return base;
29869
+ }
29870
+ }
29871
+ create$1.prototype = TupleSchema.prototype;
29872
+
29873
+ function create(builder) {
29874
+ return new Lazy(builder);
29875
+ }
29876
+ class Lazy {
29877
+ constructor(builder) {
29878
+ this.type = 'lazy';
29879
+ this.__isYupSchema__ = true;
29880
+ this.spec = void 0;
29881
+ this._resolve = (value, options = {}) => {
29882
+ let schema = this.builder(value, options);
29883
+ if (!isSchema(schema)) throw new TypeError('lazy() functions must return a valid schema');
29884
+ if (this.spec.optional) schema = schema.optional();
29885
+ return schema.resolve(options);
29886
+ };
29887
+ this.builder = builder;
29888
+ this.spec = {
29889
+ meta: undefined,
29890
+ optional: false
29891
+ };
29892
+ }
29893
+ clone(spec) {
29894
+ const next = new Lazy(this.builder);
29895
+ next.spec = Object.assign({}, this.spec, spec);
29896
+ return next;
29897
+ }
29898
+ optionality(optional) {
29899
+ const next = this.clone({
29900
+ optional
29901
+ });
29902
+ return next;
29903
+ }
29904
+ optional() {
29905
+ return this.optionality(true);
29906
+ }
29907
+ resolve(options) {
29908
+ return this._resolve(options.value, options);
29909
+ }
29910
+ cast(value, options) {
29911
+ return this._resolve(value, options).cast(value, options);
29912
+ }
29913
+ asNestedTest(config) {
29914
+ let {
29915
+ key,
29916
+ index,
29917
+ parent,
29918
+ options
29919
+ } = config;
29920
+ let value = parent[index != null ? index : key];
29921
+ return this._resolve(value, Object.assign({}, options, {
29922
+ value,
29923
+ parent
29924
+ })).asNestedTest(config);
29925
+ }
29926
+ validate(value, options) {
29927
+ return this._resolve(value, options).validate(value, options);
29928
+ }
29929
+ validateSync(value, options) {
29930
+ return this._resolve(value, options).validateSync(value, options);
29931
+ }
29932
+ validateAt(path, value, options) {
29933
+ return this._resolve(value, options).validateAt(path, value, options);
29934
+ }
29935
+ validateSyncAt(path, value, options) {
29936
+ return this._resolve(value, options).validateSyncAt(path, value, options);
29937
+ }
29938
+ isValid(value, options) {
29939
+ return this._resolve(value, options).isValid(value, options);
29940
+ }
29941
+ isValidSync(value, options) {
29942
+ return this._resolve(value, options).isValidSync(value, options);
29943
+ }
29944
+ describe(options) {
29945
+ return options ? this.resolve(options).describe(options) : {
29946
+ type: 'lazy',
29947
+ meta: this.spec.meta,
29948
+ label: undefined
29949
+ };
29950
+ }
29951
+ meta(...args) {
29952
+ if (args.length === 0) return this.spec.meta;
29953
+ let next = this.clone();
29954
+ next.spec.meta = Object.assign(next.spec.meta || {}, args[0]);
29955
+ return next;
29956
+ }
29957
+ }
29958
+
29959
+ function setLocale(custom) {
29960
+ Object.keys(custom).forEach(type => {
29961
+ // @ts-ignore
29962
+ Object.keys(custom[type]).forEach(method => {
29963
+ // @ts-ignore
29964
+ locale[type][method] = custom[type][method];
29965
+ });
29966
+ });
29967
+ }
29968
+
29969
+ function addMethod(schemaType, name, fn) {
29970
+ if (!schemaType || !isSchema(schemaType.prototype)) throw new TypeError('You must provide a yup schema constructor function');
29971
+ if (typeof name !== 'string') throw new TypeError('A Method name must be provided');
29972
+ if (typeof fn !== 'function') throw new TypeError('Method function must be provided');
29973
+ schemaType.prototype[name] = fn;
29974
+ }
29975
+
29976
+ var index_esm = /*#__PURE__*/Object.freeze({
29977
+ __proto__: null,
29978
+ ArraySchema: ArraySchema,
29979
+ BooleanSchema: BooleanSchema,
29980
+ DateSchema: DateSchema,
29981
+ MixedSchema: MixedSchema,
29982
+ NumberSchema: NumberSchema,
29983
+ ObjectSchema: ObjectSchema,
29984
+ Schema: Schema,
29985
+ StringSchema: StringSchema,
29986
+ TupleSchema: TupleSchema,
29987
+ ValidationError: ValidationError,
29988
+ addMethod: addMethod,
29989
+ array: create$2,
29990
+ bool: create$7,
29991
+ boolean: create$7,
29992
+ date: create$4,
29993
+ defaultLocale: locale,
29994
+ getIn: getIn,
29995
+ isSchema: isSchema,
29996
+ lazy: create,
29997
+ mixed: create$8,
29998
+ number: create$5,
29999
+ object: create$3,
30000
+ printValue: printValue,
30001
+ reach: reach,
30002
+ ref: create$9,
30003
+ setLocale: setLocale,
30004
+ string: create$6,
30005
+ tuple: create$1
30006
+ });
30007
+
27251
30008
  exports.Controller = Controller;
27252
30009
  exports.Form = Form;
27253
30010
  exports.FormProvider = FormProvider;
@@ -27260,6 +30017,7 @@ exports.RHFSlider = RHFSlider;
27260
30017
  exports.RHFSwitch = RHFSwitch;
27261
30018
  exports.RHFTextField = RHFTextField;
27262
30019
  exports.Simple = Simple;
30020
+ exports.Yup = index_esm;
27263
30021
  exports.appendErrors = appendErrors;
27264
30022
  exports.get = get;
27265
30023
  exports.set = set;
@@ -27269,4 +30027,5 @@ exports.useForm = useForm;
27269
30027
  exports.useFormContext = useFormContext;
27270
30028
  exports.useFormState = useFormState;
27271
30029
  exports.useWatch = useWatch;
30030
+ exports.yupResolver = o;
27272
30031
  //# sourceMappingURL=index.cjs.js.map