vee-validate 4.9.1 → 4.9.3

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.
@@ -226,6 +226,9 @@ interface PathState<TValue = unknown> {
226
226
  type: InputType;
227
227
  multiple: boolean;
228
228
  fieldsCount: number;
229
+ __flags: {
230
+ pendingUnmount: Record<string, boolean>;
231
+ };
229
232
  validate?: FieldValidator;
230
233
  }
231
234
  interface FieldEntry<TValue = unknown> {
@@ -328,6 +331,7 @@ interface PrivateFormContext<TValues extends GenericObject = GenericObject, TOut
328
331
  errors: ComputedRef<FormErrors<TValues>>;
329
332
  meta: ComputedRef<FormMeta<TValues>>;
330
333
  isSubmitting: Ref<boolean>;
334
+ isValidating: Ref<boolean>;
331
335
  keepValuesOnUnmount: MaybeRef<boolean>;
332
336
  validateSchema?: (mode: SchemaValidationMode) => Promise<FormValidationResult<TValues, TOutput>>;
333
337
  validate(opts?: Partial<ValidationOptions$1>): Promise<FormValidationResult<TValues, TOutput>>;
@@ -343,15 +347,16 @@ interface PrivateFormContext<TValues extends GenericObject = GenericObject, TOut
343
347
  createPathState<TPath extends Path<TValues>>(path: MaybeRef<TPath>, config?: Partial<PathStateConfig>): PathState<PathValue<TValues, TPath>>;
344
348
  getPathState<TPath extends Path<TValues>>(path: TPath): PathState<PathValue<TValues, TPath>> | undefined;
345
349
  getAllPathStates(): PathState[];
346
- removePathState<TPath extends Path<TValues>>(path: TPath): void;
350
+ removePathState<TPath extends Path<TValues>>(path: TPath, id: number): void;
347
351
  unsetPathValue<TPath extends Path<TValues>>(path: TPath): void;
352
+ markForUnmount(path: string): void;
348
353
  }
349
354
  interface BaseComponentBinds<TValue = unknown> {
350
355
  modelValue: TValue | undefined;
351
356
  'onUpdate:modelValue': (value: TValue) => void;
352
357
  onBlur: () => void;
353
358
  }
354
- type PublicPathState<TValue = unknown> = Omit<PathState<TValue>, 'bails' | 'label' | 'multiple' | 'fieldsCount' | 'validate' | 'id' | 'type'>;
359
+ type PublicPathState<TValue = unknown> = Omit<PathState<TValue>, 'bails' | 'label' | 'multiple' | 'fieldsCount' | 'validate' | 'id' | 'type' | '__flags'>;
355
360
  interface ComponentBindsConfig<TValue = unknown, TExtraProps extends GenericObject = GenericObject> {
356
361
  mapProps: (state: PublicPathState<TValue>) => TExtraProps;
357
362
  validateOnBlur: boolean;
@@ -380,7 +385,7 @@ type LazyInputBindsConfig<TValue = unknown, TExtraProps extends GenericObject =
380
385
  validateOnChange: boolean;
381
386
  validateOnInput: boolean;
382
387
  }>;
383
- interface FormContext<TValues extends GenericObject = GenericObject, TOutput = TValues> extends Omit<PrivateFormContext<TValues, TOutput>, 'formId' | 'schema' | 'initialValues' | 'getPathState' | 'getAllPathStates' | 'removePathState' | 'unsetPathValue' | 'validateSchema' | 'stageInitialValue' | 'setFieldInitialValue' | 'unsetInitialValue' | 'fieldArrays' | 'keepValuesOnUnmount'> {
388
+ interface FormContext<TValues extends GenericObject = GenericObject, TOutput = TValues> extends Omit<PrivateFormContext<TValues, TOutput>, 'formId' | 'schema' | 'initialValues' | 'getPathState' | 'getAllPathStates' | 'removePathState' | 'unsetPathValue' | 'validateSchema' | 'stageInitialValue' | 'setFieldInitialValue' | 'unsetInitialValue' | 'fieldArrays' | 'markForUnmount' | 'keepValuesOnUnmount'> {
384
389
  handleReset: () => void;
385
390
  submitForm: (e?: unknown) => Promise<void>;
386
391
  defineComponentBinds<TPath extends Path<TValues>, TValue = PathValue<TValues, TPath>, TExtras extends GenericObject = GenericObject>(path: MaybeRefOrLazy<TPath>, config?: Partial<ComponentBindsConfig<TValue, TExtras>> | LazyComponentBindsConfig<TValue, TExtras>): Ref<BaseComponentBinds<TValue> & TExtras>;
@@ -845,7 +850,7 @@ declare const Field: {
845
850
  };
846
851
  });
847
852
 
848
- type FormSlotProps = UnwrapRef<Pick<FormContext, 'meta' | 'errors' | 'errorBag' | 'values' | 'isSubmitting' | 'submitCount' | 'validate' | 'validateField' | 'handleReset' | 'setErrors' | 'setFieldError' | 'setFieldValue' | 'setValues' | 'setFieldTouched' | 'setTouched' | 'resetForm' | 'resetField' | 'controlledValues'>> & {
853
+ type FormSlotProps = UnwrapRef<Pick<FormContext, 'meta' | 'errors' | 'errorBag' | 'values' | 'isSubmitting' | 'isValidating' | 'submitCount' | 'validate' | 'validateField' | 'handleReset' | 'setErrors' | 'setFieldError' | 'setFieldValue' | 'setValues' | 'setFieldTouched' | 'setTouched' | 'resetForm' | 'resetField' | 'controlledValues'>> & {
849
854
  handleSubmit: (evt: Event | SubmissionHandler, onSubmit?: SubmissionHandler) => Promise<unknown>;
850
855
  submitForm(evt?: Event): void;
851
856
  getValues<TValues extends GenericObject = GenericObject>(): TValues;
@@ -1361,6 +1366,11 @@ declare function useIsFieldValid(path?: MaybeRef<string>): vue.ComputedRef<boole
1361
1366
  */
1362
1367
  declare function useIsSubmitting(): vue.ComputedRef<boolean>;
1363
1368
 
1369
+ /**
1370
+ * If the form is validating or not
1371
+ */
1372
+ declare function useIsValidating(): vue.ComputedRef<boolean>;
1373
+
1364
1374
  /**
1365
1375
  * Validates a single field
1366
1376
  */
@@ -1417,4 +1427,4 @@ declare const FormContextKey: InjectionKey<PrivateFormContext>;
1417
1427
  declare const FieldContextKey: InjectionKey<PrivateFieldContext<unknown>>;
1418
1428
  declare const IS_ABSENT: any;
1419
1429
 
1420
- export { ComponentBindsConfig, ErrorMessage, Field, FieldArray, FieldArrayContext, FieldContext, FieldContextKey, FieldEntry, FieldMeta, FieldOptions, FieldState, Form, FormActions, FormContext, FormContextKey, FormMeta, FormOptions, FormState, FormValidationResult, GenericValidateFunction, IS_ABSENT, InputBindsConfig, InvalidSubmissionContext, InvalidSubmissionHandler, LazyComponentBindsConfig, LazyInputBindsConfig, Path, PublicPathState as PathState, RawFormSchema, RuleExpression, SubmissionContext, SubmissionHandler, TypedSchema, TypedSchemaError, ValidationOptions$1 as ValidationOptions, ValidationResult, configure, defineRule, useField, useFieldArray, useFieldError, useFieldValue, useForm, useFormErrors, useFormValues, useIsFieldDirty, useIsFieldTouched, useIsFieldValid, useIsFormDirty, useIsFormTouched, useIsFormValid, useIsSubmitting, useResetForm, useSubmitCount, useSubmitForm, useValidateField, useValidateForm, validate, validateObjectSchema as validateObject };
1430
+ export { ComponentBindsConfig, ErrorMessage, Field, FieldArray, FieldArrayContext, FieldContext, FieldContextKey, FieldEntry, FieldMeta, FieldOptions, FieldState, Form, FormActions, FormContext, FormContextKey, FormMeta, FormOptions, FormState, FormValidationResult, GenericValidateFunction, IS_ABSENT, InputBindsConfig, InvalidSubmissionContext, InvalidSubmissionHandler, LazyComponentBindsConfig, LazyInputBindsConfig, Path, PublicPathState as PathState, RawFormSchema, RuleExpression, SubmissionContext, SubmissionHandler, TypedSchema, TypedSchemaError, ValidationOptions$1 as ValidationOptions, ValidationResult, configure, defineRule, useField, useFieldArray, useFieldError, useFieldValue, useForm, useFormErrors, useFormValues, useIsFieldDirty, useIsFieldTouched, useIsFieldValid, useIsFormDirty, useIsFormTouched, useIsFormValid, useIsSubmitting, useIsValidating, useResetForm, useSubmitCount, useSubmitForm, useValidateField, useValidateForm, validate, validateObjectSchema as validateObject };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * vee-validate v4.9.1
2
+ * vee-validate v4.9.3
3
3
  * (c) 2023 Abdelrahman Awad
4
4
  * @license MIT
5
5
  */
@@ -971,6 +971,7 @@ function useFieldState(path, init) {
971
971
  value,
972
972
  initialValue,
973
973
  meta,
974
+ flags: { pendingUnmount: { [id]: false } },
974
975
  errors,
975
976
  setState,
976
977
  };
@@ -1004,6 +1005,7 @@ function useFieldState(path, init) {
1004
1005
  errors,
1005
1006
  meta: state,
1006
1007
  initialValue,
1008
+ flags: state.__flags,
1007
1009
  setState,
1008
1010
  };
1009
1011
  }
@@ -1430,7 +1432,7 @@ function buildFieldState(state) {
1430
1432
  };
1431
1433
  }
