tp-react-elements-dev 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -10762,7 +10762,7 @@ function isElement(node) {
10762
10762
  return node instanceof OwnElement || node instanceof Element;
10763
10763
  }
10764
10764
 
10765
- function isHTMLElement$1(node) {
10765
+ function isHTMLElement$2(node) {
10766
10766
  var OwnElement = getWindow(node).HTMLElement;
10767
10767
  return node instanceof OwnElement || node instanceof HTMLElement;
10768
10768
  }
@@ -10786,7 +10786,7 @@ function applyStyles(_ref) {
10786
10786
  var attributes = state.attributes[name] || {};
10787
10787
  var element = state.elements[name]; // arrow is optional + virtual elements
10788
10788
 
10789
- if (!isHTMLElement$1(element) || !getNodeName(element)) {
10789
+ if (!isHTMLElement$2(element) || !getNodeName(element)) {
10790
10790
  return;
10791
10791
  } // Flow doesn't support to extend this property, but it's the most
10792
10792
  // effective way to apply styles to an HTMLElement
@@ -10838,7 +10838,7 @@ function effect$2(_ref2) {
10838
10838
  return style;
10839
10839
  }, {}); // arrow is optional + virtual elements
10840
10840
 
10841
- if (!isHTMLElement$1(element) || !getNodeName(element)) {
10841
+ if (!isHTMLElement$2(element) || !getNodeName(element)) {
10842
10842
  return;
10843
10843
  }
10844
10844
 
@@ -10897,7 +10897,7 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy) {
10897
10897
  var scaleX = 1;
10898
10898
  var scaleY = 1;
10899
10899
 
10900
- if (includeScale && isHTMLElement$1(element)) {
10900
+ if (includeScale && isHTMLElement$2(element)) {
10901
10901
  scaleX = element.offsetWidth > 0 ? round$1(clientRect.width) / element.offsetWidth || 1 : 1;
10902
10902
  scaleY = element.offsetHeight > 0 ? round$1(clientRect.height) / element.offsetHeight || 1 : 1;
10903
10903
  }
@@ -11002,7 +11002,7 @@ function getParentNode(element) {
11002
11002
  }
11003
11003
 
11004
11004
  function getTrueOffsetParent(element) {
11005
- if (!isHTMLElement$1(element) || // https://github.com/popperjs/popper-core/issues/837
11005
+ if (!isHTMLElement$2(element) || // https://github.com/popperjs/popper-core/issues/837
11006
11006
  getComputedStyle(element).position === 'fixed') {
11007
11007
  return null;
11008
11008
  }
@@ -11016,7 +11016,7 @@ function getContainingBlock(element) {
11016
11016
  var isFirefox = /firefox/i.test(getUAString());
11017
11017
  var isIE = /Trident/i.test(getUAString());
11018
11018
 
11019
- if (isIE && isHTMLElement$1(element)) {
11019
+ if (isIE && isHTMLElement$2(element)) {
11020
11020
  // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
11021
11021
  var elementCss = getComputedStyle(element);
11022
11022
 
@@ -11031,7 +11031,7 @@ function getContainingBlock(element) {
11031
11031
  currentNode = currentNode.host;
11032
11032
  }
11033
11033
 
11034
- while (isHTMLElement$1(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
11034
+ while (isHTMLElement$2(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
11035
11035
  var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
11036
11036
  // create a containing block.
11037
11037
  // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
@@ -11501,7 +11501,7 @@ function getScrollParent(node) {
11501
11501
  return node.ownerDocument.body;
11502
11502
  }
11503
11503
 
11504
- if (isHTMLElement$1(node) && isScrollParent(node)) {
11504
+ if (isHTMLElement$2(node) && isScrollParent(node)) {
11505
11505
  return node;
11506
11506
  }
11507
11507
 
@@ -11563,7 +11563,7 @@ function getClientRectFromMixedType(element, clippingParent, strategy) {
11563
11563
  function getClippingParents(element) {
11564
11564
  var clippingParents = listScrollParents(getParentNode(element));
11565
11565
  var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
11566
- var clipperElement = canEscapeClipping && isHTMLElement$1(element) ? getOffsetParent(element) : element;
11566
+ var clipperElement = canEscapeClipping && isHTMLElement$2(element) ? getOffsetParent(element) : element;
11567
11567
 
11568
11568
  if (!isElement(clipperElement)) {
11569
11569
  return [];
@@ -12175,7 +12175,7 @@ function getHTMLElementScroll(element) {
12175
12175
  }
12176
12176
 
12177
12177
  function getNodeScroll(node) {
12178
- if (node === getWindow(node) || !isHTMLElement$1(node)) {
12178
+ if (node === getWindow(node) || !isHTMLElement$2(node)) {
12179
12179
  return getWindowScroll(node);
12180
12180
  } else {
12181
12181
  return getHTMLElementScroll(node);
@@ -12196,8 +12196,8 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
12196
12196
  isFixed = false;
12197
12197
  }
12198
12198
 
12199
- var isOffsetParentAnElement = isHTMLElement$1(offsetParent);
12200
- var offsetParentIsScaled = isHTMLElement$1(offsetParent) && isElementScaled(offsetParent);
12199
+ var isOffsetParentAnElement = isHTMLElement$2(offsetParent);
12200
+ var offsetParentIsScaled = isHTMLElement$2(offsetParent) && isElementScaled(offsetParent);
12201
12201
  var documentElement = getDocumentElement(offsetParent);
12202
12202
  var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
12203
12203
  var scroll = {
@@ -12215,7 +12215,7 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
12215
12215
  scroll = getNodeScroll(offsetParent);
12216
12216
  }
12217
12217
 
12218
- if (isHTMLElement$1(offsetParent)) {
12218
+ if (isHTMLElement$2(offsetParent)) {
12219
12219
  offsets = getBoundingClientRect(offsetParent, true);
12220
12220
  offsets.x += offsetParent.clientLeft;
12221
12221
  offsets.y += offsetParent.clientTop;
@@ -12527,11 +12527,11 @@ function flipPlacement(placement, direction) {
12527
12527
  function resolveAnchorEl$1(anchorEl) {
12528
12528
  return typeof anchorEl === 'function' ? anchorEl() : anchorEl;
12529
12529
  }
12530
- function isHTMLElement(element) {
12530
+ function isHTMLElement$1(element) {
12531
12531
  return element.nodeType !== undefined;
12532
12532
  }
12533
12533
  function isVirtualElement(element) {
12534
- return !isHTMLElement(element);
12534
+ return !isHTMLElement$1(element);
12535
12535
  }
12536
12536
  const useUtilityClasses$U = () => {
12537
12537
  const slots = {
@@ -12593,7 +12593,7 @@ const PopperTooltip = /*#__PURE__*/React$1.forwardRef(function PopperTooltip(pro
12593
12593
  setPlacement(data.placement);
12594
12594
  };
12595
12595
  if (process.env.NODE_ENV !== 'production') {
12596
- if (resolvedAnchorElement && isHTMLElement(resolvedAnchorElement) && resolvedAnchorElement.nodeType === 1) {
12596
+ if (resolvedAnchorElement && isHTMLElement$1(resolvedAnchorElement) && resolvedAnchorElement.nodeType === 1) {
12597
12597
  const box = resolvedAnchorElement.getBoundingClientRect();
12598
12598
  if (process.env.NODE_ENV !== 'test' && box.top === 0 && box.left === 0 && box.right === 0 && box.bottom === 0) {
12599
12599
  console.warn(['MUI: The `anchorEl` prop provided to the component is invalid.', 'The anchor element should be part of the document layout.', "Make sure the element is present in the document or that it's not display none."].join('\n'));
@@ -12710,7 +12710,7 @@ const Popper$1 = /*#__PURE__*/React$1.forwardRef(function Popper(props, forwarde
12710
12710
  container = containerProp;
12711
12711
  } else if (anchorEl) {
12712
12712
  const resolvedAnchorEl = resolveAnchorEl$1(anchorEl);
12713
- container = resolvedAnchorEl && isHTMLElement(resolvedAnchorEl) ? ownerDocument(resolvedAnchorEl).body : ownerDocument(null).body;
12713
+ container = resolvedAnchorEl && isHTMLElement$1(resolvedAnchorEl) ? ownerDocument(resolvedAnchorEl).body : ownerDocument(null).body;
12714
12714
  }
12715
12715
  const display = !open && keepMounted && (!transition || exited) ? 'none' : undefined;
12716
12716
  const transitionProps = transition ? {
@@ -12761,7 +12761,7 @@ process.env.NODE_ENV !== "production" ? Popper$1.propTypes /* remove-proptypes *
12761
12761
  anchorEl: chainPropTypes(PropTypes.oneOfType([HTMLElementType, PropTypes.object, PropTypes.func]), props => {
12762
12762
  if (props.open) {
12763
12763
  const resolvedAnchorEl = resolveAnchorEl$1(props.anchorEl);
12764
- if (resolvedAnchorEl && isHTMLElement(resolvedAnchorEl) && resolvedAnchorEl.nodeType === 1) {
12764
+ if (resolvedAnchorEl && isHTMLElement$1(resolvedAnchorEl) && resolvedAnchorEl.nodeType === 1) {
12765
12765
  const box = resolvedAnchorEl.getBoundingClientRect();
12766
12766
  if (process.env.NODE_ENV !== 'test' && box.top === 0 && box.left === 0 && box.right === 0 && box.bottom === 0) {
12767
12767
  return new Error(['MUI: The `anchorEl` prop provided to the component is invalid.', 'The anchor element should be part of the document layout.', "Make sure the element is present in the document or that it's not display none."].join('\n'));
@@ -13119,7 +13119,7 @@ function createFilterOptions(config = {}) {
13119
13119
  }
13120
13120
 
13121
13121
  // To replace with .findIndex() once we stop IE11 support.
13122
- function findIndex$1(array, comp) {
13122
+ function findIndex$2(array, comp) {
13123
13123
  for (let i = 0; i < array.length; i += 1) {
13124
13124
  if (comp(array[i])) {
13125
13125
  return i;
@@ -13467,7 +13467,7 @@ function useAutocomplete(props) {
13467
13467
  if (highlightedIndexRef.current !== -1 && previousProps.filteredOptions && previousProps.filteredOptions.length !== filteredOptions.length && previousProps.inputValue === inputValue && (multiple ? value.length === previousProps.value.length && previousProps.value.every((val, i) => getOptionLabel(value[i]) === getOptionLabel(val)) : isSameValue(previousProps.value, value))) {
13468
13468
  const previousHighlightedOption = previousProps.filteredOptions[highlightedIndexRef.current];
13469
13469
  if (previousHighlightedOption) {
13470
- return findIndex$1(filteredOptions, option => {
13470
+ return findIndex$2(filteredOptions, option => {
13471
13471
  return getOptionLabel(option) === getOptionLabel(previousHighlightedOption);
13472
13472
  });
13473
13473
  }
@@ -13504,10 +13504,10 @@ function useAutocomplete(props) {
13504
13504
  const currentOption = filteredOptions[highlightedIndexRef.current];
13505
13505
 
13506
13506
  // Keep the current highlighted index if possible
13507
- if (multiple && currentOption && findIndex$1(value, val => isOptionEqualToValue(currentOption, val)) !== -1) {
13507
+ if (multiple && currentOption && findIndex$2(value, val => isOptionEqualToValue(currentOption, val)) !== -1) {
13508
13508
  return;
13509
13509
  }
13510
- const itemIndex = findIndex$1(filteredOptions, optionItem => isOptionEqualToValue(optionItem, valueItem));
13510
+ const itemIndex = findIndex$2(filteredOptions, optionItem => isOptionEqualToValue(optionItem, valueItem));
13511
13511
  if (itemIndex === -1) {
13512
13512
  changeHighlightedIndex({
13513
13513
  diff: 'reset'
@@ -13606,7 +13606,7 @@ function useAutocomplete(props) {
13606
13606
  console.error([`MUI: The \`isOptionEqualToValue\` method of ${componentName} does not handle the arguments correctly.`, `The component expects a single value to match a given option but found ${matches.length} matches.`].join('\n'));
13607
13607
  }
13608
13608
  }
13609
- const itemIndex = findIndex$1(newValue, valueItem => isOptionEqualToValue(option, valueItem));
13609
+ const itemIndex = findIndex$2(newValue, valueItem => isOptionEqualToValue(option, valueItem));
13610
13610
  if (itemIndex === -1) {
13611
13611
  newValue.push(option);
13612
13612
  } else if (origin !== 'freeSolo') {
@@ -23325,12 +23325,12 @@ var isDateObject = (value) => value instanceof Date;
23325
23325
  var isNullOrUndefined = (value) => value == null;
23326
23326
 
23327
23327
  const isObjectType = (value) => typeof value === 'object';
23328
- var isObject = (value) => !isNullOrUndefined(value) &&
23328
+ var isObject$1 = (value) => !isNullOrUndefined(value) &&
23329
23329
  !Array.isArray(value) &&
23330
23330
  isObjectType(value) &&
23331
23331
  !isDateObject(value);
23332
23332
 
23333
- var getEventValue = (event) => isObject(event) && event.target
23333
+ var getEventValue = (event) => isObject$1(event) && event.target
23334
23334
  ? isCheckBoxInput(event.target)
23335
23335
  ? event.target.checked
23336
23336
  : event.target.value
@@ -23342,7 +23342,7 @@ var isNameInFieldArray = (names, name) => names.has(getNodeParentName(name));
23342
23342
 
23343
23343
  var isPlainObject = (tempObject) => {
23344
23344
  const prototypeCopy = tempObject.constructor && tempObject.constructor.prototype;
23345
- return (isObject(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf'));
23345
+ return (isObject$1(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf'));
23346
23346
  };
23347
23347
 
23348
23348
  var isWeb = typeof window !== 'undefined' &&
@@ -23359,7 +23359,7 @@ function cloneObject(data) {
23359
23359
  copy = new Set(data);
23360
23360
  }
23361
23361
  else if (!(isWeb && (data instanceof Blob || data instanceof FileList)) &&
23362
- (isArray || isObject(data))) {
23362
+ (isArray || isObject$1(data))) {
23363
23363
  copy = isArray ? [] : {};
23364
23364
  if (!isArray && !isPlainObject(data)) {
23365
23365
  copy = data;
@@ -23383,7 +23383,7 @@ var compact = (value) => Array.isArray(value) ? value.filter(Boolean) : [];
23383
23383
  var isUndefined = (val) => val === undefined;
23384
23384
 
23385
23385
  var get = (object, path, defaultValue) => {
23386
- if (!path || !isObject(object)) {
23386
+ if (!path || !isObject$1(object)) {
23387
23387
  return defaultValue;
23388
23388
  }
23389
23389
  const result = compact(path.split(/[,[\].]+?/)).reduce((result, key) => isNullOrUndefined(result) ? result : result[key], object);
@@ -23411,7 +23411,7 @@ var set = (object, path, value) => {
23411
23411
  if (index !== lastIndex) {
23412
23412
  const objValue = object[key];
23413
23413
  newValue =
23414
- isObject(objValue) || Array.isArray(objValue)
23414
+ isObject$1(objValue) || Array.isArray(objValue)
23415
23415
  ? objValue
23416
23416
  : !isNaN(+tempPath[index + 1])
23417
23417
  ? []
@@ -23438,6 +23438,15 @@ const VALIDATION_MODE = {
23438
23438
  onTouched: 'onTouched',
23439
23439
  all: 'all',
23440
23440
  };
23441
+ const INPUT_VALIDATION_RULES = {
23442
+ max: 'max',
23443
+ min: 'min',
23444
+ maxLength: 'maxLength',
23445
+ minLength: 'minLength',
23446
+ pattern: 'pattern',
23447
+ required: 'required',
23448
+ validate: 'validate',
23449
+ };
23441
23450
 
23442
23451
  const HookFormContext = React__default.createContext(null);
23443
23452
  /**
@@ -23491,7 +23500,7 @@ var getProxyFormState = (formState, control, localProxyFormState, isRoot = true)
23491
23500
  return result;
23492
23501
  };
23493
23502
 
23494
- var isEmptyObject = (value) => isObject(value) && !Object.keys(value).length;
23503
+ var isEmptyObject = (value) => isObject$1(value) && !Object.keys(value).length;
23495
23504
 
23496
23505
  var shouldRenderFormState = (formStateData, _proxyFormState, updateFormState, isRoot) => {
23497
23506
  updateFormState(formStateData);
@@ -23499,7 +23508,7 @@ var shouldRenderFormState = (formStateData, _proxyFormState, updateFormState, is
23499
23508
  return (isEmptyObject(formState) ||
23500
23509
  Object.keys(formState).length >= Object.keys(_proxyFormState).length ||
23501
23510
  Object.keys(formState).find((key) => _proxyFormState[key] ===
23502
- (!isRoot )));
23511
+ (!isRoot || VALIDATION_MODE.all)));
23503
23512
  };
23504
23513
 
23505
23514
  var convertToArrayPayload = (value) => (Array.isArray(value) ? value : [value]);
@@ -23600,11 +23609,13 @@ var isString = (value) => typeof value === 'string';
23600
23609
 
23601
23610
  var generateWatchOutput = (names, _names, formValues, isGlobal, defaultValue) => {
23602
23611
  if (isString(names)) {
23612
+ isGlobal && _names.watch.add(names);
23603
23613
  return get(formValues, names, defaultValue);
23604
23614
  }
23605
23615
  if (Array.isArray(names)) {
23606
- return names.map((fieldName) => (get(formValues, fieldName)));
23616
+ return names.map((fieldName) => (isGlobal && _names.watch.add(fieldName), get(formValues, fieldName)));
23607
23617
  }
23618
+ isGlobal && (_names.watchAll = true);
23608
23619
  return formValues;
23609
23620
  };
23610
23621
 
@@ -23823,7 +23834,1656 @@ function useController(props) {
23823
23834
  */
23824
23835
  const Controller = (props) => props.render(useController(props));
23825
23836
 
23826
- var s=function(s){var t=s.as,a=s.errors,m=s.name,o=s.message,i=s.render,l=function(e,r){if(null==e)return {};var n,s,t={},a=Object.keys(e);for(s=0;s<a.length;s++)r.indexOf(n=a[s])>=0||(t[n]=e[n]);return t}(s,["as","errors","name","message","render"]),f=useFormContext(),c=get(a||f.formState.errors,m);if(!c)return null;var g=c.message,u=c.types,d=Object.assign({},l,{children:g||o});return React$1.isValidElement(t)?React$1.cloneElement(t,d):i?i({message:g||o,messages:u}):React$1.createElement(t||React$1.Fragment,d)};
23837
+ var appendErrors = (name, validateAllFieldCriteria, errors, type, message) => validateAllFieldCriteria
23838
+ ? {
23839
+ ...errors[name],
23840
+ types: {
23841
+ ...(errors[name] && errors[name].types ? errors[name].types : {}),
23842
+ [type]: message || true,
23843
+ },
23844
+ }
23845
+ : {};
23846
+
23847
+ var getValidationModes = (mode) => ({
23848
+ isOnSubmit: !mode || mode === VALIDATION_MODE.onSubmit,
23849
+ isOnBlur: mode === VALIDATION_MODE.onBlur,
23850
+ isOnChange: mode === VALIDATION_MODE.onChange,
23851
+ isOnAll: mode === VALIDATION_MODE.all,
23852
+ isOnTouch: mode === VALIDATION_MODE.onTouched,
23853
+ });
23854
+
23855
+ var isWatched = (name, _names, isBlurEvent) => !isBlurEvent &&
23856
+ (_names.watchAll ||
23857
+ _names.watch.has(name) ||
23858
+ [..._names.watch].some((watchName) => name.startsWith(watchName) &&
23859
+ /^\.\w+/.test(name.slice(watchName.length))));
23860
+
23861
+ const iterateFieldsByAction = (fields, action, fieldsNames, abortEarly) => {
23862
+ for (const key of fieldsNames || Object.keys(fields)) {
23863
+ const field = get(fields, key);
23864
+ if (field) {
23865
+ const { _f, ...currentField } = field;
23866
+ if (_f) {
23867
+ if (_f.refs && _f.refs[0] && action(_f.refs[0], key) && !abortEarly) {
23868
+ break;
23869
+ }
23870
+ else if (_f.ref && action(_f.ref, _f.name) && !abortEarly) {
23871
+ break;
23872
+ }
23873
+ else {
23874
+ iterateFieldsByAction(currentField, action);
23875
+ }
23876
+ }
23877
+ else if (isObject$1(currentField)) {
23878
+ iterateFieldsByAction(currentField, action);
23879
+ }
23880
+ }
23881
+ }
23882
+ };
23883
+
23884
+ var updateFieldArrayRootError = (errors, error, name) => {
23885
+ const fieldArrayErrors = compact(get(errors, name));
23886
+ set(fieldArrayErrors, 'root', error[name]);
23887
+ set(errors, name, fieldArrayErrors);
23888
+ return errors;
23889
+ };
23890
+
23891
+ var isFileInput = (element) => element.type === 'file';
23892
+
23893
+ var isFunction = (value) => typeof value === 'function';
23894
+
23895
+ var isHTMLElement = (value) => {
23896
+ if (!isWeb) {
23897
+ return false;
23898
+ }
23899
+ const owner = value ? value.ownerDocument : 0;
23900
+ return (value instanceof
23901
+ (owner && owner.defaultView ? owner.defaultView.HTMLElement : HTMLElement));
23902
+ };
23903
+
23904
+ var isMessage = (value) => isString(value);
23905
+
23906
+ var isRadioInput = (element) => element.type === 'radio';
23907
+
23908
+ var isRegex = (value) => value instanceof RegExp;
23909
+
23910
+ const defaultResult = {
23911
+ value: false,
23912
+ isValid: false,
23913
+ };
23914
+ const validResult = { value: true, isValid: true };
23915
+ var getCheckboxValue = (options) => {
23916
+ if (Array.isArray(options)) {
23917
+ if (options.length > 1) {
23918
+ const values = options
23919
+ .filter((option) => option && option.checked && !option.disabled)
23920
+ .map((option) => option.value);
23921
+ return { value: values, isValid: !!values.length };
23922
+ }
23923
+ return options[0].checked && !options[0].disabled
23924
+ ? // @ts-expect-error expected to work in the browser
23925
+ options[0].attributes && !isUndefined(options[0].attributes.value)
23926
+ ? isUndefined(options[0].value) || options[0].value === ''
23927
+ ? validResult
23928
+ : { value: options[0].value, isValid: true }
23929
+ : validResult
23930
+ : defaultResult;
23931
+ }
23932
+ return defaultResult;
23933
+ };
23934
+
23935
+ const defaultReturn = {
23936
+ isValid: false,
23937
+ value: null,
23938
+ };
23939
+ var getRadioValue = (options) => Array.isArray(options)
23940
+ ? options.reduce((previous, option) => option && option.checked && !option.disabled
23941
+ ? {
23942
+ isValid: true,
23943
+ value: option.value,
23944
+ }
23945
+ : previous, defaultReturn)
23946
+ : defaultReturn;
23947
+
23948
+ function getValidateError(result, ref, type = 'validate') {
23949
+ if (isMessage(result) ||
23950
+ (Array.isArray(result) && result.every(isMessage)) ||
23951
+ (isBoolean(result) && !result)) {
23952
+ return {
23953
+ type,
23954
+ message: isMessage(result) ? result : '',
23955
+ ref,
23956
+ };
23957
+ }
23958
+ }
23959
+
23960
+ var getValueAndMessage = (validationData) => isObject$1(validationData) && !isRegex(validationData)
23961
+ ? validationData
23962
+ : {
23963
+ value: validationData,
23964
+ message: '',
23965
+ };
23966
+
23967
+ var validateField = async (field, formValues, validateAllFieldCriteria, shouldUseNativeValidation, isFieldArray) => {
23968
+ const { ref, refs, required, maxLength, minLength, min, max, pattern, validate, name, valueAsNumber, mount, disabled, } = field._f;
23969
+ const inputValue = get(formValues, name);
23970
+ if (!mount || disabled) {
23971
+ return {};
23972
+ }
23973
+ const inputRef = refs ? refs[0] : ref;
23974
+ const setCustomValidity = (message) => {
23975
+ if (shouldUseNativeValidation && inputRef.reportValidity) {
23976
+ inputRef.setCustomValidity(isBoolean(message) ? '' : message || '');
23977
+ inputRef.reportValidity();
23978
+ }
23979
+ };
23980
+ const error = {};
23981
+ const isRadio = isRadioInput(ref);
23982
+ const isCheckBox = isCheckBoxInput(ref);
23983
+ const isRadioOrCheckbox = isRadio || isCheckBox;
23984
+ const isEmpty = ((valueAsNumber || isFileInput(ref)) &&
23985
+ isUndefined(ref.value) &&
23986
+ isUndefined(inputValue)) ||
23987
+ (isHTMLElement(ref) && ref.value === '') ||
23988
+ inputValue === '' ||
23989
+ (Array.isArray(inputValue) && !inputValue.length);
23990
+ const appendErrorsCurry = appendErrors.bind(null, name, validateAllFieldCriteria, error);
23991
+ const getMinMaxMessage = (exceedMax, maxLengthMessage, minLengthMessage, maxType = INPUT_VALIDATION_RULES.maxLength, minType = INPUT_VALIDATION_RULES.minLength) => {
23992
+ const message = exceedMax ? maxLengthMessage : minLengthMessage;
23993
+ error[name] = {
23994
+ type: exceedMax ? maxType : minType,
23995
+ message,
23996
+ ref,
23997
+ ...appendErrorsCurry(exceedMax ? maxType : minType, message),
23998
+ };
23999
+ };
24000
+ if (isFieldArray
24001
+ ? !Array.isArray(inputValue) || !inputValue.length
24002
+ : required &&
24003
+ ((!isRadioOrCheckbox && (isEmpty || isNullOrUndefined(inputValue))) ||
24004
+ (isBoolean(inputValue) && !inputValue) ||
24005
+ (isCheckBox && !getCheckboxValue(refs).isValid) ||
24006
+ (isRadio && !getRadioValue(refs).isValid))) {
24007
+ const { value, message } = isMessage(required)
24008
+ ? { value: !!required, message: required }
24009
+ : getValueAndMessage(required);
24010
+ if (value) {
24011
+ error[name] = {
24012
+ type: INPUT_VALIDATION_RULES.required,
24013
+ message,
24014
+ ref: inputRef,
24015
+ ...appendErrorsCurry(INPUT_VALIDATION_RULES.required, message),
24016
+ };
24017
+ if (!validateAllFieldCriteria) {
24018
+ setCustomValidity(message);
24019
+ return error;
24020
+ }
24021
+ }
24022
+ }
24023
+ if (!isEmpty && (!isNullOrUndefined(min) || !isNullOrUndefined(max))) {
24024
+ let exceedMax;
24025
+ let exceedMin;
24026
+ const maxOutput = getValueAndMessage(max);
24027
+ const minOutput = getValueAndMessage(min);
24028
+ if (!isNullOrUndefined(inputValue) && !isNaN(inputValue)) {
24029
+ const valueNumber = ref.valueAsNumber ||
24030
+ (inputValue ? +inputValue : inputValue);
24031
+ if (!isNullOrUndefined(maxOutput.value)) {
24032
+ exceedMax = valueNumber > maxOutput.value;
24033
+ }
24034
+ if (!isNullOrUndefined(minOutput.value)) {
24035
+ exceedMin = valueNumber < minOutput.value;
24036
+ }
24037
+ }
24038
+ else {
24039
+ const valueDate = ref.valueAsDate || new Date(inputValue);
24040
+ const convertTimeToDate = (time) => new Date(new Date().toDateString() + ' ' + time);
24041
+ const isTime = ref.type == 'time';
24042
+ const isWeek = ref.type == 'week';
24043
+ if (isString(maxOutput.value) && inputValue) {
24044
+ exceedMax = isTime
24045
+ ? convertTimeToDate(inputValue) > convertTimeToDate(maxOutput.value)
24046
+ : isWeek
24047
+ ? inputValue > maxOutput.value
24048
+ : valueDate > new Date(maxOutput.value);
24049
+ }
24050
+ if (isString(minOutput.value) && inputValue) {
24051
+ exceedMin = isTime
24052
+ ? convertTimeToDate(inputValue) < convertTimeToDate(minOutput.value)
24053
+ : isWeek
24054
+ ? inputValue < minOutput.value
24055
+ : valueDate < new Date(minOutput.value);
24056
+ }
24057
+ }
24058
+ if (exceedMax || exceedMin) {
24059
+ getMinMaxMessage(!!exceedMax, maxOutput.message, minOutput.message, INPUT_VALIDATION_RULES.max, INPUT_VALIDATION_RULES.min);
24060
+ if (!validateAllFieldCriteria) {
24061
+ setCustomValidity(error[name].message);
24062
+ return error;
24063
+ }
24064
+ }
24065
+ }
24066
+ if ((maxLength || minLength) &&
24067
+ !isEmpty &&
24068
+ (isString(inputValue) || (isFieldArray && Array.isArray(inputValue)))) {
24069
+ const maxLengthOutput = getValueAndMessage(maxLength);
24070
+ const minLengthOutput = getValueAndMessage(minLength);
24071
+ const exceedMax = !isNullOrUndefined(maxLengthOutput.value) &&
24072
+ inputValue.length > +maxLengthOutput.value;
24073
+ const exceedMin = !isNullOrUndefined(minLengthOutput.value) &&
24074
+ inputValue.length < +minLengthOutput.value;
24075
+ if (exceedMax || exceedMin) {
24076
+ getMinMaxMessage(exceedMax, maxLengthOutput.message, minLengthOutput.message);
24077
+ if (!validateAllFieldCriteria) {
24078
+ setCustomValidity(error[name].message);
24079
+ return error;
24080
+ }
24081
+ }
24082
+ }
24083
+ if (pattern && !isEmpty && isString(inputValue)) {
24084
+ const { value: patternValue, message } = getValueAndMessage(pattern);
24085
+ if (isRegex(patternValue) && !inputValue.match(patternValue)) {
24086
+ error[name] = {
24087
+ type: INPUT_VALIDATION_RULES.pattern,
24088
+ message,
24089
+ ref,
24090
+ ...appendErrorsCurry(INPUT_VALIDATION_RULES.pattern, message),
24091
+ };
24092
+ if (!validateAllFieldCriteria) {
24093
+ setCustomValidity(message);
24094
+ return error;
24095
+ }
24096
+ }
24097
+ }
24098
+ if (validate) {
24099
+ if (isFunction(validate)) {
24100
+ const result = await validate(inputValue, formValues);
24101
+ const validateError = getValidateError(result, inputRef);
24102
+ if (validateError) {
24103
+ error[name] = {
24104
+ ...validateError,
24105
+ ...appendErrorsCurry(INPUT_VALIDATION_RULES.validate, validateError.message),
24106
+ };
24107
+ if (!validateAllFieldCriteria) {
24108
+ setCustomValidity(validateError.message);
24109
+ return error;
24110
+ }
24111
+ }
24112
+ }
24113
+ else if (isObject$1(validate)) {
24114
+ let validationResult = {};
24115
+ for (const key in validate) {
24116
+ if (!isEmptyObject(validationResult) && !validateAllFieldCriteria) {
24117
+ break;
24118
+ }
24119
+ const validateError = getValidateError(await validate[key](inputValue, formValues), inputRef, key);
24120
+ if (validateError) {
24121
+ validationResult = {
24122
+ ...validateError,
24123
+ ...appendErrorsCurry(key, validateError.message),
24124
+ };
24125
+ setCustomValidity(validateError.message);
24126
+ if (validateAllFieldCriteria) {
24127
+ error[name] = validationResult;
24128
+ }
24129
+ }
24130
+ }
24131
+ if (!isEmptyObject(validationResult)) {
24132
+ error[name] = {
24133
+ ref: inputRef,
24134
+ ...validationResult,
24135
+ };
24136
+ if (!validateAllFieldCriteria) {
24137
+ return error;
24138
+ }
24139
+ }
24140
+ }
24141
+ }
24142
+ setCustomValidity(true);
24143
+ return error;
24144
+ };
24145
+
24146
+ function baseGet(object, updatePath) {
24147
+ const length = updatePath.slice(0, -1).length;
24148
+ let index = 0;
24149
+ while (index < length) {
24150
+ object = isUndefined(object) ? index++ : object[updatePath[index++]];
24151
+ }
24152
+ return object;
24153
+ }
24154
+ function isEmptyArray(obj) {
24155
+ for (const key in obj) {
24156
+ if (obj.hasOwnProperty(key) && !isUndefined(obj[key])) {
24157
+ return false;
24158
+ }
24159
+ }
24160
+ return true;
24161
+ }
24162
+ function unset(object, path) {
24163
+ const paths = Array.isArray(path)
24164
+ ? path
24165
+ : isKey(path)
24166
+ ? [path]
24167
+ : stringToPath(path);
24168
+ const childObject = paths.length === 1 ? object : baseGet(object, paths);
24169
+ const index = paths.length - 1;
24170
+ const key = paths[index];
24171
+ if (childObject) {
24172
+ delete childObject[key];
24173
+ }
24174
+ if (index !== 0 &&
24175
+ ((isObject$1(childObject) && isEmptyObject(childObject)) ||
24176
+ (Array.isArray(childObject) && isEmptyArray(childObject)))) {
24177
+ unset(object, paths.slice(0, -1));
24178
+ }
24179
+ return object;
24180
+ }
24181
+
24182
+ var createSubject = () => {
24183
+ let _observers = [];
24184
+ const next = (value) => {
24185
+ for (const observer of _observers) {
24186
+ observer.next && observer.next(value);
24187
+ }
24188
+ };
24189
+ const subscribe = (observer) => {
24190
+ _observers.push(observer);
24191
+ return {
24192
+ unsubscribe: () => {
24193
+ _observers = _observers.filter((o) => o !== observer);
24194
+ },
24195
+ };
24196
+ };
24197
+ const unsubscribe = () => {
24198
+ _observers = [];
24199
+ };
24200
+ return {
24201
+ get observers() {
24202
+ return _observers;
24203
+ },
24204
+ next,
24205
+ subscribe,
24206
+ unsubscribe,
24207
+ };
24208
+ };
24209
+
24210
+ var isPrimitive = (value) => isNullOrUndefined(value) || !isObjectType(value);
24211
+
24212
+ function deepEqual(object1, object2) {
24213
+ if (isPrimitive(object1) || isPrimitive(object2)) {
24214
+ return object1 === object2;
24215
+ }
24216
+ if (isDateObject(object1) && isDateObject(object2)) {
24217
+ return object1.getTime() === object2.getTime();
24218
+ }
24219
+ const keys1 = Object.keys(object1);
24220
+ const keys2 = Object.keys(object2);
24221
+ if (keys1.length !== keys2.length) {
24222
+ return false;
24223
+ }
24224
+ for (const key of keys1) {
24225
+ const val1 = object1[key];
24226
+ if (!keys2.includes(key)) {
24227
+ return false;
24228
+ }
24229
+ if (key !== 'ref') {
24230
+ const val2 = object2[key];
24231
+ if ((isDateObject(val1) && isDateObject(val2)) ||
24232
+ (isObject$1(val1) && isObject$1(val2)) ||
24233
+ (Array.isArray(val1) && Array.isArray(val2))
24234
+ ? !deepEqual(val1, val2)
24235
+ : val1 !== val2) {
24236
+ return false;
24237
+ }
24238
+ }
24239
+ }
24240
+ return true;
24241
+ }
24242
+
24243
+ var isMultipleSelect = (element) => element.type === `select-multiple`;
24244
+
24245
+ var isRadioOrCheckbox = (ref) => isRadioInput(ref) || isCheckBoxInput(ref);
24246
+
24247
+ var live = (ref) => isHTMLElement(ref) && ref.isConnected;
24248
+
24249
+ var objectHasFunction = (data) => {
24250
+ for (const key in data) {
24251
+ if (isFunction(data[key])) {
24252
+ return true;
24253
+ }
24254
+ }
24255
+ return false;
24256
+ };
24257
+
24258
+ function markFieldsDirty(data, fields = {}) {
24259
+ const isParentNodeArray = Array.isArray(data);
24260
+ if (isObject$1(data) || isParentNodeArray) {
24261
+ for (const key in data) {
24262
+ if (Array.isArray(data[key]) ||
24263
+ (isObject$1(data[key]) && !objectHasFunction(data[key]))) {
24264
+ fields[key] = Array.isArray(data[key]) ? [] : {};
24265
+ markFieldsDirty(data[key], fields[key]);
24266
+ }
24267
+ else if (!isNullOrUndefined(data[key])) {
24268
+ fields[key] = true;
24269
+ }
24270
+ }
24271
+ }
24272
+ return fields;
24273
+ }
24274
+ function getDirtyFieldsFromDefaultValues(data, formValues, dirtyFieldsFromValues) {
24275
+ const isParentNodeArray = Array.isArray(data);
24276
+ if (isObject$1(data) || isParentNodeArray) {
24277
+ for (const key in data) {
24278
+ if (Array.isArray(data[key]) ||
24279
+ (isObject$1(data[key]) && !objectHasFunction(data[key]))) {
24280
+ if (isUndefined(formValues) ||
24281
+ isPrimitive(dirtyFieldsFromValues[key])) {
24282
+ dirtyFieldsFromValues[key] = Array.isArray(data[key])
24283
+ ? markFieldsDirty(data[key], [])
24284
+ : { ...markFieldsDirty(data[key]) };
24285
+ }
24286
+ else {
24287
+ getDirtyFieldsFromDefaultValues(data[key], isNullOrUndefined(formValues) ? {} : formValues[key], dirtyFieldsFromValues[key]);
24288
+ }
24289
+ }
24290
+ else {
24291
+ dirtyFieldsFromValues[key] = !deepEqual(data[key], formValues[key]);
24292
+ }
24293
+ }
24294
+ }
24295
+ return dirtyFieldsFromValues;
24296
+ }
24297
+ var getDirtyFields = (defaultValues, formValues) => getDirtyFieldsFromDefaultValues(defaultValues, formValues, markFieldsDirty(formValues));
24298
+
24299
+ var getFieldValueAs = (value, { valueAsNumber, valueAsDate, setValueAs }) => isUndefined(value)
24300
+ ? value
24301
+ : valueAsNumber
24302
+ ? value === ''
24303
+ ? NaN
24304
+ : value
24305
+ ? +value
24306
+ : value
24307
+ : valueAsDate && isString(value)
24308
+ ? new Date(value)
24309
+ : setValueAs
24310
+ ? setValueAs(value)
24311
+ : value;
24312
+
24313
+ function getFieldValue(_f) {
24314
+ const ref = _f.ref;
24315
+ if (_f.refs ? _f.refs.every((ref) => ref.disabled) : ref.disabled) {
24316
+ return;
24317
+ }
24318
+ if (isFileInput(ref)) {
24319
+ return ref.files;
24320
+ }
24321
+ if (isRadioInput(ref)) {
24322
+ return getRadioValue(_f.refs).value;
24323
+ }
24324
+ if (isMultipleSelect(ref)) {
24325
+ return [...ref.selectedOptions].map(({ value }) => value);
24326
+ }
24327
+ if (isCheckBoxInput(ref)) {
24328
+ return getCheckboxValue(_f.refs).value;
24329
+ }
24330
+ return getFieldValueAs(isUndefined(ref.value) ? _f.ref.value : ref.value, _f);
24331
+ }
24332
+
24333
+ var getResolverOptions = (fieldsNames, _fields, criteriaMode, shouldUseNativeValidation) => {
24334
+ const fields = {};
24335
+ for (const name of fieldsNames) {
24336
+ const field = get(_fields, name);
24337
+ field && set(fields, name, field._f);
24338
+ }
24339
+ return {
24340
+ criteriaMode,
24341
+ names: [...fieldsNames],
24342
+ fields,
24343
+ shouldUseNativeValidation,
24344
+ };
24345
+ };
24346
+
24347
+ var getRuleValue = (rule) => isUndefined(rule)
24348
+ ? rule
24349
+ : isRegex(rule)
24350
+ ? rule.source
24351
+ : isObject$1(rule)
24352
+ ? isRegex(rule.value)
24353
+ ? rule.value.source
24354
+ : rule.value
24355
+ : rule;
24356
+
24357
+ var hasValidation = (options) => options.mount &&
24358
+ (options.required ||
24359
+ options.min ||
24360
+ options.max ||
24361
+ options.maxLength ||
24362
+ options.minLength ||
24363
+ options.pattern ||
24364
+ options.validate);
24365
+
24366
+ function schemaErrorLookup(errors, _fields, name) {
24367
+ const error = get(errors, name);
24368
+ if (error || isKey(name)) {
24369
+ return {
24370
+ error,
24371
+ name,
24372
+ };
24373
+ }
24374
+ const names = name.split('.');
24375
+ while (names.length) {
24376
+ const fieldName = names.join('.');
24377
+ const field = get(_fields, fieldName);
24378
+ const foundError = get(errors, fieldName);
24379
+ if (field && !Array.isArray(field) && name !== fieldName) {
24380
+ return { name };
24381
+ }
24382
+ if (foundError && foundError.type) {
24383
+ return {
24384
+ name: fieldName,
24385
+ error: foundError,
24386
+ };
24387
+ }
24388
+ names.pop();
24389
+ }
24390
+ return {
24391
+ name,
24392
+ };
24393
+ }
24394
+
24395
+ var skipValidation = (isBlurEvent, isTouched, isSubmitted, reValidateMode, mode) => {
24396
+ if (mode.isOnAll) {
24397
+ return false;
24398
+ }
24399
+ else if (!isSubmitted && mode.isOnTouch) {
24400
+ return !(isTouched || isBlurEvent);
24401
+ }
24402
+ else if (isSubmitted ? reValidateMode.isOnBlur : mode.isOnBlur) {
24403
+ return !isBlurEvent;
24404
+ }
24405
+ else if (isSubmitted ? reValidateMode.isOnChange : mode.isOnChange) {
24406
+ return isBlurEvent;
24407
+ }
24408
+ return true;
24409
+ };
24410
+
24411
+ var unsetEmptyArray = (ref, name) => !compact(get(ref, name)).length && unset(ref, name);
24412
+
24413
+ const defaultOptions$2 = {
24414
+ mode: VALIDATION_MODE.onSubmit,
24415
+ reValidateMode: VALIDATION_MODE.onChange,
24416
+ shouldFocusError: true,
24417
+ };
24418
+ function createFormControl(props = {}) {
24419
+ let _options = {
24420
+ ...defaultOptions$2,
24421
+ ...props,
24422
+ };
24423
+ let _formState = {
24424
+ submitCount: 0,
24425
+ isDirty: false,
24426
+ isLoading: isFunction(_options.defaultValues),
24427
+ isValidating: false,
24428
+ isSubmitted: false,
24429
+ isSubmitting: false,
24430
+ isSubmitSuccessful: false,
24431
+ isValid: false,
24432
+ touchedFields: {},
24433
+ dirtyFields: {},
24434
+ validatingFields: {},
24435
+ errors: _options.errors || {},
24436
+ disabled: _options.disabled || false,
24437
+ };
24438
+ let _fields = {};
24439
+ let _defaultValues = isObject$1(_options.defaultValues) || isObject$1(_options.values)
24440
+ ? cloneObject(_options.defaultValues || _options.values) || {}
24441
+ : {};
24442
+ let _formValues = _options.shouldUnregister
24443
+ ? {}
24444
+ : cloneObject(_defaultValues);
24445
+ let _state = {
24446
+ action: false,
24447
+ mount: false,
24448
+ watch: false,
24449
+ };
24450
+ let _names = {
24451
+ mount: new Set(),
24452
+ unMount: new Set(),
24453
+ array: new Set(),
24454
+ watch: new Set(),
24455
+ };
24456
+ let delayErrorCallback;
24457
+ let timer = 0;
24458
+ const _proxyFormState = {
24459
+ isDirty: false,
24460
+ dirtyFields: false,
24461
+ validatingFields: false,
24462
+ touchedFields: false,
24463
+ isValidating: false,
24464
+ isValid: false,
24465
+ errors: false,
24466
+ };
24467
+ const _subjects = {
24468
+ values: createSubject(),
24469
+ array: createSubject(),
24470
+ state: createSubject(),
24471
+ };
24472
+ const validationModeBeforeSubmit = getValidationModes(_options.mode);
24473
+ const validationModeAfterSubmit = getValidationModes(_options.reValidateMode);
24474
+ const shouldDisplayAllAssociatedErrors = _options.criteriaMode === VALIDATION_MODE.all;
24475
+ const debounce = (callback) => (wait) => {
24476
+ clearTimeout(timer);
24477
+ timer = setTimeout(callback, wait);
24478
+ };
24479
+ const _updateValid = async (shouldUpdateValid) => {
24480
+ if (_proxyFormState.isValid || shouldUpdateValid) {
24481
+ const isValid = _options.resolver
24482
+ ? isEmptyObject((await _executeSchema()).errors)
24483
+ : await executeBuiltInValidation(_fields, true);
24484
+ if (isValid !== _formState.isValid) {
24485
+ _subjects.state.next({
24486
+ isValid,
24487
+ });
24488
+ }
24489
+ }
24490
+ };
24491
+ const _updateIsValidating = (names, isValidating) => {
24492
+ if (_proxyFormState.isValidating || _proxyFormState.validatingFields) {
24493
+ (names || Array.from(_names.mount)).forEach((name) => {
24494
+ if (name) {
24495
+ isValidating
24496
+ ? set(_formState.validatingFields, name, isValidating)
24497
+ : unset(_formState.validatingFields, name);
24498
+ }
24499
+ });
24500
+ _subjects.state.next({
24501
+ validatingFields: _formState.validatingFields,
24502
+ isValidating: !isEmptyObject(_formState.validatingFields),
24503
+ });
24504
+ }
24505
+ };
24506
+ const _updateFieldArray = (name, values = [], method, args, shouldSetValues = true, shouldUpdateFieldsAndState = true) => {
24507
+ if (args && method) {
24508
+ _state.action = true;
24509
+ if (shouldUpdateFieldsAndState && Array.isArray(get(_fields, name))) {
24510
+ const fieldValues = method(get(_fields, name), args.argA, args.argB);
24511
+ shouldSetValues && set(_fields, name, fieldValues);
24512
+ }
24513
+ if (shouldUpdateFieldsAndState &&
24514
+ Array.isArray(get(_formState.errors, name))) {
24515
+ const errors = method(get(_formState.errors, name), args.argA, args.argB);
24516
+ shouldSetValues && set(_formState.errors, name, errors);
24517
+ unsetEmptyArray(_formState.errors, name);
24518
+ }
24519
+ if (_proxyFormState.touchedFields &&
24520
+ shouldUpdateFieldsAndState &&
24521
+ Array.isArray(get(_formState.touchedFields, name))) {
24522
+ const touchedFields = method(get(_formState.touchedFields, name), args.argA, args.argB);
24523
+ shouldSetValues && set(_formState.touchedFields, name, touchedFields);
24524
+ }
24525
+ if (_proxyFormState.dirtyFields) {
24526
+ _formState.dirtyFields = getDirtyFields(_defaultValues, _formValues);
24527
+ }
24528
+ _subjects.state.next({
24529
+ name,
24530
+ isDirty: _getDirty(name, values),
24531
+ dirtyFields: _formState.dirtyFields,
24532
+ errors: _formState.errors,
24533
+ isValid: _formState.isValid,
24534
+ });
24535
+ }
24536
+ else {
24537
+ set(_formValues, name, values);
24538
+ }
24539
+ };
24540
+ const updateErrors = (name, error) => {
24541
+ set(_formState.errors, name, error);
24542
+ _subjects.state.next({
24543
+ errors: _formState.errors,
24544
+ });
24545
+ };
24546
+ const _setErrors = (errors) => {
24547
+ _formState.errors = errors;
24548
+ _subjects.state.next({
24549
+ errors: _formState.errors,
24550
+ isValid: false,
24551
+ });
24552
+ };
24553
+ const updateValidAndValue = (name, shouldSkipSetValueAs, value, ref) => {
24554
+ const field = get(_fields, name);
24555
+ if (field) {
24556
+ const defaultValue = get(_formValues, name, isUndefined(value) ? get(_defaultValues, name) : value);
24557
+ isUndefined(defaultValue) ||
24558
+ (ref && ref.defaultChecked) ||
24559
+ shouldSkipSetValueAs
24560
+ ? set(_formValues, name, shouldSkipSetValueAs ? defaultValue : getFieldValue(field._f))
24561
+ : setFieldValue(name, defaultValue);
24562
+ _state.mount && _updateValid();
24563
+ }
24564
+ };
24565
+ const updateTouchAndDirty = (name, fieldValue, isBlurEvent, shouldDirty, shouldRender) => {
24566
+ let shouldUpdateField = false;
24567
+ let isPreviousDirty = false;
24568
+ const output = {
24569
+ name,
24570
+ };
24571
+ const disabledField = !!(get(_fields, name) && get(_fields, name)._f.disabled);
24572
+ if (!isBlurEvent || shouldDirty) {
24573
+ if (_proxyFormState.isDirty) {
24574
+ isPreviousDirty = _formState.isDirty;
24575
+ _formState.isDirty = output.isDirty = _getDirty();
24576
+ shouldUpdateField = isPreviousDirty !== output.isDirty;
24577
+ }
24578
+ const isCurrentFieldPristine = disabledField || deepEqual(get(_defaultValues, name), fieldValue);
24579
+ isPreviousDirty = !!(!disabledField && get(_formState.dirtyFields, name));
24580
+ isCurrentFieldPristine || disabledField
24581
+ ? unset(_formState.dirtyFields, name)
24582
+ : set(_formState.dirtyFields, name, true);
24583
+ output.dirtyFields = _formState.dirtyFields;
24584
+ shouldUpdateField =
24585
+ shouldUpdateField ||
24586
+ (_proxyFormState.dirtyFields &&
24587
+ isPreviousDirty !== !isCurrentFieldPristine);
24588
+ }
24589
+ if (isBlurEvent) {
24590
+ const isPreviousFieldTouched = get(_formState.touchedFields, name);
24591
+ if (!isPreviousFieldTouched) {
24592
+ set(_formState.touchedFields, name, isBlurEvent);
24593
+ output.touchedFields = _formState.touchedFields;
24594
+ shouldUpdateField =
24595
+ shouldUpdateField ||
24596
+ (_proxyFormState.touchedFields &&
24597
+ isPreviousFieldTouched !== isBlurEvent);
24598
+ }
24599
+ }
24600
+ shouldUpdateField && shouldRender && _subjects.state.next(output);
24601
+ return shouldUpdateField ? output : {};
24602
+ };
24603
+ const shouldRenderByError = (name, isValid, error, fieldState) => {
24604
+ const previousFieldError = get(_formState.errors, name);
24605
+ const shouldUpdateValid = _proxyFormState.isValid &&
24606
+ isBoolean(isValid) &&
24607
+ _formState.isValid !== isValid;
24608
+ if (props.delayError && error) {
24609
+ delayErrorCallback = debounce(() => updateErrors(name, error));
24610
+ delayErrorCallback(props.delayError);
24611
+ }
24612
+ else {
24613
+ clearTimeout(timer);
24614
+ delayErrorCallback = null;
24615
+ error
24616
+ ? set(_formState.errors, name, error)
24617
+ : unset(_formState.errors, name);
24618
+ }
24619
+ if ((error ? !deepEqual(previousFieldError, error) : previousFieldError) ||
24620
+ !isEmptyObject(fieldState) ||
24621
+ shouldUpdateValid) {
24622
+ const updatedFormState = {
24623
+ ...fieldState,
24624
+ ...(shouldUpdateValid && isBoolean(isValid) ? { isValid } : {}),
24625
+ errors: _formState.errors,
24626
+ name,
24627
+ };
24628
+ _formState = {
24629
+ ..._formState,
24630
+ ...updatedFormState,
24631
+ };
24632
+ _subjects.state.next(updatedFormState);
24633
+ }
24634
+ };
24635
+ const _executeSchema = async (name) => {
24636
+ _updateIsValidating(name, true);
24637
+ const result = await _options.resolver(_formValues, _options.context, getResolverOptions(name || _names.mount, _fields, _options.criteriaMode, _options.shouldUseNativeValidation));
24638
+ _updateIsValidating(name);
24639
+ return result;
24640
+ };
24641
+ const executeSchemaAndUpdateState = async (names) => {
24642
+ const { errors } = await _executeSchema(names);
24643
+ if (names) {
24644
+ for (const name of names) {
24645
+ const error = get(errors, name);
24646
+ error
24647
+ ? set(_formState.errors, name, error)
24648
+ : unset(_formState.errors, name);
24649
+ }
24650
+ }
24651
+ else {
24652
+ _formState.errors = errors;
24653
+ }
24654
+ return errors;
24655
+ };
24656
+ const executeBuiltInValidation = async (fields, shouldOnlyCheckValid, context = {
24657
+ valid: true,
24658
+ }) => {
24659
+ for (const name in fields) {
24660
+ const field = fields[name];
24661
+ if (field) {
24662
+ const { _f, ...fieldValue } = field;
24663
+ if (_f) {
24664
+ const isFieldArrayRoot = _names.array.has(_f.name);
24665
+ _updateIsValidating([name], true);
24666
+ const fieldError = await validateField(field, _formValues, shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation && !shouldOnlyCheckValid, isFieldArrayRoot);
24667
+ _updateIsValidating([name]);
24668
+ if (fieldError[_f.name]) {
24669
+ context.valid = false;
24670
+ if (shouldOnlyCheckValid) {
24671
+ break;
24672
+ }
24673
+ }
24674
+ !shouldOnlyCheckValid &&
24675
+ (get(fieldError, _f.name)
24676
+ ? isFieldArrayRoot
24677
+ ? updateFieldArrayRootError(_formState.errors, fieldError, _f.name)
24678
+ : set(_formState.errors, _f.name, fieldError[_f.name])
24679
+ : unset(_formState.errors, _f.name));
24680
+ }
24681
+ fieldValue &&
24682
+ (await executeBuiltInValidation(fieldValue, shouldOnlyCheckValid, context));
24683
+ }
24684
+ }
24685
+ return context.valid;
24686
+ };
24687
+ const _removeUnmounted = () => {
24688
+ for (const name of _names.unMount) {
24689
+ const field = get(_fields, name);
24690
+ field &&
24691
+ (field._f.refs
24692
+ ? field._f.refs.every((ref) => !live(ref))
24693
+ : !live(field._f.ref)) &&
24694
+ unregister(name);
24695
+ }
24696
+ _names.unMount = new Set();
24697
+ };
24698
+ const _getDirty = (name, data) => (name && data && set(_formValues, name, data),
24699
+ !deepEqual(getValues(), _defaultValues));
24700
+ const _getWatch = (names, defaultValue, isGlobal) => generateWatchOutput(names, _names, {
24701
+ ...(_state.mount
24702
+ ? _formValues
24703
+ : isUndefined(defaultValue)
24704
+ ? _defaultValues
24705
+ : isString(names)
24706
+ ? { [names]: defaultValue }
24707
+ : defaultValue),
24708
+ }, isGlobal, defaultValue);
24709
+ const _getFieldArray = (name) => compact(get(_state.mount ? _formValues : _defaultValues, name, props.shouldUnregister ? get(_defaultValues, name, []) : []));
24710
+ const setFieldValue = (name, value, options = {}) => {
24711
+ const field = get(_fields, name);
24712
+ let fieldValue = value;
24713
+ if (field) {
24714
+ const fieldReference = field._f;
24715
+ if (fieldReference) {
24716
+ !fieldReference.disabled &&
24717
+ set(_formValues, name, getFieldValueAs(value, fieldReference));
24718
+ fieldValue =
24719
+ isHTMLElement(fieldReference.ref) && isNullOrUndefined(value)
24720
+ ? ''
24721
+ : value;
24722
+ if (isMultipleSelect(fieldReference.ref)) {
24723
+ [...fieldReference.ref.options].forEach((optionRef) => (optionRef.selected = fieldValue.includes(optionRef.value)));
24724
+ }
24725
+ else if (fieldReference.refs) {
24726
+ if (isCheckBoxInput(fieldReference.ref)) {
24727
+ fieldReference.refs.length > 1
24728
+ ? fieldReference.refs.forEach((checkboxRef) => (!checkboxRef.defaultChecked || !checkboxRef.disabled) &&
24729
+ (checkboxRef.checked = Array.isArray(fieldValue)
24730
+ ? !!fieldValue.find((data) => data === checkboxRef.value)
24731
+ : fieldValue === checkboxRef.value))
24732
+ : fieldReference.refs[0] &&
24733
+ (fieldReference.refs[0].checked = !!fieldValue);
24734
+ }
24735
+ else {
24736
+ fieldReference.refs.forEach((radioRef) => (radioRef.checked = radioRef.value === fieldValue));
24737
+ }
24738
+ }
24739
+ else if (isFileInput(fieldReference.ref)) {
24740
+ fieldReference.ref.value = '';
24741
+ }
24742
+ else {
24743
+ fieldReference.ref.value = fieldValue;
24744
+ if (!fieldReference.ref.type) {
24745
+ _subjects.values.next({
24746
+ name,
24747
+ values: { ..._formValues },
24748
+ });
24749
+ }
24750
+ }
24751
+ }
24752
+ }
24753
+ (options.shouldDirty || options.shouldTouch) &&
24754
+ updateTouchAndDirty(name, fieldValue, options.shouldTouch, options.shouldDirty, true);
24755
+ options.shouldValidate && trigger(name);
24756
+ };
24757
+ const setValues = (name, value, options) => {
24758
+ for (const fieldKey in value) {
24759
+ const fieldValue = value[fieldKey];
24760
+ const fieldName = `${name}.${fieldKey}`;
24761
+ const field = get(_fields, fieldName);
24762
+ (_names.array.has(name) ||
24763
+ !isPrimitive(fieldValue) ||
24764
+ (field && !field._f)) &&
24765
+ !isDateObject(fieldValue)
24766
+ ? setValues(fieldName, fieldValue, options)
24767
+ : setFieldValue(fieldName, fieldValue, options);
24768
+ }
24769
+ };
24770
+ const setValue = (name, value, options = {}) => {
24771
+ const field = get(_fields, name);
24772
+ const isFieldArray = _names.array.has(name);
24773
+ const cloneValue = cloneObject(value);
24774
+ set(_formValues, name, cloneValue);
24775
+ if (isFieldArray) {
24776
+ _subjects.array.next({
24777
+ name,
24778
+ values: { ..._formValues },
24779
+ });
24780
+ if ((_proxyFormState.isDirty || _proxyFormState.dirtyFields) &&
24781
+ options.shouldDirty) {
24782
+ _subjects.state.next({
24783
+ name,
24784
+ dirtyFields: getDirtyFields(_defaultValues, _formValues),
24785
+ isDirty: _getDirty(name, cloneValue),
24786
+ });
24787
+ }
24788
+ }
24789
+ else {
24790
+ field && !field._f && !isNullOrUndefined(cloneValue)
24791
+ ? setValues(name, cloneValue, options)
24792
+ : setFieldValue(name, cloneValue, options);
24793
+ }
24794
+ isWatched(name, _names) && _subjects.state.next({ ..._formState });
24795
+ _subjects.values.next({
24796
+ name: _state.mount ? name : undefined,
24797
+ values: { ..._formValues },
24798
+ });
24799
+ };
24800
+ const onChange = async (event) => {
24801
+ _state.mount = true;
24802
+ const target = event.target;
24803
+ let name = target.name;
24804
+ let isFieldValueUpdated = true;
24805
+ const field = get(_fields, name);
24806
+ const getCurrentFieldValue = () => target.type ? getFieldValue(field._f) : getEventValue(event);
24807
+ const _updateIsFieldValueUpdated = (fieldValue) => {
24808
+ isFieldValueUpdated =
24809
+ Number.isNaN(fieldValue) ||
24810
+ fieldValue === get(_formValues, name, fieldValue);
24811
+ };
24812
+ if (field) {
24813
+ let error;
24814
+ let isValid;
24815
+ const fieldValue = getCurrentFieldValue();
24816
+ const isBlurEvent = event.type === EVENTS.BLUR || event.type === EVENTS.FOCUS_OUT;
24817
+ const shouldSkipValidation = (!hasValidation(field._f) &&
24818
+ !_options.resolver &&
24819
+ !get(_formState.errors, name) &&
24820
+ !field._f.deps) ||
24821
+ skipValidation(isBlurEvent, get(_formState.touchedFields, name), _formState.isSubmitted, validationModeAfterSubmit, validationModeBeforeSubmit);
24822
+ const watched = isWatched(name, _names, isBlurEvent);
24823
+ set(_formValues, name, fieldValue);
24824
+ if (isBlurEvent) {
24825
+ field._f.onBlur && field._f.onBlur(event);
24826
+ delayErrorCallback && delayErrorCallback(0);
24827
+ }
24828
+ else if (field._f.onChange) {
24829
+ field._f.onChange(event);
24830
+ }
24831
+ const fieldState = updateTouchAndDirty(name, fieldValue, isBlurEvent, false);
24832
+ const shouldRender = !isEmptyObject(fieldState) || watched;
24833
+ !isBlurEvent &&
24834
+ _subjects.values.next({
24835
+ name,
24836
+ type: event.type,
24837
+ values: { ..._formValues },
24838
+ });
24839
+ if (shouldSkipValidation) {
24840
+ _proxyFormState.isValid && _updateValid();
24841
+ return (shouldRender &&
24842
+ _subjects.state.next({ name, ...(watched ? {} : fieldState) }));
24843
+ }
24844
+ !isBlurEvent && watched && _subjects.state.next({ ..._formState });
24845
+ if (_options.resolver) {
24846
+ const { errors } = await _executeSchema([name]);
24847
+ _updateIsFieldValueUpdated(fieldValue);
24848
+ if (isFieldValueUpdated) {
24849
+ const previousErrorLookupResult = schemaErrorLookup(_formState.errors, _fields, name);
24850
+ const errorLookupResult = schemaErrorLookup(errors, _fields, previousErrorLookupResult.name || name);
24851
+ error = errorLookupResult.error;
24852
+ name = errorLookupResult.name;
24853
+ isValid = isEmptyObject(errors);
24854
+ }
24855
+ }
24856
+ else {
24857
+ _updateIsValidating([name], true);
24858
+ error = (await validateField(field, _formValues, shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation))[name];
24859
+ _updateIsValidating([name]);
24860
+ _updateIsFieldValueUpdated(fieldValue);
24861
+ if (isFieldValueUpdated) {
24862
+ if (error) {
24863
+ isValid = false;
24864
+ }
24865
+ else if (_proxyFormState.isValid) {
24866
+ isValid = await executeBuiltInValidation(_fields, true);
24867
+ }
24868
+ }
24869
+ }
24870
+ if (isFieldValueUpdated) {
24871
+ field._f.deps &&
24872
+ trigger(field._f.deps);
24873
+ shouldRenderByError(name, isValid, error, fieldState);
24874
+ }
24875
+ }
24876
+ };
24877
+ const _focusInput = (ref, key) => {
24878
+ if (get(_formState.errors, key) && ref.focus) {
24879
+ ref.focus();
24880
+ return 1;
24881
+ }
24882
+ return;
24883
+ };
24884
+ const trigger = async (name, options = {}) => {
24885
+ let isValid;
24886
+ let validationResult;
24887
+ const fieldNames = convertToArrayPayload(name);
24888
+ if (_options.resolver) {
24889
+ const errors = await executeSchemaAndUpdateState(isUndefined(name) ? name : fieldNames);
24890
+ isValid = isEmptyObject(errors);
24891
+ validationResult = name
24892
+ ? !fieldNames.some((name) => get(errors, name))
24893
+ : isValid;
24894
+ }
24895
+ else if (name) {
24896
+ validationResult = (await Promise.all(fieldNames.map(async (fieldName) => {
24897
+ const field = get(_fields, fieldName);
24898
+ return await executeBuiltInValidation(field && field._f ? { [fieldName]: field } : field);
24899
+ }))).every(Boolean);
24900
+ !(!validationResult && !_formState.isValid) && _updateValid();
24901
+ }
24902
+ else {
24903
+ validationResult = isValid = await executeBuiltInValidation(_fields);
24904
+ }
24905
+ _subjects.state.next({
24906
+ ...(!isString(name) ||
24907
+ (_proxyFormState.isValid && isValid !== _formState.isValid)
24908
+ ? {}
24909
+ : { name }),
24910
+ ...(_options.resolver || !name ? { isValid } : {}),
24911
+ errors: _formState.errors,
24912
+ });
24913
+ options.shouldFocus &&
24914
+ !validationResult &&
24915
+ iterateFieldsByAction(_fields, _focusInput, name ? fieldNames : _names.mount);
24916
+ return validationResult;
24917
+ };
24918
+ const getValues = (fieldNames) => {
24919
+ const values = {
24920
+ ...(_state.mount ? _formValues : _defaultValues),
24921
+ };
24922
+ return isUndefined(fieldNames)
24923
+ ? values
24924
+ : isString(fieldNames)
24925
+ ? get(values, fieldNames)
24926
+ : fieldNames.map((name) => get(values, name));
24927
+ };
24928
+ const getFieldState = (name, formState) => ({
24929
+ invalid: !!get((formState || _formState).errors, name),
24930
+ isDirty: !!get((formState || _formState).dirtyFields, name),
24931
+ isTouched: !!get((formState || _formState).touchedFields, name),
24932
+ isValidating: !!get((formState || _formState).validatingFields, name),
24933
+ error: get((formState || _formState).errors, name),
24934
+ });
24935
+ const clearErrors = (name) => {
24936
+ name &&
24937
+ convertToArrayPayload(name).forEach((inputName) => unset(_formState.errors, inputName));
24938
+ _subjects.state.next({
24939
+ errors: name ? _formState.errors : {},
24940
+ });
24941
+ };
24942
+ const setError = (name, error, options) => {
24943
+ const ref = (get(_fields, name, { _f: {} })._f || {}).ref;
24944
+ const currentError = get(_formState.errors, name) || {};
24945
+ // Don't override existing error messages elsewhere in the object tree.
24946
+ const { ref: currentRef, message, type, ...restOfErrorTree } = currentError;
24947
+ set(_formState.errors, name, {
24948
+ ...restOfErrorTree,
24949
+ ...error,
24950
+ ref,
24951
+ });
24952
+ _subjects.state.next({
24953
+ name,
24954
+ errors: _formState.errors,
24955
+ isValid: false,
24956
+ });
24957
+ options && options.shouldFocus && ref && ref.focus && ref.focus();
24958
+ };
24959
+ const watch = (name, defaultValue) => isFunction(name)
24960
+ ? _subjects.values.subscribe({
24961
+ next: (payload) => name(_getWatch(undefined, defaultValue), payload),
24962
+ })
24963
+ : _getWatch(name, defaultValue, true);
24964
+ const unregister = (name, options = {}) => {
24965
+ for (const fieldName of name ? convertToArrayPayload(name) : _names.mount) {
24966
+ _names.mount.delete(fieldName);
24967
+ _names.array.delete(fieldName);
24968
+ if (!options.keepValue) {
24969
+ unset(_fields, fieldName);
24970
+ unset(_formValues, fieldName);
24971
+ }
24972
+ !options.keepError && unset(_formState.errors, fieldName);
24973
+ !options.keepDirty && unset(_formState.dirtyFields, fieldName);
24974
+ !options.keepTouched && unset(_formState.touchedFields, fieldName);
24975
+ !options.keepIsValidating &&
24976
+ unset(_formState.validatingFields, fieldName);
24977
+ !_options.shouldUnregister &&
24978
+ !options.keepDefaultValue &&
24979
+ unset(_defaultValues, fieldName);
24980
+ }
24981
+ _subjects.values.next({
24982
+ values: { ..._formValues },
24983
+ });
24984
+ _subjects.state.next({
24985
+ ..._formState,
24986
+ ...(!options.keepDirty ? {} : { isDirty: _getDirty() }),
24987
+ });
24988
+ !options.keepIsValid && _updateValid();
24989
+ };
24990
+ const _updateDisabledField = ({ disabled, name, field, fields, value, }) => {
24991
+ if ((isBoolean(disabled) && _state.mount) || !!disabled) {
24992
+ const inputValue = disabled
24993
+ ? undefined
24994
+ : isUndefined(value)
24995
+ ? getFieldValue(field ? field._f : get(fields, name)._f)
24996
+ : value;
24997
+ set(_formValues, name, inputValue);
24998
+ updateTouchAndDirty(name, inputValue, false, false, true);
24999
+ }
25000
+ };
25001
+ const register = (name, options = {}) => {
25002
+ let field = get(_fields, name);
25003
+ const disabledIsDefined = isBoolean(options.disabled);
25004
+ set(_fields, name, {
25005
+ ...(field || {}),
25006
+ _f: {
25007
+ ...(field && field._f ? field._f : { ref: { name } }),
25008
+ name,
25009
+ mount: true,
25010
+ ...options,
25011
+ },
25012
+ });
25013
+ _names.mount.add(name);
25014
+ if (field) {
25015
+ _updateDisabledField({
25016
+ field,
25017
+ disabled: options.disabled,
25018
+ name,
25019
+ value: options.value,
25020
+ });
25021
+ }
25022
+ else {
25023
+ updateValidAndValue(name, true, options.value);
25024
+ }
25025
+ return {
25026
+ ...(disabledIsDefined ? { disabled: options.disabled } : {}),
25027
+ ...(_options.progressive
25028
+ ? {
25029
+ required: !!options.required,
25030
+ min: getRuleValue(options.min),
25031
+ max: getRuleValue(options.max),
25032
+ minLength: getRuleValue(options.minLength),
25033
+ maxLength: getRuleValue(options.maxLength),
25034
+ pattern: getRuleValue(options.pattern),
25035
+ }
25036
+ : {}),
25037
+ name,
25038
+ onChange,
25039
+ onBlur: onChange,
25040
+ ref: (ref) => {
25041
+ if (ref) {
25042
+ register(name, options);
25043
+ field = get(_fields, name);
25044
+ const fieldRef = isUndefined(ref.value)
25045
+ ? ref.querySelectorAll
25046
+ ? ref.querySelectorAll('input,select,textarea')[0] || ref
25047
+ : ref
25048
+ : ref;
25049
+ const radioOrCheckbox = isRadioOrCheckbox(fieldRef);
25050
+ const refs = field._f.refs || [];
25051
+ if (radioOrCheckbox
25052
+ ? refs.find((option) => option === fieldRef)
25053
+ : fieldRef === field._f.ref) {
25054
+ return;
25055
+ }
25056
+ set(_fields, name, {
25057
+ _f: {
25058
+ ...field._f,
25059
+ ...(radioOrCheckbox
25060
+ ? {
25061
+ refs: [
25062
+ ...refs.filter(live),
25063
+ fieldRef,
25064
+ ...(Array.isArray(get(_defaultValues, name)) ? [{}] : []),
25065
+ ],
25066
+ ref: { type: fieldRef.type, name },
25067
+ }
25068
+ : { ref: fieldRef }),
25069
+ },
25070
+ });
25071
+ updateValidAndValue(name, false, undefined, fieldRef);
25072
+ }
25073
+ else {
25074
+ field = get(_fields, name, {});
25075
+ if (field._f) {
25076
+ field._f.mount = false;
25077
+ }
25078
+ (_options.shouldUnregister || options.shouldUnregister) &&
25079
+ !(isNameInFieldArray(_names.array, name) && _state.action) &&
25080
+ _names.unMount.add(name);
25081
+ }
25082
+ },
25083
+ };
25084
+ };
25085
+ const _focusError = () => _options.shouldFocusError &&
25086
+ iterateFieldsByAction(_fields, _focusInput, _names.mount);
25087
+ const _disableForm = (disabled) => {
25088
+ if (isBoolean(disabled)) {
25089
+ _subjects.state.next({ disabled });
25090
+ iterateFieldsByAction(_fields, (ref, name) => {
25091
+ const currentField = get(_fields, name);
25092
+ if (currentField) {
25093
+ ref.disabled = currentField._f.disabled || disabled;
25094
+ if (Array.isArray(currentField._f.refs)) {
25095
+ currentField._f.refs.forEach((inputRef) => {
25096
+ inputRef.disabled = currentField._f.disabled || disabled;
25097
+ });
25098
+ }
25099
+ }
25100
+ }, 0, false);
25101
+ }
25102
+ };
25103
+ const handleSubmit = (onValid, onInvalid) => async (e) => {
25104
+ let onValidError = undefined;
25105
+ if (e) {
25106
+ e.preventDefault && e.preventDefault();
25107
+ e.persist && e.persist();
25108
+ }
25109
+ let fieldValues = cloneObject(_formValues);
25110
+ _subjects.state.next({
25111
+ isSubmitting: true,
25112
+ });
25113
+ if (_options.resolver) {
25114
+ const { errors, values } = await _executeSchema();
25115
+ _formState.errors = errors;
25116
+ fieldValues = values;
25117
+ }
25118
+ else {
25119
+ await executeBuiltInValidation(_fields);
25120
+ }
25121
+ unset(_formState.errors, 'root');
25122
+ if (isEmptyObject(_formState.errors)) {
25123
+ _subjects.state.next({
25124
+ errors: {},
25125
+ });
25126
+ try {
25127
+ await onValid(fieldValues, e);
25128
+ }
25129
+ catch (error) {
25130
+ onValidError = error;
25131
+ }
25132
+ }
25133
+ else {
25134
+ if (onInvalid) {
25135
+ await onInvalid({ ..._formState.errors }, e);
25136
+ }
25137
+ _focusError();
25138
+ setTimeout(_focusError);
25139
+ }
25140
+ _subjects.state.next({
25141
+ isSubmitted: true,
25142
+ isSubmitting: false,
25143
+ isSubmitSuccessful: isEmptyObject(_formState.errors) && !onValidError,
25144
+ submitCount: _formState.submitCount + 1,
25145
+ errors: _formState.errors,
25146
+ });
25147
+ if (onValidError) {
25148
+ throw onValidError;
25149
+ }
25150
+ };
25151
+ const resetField = (name, options = {}) => {
25152
+ if (get(_fields, name)) {
25153
+ if (isUndefined(options.defaultValue)) {
25154
+ setValue(name, cloneObject(get(_defaultValues, name)));
25155
+ }
25156
+ else {
25157
+ setValue(name, options.defaultValue);
25158
+ set(_defaultValues, name, cloneObject(options.defaultValue));
25159
+ }
25160
+ if (!options.keepTouched) {
25161
+ unset(_formState.touchedFields, name);
25162
+ }
25163
+ if (!options.keepDirty) {
25164
+ unset(_formState.dirtyFields, name);
25165
+ _formState.isDirty = options.defaultValue
25166
+ ? _getDirty(name, cloneObject(get(_defaultValues, name)))
25167
+ : _getDirty();
25168
+ }
25169
+ if (!options.keepError) {
25170
+ unset(_formState.errors, name);
25171
+ _proxyFormState.isValid && _updateValid();
25172
+ }
25173
+ _subjects.state.next({ ..._formState });
25174
+ }
25175
+ };
25176
+ const _reset = (formValues, keepStateOptions = {}) => {
25177
+ const updatedValues = formValues ? cloneObject(formValues) : _defaultValues;
25178
+ const cloneUpdatedValues = cloneObject(updatedValues);
25179
+ const isEmptyResetValues = isEmptyObject(formValues);
25180
+ const values = isEmptyResetValues ? _defaultValues : cloneUpdatedValues;
25181
+ if (!keepStateOptions.keepDefaultValues) {
25182
+ _defaultValues = updatedValues;
25183
+ }
25184
+ if (!keepStateOptions.keepValues) {
25185
+ if (keepStateOptions.keepDirtyValues) {
25186
+ for (const fieldName of _names.mount) {
25187
+ get(_formState.dirtyFields, fieldName)
25188
+ ? set(values, fieldName, get(_formValues, fieldName))
25189
+ : setValue(fieldName, get(values, fieldName));
25190
+ }
25191
+ }
25192
+ else {
25193
+ if (isWeb && isUndefined(formValues)) {
25194
+ for (const name of _names.mount) {
25195
+ const field = get(_fields, name);
25196
+ if (field && field._f) {
25197
+ const fieldReference = Array.isArray(field._f.refs)
25198
+ ? field._f.refs[0]
25199
+ : field._f.ref;
25200
+ if (isHTMLElement(fieldReference)) {
25201
+ const form = fieldReference.closest('form');
25202
+ if (form) {
25203
+ form.reset();
25204
+ break;
25205
+ }
25206
+ }
25207
+ }
25208
+ }
25209
+ }
25210
+ _fields = {};
25211
+ }
25212
+ _formValues = props.shouldUnregister
25213
+ ? keepStateOptions.keepDefaultValues
25214
+ ? cloneObject(_defaultValues)
25215
+ : {}
25216
+ : cloneObject(values);
25217
+ _subjects.array.next({
25218
+ values: { ...values },
25219
+ });
25220
+ _subjects.values.next({
25221
+ values: { ...values },
25222
+ });
25223
+ }
25224
+ _names = {
25225
+ mount: keepStateOptions.keepDirtyValues ? _names.mount : new Set(),
25226
+ unMount: new Set(),
25227
+ array: new Set(),
25228
+ watch: new Set(),
25229
+ watchAll: false,
25230
+ focus: '',
25231
+ };
25232
+ _state.mount =
25233
+ !_proxyFormState.isValid ||
25234
+ !!keepStateOptions.keepIsValid ||
25235
+ !!keepStateOptions.keepDirtyValues;
25236
+ _state.watch = !!props.shouldUnregister;
25237
+ _subjects.state.next({
25238
+ submitCount: keepStateOptions.keepSubmitCount
25239
+ ? _formState.submitCount
25240
+ : 0,
25241
+ isDirty: isEmptyResetValues
25242
+ ? false
25243
+ : keepStateOptions.keepDirty
25244
+ ? _formState.isDirty
25245
+ : !!(keepStateOptions.keepDefaultValues &&
25246
+ !deepEqual(formValues, _defaultValues)),
25247
+ isSubmitted: keepStateOptions.keepIsSubmitted
25248
+ ? _formState.isSubmitted
25249
+ : false,
25250
+ dirtyFields: isEmptyResetValues
25251
+ ? []
25252
+ : keepStateOptions.keepDirtyValues
25253
+ ? keepStateOptions.keepDefaultValues && _formValues
25254
+ ? getDirtyFields(_defaultValues, _formValues)
25255
+ : _formState.dirtyFields
25256
+ : keepStateOptions.keepDefaultValues && formValues
25257
+ ? getDirtyFields(_defaultValues, formValues)
25258
+ : {},
25259
+ touchedFields: keepStateOptions.keepTouched
25260
+ ? _formState.touchedFields
25261
+ : {},
25262
+ errors: keepStateOptions.keepErrors ? _formState.errors : {},
25263
+ isSubmitSuccessful: keepStateOptions.keepIsSubmitSuccessful
25264
+ ? _formState.isSubmitSuccessful
25265
+ : false,
25266
+ isSubmitting: false,
25267
+ });
25268
+ };
25269
+ const reset = (formValues, keepStateOptions) => _reset(isFunction(formValues)
25270
+ ? formValues(_formValues)
25271
+ : formValues, keepStateOptions);
25272
+ const setFocus = (name, options = {}) => {
25273
+ const field = get(_fields, name);
25274
+ const fieldReference = field && field._f;
25275
+ if (fieldReference) {
25276
+ const fieldRef = fieldReference.refs
25277
+ ? fieldReference.refs[0]
25278
+ : fieldReference.ref;
25279
+ if (fieldRef.focus) {
25280
+ fieldRef.focus();
25281
+ options.shouldSelect && fieldRef.select();
25282
+ }
25283
+ }
25284
+ };
25285
+ const _updateFormState = (updatedFormState) => {
25286
+ _formState = {
25287
+ ..._formState,
25288
+ ...updatedFormState,
25289
+ };
25290
+ };
25291
+ const _resetDefaultValues = () => isFunction(_options.defaultValues) &&
25292
+ _options.defaultValues().then((values) => {
25293
+ reset(values, _options.resetOptions);
25294
+ _subjects.state.next({
25295
+ isLoading: false,
25296
+ });
25297
+ });
25298
+ return {
25299
+ control: {
25300
+ register,
25301
+ unregister,
25302
+ getFieldState,
25303
+ handleSubmit,
25304
+ setError,
25305
+ _executeSchema,
25306
+ _getWatch,
25307
+ _getDirty,
25308
+ _updateValid,
25309
+ _removeUnmounted,
25310
+ _updateFieldArray,
25311
+ _updateDisabledField,
25312
+ _getFieldArray,
25313
+ _reset,
25314
+ _resetDefaultValues,
25315
+ _updateFormState,
25316
+ _disableForm,
25317
+ _subjects,
25318
+ _proxyFormState,
25319
+ _setErrors,
25320
+ get _fields() {
25321
+ return _fields;
25322
+ },
25323
+ get _formValues() {
25324
+ return _formValues;
25325
+ },
25326
+ get _state() {
25327
+ return _state;
25328
+ },
25329
+ set _state(value) {
25330
+ _state = value;
25331
+ },
25332
+ get _defaultValues() {
25333
+ return _defaultValues;
25334
+ },
25335
+ get _names() {
25336
+ return _names;
25337
+ },
25338
+ set _names(value) {
25339
+ _names = value;
25340
+ },
25341
+ get _formState() {
25342
+ return _formState;
25343
+ },
25344
+ set _formState(value) {
25345
+ _formState = value;
25346
+ },
25347
+ get _options() {
25348
+ return _options;
25349
+ },
25350
+ set _options(value) {
25351
+ _options = {
25352
+ ..._options,
25353
+ ...value,
25354
+ };
25355
+ },
25356
+ },
25357
+ trigger,
25358
+ register,
25359
+ handleSubmit,
25360
+ watch,
25361
+ setValue,
25362
+ getValues,
25363
+ reset,
25364
+ resetField,
25365
+ clearErrors,
25366
+ unregister,
25367
+ setError,
25368
+ setFocus,
25369
+ getFieldState,
25370
+ };
25371
+ }
25372
+
25373
+ /**
25374
+ * Custom hook to manage the entire form.
25375
+ *
25376
+ * @remarks
25377
+ * [API](https://react-hook-form.com/docs/useform) • [Demo](https://codesandbox.io/s/react-hook-form-get-started-ts-5ksmm) • [Video](https://www.youtube.com/watch?v=RkXv4AXXC_4)
25378
+ *
25379
+ * @param props - form configuration and validation parameters.
25380
+ *
25381
+ * @returns methods - individual functions to manage the form state. {@link UseFormReturn}
25382
+ *
25383
+ * @example
25384
+ * ```tsx
25385
+ * function App() {
25386
+ * const { register, handleSubmit, watch, formState: { errors } } = useForm();
25387
+ * const onSubmit = data => console.log(data);
25388
+ *
25389
+ * console.log(watch("example"));
25390
+ *
25391
+ * return (
25392
+ * <form onSubmit={handleSubmit(onSubmit)}>
25393
+ * <input defaultValue="test" {...register("example")} />
25394
+ * <input {...register("exampleRequired", { required: true })} />
25395
+ * {errors.exampleRequired && <span>This field is required</span>}
25396
+ * <button>Submit</button>
25397
+ * </form>
25398
+ * );
25399
+ * }
25400
+ * ```
25401
+ */
25402
+ function useForm(props = {}) {
25403
+ const _formControl = React__default.useRef();
25404
+ const _values = React__default.useRef();
25405
+ const [formState, updateFormState] = React__default.useState({
25406
+ isDirty: false,
25407
+ isValidating: false,
25408
+ isLoading: isFunction(props.defaultValues),
25409
+ isSubmitted: false,
25410
+ isSubmitting: false,
25411
+ isSubmitSuccessful: false,
25412
+ isValid: false,
25413
+ submitCount: 0,
25414
+ dirtyFields: {},
25415
+ touchedFields: {},
25416
+ validatingFields: {},
25417
+ errors: props.errors || {},
25418
+ disabled: props.disabled || false,
25419
+ defaultValues: isFunction(props.defaultValues)
25420
+ ? undefined
25421
+ : props.defaultValues,
25422
+ });
25423
+ if (!_formControl.current) {
25424
+ _formControl.current = {
25425
+ ...createFormControl(props),
25426
+ formState,
25427
+ };
25428
+ }
25429
+ const control = _formControl.current.control;
25430
+ control._options = props;
25431
+ useSubscribe({
25432
+ subject: control._subjects.state,
25433
+ next: (value) => {
25434
+ if (shouldRenderFormState(value, control._proxyFormState, control._updateFormState, true)) {
25435
+ updateFormState({ ...control._formState });
25436
+ }
25437
+ },
25438
+ });
25439
+ React__default.useEffect(() => control._disableForm(props.disabled), [control, props.disabled]);
25440
+ React__default.useEffect(() => {
25441
+ if (control._proxyFormState.isDirty) {
25442
+ const isDirty = control._getDirty();
25443
+ if (isDirty !== formState.isDirty) {
25444
+ control._subjects.state.next({
25445
+ isDirty,
25446
+ });
25447
+ }
25448
+ }
25449
+ }, [control, formState.isDirty]);
25450
+ React__default.useEffect(() => {
25451
+ if (props.values && !deepEqual(props.values, _values.current)) {
25452
+ control._reset(props.values, control._options.resetOptions);
25453
+ _values.current = props.values;
25454
+ updateFormState((state) => ({ ...state }));
25455
+ }
25456
+ else {
25457
+ control._resetDefaultValues();
25458
+ }
25459
+ }, [props.values, control]);
25460
+ React__default.useEffect(() => {
25461
+ if (props.errors) {
25462
+ control._setErrors(props.errors);
25463
+ }
25464
+ }, [props.errors, control]);
25465
+ React__default.useEffect(() => {
25466
+ if (!control._state.mount) {
25467
+ control._updateValid();
25468
+ control._state.mount = true;
25469
+ }
25470
+ if (control._state.watch) {
25471
+ control._state.watch = false;
25472
+ control._subjects.state.next({ ...control._formState });
25473
+ }
25474
+ control._removeUnmounted();
25475
+ });
25476
+ React__default.useEffect(() => {
25477
+ props.shouldUnregister &&
25478
+ control._subjects.values.next({
25479
+ values: control._getWatch(),
25480
+ });
25481
+ }, [props.shouldUnregister, control]);
25482
+ _formControl.current.formState = getProxyFormState(formState, control);
25483
+ return _formControl.current;
25484
+ }
25485
+
25486
+ var s$1=function(s){var t=s.as,a=s.errors,m=s.name,o=s.message,i=s.render,l=function(e,r){if(null==e)return {};var n,s,t={},a=Object.keys(e);for(s=0;s<a.length;s++)r.indexOf(n=a[s])>=0||(t[n]=e[n]);return t}(s,["as","errors","name","message","render"]),f=useFormContext(),c=get(a||f.formState.errors,m);if(!c)return null;var g=c.message,u=c.types,d=Object.assign({},l,{children:g||o});return React$1.isValidElement(t)?React$1.cloneElement(t,d):i?i({message:g||o,messages:u}):React$1.createElement(t||React$1.Fragment,d)};
23827
25487
 
23828
25488
  // TODO: remove this export once ClassNameGenerator is stable
23829
25489
  // eslint-disable-next-line @typescript-eslint/naming-convention
@@ -40568,7 +42228,7 @@ default_1$3 = ArrowDropDownSharp.default = (0, _createSvgIcon$3.default)( /*#__P
40568
42228
  d: "m7 10 5 5 5-5z"
40569
42229
  }), 'ArrowDropDownSharp');
40570
42230
 
40571
- styled$1(Grid)(({ theme }) => ({
42231
+ const FormComponent = styled$1(Grid)(({ theme }) => ({
40572
42232
  alignItems: 'flex-start',
40573
42233
  flexWrap: 'wrap',
40574
42234
  [theme.breakpoints.down('md')]: {
@@ -40584,7 +42244,7 @@ styled$1(Box)(({ theme }) => ({
40584
42244
  boxShadow: '0 1px 15px rgba(0,0,0,.04), 0 1px 6px rgba(0,0,0,.04)',
40585
42245
  borderRadius: '0.75rem'
40586
42246
  }));
40587
- styled$1(Grid, {
42247
+ const Formitem = styled$1(Grid, {
40588
42248
  shouldForwardProp: prop => prop !== 'isActive' && prop !== 'noOfColumn'
40589
42249
  })(({ theme, noOfColumn }) => ({
40590
42250
  width: `calc(100%/${noOfColumn})`,
@@ -40786,7 +42446,7 @@ function MultiSelectV1({ props }) {
40786
42446
  } }), jsxRuntimeExports.jsx(ListItemText, { primary: "Select All", sx: { fontSize: "5px" } })] })), (filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.length) !== 0 ? (filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.map((name) => {
40787
42447
  var _a;
40788
42448
  return (jsxRuntimeExports.jsxs(MenuItem, Object.assign({ value: name, sx: { zIndex: 0, fontSize: "5px !important" } }, { children: [jsxRuntimeExports.jsx(Checkbox, { checked: ((_a = extractValuesToArray(fieldValue)) === null || _a === void 0 ? void 0 : _a.indexOf(name)) > -1, size: "small" }), jsxRuntimeExports.jsx(ListItemText, { primary: name, sx: { fontSize: "5px" } })] }), name));
40789
- })) : (jsxRuntimeExports.jsx(MenuItem, Object.assign({ disabled: true, value: "NA" }, { children: "No data Found" }), "NA"))] })), jsxRuntimeExports.jsx(s, { errors: props.errors, name: props.item.name, render: ({ message }) => (jsxRuntimeExports.jsx(ErrorMessageComponent, { children: message })) })] })) }));
42449
+ })) : (jsxRuntimeExports.jsx(MenuItem, Object.assign({ disabled: true, value: "NA" }, { children: "No data Found" }), "NA"))] })), jsxRuntimeExports.jsx(s$1, { errors: props.errors, name: props.item.name, render: ({ message }) => (jsxRuntimeExports.jsx(ErrorMessageComponent, { children: message })) })] })) }));
40790
42450
  }
40791
42451
 
40792
42452
  var dayjs_min = {exports: {}};
@@ -42146,7 +43806,7 @@ function isSameDay(dateLeft, dateRight) {
42146
43806
  * const result = isDate({})
42147
43807
  * //=> false
42148
43808
  */
42149
- function isDate(value) {
43809
+ function isDate$1(value) {
42150
43810
  return (
42151
43811
  value instanceof Date ||
42152
43812
  (typeof value === "object" &&
@@ -42188,7 +43848,7 @@ function isDate(value) {
42188
43848
  * //=> false
42189
43849
  */
42190
43850
  function isValid(date) {
42191
- if (!isDate(date) && typeof date !== "number") {
43851
+ if (!isDate$1(date) && typeof date !== "number") {
42192
43852
  return false;
42193
43853
  }
42194
43854
  const _date = toDate(date);
@@ -42818,7 +44478,7 @@ function buildMatchFn(args) {
42818
44478
  args.parsePatterns[args.defaultParseWidth];
42819
44479
 
42820
44480
  const key = Array.isArray(parsePatterns)
42821
- ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString))
44481
+ ? findIndex$1(parsePatterns, (pattern) => pattern.test(matchedString))
42822
44482
  : // eslint-disable-next-line @typescript-eslint/no-explicit-any -- I challange you to fix the type
42823
44483
  findKey(parsePatterns, (pattern) => pattern.test(matchedString));
42824
44484
 
@@ -42848,7 +44508,7 @@ function findKey(object, predicate) {
42848
44508
  return undefined;
42849
44509
  }
42850
44510
 
42851
- function findIndex(array, predicate) {
44511
+ function findIndex$1(array, predicate) {
42852
44512
  for (let key = 0; key < array.length; key++) {
42853
44513
  if (predicate(array[key])) {
42854
44514
  return key;
@@ -45858,7 +47518,7 @@ function createRule(name, decl, options) {
45858
47518
  return null;
45859
47519
  }
45860
47520
 
45861
- var join = function join(value, by) {
47521
+ var join$1 = function join(value, by) {
45862
47522
  var result = '';
45863
47523
 
45864
47524
  for (var i = 0; i < value.length; i++) {
@@ -45888,9 +47548,9 @@ var toCssValue = function toCssValue(value) {
45888
47548
  for (var i = 0; i < value.length; i++) {
45889
47549
  if (value[i] === '!important') break;
45890
47550
  if (cssValue) cssValue += ', ';
45891
- cssValue += join(value[i], ' ');
47551
+ cssValue += join$1(value[i], ' ');
45892
47552
  }
45893
- } else cssValue = join(value, ', '); // Add !important, because it was ignored.
47553
+ } else cssValue = join$1(value, ', '); // Add !important, because it was ignored.
45894
47554
 
45895
47555
 
45896
47556
  if (value[value.length - 1] === '!important') {
@@ -48426,7 +50086,7 @@ function convertCase(style) {
48426
50086
  */
48427
50087
 
48428
50088
 
48429
- function camelCase() {
50089
+ function camelCase$1() {
48430
50090
  function onProcessStyle(style) {
48431
50091
  if (Array.isArray(style)) {
48432
50092
  // Handle rules like @font-face, which can have multiple styles in an array
@@ -49389,7 +51049,7 @@ function jssPropsSort() {
49389
51049
  // Subset of jss-preset-default with only the plugins the MUI components are using.
49390
51050
  function jssPreset() {
49391
51051
  return {
49392
- plugins: [functionPlugin(), jssGlobal(), jssNested(), camelCase(), defaultUnit(),
51052
+ plugins: [functionPlugin(), jssGlobal(), jssNested(), camelCase$1(), defaultUnit(),
49393
51053
  // Disable the vendor prefixer server-side, it does nothing.
49394
51054
  // This way, we can get a performance boost.
49395
51055
  // In the documentation, we are using `autoprefixer` to solve this problem.
@@ -49958,7 +51618,7 @@ const SingleSelect = ({ props }) => {
49958
51618
  },
49959
51619
  }, getOptionLabel: (option) => option.label, renderInput: (params) => {
49960
51620
  return (jsxRuntimeExports.jsx(Tooltip, Object.assign({ title: params.inputProps.value && params.inputProps.value }, { children: jsxRuntimeExports.jsx(TextField, Object.assign({}, params, { placeholder: props.item.Placeholder, label: props.item.label })) })));
49961
- }, isOptionEqualToValue: isOptionEqualToValue })), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s, { errors: props.errors, name: props.item.name }) })] }));
51621
+ }, isOptionEqualToValue: isOptionEqualToValue })), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s$1, { errors: props.errors, name: props.item.name }) })] }));
49962
51622
  } }));
49963
51623
  };
49964
51624
 
@@ -49985,7 +51645,7 @@ const PasswordField = ({ props }) => {
49985
51645
  right: "14px",
49986
51646
  top: "50%",
49987
51647
  transform: "translateY(-50%)",
49988
- }, "aria-label": "toggle password visibility", onClick: handleTogglePasswordVisibility, edge: "end" }, { children: showPassword ? (jsxRuntimeExports.jsx(Visibility, { sx: { fontSize: "12px", position: 'absolute', top: '22%', right: 10 } })) : (jsxRuntimeExports.jsx(VisibilityOff, { sx: { fontSize: "12px", position: 'absolute', top: '22%', right: 10 } })) }))] })), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s, { errors: props.errors, name: props.item.name }) })] })) })] })));
51648
+ }, "aria-label": "toggle password visibility", onClick: handleTogglePasswordVisibility, edge: "end" }, { children: showPassword ? (jsxRuntimeExports.jsx(Visibility, { sx: { fontSize: "12px", position: 'absolute', top: '22%', right: 10 } })) : (jsxRuntimeExports.jsx(VisibilityOff, { sx: { fontSize: "12px", position: 'absolute', top: '22%', right: 10 } })) }))] })), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s$1, { errors: props.errors, name: props.item.name }) })] })) })] })));
49989
51649
  };
49990
51650
 
49991
51651
  const Monthpickerrender = ({ props }) => {
@@ -50054,7 +51714,7 @@ const Monthpickerrender = ({ props }) => {
50054
51714
  fontFamily: "Roboto-Reg",
50055
51715
  fontSize: "11px",
50056
51716
  color: "#3651d3",
50057
- } }, { children: ["(", (_b = props === null || props === void 0 ? void 0 : props.item) === null || _b === void 0 ? void 0 : _b.helperText, ")"] }))), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s, { errors: props.errors, name: props.item.name }) })] }));
51717
+ } }, { children: ["(", (_b = props === null || props === void 0 ? void 0 : props.item) === null || _b === void 0 ? void 0 : _b.helperText, ")"] }))), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s$1, { errors: props.errors, name: props.item.name }) })] }));
50058
51718
  } }));
50059
51719
  };
50060
51720
 
@@ -50094,7 +51754,7 @@ const DatepickerWrapperV2 = ({ props }) => {
50094
51754
  fontFamily: "Roboto-Reg",
50095
51755
  fontSize: "11px",
50096
51756
  color: "#3651d3",
50097
- } }, { children: ["(", (_d = props === null || props === void 0 ? void 0 : props.item) === null || _d === void 0 ? void 0 : _d.helperText, ")"] }))), !(props === null || props === void 0 ? void 0 : props.getValues(props.item.name)) && (jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s, { errors: props.errors, name: props.item.name }) }))] }));
51757
+ } }, { children: ["(", (_d = props === null || props === void 0 ? void 0 : props.item) === null || _d === void 0 ? void 0 : _d.helperText, ")"] }))), !(props === null || props === void 0 ? void 0 : props.getValues(props.item.name)) && (jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s$1, { errors: props.errors, name: props.item.name }) }))] }));
50098
51758
  } }));