1432
1434
  function buildFormState(form) {
1433
- const { errorBag, meta, values, isSubmitting, submitCount } = form;
1435
+ const { errorBag, meta, values, isSubmitting, isValidating, submitCount } = form;
1434
1436
  return {
1435
1437
  'Form state': [
1436
1438
  {
@@ -1441,6 +1443,10 @@ function buildFormState(form) {
1441
1443
  key: 'isSubmitting',
1442
1444
  value: isSubmitting.value,
1443
1445
  },
1446
+ {
1447
+ key: 'isValidating',
1448
+ value: isValidating.value,
1449
+ },
1444
1450
  {
1445
1451
  key: 'touched',
1446
1452
  value: meta.value.touched,
@@ -1499,7 +1505,6 @@ function _useField(path, rules, opts) {
1499
1505
  const injectedForm = controlled ? injectWithSelf(FormContextKey) : undefined;
1500
1506
  const form = controlForm || injectedForm;
1501
1507
  const name = lazyToRef(path);
1502
- let PENDING_UNMOUNT = false;
1503
1508
  const validator = computed(() => {
1504
1509
  const schema = unref(form === null || form === void 0 ? void 0 : form.schema);
1505
1510
  if (schema) {
@@ -1514,7 +1519,7 @@ function _useField(path, rules, opts) {
1514
1519
  }
1515
1520
  return normalizeRules(rulesValue);
1516
1521
  });
1517
- const { id, value, initialValue, meta, setState, errors } = useFieldState(name, {
1522
+ const { id, value, initialValue, meta, setState, errors, flags } = useFieldState(name, {
1518
1523
  modelValue,
1519
1524
  form,
1520
1525
  bails,
@@ -1552,7 +1557,7 @@ function _useField(path, rules, opts) {
1552
1557
  meta.validated = true;
1553
1558
  return validateCurrentValue('validated-only');
1554
1559
  }, result => {
1555
- if (PENDING_UNMOUNT) {
1560
+ if (flags.pendingUnmount[field.id]) {
1556
1561
  return;
1557
1562
  }
1558
1563
  setState({ errors: result.errors });
@@ -1575,10 +1580,7 @@ function _useField(path, rules, opts) {
1575
1580
  // Common input/change event handler
1576
1581
  function handleChange(e, shouldValidate = true) {
1577
1582
  const newValue = normalizeEventValue(e);
1578
- setValue(newValue, false);
1579
- if (!validateOnValueUpdate && shouldValidate) {
1580
- validateWithStateMutation();
1581
- }
1583
+ setValue(newValue, shouldValidate);
1582
1584
  }
1583
1585
  // Runs the initial validation
1584
1586
  onMounted(() => {
@@ -1607,12 +1609,13 @@ function _useField(path, rules, opts) {
1607
1609
  meta.validated = false;
1608
1610
  validateValidStateOnly();
1609
1611
  }
1610
- function setValue(newValue, validate = true) {
1612
+ function setValue(newValue, shouldValidate = true) {
1611
1613
  value.value = newValue;
1612
- if (!validate) {
1614
+ if (!shouldValidate) {
1615
+ validateValidStateOnly();
1613
1616
  return;
1614
1617
  }
1615
- const validateFn = validateOnValueUpdate ? validateWithStateMutation : validateValidStateOnly;
1618
+ const validateFn = shouldValidate ? validateWithStateMutation : validateValidStateOnly;
1616
1619
  validateFn();
1617
1620
  }
1618
1621
  function setErrors(errors) {
@@ -1722,12 +1725,13 @@ function _useField(path, rules, opts) {
1722
1725
  });
1723
1726
  onBeforeUnmount(() => {
1724
1727
  var _a;
1725
- PENDING_UNMOUNT = true;
1726
1728
  const shouldKeepValue = (_a = unref(field.keepValueOnUnmount)) !== null && _a !== void 0 ? _a : unref(form.keepValuesOnUnmount);
1727
- if (shouldKeepValue || !form) {
1729
+ const path = unravel(name);
1730
+ if (shouldKeepValue || !form || flags.pendingUnmount[field.id]) {
1731
+ form === null || form === void 0 ? void 0 : form.removePathState(path, id);
1728
1732
  return;
1729
1733
  }
1730
- const path = unravel(name);
1734
+ flags.pendingUnmount[field.id] = true;
1731
1735
  const pathState = form.getPathState(path);
1732
1736
  const matchesId = Array.isArray(pathState === null || pathState === void 0 ? void 0 : pathState.id) && (pathState === null || pathState === void 0 ? void 0 : pathState.multiple)
1733
1737
  ? pathState === null || pathState === void 0 ? void 0 : pathState.id.includes(field.id)
@@ -1747,9 +1751,9 @@ function _useField(path, rules, opts) {
1747
1751
  }
1748
1752
  }
1749
1753
  else {
1750
- form.unsetPathValue(path);
1754
+ form.unsetPathValue(unravel(name));
1751
1755
  }
1752
- form.removePathState(path);
1756
+ form.removePathState(path, id);
1753
1757
  });
1754
1758
  return field;
1755
1759
  }
@@ -1953,15 +1957,6 @@ const FieldImpl = defineComponent({
1953
1957
  handleChange(e, shouldValidate);
1954
1958
  ctx.emit('update:modelValue', value.value);
1955
1959
  };
1956
- const handleInput = (e) => {
1957
- if (!hasCheckedAttr(ctx.attrs.type)) {
1958
- value.value = normalizeEventValue(e);
1959
- }
1960
- };
1961
- const onInputHandler = function handleInputWithModel(e) {
1962
- handleInput(e);
1963
- ctx.emit('update:modelValue', value.value);
1964
- };
1965
1960
  const fieldProps = computed(() => {
1966
1961
  const { validateOnInput, validateOnChange, validateOnBlur, validateOnModelUpdate } = resolveValidationTriggers(props);
1967
1962
  function baseOnBlur(e) {
@@ -2011,7 +2006,7 @@ const FieldImpl = defineComponent({
2011
2006
  validate: validateField,
2012
2007
  resetField,
2013
2008
  handleChange: onChangeHandler,
2014
- handleInput: onInputHandler,
2009
+ handleInput: e => onChangeHandler(e, false),
2015
2010
  handleReset,
2016
2011
  handleBlur,
2017
2012
  setTouched,
@@ -2079,6 +2074,8 @@ function useForm(opts) {
2079
2074
  let FIELD_ID_COUNTER = 0;
2080
2075
  // If the form is currently submitting
2081
2076
  const isSubmitting = ref(false);
2077
+ // If the form is currently validating
2078
+ const isValidating = ref(false);
2082
2079
  // The number of times the user tried to submit the form
2083
2080
  const submitCount = ref(0);
2084
2081
  // field arrays managed by this form
@@ -2168,19 +2165,22 @@ function useForm(opts) {
2168
2165
  if ((config === null || config === void 0 ? void 0 : config.type) === 'checkbox' || (config === null || config === void 0 ? void 0 : config.type) === 'radio') {
2169
2166
  pathStateExists.multiple = true;
2170
2167
  }
2168
+ const id = FIELD_ID_COUNTER++;
2171
2169
  if (Array.isArray(pathStateExists.id)) {
2172
- pathStateExists.id.push(FIELD_ID_COUNTER++);
2170
+ pathStateExists.id.push(id);
2173
2171
  }
2174
2172
  else {
2175
- pathStateExists.id = [pathStateExists.id, FIELD_ID_COUNTER++];
2173
+ pathStateExists.id = [pathStateExists.id, id];
2176
2174
  }
2177
2175
  pathStateExists.fieldsCount++;
2176
+ pathStateExists.__flags.pendingUnmount[id] = false;
2178
2177
  return pathStateExists;
2179
2178
  }
2180
2179
  const currentValue = computed(() => getFromPath(formValues, unravel(path)));
2181
2180
  const pathValue = unravel(path);
2181
+ const id = FIELD_ID_COUNTER++;
2182
2182
  const state = reactive({
2183
- id: FIELD_ID_COUNTER++,
2183
+ id,
2184
2184
  path,
2185
2185
  touched: false,
2186
2186
  pending: false,
@@ -2193,6 +2193,9 @@ function useForm(opts) {
2193
2193
  type: (config === null || config === void 0 ? void 0 : config.type) || 'default',
2194
2194
  value: currentValue,
2195
2195
  multiple: false,
2196
+ __flags: {
2197
+ pendingUnmount: { [id]: false },
2198
+ },
2196
2199
  fieldsCount: 1,
2197
2200
  validate: config === null || config === void 0 ? void 0 : config.validate,
2198
2201
  dirty: computed(() => {
@@ -2233,11 +2236,11 @@ function useForm(opts) {
2233
2236
  // this ensures we have a complete key map of all the fields
2234
2237
  const paths = [
2235
2238
  ...new Set([...keysOf(formResult.results), ...pathStates.value.map(p => p.path), ...currentErrorsPaths]),
2236
- ];
2239
+ ].sort();
2237
2240
  // aggregates the paths into a single result object while applying the results on the fields
2238
2241
  return paths.reduce((validation, _path) => {
2239
2242
  const path = _path;
2240
- const pathState = findPathState(path);
2243
+ const pathState = findPathState(path) || findHoistedPath(path);
2241
2244
  const messages = (formResult.results[path] || { errors: [] }).errors;
2242
2245
  const fieldResult = {
2243
2246
  errors: messages,
@@ -2275,8 +2278,30 @@ function useForm(opts) {
2275
2278
  const pathState = typeof path === 'string' ? pathStates.value.find(state => state.path === path) : path;
2276
2279
  return pathState;
2277
2280
  }
2281
+ function findHoistedPath(path) {
2282
+ const candidates = pathStates.value.filter(state => path.startsWith(state.path));
2283
+ return candidates.reduce((bestCandidate, candidate) => {
2284
+ if (!bestCandidate) {
2285
+ return candidate;
2286
+ }
2287
+ return (candidate.path.length > bestCandidate.path.length ? candidate : bestCandidate);
2288
+ }, undefined);
2289
+ }
2290
+ let UNSET_BATCH = [];
2291
+ let PENDING_UNSET;
2278
2292
  function unsetPathValue(path) {
2279
- unsetPath(formValues, path);
2293
+ UNSET_BATCH.push(path);
2294
+ if (!PENDING_UNSET) {
2295
+ PENDING_UNSET = nextTick(() => {
2296
+ const sortedPaths = [...UNSET_BATCH].sort().reverse();
2297
+ sortedPaths.forEach(p => {
2298
+ unsetPath(formValues, p);
2299
+ });
2300
+ UNSET_BATCH = [];
2301
+ PENDING_UNSET = null;
2302
+ });
2303
+ }
2304
+ return PENDING_UNSET;
2280
2305
  }
2281
2306
  function makeSubmissionFactory(onlyControlled) {
2282
2307
  return function submitHandlerFactory(fn, onValidationError) {
@@ -2334,7 +2359,7 @@ function useForm(opts) {
2334
2359
  const handleSubmitImpl = makeSubmissionFactory(false);
2335
2360
  const handleSubmit = handleSubmitImpl;
2336
2361
  handleSubmit.withControlled = makeSubmissionFactory(true);
2337
- function removePathState(path) {
2362
+ function removePathState(path, id) {
2338
2363
  const idx = pathStates.value.findIndex(s => s.path === path);
2339
2364
  const pathState = pathStates.value[idx];
2340
2365
  if (idx === -1 || !pathState) {
@@ -2343,11 +2368,27 @@ function useForm(opts) {
2343
2368
  if (pathState.multiple && pathState.fieldsCount) {
2344
2369
  pathState.fieldsCount--;
2345
2370
  }
2371
+ if (Array.isArray(pathState.id)) {
2372
+ const idIndex = pathState.id.indexOf(id);
2373
+ if (idIndex >= 0) {
2374
+ pathState.id.splice(idIndex, 1);
2375
+ }
2376
+ delete pathState.__flags.pendingUnmount[id];
2377
+ }
2346
2378
  if (!pathState.multiple || pathState.fieldsCount <= 0) {
2347
2379
  pathStates.value.splice(idx, 1);
2348
2380
  unsetInitialValue(path);
2349
2381
  }
2350
2382
  }
2383
+ function markForUnmount(path) {
2384
+ return mutateAllPathState(s => {
2385
+ if (s.path.startsWith(path)) {
2386
+ keysOf(s.__flags.pendingUnmount).forEach(id => {
2387
+ s.__flags.pendingUnmount[id] = true;
2388
+ });
2389
+ }
2390
+ });
2391
+ }
2351
2392
  const formCtx = {
2352
2393
  formId,
2353
2394
  values: formValues,
@@ -2358,6 +2399,7 @@ function useForm(opts) {
2358
2399
  submitCount,
2359
2400
  meta,
2360
2401
  isSubmitting,
2402
+ isValidating,
2361
2403
  fieldArrays,
2362
2404
  keepValuesOnUnmount,
2363
2405
  validateSchema: unref(schema) ? validateSchema : undefined,
@@ -2382,6 +2424,7 @@ function useForm(opts) {
2382
2424
  removePathState,
2383
2425
  initialValues: initialValues,
2384
2426
  getAllPathStates: () => pathStates.value,
2427
+ markForUnmount,
2385
2428
  };
2386
2429
  /**
2387
2430
  * Sets a single field value
@@ -2479,6 +2522,7 @@ function useForm(opts) {
2479
2522
  if (formCtx.validateSchema) {
2480
2523
  return formCtx.validateSchema(mode);
2481
2524
  }
2525
+ isValidating.value = true;
2482
2526
  // No schema, each field is responsible to validate itself
2483
2527
  const validations = await Promise.all(pathStates.value.map(state => {
2484
2528
  if (!state.validate) {
@@ -2496,6 +2540,7 @@ function useForm(opts) {
2496
2540
  };
2497
2541
  });
2498
2542
  }));
2543
+ isValidating.value = false;
2499
2544
  const results = {};
2500
2545
  const errors = {};
2501
2546
  for (const validation of validations) {
@@ -2551,12 +2596,14 @@ function useForm(opts) {
2551
2596
  if (!schemaValue) {
2552
2597
  return { valid: true, results: {}, errors: {} };
2553
2598
  }
2599
+ isValidating.value = true;
2554
2600
  const formResult = isYupValidator(schemaValue) || isTypedSchema(schemaValue)
2555
2601
  ? await validateTypedSchema(schemaValue, formValues)
2556
2602
  : await validateObjectSchema(schemaValue, formValues, {
2557
2603
  names: fieldNames.value,
2558
2604
  bailsMap: fieldBailsMap.value,
2559
2605
  });
2606
+ isValidating.value = false;
2560
2607
  return formResult;
2561
2608
  }
2562
2609
  const submitForm = handleSubmit((_, { evt }) => {
@@ -2593,7 +2640,7 @@ function useForm(opts) {
2593
2640
  provide(FormContextKey, formCtx);
2594
2641
  if ((process.env.NODE_ENV !== 'production')) {
2595
2642
  registerFormWithDevTools(formCtx);
2596
- watch(() => (Object.assign(Object.assign({ errors: errorBag.value }, meta.value), { values: formValues, isSubmitting: isSubmitting.value, submitCount: submitCount.value })), refreshInspector, {
2643
+ watch(() => (Object.assign(Object.assign({ errors: errorBag.value }, meta.value), { values: formValues, isSubmitting: isSubmitting.value, isValidating: isValidating.value, submitCount: submitCount.value })), refreshInspector, {
2597
2644
  deep: true,
2598
2645
  });
2599
2646
  }
@@ -2805,7 +2852,7 @@ const FormImpl = defineComponent({
2805
2852
  const initialValues = toRef(props, 'initialValues');
2806
2853
  const validationSchema = toRef(props, 'validationSchema');
2807
2854
  const keepValues = toRef(props, 'keepValues');
2808
- const { errors, errorBag, values, meta, isSubmitting, submitCount, controlledValues, validate, validateField, handleReset, resetForm, handleSubmit, setErrors, setFieldError, setFieldValue, setValues, setFieldTouched, setTouched, resetField, } = useForm({
2855
+ const { errors, errorBag, values, meta, isSubmitting, isValidating, submitCount, controlledValues, validate, validateField, handleReset, resetForm, handleSubmit, setErrors, setFieldError, setFieldValue, setValues, setFieldTouched, setTouched, resetField, } = useForm({
2809
2856
  validationSchema: validationSchema.value ? validationSchema : undefined,
2810
2857
  initialValues,
2811
2858
  initialErrors: props.initialErrors,
@@ -2849,6 +2896,7 @@ const FormImpl = defineComponent({
2849
2896
  errorBag: errorBag.value,
2850
2897
  values,
2851
2898
  isSubmitting: isSubmitting.value,
2899
+ isValidating: isValidating.value,
2852
2900
  submitCount: submitCount.value,
2853
2901
  controlledValues: controlledValues.value,
2854
2902
  validate,
@@ -2998,6 +3046,7 @@ function useFieldArray(arrayPath) {
2998
3046
  const newValue = [...pathValue];
2999
3047
  newValue.splice(idx, 1);
3000
3048
  const fieldPath = pathName + `[${idx}]`;
3049
+ form.markForUnmount(fieldPath);
3001
3050
  form.unsetInitialValue(fieldPath);
3002
3051
  setInPath(form.values, pathName, newValue);
3003
3052
  fields.value.splice(idx, 1);
@@ -3284,6 +3333,20 @@ function useIsSubmitting() {
3284
3333
  });
3285
3334
  }
3286
3335
 
3336
+ /**
3337
+ * If the form is validating or not
3338
+ */
3339
+ function useIsValidating() {
3340
+ const form = injectWithSelf(FormContextKey);
3341
+ if (!form) {
3342
+ warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3343
+ }
3344
+ return computed(() => {
3345
+ var _a;
3346
+ return (_a = form === null || form === void 0 ? void 0 : form.isValidating.value) !== null && _a !== void 0 ? _a : false;
3347
+ });
3348
+ }
3349
+
3287
3350
  /**
3288
3351
  * Validates a single field
3289
3352
  */
@@ -3447,4 +3510,4 @@ function useSubmitForm(cb) {
3447
3510
  };
3448
3511
  }
3449
3512
 
3450
- export { ErrorMessage, Field, FieldArray, FieldContextKey, Form, FormContextKey, IS_ABSENT, configure, defineRule, useField, useFieldArray, useFieldError, useFieldValue, useForm, useFormErrors, useFormValues, useIsFieldDirty, useIsFieldTouched, useIsFieldValid, useIsFormDirty, useIsFormTouched, useIsFormValid, useIsSubmitting, useResetForm, useSubmitCount, useSubmitForm, useValidateField, useValidateForm, validate, validateObjectSchema as validateObject };
3513
+ export { ErrorMessage, Field, FieldArray, FieldContextKey, Form, FormContextKey, IS_ABSENT, configure, defineRule, useField, useFieldArray, useFieldError, useFieldValue, useForm, useFormErrors, useFormValues, useIsFieldDirty, useIsFieldTouched, useIsFieldValid, useIsFormDirty, useIsFormTouched, useIsFormValid, useIsSubmitting, useIsValidating, useResetForm, useSubmitCount, useSubmitForm, useValidateField, useValidateForm, validate, validateObjectSchema as validateObject };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * vee-validate v4.9.1
2
+ * vee-validate v4.9.3
3
3
  * (c) 2023 Abdelrahman Awad
4
4
  * @license MIT
5
5
  */
@@ -956,6 +956,7 @@
956
956
  value,
957
957
  initialValue,
958
958
  meta,
959
+ flags: { pendingUnmount: { [id]: false } },
959
960
  errors,
960
961
  setState,
961
962
  };
@@ -989,6 +990,7 @@
989
990
  errors,
990
991
  meta: state,
991
992
  initialValue,
993
+ flags: state.__flags,
992
994
  setState,
993
995
  };
994
996
  }
@@ -1105,7 +1107,6 @@
1105
1107
  const injectedForm = controlled ? injectWithSelf(FormContextKey) : undefined;
1106
1108
  const form = controlForm || injectedForm;
1107
1109
  const name = lazyToRef(path);
1108
- let PENDING_UNMOUNT = false;
1109
1110
  const validator = vue.computed(() => {
1110
1111
  const schema = vue.unref(form === null || form === void 0 ? void 0 : form.schema);
1111
1112
  if (schema) {
@@ -1120,7 +1121,7 @@
1120
1121
  }
1121
1122
  return normalizeRules(rulesValue);
1122
1123
  });
1123
- const { id, value, initialValue, meta, setState, errors } = useFieldState(name, {
1124
+ const { id, value, initialValue, meta, setState, errors, flags } = useFieldState(name, {
1124
1125
  modelValue,
1125
1126
  form,
1126
1127
  bails,
@@ -1158,7 +1159,7 @@
1158
1159
  meta.validated = true;
1159
1160
  return validateCurrentValue('validated-only');
1160
1161
  }, result => {
1161
- if (PENDING_UNMOUNT) {
1162
+ if (flags.pendingUnmount[field.id]) {
1162
1163
  return;
1163
1164
  }
1164
1165
  setState({ errors: result.errors });
@@ -1181,10 +1182,7 @@
1181
1182
  // Common input/change event handler
1182
1183
  function handleChange(e, shouldValidate = true) {
1183
1184
  const newValue = normalizeEventValue(e);
1184
- setValue(newValue, false);
1185
- if (!validateOnValueUpdate && shouldValidate) {
1186
- validateWithStateMutation();
1187
- }
1185
+ setValue(newValue, shouldValidate);
1188
1186
  }
1189
1187
  // Runs the initial validation
1190
1188
  vue.onMounted(() => {
@@ -1213,12 +1211,13 @@
1213
1211
  meta.validated = false;
1214
1212
  validateValidStateOnly();
1215
1213
  }
1216
- function setValue(newValue, validate = true) {
1214
+ function setValue(newValue, shouldValidate = true) {
1217
1215
  value.value = newValue;
1218
- if (!validate) {
1216
+ if (!shouldValidate) {
1217
+ validateValidStateOnly();
1219
1218
  return;
1220
1219
  }
1221
- const validateFn = validateOnValueUpdate ? validateWithStateMutation : validateValidStateOnly;
1220
+ const validateFn = shouldValidate ? validateWithStateMutation : validateValidStateOnly;
1222
1221
  validateFn();
1223
1222
  }
1224
1223
  function setErrors(errors) {
@@ -1309,12 +1308,13 @@
1309
1308
  });
1310
1309
  vue.onBeforeUnmount(() => {
1311
1310
  var _a;
1312
- PENDING_UNMOUNT = true;
1313
1311
  const shouldKeepValue = (_a = vue.unref(field.keepValueOnUnmount)) !== null && _a !== void 0 ? _a : vue.unref(form.keepValuesOnUnmount);
1314
- if (shouldKeepValue || !form) {
1312
+ const path = unravel(name);
1313
+ if (shouldKeepValue || !form || flags.pendingUnmount[field.id]) {
1314
+ form === null || form === void 0 ? void 0 : form.removePathState(path, id);
1315
1315
  return;
1316
1316
  }
1317
- const path = unravel(name);
1317
+ flags.pendingUnmount[field.id] = true;
1318
1318
  const pathState = form.getPathState(path);
1319
1319
  const matchesId = Array.isArray(pathState === null || pathState === void 0 ? void 0 : pathState.id) && (pathState === null || pathState === void 0 ? void 0 : pathState.multiple)
1320
1320
  ? pathState === null || pathState === void 0 ? void 0 : pathState.id.includes(field.id)
@@ -1334,9 +1334,9 @@
1334
1334
  }
1335
1335
  }
1336
1336
  else {
1337
- form.unsetPathValue(path);
1337
+ form.unsetPathValue(unravel(name));
1338
1338
  }
1339
- form.removePathState(path);
1339
+ form.removePathState(path, id);
1340
1340
  });
1341
1341
  return field;
1342
1342
  }
@@ -1537,15 +1537,6 @@
1537
1537
  handleChange(e, shouldValidate);
1538
1538
  ctx.emit('update:modelValue', value.value);
1539
1539
  };
1540
- const handleInput = (e) => {
1541
- if (!hasCheckedAttr(ctx.attrs.type)) {
1542
- value.value = normalizeEventValue(e);
1543
- }
1544
- };
1545
- const onInputHandler = function handleInputWithModel(e) {
1546
- handleInput(e);
1547
- ctx.emit('update:modelValue', value.value);
1548
- };
1549
1540
  const fieldProps = vue.computed(() => {
1550
1541
  const { validateOnInput, validateOnChange, validateOnBlur, validateOnModelUpdate } = resolveValidationTriggers(props);
1551
1542
  function baseOnBlur(e) {
@@ -1595,7 +1586,7 @@
1595
1586
  validate: validateField,
1596
1587
  resetField,
1597
1588
  handleChange: onChangeHandler,
1598
- handleInput: onInputHandler,
1589
+ handleInput: e => onChangeHandler(e, false),
1599
1590
  handleReset,
1600
1591
  handleBlur,
1601
1592
  setTouched,
@@ -1663,6 +1654,8 @@
1663
1654
  let FIELD_ID_COUNTER = 0;
1664
1655
  // If the form is currently submitting
1665
1656
  const isSubmitting = vue.ref(false);
1657
+ // If the form is currently validating
1658
+ const isValidating = vue.ref(false);
1666
1659
  // The number of times the user tried to submit the form
1667
1660
  const submitCount = vue.ref(0);
1668
1661
  // field arrays managed by this form
@@ -1752,19 +1745,22 @@
1752
1745
  if ((config === null || config === void 0 ? void 0 : config.type) === 'checkbox' || (config === null || config === void 0 ? void 0 : config.type) === 'radio') {
1753
1746
  pathStateExists.multiple = true;
1754
1747
  }
1748
+ const id = FIELD_ID_COUNTER++;
1755
1749
  if (Array.isArray(pathStateExists.id)) {
1756
- pathStateExists.id.push(FIELD_ID_COUNTER++);
1750
+ pathStateExists.id.push(id);
1757
1751
  }
1758
1752
  else {
1759
- pathStateExists.id = [pathStateExists.id, FIELD_ID_COUNTER++];
1753
+ pathStateExists.id = [pathStateExists.id, id];
1760
1754
  }
1761
1755
  pathStateExists.fieldsCount++;
1756
+ pathStateExists.__flags.pendingUnmount[id] = false;
1762
1757
  return pathStateExists;
1763
1758
  }
1764
1759
  const currentValue = vue.computed(() => getFromPath(formValues, unravel(path)));
1765
1760
  const pathValue = unravel(path);
1761
+ const id = FIELD_ID_COUNTER++;
1766
1762
  const state = vue.reactive({
1767
- id: FIELD_ID_COUNTER++,
1763
+ id,
1768
1764
  path,
1769
1765
  touched: false,
1770
1766
  pending: false,
@@ -1777,6 +1773,9 @@
1777
1773
  type: (config === null || config === void 0 ? void 0 : config.type) || 'default',
1778
1774
  value: currentValue,
1779
1775
  multiple: false,
1776
+ __flags: {
1777
+ pendingUnmount: { [id]: false },
1778
+ },
1780
1779
  fieldsCount: 1,
1781
1780
  validate: config === null || config === void 0 ? void 0 : config.validate,
1782
1781
  dirty: vue.computed(() => {
@@ -1817,11 +1816,11 @@
1817
1816
  // this ensures we have a complete key map of all the fields
1818
1817
  const paths = [
1819
1818
  ...new Set([...keysOf(formResult.results), ...pathStates.value.map(p => p.path), ...currentErrorsPaths]),
1820
- ];
1819
+ ].sort();
1821
1820
  // aggregates the paths into a single result object while applying the results on the fields
1822
1821
  return paths.reduce((validation, _path) => {
1823
1822
  const path = _path;
1824
- const pathState = findPathState(path);
1823
+ const pathState = findPathState(path) || findHoistedPath(path);
1825
1824
  const messages = (formResult.results[path] || { errors: [] }).errors;
1826
1825
  const fieldResult = {
1827
1826
  errors: messages,
@@ -1859,8 +1858,30 @@
1859
1858
  const pathState = typeof path === 'string' ? pathStates.value.find(state => state.path === path) : path;
1860
1859
  return pathState;
1861
1860
  }
1861
+ function findHoistedPath(path) {
1862
+ const candidates = pathStates.value.filter(state => path.startsWith(state.path));
1863
+ return candidates.reduce((bestCandidate, candidate) => {
1864
+ if (!bestCandidate) {
1865
+ return candidate;
1866
+ }
1867
+ return (candidate.path.length > bestCandidate.path.length ? candidate : bestCandidate);
1868
+ }, undefined);
1869
+ }
1870
+ let UNSET_BATCH = [];
1871
+ let PENDING_UNSET;
1862
1872
  function unsetPathValue(path) {
1863
- unsetPath(formValues, path);
1873
+ UNSET_BATCH.push(path);
1874
+ if (!PENDING_UNSET) {
1875
+ PENDING_UNSET = vue.nextTick(() => {
1876
+ const sortedPaths = [...UNSET_BATCH].sort().reverse();
1877
+ sortedPaths.forEach(p => {
1878
+ unsetPath(formValues, p);
1879
+ });
1880
+ UNSET_BATCH = [];
1881
+ PENDING_UNSET = null;
1882
+ });
1883
+ }
1884
+ return PENDING_UNSET;
1864
1885
  }
1865
1886
  function makeSubmissionFactory(onlyControlled) {
1866
1887
  return function submitHandlerFactory(fn, onValidationError) {
@@ -1918,7 +1939,7 @@
1918
1939
  const handleSubmitImpl = makeSubmissionFactory(false);
1919
1940
  const handleSubmit = handleSubmitImpl;
1920
1941
  handleSubmit.withControlled = makeSubmissionFactory(true);
1921
- function removePathState(path) {
1942
+ function removePathState(path, id) {
1922
1943
  const idx = pathStates.value.findIndex(s => s.path === path);
1923
1944
  const pathState = pathStates.value[idx];
1924
1945
  if (idx === -1 || !pathState) {
@@ -1927,11 +1948,27 @@
1927
1948
  if (pathState.multiple && pathState.fieldsCount) {
1928
1949
  pathState.fieldsCount--;
1929
1950
  }
1951
+ if (Array.isArray(pathState.id)) {
1952
+ const idIndex = pathState.id.indexOf(id);
1953
+ if (idIndex >= 0) {
1954
+ pathState.id.splice(idIndex, 1);
1955
+ }
1956
+ delete pathState.__flags.pendingUnmount[id];
1957
+ }
1930
1958
  if (!pathState.multiple || pathState.fieldsCount <= 0) {
1931
1959
  pathStates.value.splice(idx, 1);
1932
1960
  unsetInitialValue(path);
1933
1961
  }
1934
1962
  }
1963
+ function markForUnmount(path) {
1964
+ return mutateAllPathState(s => {
1965
+ if (s.path.startsWith(path)) {
1966
+ keysOf(s.__flags.pendingUnmount).forEach(id => {
1967
+ s.__flags.pendingUnmount[id] = true;
1968
+ });
1969
+ }
1970
+ });
1971
+ }
1935
1972
  const formCtx = {
1936
1973
  formId,
1937
1974
  values: formValues,
@@ -1942,6 +1979,7 @@
1942
1979
  submitCount,
1943
1980
  meta,
1944
1981
  isSubmitting,
1982
+ isValidating,
1945
1983
  fieldArrays,
1946
1984
  keepValuesOnUnmount,
1947
1985
  validateSchema: vue.unref(schema) ? validateSchema : undefined,
@@ -1966,6 +2004,7 @@
1966
2004
  removePathState,
1967
2005
  initialValues: initialValues,
1968
2006
  getAllPathStates: () => pathStates.value,
2007
+ markForUnmount,
1969
2008
  };
1970
2009
  /**
1971
2010
  * Sets a single field value
@@ -2063,6 +2102,7 @@
2063
2102
  if (formCtx.validateSchema) {
2064
2103
  return formCtx.validateSchema(mode);
2065
2104
  }
2105
+ isValidating.value = true;
2066
2106
  // No schema, each field is responsible to validate itself
2067
2107
  const validations = await Promise.all(pathStates.value.map(state => {
2068
2108
  if (!state.validate) {
@@ -2080,6 +2120,7 @@
2080
2120
  };
2081
2121
  });
2082
2122
  }));
2123
+ isValidating.value = false;
2083
2124
  const results = {};
2084
2125
  const errors = {};
2085
2126
  for (const validation of validations) {
@@ -2135,12 +2176,14 @@
2135
2176
  if (!schemaValue) {
2136
2177
  return { valid: true, results: {}, errors: {} };
2137
2178
  }
2179
+ isValidating.value = true;
2138
2180
  const formResult = isYupValidator(schemaValue) || isTypedSchema(schemaValue)
2139
2181
  ? await validateTypedSchema(schemaValue, formValues)
2140
2182
  : await validateObjectSchema(schemaValue, formValues, {
2141
2183
  names: fieldNames.value,
2142
2184
  bailsMap: fieldBailsMap.value,
2143
2185
  });
2186
+ isValidating.value = false;
2144
2187
  return formResult;
2145
2188
  }
2146
2189
  const submitForm = handleSubmit((_, { evt }) => {
@@ -2383,7 +2426,7 @@
2383
2426
  const initialValues = vue.toRef(props, 'initialValues');
2384
2427
  const validationSchema = vue.toRef(props, 'validationSchema');
2385
2428
  const keepValues = vue.toRef(props, 'keepValues');
2386
- const { errors, errorBag, values, meta, isSubmitting, submitCount, controlledValues, validate, validateField, handleReset, resetForm, handleSubmit, setErrors, setFieldError, setFieldValue, setValues, setFieldTouched, setTouched, resetField, } = useForm({
2429
+ const { errors, errorBag, values, meta, isSubmitting, isValidating, submitCount, controlledValues, validate, validateField, handleReset, resetForm, handleSubmit, setErrors, setFieldError, setFieldValue, setValues, setFieldTouched, setTouched, resetField, } = useForm({
2387
2430
  validationSchema: validationSchema.value ? validationSchema : undefined,
2388
2431
  initialValues,
2389
2432
  initialErrors: props.initialErrors,
@@ -2427,6 +2470,7 @@
2427
2470
  errorBag: errorBag.value,
2428
2471
  values,
2429
2472
  isSubmitting: isSubmitting.value,
2473
+ isValidating: isValidating.value,
2430
2474
  submitCount: submitCount.value,
2431
2475
  controlledValues: controlledValues.value,
2432
2476
  validate,
@@ -2576,6 +2620,7 @@
2576
2620
  const newValue = [...pathValue];
2577
2621
  newValue.splice(idx, 1);
2578
2622
  const fieldPath = pathName + `[${idx}]`;
2623
+ form.markForUnmount(fieldPath);
2579
2624
  form.unsetInitialValue(fieldPath);
2580
2625
  setInPath(form.values, pathName, newValue);
2581
2626
  fields.value.splice(idx, 1);
@@ -2862,6 +2907,20 @@
2862
2907
  });
2863
2908
  }
2864
2909
 
2910
+ /**
2911
+ * If the form is validating or not
2912
+ */
2913
+ function useIsValidating() {
2914
+ const form = injectWithSelf(FormContextKey);
2915
+ if (!form) {
2916
+ warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
2917
+ }
2918
+ return vue.computed(() => {
2919
+ var _a;
2920
+ return (_a = form === null || form === void 0 ? void 0 : form.isValidating.value) !== null && _a !== void 0 ? _a : false;
2921
+ });
2922
+ }
2923
+
2865
2924
  /**
2866
2925
  * Validates a single field
2867
2926
  */
@@ -3048,6 +3107,7 @@
3048
3107
  exports.useIsFormTouched = useIsFormTouched;
3049
3108
  exports.useIsFormValid = useIsFormValid;
3050
3109
  exports.useIsSubmitting = useIsSubmitting;
3110
+ exports.useIsValidating = useIsValidating;
3051
3111
  exports.useResetForm = useResetForm;
3052
3112
  exports.useSubmitCount = useSubmitCount;
3053
3113
  exports.useSubmitForm = useSubmitForm;
@@ -1,6 +1,6 @@
1
1
  /**
2
- * vee-validate v4.9.1
2
+ * vee-validate v4.9.3
3
3
  * (c) 2023 Abdelrahman Awad
4
4
  * @license MIT
5
5
  */
6
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VeeValidate={},e.Vue)}(this,(function(e,t){"use strict";function n(e){return"function"==typeof e}function r(e){return null==e}const a=e=>null!==e&&!!e&&"object"==typeof e&&!Array.isArray(e);function l(e){return Number(e)>=0}function i(e,t){return Object.keys(t).forEach((n=>{if(a(t[n]))return e[n]||(e[n]={}),void i(e[n],t[n]);e[n]=t[n]})),e}const u={};const o=Symbol("vee-validate-form"),s=Symbol("vee-validate-field-instance"),d=Symbol("Default empty value"),c="undefined"!=typeof window;function v(e){return n(e)&&!!e.__locatorRef}function f(e){return!!e&&n(e.parse)&&"VVTypedSchema"===e.__type}function p(e){return!!e&&n(e.validate)}function m(e){return"checkbox"===e||"radio"===e}function h(e){return/^\[.+\]$/i.test(e)}function y(e){return"SELECT"===e.tagName}function g(e,t){return!function(e,t){const n=![!1,null,void 0,0].includes(t.multiple)&&!Number.isNaN(t.multiple);return"select"===e&&"multiple"in t&&n}(e,t)&&"file"!==t.type&&!m(t.type)}function b(e){return O(e)&&e.target&&"submit"in e.target}function O(e){return!!e&&(!!("undefined"!=typeof Event&&n(Event)&&e instanceof Event)||!(!e||!e.srcElement))}function V(e,t){return t in e&&e[t]!==d}function F(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;var n,r,a;if(Array.isArray(e)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(!F(e[r],t[r]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;for(r of e.entries())if(!F(r[1],t.get(r[0])))return!1;return!0}if(A(e)&&A(t))return e.size===t.size&&(e.name===t.name&&(e.lastModified===t.lastModified&&e.type===t.type));if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(e[r]!==t[r])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if((n=(a=Object.keys(e)).length)!==Object.keys(t).length)return!1;for(r=n;0!=r--;)if(!Object.prototype.hasOwnProperty.call(t,a[r]))return!1;for(r=n;0!=r--;){var l=a[r];if(!F(e[l],t[l]))return!1}return!0}return e!=e&&t!=t}function A(e){return!!c&&e instanceof File}function j(e,t,n){"object"==typeof n.value&&(n.value=w(n.value)),n.enumerable&&!n.get&&!n.set&&n.configurable&&n.writable&&"__proto__"!==t?e[t]=n.value:Object.defineProperty(e,t,n)}function w(e){if("object"!=typeof e)return e;var t,n,r,a=0,l=Object.prototype.toString.call(e);if("[object Object]"===l?r=Object.create(e.__proto__||null):"[object Array]"===l?r=Array(e.length):"[object Set]"===l?(r=new Set,e.forEach((function(e){r.add(w(e))}))):"[object Map]"===l?(r=new Map,e.forEach((function(e,t){r.set(w(t),w(e))}))):"[object Date]"===l?r=new Date(+e):"[object RegExp]"===l?r=new RegExp(e.source,e.flags):"[object DataView]"===l?r=new e.constructor(w(e.buffer)):"[object ArrayBuffer]"===l?r=e.slice(0):"Array]"===l.slice(-6)&&(r=new e.constructor(e)),r){for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)j(r,n[a],Object.getOwnPropertyDescriptor(e,n[a]));for(a=0,n=Object.getOwnPropertyNames(e);a<n.length;a++)Object.hasOwnProperty.call(r,t=n[a])&&r[t]===e[t]||j(r,t,Object.getOwnPropertyDescriptor(e,t))}return r||e}function S(e){return h(e)?e.replace(/\[|\]/gi,""):e}function E(e,t,n){if(!e)return n;if(h(t))return e[S(t)];return(t||"").split(/\.|\[(\d+)\]/).filter(Boolean).reduce(((e,t)=>{return(a(r=e)||Array.isArray(r))&&t in e?e[t]:n;var r}),e)}function k(e,t,n){if(h(t))return void(e[S(t)]=n);const a=t.split(/\.|\[(\d+)\]/).filter(Boolean);let i=e;for(let e=0;e<a.length;e++){if(e===a.length-1)return void(i[a[e]]=n);a[e]in i&&!r(i[a[e]])||(i[a[e]]=l(a[e+1])?[]:{}),i=i[a[e]]}}function I(e,t){Array.isArray(e)&&l(t)?e.splice(Number(t),1):a(e)&&delete e[t]}function C(e,t){if(h(t))return void delete e[S(t)];const n=t.split(/\.|\[(\d+)\]/).filter(Boolean);let l=e;for(let e=0;e<n.length;e++){if(e===n.length-1){I(l,n[e]);break}if(!(n[e]in l)||r(l[n[e]]))break;l=l[n[e]]}const i=n.map(((t,r)=>E(e,n.slice(0,r).join("."))));for(let t=i.length-1;t>=0;t--)u=i[t],(Array.isArray(u)?0===u.length:a(u)&&0===Object.keys(u).length)&&(0!==t?I(i[t-1],n[t-1]):I(e,n[0]));var u}function M(e){return Object.keys(e)}function B(e,n=void 0){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function T(e){t.warn(`[vee-validate]: ${e}`)}function P(e,t,n){if(Array.isArray(e)){const n=[...e],r=n.findIndex((e=>F(e,t)));return r>=0?n.splice(r,1):n.push(t),n}return F(e,t)?n:t}function R(e,t=0){let n=null,r=[];return function(...a){return n&&window.clearTimeout(n),n=window.setTimeout((()=>{const t=e(...a);r.forEach((e=>e(t))),r=[]}),t),new Promise((e=>r.push(e)))}}function x(e,t){return a(t)&&t.number?function(e){const t=parseFloat(e);return isNaN(t)?e:t}(e):e}function N(e,t){let n;return async function(...r){const a=e(...r);n=a;const l=await a;return a!==n||(n=void 0,t(l,r)),l}}function U({get:e,set:n}){const r=t.ref(w(e()));return t.watch(e,(e=>{F(e,r.value)||(r.value=w(e))}),{deep:!0}),t.watch(r,(t=>{F(t,e())||n(w(t))}),{deep:!0}),r}function _(e){return n(e)?e():t.unref(e)}function $(e){return Array.isArray(e)?e:e?[e]:[]}function D(e){const n=B(o),r=e?t.computed((()=>null==n?void 0:n.getPathState(t.unref(e)))):void 0,a=e?void 0:t.inject(s);return a||(null==r?void 0:r.value)||T(`field with name ${t.unref(e)} was not found`),r||a}function z(e,t){const n={};for(const r in e)t.includes(r)||(n[r]=e[r]);return n}const q=(e,t,n)=>t.slots.default?"string"!=typeof e&&e?{default:()=>{var e,r;return null===(r=(e=t.slots).default)||void 0===r?void 0:r.call(e,n())}}:t.slots.default(n()):t.slots.default;function L(e){if(K(e))return e._value}function K(e){return"_value"in e}function G(e){if(!O(e))return e;const t=e.target;if(m(t.type)&&K(t))return L(t);if("file"===t.type&&t.files){const e=Array.from(t.files);return t.multiple?e:e[0]}if(y(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map(L);var n;if(y(t)){const e=Array.from(t.options).find((e=>e.selected));return e?L(e):t.value}return t.value}function X(e){const t={};return Object.defineProperty(t,"_$$isNormalized",{value:!0,writable:!1,enumerable:!1,configurable:!1}),e?a(e)&&e._$$isNormalized?e:a(e)?Object.keys(e).reduce(((t,n)=>{const r=function(e){if(!0===e)return[];if(Array.isArray(e))return e;if(a(e))return e;return[e]}(e[n]);return!1!==e[n]&&(t[n]=H(r)),t}),t):"string"!=typeof e?t:e.split("|").reduce(((e,t)=>{const n=J(t);return n.name?(e[n.name]=H(n.params),e):e}),t):t}function H(e){const t=e=>"string"==typeof e&&"@"===e[0]?function(e){const t=t=>E(t,e)||t[e];return t.__locatorRef=e,t}(e.slice(1)):e;return Array.isArray(e)?e.map(t):e instanceof RegExp?[e]:Object.keys(e).reduce(((n,r)=>(n[r]=t(e[r]),n)),{})}const J=e=>{let t=[];const n=e.split(":")[0];return e.includes(":")&&(t=e.split(":").slice(1).join(":").split(",")),{name:n,params:t}};let Q=Object.assign({},{generateMessage:({field:e})=>`${e} is not valid.`,bails:!0,validateOnBlur:!0,validateOnChange:!0,validateOnInput:!1,validateOnModelUpdate:!0});const W=()=>Q,Y=e=>{Q=Object.assign(Object.assign({},Q),e)};async function Z(e,t,r={}){const a=null==r?void 0:r.bails,l={name:(null==r?void 0:r.name)||"{field}",rules:t,label:null==r?void 0:r.label,bails:null==a||a,formData:(null==r?void 0:r.values)||{}},i=await async function(e,t){if(f(e.rules)||p(e.rules))return async function(e,t){const n=f(t)?t:ee(t),r=await n.parse(e),a=[];for(const e of r.errors)e.errors.length&&a.push(...e.errors);return{errors:a}}(t,e.rules);if(n(e.rules)||Array.isArray(e.rules)){const n={field:e.label||e.name,name:e.name,label:e.label,form:e.formData,value:t},r=Array.isArray(e.rules)?e.rules:[e.rules],a=r.length,l=[];for(let i=0;i<a;i++){const a=r[i],u=await a(t,n);if("string"!=typeof u&&u)continue;const o="string"==typeof u?u:ne(n);if(l.push(o),e.bails)return{errors:l}}return{errors:l}}const r=Object.assign(Object.assign({},e),{rules:X(e.rules)}),a=[],l=Object.keys(r.rules),i=l.length;for(let n=0;n<i;n++){const i=l[n],u=await te(r,t,{name:i,params:r.rules[i]});if(u.error&&(a.push(u.error),e.bails))return{errors:a}}return{errors:a}}(l,e),u=i.errors;return{errors:u,valid:!u.length}}function ee(e){return{__type:"VVTypedSchema",async parse(t){var n;try{return{output:await e.validate(t,{abortEarly:!1}),errors:[]}}catch(e){if(!function(e){return!!e&&"ValidationError"===e.name}(e))throw e;if(!(null===(n=e.inner)||void 0===n?void 0:n.length)&&e.errors.length)return{errors:[{path:e.path,errors:e.errors}]};const t=e.inner.reduce(((e,t)=>{const n=t.path||"";return e[n]||(e[n]={errors:[],path:n}),e[n].errors.push(...t.errors),e}),{});return{errors:Object.values(t)}}}}}async function te(e,t,n){const r=(a=n.name,u[a]);var a;if(!r)throw new Error(`No such validator '${n.name}' exists.`);const l=function(e,t){const n=e=>v(e)?e(t):e;if(Array.isArray(e))return e.map(n);return Object.keys(e).reduce(((t,r)=>(t[r]=n(e[r]),t)),{})}(n.params,e.formData),i={field:e.label||e.name,name:e.name,label:e.label,value:t,form:e.formData,rule:Object.assign(Object.assign({},n),{params:l})},o=await r(t,l,i);return"string"==typeof o?{error:o}:{error:o?void 0:ne(i)}}function ne(e){const t=W().generateMessage;return t?t(e):"Field is invalid"}async function re(e,t,n){const r=M(e).map((async r=>{var a,l,i;const u=null===(a=null==n?void 0:n.names)||void 0===a?void 0:a[r],o=await Z(E(t,r),e[r],{name:(null==u?void 0:u.name)||r,label:null==u?void 0:u.label,values:t,bails:null===(i=null===(l=null==n?void 0:n.bailsMap)||void 0===l?void 0:l[r])||void 0===i||i});return Object.assign(Object.assign({},o),{path:r})}));let a=!0;const l=await Promise.all(r),i={},u={};for(const e of l)i[e.path]={valid:e.valid,errors:e.errors},e.valid||(a=!1,u[e.path]=e.errors[0]);return{valid:a,results:i,errors:u}}let ae=0;function le(e,n){const{value:r,initialValue:a,setInitialValue:l}=function(e,n,r){const a=t.ref(t.unref(n));function l(){return r?E(r.initialValues.value,t.unref(e),t.unref(a)):t.unref(a)}function i(n){r?r.stageInitialValue(t.unref(e),n,!0):a.value=n}const u=t.computed(l);if(!r){return{value:t.ref(l()),initialValue:u,setInitialValue:i}}const o=function(e,n,r,a){if(t.isRef(e))return t.unref(e);if(void 0!==e)return e;return E(n.values,t.unref(a),t.unref(r))}(n,r,u,e);r.stageInitialValue(t.unref(e),o,!0);const s=t.computed({get:()=>E(r.values,t.unref(e)),set(n){r.setFieldValue(t.unref(e),n)}});return{value:s,initialValue:u,setInitialValue:i}}(e,n.modelValue,n.form);if(!n.form){const{errors:o,setErrors:s}=function(){const e=t.ref([]);return{errors:e,setErrors:t=>{e.value=$(t)}}}(),d=ae>=Number.MAX_SAFE_INTEGER?0:++ae,c=function(e,n,r){const a=t.reactive({touched:!1,pending:!1,valid:!0,validated:!!t.unref(r).length,initialValue:t.computed((()=>t.unref(n))),dirty:t.computed((()=>!F(t.unref(e),t.unref(n))))});return t.watch(r,(e=>{a.valid=!e.length}),{immediate:!0,flush:"sync"}),a}(r,a,o);function v(e){var t;"value"in e&&(r.value=e.value),"errors"in e&&s(e.errors),"touched"in e&&(c.touched=null!==(t=e.touched)&&void 0!==t?t:c.touched),"initialValue"in e&&l(e.initialValue)}return{id:d,path:e,value:r,initialValue:a,meta:c,errors:o,setState:v}}const i=n.form.createPathState(e,{bails:n.bails,label:n.label,type:n.type,validate:n.validate}),u=t.computed((()=>i.errors));return{id:Array.isArray(i.id)?i.id[i.id.length-1]:i.id,path:e,value:r,errors:u,meta:i,initialValue:a,setState:function(a){var i,u,o;"value"in a&&(r.value=a.value),"errors"in a&&(null===(i=n.form)||void 0===i||i.setFieldError(t.unref(e),a.errors)),"touched"in a&&(null===(u=n.form)||void 0===u||u.setFieldTouched(t.unref(e),null!==(o=a.touched)&&void 0!==o&&o)),"initialValue"in a&&l(a.initialValue)}}}function ie(e,n,r){return m(null==r?void 0:r.type)?function(e,n,r){const a=(null==r?void 0:r.standalone)?void 0:B(o),l=null==r?void 0:r.checkedValue,i=null==r?void 0:r.uncheckedValue;function u(n){const r=n.handleChange,u=t.computed((()=>{const e=t.unref(n.value),r=t.unref(l);return Array.isArray(e)?e.findIndex((e=>F(e,r)))>=0:F(r,e)}));function o(o,s=!0){var d;if(u.value===(null===(d=null==o?void 0:o.target)||void 0===d?void 0:d.checked))return void(s&&n.validate());const c=_(e),v=null==a?void 0:a.getPathState(c),f=G(o);let p;p=a&&(null==v?void 0:v.multiple)&&"checkbox"===v.type?P(E(a.values,c)||[],f,void 0):P(t.unref(n.value),t.unref(l),t.unref(i)),r(p,s)}return Object.assign(Object.assign({},n),{checked:u,checkedValue:l,uncheckedValue:i,handleChange:o})}return u(ue(e,n,r))}(e,n,r):ue(e,n,r)}function ue(e,r,a){const{initialValue:l,validateOnMount:i,bails:u,type:c,checkedValue:m,label:h,validateOnValueUpdate:y,uncheckedValue:g,controlled:b,keepValueOnUnmount:O,modelPropName:V,syncVModel:A,form:j}=function(e){var n;const r=()=>({initialValue:void 0,validateOnMount:!1,bails:!0,label:void 0,validateOnValueUpdate:!0,keepValueOnUnmount:void 0,modelPropName:"modelValue",syncVModel:!0,controlled:!0}),a=null===(n=null==e?void 0:e.syncVModel)||void 0===n||n,l=a&&!("initialValue"in(e||{}))?oe(t.getCurrentInstance(),(null==e?void 0:e.modelPropName)||"modelValue"):null==e?void 0:e.initialValue;if(!e)return Object.assign(Object.assign({},r()),{initialValue:l});const i="valueProp"in e?e.valueProp:e.checkedValue,u="standalone"in e?!e.standalone:e.controlled;return Object.assign(Object.assign(Object.assign({},r()),e||{}),{initialValue:l,controlled:null==u||u,checkedValue:i})}(a),S=b?B(o):void 0,k=j||S,I=function(e){return t.computed((()=>_(e)))}(e);let C=!1;const T=t.computed((()=>{if(t.unref(null==k?void 0:k.schema))return;const e=t.unref(r);return p(e)||f(e)||n(e)||Array.isArray(e)?e:X(e)})),{id:P,value:R,initialValue:U,meta:$,setState:D,errors:z}=le(I,{modelValue:l,form:k,bails:u,label:h,type:c,validate:T.value?J:void 0}),q=t.computed((()=>z.value[0]));A&&function({prop:e,value:n,handleChange:r}){const a=t.getCurrentInstance();if(!a)return;const l=e||"modelValue",i=`update:${l}`;if(!(l in a.props))return;t.watch(n,(e=>{F(e,oe(a,l))||a.emit(i,e)})),t.watch((()=>oe(a,l)),(e=>{if(e===d&&void 0===n.value)return;const t=e===d?void 0:e;F(t,x(n.value,a.props.modelModifiers))||r(t)}))}({value:R,prop:V,handleChange:Q});async function L(e){var n,r;return(null==k?void 0:k.validateSchema)?null!==(n=(await k.validateSchema(e)).results[t.unref(I)])&&void 0!==n?n:{valid:!0,errors:[]}:T.value?Z(R.value,T.value,{name:t.unref(I),label:t.unref(h),values:null!==(r=null==k?void 0:k.values)&&void 0!==r?r:{},bails:u}):{valid:!0,errors:[]}}const K=N((async()=>($.pending=!0,$.validated=!0,L("validated-only"))),(e=>{if(!C)return D({errors:e.errors}),$.pending=!1,$.valid=e.valid,e})),H=N((async()=>L("silent")),(e=>($.valid=e.valid,e)));function J(e){return"silent"===(null==e?void 0:e.mode)?H():K()}function Q(e,t=!0){Y(G(e),!1),!y&&t&&K()}function W(e){var t;const n=e&&"value"in e?e.value:U.value;D({value:w(n),initialValue:w(n),touched:null!==(t=null==e?void 0:e.touched)&&void 0!==t&&t,errors:(null==e?void 0:e.errors)||[]}),$.pending=!1,$.validated=!1,H()}function Y(e,t=!0){if(R.value=e,!t)return;(y?K:H)()}t.onMounted((()=>{if(i)return K();k&&k.validateSchema||H()}));const ee=t.computed({get:()=>R.value,set(e){Y(e,y)}}),te={id:P,name:I,label:h,value:ee,meta:$,errors:z,errorMessage:q,type:c,checkedValue:m,uncheckedValue:g,bails:u,keepValueOnUnmount:O,resetField:W,handleReset:()=>W(),validate:J,handleChange:Q,handleBlur:()=>{$.touched=!0},setState:D,setTouched:function(e){$.touched=e},setErrors:function(e){D({errors:Array.isArray(e)?e:[e]})},setValue:Y};if(t.provide(s,te),t.isRef(r)&&"function"!=typeof t.unref(r)&&t.watch(r,((e,t)=>{F(e,t)||($.validated?K():H())}),{deep:!0}),!k)return te;const ne=t.computed((()=>{const e=T.value;return!e||n(e)||p(e)||f(e)||Array.isArray(e)?{}:Object.keys(e).reduce(((t,n)=>{const r=(a=e[n],Array.isArray(a)?a.filter(v):M(a).filter((e=>v(a[e]))).map((e=>a[e]))).map((e=>e.__locatorRef)).reduce(((e,t)=>{const n=E(k.values,t)||k.values[t];return void 0!==n&&(e[t]=n),e}),{});var a;return Object.assign(t,r),t}),{})}));return t.watch(ne,((e,t)=>{if(!Object.keys(e).length)return;!F(e,t)&&($.validated?K():H())})),t.onBeforeUnmount((()=>{var e;C=!0;if((null!==(e=t.unref(te.keepValueOnUnmount))&&void 0!==e?e:t.unref(k.keepValuesOnUnmount))||!k)return;const n=_(I),r=k.getPathState(n);if(Array.isArray(null==r?void 0:r.id)&&(null==r?void 0:r.multiple)?null==r?void 0:r.id.includes(te.id):(null==r?void 0:r.id)===te.id){if((null==r?void 0:r.multiple)&&Array.isArray(r.value)){const e=r.value.findIndex((e=>F(e,t.unref(te.checkedValue))));if(e>-1){const t=[...r.value];t.splice(e,1),k.setFieldValue(n,t)}Array.isArray(r.id)&&r.id.splice(r.id.indexOf(te.id),1)}else k.unsetPathValue(n);k.removePathState(n)}})),te}function oe(e,t){if(e)return e.props[t]}function se(e,t){let n=e.as||"";return e.as||t.slots.default||(n="input"),n}function de(e,t){return m(t.attrs.type)?V(e,"modelValue")?e.modelValue:void 0:V(e,"modelValue")?e.modelValue:t.attrs.value}const ce=t.defineComponent({name:"Field",inheritAttrs:!1,props:{as:{type:[String,Object],default:void 0},name:{type:String,required:!0},rules:{type:[Object,String,Function],default:void 0},validateOnMount:{type:Boolean,default:!1},validateOnBlur:{type:Boolean,default:void 0},validateOnChange:{type:Boolean,default:void 0},validateOnInput:{type:Boolean,default:void 0},validateOnModelUpdate:{type:Boolean,default:void 0},bails:{type:Boolean,default:()=>W().bails},label:{type:String,default:void 0},uncheckedValue:{type:null,default:void 0},modelValue:{type:null,default:d},modelModifiers:{type:null,default:()=>({})},"onUpdate:modelValue":{type:null,default:void 0},standalone:{type:Boolean,default:!1},keepValue:{type:Boolean,default:void 0}},setup(e,r){const a=t.toRef(e,"rules"),l=t.toRef(e,"name"),i=t.toRef(e,"label"),u=t.toRef(e,"uncheckedValue"),o=t.toRef(e,"keepValue"),{errors:s,value:d,errorMessage:c,validate:v,handleChange:f,handleBlur:p,setTouched:h,resetField:y,handleReset:b,meta:O,checked:V,setErrors:F}=ie(l,a,{validateOnMount:e.validateOnMount,bails:e.bails,standalone:e.standalone,type:r.attrs.type,initialValue:de(e,r),checkedValue:r.attrs.value,uncheckedValue:u,label:i,validateOnValueUpdate:!1,keepValueOnUnmount:o}),A=function(e,t=!0){f(e,t),r.emit("update:modelValue",d.value)},j=function(e){(e=>{m(r.attrs.type)||(d.value=G(e))})(e),r.emit("update:modelValue",d.value)},w=t.computed((()=>{const{validateOnInput:t,validateOnChange:a,validateOnBlur:l,validateOnModelUpdate:i}=function(e){var t,n,r,a;const{validateOnInput:l,validateOnChange:i,validateOnBlur:u,validateOnModelUpdate:o}=W();return{validateOnInput:null!==(t=e.validateOnInput)&&void 0!==t?t:l,validateOnChange:null!==(n=e.validateOnChange)&&void 0!==n?n:i,validateOnBlur:null!==(r=e.validateOnBlur)&&void 0!==r?r:u,validateOnModelUpdate:null!==(a=e.validateOnModelUpdate)&&void 0!==a?a:o}}(e);const u={name:e.name,onBlur:function(e){p(e),n(r.attrs.onBlur)&&r.attrs.onBlur(e),l&&v()},onInput:function(e){A(e,t),n(r.attrs.onInput)&&r.attrs.onInput(e)},onChange:function(e){A(e,a),n(r.attrs.onChange)&&r.attrs.onChange(e)},"onUpdate:modelValue":e=>A(e,i)};m(r.attrs.type)&&V&&(u.checked=V.value);return g(se(e,r),r.attrs)&&(u.value=d.value),u}));function S(){return{field:w.value,value:d.value,meta:O,errors:s.value,errorMessage:c.value,validate:v,resetField:y,handleChange:A,handleInput:j,handleReset:b,handleBlur:p,setTouched:h,setErrors:F}}return r.expose({setErrors:F,setTouched:h,reset:y,validate:v,handleChange:f}),()=>{const n=t.resolveDynamicComponent(se(e,r)),a=q(n,r,S);return n?t.h(n,Object.assign(Object.assign({},r.attrs),w.value),a):a}}});let ve=0;const fe=["bails","fieldsCount","id","multiple","type","validate"];function pe(e){const r=t.unref(null==e?void 0:e.initialValues)||{},a=t.unref(null==e?void 0:e.validationSchema);return a&&f(a)&&n(a.cast)?w(a.cast(r)||{}):w(r)}function me(e){var r;const a=ve++;let l=0;const u=t.ref(!1),s=t.ref(0),d=[],c=t.reactive(pe(e)),v=t.ref([]),m=t.ref({});function h(e,t){const n=H(e);n?n.errors=$(t):m.value[e]=$(t)}function y(e){M(e).forEach((t=>{h(t,e[t])}))}(null==e?void 0:e.initialErrors)&&y(e.initialErrors);const g=t.computed((()=>{const e=v.value.reduce(((e,t)=>(t.errors.length&&(e[t.path]=t.errors),e)),{});return Object.assign(Object.assign({},m.value),e)})),O=t.computed((()=>M(g.value).reduce(((e,t)=>{const n=g.value[t];return(null==n?void 0:n.length)&&(e[t]=n[0]),e}),{}))),V=t.computed((()=>v.value.reduce(((e,t)=>(e[t.path]={name:t.path||"",label:t.label||""},e)),{}))),A=t.computed((()=>v.value.reduce(((e,t)=>{var n;return e[t.path]=null===(n=t.bails)||void 0===n||n,e}),{}))),j=Object.assign({},(null==e?void 0:e.initialErrors)||{}),S=null!==(r=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==r&&r,{initialValues:I,originalInitialValues:B,setInitialValues:T}=function(e,n,r){const a=pe(r),l=null==r?void 0:r.initialValues,i=t.ref(a),u=t.ref(w(a));function o(t,r=!1){i.value=w(t),u.value=w(t),r&&e.value.forEach((e=>{if(e.touched)return;const t=E(i.value,e.path);k(n,e.path,w(t))}))}t.isRef(l)&&t.watch(l,(e=>{o(e,!0)}),{deep:!0});return{initialValues:i,originalInitialValues:u,setInitialValues:o}}(v,c,e),P=function(e,n,r,a){const l={touched:"some",pending:"some",valid:"every"},i=t.computed((()=>!F(n,t.unref(r))));function u(){const t=e.value;return M(l).reduce(((e,n)=>{const r=l[n];return e[n]=t[r]((e=>e[n])),e}),{})}const o=t.reactive(u());return t.watchEffect((()=>{const e=u();o.touched=e.touched,o.valid=e.valid,o.pending=e.pending})),t.computed((()=>Object.assign(Object.assign({initialValues:t.unref(r)},o),{valid:o.valid&&!M(a.value).length,dirty:i.value})))}(v,c,B,O),x=t.computed((()=>v.value.reduce(((e,t)=>{const n=E(c,t.path);return k(e,t.path,n),e}),{}))),U=null==e?void 0:e.validationSchema;function D(e,n){var r,a;const i=t.computed((()=>E(I.value,_(e)))),u=v.value.find((n=>n.path===t.unref(e)));if(u)return"checkbox"!==(null==n?void 0:n.type)&&"radio"!==(null==n?void 0:n.type)||(u.multiple=!0),Array.isArray(u.id)?u.id.push(l++):u.id=[u.id,l++],u.fieldsCount++,u;const o=t.computed((()=>E(c,_(e)))),s=_(e),d=t.reactive({id:l++,path:e,touched:!1,pending:!1,valid:!0,validated:!!(null===(r=j[s])||void 0===r?void 0:r.length),initialValue:i,errors:t.shallowRef([]),bails:null!==(a=null==n?void 0:n.bails)&&void 0!==a&&a,label:null==n?void 0:n.label,type:(null==n?void 0:n.type)||"default",value:o,multiple:!1,fieldsCount:1,validate:null==n?void 0:n.validate,dirty:t.computed((()=>!F(t.unref(o),t.unref(i))))});return v.value.push(d),O.value[s]&&!j[s]&&t.nextTick((()=>{se(s)})),t.isRef(e)&&t.watch(e,(e=>{const n=w(o.value);t.nextTick((()=>{k(c,e,n)}))})),d}const q=R(me,5),L=R(me,5),K=N((async e=>"silent"===await e?q():L()),((e,[t])=>{const n=M(Y.errorBag.value);return[...new Set([...M(e.results),...v.value.map((e=>e.path)),...n])].reduce(((n,r)=>{const a=r,l=H(a),i=(e.results[a]||{errors:[]}).errors,u={errors:i,valid:!i.length};return n.results[a]=u,u.valid||(n.errors[a]=u.errors[0]),l&&m.value[a]&&delete m.value[a],l?(l.valid=u.valid,"silent"===t?n:"validated-only"!==t||l.validated?(h(l,u.errors),n):n):(h(a,i),n)}),{valid:e.valid,results:{},errors:{}})}));function X(e){v.value.forEach(e)}function H(e){return"string"==typeof e?v.value.find((t=>t.path===e)):e}function J(e){return function(t,n){return function(r){return r instanceof Event&&(r.preventDefault(),r.stopPropagation()),X((e=>e.touched=!0)),u.value=!0,s.value++,oe().then((a=>{const l=w(c);if(a.valid&&"function"==typeof t){const n=w(x.value);let i=e?n:l;return a.values&&(i=a.values),t(i,{evt:r,controlledValues:n,setErrors:y,setFieldError:h,setTouched:le,setFieldTouched:ae,setValues:te,setFieldValue:Z,resetForm:ue,resetField:ie})}a.valid||"function"!=typeof n||n({values:l,evt:r,errors:a.errors,results:a.results})})).then((e=>(u.value=!1,e)),(e=>{throw u.value=!1,e}))}}}const Q=J(!1);Q.withControlled=J(!0);const Y={formId:a,values:c,controlledValues:x,errorBag:g,errors:O,schema:U,submitCount:s,meta:P,isSubmitting:u,fieldArrays:d,keepValuesOnUnmount:S,validateSchema:t.unref(U)?K:void 0,validate:oe,setFieldError:h,validateField:se,setFieldValue:Z,setValues:te,setErrors:y,setFieldTouched:ae,setTouched:le,resetForm:ue,resetField:ie,handleSubmit:Q,stageInitialValue:function(t,n,r=!1){ce(t,n),k(c,t,n),r&&!(null==e?void 0:e.initialValues)&&k(B.value,t,w(n))},unsetInitialValue:de,setFieldInitialValue:ce,useFieldModel:function(e){if(!Array.isArray(e))return ne(e);return e.map(ne)},createPathState:D,getPathState:H,unsetPathValue:function(e){C(c,e)},removePathState:function(e){const t=v.value.findIndex((t=>t.path===e)),n=v.value[t];-1!==t&&n&&(n.multiple&&n.fieldsCount&&n.fieldsCount--,(!n.multiple||n.fieldsCount<=0)&&(v.value.splice(t,1),de(e)))},initialValues:I,getAllPathStates:()=>v.value};function Z(e,t){const n=w(t),r="string"==typeof e?e:e.path;H(r)||D(r),k(c,r,n)}function te(e){i(c,e),d.forEach((e=>e&&e.reset()))}function ne(e){const n=H(t.unref(e))||D(e);return t.computed({get:()=>n.value,set(r){const a=t.unref(e);Z(a,r),n.validated=!0,n.pending=!0,se(a).then((()=>{n.pending=!1}))}})}function ae(e,t){const n=H(e);n&&(n.touched=t)}function le(e){M(e).forEach((t=>{ae(t,!!e[t])}))}function ie(e,t){var n;const r=t&&"value"in t?t.value:E(I.value,e);ce(e,w(r)),Z(e,r),ae(e,null!==(n=null==t?void 0:t.touched)&&void 0!==n&&n),h(e,(null==t?void 0:t.errors)||[])}function ue(e){const n=(null==e?void 0:e.values)?e.values:B.value;T(n),te(n),X((t=>{var r;t.validated=!1,t.touched=(null===(r=null==e?void 0:e.touched)||void 0===r?void 0:r[t.path])||!1,Z(t.path,E(n,t.path)),h(t.path,void 0)})),y((null==e?void 0:e.errors)||{}),s.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{oe({mode:"silent"})}))}async function oe(e){const t=(null==e?void 0:e.mode)||"force";if("force"===t&&X((e=>e.validated=!0)),Y.validateSchema)return Y.validateSchema(t);const n=await Promise.all(v.value.map((t=>t.validate?t.validate(e).then((e=>({key:t.path,valid:e.valid,errors:e.errors}))):Promise.resolve({key:t.path,valid:!0,errors:[]})))),r={},a={};for(const e of n)r[e.key]={valid:e.valid,errors:e.errors},e.errors.length&&(a[e.key]=e.errors[0]);return{valid:n.every((e=>e.valid)),results:r,errors:a}}async function se(e){const n=H(e);if(n&&(n.validated=!0),U){const{results:t}=await K("validated-only");return t[e]||{errors:[],valid:!0}}return(null==n?void 0:n.validate)?n.validate():(n||t.warn(`field with path ${e} was not found`),Promise.resolve({errors:[],valid:!0}))}function de(e){C(I.value,e)}function ce(e,t){k(I.value,e,w(t))}async function me(){const e=t.unref(U);if(!e)return{valid:!0,results:{},errors:{}};const n=p(e)||f(e)?await async function(e,t){const n=f(e)?e:ee(e),r=await n.parse(t),a={},l={};for(const e of r.errors){const t=e.errors,n=(e.path||"").replace(/\["(\d+)"\]/g,((e,t)=>`[${t}]`));a[n]={valid:!t.length,errors:t},t.length&&(l[n]=t[0])}return{valid:!r.errors.length,results:a,errors:l,values:r.value}}(e,c):await re(e,c,{names:V.value,bailsMap:A.value});return n}const he=Q(((e,{evt:t})=>{b(t)&&t.target.submit()}));return t.onMounted((()=>{(null==e?void 0:e.initialErrors)&&y(e.initialErrors),(null==e?void 0:e.initialTouched)&&le(e.initialTouched),(null==e?void 0:e.validateOnMount)?oe():Y.validateSchema&&Y.validateSchema("silent")})),t.isRef(U)&&t.watch(U,(()=>{var e;null===(e=Y.validateSchema)||void 0===e||e.call(Y,"validated-only")})),t.provide(o,Y),Object.assign(Object.assign({},Y),{handleReset:()=>ue(),submitForm:he,defineComponentBinds:function(e,r){const a=H(_(e))||D(e),l=()=>n(r)?r(z(a,fe)):r||{};function i(){var e;a.touched=!0;(null!==(e=l().validateOnBlur)&&void 0!==e?e:W().validateOnBlur)&&se(a.path)}function u(e){var t;Z(a.path,e);(null!==(t=l().validateOnModelUpdate)&&void 0!==t?t:W().validateOnModelUpdate)&&se(a.path)}return t.computed((()=>{const e={modelValue:a.value,"onUpdate:modelValue":u,onBlur:i};return n(r)?Object.assign(Object.assign({},e),r(a).props||{}):(null==r?void 0:r.mapProps)?Object.assign(Object.assign({},e),r.mapProps(z(a,fe))):e}))},defineInputBinds:function(e,r){const a=H(_(e))||D(e),l=()=>n(r)?r(z(a,fe)):r||{};function i(){var e;a.touched=!0;(null!==(e=l().validateOnBlur)&&void 0!==e?e:W().validateOnBlur)&&se(a.path)}function u(e){var t;const n=G(e);Z(a.path,n);(null!==(t=l().validateOnInput)&&void 0!==t?t:W().validateOnInput)&&se(a.path)}function o(e){var t;const n=G(e);Z(a.path,n);(null!==(t=l().validateOnChange)&&void 0!==t?t:W().validateOnChange)&&se(a.path)}return t.computed((()=>{const e={value:a.value,onChange:o,onInput:u,onBlur:i};return n(r)?Object.assign(Object.assign({},e),r(z(a,fe)).attrs||{}):(null==r?void 0:r.mapAttrs)?Object.assign(Object.assign({},e),r.mapAttrs(z(a,fe))):e}))}})}const he=t.defineComponent({name:"Form",inheritAttrs:!1,props:{as:{type:String,default:"form"},validationSchema:{type:Object,default:void 0},initialValues:{type:Object,default:void 0},initialErrors:{type:Object,default:void 0},initialTouched:{type:Object,default:void 0},validateOnMount:{type:Boolean,default:!1},onSubmit:{type:Function,default:void 0},onInvalidSubmit:{type:Function,default:void 0},keepValues:{type:Boolean,default:!1}},setup(e,n){const r=t.toRef(e,"initialValues"),a=t.toRef(e,"validationSchema"),l=t.toRef(e,"keepValues"),{errors:i,errorBag:u,values:o,meta:s,isSubmitting:d,submitCount:c,controlledValues:v,validate:f,validateField:p,handleReset:m,resetForm:h,handleSubmit:y,setErrors:g,setFieldError:V,setFieldValue:F,setValues:A,setFieldTouched:j,setTouched:S,resetField:E}=me({validationSchema:a.value?a:void 0,initialValues:r,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:l}),k=y(((e,{evt:t})=>{b(t)&&t.target.submit()}),e.onInvalidSubmit),I=e.onSubmit?y(e.onSubmit,e.onInvalidSubmit):k;function C(e){O(e)&&e.preventDefault(),m(),"function"==typeof n.attrs.onReset&&n.attrs.onReset()}function M(t,n){return y("function"!=typeof t||n?n:t,e.onInvalidSubmit)(t)}function B(){return w(o)}function T(){return w(s.value)}function P(){return w(i.value)}function R(){return{meta:s.value,errors:i.value,errorBag:u.value,values:o,isSubmitting:d.value,submitCount:c.value,controlledValues:v.value,validate:f,validateField:p,handleSubmit:M,handleReset:m,submitForm:k,setErrors:g,setFieldError:V,setFieldValue:F,setValues:A,setFieldTouched:j,setTouched:S,resetForm:h,resetField:E,getValues:B,getMeta:T,getErrors:P}}return n.expose({setFieldError:V,setErrors:g,setFieldValue:F,setValues:A,setFieldTouched:j,setTouched:S,resetForm:h,validate:f,validateField:p,resetField:E,getValues:B,getMeta:T,getErrors:P}),function(){const r="form"===e.as?e.as:t.resolveDynamicComponent(e.as),a=q(r,n,R);if(!e.as)return a;const l="form"===e.as?{novalidate:!0}:{};return t.h(r,Object.assign(Object.assign(Object.assign({},l),n.attrs),{onSubmit:I,onReset:C}),a)}}}),ye=he;function ge(e){const n=B(o,void 0),a=t.ref([]),l=()=>{},i={fields:a,remove:l,push:l,swap:l,insert:l,update:l,replace:l,prepend:l,move:l};if(!n)return T("FieldArray requires being a child of `<Form/>` or `useForm` being called before it. Array fields may not work correctly"),i;if(!t.unref(e))return T("FieldArray requires a field path to be provided, did you forget to pass the `name` prop?"),i;const u=n.fieldArrays.find((n=>t.unref(n.path)===t.unref(e)));if(u)return u;let s=0;function d(){return E(null==n?void 0:n.values,t.unref(e),[])||[]}function c(){const e=d();Array.isArray(e)&&(a.value=e.map(((e,t)=>f(e,t,a.value))),v())}function v(){const e=a.value.length;for(let t=0;t<e;t++){const n=a.value[t];n.isFirst=0===t,n.isLast=t===e-1}}function f(l,i,u){if(u&&!r(i)&&u[i])return u[i];const o=s++,d={key:o,value:U({get(){const r=E(null==n?void 0:n.values,t.unref(e),[])||[],i=a.value.findIndex((e=>e.key===o));return-1===i?l:r[i]},set(e){const t=a.value.findIndex((e=>e.key===o));-1!==t?m(t,e):T("Attempting to update a non-existent array item")}}),isFirst:!1,isLast:!1};return d}function p(){v(),null==n||n.validate({mode:"silent"})}function m(r,a){const l=t.unref(e),i=E(null==n?void 0:n.values,l);!Array.isArray(i)||i.length-1<r||(k(n.values,`${l}[${r}]`,a),null==n||n.validate({mode:"validated-only"}))}c();const h={fields:a,remove:function(r){const l=t.unref(e),i=E(null==n?void 0:n.values,l);if(!i||!Array.isArray(i))return;const u=[...i];u.splice(r,1);const o=l+`[${r}]`;n.unsetInitialValue(o),k(n.values,l,u),a.value.splice(r,1),p()},push:function(l){const i=t.unref(e),u=E(null==n?void 0:n.values,i),o=r(u)?[]:u;if(!Array.isArray(o))return;const s=[...o];s.push(l),n.stageInitialValue(i+`[${s.length-1}]`,l),k(n.values,i,s),a.value.push(f(l)),p()},swap:function(r,l){const i=t.unref(e),u=E(null==n?void 0:n.values,i);if(!Array.isArray(u)||!(r in u)||!(l in u))return;const o=[...u],s=[...a.value],d=o[r];o[r]=o[l],o[l]=d;const c=s[r];s[r]=s[l],s[l]=c,k(n.values,i,o),a.value=s,v()},insert:function(r,l){const i=t.unref(e),u=E(null==n?void 0:n.values,i);if(!Array.isArray(u)||u.length<r)return;const o=[...u],s=[...a.value];o.splice(r,0,l),s.splice(r,0,f(l)),k(n.values,i,o),a.value=s,p()},update:m,replace:function(r){const a=t.unref(e);n.stageInitialValue(a,r),k(n.values,a,r),c(),p()},prepend:function(l){const i=t.unref(e),u=E(null==n?void 0:n.values,i),o=r(u)?[]:u;if(!Array.isArray(o))return;const s=[l,...o];n.stageInitialValue(i+`[${s.length-1}]`,l),k(n.values,i,s),a.value.unshift(f(l)),p()},move:function(l,i){const u=t.unref(e),o=E(null==n?void 0:n.values,u),s=r(o)?[]:[...o];if(!Array.isArray(o)||!(l in o)||!(i in o))return;const d=[...a.value],c=d[l];d.splice(l,1),d.splice(i,0,c);const v=s[l];s.splice(l,1),s.splice(i,0,v),k(n.values,u,s),a.value=d,p()}};return n.fieldArrays.push(Object.assign({path:e,reset:c},h)),t.onBeforeUnmount((()=>{const r=n.fieldArrays.findIndex((n=>t.unref(n.path)===t.unref(e)));r>=0&&n.fieldArrays.splice(r,1)})),t.watch(d,(e=>{F(e,a.value.map((e=>e.value)))||c()})),h}const be=t.defineComponent({name:"FieldArray",inheritAttrs:!1,props:{name:{type:String,required:!0}},setup(e,n){const{push:r,remove:a,swap:l,insert:i,replace:u,update:o,prepend:s,move:d,fields:c}=ge(t.toRef(e,"name"));function v(){return{fields:c.value,push:r,remove:a,swap:l,insert:i,update:o,replace:u,prepend:s,move:d}}return n.expose({push:r,remove:a,swap:l,insert:i,update:o,replace:u,prepend:s,move:d}),()=>q(void 0,n,v)}}),Oe=t.defineComponent({name:"ErrorMessage",props:{as:{type:String,default:void 0},name:{type:String,required:!0}},setup(e,n){const r=t.inject(o,void 0),a=t.computed((()=>null==r?void 0:r.errors.value[e.name]));function l(){return{message:a.value}}return()=>{if(!a.value)return;const r=e.as?t.resolveDynamicComponent(e.as):e.as,i=q(r,n,l),u=Object.assign({role:"alert"},n.attrs);return r||!Array.isArray(i)&&i||!(null==i?void 0:i.length)?!Array.isArray(i)&&i||(null==i?void 0:i.length)?t.h(r,u,i):t.h(r||"span",u,a.value):i}}});e.ErrorMessage=Oe,e.Field=ce,e.FieldArray=be,e.FieldContextKey=s,e.Form=ye,e.FormContextKey=o,e.IS_ABSENT=d,e.configure=Y,e.defineRule=function(e,t){!function(e,t){if(n(t))return;throw new Error(`Extension Error: The validator '${e}' must be a function.`)}(e,t),u[e]=t},e.useField=ie,e.useFieldArray=ge,e.useFieldError=function(e){const n=B(o),r=e?void 0:t.inject(s);return t.computed((()=>e?null==n?void 0:n.errors.value[t.unref(e)]:null==r?void 0:r.errorMessage.value))},e.useFieldValue=function(e){const n=B(o),r=e?void 0:t.inject(s);return t.computed((()=>e?E(null==n?void 0:n.values,t.unref(e)):t.unref(null==r?void 0:r.value)))},e.useForm=me,e.useFormErrors=function(){const e=B(o);return e||T("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>(null==e?void 0:e.errors.value)||{}))},e.useFormValues=function(){const e=B(o);return e||T("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>(null==e?void 0:e.values)||{}))},e.useIsFieldDirty=function(e){const n=D(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.dirty:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.dirty)&&void 0!==t&&t)}))},e.useIsFieldTouched=function(e){const n=D(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.touched:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.touched)&&void 0!==t&&t)}))},e.useIsFieldValid=function(e){const n=D(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.valid:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.valid)&&void 0!==t&&t)}))},e.useIsFormDirty=function(){const e=B(o);return e||T("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.dirty)&&void 0!==t&&t}))},e.useIsFormTouched=function(){const e=B(o);return e||T("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.touched)&&void 0!==t&&t}))},e.useIsFormValid=function(){const e=B(o);return e||T("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.valid)&&void 0!==t&&t}))},e.useIsSubmitting=function(){const e=B(o);return e||T("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isSubmitting.value)&&void 0!==t&&t}))},e.useResetForm=function(){const e=B(o);return e||T("No vee-validate <Form /> or `useForm` was detected in the component tree"),function(t){if(e)return e.resetForm(t)}},e.useSubmitCount=function(){const e=B(o);return e||T("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.submitCount.value)&&void 0!==t?t:0}))},e.useSubmitForm=function(e){const t=B(o);t||T("No vee-validate <Form /> or `useForm` was detected in the component tree");const n=t?t.handleSubmit(e):void 0;return function(e){if(n)return n(e)}},e.useValidateField=function(e){const n=B(o),r=e?void 0:t.inject(s);return function(){return r?r.validate():n&&e?null==n?void 0:n.validateField(t.unref(e)):(T(`field with name ${t.unref(e)} was not found`),Promise.resolve({errors:[],valid:!0}))}},e.useValidateForm=function(){const e=B(o);return e||T("No vee-validate <Form /> or `useForm` was detected in the component tree"),function(){return e?e.validate():Promise.resolve({results:{},errors:{},valid:!0})}},e.validate=Z,e.validateObject=re}));
6
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VeeValidate={},e.Vue)}(this,(function(e,t){"use strict";function n(e){return"function"==typeof e}function r(e){return null==e}const a=e=>null!==e&&!!e&&"object"==typeof e&&!Array.isArray(e);function i(e){return Number(e)>=0}function l(e,t){return Object.keys(t).forEach((n=>{if(a(t[n]))return e[n]||(e[n]={}),void l(e[n],t[n]);e[n]=t[n]})),e}const u={};const o=Symbol("vee-validate-form"),s=Symbol("vee-validate-field-instance"),d=Symbol("Default empty value"),c="undefined"!=typeof window;function v(e){return n(e)&&!!e.__locatorRef}function f(e){return!!e&&n(e.parse)&&"VVTypedSchema"===e.__type}function p(e){return!!e&&n(e.validate)}function m(e){return"checkbox"===e||"radio"===e}function h(e){return/^\[.+\]$/i.test(e)}function y(e){return"SELECT"===e.tagName}function g(e,t){return!function(e,t){const n=![!1,null,void 0,0].includes(t.multiple)&&!Number.isNaN(t.multiple);return"select"===e&&"multiple"in t&&n}(e,t)&&"file"!==t.type&&!m(t.type)}function b(e){return V(e)&&e.target&&"submit"in e.target}function V(e){return!!e&&(!!("undefined"!=typeof Event&&n(Event)&&e instanceof Event)||!(!e||!e.srcElement))}function O(e,t){return t in e&&e[t]!==d}function F(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;var n,r,a;if(Array.isArray(e)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(!F(e[r],t[r]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;for(r of e.entries())if(!F(r[1],t.get(r[0])))return!1;return!0}if(A(e)&&A(t))return e.size===t.size&&(e.name===t.name&&(e.lastModified===t.lastModified&&e.type===t.type));if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(e[r]!==t[r])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if((n=(a=Object.keys(e)).length)!==Object.keys(t).length)return!1;for(r=n;0!=r--;)if(!Object.prototype.hasOwnProperty.call(t,a[r]))return!1;for(r=n;0!=r--;){var i=a[r];if(!F(e[i],t[i]))return!1}return!0}return e!=e&&t!=t}function A(e){return!!c&&e instanceof File}function j(e,t,n){"object"==typeof n.value&&(n.value=w(n.value)),n.enumerable&&!n.get&&!n.set&&n.configurable&&n.writable&&"__proto__"!==t?e[t]=n.value:Object.defineProperty(e,t,n)}function w(e){if("object"!=typeof e)return e;var t,n,r,a=0,i=Object.prototype.toString.call(e);if("[object Object]"===i?r=Object.create(e.__proto__||null):"[object Array]"===i?r=Array(e.length):"[object Set]"===i?(r=new Set,e.forEach((function(e){r.add(w(e))}))):"[object Map]"===i?(r=new Map,e.forEach((function(e,t){r.set(w(t),w(e))}))):"[object Date]"===i?r=new Date(+e):"[object RegExp]"===i?r=new RegExp(e.source,e.flags):"[object DataView]"===i?r=new e.constructor(w(e.buffer)):"[object ArrayBuffer]"===i?r=e.slice(0):"Array]"===i.slice(-6)&&(r=new e.constructor(e)),r){for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)j(r,n[a],Object.getOwnPropertyDescriptor(e,n[a]));for(a=0,n=Object.getOwnPropertyNames(e);a<n.length;a++)Object.hasOwnProperty.call(r,t=n[a])&&r[t]===e[t]||j(r,t,Object.getOwnPropertyDescriptor(e,t))}return r||e}function S(e){return h(e)?e.replace(/\[|\]/gi,""):e}function E(e,t,n){if(!e)return n;if(h(t))return e[S(t)];return(t||"").split(/\.|\[(\d+)\]/).filter(Boolean).reduce(((e,t)=>{return(a(r=e)||Array.isArray(r))&&t in e?e[t]:n;var r}),e)}function k(e,t,n){if(h(t))return void(e[S(t)]=n);const a=t.split(/\.|\[(\d+)\]/).filter(Boolean);let l=e;for(let e=0;e<a.length;e++){if(e===a.length-1)return void(l[a[e]]=n);a[e]in l&&!r(l[a[e]])||(l[a[e]]=i(a[e+1])?[]:{}),l=l[a[e]]}}function I(e,t){Array.isArray(e)&&i(t)?e.splice(Number(t),1):a(e)&&delete e[t]}function C(e,t){if(h(t))return void delete e[S(t)];const n=t.split(/\.|\[(\d+)\]/).filter(Boolean);let i=e;for(let e=0;e<n.length;e++){if(e===n.length-1){I(i,n[e]);break}if(!(n[e]in i)||r(i[n[e]]))break;i=i[n[e]]}const l=n.map(((t,r)=>E(e,n.slice(0,r).join("."))));for(let t=l.length-1;t>=0;t--)u=l[t],(Array.isArray(u)?0===u.length:a(u)&&0===Object.keys(u).length)&&(0!==t?I(l[t-1],n[t-1]):I(e,n[0]));var u}function M(e){return Object.keys(e)}function B(e,n=void 0){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function _(e){t.warn(`[vee-validate]: ${e}`)}function T(e,t,n){if(Array.isArray(e)){const n=[...e],r=n.findIndex((e=>F(e,t)));return r>=0?n.splice(r,1):n.push(t),n}return F(e,t)?n:t}function U(e,t=0){let n=null,r=[];return function(...a){return n&&window.clearTimeout(n),n=window.setTimeout((()=>{const t=e(...a);r.forEach((e=>e(t))),r=[]}),t),new Promise((e=>r.push(e)))}}function P(e,t){return a(t)&&t.number?function(e){const t=parseFloat(e);return isNaN(t)?e:t}(e):e}function R(e,t){let n;return async function(...r){const a=e(...r);n=a;const i=await a;return a!==n||(n=void 0,t(i,r)),i}}function x({get:e,set:n}){const r=t.ref(w(e()));return t.watch(e,(e=>{F(e,r.value)||(r.value=w(e))}),{deep:!0}),t.watch(r,(t=>{F(t,e())||n(w(t))}),{deep:!0}),r}function N(e){return n(e)?e():t.unref(e)}function $(e){return Array.isArray(e)?e:e?[e]:[]}function D(e){const n=B(o),r=e?t.computed((()=>null==n?void 0:n.getPathState(t.unref(e)))):void 0,a=e?void 0:t.inject(s);return a||(null==r?void 0:r.value)||_(`field with name ${t.unref(e)} was not found`),r||a}function z(e,t){const n={};for(const r in e)t.includes(r)||(n[r]=e[r]);return n}const q=(e,t,n)=>t.slots.default?"string"!=typeof e&&e?{default:()=>{var e,r;return null===(r=(e=t.slots).default)||void 0===r?void 0:r.call(e,n())}}:t.slots.default(n()):t.slots.default;function L(e){if(K(e))return e._value}function K(e){return"_value"in e}function W(e){if(!V(e))return e;const t=e.target;if(m(t.type)&&K(t))return L(t);if("file"===t.type&&t.files){const e=Array.from(t.files);return t.multiple?e:e[0]}if(y(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map(L);var n;if(y(t)){const e=Array.from(t.options).find((e=>e.selected));return e?L(e):t.value}return t.value}function G(e){const t={};return Object.defineProperty(t,"_$$isNormalized",{value:!0,writable:!1,enumerable:!1,configurable:!1}),e?a(e)&&e._$$isNormalized?e:a(e)?Object.keys(e).reduce(((t,n)=>{const r=function(e){if(!0===e)return[];if(Array.isArray(e))return e;if(a(e))return e;return[e]}(e[n]);return!1!==e[n]&&(t[n]=X(r)),t}),t):"string"!=typeof e?t:e.split("|").reduce(((e,t)=>{const n=H(t);return n.name?(e[n.name]=X(n.params),e):e}),t):t}function X(e){const t=e=>"string"==typeof e&&"@"===e[0]?function(e){const t=t=>E(t,e)||t[e];return t.__locatorRef=e,t}(e.slice(1)):e;return Array.isArray(e)?e.map(t):e instanceof RegExp?[e]:Object.keys(e).reduce(((n,r)=>(n[r]=t(e[r]),n)),{})}const H=e=>{let t=[];const n=e.split(":")[0];return e.includes(":")&&(t=e.split(":").slice(1).join(":").split(",")),{name:n,params:t}};let J=Object.assign({},{generateMessage:({field:e})=>`${e} is not valid.`,bails:!0,validateOnBlur:!0,validateOnChange:!0,validateOnInput:!1,validateOnModelUpdate:!0});const Q=()=>J,Y=e=>{J=Object.assign(Object.assign({},J),e)};async function Z(e,t,r={}){const a=null==r?void 0:r.bails,i={name:(null==r?void 0:r.name)||"{field}",rules:t,label:null==r?void 0:r.label,bails:null==a||a,formData:(null==r?void 0:r.values)||{}},l=await async function(e,t){if(f(e.rules)||p(e.rules))return async function(e,t){const n=f(t)?t:ee(t),r=await n.parse(e),a=[];for(const e of r.errors)e.errors.length&&a.push(...e.errors);return{errors:a}}(t,e.rules);if(n(e.rules)||Array.isArray(e.rules)){const n={field:e.label||e.name,name:e.name,label:e.label,form:e.formData,value:t},r=Array.isArray(e.rules)?e.rules:[e.rules],a=r.length,i=[];for(let l=0;l<a;l++){const a=r[l],u=await a(t,n);if("string"!=typeof u&&u)continue;const o="string"==typeof u?u:ne(n);if(i.push(o),e.bails)return{errors:i}}return{errors:i}}const r=Object.assign(Object.assign({},e),{rules:G(e.rules)}),a=[],i=Object.keys(r.rules),l=i.length;for(let n=0;n<l;n++){const l=i[n],u=await te(r,t,{name:l,params:r.rules[l]});if(u.error&&(a.push(u.error),e.bails))return{errors:a}}return{errors:a}}(i,e),u=l.errors;return{errors:u,valid:!u.length}}function ee(e){return{__type:"VVTypedSchema",async parse(t){var n;try{return{output:await e.validate(t,{abortEarly:!1}),errors:[]}}catch(e){if(!function(e){return!!e&&"ValidationError"===e.name}(e))throw e;if(!(null===(n=e.inner)||void 0===n?void 0:n.length)&&e.errors.length)return{errors:[{path:e.path,errors:e.errors}]};const t=e.inner.reduce(((e,t)=>{const n=t.path||"";return e[n]||(e[n]={errors:[],path:n}),e[n].errors.push(...t.errors),e}),{});return{errors:Object.values(t)}}}}}async function te(e,t,n){const r=(a=n.name,u[a]);var a;if(!r)throw new Error(`No such validator '${n.name}' exists.`);const i=function(e,t){const n=e=>v(e)?e(t):e;if(Array.isArray(e))return e.map(n);return Object.keys(e).reduce(((t,r)=>(t[r]=n(e[r]),t)),{})}(n.params,e.formData),l={field:e.label||e.name,name:e.name,label:e.label,value:t,form:e.formData,rule:Object.assign(Object.assign({},n),{params:i})},o=await r(t,i,l);return"string"==typeof o?{error:o}:{error:o?void 0:ne(l)}}function ne(e){const t=Q().generateMessage;return t?t(e):"Field is invalid"}async function re(e,t,n){const r=M(e).map((async r=>{var a,i,l;const u=null===(a=null==n?void 0:n.names)||void 0===a?void 0:a[r],o=await Z(E(t,r),e[r],{name:(null==u?void 0:u.name)||r,label:null==u?void 0:u.label,values:t,bails:null===(l=null===(i=null==n?void 0:n.bailsMap)||void 0===i?void 0:i[r])||void 0===l||l});return Object.assign(Object.assign({},o),{path:r})}));let a=!0;const i=await Promise.all(r),l={},u={};for(const e of i)l[e.path]={valid:e.valid,errors:e.errors},e.valid||(a=!1,u[e.path]=e.errors[0]);return{valid:a,results:l,errors:u}}let ae=0;function ie(e,n){const{value:r,initialValue:a,setInitialValue:i}=function(e,n,r){const a=t.ref(t.unref(n));function i(){return r?E(r.initialValues.value,t.unref(e),t.unref(a)):t.unref(a)}function l(n){r?r.stageInitialValue(t.unref(e),n,!0):a.value=n}const u=t.computed(i);if(!r){return{value:t.ref(i()),initialValue:u,setInitialValue:l}}const o=function(e,n,r,a){if(t.isRef(e))return t.unref(e);if(void 0!==e)return e;return E(n.values,t.unref(a),t.unref(r))}(n,r,u,e);r.stageInitialValue(t.unref(e),o,!0);const s=t.computed({get:()=>E(r.values,t.unref(e)),set(n){r.setFieldValue(t.unref(e),n)}});return{value:s,initialValue:u,setInitialValue:l}}(e,n.modelValue,n.form);if(!n.form){const{errors:o,setErrors:s}=function(){const e=t.ref([]);return{errors:e,setErrors:t=>{e.value=$(t)}}}(),d=ae>=Number.MAX_SAFE_INTEGER?0:++ae,c=function(e,n,r){const a=t.reactive({touched:!1,pending:!1,valid:!0,validated:!!t.unref(r).length,initialValue:t.computed((()=>t.unref(n))),dirty:t.computed((()=>!F(t.unref(e),t.unref(n))))});return t.watch(r,(e=>{a.valid=!e.length}),{immediate:!0,flush:"sync"}),a}(r,a,o);function v(e){var t;"value"in e&&(r.value=e.value),"errors"in e&&s(e.errors),"touched"in e&&(c.touched=null!==(t=e.touched)&&void 0!==t?t:c.touched),"initialValue"in e&&i(e.initialValue)}return{id:d,path:e,value:r,initialValue:a,meta:c,flags:{pendingUnmount:{[d]:!1}},errors:o,setState:v}}const l=n.form.createPathState(e,{bails:n.bails,label:n.label,type:n.type,validate:n.validate}),u=t.computed((()=>l.errors));return{id:Array.isArray(l.id)?l.id[l.id.length-1]:l.id,path:e,value:r,errors:u,meta:l,initialValue:a,flags:l.__flags,setState:function(a){var l,u,o;"value"in a&&(r.value=a.value),"errors"in a&&(null===(l=n.form)||void 0===l||l.setFieldError(t.unref(e),a.errors)),"touched"in a&&(null===(u=n.form)||void 0===u||u.setFieldTouched(t.unref(e),null!==(o=a.touched)&&void 0!==o&&o)),"initialValue"in a&&i(a.initialValue)}}}function le(e,n,r){return m(null==r?void 0:r.type)?function(e,n,r){const a=(null==r?void 0:r.standalone)?void 0:B(o),i=null==r?void 0:r.checkedValue,l=null==r?void 0:r.uncheckedValue;function u(n){const r=n.handleChange,u=t.computed((()=>{const e=t.unref(n.value),r=t.unref(i);return Array.isArray(e)?e.findIndex((e=>F(e,r)))>=0:F(r,e)}));function o(o,s=!0){var d;if(u.value===(null===(d=null==o?void 0:o.target)||void 0===d?void 0:d.checked))return void(s&&n.validate());const c=N(e),v=null==a?void 0:a.getPathState(c),f=W(o);let p;p=a&&(null==v?void 0:v.multiple)&&"checkbox"===v.type?T(E(a.values,c)||[],f,void 0):T(t.unref(n.value),t.unref(i),t.unref(l)),r(p,s)}return Object.assign(Object.assign({},n),{checked:u,checkedValue:i,uncheckedValue:l,handleChange:o})}return u(ue(e,n,r))}(e,n,r):ue(e,n,r)}function ue(e,r,a){const{initialValue:i,validateOnMount:l,bails:u,type:c,checkedValue:m,label:h,validateOnValueUpdate:y,uncheckedValue:g,controlled:b,keepValueOnUnmount:V,modelPropName:O,syncVModel:A,form:j}=function(e){var n;const r=()=>({initialValue:void 0,validateOnMount:!1,bails:!0,label:void 0,validateOnValueUpdate:!0,keepValueOnUnmount:void 0,modelPropName:"modelValue",syncVModel:!0,controlled:!0}),a=null===(n=null==e?void 0:e.syncVModel)||void 0===n||n,i=a&&!("initialValue"in(e||{}))?oe(t.getCurrentInstance(),(null==e?void 0:e.modelPropName)||"modelValue"):null==e?void 0:e.initialValue;if(!e)return Object.assign(Object.assign({},r()),{initialValue:i});const l="valueProp"in e?e.valueProp:e.checkedValue,u="standalone"in e?!e.standalone:e.controlled;return Object.assign(Object.assign(Object.assign({},r()),e||{}),{initialValue:i,controlled:null==u||u,checkedValue:l})}(a),S=b?B(o):void 0,k=j||S,I=function(e){return t.computed((()=>N(e)))}(e),C=t.computed((()=>{if(t.unref(null==k?void 0:k.schema))return;const e=t.unref(r);return p(e)||f(e)||n(e)||Array.isArray(e)?e:G(e)})),{id:_,value:T,initialValue:U,meta:x,setState:$,errors:D,flags:z}=ie(I,{modelValue:i,form:k,bails:u,label:h,type:c,validate:C.value?H:void 0}),q=t.computed((()=>D.value[0]));A&&function({prop:e,value:n,handleChange:r}){const a=t.getCurrentInstance();if(!a)return;const i=e||"modelValue",l=`update:${i}`;if(!(i in a.props))return;t.watch(n,(e=>{F(e,oe(a,i))||a.emit(l,e)})),t.watch((()=>oe(a,i)),(e=>{if(e===d&&void 0===n.value)return;const t=e===d?void 0:e;F(t,P(n.value,a.props.modelModifiers))||r(t)}))}({value:T,prop:O,handleChange:J});async function L(e){var n,r;return(null==k?void 0:k.validateSchema)?null!==(n=(await k.validateSchema(e)).results[t.unref(I)])&&void 0!==n?n:{valid:!0,errors:[]}:C.value?Z(T.value,C.value,{name:t.unref(I),label:t.unref(h),values:null!==(r=null==k?void 0:k.values)&&void 0!==r?r:{},bails:u}):{valid:!0,errors:[]}}const K=R((async()=>(x.pending=!0,x.validated=!0,L("validated-only"))),(e=>{if(!z.pendingUnmount[te.id])return $({errors:e.errors}),x.pending=!1,x.valid=e.valid,e})),X=R((async()=>L("silent")),(e=>(x.valid=e.valid,e)));function H(e){return"silent"===(null==e?void 0:e.mode)?X():K()}function J(e,t=!0){Y(W(e),t)}function Q(e){var t;const n=e&&"value"in e?e.value:U.value;$({value:w(n),initialValue:w(n),touched:null!==(t=null==e?void 0:e.touched)&&void 0!==t&&t,errors:(null==e?void 0:e.errors)||[]}),x.pending=!1,x.validated=!1,X()}function Y(e,t=!0){if(T.value=e,!t)return void X();(t?K:X)()}t.onMounted((()=>{if(l)return K();k&&k.validateSchema||X()}));const ee=t.computed({get:()=>T.value,set(e){Y(e,y)}}),te={id:_,name:I,label:h,value:ee,meta:x,errors:D,errorMessage:q,type:c,checkedValue:m,uncheckedValue:g,bails:u,keepValueOnUnmount:V,resetField:Q,handleReset:()=>Q(),validate:H,handleChange:J,handleBlur:()=>{x.touched=!0},setState:$,setTouched:function(e){x.touched=e},setErrors:function(e){$({errors:Array.isArray(e)?e:[e]})},setValue:Y};if(t.provide(s,te),t.isRef(r)&&"function"!=typeof t.unref(r)&&t.watch(r,((e,t)=>{F(e,t)||(x.validated?K():X())}),{deep:!0}),!k)return te;const ne=t.computed((()=>{const e=C.value;return!e||n(e)||p(e)||f(e)||Array.isArray(e)?{}:Object.keys(e).reduce(((t,n)=>{const r=(a=e[n],Array.isArray(a)?a.filter(v):M(a).filter((e=>v(a[e]))).map((e=>a[e]))).map((e=>e.__locatorRef)).reduce(((e,t)=>{const n=E(k.values,t)||k.values[t];return void 0!==n&&(e[t]=n),e}),{});var a;return Object.assign(t,r),t}),{})}));return t.watch(ne,((e,t)=>{if(!Object.keys(e).length)return;!F(e,t)&&(x.validated?K():X())})),t.onBeforeUnmount((()=>{var e;const n=null!==(e=t.unref(te.keepValueOnUnmount))&&void 0!==e?e:t.unref(k.keepValuesOnUnmount),r=N(I);if(n||!k||z.pendingUnmount[te.id])return void(null==k||k.removePathState(r,_));z.pendingUnmount[te.id]=!0;const a=k.getPathState(r);if(Array.isArray(null==a?void 0:a.id)&&(null==a?void 0:a.multiple)?null==a?void 0:a.id.includes(te.id):(null==a?void 0:a.id)===te.id){if((null==a?void 0:a.multiple)&&Array.isArray(a.value)){const e=a.value.findIndex((e=>F(e,t.unref(te.checkedValue))));if(e>-1){const t=[...a.value];t.splice(e,1),k.setFieldValue(r,t)}Array.isArray(a.id)&&a.id.splice(a.id.indexOf(te.id),1)}else k.unsetPathValue(N(I));k.removePathState(r,_)}})),te}function oe(e,t){if(e)return e.props[t]}function se(e,t){let n=e.as||"";return e.as||t.slots.default||(n="input"),n}function de(e,t){return m(t.attrs.type)?O(e,"modelValue")?e.modelValue:void 0:O(e,"modelValue")?e.modelValue:t.attrs.value}const ce=t.defineComponent({name:"Field",inheritAttrs:!1,props:{as:{type:[String,Object],default:void 0},name:{type:String,required:!0},rules:{type:[Object,String,Function],default:void 0},validateOnMount:{type:Boolean,default:!1},validateOnBlur:{type:Boolean,default:void 0},validateOnChange:{type:Boolean,default:void 0},validateOnInput:{type:Boolean,default:void 0},validateOnModelUpdate:{type:Boolean,default:void 0},bails:{type:Boolean,default:()=>Q().bails},label:{type:String,default:void 0},uncheckedValue:{type:null,default:void 0},modelValue:{type:null,default:d},modelModifiers:{type:null,default:()=>({})},"onUpdate:modelValue":{type:null,default:void 0},standalone:{type:Boolean,default:!1},keepValue:{type:Boolean,default:void 0}},setup(e,r){const a=t.toRef(e,"rules"),i=t.toRef(e,"name"),l=t.toRef(e,"label"),u=t.toRef(e,"uncheckedValue"),o=t.toRef(e,"keepValue"),{errors:s,value:d,errorMessage:c,validate:v,handleChange:f,handleBlur:p,setTouched:h,resetField:y,handleReset:b,meta:V,checked:O,setErrors:F}=le(i,a,{validateOnMount:e.validateOnMount,bails:e.bails,standalone:e.standalone,type:r.attrs.type,initialValue:de(e,r),checkedValue:r.attrs.value,uncheckedValue:u,label:l,validateOnValueUpdate:!1,keepValueOnUnmount:o}),A=function(e,t=!0){f(e,t),r.emit("update:modelValue",d.value)},j=t.computed((()=>{const{validateOnInput:t,validateOnChange:a,validateOnBlur:i,validateOnModelUpdate:l}=function(e){var t,n,r,a;const{validateOnInput:i,validateOnChange:l,validateOnBlur:u,validateOnModelUpdate:o}=Q();return{validateOnInput:null!==(t=e.validateOnInput)&&void 0!==t?t:i,validateOnChange:null!==(n=e.validateOnChange)&&void 0!==n?n:l,validateOnBlur:null!==(r=e.validateOnBlur)&&void 0!==r?r:u,validateOnModelUpdate:null!==(a=e.validateOnModelUpdate)&&void 0!==a?a:o}}(e);const u={name:e.name,onBlur:function(e){p(e),n(r.attrs.onBlur)&&r.attrs.onBlur(e),i&&v()},onInput:function(e){A(e,t),n(r.attrs.onInput)&&r.attrs.onInput(e)},onChange:function(e){A(e,a),n(r.attrs.onChange)&&r.attrs.onChange(e)},"onUpdate:modelValue":e=>A(e,l)};m(r.attrs.type)&&O&&(u.checked=O.value);return g(se(e,r),r.attrs)&&(u.value=d.value),u}));function w(){return{field:j.value,value:d.value,meta:V,errors:s.value,errorMessage:c.value,validate:v,resetField:y,handleChange:A,handleInput:e=>A(e,!1),handleReset:b,handleBlur:p,setTouched:h,setErrors:F}}return r.expose({setErrors:F,setTouched:h,reset:y,validate:v,handleChange:f}),()=>{const n=t.resolveDynamicComponent(se(e,r)),a=q(n,r,w);return n?t.h(n,Object.assign(Object.assign({},r.attrs),j.value),a):a}}});let ve=0;const fe=["bails","fieldsCount","id","multiple","type","validate"];function pe(e){const r=t.unref(null==e?void 0:e.initialValues)||{},a=t.unref(null==e?void 0:e.validationSchema);return a&&f(a)&&n(a.cast)?w(a.cast(r)||{}):w(r)}function me(e){var r;const a=ve++;let i=0;const u=t.ref(!1),s=t.ref(!1),d=t.ref(0),c=[],v=t.reactive(pe(e)),m=t.ref([]),h=t.ref({});function y(e,t){const n=H(e);n?n.errors=$(t):h.value[e]=$(t)}function g(e){M(e).forEach((t=>{y(t,e[t])}))}(null==e?void 0:e.initialErrors)&&g(e.initialErrors);const V=t.computed((()=>{const e=m.value.reduce(((e,t)=>(t.errors.length&&(e[t.path]=t.errors),e)),{});return Object.assign(Object.assign({},h.value),e)})),O=t.computed((()=>M(V.value).reduce(((e,t)=>{const n=V.value[t];return(null==n?void 0:n.length)&&(e[t]=n[0]),e}),{}))),A=t.computed((()=>m.value.reduce(((e,t)=>(e[t.path]={name:t.path||"",label:t.label||""},e)),{}))),j=t.computed((()=>m.value.reduce(((e,t)=>{var n;return e[t.path]=null===(n=t.bails)||void 0===n||n,e}),{}))),S=Object.assign({},(null==e?void 0:e.initialErrors)||{}),I=null!==(r=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==r&&r,{initialValues:B,originalInitialValues:_,setInitialValues:T}=function(e,n,r){const a=pe(r),i=null==r?void 0:r.initialValues,l=t.ref(a),u=t.ref(w(a));function o(t,r=!1){l.value=w(t),u.value=w(t),r&&e.value.forEach((e=>{if(e.touched)return;const t=E(l.value,e.path);k(n,e.path,w(t))}))}t.isRef(i)&&t.watch(i,(e=>{o(e,!0)}),{deep:!0});return{initialValues:l,originalInitialValues:u,setInitialValues:o}}(m,v,e),P=function(e,n,r,a){const i={touched:"some",pending:"some",valid:"every"},l=t.computed((()=>!F(n,t.unref(r))));function u(){const t=e.value;return M(i).reduce(((e,n)=>{const r=i[n];return e[n]=t[r]((e=>e[n])),e}),{})}const o=t.reactive(u());return t.watchEffect((()=>{const e=u();o.touched=e.touched,o.valid=e.valid,o.pending=e.pending})),t.computed((()=>Object.assign(Object.assign({initialValues:t.unref(r)},o),{valid:o.valid&&!M(a.value).length,dirty:l.value})))}(m,v,_,O),x=t.computed((()=>m.value.reduce(((e,t)=>{const n=E(v,t.path);return k(e,t.path,n),e}),{}))),D=null==e?void 0:e.validationSchema;function q(e,n){var r,a;const l=t.computed((()=>E(B.value,N(e)))),u=m.value.find((n=>n.path===t.unref(e)));if(u){"checkbox"!==(null==n?void 0:n.type)&&"radio"!==(null==n?void 0:n.type)||(u.multiple=!0);const e=i++;return Array.isArray(u.id)?u.id.push(e):u.id=[u.id,e],u.fieldsCount++,u.__flags.pendingUnmount[e]=!1,u}const o=t.computed((()=>E(v,N(e)))),s=N(e),d=i++,c=t.reactive({id:d,path:e,touched:!1,pending:!1,valid:!0,validated:!!(null===(r=S[s])||void 0===r?void 0:r.length),initialValue:l,errors:t.shallowRef([]),bails:null!==(a=null==n?void 0:n.bails)&&void 0!==a&&a,label:null==n?void 0:n.label,type:(null==n?void 0:n.type)||"default",value:o,multiple:!1,__flags:{pendingUnmount:{[d]:!1}},fieldsCount:1,validate:null==n?void 0:n.validate,dirty:t.computed((()=>!F(t.unref(o),t.unref(l))))});return m.value.push(c),O.value[s]&&!S[s]&&t.nextTick((()=>{me(s)})),t.isRef(e)&&t.watch(e,(e=>{const n=w(o.value);t.nextTick((()=>{k(v,e,n)}))})),c}const L=U(ge,5),K=U(ge,5),G=R((async e=>"silent"===await e?L():K()),((e,[t])=>{const n=M(ne.errorBag.value);return[...new Set([...M(e.results),...m.value.map((e=>e.path)),...n])].sort().reduce(((n,r)=>{const a=r,i=H(a)||function(e){const t=m.value.filter((t=>e.startsWith(t.path)));return t.reduce(((e,t)=>e?t.path.length>e.path.length?t:e:t),void 0)}(a),l=(e.results[a]||{errors:[]}).errors,u={errors:l,valid:!l.length};return n.results[a]=u,u.valid||(n.errors[a]=u.errors[0]),i&&h.value[a]&&delete h.value[a],i?(i.valid=u.valid,"silent"===t?n:"validated-only"!==t||i.validated?(y(i,u.errors),n):n):(y(a,l),n)}),{valid:e.valid,results:{},errors:{}})}));function X(e){m.value.forEach(e)}function H(e){return"string"==typeof e?m.value.find((t=>t.path===e)):e}let J,Y=[];function Z(e){return function(t,n){return function(r){return r instanceof Event&&(r.preventDefault(),r.stopPropagation()),X((e=>e.touched=!0)),u.value=!0,d.value++,ce().then((a=>{const i=w(v);if(a.valid&&"function"==typeof t){const n=w(x.value);let l=e?n:i;return a.values&&(l=a.values),t(l,{evt:r,controlledValues:n,setErrors:g,setFieldError:y,setTouched:oe,setFieldTouched:ue,setValues:ie,setFieldValue:ae,resetForm:de,resetField:se})}a.valid||"function"!=typeof n||n({values:i,evt:r,errors:a.errors,results:a.results})})).then((e=>(u.value=!1,e)),(e=>{throw u.value=!1,e}))}}}const te=Z(!1);te.withControlled=Z(!0);const ne={formId:a,values:v,controlledValues:x,errorBag:V,errors:O,schema:D,submitCount:d,meta:P,isSubmitting:u,isValidating:s,fieldArrays:c,keepValuesOnUnmount:I,validateSchema:t.unref(D)?G:void 0,validate:ce,setFieldError:y,validateField:me,setFieldValue:ae,setValues:ie,setErrors:g,setFieldTouched:ue,setTouched:oe,resetForm:de,resetField:se,handleSubmit:te,stageInitialValue:function(t,n,r=!1){ye(t,n),k(v,t,n),r&&!(null==e?void 0:e.initialValues)&&k(_.value,t,w(n))},unsetInitialValue:he,setFieldInitialValue:ye,useFieldModel:function(e){if(!Array.isArray(e))return le(e);return e.map(le)},createPathState:q,getPathState:H,unsetPathValue:function(e){return Y.push(e),J||(J=t.nextTick((()=>{[...Y].sort().reverse().forEach((e=>{C(v,e)})),Y=[],J=null}))),J},removePathState:function(e,t){const n=m.value.findIndex((t=>t.path===e)),r=m.value[n];if(-1!==n&&r){if(r.multiple&&r.fieldsCount&&r.fieldsCount--,Array.isArray(r.id)){const e=r.id.indexOf(t);e>=0&&r.id.splice(e,1),delete r.__flags.pendingUnmount[t]}(!r.multiple||r.fieldsCount<=0)&&(m.value.splice(n,1),he(e))}},initialValues:B,getAllPathStates:()=>m.value,markForUnmount:function(e){return X((t=>{t.path.startsWith(e)&&M(t.__flags.pendingUnmount).forEach((e=>{t.__flags.pendingUnmount[e]=!0}))}))}};function ae(e,t){const n=w(t),r="string"==typeof e?e:e.path;H(r)||q(r),k(v,r,n)}function ie(e){l(v,e),c.forEach((e=>e&&e.reset()))}function le(e){const n=H(t.unref(e))||q(e);return t.computed({get:()=>n.value,set(r){const a=t.unref(e);ae(a,r),n.validated=!0,n.pending=!0,me(a).then((()=>{n.pending=!1}))}})}function ue(e,t){const n=H(e);n&&(n.touched=t)}function oe(e){M(e).forEach((t=>{ue(t,!!e[t])}))}function se(e,t){var n;const r=t&&"value"in t?t.value:E(B.value,e);ye(e,w(r)),ae(e,r),ue(e,null!==(n=null==t?void 0:t.touched)&&void 0!==n&&n),y(e,(null==t?void 0:t.errors)||[])}function de(e){const n=(null==e?void 0:e.values)?e.values:_.value;T(n),ie(n),X((t=>{var r;t.validated=!1,t.touched=(null===(r=null==e?void 0:e.touched)||void 0===r?void 0:r[t.path])||!1,ae(t.path,E(n,t.path)),y(t.path,void 0)})),g((null==e?void 0:e.errors)||{}),d.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{ce({mode:"silent"})}))}async function ce(e){const t=(null==e?void 0:e.mode)||"force";if("force"===t&&X((e=>e.validated=!0)),ne.validateSchema)return ne.validateSchema(t);s.value=!0;const n=await Promise.all(m.value.map((t=>t.validate?t.validate(e).then((e=>({key:t.path,valid:e.valid,errors:e.errors}))):Promise.resolve({key:t.path,valid:!0,errors:[]}))));s.value=!1;const r={},a={};for(const e of n)r[e.key]={valid:e.valid,errors:e.errors},e.errors.length&&(a[e.key]=e.errors[0]);return{valid:n.every((e=>e.valid)),results:r,errors:a}}async function me(e){const n=H(e);if(n&&(n.validated=!0),D){const{results:t}=await G("validated-only");return t[e]||{errors:[],valid:!0}}return(null==n?void 0:n.validate)?n.validate():(n||t.warn(`field with path ${e} was not found`),Promise.resolve({errors:[],valid:!0}))}function he(e){C(B.value,e)}function ye(e,t){k(B.value,e,w(t))}async function ge(){const e=t.unref(D);if(!e)return{valid:!0,results:{},errors:{}};s.value=!0;const n=p(e)||f(e)?await async function(e,t){const n=f(e)?e:ee(e),r=await n.parse(t),a={},i={};for(const e of r.errors){const t=e.errors,n=(e.path||"").replace(/\["(\d+)"\]/g,((e,t)=>`[${t}]`));a[n]={valid:!t.length,errors:t},t.length&&(i[n]=t[0])}return{valid:!r.errors.length,results:a,errors:i,values:r.value}}(e,v):await re(e,v,{names:A.value,bailsMap:j.value});return s.value=!1,n}const be=te(((e,{evt:t})=>{b(t)&&t.target.submit()}));return t.onMounted((()=>{(null==e?void 0:e.initialErrors)&&g(e.initialErrors),(null==e?void 0:e.initialTouched)&&oe(e.initialTouched),(null==e?void 0:e.validateOnMount)?ce():ne.validateSchema&&ne.validateSchema("silent")})),t.isRef(D)&&t.watch(D,(()=>{var e;null===(e=ne.validateSchema)||void 0===e||e.call(ne,"validated-only")})),t.provide(o,ne),Object.assign(Object.assign({},ne),{handleReset:()=>de(),submitForm:be,defineComponentBinds:function(e,r){const a=H(N(e))||q(e),i=()=>n(r)?r(z(a,fe)):r||{};function l(){var e;a.touched=!0;(null!==(e=i().validateOnBlur)&&void 0!==e?e:Q().validateOnBlur)&&me(a.path)}function u(e){var t;ae(a.path,e);(null!==(t=i().validateOnModelUpdate)&&void 0!==t?t:Q().validateOnModelUpdate)&&me(a.path)}return t.computed((()=>{const e={modelValue:a.value,"onUpdate:modelValue":u,onBlur:l};return n(r)?Object.assign(Object.assign({},e),r(a).props||{}):(null==r?void 0:r.mapProps)?Object.assign(Object.assign({},e),r.mapProps(z(a,fe))):e}))},defineInputBinds:function(e,r){const a=H(N(e))||q(e),i=()=>n(r)?r(z(a,fe)):r||{};function l(){var e;a.touched=!0;(null!==(e=i().validateOnBlur)&&void 0!==e?e:Q().validateOnBlur)&&me(a.path)}function u(e){var t;const n=W(e);ae(a.path,n);(null!==(t=i().validateOnInput)&&void 0!==t?t:Q().validateOnInput)&&me(a.path)}function o(e){var t;const n=W(e);ae(a.path,n);(null!==(t=i().validateOnChange)&&void 0!==t?t:Q().validateOnChange)&&me(a.path)}return t.computed((()=>{const e={value:a.value,onChange:o,onInput:u,onBlur:l};return n(r)?Object.assign(Object.assign({},e),r(z(a,fe)).attrs||{}):(null==r?void 0:r.mapAttrs)?Object.assign(Object.assign({},e),r.mapAttrs(z(a,fe))):e}))}})}const he=t.defineComponent({name:"Form",inheritAttrs:!1,props:{as:{type:String,default:"form"},validationSchema:{type:Object,default:void 0},initialValues:{type:Object,default:void 0},initialErrors:{type:Object,default:void 0},initialTouched:{type:Object,default:void 0},validateOnMount:{type:Boolean,default:!1},onSubmit:{type:Function,default:void 0},onInvalidSubmit:{type:Function,default:void 0},keepValues:{type:Boolean,default:!1}},setup(e,n){const r=t.toRef(e,"initialValues"),a=t.toRef(e,"validationSchema"),i=t.toRef(e,"keepValues"),{errors:l,errorBag:u,values:o,meta:s,isSubmitting:d,isValidating:c,submitCount:v,controlledValues:f,validate:p,validateField:m,handleReset:h,resetForm:y,handleSubmit:g,setErrors:O,setFieldError:F,setFieldValue:A,setValues:j,setFieldTouched:S,setTouched:E,resetField:k}=me({validationSchema:a.value?a:void 0,initialValues:r,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:i}),I=g(((e,{evt:t})=>{b(t)&&t.target.submit()}),e.onInvalidSubmit),C=e.onSubmit?g(e.onSubmit,e.onInvalidSubmit):I;function M(e){V(e)&&e.preventDefault(),h(),"function"==typeof n.attrs.onReset&&n.attrs.onReset()}function B(t,n){return g("function"!=typeof t||n?n:t,e.onInvalidSubmit)(t)}function _(){return w(o)}function T(){return w(s.value)}function U(){return w(l.value)}function P(){return{meta:s.value,errors:l.value,errorBag:u.value,values:o,isSubmitting:d.value,isValidating:c.value,submitCount:v.value,controlledValues:f.value,validate:p,validateField:m,handleSubmit:B,handleReset:h,submitForm:I,setErrors:O,setFieldError:F,setFieldValue:A,setValues:j,setFieldTouched:S,setTouched:E,resetForm:y,resetField:k,getValues:_,getMeta:T,getErrors:U}}return n.expose({setFieldError:F,setErrors:O,setFieldValue:A,setValues:j,setFieldTouched:S,setTouched:E,resetForm:y,validate:p,validateField:m,resetField:k,getValues:_,getMeta:T,getErrors:U}),function(){const r="form"===e.as?e.as:t.resolveDynamicComponent(e.as),a=q(r,n,P);if(!e.as)return a;const i="form"===e.as?{novalidate:!0}:{};return t.h(r,Object.assign(Object.assign(Object.assign({},i),n.attrs),{onSubmit:C,onReset:M}),a)}}}),ye=he;function ge(e){const n=B(o,void 0),a=t.ref([]),i=()=>{},l={fields:a,remove:i,push:i,swap:i,insert:i,update:i,replace:i,prepend:i,move:i};if(!n)return _("FieldArray requires being a child of `<Form/>` or `useForm` being called before it. Array fields may not work correctly"),l;if(!t.unref(e))return _("FieldArray requires a field path to be provided, did you forget to pass the `name` prop?"),l;const u=n.fieldArrays.find((n=>t.unref(n.path)===t.unref(e)));if(u)return u;let s=0;function d(){return E(null==n?void 0:n.values,t.unref(e),[])||[]}function c(){const e=d();Array.isArray(e)&&(a.value=e.map(((e,t)=>f(e,t,a.value))),v())}function v(){const e=a.value.length;for(let t=0;t<e;t++){const n=a.value[t];n.isFirst=0===t,n.isLast=t===e-1}}function f(i,l,u){if(u&&!r(l)&&u[l])return u[l];const o=s++,d={key:o,value:x({get(){const r=E(null==n?void 0:n.values,t.unref(e),[])||[],l=a.value.findIndex((e=>e.key===o));return-1===l?i:r[l]},set(e){const t=a.value.findIndex((e=>e.key===o));-1!==t?m(t,e):_("Attempting to update a non-existent array item")}}),isFirst:!1,isLast:!1};return d}function p(){v(),null==n||n.validate({mode:"silent"})}function m(r,a){const i=t.unref(e),l=E(null==n?void 0:n.values,i);!Array.isArray(l)||l.length-1<r||(k(n.values,`${i}[${r}]`,a),null==n||n.validate({mode:"validated-only"}))}c();const h={fields:a,remove:function(r){const i=t.unref(e),l=E(null==n?void 0:n.values,i);if(!l||!Array.isArray(l))return;const u=[...l];u.splice(r,1);const o=i+`[${r}]`;n.markForUnmount(o),n.unsetInitialValue(o),k(n.values,i,u),a.value.splice(r,1),p()},push:function(i){const l=t.unref(e),u=E(null==n?void 0:n.values,l),o=r(u)?[]:u;if(!Array.isArray(o))return;const s=[...o];s.push(i),n.stageInitialValue(l+`[${s.length-1}]`,i),k(n.values,l,s),a.value.push(f(i)),p()},swap:function(r,i){const l=t.unref(e),u=E(null==n?void 0:n.values,l);if(!Array.isArray(u)||!(r in u)||!(i in u))return;const o=[...u],s=[...a.value],d=o[r];o[r]=o[i],o[i]=d;const c=s[r];s[r]=s[i],s[i]=c,k(n.values,l,o),a.value=s,v()},insert:function(r,i){const l=t.unref(e),u=E(null==n?void 0:n.values,l);if(!Array.isArray(u)||u.length<r)return;const o=[...u],s=[...a.value];o.splice(r,0,i),s.splice(r,0,f(i)),k(n.values,l,o),a.value=s,p()},update:m,replace:function(r){const a=t.unref(e);n.stageInitialValue(a,r),k(n.values,a,r),c(),p()},prepend:function(i){const l=t.unref(e),u=E(null==n?void 0:n.values,l),o=r(u)?[]:u;if(!Array.isArray(o))return;const s=[i,...o];n.stageInitialValue(l+`[${s.length-1}]`,i),k(n.values,l,s),a.value.unshift(f(i)),p()},move:function(i,l){const u=t.unref(e),o=E(null==n?void 0:n.values,u),s=r(o)?[]:[...o];if(!Array.isArray(o)||!(i in o)||!(l in o))return;const d=[...a.value],c=d[i];d.splice(i,1),d.splice(l,0,c);const v=s[i];s.splice(i,1),s.splice(l,0,v),k(n.values,u,s),a.value=d,p()}};return n.fieldArrays.push(Object.assign({path:e,reset:c},h)),t.onBeforeUnmount((()=>{const r=n.fieldArrays.findIndex((n=>t.unref(n.path)===t.unref(e)));r>=0&&n.fieldArrays.splice(r,1)})),t.watch(d,(e=>{F(e,a.value.map((e=>e.value)))||c()})),h}const be=t.defineComponent({name:"FieldArray",inheritAttrs:!1,props:{name:{type:String,required:!0}},setup(e,n){const{push:r,remove:a,swap:i,insert:l,replace:u,update:o,prepend:s,move:d,fields:c}=ge(t.toRef(e,"name"));function v(){return{fields:c.value,push:r,remove:a,swap:i,insert:l,update:o,replace:u,prepend:s,move:d}}return n.expose({push:r,remove:a,swap:i,insert:l,update:o,replace:u,prepend:s,move:d}),()=>q(void 0,n,v)}}),Ve=t.defineComponent({name:"ErrorMessage",props:{as:{type:String,default:void 0},name:{type:String,required:!0}},setup(e,n){const r=t.inject(o,void 0),a=t.computed((()=>null==r?void 0:r.errors.value[e.name]));function i(){return{message:a.value}}return()=>{if(!a.value)return;const r=e.as?t.resolveDynamicComponent(e.as):e.as,l=q(r,n,i),u=Object.assign({role:"alert"},n.attrs);return r||!Array.isArray(l)&&l||!(null==l?void 0:l.length)?!Array.isArray(l)&&l||(null==l?void 0:l.length)?t.h(r,u,l):t.h(r||"span",u,a.value):l}}});e.ErrorMessage=Ve,e.Field=ce,e.FieldArray=be,e.FieldContextKey=s,e.Form=ye,e.FormContextKey=o,e.IS_ABSENT=d,e.configure=Y,e.defineRule=function(e,t){!function(e,t){if(n(t))return;throw new Error(`Extension Error: The validator '${e}' must be a function.`)}(e,t),u[e]=t},e.useField=le,e.useFieldArray=ge,e.useFieldError=function(e){const n=B(o),r=e?void 0:t.inject(s);return t.computed((()=>e?null==n?void 0:n.errors.value[t.unref(e)]:null==r?void 0:r.errorMessage.value))},e.useFieldValue=function(e){const n=B(o),r=e?void 0:t.inject(s);return t.computed((()=>e?E(null==n?void 0:n.values,t.unref(e)):t.unref(null==r?void 0:r.value)))},e.useForm=me,e.useFormErrors=function(){const e=B(o);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>(null==e?void 0:e.errors.value)||{}))},e.useFormValues=function(){const e=B(o);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>(null==e?void 0:e.values)||{}))},e.useIsFieldDirty=function(e){const n=D(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.dirty:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.dirty)&&void 0!==t&&t)}))},e.useIsFieldTouched=function(e){const n=D(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.touched:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.touched)&&void 0!==t&&t)}))},e.useIsFieldValid=function(e){const n=D(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.valid:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.valid)&&void 0!==t&&t)}))},e.useIsFormDirty=function(){const e=B(o);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.dirty)&&void 0!==t&&t}))},e.useIsFormTouched=function(){const e=B(o);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.touched)&&void 0!==t&&t}))},e.useIsFormValid=function(){const e=B(o);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.valid)&&void 0!==t&&t}))},e.useIsSubmitting=function(){const e=B(o);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isSubmitting.value)&&void 0!==t&&t}))},e.useIsValidating=function(){const e=B(o);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isValidating.value)&&void 0!==t&&t}))},e.useResetForm=function(){const e=B(o);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),function(t){if(e)return e.resetForm(t)}},e.useSubmitCount=function(){const e=B(o);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.submitCount.value)&&void 0!==t?t:0}))},e.useSubmitForm=function(e){const t=B(o);t||_("No vee-validate <Form /> or `useForm` was detected in the component tree");const n=t?t.handleSubmit(e):void 0;return function(e){if(n)return n(e)}},e.useValidateField=function(e){const n=B(o),r=e?void 0:t.inject(s);return function(){return r?r.validate():n&&e?null==n?void 0:n.validateField(t.unref(e)):(_(`field with name ${t.unref(e)} was not found`),Promise.resolve({errors:[],valid:!0}))}},e.useValidateForm=function(){const e=B(o);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),function(){return e?e.validate():Promise.resolve({results:{},errors:{},valid:!0})}},e.validate=Z,e.validateObject=re}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vee-validate",
3
- "version": "4.9.1",
3
+ "version": "4.9.3",
4
4
  "description": "Form Validation for Vue.js",
5
5
  "author": "Abdelrahman Awad <logaretm1@gmail.com>",
6
6
  "license": "MIT",