50099
51759
  };
50100
51760
 
@@ -50115,7 +51775,7 @@ const FormRenderFileUpload = ({ props }) => {
50115
51775
  [props.item.name]: file,
50116
51776
  [props.item.name + "Name"]: fileName,
50117
51777
  });
50118
- }, sx: { width: "100%" } }) })), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s, { errors: props.errors, name: props.item.name }) })] }));
51778
+ }, sx: { width: "100%" } }) })), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s$1, { errors: props.errors, name: props.item.name }) })] }));
50119
51779
  };
50120
51780
 
50121
51781
  const useStyles = makeStyles((theme) => ({
@@ -50138,7 +51798,7 @@ const SingleSelectNonAutoComplete = ({ props }) => {
50138
51798
  fontSize: "11px",
50139
51799
  fontFamily: "Roboto-Reg",
50140
51800
  zIndex: 2000,
50141
- }, value: item.value }, { children: item.label })))) })), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s, { errors: props.errors, name: props.item.name }) })] })));
51801
+ }, value: item.value }, { children: item.label })))) })), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s$1, { errors: props.errors, name: props.item.name }) })] })));
50142
51802
  };
50143
51803
 
50144
51804
  function formatDateMonthAndYear(date) {
@@ -50189,7 +51849,7 @@ const RenderForm = (props) => {
50189
51849
  fontFamily: "Roboto-Reg",
50190
51850
  fontSize: "11px",
50191
51851
  color: "#3651d3",
50192
- } }, { children: ["(", (_b = props === null || props === void 0 ? void 0 : props.item) === null || _b === void 0 ? void 0 : _b.helperText, ")"] }))), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s, { errors: props.errors, name: props.item.name }) })] }));
51852
+ } }, { children: ["(", (_b = props === null || props === void 0 ? void 0 : props.item) === null || _b === void 0 ? void 0 : _b.helperText, ")"] }))), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s$1, { errors: props.errors, name: props.item.name }) })] }));
50193
51853
  } }) }));
50194
51854
  case "register-number":
50195
51855
  return (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: jsxRuntimeExports.jsx(Controller, { control: props.control, name: props.item.name, render: ({ field }) => {
@@ -50228,7 +51888,7 @@ const RenderForm = (props) => {
50228
51888
  fontFamily: "Roboto-Reg",
50229
51889
  fontSize: "11px",
50230
51890
  color: "#3651d3",
50231
- } }, { children: ["(", (_b = props === null || props === void 0 ? void 0 : props.item) === null || _b === void 0 ? void 0 : _b.helperText, ")"] }))), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s, { errors: props.errors, name: props.item.name }) })] }));
51891
+ } }, { children: ["(", (_b = props === null || props === void 0 ? void 0 : props.item) === null || _b === void 0 ? void 0 : _b.helperText, ")"] }))), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s$1, { errors: props.errors, name: props.item.name }) })] }));
50232
51892
  } }) }));
50233
51893
  case "password":
50234
51894
  return (jsxRuntimeExports.jsx(Box, Object.assign({ position: "relative" }, { children: jsxRuntimeExports.jsx(PasswordField, { props: props }) })));
@@ -50256,7 +51916,7 @@ const RenderForm = (props) => {
50256
51916
  }, inputProps: {
50257
51917
  pattern: "[0-9]*",
50258
51918
  maxLength: props.item.maxLength || 20,
50259
- }, disabled: props.item.disable })), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s, { errors: props.errors, name: props.item.name }) })] }));
51919
+ }, disabled: props.item.disable })), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s$1, { errors: props.errors, name: props.item.name }) })] }));
50260
51920
  } }) }));
50261
51921
  case "decimal":
50262
51922
  return (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: jsxRuntimeExports.jsx(Controller, { name: props.item.name, control: props.control, disabled: (_b = props.item) === null || _b === void 0 ? void 0 : _b.disable, render: ({ field }) => (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(TextField, Object.assign({ type: "text", size: "small", label: props.item.label }, field, { onChange: (e) => (props === null || props === void 0 ? void 0 : props.clearErrors) && (props === null || props === void 0 ? void 0 : props.clearErrors(props.item.name)), sx: {
@@ -50284,7 +51944,7 @@ const RenderForm = (props) => {
50284
51944
  pattern: "[1-9]",
50285
51945
  maxLength: 7,
50286
51946
  },
50287
- } })), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s, { errors: props.errors, name: props.item.name }) })] })) }) }));
51947
+ } })), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s$1, { errors: props.errors, name: props.item.name }) })] })) }) }));
50288
51948
  // case "alpha-numerical":
50289
51949
  // return (
50290
51950
  // <>
@@ -50498,7 +52158,7 @@ const RenderForm = (props) => {
50498
52158
  }, error: props.errors, inputProps: {
50499
52159
  min: props.item.minDate,
50500
52160
  } }))
50501
- } }) })), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s, { errors: props.errors, name: props.item.name }) })] })) }) }));
52161
+ } }) })), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s$1, { errors: props.errors, name: props.item.name }) })] })) }) }));
50502
52162
  case "dateRangePicker":
50503
52163
  return (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: jsxRuntimeExports.jsx(DateRangePickerComponent, { props: props }) }));
50504
52164
  case "monthpicker":
@@ -50542,7 +52202,7 @@ const RenderForm = (props) => {
50542
52202
  },
50543
52203
  }, minRows: props.item.minRows || 1,
50544
52204
  // maxRows={2}
50545
- placeholder: props.item.placeholder || "Type Something..." }, field, { label: props.item.label, value: field.value || "", disabled: props.item.disable })), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s, { errors: props.errors, name: props.item.name }) })] })) }) }));
52205
+ placeholder: props.item.placeholder || "Type Something..." }, field, { label: props.item.label, value: field.value || "", disabled: props.item.disable })), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s$1, { errors: props.errors, name: props.item.name }) })] })) }) }));
50546
52206
  // case "textarea-normal":
50547
52207
  // return (
50548
52208
  // <>
@@ -50619,5 +52279,2333 @@ const RenderForm = (props) => {
50619
52279
  }
50620
52280
  };
50621
52281
 
50622
- export { Button$1 as Button, RenderForm };
52282
+ /**
52283
+ * Based on Kendo UI Core expression code <https://github.com/telerik/kendo-ui-core#license-information>
52284
+ */
52285
+
52286
+ function Cache(maxSize) {
52287
+ this._maxSize = maxSize;
52288
+ this.clear();
52289
+ }
52290
+ Cache.prototype.clear = function () {
52291
+ this._size = 0;
52292
+ this._values = Object.create(null);
52293
+ };
52294
+ Cache.prototype.get = function (key) {
52295
+ return this._values[key]
52296
+ };
52297
+ Cache.prototype.set = function (key, value) {
52298
+ this._size >= this._maxSize && this.clear();
52299
+ if (!(key in this._values)) this._size++;
52300
+
52301
+ return (this._values[key] = value)
52302
+ };
52303
+
52304
+ var SPLIT_REGEX = /[^.^\]^[]+|(?=\[\]|\.\.)/g,
52305
+ DIGIT_REGEX = /^\d+$/,
52306
+ LEAD_DIGIT_REGEX = /^\d/,
52307
+ SPEC_CHAR_REGEX = /[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,
52308
+ CLEAN_QUOTES_REGEX = /^\s*(['"]?)(.*?)(\1)\s*$/,
52309
+ MAX_CACHE_SIZE = 512;
52310
+
52311
+ var pathCache = new Cache(MAX_CACHE_SIZE),
52312
+ setCache = new Cache(MAX_CACHE_SIZE),
52313
+ getCache = new Cache(MAX_CACHE_SIZE);
52314
+
52315
+ var propertyExpr = {
52316
+ Cache: Cache,
52317
+
52318
+ split: split,
52319
+
52320
+ normalizePath: normalizePath,
52321
+
52322
+ setter: function (path) {
52323
+ var parts = normalizePath(path);
52324
+
52325
+ return (
52326
+ setCache.get(path) ||
52327
+ setCache.set(path, function setter(obj, value) {
52328
+ var index = 0;
52329
+ var len = parts.length;
52330
+ var data = obj;
52331
+
52332
+ while (index < len - 1) {
52333
+ var part = parts[index];
52334
+ if (
52335
+ part === '__proto__' ||
52336
+ part === 'constructor' ||
52337
+ part === 'prototype'
52338
+ ) {
52339
+ return obj
52340
+ }
52341
+
52342
+ data = data[parts[index++]];
52343
+ }
52344
+ data[parts[index]] = value;
52345
+ })
52346
+ )
52347
+ },
52348
+
52349
+ getter: function (path, safe) {
52350
+ var parts = normalizePath(path);
52351
+ return (
52352
+ getCache.get(path) ||
52353
+ getCache.set(path, function getter(data) {
52354
+ var index = 0,
52355
+ len = parts.length;
52356
+ while (index < len) {
52357
+ if (data != null || !safe) data = data[parts[index++]];
52358
+ else return
52359
+ }
52360
+ return data
52361
+ })
52362
+ )
52363
+ },
52364
+
52365
+ join: function (segments) {
52366
+ return segments.reduce(function (path, part) {
52367
+ return (
52368
+ path +
52369
+ (isQuoted(part) || DIGIT_REGEX.test(part)
52370
+ ? '[' + part + ']'
52371
+ : (path ? '.' : '') + part)
52372
+ )
52373
+ }, '')
52374
+ },
52375
+
52376
+ forEach: function (path, cb, thisArg) {
52377
+ forEach(Array.isArray(path) ? path : split(path), cb, thisArg);
52378
+ },
52379
+ };
52380
+
52381
+ function normalizePath(path) {
52382
+ return (
52383
+ pathCache.get(path) ||
52384
+ pathCache.set(
52385
+ path,
52386
+ split(path).map(function (part) {
52387
+ return part.replace(CLEAN_QUOTES_REGEX, '$2')
52388
+ })
52389
+ )
52390
+ )
52391
+ }
52392
+
52393
+ function split(path) {
52394
+ return path.match(SPLIT_REGEX) || ['']
52395
+ }
52396
+
52397
+ function forEach(parts, iter, thisArg) {
52398
+ var len = parts.length,
52399
+ part,
52400
+ idx,
52401
+ isArray,
52402
+ isBracket;
52403
+
52404
+ for (idx = 0; idx < len; idx++) {
52405
+ part = parts[idx];
52406
+
52407
+ if (part) {
52408
+ if (shouldBeQuoted(part)) {
52409
+ part = '"' + part + '"';
52410
+ }
52411
+
52412
+ isBracket = isQuoted(part);
52413
+ isArray = !isBracket && /^\d+$/.test(part);
52414
+
52415
+ iter.call(thisArg, part, isBracket, isArray, idx, parts);
52416
+ }
52417
+ }
52418
+ }
52419
+
52420
+ function isQuoted(str) {
52421
+ return (
52422
+ typeof str === 'string' && str && ["'", '"'].indexOf(str.charAt(0)) !== -1
52423
+ )
52424
+ }
52425
+
52426
+ function hasLeadingNumber(part) {
52427
+ return part.match(LEAD_DIGIT_REGEX) && !part.match(DIGIT_REGEX)
52428
+ }
52429
+
52430
+ function hasSpecialChars(part) {
52431
+ return SPEC_CHAR_REGEX.test(part)
52432
+ }
52433
+
52434
+ function shouldBeQuoted(part) {
52435
+ return !isQuoted(part) && (hasLeadingNumber(part) || hasSpecialChars(part))
52436
+ }
52437
+
52438
+ 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;
52439
+
52440
+ const words = (str) => str.match(reWords) || [];
52441
+
52442
+ const upperFirst = (str) => str[0].toUpperCase() + str.slice(1);
52443
+
52444
+ const join = (str, d) => words(str).join(d).toLowerCase();
52445
+
52446
+ const camelCase = (str) =>
52447
+ words(str).reduce(
52448
+ (acc, next) =>
52449
+ `${acc}${
52450
+ !acc
52451
+ ? next.toLowerCase()
52452
+ : next[0].toUpperCase() + next.slice(1).toLowerCase()
52453
+ }`,
52454
+ '',
52455
+ );
52456
+
52457
+ const pascalCase = (str) => upperFirst(camelCase(str));
52458
+
52459
+ const snakeCase = (str) => join(str, '_');
52460
+
52461
+ const kebabCase = (str) => join(str, '-');
52462
+
52463
+ const sentenceCase = (str) => upperFirst(join(str, ' '));
52464
+
52465
+ const titleCase = (str) => words(str).map(upperFirst).join(' ');
52466
+
52467
+ var tinyCase = {
52468
+ words,
52469
+ upperFirst,
52470
+ camelCase,
52471
+ pascalCase,
52472
+ snakeCase,
52473
+ kebabCase,
52474
+ sentenceCase,
52475
+ titleCase,
52476
+ };
52477
+
52478
+ var toposort$2 = {exports: {}};
52479
+
52480
+ /**
52481
+ * Topological sorting function
52482
+ *
52483
+ * @param {Array} edges
52484
+ * @returns {Array}
52485
+ */
52486
+
52487
+ toposort$2.exports = function(edges) {
52488
+ return toposort(uniqueNodes(edges), edges)
52489
+ };
52490
+
52491
+ toposort$2.exports.array = toposort;
52492
+
52493
+ function toposort(nodes, edges) {
52494
+ var cursor = nodes.length
52495
+ , sorted = new Array(cursor)
52496
+ , visited = {}
52497
+ , i = cursor
52498
+ // Better data structures make algorithm much faster.
52499
+ , outgoingEdges = makeOutgoingEdges(edges)
52500
+ , nodesHash = makeNodesHash(nodes);
52501
+
52502
+ // check for unknown nodes
52503
+ edges.forEach(function(edge) {
52504
+ if (!nodesHash.has(edge[0]) || !nodesHash.has(edge[1])) {
52505
+ throw new Error('Unknown node. There is an unknown node in the supplied edges.')
52506
+ }
52507
+ });
52508
+
52509
+ while (i--) {
52510
+ if (!visited[i]) visit(nodes[i], i, new Set());
52511
+ }
52512
+
52513
+ return sorted
52514
+
52515
+ function visit(node, i, predecessors) {
52516
+ if(predecessors.has(node)) {
52517
+ var nodeRep;
52518
+ try {
52519
+ nodeRep = ", node was:" + JSON.stringify(node);
52520
+ } catch(e) {
52521
+ nodeRep = "";
52522
+ }
52523
+ throw new Error('Cyclic dependency' + nodeRep)
52524
+ }
52525
+
52526
+ if (!nodesHash.has(node)) {
52527
+ throw new Error('Found unknown node. Make sure to provided all involved nodes. Unknown node: '+JSON.stringify(node))
52528
+ }
52529
+
52530
+ if (visited[i]) return;
52531
+ visited[i] = true;
52532
+
52533
+ var outgoing = outgoingEdges.get(node) || new Set();
52534
+ outgoing = Array.from(outgoing);
52535
+
52536
+ if (i = outgoing.length) {
52537
+ predecessors.add(node);
52538
+ do {
52539
+ var child = outgoing[--i];
52540
+ visit(child, nodesHash.get(child), predecessors);
52541
+ } while (i)
52542
+ predecessors.delete(node);
52543
+ }
52544
+
52545
+ sorted[--cursor] = node;
52546
+ }
52547
+ }
52548
+
52549
+ function uniqueNodes(arr){
52550
+ var res = new Set();
52551
+ for (var i = 0, len = arr.length; i < len; i++) {
52552
+ var edge = arr[i];
52553
+ res.add(edge[0]);
52554
+ res.add(edge[1]);
52555
+ }
52556
+ return Array.from(res)
52557
+ }
52558
+
52559
+ function makeOutgoingEdges(arr){
52560
+ var edges = new Map();
52561
+ for (var i = 0, len = arr.length; i < len; i++) {
52562
+ var edge = arr[i];
52563
+ if (!edges.has(edge[0])) edges.set(edge[0], new Set());
52564
+ if (!edges.has(edge[1])) edges.set(edge[1], new Set());
52565
+ edges.get(edge[0]).add(edge[1]);
52566
+ }
52567
+ return edges
52568
+ }
52569
+
52570
+ function makeNodesHash(arr){
52571
+ var res = new Map();
52572
+ for (var i = 0, len = arr.length; i < len; i++) {
52573
+ res.set(arr[i], i);
52574
+ }
52575
+ return res
52576
+ }
52577
+
52578
+ var toposortExports = toposort$2.exports;
52579
+ var toposort$1 = /*@__PURE__*/getDefaultExportFromCjs(toposortExports);
52580
+
52581
+ const toString = Object.prototype.toString;
52582
+ const errorToString = Error.prototype.toString;
52583
+ const regExpToString = RegExp.prototype.toString;
52584
+ const symbolToString = typeof Symbol !== 'undefined' ? Symbol.prototype.toString : () => '';
52585
+ const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
52586
+ function printNumber(val) {
52587
+ if (val != +val) return 'NaN';
52588
+ const isNegativeZero = val === 0 && 1 / val < 0;
52589
+ return isNegativeZero ? '-0' : '' + val;
52590
+ }
52591
+ function printSimpleValue(val, quoteStrings = false) {
52592
+ if (val == null || val === true || val === false) return '' + val;
52593
+ const typeOf = typeof val;
52594
+ if (typeOf === 'number') return printNumber(val);
52595
+ if (typeOf === 'string') return quoteStrings ? `"${val}"` : val;
52596
+ if (typeOf === 'function') return '[Function ' + (val.name || 'anonymous') + ']';
52597
+ if (typeOf === 'symbol') return symbolToString.call(val).replace(SYMBOL_REGEXP, 'Symbol($1)');
52598
+ const tag = toString.call(val).slice(8, -1);
52599
+ if (tag === 'Date') return isNaN(val.getTime()) ? '' + val : val.toISOString(val);
52600
+ if (tag === 'Error' || val instanceof Error) return '[' + errorToString.call(val) + ']';
52601
+ if (tag === 'RegExp') return regExpToString.call(val);
52602
+ return null;
52603
+ }
52604
+ function printValue(value, quoteStrings) {
52605
+ let result = printSimpleValue(value, quoteStrings);
52606
+ if (result !== null) return result;
52607
+ return JSON.stringify(value, function (key, value) {
52608
+ let result = printSimpleValue(this[key], quoteStrings);
52609
+ if (result !== null) return result;
52610
+ return value;
52611
+ }, 2);
52612
+ }
52613
+
52614
+ function toArray(value) {
52615
+ return value == null ? [] : [].concat(value);
52616
+ }
52617
+
52618
+ let _Symbol$toStringTag, _Symbol$hasInstance, _Symbol$toStringTag2;
52619
+ let strReg = /\$\{\s*(\w+)\s*\}/g;
52620
+ _Symbol$toStringTag = Symbol.toStringTag;
52621
+ class ValidationErrorNoStack {
52622
+ constructor(errorOrErrors, value, field, type) {
52623
+ this.name = void 0;
52624
+ this.message = void 0;
52625
+ this.value = void 0;
52626
+ this.path = void 0;
52627
+ this.type = void 0;
52628
+ this.params = void 0;
52629
+ this.errors = void 0;
52630
+ this.inner = void 0;
52631
+ this[_Symbol$toStringTag] = 'Error';
52632
+ this.name = 'ValidationError';
52633
+ this.value = value;
52634
+ this.path = field;
52635
+ this.type = type;
52636
+ this.errors = [];
52637
+ this.inner = [];
52638
+ toArray(errorOrErrors).forEach(err => {
52639
+ if (ValidationError.isError(err)) {
52640
+ this.errors.push(...err.errors);
52641
+ const innerErrors = err.inner.length ? err.inner : [err];
52642
+ this.inner.push(...innerErrors);
52643
+ } else {
52644
+ this.errors.push(err);
52645
+ }
52646
+ });
52647
+ this.message = this.errors.length > 1 ? `${this.errors.length} errors occurred` : this.errors[0];
52648
+ }
52649
+ }
52650
+ _Symbol$hasInstance = Symbol.hasInstance;
52651
+ _Symbol$toStringTag2 = Symbol.toStringTag;
52652
+ class ValidationError extends Error {
52653
+ static formatError(message, params) {
52654
+ const path = params.label || params.path || 'this';
52655
+ if (path !== params.path) params = Object.assign({}, params, {
52656
+ path
52657
+ });
52658
+ if (typeof message === 'string') return message.replace(strReg, (_, key) => printValue(params[key]));
52659
+ if (typeof message === 'function') return message(params);
52660
+ return message;
52661
+ }
52662
+ static isError(err) {
52663
+ return err && err.name === 'ValidationError';
52664
+ }
52665
+ constructor(errorOrErrors, value, field, type, disableStack) {
52666
+ const errorNoStack = new ValidationErrorNoStack(errorOrErrors, value, field, type);
52667
+ if (disableStack) {
52668
+ return errorNoStack;
52669
+ }
52670
+ super();
52671
+ this.value = void 0;
52672
+ this.path = void 0;
52673
+ this.type = void 0;
52674
+ this.params = void 0;
52675
+ this.errors = [];
52676
+ this.inner = [];
52677
+ this[_Symbol$toStringTag2] = 'Error';
52678
+ this.name = errorNoStack.name;
52679
+ this.message = errorNoStack.message;
52680
+ this.type = errorNoStack.type;
52681
+ this.value = errorNoStack.value;
52682
+ this.path = errorNoStack.path;
52683
+ this.errors = errorNoStack.errors;
52684
+ this.inner = errorNoStack.inner;
52685
+ if (Error.captureStackTrace) {
52686
+ Error.captureStackTrace(this, ValidationError);
52687
+ }
52688
+ }
52689
+ static [_Symbol$hasInstance](inst) {
52690
+ return ValidationErrorNoStack[Symbol.hasInstance](inst) || super[Symbol.hasInstance](inst);
52691
+ }
52692
+ }
52693
+
52694
+ let mixed = {
52695
+ default: '${path} is invalid',
52696
+ required: '${path} is a required field',
52697
+ defined: '${path} must be defined',
52698
+ notNull: '${path} cannot be null',
52699
+ oneOf: '${path} must be one of the following values: ${values}',
52700
+ notOneOf: '${path} must not be one of the following values: ${values}',
52701
+ notType: ({
52702
+ path,
52703
+ type,
52704
+ value,
52705
+ originalValue
52706
+ }) => {
52707
+ const castMsg = originalValue != null && originalValue !== value ? ` (cast from the value \`${printValue(originalValue, true)}\`).` : '.';
52708
+ 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;
52709
+ }
52710
+ };
52711
+ let string = {
52712
+ length: '${path} must be exactly ${length} characters',
52713
+ min: '${path} must be at least ${min} characters',
52714
+ max: '${path} must be at most ${max} characters',
52715
+ matches: '${path} must match the following: "${regex}"',
52716
+ email: '${path} must be a valid email',
52717
+ url: '${path} must be a valid URL',
52718
+ uuid: '${path} must be a valid UUID',
52719
+ datetime: '${path} must be a valid ISO date-time',
52720
+ datetime_precision: '${path} must be a valid ISO date-time with a sub-second precision of exactly ${precision} digits',
52721
+ datetime_offset: '${path} must be a valid ISO date-time with UTC "Z" timezone',
52722
+ trim: '${path} must be a trimmed string',
52723
+ lowercase: '${path} must be a lowercase string',
52724
+ uppercase: '${path} must be a upper case string'
52725
+ };
52726
+ let number = {
52727
+ min: '${path} must be greater than or equal to ${min}',
52728
+ max: '${path} must be less than or equal to ${max}',
52729
+ lessThan: '${path} must be less than ${less}',
52730
+ moreThan: '${path} must be greater than ${more}',
52731
+ positive: '${path} must be a positive number',
52732
+ negative: '${path} must be a negative number',
52733
+ integer: '${path} must be an integer'
52734
+ };
52735
+ let date = {
52736
+ min: '${path} field must be later than ${min}',
52737
+ max: '${path} field must be at earlier than ${max}'
52738
+ };
52739
+ let boolean = {
52740
+ isValue: '${path} field must be ${value}'
52741
+ };
52742
+ let object = {
52743
+ noUnknown: '${path} field has unspecified keys: ${unknown}'
52744
+ };
52745
+ let array = {
52746
+ min: '${path} field must have at least ${min} items',
52747
+ max: '${path} field must have less than or equal to ${max} items',
52748
+ length: '${path} must have ${length} items'
52749
+ };
52750
+ let tuple = {
52751
+ notType: params => {
52752
+ const {
52753
+ path,
52754
+ value,
52755
+ spec
52756
+ } = params;
52757
+ const typeLen = spec.types.length;
52758
+ if (Array.isArray(value)) {
52759
+ 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)}\``;
52760
+ 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)}\``;
52761
+ }
52762
+ return ValidationError.formatError(mixed.notType, params);
52763
+ }
52764
+ };
52765
+ Object.assign(Object.create(null), {
52766
+ mixed,
52767
+ string,
52768
+ number,
52769
+ date,
52770
+ object,
52771
+ array,
52772
+ boolean,
52773
+ tuple
52774
+ });
52775
+
52776
+ const isSchema = obj => obj && obj.__isYupSchema__;
52777
+
52778
+ class Condition {
52779
+ static fromOptions(refs, config) {
52780
+ if (!config.then && !config.otherwise) throw new TypeError('either `then:` or `otherwise:` is required for `when()` conditions');
52781
+ let {
52782
+ is,
52783
+ then,
52784
+ otherwise
52785
+ } = config;
52786
+ let check = typeof is === 'function' ? is : (...values) => values.every(value => value === is);
52787
+ return new Condition(refs, (values, schema) => {
52788
+ var _branch;
52789
+ let branch = check(...values) ? then : otherwise;
52790
+ return (_branch = branch == null ? void 0 : branch(schema)) != null ? _branch : schema;
52791
+ });
52792
+ }
52793
+ constructor(refs, builder) {
52794
+ this.fn = void 0;
52795
+ this.refs = refs;
52796
+ this.refs = refs;
52797
+ this.fn = builder;
52798
+ }
52799
+ resolve(base, options) {
52800
+ let values = this.refs.map(ref =>
52801
+ // TODO: ? operator here?
52802
+ ref.getValue(options == null ? void 0 : options.value, options == null ? void 0 : options.parent, options == null ? void 0 : options.context));
52803
+ let schema = this.fn(values, base, options);
52804
+ if (schema === undefined ||
52805
+ // @ts-ignore this can be base
52806
+ schema === base) {
52807
+ return base;
52808
+ }
52809
+ if (!isSchema(schema)) throw new TypeError('conditions must return a schema object');
52810
+ return schema.resolve(options);
52811
+ }
52812
+ }
52813
+
52814
+ const prefixes = {
52815
+ context: '$',
52816
+ value: '.'
52817
+ };
52818
+ class Reference {
52819
+ constructor(key, options = {}) {
52820
+ this.key = void 0;
52821
+ this.isContext = void 0;
52822
+ this.isValue = void 0;
52823
+ this.isSibling = void 0;
52824
+ this.path = void 0;
52825
+ this.getter = void 0;
52826
+ this.map = void 0;
52827
+ if (typeof key !== 'string') throw new TypeError('ref must be a string, got: ' + key);
52828
+ this.key = key.trim();
52829
+ if (key === '') throw new TypeError('ref must be a non-empty string');
52830
+ this.isContext = this.key[0] === prefixes.context;
52831
+ this.isValue = this.key[0] === prefixes.value;
52832
+ this.isSibling = !this.isContext && !this.isValue;
52833
+ let prefix = this.isContext ? prefixes.context : this.isValue ? prefixes.value : '';
52834
+ this.path = this.key.slice(prefix.length);
52835
+ this.getter = this.path && propertyExpr.getter(this.path, true);
52836
+ this.map = options.map;
52837
+ }
52838
+ getValue(value, parent, context) {
52839
+ let result = this.isContext ? context : this.isValue ? value : parent;
52840
+ if (this.getter) result = this.getter(result || {});
52841
+ if (this.map) result = this.map(result);
52842
+ return result;
52843
+ }
52844
+
52845
+ /**
52846
+ *
52847
+ * @param {*} value
52848
+ * @param {Object} options
52849
+ * @param {Object=} options.context
52850
+ * @param {Object=} options.parent
52851
+ */
52852
+ cast(value, options) {
52853
+ return this.getValue(value, options == null ? void 0 : options.parent, options == null ? void 0 : options.context);
52854
+ }
52855
+ resolve() {
52856
+ return this;
52857
+ }
52858
+ describe() {
52859
+ return {
52860
+ type: 'ref',
52861
+ key: this.key
52862
+ };
52863
+ }
52864
+ toString() {
52865
+ return `Ref(${this.key})`;
52866
+ }
52867
+ static isRef(value) {
52868
+ return value && value.__isYupRef;
52869
+ }
52870
+ }
52871
+
52872
+ // @ts-ignore
52873
+ Reference.prototype.__isYupRef = true;
52874
+
52875
+ const isAbsent = value => value == null;
52876
+
52877
+ function createValidation(config) {
52878
+ function validate({
52879
+ value,
52880
+ path = '',
52881
+ options,
52882
+ originalValue,
52883
+ schema
52884
+ }, panic, next) {
52885
+ const {
52886
+ name,
52887
+ test,
52888
+ params,
52889
+ message,
52890
+ skipAbsent
52891
+ } = config;
52892
+ let {
52893
+ parent,
52894
+ context,
52895
+ abortEarly = schema.spec.abortEarly,
52896
+ disableStackTrace = schema.spec.disableStackTrace
52897
+ } = options;
52898
+ function resolve(item) {
52899
+ return Reference.isRef(item) ? item.getValue(value, parent, context) : item;
52900
+ }
52901
+ function createError(overrides = {}) {
52902
+ const nextParams = Object.assign({
52903
+ value,
52904
+ originalValue,
52905
+ label: schema.spec.label,
52906
+ path: overrides.path || path,
52907
+ spec: schema.spec,
52908
+ disableStackTrace: overrides.disableStackTrace || disableStackTrace
52909
+ }, params, overrides.params);
52910
+ for (const key of Object.keys(nextParams)) nextParams[key] = resolve(nextParams[key]);
52911
+ const error = new ValidationError(ValidationError.formatError(overrides.message || message, nextParams), value, nextParams.path, overrides.type || name, nextParams.disableStackTrace);
52912
+ error.params = nextParams;
52913
+ return error;
52914
+ }
52915
+ const invalid = abortEarly ? panic : next;
52916
+ let ctx = {
52917
+ path,
52918
+ parent,
52919
+ type: name,
52920
+ from: options.from,
52921
+ createError,
52922
+ resolve,
52923
+ options,
52924
+ originalValue,
52925
+ schema
52926
+ };
52927
+ const handleResult = validOrError => {
52928
+ if (ValidationError.isError(validOrError)) invalid(validOrError);else if (!validOrError) invalid(createError());else next(null);
52929
+ };
52930
+ const handleError = err => {
52931
+ if (ValidationError.isError(err)) invalid(err);else panic(err);
52932
+ };
52933
+ const shouldSkip = skipAbsent && isAbsent(value);
52934
+ if (shouldSkip) {
52935
+ return handleResult(true);
52936
+ }
52937
+ let result;
52938
+ try {
52939
+ var _result;
52940
+ result = test.call(ctx, value, ctx);
52941
+ if (typeof ((_result = result) == null ? void 0 : _result.then) === 'function') {
52942
+ if (options.sync) {
52943
+ 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`);
52944
+ }
52945
+ return Promise.resolve(result).then(handleResult, handleError);
52946
+ }
52947
+ } catch (err) {
52948
+ handleError(err);
52949
+ return;
52950
+ }
52951
+ handleResult(result);
52952
+ }
52953
+ validate.OPTIONS = config;
52954
+ return validate;
52955
+ }
52956
+
52957
+ function getIn(schema, path, value, context = value) {
52958
+ let parent, lastPart, lastPartDebug;
52959
+
52960
+ // root path: ''
52961
+ if (!path) return {
52962
+ parent,
52963
+ parentPath: path,
52964
+ schema
52965
+ };
52966
+ propertyExpr.forEach(path, (_part, isBracket, isArray) => {
52967
+ let part = isBracket ? _part.slice(1, _part.length - 1) : _part;
52968
+ schema = schema.resolve({
52969
+ context,
52970
+ parent,
52971
+ value
52972
+ });
52973
+ let isTuple = schema.type === 'tuple';
52974
+ let idx = isArray ? parseInt(part, 10) : 0;
52975
+ if (schema.innerType || isTuple) {
52976
+ 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]"`);
52977
+ if (value && idx >= value.length) {
52978
+ 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. `);
52979
+ }
52980
+ parent = value;
52981
+ value = value && value[idx];
52982
+ schema = isTuple ? schema.spec.types[idx] : schema.innerType;
52983
+ }
52984
+
52985
+ // sometimes the array index part of a path doesn't exist: "nested.arr.child"
52986
+ // in these cases the current part is the next schema and should be processed
52987
+ // in this iteration. For cases where the index signature is included this
52988
+ // check will fail and we'll handle the `child` part on the next iteration like normal
52989
+ if (!isArray) {
52990
+ 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}")`);
52991
+ parent = value;
52992
+ value = value && value[part];
52993
+ schema = schema.fields[part];
52994
+ }
52995
+ lastPart = part;
52996
+ lastPartDebug = isBracket ? '[' + _part + ']' : '.' + _part;
52997
+ });
52998
+ return {
52999
+ schema,
53000
+ parent,
53001
+ parentPath: lastPart
53002
+ };
53003
+ }
53004
+
53005
+ class ReferenceSet extends Set {
53006
+ describe() {
53007
+ const description = [];
53008
+ for (const item of this.values()) {
53009
+ description.push(Reference.isRef(item) ? item.describe() : item);
53010
+ }
53011
+ return description;
53012
+ }
53013
+ resolveAll(resolve) {
53014
+ let result = [];
53015
+ for (const item of this.values()) {
53016
+ result.push(resolve(item));
53017
+ }
53018
+ return result;
53019
+ }
53020
+ clone() {
53021
+ return new ReferenceSet(this.values());
53022
+ }
53023
+ merge(newItems, removeItems) {
53024
+ const next = this.clone();
53025
+ newItems.forEach(value => next.add(value));
53026
+ removeItems.forEach(value => next.delete(value));
53027
+ return next;
53028
+ }
53029
+ }
53030
+
53031
+ // tweaked from https://github.com/Kelin2025/nanoclone/blob/0abeb7635bda9b68ef2277093f76dbe3bf3948e1/src/index.js
53032
+ function clone(src, seen = new Map()) {
53033
+ if (isSchema(src) || !src || typeof src !== 'object') return src;
53034
+ if (seen.has(src)) return seen.get(src);
53035
+ let copy;
53036
+ if (src instanceof Date) {
53037
+ // Date
53038
+ copy = new Date(src.getTime());
53039
+ seen.set(src, copy);
53040
+ } else if (src instanceof RegExp) {
53041
+ // RegExp
53042
+ copy = new RegExp(src);
53043
+ seen.set(src, copy);
53044
+ } else if (Array.isArray(src)) {
53045
+ // Array
53046
+ copy = new Array(src.length);
53047
+ seen.set(src, copy);
53048
+ for (let i = 0; i < src.length; i++) copy[i] = clone(src[i], seen);
53049
+ } else if (src instanceof Map) {
53050
+ // Map
53051
+ copy = new Map();
53052
+ seen.set(src, copy);
53053
+ for (const [k, v] of src.entries()) copy.set(k, clone(v, seen));
53054
+ } else if (src instanceof Set) {
53055
+ // Set
53056
+ copy = new Set();
53057
+ seen.set(src, copy);
53058
+ for (const v of src) copy.add(clone(v, seen));
53059
+ } else if (src instanceof Object) {
53060
+ // Object
53061
+ copy = {};
53062
+ seen.set(src, copy);
53063
+ for (const [k, v] of Object.entries(src)) copy[k] = clone(v, seen);
53064
+ } else {
53065
+ throw Error(`Unable to clone ${src}`);
53066
+ }
53067
+ return copy;
53068
+ }
53069
+
53070
+ // If `CustomSchemaMeta` isn't extended with any keys, we'll fall back to a
53071
+ // loose Record definition allowing free form usage.
53072
+ class Schema {
53073
+ constructor(options) {
53074
+ this.type = void 0;
53075
+ this.deps = [];
53076
+ this.tests = void 0;
53077
+ this.transforms = void 0;
53078
+ this.conditions = [];
53079
+ this._mutate = void 0;
53080
+ this.internalTests = {};
53081
+ this._whitelist = new ReferenceSet();
53082
+ this._blacklist = new ReferenceSet();
53083
+ this.exclusiveTests = Object.create(null);
53084
+ this._typeCheck = void 0;
53085
+ this.spec = void 0;
53086
+ this.tests = [];
53087
+ this.transforms = [];
53088
+ this.withMutation(() => {
53089
+ this.typeError(mixed.notType);
53090
+ });
53091
+ this.type = options.type;
53092
+ this._typeCheck = options.check;
53093
+ this.spec = Object.assign({
53094
+ strip: false,
53095
+ strict: false,
53096
+ abortEarly: true,
53097
+ recursive: true,
53098
+ disableStackTrace: false,
53099
+ nullable: false,
53100
+ optional: true,
53101
+ coerce: true
53102
+ }, options == null ? void 0 : options.spec);
53103
+ this.withMutation(s => {
53104
+ s.nonNullable();
53105
+ });
53106
+ }
53107
+
53108
+ // TODO: remove
53109
+ get _type() {
53110
+ return this.type;
53111
+ }
53112
+ clone(spec) {
53113
+ if (this._mutate) {
53114
+ if (spec) Object.assign(this.spec, spec);
53115
+ return this;
53116
+ }
53117
+
53118
+ // if the nested value is a schema we can skip cloning, since
53119
+ // they are already immutable
53120
+ const next = Object.create(Object.getPrototypeOf(this));
53121
+
53122
+ // @ts-expect-error this is readonly
53123
+ next.type = this.type;
53124
+ next._typeCheck = this._typeCheck;
53125
+ next._whitelist = this._whitelist.clone();
53126
+ next._blacklist = this._blacklist.clone();
53127
+ next.internalTests = Object.assign({}, this.internalTests);
53128
+ next.exclusiveTests = Object.assign({}, this.exclusiveTests);
53129
+
53130
+ // @ts-expect-error this is readonly
53131
+ next.deps = [...this.deps];
53132
+ next.conditions = [...this.conditions];
53133
+ next.tests = [...this.tests];
53134
+ next.transforms = [...this.transforms];
53135
+ next.spec = clone(Object.assign({}, this.spec, spec));
53136
+ return next;
53137
+ }
53138
+ label(label) {
53139
+ let next = this.clone();
53140
+ next.spec.label = label;
53141
+ return next;
53142
+ }
53143
+ meta(...args) {
53144
+ if (args.length === 0) return this.spec.meta;
53145
+ let next = this.clone();
53146
+ next.spec.meta = Object.assign(next.spec.meta || {}, args[0]);
53147
+ return next;
53148
+ }
53149
+ withMutation(fn) {
53150
+ let before = this._mutate;
53151
+ this._mutate = true;
53152
+ let result = fn(this);
53153
+ this._mutate = before;
53154
+ return result;
53155
+ }
53156
+ concat(schema) {
53157
+ if (!schema || schema === this) return this;
53158
+ if (schema.type !== this.type && this.type !== 'mixed') throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${schema.type}`);
53159
+ let base = this;
53160
+ let combined = schema.clone();
53161
+ const mergedSpec = Object.assign({}, base.spec, combined.spec);
53162
+ combined.spec = mergedSpec;
53163
+ combined.internalTests = Object.assign({}, base.internalTests, combined.internalTests);
53164
+
53165
+ // manually merge the blacklist/whitelist (the other `schema` takes
53166
+ // precedence in case of conflicts)
53167
+ combined._whitelist = base._whitelist.merge(schema._whitelist, schema._blacklist);
53168
+ combined._blacklist = base._blacklist.merge(schema._blacklist, schema._whitelist);
53169
+
53170
+ // start with the current tests
53171
+ combined.tests = base.tests;
53172
+ combined.exclusiveTests = base.exclusiveTests;
53173
+
53174
+ // manually add the new tests to ensure
53175
+ // the deduping logic is consistent
53176
+ combined.withMutation(next => {
53177
+ schema.tests.forEach(fn => {
53178
+ next.test(fn.OPTIONS);
53179
+ });
53180
+ });
53181
+ combined.transforms = [...base.transforms, ...combined.transforms];
53182
+ return combined;
53183
+ }
53184
+ isType(v) {
53185
+ if (v == null) {
53186
+ if (this.spec.nullable && v === null) return true;
53187
+ if (this.spec.optional && v === undefined) return true;
53188
+ return false;
53189
+ }
53190
+ return this._typeCheck(v);
53191
+ }
53192
+ resolve(options) {
53193
+ let schema = this;
53194
+ if (schema.conditions.length) {
53195
+ let conditions = schema.conditions;
53196
+ schema = schema.clone();
53197
+ schema.conditions = [];
53198
+ schema = conditions.reduce((prevSchema, condition) => condition.resolve(prevSchema, options), schema);
53199
+ schema = schema.resolve(options);
53200
+ }
53201
+ return schema;
53202
+ }
53203
+ resolveOptions(options) {
53204
+ var _options$strict, _options$abortEarly, _options$recursive, _options$disableStack;
53205
+ return Object.assign({}, options, {
53206
+ from: options.from || [],
53207
+ strict: (_options$strict = options.strict) != null ? _options$strict : this.spec.strict,
53208
+ abortEarly: (_options$abortEarly = options.abortEarly) != null ? _options$abortEarly : this.spec.abortEarly,
53209
+ recursive: (_options$recursive = options.recursive) != null ? _options$recursive : this.spec.recursive,
53210
+ disableStackTrace: (_options$disableStack = options.disableStackTrace) != null ? _options$disableStack : this.spec.disableStackTrace
53211
+ });
53212
+ }
53213
+
53214
+ /**
53215
+ * Run the configured transform pipeline over an input value.
53216
+ */
53217
+
53218
+ cast(value, options = {}) {
53219
+ let resolvedSchema = this.resolve(Object.assign({
53220
+ value
53221
+ }, options));
53222
+ let allowOptionality = options.assert === 'ignore-optionality';
53223
+ let result = resolvedSchema._cast(value, options);
53224
+ if (options.assert !== false && !resolvedSchema.isType(result)) {
53225
+ if (allowOptionality && isAbsent(result)) {
53226
+ return result;
53227
+ }
53228
+ let formattedValue = printValue(value);
53229
+ let formattedResult = printValue(result);
53230
+ 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}` : ''));
53231
+ }
53232
+ return result;
53233
+ }
53234
+ _cast(rawValue, options) {
53235
+ let value = rawValue === undefined ? rawValue : this.transforms.reduce((prevValue, fn) => fn.call(this, prevValue, rawValue, this), rawValue);
53236
+ if (value === undefined) {
53237
+ value = this.getDefault(options);
53238
+ }
53239
+ return value;
53240
+ }
53241
+ _validate(_value, options = {}, panic, next) {
53242
+ let {
53243
+ path,
53244
+ originalValue = _value,
53245
+ strict = this.spec.strict
53246
+ } = options;
53247
+ let value = _value;
53248
+ if (!strict) {
53249
+ value = this._cast(value, Object.assign({
53250
+ assert: false
53251
+ }, options));
53252
+ }
53253
+ let initialTests = [];
53254
+ for (let test of Object.values(this.internalTests)) {
53255
+ if (test) initialTests.push(test);
53256
+ }
53257
+ this.runTests({
53258
+ path,
53259
+ value,
53260
+ originalValue,
53261
+ options,
53262
+ tests: initialTests
53263
+ }, panic, initialErrors => {
53264
+ // even if we aren't ending early we can't proceed further if the types aren't correct
53265
+ if (initialErrors.length) {
53266
+ return next(initialErrors, value);
53267
+ }
53268
+ this.runTests({
53269
+ path,
53270
+ value,
53271
+ originalValue,
53272
+ options,
53273
+ tests: this.tests
53274
+ }, panic, next);
53275
+ });
53276
+ }
53277
+
53278
+ /**
53279
+ * Executes a set of validations, either schema, produced Tests or a nested
53280
+ * schema validate result.
53281
+ */
53282
+ runTests(runOptions, panic, next) {
53283
+ let fired = false;
53284
+ let {
53285
+ tests,
53286
+ value,
53287
+ originalValue,
53288
+ path,
53289
+ options
53290
+ } = runOptions;
53291
+ let panicOnce = arg => {
53292
+ if (fired) return;
53293
+ fired = true;
53294
+ panic(arg, value);
53295
+ };
53296
+ let nextOnce = arg => {
53297
+ if (fired) return;
53298
+ fired = true;
53299
+ next(arg, value);
53300
+ };
53301
+ let count = tests.length;
53302
+ let nestedErrors = [];
53303
+ if (!count) return nextOnce([]);
53304
+ let args = {
53305
+ value,
53306
+ originalValue,
53307
+ path,
53308
+ options,
53309
+ schema: this
53310
+ };
53311
+ for (let i = 0; i < tests.length; i++) {
53312
+ const test = tests[i];
53313
+ test(args, panicOnce, function finishTestRun(err) {
53314
+ if (err) {
53315
+ Array.isArray(err) ? nestedErrors.push(...err) : nestedErrors.push(err);
53316
+ }
53317
+ if (--count <= 0) {
53318
+ nextOnce(nestedErrors);
53319
+ }
53320
+ });
53321
+ }
53322
+ }
53323
+ asNestedTest({
53324
+ key,
53325
+ index,
53326
+ parent,
53327
+ parentPath,
53328
+ originalParent,
53329
+ options
53330
+ }) {
53331
+ const k = key != null ? key : index;
53332
+ if (k == null) {
53333
+ throw TypeError('Must include `key` or `index` for nested validations');
53334
+ }
53335
+ const isIndex = typeof k === 'number';
53336
+ let value = parent[k];
53337
+ const testOptions = Object.assign({}, options, {
53338
+ // Nested validations fields are always strict:
53339
+ // 1. parent isn't strict so the casting will also have cast inner values
53340
+ // 2. parent is strict in which case the nested values weren't cast either
53341
+ strict: true,
53342
+ parent,
53343
+ value,
53344
+ originalValue: originalParent[k],
53345
+ // FIXME: tests depend on `index` being passed around deeply,
53346
+ // we should not let the options.key/index bleed through
53347
+ key: undefined,
53348
+ // index: undefined,
53349
+ [isIndex ? 'index' : 'key']: k,
53350
+ path: isIndex || k.includes('.') ? `${parentPath || ''}[${isIndex ? k : `"${k}"`}]` : (parentPath ? `${parentPath}.` : '') + key
53351
+ });
53352
+ return (_, panic, next) => this.resolve(testOptions)._validate(value, testOptions, panic, next);
53353
+ }
53354
+ validate(value, options) {
53355
+ var _options$disableStack2;
53356
+ let schema = this.resolve(Object.assign({}, options, {
53357
+ value
53358
+ }));
53359
+ let disableStackTrace = (_options$disableStack2 = options == null ? void 0 : options.disableStackTrace) != null ? _options$disableStack2 : schema.spec.disableStackTrace;
53360
+ return new Promise((resolve, reject) => schema._validate(value, options, (error, parsed) => {
53361
+ if (ValidationError.isError(error)) error.value = parsed;
53362
+ reject(error);
53363
+ }, (errors, validated) => {
53364
+ if (errors.length) reject(new ValidationError(errors, validated, undefined, undefined, disableStackTrace));else resolve(validated);
53365
+ }));
53366
+ }
53367
+ validateSync(value, options) {
53368
+ var _options$disableStack3;
53369
+ let schema = this.resolve(Object.assign({}, options, {
53370
+ value
53371
+ }));
53372
+ let result;
53373
+ let disableStackTrace = (_options$disableStack3 = options == null ? void 0 : options.disableStackTrace) != null ? _options$disableStack3 : schema.spec.disableStackTrace;
53374
+ schema._validate(value, Object.assign({}, options, {
53375
+ sync: true
53376
+ }), (error, parsed) => {
53377
+ if (ValidationError.isError(error)) error.value = parsed;
53378
+ throw error;
53379
+ }, (errors, validated) => {
53380
+ if (errors.length) throw new ValidationError(errors, value, undefined, undefined, disableStackTrace);
53381
+ result = validated;
53382
+ });
53383
+ return result;
53384
+ }
53385
+ isValid(value, options) {
53386
+ return this.validate(value, options).then(() => true, err => {
53387
+ if (ValidationError.isError(err)) return false;
53388
+ throw err;
53389
+ });
53390
+ }
53391
+ isValidSync(value, options) {
53392
+ try {
53393
+ this.validateSync(value, options);
53394
+ return true;
53395
+ } catch (err) {
53396
+ if (ValidationError.isError(err)) return false;
53397
+ throw err;
53398
+ }
53399
+ }
53400
+ _getDefault(options) {
53401
+ let defaultValue = this.spec.default;
53402
+ if (defaultValue == null) {
53403
+ return defaultValue;
53404
+ }
53405
+ return typeof defaultValue === 'function' ? defaultValue.call(this, options) : clone(defaultValue);
53406
+ }
53407
+ getDefault(options
53408
+ // If schema is defaulted we know it's at least not undefined
53409
+ ) {
53410
+ let schema = this.resolve(options || {});
53411
+ return schema._getDefault(options);
53412
+ }
53413
+ default(def) {
53414
+ if (arguments.length === 0) {
53415
+ return this._getDefault();
53416
+ }
53417
+ let next = this.clone({
53418
+ default: def
53419
+ });
53420
+ return next;
53421
+ }
53422
+ strict(isStrict = true) {
53423
+ return this.clone({
53424
+ strict: isStrict
53425
+ });
53426
+ }
53427
+ nullability(nullable, message) {
53428
+ const next = this.clone({
53429
+ nullable
53430
+ });
53431
+ next.internalTests.nullable = createValidation({
53432
+ message,
53433
+ name: 'nullable',
53434
+ test(value) {
53435
+ return value === null ? this.schema.spec.nullable : true;
53436
+ }
53437
+ });
53438
+ return next;
53439
+ }
53440
+ optionality(optional, message) {
53441
+ const next = this.clone({
53442
+ optional
53443
+ });
53444
+ next.internalTests.optionality = createValidation({
53445
+ message,
53446
+ name: 'optionality',
53447
+ test(value) {
53448
+ return value === undefined ? this.schema.spec.optional : true;
53449
+ }
53450
+ });
53451
+ return next;
53452
+ }
53453
+ optional() {
53454
+ return this.optionality(true);
53455
+ }
53456
+ defined(message = mixed.defined) {
53457
+ return this.optionality(false, message);
53458
+ }
53459
+ nullable() {
53460
+ return this.nullability(true);
53461
+ }
53462
+ nonNullable(message = mixed.notNull) {
53463
+ return this.nullability(false, message);
53464
+ }
53465
+ required(message = mixed.required) {
53466
+ return this.clone().withMutation(next => next.nonNullable(message).defined(message));
53467
+ }
53468
+ notRequired() {
53469
+ return this.clone().withMutation(next => next.nullable().optional());
53470
+ }
53471
+ transform(fn) {
53472
+ let next = this.clone();
53473
+ next.transforms.push(fn);
53474
+ return next;
53475
+ }
53476
+
53477
+ /**
53478
+ * Adds a test function to the schema's queue of tests.
53479
+ * tests can be exclusive or non-exclusive.
53480
+ *
53481
+ * - exclusive tests, will replace any existing tests of the same name.
53482
+ * - non-exclusive: can be stacked
53483
+ *
53484
+ * If a non-exclusive test is added to a schema with an exclusive test of the same name
53485
+ * the exclusive test is removed and further tests of the same name will be stacked.
53486
+ *
53487
+ * If an exclusive test is added to a schema with non-exclusive tests of the same name
53488
+ * the previous tests are removed and further tests of the same name will replace each other.
53489
+ */
53490
+
53491
+ test(...args) {
53492
+ let opts;
53493
+ if (args.length === 1) {
53494
+ if (typeof args[0] === 'function') {
53495
+ opts = {
53496
+ test: args[0]
53497
+ };
53498
+ } else {
53499
+ opts = args[0];
53500
+ }
53501
+ } else if (args.length === 2) {
53502
+ opts = {
53503
+ name: args[0],
53504
+ test: args[1]
53505
+ };
53506
+ } else {
53507
+ opts = {
53508
+ name: args[0],
53509
+ message: args[1],
53510
+ test: args[2]
53511
+ };
53512
+ }
53513
+ if (opts.message === undefined) opts.message = mixed.default;
53514
+ if (typeof opts.test !== 'function') throw new TypeError('`test` is a required parameters');
53515
+ let next = this.clone();
53516
+ let validate = createValidation(opts);
53517
+ let isExclusive = opts.exclusive || opts.name && next.exclusiveTests[opts.name] === true;
53518
+ if (opts.exclusive) {
53519
+ if (!opts.name) throw new TypeError('Exclusive tests must provide a unique `name` identifying the test');
53520
+ }
53521
+ if (opts.name) next.exclusiveTests[opts.name] = !!opts.exclusive;
53522
+ next.tests = next.tests.filter(fn => {
53523
+ if (fn.OPTIONS.name === opts.name) {
53524
+ if (isExclusive) return false;
53525
+ if (fn.OPTIONS.test === validate.OPTIONS.test) return false;
53526
+ }
53527
+ return true;
53528
+ });
53529
+ next.tests.push(validate);
53530
+ return next;
53531
+ }
53532
+ when(keys, options) {
53533
+ if (!Array.isArray(keys) && typeof keys !== 'string') {
53534
+ options = keys;
53535
+ keys = '.';
53536
+ }
53537
+ let next = this.clone();
53538
+ let deps = toArray(keys).map(key => new Reference(key));
53539
+ deps.forEach(dep => {
53540
+ // @ts-ignore readonly array
53541
+ if (dep.isSibling) next.deps.push(dep.key);
53542
+ });
53543
+ next.conditions.push(typeof options === 'function' ? new Condition(deps, options) : Condition.fromOptions(deps, options));
53544
+ return next;
53545
+ }
53546
+ typeError(message) {
53547
+ let next = this.clone();
53548
+ next.internalTests.typeError = createValidation({
53549
+ message,
53550
+ name: 'typeError',
53551
+ skipAbsent: true,
53552
+ test(value) {
53553
+ if (!this.schema._typeCheck(value)) return this.createError({
53554
+ params: {
53555
+ type: this.schema.type
53556
+ }
53557
+ });
53558
+ return true;
53559
+ }
53560
+ });
53561
+ return next;
53562
+ }
53563
+ oneOf(enums, message = mixed.oneOf) {
53564
+ let next = this.clone();
53565
+ enums.forEach(val => {
53566
+ next._whitelist.add(val);
53567
+ next._blacklist.delete(val);
53568
+ });
53569
+ next.internalTests.whiteList = createValidation({
53570
+ message,
53571
+ name: 'oneOf',
53572
+ skipAbsent: true,
53573
+ test(value) {
53574
+ let valids = this.schema._whitelist;
53575
+ let resolved = valids.resolveAll(this.resolve);
53576
+ return resolved.includes(value) ? true : this.createError({
53577
+ params: {
53578
+ values: Array.from(valids).join(', '),
53579
+ resolved
53580
+ }
53581
+ });
53582
+ }
53583
+ });
53584
+ return next;
53585
+ }
53586
+ notOneOf(enums, message = mixed.notOneOf) {
53587
+ let next = this.clone();
53588
+ enums.forEach(val => {
53589
+ next._blacklist.add(val);
53590
+ next._whitelist.delete(val);
53591
+ });
53592
+ next.internalTests.blacklist = createValidation({
53593
+ message,
53594
+ name: 'notOneOf',
53595
+ test(value) {
53596
+ let invalids = this.schema._blacklist;
53597
+ let resolved = invalids.resolveAll(this.resolve);
53598
+ if (resolved.includes(value)) return this.createError({
53599
+ params: {
53600
+ values: Array.from(invalids).join(', '),
53601
+ resolved
53602
+ }
53603
+ });
53604
+ return true;
53605
+ }
53606
+ });
53607
+ return next;
53608
+ }
53609
+ strip(strip = true) {
53610
+ let next = this.clone();
53611
+ next.spec.strip = strip;
53612
+ return next;
53613
+ }
53614
+
53615
+ /**
53616
+ * Return a serialized description of the schema including validations, flags, types etc.
53617
+ *
53618
+ * @param options Provide any needed context for resolving runtime schema alterations (lazy, when conditions, etc).
53619
+ */
53620
+ describe(options) {
53621
+ const next = (options ? this.resolve(options) : this).clone();
53622
+ const {
53623
+ label,
53624
+ meta,
53625
+ optional,
53626
+ nullable
53627
+ } = next.spec;
53628
+ const description = {
53629
+ meta,
53630
+ label,
53631
+ optional,
53632
+ nullable,
53633
+ default: next.getDefault(options),
53634
+ type: next.type,
53635
+ oneOf: next._whitelist.describe(),
53636
+ notOneOf: next._blacklist.describe(),
53637
+ tests: next.tests.map(fn => ({
53638
+ name: fn.OPTIONS.name,
53639
+ params: fn.OPTIONS.params
53640
+ })).filter((n, idx, list) => list.findIndex(c => c.name === n.name) === idx)
53641
+ };
53642
+ return description;
53643
+ }
53644
+ }
53645
+ // @ts-expect-error
53646
+ Schema.prototype.__isYupSchema__ = true;
53647
+ for (const method of ['validate', 'validateSync']) Schema.prototype[`${method}At`] = function (path, value, options = {}) {
53648
+ const {
53649
+ parent,
53650
+ parentPath,
53651
+ schema
53652
+ } = getIn(this, path, value, options.context);
53653
+ return schema[method](parent && parent[parentPath], Object.assign({}, options, {
53654
+ parent,
53655
+ path
53656
+ }));
53657
+ };
53658
+ for (const alias of ['equals', 'is']) Schema.prototype[alias] = Schema.prototype.oneOf;
53659
+ for (const alias of ['not', 'nope']) Schema.prototype[alias] = Schema.prototype.notOneOf;
53660
+
53661
+ const returnsTrue = () => true;
53662
+ function create$8(spec) {
53663
+ return new MixedSchema(spec);
53664
+ }
53665
+ class MixedSchema extends Schema {
53666
+ constructor(spec) {
53667
+ super(typeof spec === 'function' ? {
53668
+ type: 'mixed',
53669
+ check: spec
53670
+ } : Object.assign({
53671
+ type: 'mixed',
53672
+ check: returnsTrue
53673
+ }, spec));
53674
+ }
53675
+ }
53676
+ create$8.prototype = MixedSchema.prototype;
53677
+
53678
+ /**
53679
+ * This file is a modified version of the file from the following repository:
53680
+ * Date.parse with progressive enhancement for ISO 8601 <https://github.com/csnover/js-iso8601>
53681
+ * NON-CONFORMANT EDITION.
53682
+ * © 2011 Colin Snover <http://zetafleet.com>
53683
+ * Released under MIT license.
53684
+ */
53685
+
53686
+ // prettier-ignore
53687
+ // 1 YYYY 2 MM 3 DD 4 HH 5 mm 6 ss 7 msec 8 Z 9 ± 10 tzHH 11 tzmm
53688
+ const isoReg = /^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;
53689
+ function parseIsoDate(date) {
53690
+ const struct = parseDateStruct(date);
53691
+ if (!struct) return Date.parse ? Date.parse(date) : Number.NaN;
53692
+
53693
+ // timestamps without timezone identifiers should be considered local time
53694
+ if (struct.z === undefined && struct.plusMinus === undefined) {
53695
+ return new Date(struct.year, struct.month, struct.day, struct.hour, struct.minute, struct.second, struct.millisecond).valueOf();
53696
+ }
53697
+ let totalMinutesOffset = 0;
53698
+ if (struct.z !== 'Z' && struct.plusMinus !== undefined) {
53699
+ totalMinutesOffset = struct.hourOffset * 60 + struct.minuteOffset;
53700
+ if (struct.plusMinus === '+') totalMinutesOffset = 0 - totalMinutesOffset;
53701
+ }
53702
+ return Date.UTC(struct.year, struct.month, struct.day, struct.hour, struct.minute + totalMinutesOffset, struct.second, struct.millisecond);
53703
+ }
53704
+ function parseDateStruct(date) {
53705
+ var _regexResult$7$length, _regexResult$;
53706
+ const regexResult = isoReg.exec(date);
53707
+ if (!regexResult) return null;
53708
+
53709
+ // use of toNumber() avoids NaN timestamps caused by “undefined”
53710
+ // values being passed to Date constructor
53711
+ return {
53712
+ year: toNumber(regexResult[1]),
53713
+ month: toNumber(regexResult[2], 1) - 1,
53714
+ day: toNumber(regexResult[3], 1),
53715
+ hour: toNumber(regexResult[4]),
53716
+ minute: toNumber(regexResult[5]),
53717
+ second: toNumber(regexResult[6]),
53718
+ millisecond: regexResult[7] ?
53719
+ // allow arbitrary sub-second precision beyond milliseconds
53720
+ toNumber(regexResult[7].substring(0, 3)) : 0,
53721
+ precision: (_regexResult$7$length = (_regexResult$ = regexResult[7]) == null ? void 0 : _regexResult$.length) != null ? _regexResult$7$length : undefined,
53722
+ z: regexResult[8] || undefined,
53723
+ plusMinus: regexResult[9] || undefined,
53724
+ hourOffset: toNumber(regexResult[10]),
53725
+ minuteOffset: toNumber(regexResult[11])
53726
+ };
53727
+ }
53728
+ function toNumber(str, defaultValue = 0) {
53729
+ return Number(str) || defaultValue;
53730
+ }
53731
+
53732
+ // Taken from HTML spec: https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
53733
+ let rEmail =
53734
+ // eslint-disable-next-line
53735
+ /^[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])?)*$/;
53736
+ let rUrl =
53737
+ // eslint-disable-next-line
53738
+ /^((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;
53739
+
53740
+ // eslint-disable-next-line
53741
+ 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;
53742
+ let yearMonthDay = '^\\d{4}-\\d{2}-\\d{2}';
53743
+ let hourMinuteSecond = '\\d{2}:\\d{2}:\\d{2}';
53744
+ let zOrOffset = '(([+-]\\d{2}(:?\\d{2})?)|Z)';
53745
+ let rIsoDateTime = new RegExp(`${yearMonthDay}T${hourMinuteSecond}(\\.\\d+)?${zOrOffset}$`);
53746
+ let isTrimmed = value => isAbsent(value) || value === value.trim();
53747
+ let objStringTag = {}.toString();
53748
+ function create$6() {
53749
+ return new StringSchema();
53750
+ }
53751
+ class StringSchema extends Schema {
53752
+ constructor() {
53753
+ super({
53754
+ type: 'string',
53755
+ check(value) {
53756
+ if (value instanceof String) value = value.valueOf();
53757
+ return typeof value === 'string';
53758
+ }
53759
+ });
53760
+ this.withMutation(() => {
53761
+ this.transform((value, _raw, ctx) => {
53762
+ if (!ctx.spec.coerce || ctx.isType(value)) return value;
53763
+
53764
+ // don't ever convert arrays
53765
+ if (Array.isArray(value)) return value;
53766
+ const strValue = value != null && value.toString ? value.toString() : value;
53767
+
53768
+ // no one wants plain objects converted to [Object object]
53769
+ if (strValue === objStringTag) return value;
53770
+ return strValue;
53771
+ });
53772
+ });
53773
+ }
53774
+ required(message) {
53775
+ return super.required(message).withMutation(schema => schema.test({
53776
+ message: message || mixed.required,
53777
+ name: 'required',
53778
+ skipAbsent: true,
53779
+ test: value => !!value.length
53780
+ }));
53781
+ }
53782
+ notRequired() {
53783
+ return super.notRequired().withMutation(schema => {
53784
+ schema.tests = schema.tests.filter(t => t.OPTIONS.name !== 'required');
53785
+ return schema;
53786
+ });
53787
+ }
53788
+ length(length, message = string.length) {
53789
+ return this.test({
53790
+ message,
53791
+ name: 'length',
53792
+ exclusive: true,
53793
+ params: {
53794
+ length
53795
+ },
53796
+ skipAbsent: true,
53797
+ test(value) {
53798
+ return value.length === this.resolve(length);
53799
+ }
53800
+ });
53801
+ }
53802
+ min(min, message = string.min) {
53803
+ return this.test({
53804
+ message,
53805
+ name: 'min',
53806
+ exclusive: true,
53807
+ params: {
53808
+ min
53809
+ },
53810
+ skipAbsent: true,
53811
+ test(value) {
53812
+ return value.length >= this.resolve(min);
53813
+ }
53814
+ });
53815
+ }
53816
+ max(max, message = string.max) {
53817
+ return this.test({
53818
+ name: 'max',
53819
+ exclusive: true,
53820
+ message,
53821
+ params: {
53822
+ max
53823
+ },
53824
+ skipAbsent: true,
53825
+ test(value) {
53826
+ return value.length <= this.resolve(max);
53827
+ }
53828
+ });
53829
+ }
53830
+ matches(regex, options) {
53831
+ let excludeEmptyString = false;
53832
+ let message;
53833
+ let name;
53834
+ if (options) {
53835
+ if (typeof options === 'object') {
53836
+ ({
53837
+ excludeEmptyString = false,
53838
+ message,
53839
+ name
53840
+ } = options);
53841
+ } else {
53842
+ message = options;
53843
+ }
53844
+ }
53845
+ return this.test({
53846
+ name: name || 'matches',
53847
+ message: message || string.matches,
53848
+ params: {
53849
+ regex
53850
+ },
53851
+ skipAbsent: true,
53852
+ test: value => value === '' && excludeEmptyString || value.search(regex) !== -1
53853
+ });
53854
+ }
53855
+ email(message = string.email) {
53856
+ return this.matches(rEmail, {
53857
+ name: 'email',
53858
+ message,
53859
+ excludeEmptyString: true
53860
+ });
53861
+ }
53862
+ url(message = string.url) {
53863
+ return this.matches(rUrl, {
53864
+ name: 'url',
53865
+ message,
53866
+ excludeEmptyString: true
53867
+ });
53868
+ }
53869
+ uuid(message = string.uuid) {
53870
+ return this.matches(rUUID, {
53871
+ name: 'uuid',
53872
+ message,
53873
+ excludeEmptyString: false
53874
+ });
53875
+ }
53876
+ datetime(options) {
53877
+ let message = '';
53878
+ let allowOffset;
53879
+ let precision;
53880
+ if (options) {
53881
+ if (typeof options === 'object') {
53882
+ ({
53883
+ message = '',
53884
+ allowOffset = false,
53885
+ precision = undefined
53886
+ } = options);
53887
+ } else {
53888
+ message = options;
53889
+ }
53890
+ }
53891
+ return this.matches(rIsoDateTime, {
53892
+ name: 'datetime',
53893
+ message: message || string.datetime,
53894
+ excludeEmptyString: true
53895
+ }).test({
53896
+ name: 'datetime_offset',
53897
+ message: message || string.datetime_offset,
53898
+ params: {
53899
+ allowOffset
53900
+ },
53901
+ skipAbsent: true,
53902
+ test: value => {
53903
+ if (!value || allowOffset) return true;
53904
+ const struct = parseDateStruct(value);
53905
+ if (!struct) return false;
53906
+ return !!struct.z;
53907
+ }
53908
+ }).test({
53909
+ name: 'datetime_precision',
53910
+ message: message || string.datetime_precision,
53911
+ params: {
53912
+ precision
53913
+ },
53914
+ skipAbsent: true,
53915
+ test: value => {
53916
+ if (!value || precision == undefined) return true;
53917
+ const struct = parseDateStruct(value);
53918
+ if (!struct) return false;
53919
+ return struct.precision === precision;
53920
+ }
53921
+ });
53922
+ }
53923
+
53924
+ //-- transforms --
53925
+ ensure() {
53926
+ return this.default('').transform(val => val === null ? '' : val);
53927
+ }
53928
+ trim(message = string.trim) {
53929
+ return this.transform(val => val != null ? val.trim() : val).test({
53930
+ message,
53931
+ name: 'trim',
53932
+ test: isTrimmed
53933
+ });
53934
+ }
53935
+ lowercase(message = string.lowercase) {
53936
+ return this.transform(value => !isAbsent(value) ? value.toLowerCase() : value).test({
53937
+ message,
53938
+ name: 'string_case',
53939
+ exclusive: true,
53940
+ skipAbsent: true,
53941
+ test: value => isAbsent(value) || value === value.toLowerCase()
53942
+ });
53943
+ }
53944
+ uppercase(message = string.uppercase) {
53945
+ return this.transform(value => !isAbsent(value) ? value.toUpperCase() : value).test({
53946
+ message,
53947
+ name: 'string_case',
53948
+ exclusive: true,
53949
+ skipAbsent: true,
53950
+ test: value => isAbsent(value) || value === value.toUpperCase()
53951
+ });
53952
+ }
53953
+ }
53954
+ create$6.prototype = StringSchema.prototype;
53955
+
53956
+ //
53957
+ // String Interfaces
53958
+ //
53959
+
53960
+ let isNaN$1 = value => value != +value;
53961
+ function create$5() {
53962
+ return new NumberSchema();
53963
+ }
53964
+ class NumberSchema extends Schema {
53965
+ constructor() {
53966
+ super({
53967
+ type: 'number',
53968
+ check(value) {
53969
+ if (value instanceof Number) value = value.valueOf();
53970
+ return typeof value === 'number' && !isNaN$1(value);
53971
+ }
53972
+ });
53973
+ this.withMutation(() => {
53974
+ this.transform((value, _raw, ctx) => {
53975
+ if (!ctx.spec.coerce) return value;
53976
+ let parsed = value;
53977
+ if (typeof parsed === 'string') {
53978
+ parsed = parsed.replace(/\s/g, '');
53979
+ if (parsed === '') return NaN;
53980
+ // don't use parseFloat to avoid positives on alpha-numeric strings
53981
+ parsed = +parsed;
53982
+ }
53983
+
53984
+ // null -> NaN isn't useful; treat all nulls as null and let it fail on
53985
+ // nullability check vs TypeErrors
53986
+ if (ctx.isType(parsed) || parsed === null) return parsed;
53987
+ return parseFloat(parsed);
53988
+ });
53989
+ });
53990
+ }
53991
+ min(min, message = number.min) {
53992
+ return this.test({
53993
+ message,
53994
+ name: 'min',
53995
+ exclusive: true,
53996
+ params: {
53997
+ min
53998
+ },
53999
+ skipAbsent: true,
54000
+ test(value) {
54001
+ return value >= this.resolve(min);
54002
+ }
54003
+ });
54004
+ }
54005
+ max(max, message = number.max) {
54006
+ return this.test({
54007
+ message,
54008
+ name: 'max',
54009
+ exclusive: true,
54010
+ params: {
54011
+ max
54012
+ },
54013
+ skipAbsent: true,
54014
+ test(value) {
54015
+ return value <= this.resolve(max);
54016
+ }
54017
+ });
54018
+ }
54019
+ lessThan(less, message = number.lessThan) {
54020
+ return this.test({
54021
+ message,
54022
+ name: 'max',
54023
+ exclusive: true,
54024
+ params: {
54025
+ less
54026
+ },
54027
+ skipAbsent: true,
54028
+ test(value) {
54029
+ return value < this.resolve(less);
54030
+ }
54031
+ });
54032
+ }
54033
+ moreThan(more, message = number.moreThan) {
54034
+ return this.test({
54035
+ message,
54036
+ name: 'min',
54037
+ exclusive: true,
54038
+ params: {
54039
+ more
54040
+ },
54041
+ skipAbsent: true,
54042
+ test(value) {
54043
+ return value > this.resolve(more);
54044
+ }
54045
+ });
54046
+ }
54047
+ positive(msg = number.positive) {
54048
+ return this.moreThan(0, msg);
54049
+ }
54050
+ negative(msg = number.negative) {
54051
+ return this.lessThan(0, msg);
54052
+ }
54053
+ integer(message = number.integer) {
54054
+ return this.test({
54055
+ name: 'integer',
54056
+ message,
54057
+ skipAbsent: true,
54058
+ test: val => Number.isInteger(val)
54059
+ });
54060
+ }
54061
+ truncate() {
54062
+ return this.transform(value => !isAbsent(value) ? value | 0 : value);
54063
+ }
54064
+ round(method) {
54065
+ var _method;
54066
+ let avail = ['ceil', 'floor', 'round', 'trunc'];
54067
+ method = ((_method = method) == null ? void 0 : _method.toLowerCase()) || 'round';
54068
+
54069
+ // this exists for symemtry with the new Math.trunc
54070
+ if (method === 'trunc') return this.truncate();
54071
+ if (avail.indexOf(method.toLowerCase()) === -1) throw new TypeError('Only valid options for round() are: ' + avail.join(', '));
54072
+ return this.transform(value => !isAbsent(value) ? Math[method](value) : value);
54073
+ }
54074
+ }
54075
+ create$5.prototype = NumberSchema.prototype;
54076
+
54077
+ //
54078
+ // Number Interfaces
54079
+ //
54080
+
54081
+ let invalidDate = new Date('');
54082
+ let isDate = obj => Object.prototype.toString.call(obj) === '[object Date]';
54083
+ class DateSchema extends Schema {
54084
+ constructor() {
54085
+ super({
54086
+ type: 'date',
54087
+ check(v) {
54088
+ return isDate(v) && !isNaN(v.getTime());
54089
+ }
54090
+ });
54091
+ this.withMutation(() => {
54092
+ this.transform((value, _raw, ctx) => {
54093
+ // null -> InvalidDate isn't useful; treat all nulls as null and let it fail on
54094
+ // nullability check vs TypeErrors
54095
+ if (!ctx.spec.coerce || ctx.isType(value) || value === null) return value;
54096
+ value = parseIsoDate(value);
54097
+
54098
+ // 0 is a valid timestamp equivalent to 1970-01-01T00:00:00Z(unix epoch) or before.
54099
+ return !isNaN(value) ? new Date(value) : DateSchema.INVALID_DATE;
54100
+ });
54101
+ });
54102
+ }
54103
+ prepareParam(ref, name) {
54104
+ let param;
54105
+ if (!Reference.isRef(ref)) {
54106
+ let cast = this.cast(ref);
54107
+ if (!this._typeCheck(cast)) throw new TypeError(`\`${name}\` must be a Date or a value that can be \`cast()\` to a Date`);
54108
+ param = cast;
54109
+ } else {
54110
+ param = ref;
54111
+ }
54112
+ return param;
54113
+ }
54114
+ min(min, message = date.min) {
54115
+ let limit = this.prepareParam(min, 'min');
54116
+ return this.test({
54117
+ message,
54118
+ name: 'min',
54119
+ exclusive: true,
54120
+ params: {
54121
+ min
54122
+ },
54123
+ skipAbsent: true,
54124
+ test(value) {
54125
+ return value >= this.resolve(limit);
54126
+ }
54127
+ });
54128
+ }
54129
+ max(max, message = date.max) {
54130
+ let limit = this.prepareParam(max, 'max');
54131
+ return this.test({
54132
+ message,
54133
+ name: 'max',
54134
+ exclusive: true,
54135
+ params: {
54136
+ max
54137
+ },
54138
+ skipAbsent: true,
54139
+ test(value) {
54140
+ return value <= this.resolve(limit);
54141
+ }
54142
+ });
54143
+ }
54144
+ }
54145
+ DateSchema.INVALID_DATE = invalidDate;
54146
+ DateSchema.prototype;
54147
+
54148
+ // @ts-expect-error
54149
+ function sortFields(fields, excludedEdges = []) {
54150
+ let edges = [];
54151
+ let nodes = new Set();
54152
+ let excludes = new Set(excludedEdges.map(([a, b]) => `${a}-${b}`));
54153
+ function addNode(depPath, key) {
54154
+ let node = propertyExpr.split(depPath)[0];
54155
+ nodes.add(node);
54156
+ if (!excludes.has(`${key}-${node}`)) edges.push([key, node]);
54157
+ }
54158
+ for (const key of Object.keys(fields)) {
54159
+ let value = fields[key];
54160
+ nodes.add(key);
54161
+ if (Reference.isRef(value) && value.isSibling) addNode(value.path, key);else if (isSchema(value) && 'deps' in value) value.deps.forEach(path => addNode(path, key));
54162
+ }
54163
+ return toposort$1.array(Array.from(nodes), edges).reverse();
54164
+ }
54165
+
54166
+ function findIndex(arr, err) {
54167
+ let idx = Infinity;
54168
+ arr.some((key, ii) => {
54169
+ var _err$path;
54170
+ if ((_err$path = err.path) != null && _err$path.includes(key)) {
54171
+ idx = ii;
54172
+ return true;
54173
+ }
54174
+ });
54175
+ return idx;
54176
+ }
54177
+ function sortByKeyOrder(keys) {
54178
+ return (a, b) => {
54179
+ return findIndex(keys, a) - findIndex(keys, b);
54180
+ };
54181
+ }
54182
+
54183
+ const parseJson = (value, _, ctx) => {
54184
+ if (typeof value !== 'string') {
54185
+ return value;
54186
+ }
54187
+ let parsed = value;
54188
+ try {
54189
+ parsed = JSON.parse(value);
54190
+ } catch (err) {
54191
+ /* */
54192
+ }
54193
+ return ctx.isType(parsed) ? parsed : value;
54194
+ };
54195
+
54196
+ // @ts-ignore
54197
+ function deepPartial(schema) {
54198
+ if ('fields' in schema) {
54199
+ const partial = {};
54200
+ for (const [key, fieldSchema] of Object.entries(schema.fields)) {
54201
+ partial[key] = deepPartial(fieldSchema);
54202
+ }
54203
+ return schema.setFields(partial);
54204
+ }
54205
+ if (schema.type === 'array') {
54206
+ const nextArray = schema.optional();
54207
+ if (nextArray.innerType) nextArray.innerType = deepPartial(nextArray.innerType);
54208
+ return nextArray;
54209
+ }
54210
+ if (schema.type === 'tuple') {
54211
+ return schema.optional().clone({
54212
+ types: schema.spec.types.map(deepPartial)
54213
+ });
54214
+ }
54215
+ if ('optional' in schema) {
54216
+ return schema.optional();
54217
+ }
54218
+ return schema;
54219
+ }
54220
+ const deepHas = (obj, p) => {
54221
+ const path = [...propertyExpr.normalizePath(p)];
54222
+ if (path.length === 1) return path[0] in obj;
54223
+ let last = path.pop();
54224
+ let parent = propertyExpr.getter(propertyExpr.join(path), true)(obj);
54225
+ return !!(parent && last in parent);
54226
+ };
54227
+ let isObject = obj => Object.prototype.toString.call(obj) === '[object Object]';
54228
+ function unknown(ctx, value) {
54229
+ let known = Object.keys(ctx.fields);
54230
+ return Object.keys(value).filter(key => known.indexOf(key) === -1);
54231
+ }
54232
+ const defaultSort = sortByKeyOrder([]);
54233
+ function create$3(spec) {
54234
+ return new ObjectSchema(spec);
54235
+ }
54236
+ class ObjectSchema extends Schema {
54237
+ constructor(spec) {
54238
+ super({
54239
+ type: 'object',
54240
+ check(value) {
54241
+ return isObject(value) || typeof value === 'function';
54242
+ }
54243
+ });
54244
+ this.fields = Object.create(null);
54245
+ this._sortErrors = defaultSort;
54246
+ this._nodes = [];
54247
+ this._excludedEdges = [];
54248
+ this.withMutation(() => {
54249
+ if (spec) {
54250
+ this.shape(spec);
54251
+ }
54252
+ });
54253
+ }
54254
+ _cast(_value, options = {}) {
54255
+ var _options$stripUnknown;
54256
+ let value = super._cast(_value, options);
54257
+
54258
+ //should ignore nulls here
54259
+ if (value === undefined) return this.getDefault(options);
54260
+ if (!this._typeCheck(value)) return value;
54261
+ let fields = this.fields;
54262
+ let strip = (_options$stripUnknown = options.stripUnknown) != null ? _options$stripUnknown : this.spec.noUnknown;
54263
+ let props = [].concat(this._nodes, Object.keys(value).filter(v => !this._nodes.includes(v)));
54264
+ let intermediateValue = {}; // is filled during the transform below
54265
+ let innerOptions = Object.assign({}, options, {
54266
+ parent: intermediateValue,
54267
+ __validating: options.__validating || false
54268
+ });
54269
+ let isChanged = false;
54270
+ for (const prop of props) {
54271
+ let field = fields[prop];
54272
+ let exists = (prop in value);
54273
+ if (field) {
54274
+ let fieldValue;
54275
+ let inputValue = value[prop];
54276
+
54277
+ // safe to mutate since this is fired in sequence
54278
+ innerOptions.path = (options.path ? `${options.path}.` : '') + prop;
54279
+ field = field.resolve({
54280
+ value: inputValue,
54281
+ context: options.context,
54282
+ parent: intermediateValue
54283
+ });
54284
+ let fieldSpec = field instanceof Schema ? field.spec : undefined;
54285
+ let strict = fieldSpec == null ? void 0 : fieldSpec.strict;
54286
+ if (fieldSpec != null && fieldSpec.strip) {
54287
+ isChanged = isChanged || prop in value;
54288
+ continue;
54289
+ }
54290
+ fieldValue = !options.__validating || !strict ?
54291
+ // TODO: use _cast, this is double resolving
54292
+ field.cast(value[prop], innerOptions) : value[prop];
54293
+ if (fieldValue !== undefined) {
54294
+ intermediateValue[prop] = fieldValue;
54295
+ }
54296
+ } else if (exists && !strip) {
54297
+ intermediateValue[prop] = value[prop];
54298
+ }
54299
+ if (exists !== prop in intermediateValue || intermediateValue[prop] !== value[prop]) {
54300
+ isChanged = true;
54301
+ }
54302
+ }
54303
+ return isChanged ? intermediateValue : value;
54304
+ }
54305
+ _validate(_value, options = {}, panic, next) {
54306
+ let {
54307
+ from = [],
54308
+ originalValue = _value,
54309
+ recursive = this.spec.recursive
54310
+ } = options;
54311
+ options.from = [{
54312
+ schema: this,
54313
+ value: originalValue
54314
+ }, ...from];
54315
+ // this flag is needed for handling `strict` correctly in the context of
54316
+ // validation vs just casting. e.g strict() on a field is only used when validating
54317
+ options.__validating = true;
54318
+ options.originalValue = originalValue;
54319
+ super._validate(_value, options, panic, (objectErrors, value) => {
54320
+ if (!recursive || !isObject(value)) {
54321
+ next(objectErrors, value);
54322
+ return;
54323
+ }
54324
+ originalValue = originalValue || value;
54325
+ let tests = [];
54326
+ for (let key of this._nodes) {
54327
+ let field = this.fields[key];
54328
+ if (!field || Reference.isRef(field)) {
54329
+ continue;
54330
+ }
54331
+ tests.push(field.asNestedTest({
54332
+ options,
54333
+ key,
54334
+ parent: value,
54335
+ parentPath: options.path,
54336
+ originalParent: originalValue
54337
+ }));
54338
+ }
54339
+ this.runTests({
54340
+ tests,
54341
+ value,
54342
+ originalValue,
54343
+ options
54344
+ }, panic, fieldErrors => {
54345
+ next(fieldErrors.sort(this._sortErrors).concat(objectErrors), value);
54346
+ });
54347
+ });
54348
+ }
54349
+ clone(spec) {
54350
+ const next = super.clone(spec);
54351
+ next.fields = Object.assign({}, this.fields);
54352
+ next._nodes = this._nodes;
54353
+ next._excludedEdges = this._excludedEdges;
54354
+ next._sortErrors = this._sortErrors;
54355
+ return next;
54356
+ }
54357
+ concat(schema) {
54358
+ let next = super.concat(schema);
54359
+ let nextFields = next.fields;
54360
+ for (let [field, schemaOrRef] of Object.entries(this.fields)) {
54361
+ const target = nextFields[field];
54362
+ nextFields[field] = target === undefined ? schemaOrRef : target;
54363
+ }
54364
+ return next.withMutation(s =>
54365
+ // XXX: excludes here is wrong
54366
+ s.setFields(nextFields, [...this._excludedEdges, ...schema._excludedEdges]));
54367
+ }
54368
+ _getDefault(options) {
54369
+ if ('default' in this.spec) {
54370
+ return super._getDefault(options);
54371
+ }
54372
+
54373
+ // if there is no default set invent one
54374
+ if (!this._nodes.length) {
54375
+ return undefined;
54376
+ }
54377
+ let dft = {};
54378
+ this._nodes.forEach(key => {
54379
+ var _innerOptions;
54380
+ const field = this.fields[key];
54381
+ let innerOptions = options;
54382
+ if ((_innerOptions = innerOptions) != null && _innerOptions.value) {
54383
+ innerOptions = Object.assign({}, innerOptions, {
54384
+ parent: innerOptions.value,
54385
+ value: innerOptions.value[key]
54386
+ });
54387
+ }
54388
+ dft[key] = field && 'getDefault' in field ? field.getDefault(innerOptions) : undefined;
54389
+ });
54390
+ return dft;
54391
+ }
54392
+ setFields(shape, excludedEdges) {
54393
+ let next = this.clone();
54394
+ next.fields = shape;
54395
+ next._nodes = sortFields(shape, excludedEdges);
54396
+ next._sortErrors = sortByKeyOrder(Object.keys(shape));
54397
+ // XXX: this carries over edges which may not be what you want
54398
+ if (excludedEdges) next._excludedEdges = excludedEdges;
54399
+ return next;
54400
+ }
54401
+ shape(additions, excludes = []) {
54402
+ return this.clone().withMutation(next => {
54403
+ let edges = next._excludedEdges;
54404
+ if (excludes.length) {
54405
+ if (!Array.isArray(excludes[0])) excludes = [excludes];
54406
+ edges = [...next._excludedEdges, ...excludes];
54407
+ }
54408
+
54409
+ // XXX: excludes here is wrong
54410
+ return next.setFields(Object.assign(next.fields, additions), edges);
54411
+ });
54412
+ }
54413
+ partial() {
54414
+ const partial = {};
54415
+ for (const [key, schema] of Object.entries(this.fields)) {
54416
+ partial[key] = 'optional' in schema && schema.optional instanceof Function ? schema.optional() : schema;
54417
+ }
54418
+ return this.setFields(partial);
54419
+ }
54420
+ deepPartial() {
54421
+ const next = deepPartial(this);
54422
+ return next;
54423
+ }
54424
+ pick(keys) {
54425
+ const picked = {};
54426
+ for (const key of keys) {
54427
+ if (this.fields[key]) picked[key] = this.fields[key];
54428
+ }
54429
+ return this.setFields(picked, this._excludedEdges.filter(([a, b]) => keys.includes(a) && keys.includes(b)));
54430
+ }
54431
+ omit(keys) {
54432
+ const remaining = [];
54433
+ for (const key of Object.keys(this.fields)) {
54434
+ if (keys.includes(key)) continue;
54435
+ remaining.push(key);
54436
+ }
54437
+ return this.pick(remaining);
54438
+ }
54439
+ from(from, to, alias) {
54440
+ let fromGetter = propertyExpr.getter(from, true);
54441
+ return this.transform(obj => {
54442
+ if (!obj) return obj;
54443
+ let newObj = obj;
54444
+ if (deepHas(obj, from)) {
54445
+ newObj = Object.assign({}, obj);
54446
+ if (!alias) delete newObj[from];
54447
+ newObj[to] = fromGetter(obj);
54448
+ }
54449
+ return newObj;
54450
+ });
54451
+ }
54452
+
54453
+ /** Parse an input JSON string to an object */
54454
+ json() {
54455
+ return this.transform(parseJson);
54456
+ }
54457
+ noUnknown(noAllow = true, message = object.noUnknown) {
54458
+ if (typeof noAllow !== 'boolean') {
54459
+ message = noAllow;
54460
+ noAllow = true;
54461
+ }
54462
+ let next = this.test({
54463
+ name: 'noUnknown',
54464
+ exclusive: true,
54465
+ message: message,
54466
+ test(value) {
54467
+ if (value == null) return true;
54468
+ const unknownKeys = unknown(this.schema, value);
54469
+ return !noAllow || unknownKeys.length === 0 || this.createError({
54470
+ params: {
54471
+ unknown: unknownKeys.join(', ')
54472
+ }
54473
+ });
54474
+ }
54475
+ });
54476
+ next.spec.noUnknown = noAllow;
54477
+ return next;
54478
+ }
54479
+ unknown(allow = true, message = object.noUnknown) {
54480
+ return this.noUnknown(!allow, message);
54481
+ }
54482
+ transformKeys(fn) {
54483
+ return this.transform(obj => {
54484
+ if (!obj) return obj;
54485
+ const result = {};
54486
+ for (const key of Object.keys(obj)) result[fn(key)] = obj[key];
54487
+ return result;
54488
+ });
54489
+ }
54490
+ camelCase() {
54491
+ return this.transformKeys(tinyCase.camelCase);
54492
+ }
54493
+ snakeCase() {
54494
+ return this.transformKeys(tinyCase.snakeCase);
54495
+ }
54496
+ constantCase() {
54497
+ return this.transformKeys(key => tinyCase.snakeCase(key).toUpperCase());
54498
+ }
54499
+ describe(options) {
54500
+ const next = (options ? this.resolve(options) : this).clone();
54501
+ const base = super.describe(options);
54502
+ base.fields = {};
54503
+ for (const [key, value] of Object.entries(next.fields)) {
54504
+ var _innerOptions2;
54505
+ let innerOptions = options;
54506
+ if ((_innerOptions2 = innerOptions) != null && _innerOptions2.value) {
54507
+ innerOptions = Object.assign({}, innerOptions, {
54508
+ parent: innerOptions.value,
54509
+ value: innerOptions.value[key]
54510
+ });
54511
+ }
54512
+ base.fields[key] = value.describe(innerOptions);
54513
+ }
54514
+ return base;
54515
+ }
54516
+ }
54517
+ create$3.prototype = ObjectSchema.prototype;
54518
+
54519
+ var t=function(t,n,e){if(t&&"reportValidity"in t){var i=get(e,n);t.setCustomValidity(i&&i.message||""),t.reportValidity();}},n=function(r,n){var e=function(e){var i=n.fields[e];i&&i.ref&&"reportValidity"in i.ref?t(i.ref,e,r):i.refs&&i.refs.forEach(function(n){return t(n,e,r)});};for(var i in n.fields)e(i);},e=function(r){return r instanceof Date},i=function(r){return null==r},a=function(r){return "object"==typeof r},o$1=function(r){return !i(r)&&!Array.isArray(r)&&a(r)&&!e(r)},f=function(r){return /^\w*$/.test(r)},s=function(r,t,n){for(var e=-1,i=f(t)?[t]:function(r){return t=r.replace(/["|']|\]/g,"").split(/\.|\[/),Array.isArray(t)?t.filter(Boolean):[];var t;}(t),a=i.length,s=a-1;++e<a;){var u=i[e],c=n;if(e!==s){var l=r[u];c=o$1(l)||Array.isArray(l)?l:isNaN(+i[e+1])?{}:[];}r[u]=c,r=r[u];}return r},u=function(t,e){e.shouldUseNativeValidation&&n(t,e);var i={};for(var a in t){var o=get(e.fields,a),f=Object.assign(t[a]||{},{ref:o&&o.ref});if(c(e.names||Object.keys(t),a)){var u=Object.assign({},get(i,a));s(u,"root",f),s(i,a,u);}else s(i,a,f);}return i},c=function(r,t){return r.some(function(r){return r.startsWith(t+".")})};
54520
+
54521
+ function o(o,n$1,a){return void 0===n$1&&(n$1={}),void 0===a&&(a={}),function(s,i,c){try{return Promise.resolve(function(t,r){try{var u=(n$1.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$1,{context:i}))).then(function(t){return c.shouldUseNativeValidation&&n({},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:u((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)}}}
54522
+
54523
+ const FormRenderWrapper = ({ formArray, name, setFormFunctions, numberOfColumns = 3 }) => {
54524
+ const initialValues = {};
54525
+ const validationShape = {};
54526
+ formArray.forEach((field) => {
54527
+ switch (field.inputType) {
54528
+ case "text":
54529
+ initialValues[field.name] = "";
54530
+ if (field.required) {
54531
+ validationShape[field.name] = create$6()
54532
+ .typeError(`Select ${field.label}`)
54533
+ .required(field.errorMessage);
54534
+ }
54535
+ break;
54536
+ case "number":
54537
+ initialValues[field.name] = null;
54538
+ if (field.required) {
54539
+ validationShape[field.name] = create$5()
54540
+ .nullable()
54541
+ .typeError(`Enters ${field.label}`)
54542
+ .required(field.errorMessage);
54543
+ }
54544
+ break;
54545
+ case "password":
54546
+ initialValues[field.name] = '';
54547
+ if (field.required) {
54548
+ validationShape[field.name] = create$5()
54549
+ .nullable()
54550
+ .typeError(`Enters ${field.label}`)
54551
+ .required(field.errorMessage);
54552
+ }
54553
+ break;
54554
+ case "select":
54555
+ initialValues[field.name] = "";
54556
+ if (field.required) {
54557
+ validationShape[field.name] = create$6()
54558
+ .typeError(`Select ${field.label}`)
54559
+ .required(field.errorMessage);
54560
+ }
54561
+ break;
54562
+ case "multiselect":
54563
+ initialValues[field.name] = null;
54564
+ if (field.required) {
54565
+ validationShape[field.name] = validationShape[field.name] = create$6()
54566
+ .typeError(`Select atleast one ${field.label}`)
54567
+ .required(field.errorMessage);
54568
+ }
54569
+ break;
54570
+ default:
54571
+ initialValues[field.name] = null; // default value if inputType is not recognized
54572
+ if (field.required) {
54573
+ validationShape[field.name] = create$8().required(field.errorMessage);
54574
+ }
54575
+ break;
54576
+ }
54577
+ });
54578
+ const validationSchema = create$3().shape(validationShape);
54579
+ const { register, handleSubmit, setValue, clearErrors, watch, control, getValues, reset, formState: { errors }, } = useForm({
54580
+ defaultValues: initialValues,
54581
+ resolver: o(validationSchema),
54582
+ });
54583
+ useEffect(() => {
54584
+ setFormFunctions({
54585
+ handleSubmit,
54586
+ setValue,
54587
+ clearErrors,
54588
+ watch,
54589
+ control,
54590
+ getValues,
54591
+ reset,
54592
+ });
54593
+ }, [
54594
+ handleSubmit,
54595
+ setFormFunctions,
54596
+ setValue,
54597
+ watch,
54598
+ register,
54599
+ control,
54600
+ errors,
54601
+ getValues,
54602
+ reset,
54603
+ clearErrors,
54604
+ ]);
54605
+ return jsxRuntimeExports.jsx(FormComponent, Object.assign({ container: true, margin: "auto" }, { children: formArray.map((item, i) => {
54606
+ return (jsxRuntimeExports.jsx(Formitem, Object.assign({ container: true, sx: item.CustomProps, noOfColumn: item.numberOfColumns || numberOfColumns }, { children: jsxRuntimeExports.jsx(RenderForm, { item: item, register: register, control: control, errors: errors, getValues: getValues, clearErrors: clearErrors, setValue: setValue }) }), i));
54607
+ }) }));
54608
+ };
54609
+
54610
+ export { Button$1 as Button, FormRenderWrapper as RenderForm };
50623
54611
  //# sourceMappingURL=index.esm.js.map