vee-validate 4.11.0 → 4.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -160,12 +160,6 @@ Read the [documentation and demos](https://vee-validate.logaretm.com/v4).
160
160
 
161
161
  You are welcome to contribute to this project, but before you do, please make sure you read the [contribution guide](/CONTRIBUTING.md).
162
162
 
163
- ## Translations 🌎🗺
164
-
165
- [![translation badge](https://inlang.com/badge?url=github.com/logaretm/vee-validate)](https://inlang.com/editor/github.com/logaretm/vee-validate?ref=badge)
166
-
167
- To add translations, you can manually edit the JSON translation files in `packages/i18n/src/locale`, use the [inlang](https://inlang.com/) online editor, or run `pnpm machine-translate` to add missing translations using AI from Inlang.
168
-
169
163
  ## Credits
170
164
 
171
165
  - Inspired by Laravel's [validation syntax](https://laravel.com/docs/5.4/validation)
@@ -172,6 +172,9 @@ type YupSchema<TValues = any> = {
172
172
  __isYupSchema__: boolean;
173
173
  validate(value: any, options: GenericObject): Promise<any>;
174
174
  };
175
+ type Locator = {
176
+ __locatorRef: string;
177
+ } & ((values: GenericObject) => unknown);
175
178
  interface FieldMeta<TValue> {
176
179
  touched: boolean;
177
180
  dirty: boolean;
@@ -207,7 +210,7 @@ interface ValidationOptions$1 {
207
210
  type FieldValidator = (opts?: Partial<ValidationOptions$1>) => Promise<ValidationResult>;
208
211
  interface PathStateConfig {
209
212
  bails: boolean;
210
- label: MaybeRef<string | undefined>;
213
+ label: MaybeRefOrGetter<string | undefined>;
211
214
  type: InputType;
212
215
  validate: FieldValidator;
213
216
  }
@@ -260,12 +263,12 @@ interface PrivateFieldContext<TValue = unknown> {
260
263
  meta: FieldMeta<TValue>;
261
264
  errors: Ref<string[]>;
262
265
  errorMessage: Ref<string | undefined>;
263
- label?: MaybeRef<string | undefined>;
266
+ label?: MaybeRefOrGetter<string | undefined>;
264
267
  type?: string;
265
268
  bails?: boolean;
266
- keepValueOnUnmount?: MaybeRef<boolean | undefined>;
267
- checkedValue?: MaybeRef<TValue>;
268
- uncheckedValue?: MaybeRef<TValue>;
269
+ keepValueOnUnmount?: MaybeRefOrGetter<boolean | undefined>;
270
+ checkedValue?: MaybeRefOrGetter<TValue>;
271
+ uncheckedValue?: MaybeRefOrGetter<TValue>;
269
272
  checked?: Ref<boolean>;
270
273
  resetField(state?: Partial<FieldState<TValue>>): void;
271
274
  handleReset(): void;
@@ -316,6 +319,7 @@ interface InvalidSubmissionContext<TValues extends GenericObject = GenericObject
316
319
  }
317
320
  type InvalidSubmissionHandler<TValues extends GenericObject = GenericObject> = (ctx: InvalidSubmissionContext<TValues>) => void;
318
321
  type RawFormSchema<TValues> = Record<Path<TValues>, string | GenericValidateFunction | GenericObject>;
322
+ type FieldPathLookup<TValues extends GenericObject = GenericObject> = Partial<Record<Path<TValues>, PrivateFieldContext | PrivateFieldContext[]>>;
319
323
  type HandleSubmitFactory<TValues extends GenericObject, TOutput = TValues> = <TReturn = unknown>(cb: SubmissionHandler<TValues, TOutput, TReturn>, onSubmitValidationErrorCb?: InvalidSubmissionHandler<TValues>) => (e?: Event) => Promise<TReturn | undefined>;
320
324
  interface PrivateFormContext<TValues extends GenericObject = GenericObject, TOutput = TValues> extends FormActions<TValues> {
321
325
  formId: number;
@@ -348,6 +352,9 @@ interface PrivateFormContext<TValues extends GenericObject = GenericObject, TOut
348
352
  removePathState<TPath extends Path<TValues>>(path: TPath, id: number): void;
349
353
  unsetPathValue<TPath extends Path<TValues>>(path: TPath): void;
350
354
  markForUnmount(path: string): void;
355
+ isFieldTouched<TPath extends Path<TValues>>(path: TPath): boolean;
356
+ isFieldDirty<TPath extends Path<TValues>>(path: TPath): boolean;
357
+ isFieldValid<TPath extends Path<TValues>>(path: TPath): boolean;
351
358
  }
352
359
  interface BaseComponentBinds<TValue = unknown, TModel = 'modelValue'> {
353
360
  onBlur: () => void;
@@ -391,6 +398,22 @@ interface FormContext<TValues extends GenericObject = GenericObject, TOutput = T
391
398
  defineInputBinds<TPath extends Path<TValues>, TValue = PathValue<TValues, TPath>, TExtras extends GenericObject = GenericObject>(path: MaybeRefOrGetter<TPath>, config?: Partial<InputBindsConfig<TValue, TExtras>> | LazyInputBindsConfig<TValue, TExtras>): Ref<BaseInputBinds<TValue> & TExtras>;
392
399
  }
393
400
 
401
+ interface DevtoolsPluginFieldState {
402
+ name: string;
403
+ value: any;
404
+ initialValue: any;
405
+ errors: string[];
406
+ meta: FieldMeta<any>;
407
+ }
408
+ interface DevtoolsPluginFormState {
409
+ meta: FormMeta<Record<string, any>>;
410
+ errors: FormErrors<Record<string, any>>;
411
+ values: Record<string, any>;
412
+ isSubmitting: boolean;
413
+ isValidating: boolean;
414
+ submitCount: number;
415
+ }
416
+
394
417
  interface ValidationOptions {
395
418
  name?: string;
396
419
  label?: string;
@@ -438,16 +461,16 @@ interface FieldOptions<TValue = unknown> {
438
461
  /**
439
462
  * @deprecated Use `checkedValue` instead.
440
463
  */
441
- valueProp?: MaybeRef<TValue>;
442
- checkedValue?: MaybeRef<TValue>;
443
- uncheckedValue?: MaybeRef<TValue>;
444
- label?: MaybeRef<string | undefined>;
464
+ valueProp?: MaybeRefOrGetter<TValue>;
465
+ checkedValue?: MaybeRefOrGetter<TValue>;
466
+ uncheckedValue?: MaybeRefOrGetter<TValue>;
467
+ label?: MaybeRefOrGetter<string | undefined>;
445
468
  controlled?: boolean;
446
469
  /**
447
470
  * @deprecated Use `controlled` instead, controlled is opposite of standalone.
448
471
  */
449
472
  standalone?: boolean;
450
- keepValueOnUnmount?: MaybeRef<boolean | undefined>;
473
+ keepValueOnUnmount?: MaybeRefOrGetter<boolean | undefined>;
451
474
  /**
452
475
  * @deprecated Pass the model prop name to `syncVModel` instead.
453
476
  */
@@ -1432,17 +1455,17 @@ declare function useResetForm<TValues extends Record<string, unknown> = Record<s
1432
1455
  /**
1433
1456
  * If a field is dirty or not
1434
1457
  */
1435
- declare function useIsFieldDirty(path?: MaybeRef<string>): vue.ComputedRef<boolean>;
1458
+ declare function useIsFieldDirty(path?: MaybeRefOrGetter<string>): vue.ComputedRef<boolean>;
1436
1459
 
1437
1460
  /**
1438
1461
  * If a field is touched or not
1439
1462
  */
1440
- declare function useIsFieldTouched(path?: MaybeRef<string>): vue.ComputedRef<boolean>;
1463
+ declare function useIsFieldTouched(path?: MaybeRefOrGetter<string>): vue.ComputedRef<boolean>;
1441
1464
 
1442
1465
  /**
1443
1466
  * If a field is validated and is valid
1444
1467
  */
1445
- declare function useIsFieldValid(path?: MaybeRef<string>): vue.ComputedRef<boolean>;
1468
+ declare function useIsFieldValid(path?: MaybeRefOrGetter<string>): vue.ComputedRef<boolean>;
1446
1469
 
1447
1470
  /**
1448
1471
  * If the form is submitting or not
@@ -1457,7 +1480,7 @@ declare function useIsValidating(): vue.ComputedRef<boolean>;
1457
1480
  /**
1458
1481
  * Validates a single field
1459
1482
  */
1460
- declare function useValidateField(path?: MaybeRef<string>): () => Promise<ValidationResult>;
1483
+ declare function useValidateField(path?: MaybeRefOrGetter<string>): () => Promise<ValidationResult>;
1461
1484
 
1462
1485
  /**
1463
1486
  * If the form is dirty or not
@@ -1487,7 +1510,7 @@ declare function useSubmitCount(): vue.ComputedRef<number>;
1487
1510
  /**
1488
1511
  * Gives access to a field's current value
1489
1512
  */
1490
- declare function useFieldValue<TValue = unknown>(path?: MaybeRef<string>): vue.ComputedRef<TValue>;
1513
+ declare function useFieldValue<TValue = unknown>(path?: MaybeRefOrGetter<string>): vue.ComputedRef<TValue>;
1491
1514
 
1492
1515
  /**
1493
1516
  * Gives access to a form's values
@@ -1502,7 +1525,7 @@ declare function useFormErrors<TValues extends Record<string, unknown> = Record<
1502
1525
  /**
1503
1526
  * Gives access to a single field error
1504
1527
  */
1505
- declare function useFieldError(path?: MaybeRef<string>): vue.ComputedRef<string>;
1528
+ declare function useFieldError(path?: MaybeRefOrGetter<string>): vue.ComputedRef<string>;
1506
1529
 
1507
1530
  declare function useSubmitForm<TValues extends Record<string, unknown> = Record<string, unknown>>(cb: SubmissionHandler<TValues>): (e?: Event) => Promise<unknown>;
1508
1531
 
@@ -1540,4 +1563,4 @@ declare const FormContextKey: InjectionKey<PrivateFormContext>;
1540
1563
  declare const FieldContextKey: InjectionKey<PrivateFieldContext<unknown>>;
1541
1564
  declare const IS_ABSENT: unique symbol;
1542
1565
 
1543
- 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, normalizeRules, useField, useFieldArray, useFieldError, useFieldValue, useForm, useFormErrors, useFormValues, useIsFieldDirty, useIsFieldTouched, useIsFieldValid, useIsFormDirty, useIsFormTouched, useIsFormValid, useIsSubmitting, useIsValidating, useResetForm, useSetFieldError, useSetFieldTouched, useSetFieldValue, useSetFormErrors, useSetFormTouched, useSetFormValues, useSubmitCount, useSubmitForm, useValidateField, useValidateForm, validate, validateObjectSchema as validateObject };
1566
+ export { type BaseComponentBinds, type BaseInputBinds, type ComponentBindsConfig, type DevtoolsPluginFieldState, type DevtoolsPluginFormState, ErrorMessage, Field, FieldArray, type FieldArrayContext, type FieldContext, FieldContextKey, type FieldEntry, type FieldMeta, type FieldOptions, type FieldPathLookup, type FieldState, type FieldValidator, type FlattenAndSetPathsType, Form, type FormActions, type FormContext, FormContextKey, type FormErrorBag, type FormErrors, type FormMeta, type FormOptions, type FormState, type FormValidationResult, type GenericObject, type GenericValidateFunction, IS_ABSENT, type InputBindsConfig, type InputType, type InvalidSubmissionContext, type InvalidSubmissionHandler, type IsAny, type IsEqual, type LazyComponentBindsConfig, type LazyInputBindsConfig, type Locator, type MapValuesPathsToRefs, type MaybeArray, type MaybePromise, type Path, type PathState, type PathStateConfig, type PathValue, type PrivateFieldArrayContext, type PrivateFieldContext, type PrivateFormContext, type PublicPathState, type RawFormSchema, type RuleExpression, type SchemaValidationMode, type SubmissionContext, type SubmissionHandler, type TypedSchema, type TypedSchemaError, type ValidationOptions$1 as ValidationOptions, type ValidationResult, type YupSchema, configure, defineRule, normalizeRules, useField, useFieldArray, useFieldError, useFieldValue, useForm, useFormErrors, useFormValues, useIsFieldDirty, useIsFieldTouched, useIsFieldValid, useIsFormDirty, useIsFormTouched, useIsFormValid, useIsSubmitting, useIsValidating, useResetForm, useSetFieldError, useSetFieldTouched, useSetFieldValue, useSetFormErrors, useSetFormTouched, useSetFormValues, useSubmitCount, useSubmitForm, useValidateField, useValidateForm, validate, validateObjectSchema as validateObject };
@@ -1,9 +1,9 @@
1
1
  /**
2
- * vee-validate v4.11.0
2
+ * vee-validate v4.11.2
3
3
  * (c) 2023 Abdelrahman Awad
4
4
  * @license MIT
5
5
  */
6
- import { getCurrentInstance, inject, warn as warn$1, computed, unref, ref, watch, nextTick, isRef, reactive, onUnmounted, toValue, onMounted, provide, onBeforeUnmount, defineComponent, toRef, resolveDynamicComponent, h, readonly, watchEffect, shallowRef } from 'vue';
6
+ import { getCurrentInstance, inject, warn as warn$1, computed, toValue, ref, watch, nextTick, unref, isRef, reactive, onUnmounted, onMounted, provide, onBeforeUnmount, defineComponent, toRef, resolveDynamicComponent, h, readonly, watchEffect, shallowRef } from 'vue';
7
7
  import { setupDevtoolsPlugin } from '@vue/devtools-api';
8
8
 
9
9
  function isCallable(fn) {
@@ -534,10 +534,12 @@ function normalizeErrorItem(message) {
534
534
  }
535
535
  function resolveFieldOrPathState(path) {
536
536
  const form = injectWithSelf(FormContextKey);
537
- const state = path ? computed(() => form === null || form === void 0 ? void 0 : form.getPathState(unref(path))) : undefined;
537
+ const state = path ? computed(() => form === null || form === void 0 ? void 0 : form.getPathState(toValue(path))) : undefined;
538
538
  const field = path ? undefined : inject(FieldContextKey);
539
539
  if (!field && !(state === null || state === void 0 ? void 0 : state.value)) {
540
- warn(`field with name ${unref(path)} was not found`);
540
+ if ((process.env.NODE_ENV !== 'production')) {
541
+ warn(`field with name ${toValue(path)} was not found`);
542
+ }
541
543
  }
542
544
  return state || field;
543
545
  }
@@ -605,6 +607,9 @@ function parseInputValue(el) {
605
607
  if (el.type === 'number') {
606
608
  return Number.isNaN(el.valueAsNumber) ? el.value : el.valueAsNumber;
607
609
  }
610
+ if (el.type === 'range') {
611
+ return Number.isNaN(el.valueAsNumber) ? el.value : el.valueAsNumber;
612
+ }
608
613
  return el.value;
609
614
  }
610
615
  function normalizeEventValue(value) {
@@ -1565,7 +1570,7 @@ function _useField(path, rules, opts) {
1565
1570
  const form = controlForm || injectedForm;
1566
1571
  const name = computed(() => normalizeFormPath(toValue(path)));
1567
1572
  const validator = computed(() => {
1568
- const schema = unref(form === null || form === void 0 ? void 0 : form.schema);
1573
+ const schema = toValue(form === null || form === void 0 ? void 0 : form.schema);
1569
1574
  if (schema) {
1570
1575
  return undefined;
1571
1576
  }
@@ -1602,12 +1607,12 @@ function _useField(path, rules, opts) {
1602
1607
  async function validateCurrentValue(mode) {
1603
1608
  var _a, _b;
1604
1609
  if (form === null || form === void 0 ? void 0 : form.validateSchema) {
1605
- return (_a = (await form.validateSchema(mode)).results[unref(name)]) !== null && _a !== void 0 ? _a : { valid: true, errors: [] };
1610
+ return (_a = (await form.validateSchema(mode)).results[toValue(name)]) !== null && _a !== void 0 ? _a : { valid: true, errors: [] };
1606
1611
  }
1607
1612
  if (validator.value) {
1608
1613
  return validate(value.value, validator.value, {
1609
- name: unref(name),
1610
- label: unref(label),
1614
+ name: toValue(name),
1615
+ label: toValue(label),
1611
1616
  values: (_b = form === null || form === void 0 ? void 0 : form.values) !== null && _b !== void 0 ? _b : {},
1612
1617
  bails,
1613
1618
  });
@@ -1784,7 +1789,7 @@ function _useField(path, rules, opts) {
1784
1789
  });
1785
1790
  onBeforeUnmount(() => {
1786
1791
  var _a;
1787
- const shouldKeepValue = (_a = unref(field.keepValueOnUnmount)) !== null && _a !== void 0 ? _a : unref(form.keepValuesOnUnmount);
1792
+ const shouldKeepValue = (_a = toValue(field.keepValueOnUnmount)) !== null && _a !== void 0 ? _a : toValue(form.keepValuesOnUnmount);
1788
1793
  const path = toValue(name);
1789
1794
  if (shouldKeepValue || !form || flags.pendingUnmount[field.id]) {
1790
1795
  form === null || form === void 0 ? void 0 : form.removePathState(path, id);
@@ -1799,7 +1804,7 @@ function _useField(path, rules, opts) {
1799
1804
  return;
1800
1805
  }
1801
1806
  if ((pathState === null || pathState === void 0 ? void 0 : pathState.multiple) && Array.isArray(pathState.value)) {
1802
- const valueIdx = pathState.value.findIndex(i => isEqual(i, unref(field.checkedValue)));
1807
+ const valueIdx = pathState.value.findIndex(i => isEqual(i, toValue(field.checkedValue)));
1803
1808
  if (valueIdx > -1) {
1804
1809
  const newVal = [...pathState.value];
1805
1810
  newVal.splice(valueIdx, 1);
@@ -1852,8 +1857,8 @@ function useFieldWithChecked(name, rules, opts) {
1852
1857
  function patchCheckedApi(field) {
1853
1858
  const handleChange = field.handleChange;
1854
1859
  const checked = computed(() => {
1855
- const currentValue = unref(field.value);
1856
- const checkedVal = unref(checkedValue);
1860
+ const currentValue = toValue(field.value);
1861
+ const checkedVal = toValue(checkedValue);
1857
1862
  return Array.isArray(currentValue)
1858
1863
  ? currentValue.findIndex(v => isEqual(v, checkedVal)) >= 0
1859
1864
  : isEqual(checkedVal, currentValue);
@@ -1869,12 +1874,12 @@ function useFieldWithChecked(name, rules, opts) {
1869
1874
  const path = toValue(name);
1870
1875
  const pathState = form === null || form === void 0 ? void 0 : form.getPathState(path);
1871
1876
  const value = normalizeEventValue(e);
1872
- let newValue = (_b = unref(checkedValue)) !== null && _b !== void 0 ? _b : value;
1877
+ let newValue = (_b = toValue(checkedValue)) !== null && _b !== void 0 ? _b : value;
1873
1878
  if (form && (pathState === null || pathState === void 0 ? void 0 : pathState.multiple) && pathState.type === 'checkbox') {
1874
1879
  newValue = resolveNextCheckboxValue(getFromPath(form.values, path) || [], newValue, undefined);
1875
1880
  }
1876
1881
  else if ((opts === null || opts === void 0 ? void 0 : opts.type) === 'checkbox') {
1877
- newValue = resolveNextCheckboxValue(unref(field.value), newValue, unref(uncheckedValue));
1882
+ newValue = resolveNextCheckboxValue(toValue(field.value), newValue, toValue(uncheckedValue));
1878
1883
  }
1879
1884
  handleChange(newValue, shouldValidate);
1880
1885
  }
@@ -2516,6 +2521,9 @@ function useForm(opts) {
2516
2521
  initialValues: initialValues,
2517
2522
  getAllPathStates: () => pathStates.value,
2518
2523
  markForUnmount,
2524
+ isFieldTouched,
2525
+ isFieldDirty,
2526
+ isFieldValid,
2519
2527
  };
2520
2528
  /**
2521
2529
  * Sets a single field value
@@ -2575,6 +2583,18 @@ function useForm(opts) {
2575
2583
  pathState.touched = isTouched;
2576
2584
  }
2577
2585
  }
2586
+ function isFieldTouched(field) {
2587
+ var _a;
2588
+ return !!((_a = findPathState(field)) === null || _a === void 0 ? void 0 : _a.touched);
2589
+ }
2590
+ function isFieldDirty(field) {
2591
+ var _a;
2592
+ return !!((_a = findPathState(field)) === null || _a === void 0 ? void 0 : _a.dirty);
2593
+ }
2594
+ function isFieldValid(field) {
2595
+ var _a;
2596
+ return !!((_a = findPathState(field)) === null || _a === void 0 ? void 0 : _a.valid);
2597
+ }
2578
2598
  /**
2579
2599
  * Sets the touched meta state on multiple fields
2580
2600
  */
@@ -2677,7 +2697,9 @@ function useForm(opts) {
2677
2697
  }
2678
2698
  const shouldWarn = !state && ((_a = opts === null || opts === void 0 ? void 0 : opts.warn) !== null && _a !== void 0 ? _a : true);
2679
2699
  if (shouldWarn) {
2680
- warn$1(`field with path ${path} was not found`);
2700
+ if ((process.env.NODE_ENV !== 'production')) {
2701
+ warn$1(`field with path ${path} was not found`);
2702
+ }
2681
2703
  }
2682
2704
  return Promise.resolve({ errors: [], valid: true });
2683
2705
  }
@@ -3072,11 +3094,15 @@ function useFieldArray(arrayPath) {
3072
3094
  move: noOp,
3073
3095
  };
3074
3096
  if (!form) {
3075
- warn('FieldArray requires being a child of `<Form/>` or `useForm` being called before it. Array fields may not work correctly');
3097
+ if ((process.env.NODE_ENV !== 'production')) {
3098
+ warn('FieldArray requires being a child of `<Form/>` or `useForm` being called before it. Array fields may not work correctly');
3099
+ }
3076
3100
  return noOpApi;
3077
3101
  }
3078
3102
  if (!unref(arrayPath)) {
3079
- warn('FieldArray requires a field path to be provided, did you forget to pass the `name` prop?');
3103
+ if ((process.env.NODE_ENV !== 'production')) {
3104
+ warn('FieldArray requires a field path to be provided, did you forget to pass the `name` prop?');
3105
+ }
3080
3106
  return noOpApi;
3081
3107
  }
3082
3108
  const alreadyExists = form.fieldArrays.find(a => unref(a.path) === unref(arrayPath));
@@ -3123,7 +3149,9 @@ function useFieldArray(arrayPath) {
3123
3149
  set(value) {
3124
3150
  const idx = fields.value.findIndex(e => e.key === key);
3125
3151
  if (idx === -1) {
3126
- warn(`Attempting to update a non-existent array item`);
3152
+ if ((process.env.NODE_ENV !== 'production')) {
3153
+ warn(`Attempting to update a non-existent array item`);
3154
+ }
3127
3155
  return;
3128
3156
  }
3129
3157
  update(idx, value);
@@ -3372,7 +3400,9 @@ const ErrorMessage = ErrorMessageImpl;
3372
3400
  function useResetForm() {
3373
3401
  const form = injectWithSelf(FormContextKey);
3374
3402
  if (!form) {
3375
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3403
+ if ((process.env.NODE_ENV !== 'production')) {
3404
+ warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3405
+ }
3376
3406
  }
3377
3407
  return function resetForm(state) {
3378
3408
  if (!form) {
@@ -3430,7 +3460,9 @@ function useIsFieldValid(path) {
3430
3460
  function useIsSubmitting() {
3431
3461
  const form = injectWithSelf(FormContextKey);
3432
3462
  if (!form) {
3433
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3463
+ if ((process.env.NODE_ENV !== 'production')) {
3464
+ warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3465
+ }
3434
3466
  }
3435
3467
  return computed(() => {
3436
3468
  var _a;
@@ -3444,7 +3476,9 @@ function useIsSubmitting() {
3444
3476
  function useIsValidating() {
3445
3477
  const form = injectWithSelf(FormContextKey);
3446
3478
  if (!form) {
3447
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3479
+ if ((process.env.NODE_ENV !== 'production')) {
3480
+ warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3481
+ }
3448
3482
  }
3449
3483
  return computed(() => {
3450
3484
  var _a;
@@ -3463,9 +3497,11 @@ function useValidateField(path) {
3463
3497
  return field.validate();
3464
3498
  }
3465
3499
  if (form && path) {
3466
- return form === null || form === void 0 ? void 0 : form.validateField(unref(path));
3500
+ return form === null || form === void 0 ? void 0 : form.validateField(toValue(path));
3501
+ }
3502
+ if ((process.env.NODE_ENV !== 'production')) {
3503
+ warn(`field with name ${unref(path)} was not found`);
3467
3504
  }
3468
- warn(`field with name ${unref(path)} was not found`);
3469
3505
  return Promise.resolve({
3470
3506
  errors: [],
3471
3507
  valid: true,
@@ -3479,7 +3515,9 @@ function useValidateField(path) {
3479
3515
  function useIsFormDirty() {
3480
3516
  const form = injectWithSelf(FormContextKey);
3481
3517
  if (!form) {
3482
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3518
+ if ((process.env.NODE_ENV !== 'production')) {
3519
+ warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3520
+ }
3483
3521
  }
3484
3522
  return computed(() => {
3485
3523
  var _a;
@@ -3493,7 +3531,9 @@ function useIsFormDirty() {
3493
3531
  function useIsFormTouched() {
3494
3532
  const form = injectWithSelf(FormContextKey);
3495
3533
  if (!form) {
3496
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3534
+ if ((process.env.NODE_ENV !== 'production')) {
3535
+ warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3536
+ }
3497
3537
  }
3498
3538
  return computed(() => {
3499
3539
  var _a;
@@ -3507,7 +3547,9 @@ function useIsFormTouched() {
3507
3547
  function useIsFormValid() {
3508
3548
  const form = injectWithSelf(FormContextKey);
3509
3549
  if (!form) {
3510
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3550
+ if ((process.env.NODE_ENV !== 'production')) {
3551
+ warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3552
+ }
3511
3553
  }
3512
3554
  return computed(() => {
3513
3555
  var _a;
@@ -3521,7 +3563,9 @@ function useIsFormValid() {
3521
3563
  function useValidateForm() {
3522
3564
  const form = injectWithSelf(FormContextKey);
3523
3565
  if (!form) {
3524
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3566
+ if ((process.env.NODE_ENV !== 'production')) {
3567
+ warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3568
+ }
3525
3569
  }
3526
3570
  return function validateField() {
3527
3571
  if (!form) {
@@ -3537,7 +3581,9 @@ function useValidateForm() {
3537
3581
  function useSubmitCount() {
3538
3582
  const form = injectWithSelf(FormContextKey);
3539
3583
  if (!form) {
3540
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3584
+ if ((process.env.NODE_ENV !== 'production')) {
3585
+ warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3586
+ }
3541
3587
  }
3542
3588
  return computed(() => {
3543
3589
  var _a;
@@ -3554,9 +3600,9 @@ function useFieldValue(path) {
3554
3600
  const field = path ? undefined : inject(FieldContextKey);
3555
3601
  return computed(() => {
3556
3602
  if (path) {
3557
- return getFromPath(form === null || form === void 0 ? void 0 : form.values, unref(path));
3603
+ return getFromPath(form === null || form === void 0 ? void 0 : form.values, toValue(path));
3558
3604
  }
3559
- return unref(field === null || field === void 0 ? void 0 : field.value);
3605
+ return toValue(field === null || field === void 0 ? void 0 : field.value);
3560
3606
  });
3561
3607
  }
3562
3608
 
@@ -3566,7 +3612,9 @@ function useFieldValue(path) {
3566
3612
  function useFormValues() {
3567
3613
  const form = injectWithSelf(FormContextKey);
3568
3614
  if (!form) {
3569
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3615
+ if ((process.env.NODE_ENV !== 'production')) {
3616
+ warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3617
+ }
3570
3618
  }
3571
3619
  return computed(() => {
3572
3620
  return (form === null || form === void 0 ? void 0 : form.values) || {};
@@ -3579,7 +3627,9 @@ function useFormValues() {
3579
3627
  function useFormErrors() {
3580
3628
  const form = injectWithSelf(FormContextKey);
3581
3629
  if (!form) {
3582
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3630
+ if ((process.env.NODE_ENV !== 'production')) {
3631
+ warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3632
+ }
3583
3633
  }
3584
3634
  return computed(() => {
3585
3635
  return ((form === null || form === void 0 ? void 0 : form.errors.value) || {});
@@ -3595,7 +3645,7 @@ function useFieldError(path) {
3595
3645
  const field = path ? undefined : inject(FieldContextKey);
3596
3646
  return computed(() => {
3597
3647
  if (path) {
3598
- return form === null || form === void 0 ? void 0 : form.errors.value[unref(path)];
3648
+ return form === null || form === void 0 ? void 0 : form.errors.value[toValue(path)];
3599
3649
  }
3600
3650
  return field === null || field === void 0 ? void 0 : field.errorMessage.value;
3601
3651
  });
@@ -3604,7 +3654,9 @@ function useFieldError(path) {
3604
3654
  function useSubmitForm(cb) {
3605
3655
  const form = injectWithSelf(FormContextKey);
3606
3656
  if (!form) {
3607
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3657
+ if ((process.env.NODE_ENV !== 'production')) {
3658
+ warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3659
+ }
3608
3660
  }
3609
3661
  const onSubmit = form ? form.handleSubmit(cb) : undefined;
3610
3662
  return function submitForm(e) {
@@ -3625,12 +3677,14 @@ function useSetFieldError(path) {
3625
3677
  return function setFieldError(message) {
3626
3678
  if (path && form) {
3627
3679
  form.setFieldError(toValue(path), message);
3680
+ return;
3628
3681
  }
3629
3682
  if (field) {
3630
3683
  field.setErrors(message || []);
3684
+ return;
3631
3685
  }
3632
3686
  if ((process.env.NODE_ENV !== 'production')) {
3633
- warn(`Could not set error for unknown field with path "${toValue(path)}"`);
3687
+ warn(`Could not set error message since there is no form context or a field named "${toValue(path)}", did you forget to call "useField" or "useForm"?`);
3634
3688
  }
3635
3689
  };
3636
3690
  }
@@ -3645,12 +3699,14 @@ function useSetFieldTouched(path) {
3645
3699
  return function setFieldTouched(touched) {
3646
3700
  if (path && form) {
3647
3701
  form.setFieldTouched(toValue(path), touched);
3702
+ return;
3648
3703
  }
3649
3704
  if (field) {
3650
3705
  field.setTouched(touched);
3706
+ return;
3651
3707
  }
3652
3708
  if ((process.env.NODE_ENV !== 'production')) {
3653
- warn(`Could not set touched meta for unknown field with path "${toValue(path)}"`);
3709
+ warn(`Could not set touched state since there is no form context or a field named "${toValue(path)}", did you forget to call "useField" or "useForm"?`);
3654
3710
  }
3655
3711
  };
3656
3712
  }
@@ -3665,12 +3721,14 @@ function useSetFieldValue(path) {
3665
3721
  return function setFieldValue(value, shouldValidate = true) {
3666
3722
  if (path && form) {
3667
3723
  form.setFieldValue(toValue(path), value, shouldValidate);
3724
+ return;
3668
3725
  }
3669
3726
  if (field) {
3670
3727
  field.setValue(value, shouldValidate);
3728
+ return;
3671
3729
  }
3672
3730
  if ((process.env.NODE_ENV !== 'production')) {
3673
- warn(`Could not set value for unknown field with path "${toValue(path)}"`);
3731
+ warn(`Could not set value since there is no form context or a field named "${toValue(path)}", did you forget to call "useField" or "useForm"?`);
3674
3732
  }
3675
3733
  };
3676
3734
  }
@@ -3683,6 +3741,7 @@ function useSetFormErrors() {
3683
3741
  function setFormErrors(fields) {
3684
3742
  if (form) {
3685
3743
  form.setErrors(fields);
3744
+ return;
3686
3745
  }
3687
3746
  if ((process.env.NODE_ENV !== 'production')) {
3688
3747
  warn(`Could not set errors because a form was not detected, did you forget to use "useForm" in a parent component?`);
@@ -3699,6 +3758,7 @@ function useSetFormTouched() {
3699
3758
  function setFormTouched(fields) {
3700
3759
  if (form) {
3701
3760
  form.setTouched(fields);
3761
+ return;
3702
3762
  }
3703
3763
  if ((process.env.NODE_ENV !== 'production')) {
3704
3764
  warn(`Could not set touched state because a form was not detected, did you forget to use "useForm" in a parent component?`);
@@ -3715,6 +3775,7 @@ function useSetFormValues() {
3715
3775
  function setFormValues(fields) {
3716
3776
  if (form) {
3717
3777
  form.setValues(fields);
3778
+ return;
3718
3779
  }
3719
3780
  if ((process.env.NODE_ENV !== 'production')) {
3720
3781
  warn(`Could not set form values because a form was not detected, did you forget to use "useForm" in a parent component?`);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * vee-validate v4.11.0
2
+ * vee-validate v4.11.2
3
3
  * (c) 2023 Abdelrahman Awad
4
4
  * @license MIT
5
5
  */
@@ -439,9 +439,6 @@
439
439
  const vm = vue.getCurrentInstance();
440
440
  return (vm === null || vm === void 0 ? void 0 : vm.provides[symbol]) || vue.inject(symbol, def);
441
441
  }
442
- function warn(message) {
443
- vue.warn(`[vee-validate]: ${message}`);
444
- }
445
442
  function resolveNextCheckboxValue(currentValue, checkedValue, uncheckedValue) {
446
443
  if (Array.isArray(currentValue)) {
447
444
  const newVal = [...currentValue];
@@ -519,11 +516,9 @@
519
516
  }
520
517
  function resolveFieldOrPathState(path) {
521
518
  const form = injectWithSelf(FormContextKey);
522
- const state = path ? vue.computed(() => form === null || form === void 0 ? void 0 : form.getPathState(vue.unref(path))) : undefined;
519
+ const state = path ? vue.computed(() => form === null || form === void 0 ? void 0 : form.getPathState(vue.toValue(path))) : undefined;
523
520
  const field = path ? undefined : vue.inject(FieldContextKey);
524
- if (!field && !(state === null || state === void 0 ? void 0 : state.value)) {
525
- warn(`field with name ${vue.unref(path)} was not found`);
526
- }
521
+ if (!field && !(state === null || state === void 0 ? void 0 : state.value)) ;
527
522
  return state || field;
528
523
  }
529
524
  function omit(obj, keys) {
@@ -590,6 +585,9 @@
590
585
  if (el.type === 'number') {
591
586
  return Number.isNaN(el.valueAsNumber) ? el.value : el.valueAsNumber;
592
587
  }
588
+ if (el.type === 'range') {
589
+ return Number.isNaN(el.valueAsNumber) ? el.value : el.valueAsNumber;
590
+ }
593
591
  return el.value;
594
592
  }
595
593
  function normalizeEventValue(value) {
@@ -1167,7 +1165,7 @@
1167
1165
  const form = controlForm || injectedForm;
1168
1166
  const name = vue.computed(() => normalizeFormPath(vue.toValue(path)));
1169
1167
  const validator = vue.computed(() => {
1170
- const schema = vue.unref(form === null || form === void 0 ? void 0 : form.schema);
1168
+ const schema = vue.toValue(form === null || form === void 0 ? void 0 : form.schema);
1171
1169
  if (schema) {
1172
1170
  return undefined;
1173
1171
  }
@@ -1204,12 +1202,12 @@
1204
1202
  async function validateCurrentValue(mode) {
1205
1203
  var _a, _b;
1206
1204
  if (form === null || form === void 0 ? void 0 : form.validateSchema) {
1207
- return (_a = (await form.validateSchema(mode)).results[vue.unref(name)]) !== null && _a !== void 0 ? _a : { valid: true, errors: [] };
1205
+ return (_a = (await form.validateSchema(mode)).results[vue.toValue(name)]) !== null && _a !== void 0 ? _a : { valid: true, errors: [] };
1208
1206
  }
1209
1207
  if (validator.value) {
1210
1208
  return validate(value.value, validator.value, {
1211
- name: vue.unref(name),
1212
- label: vue.unref(label),
1209
+ name: vue.toValue(name),
1210
+ label: vue.toValue(label),
1213
1211
  values: (_b = form === null || form === void 0 ? void 0 : form.values) !== null && _b !== void 0 ? _b : {},
1214
1212
  bails,
1215
1213
  });
@@ -1367,7 +1365,7 @@
1367
1365
  });
1368
1366
  vue.onBeforeUnmount(() => {
1369
1367
  var _a;
1370
- const shouldKeepValue = (_a = vue.unref(field.keepValueOnUnmount)) !== null && _a !== void 0 ? _a : vue.unref(form.keepValuesOnUnmount);
1368
+ const shouldKeepValue = (_a = vue.toValue(field.keepValueOnUnmount)) !== null && _a !== void 0 ? _a : vue.toValue(form.keepValuesOnUnmount);
1371
1369
  const path = vue.toValue(name);
1372
1370
  if (shouldKeepValue || !form || flags.pendingUnmount[field.id]) {
1373
1371
  form === null || form === void 0 ? void 0 : form.removePathState(path, id);
@@ -1382,7 +1380,7 @@
1382
1380
  return;
1383
1381
  }
1384
1382
  if ((pathState === null || pathState === void 0 ? void 0 : pathState.multiple) && Array.isArray(pathState.value)) {
1385
- const valueIdx = pathState.value.findIndex(i => isEqual(i, vue.unref(field.checkedValue)));
1383
+ const valueIdx = pathState.value.findIndex(i => isEqual(i, vue.toValue(field.checkedValue)));
1386
1384
  if (valueIdx > -1) {
1387
1385
  const newVal = [...pathState.value];
1388
1386
  newVal.splice(valueIdx, 1);
@@ -1435,8 +1433,8 @@
1435
1433
  function patchCheckedApi(field) {
1436
1434
  const handleChange = field.handleChange;
1437
1435
  const checked = vue.computed(() => {
1438
- const currentValue = vue.unref(field.value);
1439
- const checkedVal = vue.unref(checkedValue);
1436
+ const currentValue = vue.toValue(field.value);
1437
+ const checkedVal = vue.toValue(checkedValue);
1440
1438
  return Array.isArray(currentValue)
1441
1439
  ? currentValue.findIndex(v => isEqual(v, checkedVal)) >= 0
1442
1440
  : isEqual(checkedVal, currentValue);
@@ -1452,12 +1450,12 @@
1452
1450
  const path = vue.toValue(name);
1453
1451
  const pathState = form === null || form === void 0 ? void 0 : form.getPathState(path);
1454
1452
  const value = normalizeEventValue(e);
1455
- let newValue = (_b = vue.unref(checkedValue)) !== null && _b !== void 0 ? _b : value;
1453
+ let newValue = (_b = vue.toValue(checkedValue)) !== null && _b !== void 0 ? _b : value;
1456
1454
  if (form && (pathState === null || pathState === void 0 ? void 0 : pathState.multiple) && pathState.type === 'checkbox') {
1457
1455
  newValue = resolveNextCheckboxValue(getFromPath(form.values, path) || [], newValue, undefined);
1458
1456
  }
1459
1457
  else if ((opts === null || opts === void 0 ? void 0 : opts.type) === 'checkbox') {
1460
- newValue = resolveNextCheckboxValue(vue.unref(field.value), newValue, vue.unref(uncheckedValue));
1458
+ newValue = resolveNextCheckboxValue(vue.toValue(field.value), newValue, vue.toValue(uncheckedValue));
1461
1459
  }
1462
1460
  handleChange(newValue, shouldValidate);
1463
1461
  }
@@ -2096,6 +2094,9 @@
2096
2094
  initialValues: initialValues,
2097
2095
  getAllPathStates: () => pathStates.value,
2098
2096
  markForUnmount,
2097
+ isFieldTouched,
2098
+ isFieldDirty,
2099
+ isFieldValid,
2099
2100
  };
2100
2101
  /**
2101
2102
  * Sets a single field value
@@ -2155,6 +2156,18 @@
2155
2156
  pathState.touched = isTouched;
2156
2157
  }
2157
2158
  }
2159
+ function isFieldTouched(field) {
2160
+ var _a;
2161
+ return !!((_a = findPathState(field)) === null || _a === void 0 ? void 0 : _a.touched);
2162
+ }
2163
+ function isFieldDirty(field) {
2164
+ var _a;
2165
+ return !!((_a = findPathState(field)) === null || _a === void 0 ? void 0 : _a.dirty);
2166
+ }
2167
+ function isFieldValid(field) {
2168
+ var _a;
2169
+ return !!((_a = findPathState(field)) === null || _a === void 0 ? void 0 : _a.valid);
2170
+ }
2158
2171
  /**
2159
2172
  * Sets the touched meta state on multiple fields
2160
2173
  */
@@ -2255,10 +2268,7 @@
2255
2268
  if (state === null || state === void 0 ? void 0 : state.validate) {
2256
2269
  return state.validate(opts);
2257
2270
  }
2258
- const shouldWarn = !state && ((_a = opts === null || opts === void 0 ? void 0 : opts.warn) !== null && _a !== void 0 ? _a : true);
2259
- if (shouldWarn) {
2260
- vue.warn(`field with path ${path} was not found`);
2261
- }
2271
+ !state && ((_a = opts === null || opts === void 0 ? void 0 : opts.warn) !== null && _a !== void 0 ? _a : true);
2262
2272
  return Promise.resolve({ errors: [], valid: true });
2263
2273
  }
2264
2274
  function unsetInitialValue(path) {
@@ -2646,11 +2656,9 @@
2646
2656
  move: noOp,
2647
2657
  };
2648
2658
  if (!form) {
2649
- warn('FieldArray requires being a child of `<Form/>` or `useForm` being called before it. Array fields may not work correctly');
2650
2659
  return noOpApi;
2651
2660
  }
2652
2661
  if (!vue.unref(arrayPath)) {
2653
- warn('FieldArray requires a field path to be provided, did you forget to pass the `name` prop?');
2654
2662
  return noOpApi;
2655
2663
  }
2656
2664
  const alreadyExists = form.fieldArrays.find(a => vue.unref(a.path) === vue.unref(arrayPath));
@@ -2697,7 +2705,6 @@
2697
2705
  set(value) {
2698
2706
  const idx = fields.value.findIndex(e => e.key === key);
2699
2707
  if (idx === -1) {
2700
- warn(`Attempting to update a non-existent array item`);
2701
2708
  return;
2702
2709
  }
2703
2710
  update(idx, value);
@@ -2945,9 +2952,6 @@
2945
2952
 
2946
2953
  function useResetForm() {
2947
2954
  const form = injectWithSelf(FormContextKey);
2948
- if (!form) {
2949
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
2950
- }
2951
2955
  return function resetForm(state) {
2952
2956
  if (!form) {
2953
2957
  return;
@@ -3003,9 +3007,6 @@
3003
3007
  */
3004
3008
  function useIsSubmitting() {
3005
3009
  const form = injectWithSelf(FormContextKey);
3006
- if (!form) {
3007
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3008
- }
3009
3010
  return vue.computed(() => {
3010
3011
  var _a;
3011
3012
  return (_a = form === null || form === void 0 ? void 0 : form.isSubmitting.value) !== null && _a !== void 0 ? _a : false;
@@ -3017,9 +3018,6 @@
3017
3018
  */
3018
3019
  function useIsValidating() {
3019
3020
  const form = injectWithSelf(FormContextKey);
3020
- if (!form) {
3021
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3022
- }
3023
3021
  return vue.computed(() => {
3024
3022
  var _a;
3025
3023
  return (_a = form === null || form === void 0 ? void 0 : form.isValidating.value) !== null && _a !== void 0 ? _a : false;
@@ -3037,9 +3035,8 @@
3037
3035
  return field.validate();
3038
3036
  }
3039
3037
  if (form && path) {
3040
- return form === null || form === void 0 ? void 0 : form.validateField(vue.unref(path));
3038
+ return form === null || form === void 0 ? void 0 : form.validateField(vue.toValue(path));
3041
3039
  }
3042
- warn(`field with name ${vue.unref(path)} was not found`);
3043
3040
  return Promise.resolve({
3044
3041
  errors: [],
3045
3042
  valid: true,
@@ -3052,9 +3049,6 @@
3052
3049
  */
3053
3050
  function useIsFormDirty() {
3054
3051
  const form = injectWithSelf(FormContextKey);
3055
- if (!form) {
3056
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3057
- }
3058
3052
  return vue.computed(() => {
3059
3053
  var _a;
3060
3054
  return (_a = form === null || form === void 0 ? void 0 : form.meta.value.dirty) !== null && _a !== void 0 ? _a : false;
@@ -3066,9 +3060,6 @@
3066
3060
  */
3067
3061
  function useIsFormTouched() {
3068
3062
  const form = injectWithSelf(FormContextKey);
3069
- if (!form) {
3070
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3071
- }
3072
3063
  return vue.computed(() => {
3073
3064
  var _a;
3074
3065
  return (_a = form === null || form === void 0 ? void 0 : form.meta.value.touched) !== null && _a !== void 0 ? _a : false;
@@ -3080,9 +3071,6 @@
3080
3071
  */
3081
3072
  function useIsFormValid() {
3082
3073
  const form = injectWithSelf(FormContextKey);
3083
- if (!form) {
3084
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3085
- }
3086
3074
  return vue.computed(() => {
3087
3075
  var _a;
3088
3076
  return (_a = form === null || form === void 0 ? void 0 : form.meta.value.valid) !== null && _a !== void 0 ? _a : false;
@@ -3094,9 +3082,6 @@
3094
3082
  */
3095
3083
  function useValidateForm() {
3096
3084
  const form = injectWithSelf(FormContextKey);
3097
- if (!form) {
3098
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3099
- }
3100
3085
  return function validateField() {
3101
3086
  if (!form) {
3102
3087
  return Promise.resolve({ results: {}, errors: {}, valid: true });
@@ -3110,9 +3095,6 @@
3110
3095
  */
3111
3096
  function useSubmitCount() {
3112
3097
  const form = injectWithSelf(FormContextKey);
3113
- if (!form) {
3114
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3115
- }
3116
3098
  return vue.computed(() => {
3117
3099
  var _a;
3118
3100
  return (_a = form === null || form === void 0 ? void 0 : form.submitCount.value) !== null && _a !== void 0 ? _a : 0;
@@ -3128,9 +3110,9 @@
3128
3110
  const field = path ? undefined : vue.inject(FieldContextKey);
3129
3111
  return vue.computed(() => {
3130
3112
  if (path) {
3131
- return getFromPath(form === null || form === void 0 ? void 0 : form.values, vue.unref(path));
3113
+ return getFromPath(form === null || form === void 0 ? void 0 : form.values, vue.toValue(path));
3132
3114
  }
3133
- return vue.unref(field === null || field === void 0 ? void 0 : field.value);
3115
+ return vue.toValue(field === null || field === void 0 ? void 0 : field.value);
3134
3116
  });
3135
3117
  }
3136
3118
 
@@ -3139,9 +3121,6 @@
3139
3121
  */
3140
3122
  function useFormValues() {
3141
3123
  const form = injectWithSelf(FormContextKey);
3142
- if (!form) {
3143
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3144
- }
3145
3124
  return vue.computed(() => {
3146
3125
  return (form === null || form === void 0 ? void 0 : form.values) || {};
3147
3126
  });
@@ -3152,9 +3131,6 @@
3152
3131
  */
3153
3132
  function useFormErrors() {
3154
3133
  const form = injectWithSelf(FormContextKey);
3155
- if (!form) {
3156
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3157
- }
3158
3134
  return vue.computed(() => {
3159
3135
  return ((form === null || form === void 0 ? void 0 : form.errors.value) || {});
3160
3136
  });
@@ -3169,7 +3145,7 @@
3169
3145
  const field = path ? undefined : vue.inject(FieldContextKey);
3170
3146
  return vue.computed(() => {
3171
3147
  if (path) {
3172
- return form === null || form === void 0 ? void 0 : form.errors.value[vue.unref(path)];
3148
+ return form === null || form === void 0 ? void 0 : form.errors.value[vue.toValue(path)];
3173
3149
  }
3174
3150
  return field === null || field === void 0 ? void 0 : field.errorMessage.value;
3175
3151
  });
@@ -3177,9 +3153,6 @@
3177
3153
 
3178
3154
  function useSubmitForm(cb) {
3179
3155
  const form = injectWithSelf(FormContextKey);
3180
- if (!form) {
3181
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3182
- }
3183
3156
  const onSubmit = form ? form.handleSubmit(cb) : undefined;
3184
3157
  return function submitForm(e) {
3185
3158
  if (!onSubmit) {
@@ -3199,9 +3172,11 @@
3199
3172
  return function setFieldError(message) {
3200
3173
  if (path && form) {
3201
3174
  form.setFieldError(vue.toValue(path), message);
3175
+ return;
3202
3176
  }
3203
3177
  if (field) {
3204
3178
  field.setErrors(message || []);
3179
+ return;
3205
3180
  }
3206
3181
  };
3207
3182
  }
@@ -3216,9 +3191,11 @@
3216
3191
  return function setFieldTouched(touched) {
3217
3192
  if (path && form) {
3218
3193
  form.setFieldTouched(vue.toValue(path), touched);
3194
+ return;
3219
3195
  }
3220
3196
  if (field) {
3221
3197
  field.setTouched(touched);
3198
+ return;
3222
3199
  }
3223
3200
  };
3224
3201
  }
@@ -3233,9 +3210,11 @@
3233
3210
  return function setFieldValue(value, shouldValidate = true) {
3234
3211
  if (path && form) {
3235
3212
  form.setFieldValue(vue.toValue(path), value, shouldValidate);
3213
+ return;
3236
3214
  }
3237
3215
  if (field) {
3238
3216
  field.setValue(value, shouldValidate);
3217
+ return;
3239
3218
  }
3240
3219
  };
3241
3220
  }
@@ -3248,6 +3227,7 @@
3248
3227
  function setFormErrors(fields) {
3249
3228
  if (form) {
3250
3229
  form.setErrors(fields);
3230
+ return;
3251
3231
  }
3252
3232
  }
3253
3233
  return setFormErrors;
@@ -3261,6 +3241,7 @@
3261
3241
  function setFormTouched(fields) {
3262
3242
  if (form) {
3263
3243
  form.setTouched(fields);
3244
+ return;
3264
3245
  }
3265
3246
  }
3266
3247
  return setFormTouched;
@@ -3274,6 +3255,7 @@
3274
3255
  function setFormValues(fields) {
3275
3256
  if (form) {
3276
3257
  form.setValues(fields);
3258
+ return;
3277
3259
  }
3278
3260
  }
3279
3261
  return setFormValues;
@@ -1,6 +1,6 @@
1
1
  /**
2
- * vee-validate v4.11.0
2
+ * vee-validate v4.11.2
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 u(e){if(!function(e){return"object"==typeof e&&null!==e}(e)||"[object Object]"!==function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}(e))return!1;if(null===Object.getPrototypeOf(e))return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function i(e,t){return Object.keys(t).forEach((n=>{if(u(t[n]))return e[n]||(e[n]={}),void i(e[n],t[n]);e[n]=t[n]})),e}function o(e){const t=e.split(".");if(!t.length)return"";let n=String(t[0]);for(let e=1;e<t.length;e++)l(t[e])?n+=`[${t[e]}]`:n+=`.${t[e]}`;return n}const s={};const d=Symbol("vee-validate-form"),c=Symbol("vee-validate-field-instance"),v=Symbol("Default empty value"),f="undefined"!=typeof window;function p(e){return n(e)&&!!e.__locatorRef}function m(e){return!!e&&n(e.parse)&&"VVTypedSchema"===e.__type}function h(e){return!!e&&n(e.validate)}function y(e){return"checkbox"===e||"radio"===e}function g(e){return/^\[.+\]$/i.test(e)}function b(e){return"SELECT"===e.tagName}function V(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&&!y(t.type)}function O(e){return F(e)&&e.target&&"submit"in e.target}function F(e){return!!e&&(!!("undefined"!=typeof Event&&n(Event)&&e instanceof Event)||!(!e||!e.srcElement))}function j(e,t){return t in e&&e[t]!==v}function A(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(!A(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(!A(r[1],t.get(r[0])))return!1;return!0}if(w(e)&&w(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();for(r=n=(a=Object.keys(e)).length;0!=r--;){var l=a[r];if(!A(e[l],t[l]))return!1}return!0}return e!=e&&t!=t}function w(e){return!!f&&e instanceof File}function S(e,t,n){"object"==typeof n.value&&(n.value=E(n.value)),n.enumerable&&!n.get&&!n.set&&n.configurable&&n.writable&&"__proto__"!==t?e[t]=n.value:Object.defineProperty(e,t,n)}function E(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(E(e))}))):"[object Map]"===l?(r=new Map,e.forEach((function(e,t){r.set(E(t),E(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(E(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++)S(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]||S(r,t,Object.getOwnPropertyDescriptor(e,t))}return r||e}function k(e){return g(e)?e.replace(/\[|\]/gi,""):e}function I(e,t,n){if(!e)return n;if(g(t))return e[k(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 M(e,t,n){if(g(t))return void(e[k(t)]=n);const a=t.split(/\.|\[(\d+)\]/).filter(Boolean);let u=e;for(let e=0;e<a.length;e++){if(e===a.length-1)return void(u[a[e]]=n);a[e]in u&&!r(u[a[e]])||(u[a[e]]=l(a[e+1])?[]:{}),u=u[a[e]]}}function C(e,t){Array.isArray(e)&&l(t)?e.splice(Number(t),1):a(e)&&delete e[t]}function B(e,t){if(g(t))return void delete e[k(t)];const n=t.split(/\.|\[(\d+)\]/).filter(Boolean);let l=e;for(let e=0;e<n.length;e++){if(e===n.length-1){C(l,n[e]);break}if(!(n[e]in l)||r(l[n[e]]))break;l=l[n[e]]}const u=n.map(((t,r)=>I(e,n.slice(0,r).join("."))));for(let t=u.length-1;t>=0;t--)i=u[t],(Array.isArray(i)?0===i.length:a(i)&&0===Object.keys(i).length)&&(0!==t?C(u[t-1],n[t-1]):C(e,n[0]));var i}function T(e){return Object.keys(e)}function P(e,n=void 0){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function U(e){t.warn(`[vee-validate]: ${e}`)}function _(e,t,n){if(Array.isArray(e)){const n=[...e],r=n.findIndex((e=>A(e,t)));return r>=0?n.splice(r,1):n.push(t),n}return A(e,t)?n:t}function R(e,t=0){let n=null,r=[];return function(...a){return n&&clearTimeout(n),n=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 $({get:e,set:n}){const r=t.ref(E(e()));return t.watch(e,(e=>{A(e,r.value)||(r.value=E(e))}),{deep:!0}),t.watch(r,(t=>{A(t,e())||n(E(t))}),{deep:!0}),r}function D(e){return Array.isArray(e)?e:e?[e]:[]}function z(e){const n=P(d),r=e?t.computed((()=>null==n?void 0:n.getPathState(t.unref(e)))):void 0,a=e?void 0:t.inject(c);return a||(null==r?void 0:r.value)||U(`field with name ${t.unref(e)} was not found`),r||a}function q(e,t){const n={};for(const r in e)t.includes(r)||(n[r]=e[r]);return n}const L=(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 K(e){if(W(e))return e._value}function W(e){return"_value"in e}function G(e){if(!F(e))return e;const t=e.target;if(y(t.type)&&W(t))return K(t);if("file"===t.type&&t.files){const e=Array.from(t.files);return t.multiple?e:e[0]}if(b(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map(K);var n;if(b(t)){const e=Array.from(t.options).find((e=>e.selected));return e?K(e):t.value}return function(e){return"number"===e.type?Number.isNaN(e.valueAsNumber)?e.value:e.valueAsNumber:e.value}(t)}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=>I(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 Y=()=>Q,Z=e=>{Q=Object.assign(Object.assign({},Q),e)};async function ee(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)||{}},u=await async function(e,t){if(m(e.rules)||h(e.rules))return async function(e,t){const n=m(t)?t:te(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 u=0;u<a;u++){const a=r[u],i=await a(t,n);if(!("string"!=typeof i&&!Array.isArray(i)&&i)){if(Array.isArray(i))l.push(...i);else{const e="string"==typeof i?i:re(n);l.push(e)}if(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),u=l.length;for(let n=0;n<u;n++){const u=l[n],i=await ne(r,t,{name:u,params:r.rules[u]});if(i.error&&(a.push(i.error),e.bails))return{errors:a}}return{errors:a}}(l,e),i=u.errors;return{errors:i,valid:!i.length}}function te(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 ne(e,t,n){const r=(a=n.name,s[a]);var a;if(!r)throw new Error(`No such validator '${n.name}' exists.`);const l=function(e,t){const n=e=>p(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),u={field:e.label||e.name,name:e.name,label:e.label,value:t,form:e.formData,rule:Object.assign(Object.assign({},n),{params:l})},i=await r(t,l,u);return"string"==typeof i?{error:i}:{error:i?void 0:re(u)}}function re(e){const t=Y().generateMessage;return t?t(e):"Field is invalid"}async function ae(e,t,n){const r=T(e).map((async r=>{var a,l,u;const i=null===(a=null==n?void 0:n.names)||void 0===a?void 0:a[r],o=await ee(I(t,r),e[r],{name:(null==i?void 0:i.name)||r,label:null==i?void 0:i.label,values:t,bails:null===(u=null===(l=null==n?void 0:n.bailsMap)||void 0===l?void 0:l[r])||void 0===u||u});return Object.assign(Object.assign({},o),{path:r})}));let a=!0;const l=await Promise.all(r),u={},i={};for(const e of l)u[e.path]={valid:e.valid,errors:e.errors},e.valid||(a=!1,i[e.path]=e.errors[0]);return{valid:a,results:u,errors:i}}let le=0;function ue(e,n){const{value:r,initialValue:a,setInitialValue:l}=function(e,n,r){const a=t.ref(t.unref(n));function l(){return r?I(r.initialValues.value,t.unref(e),t.unref(a)):t.unref(a)}function u(n){r?r.stageInitialValue(t.unref(e),n,!0):a.value=n}const i=t.computed(l);if(!r){return{value:t.ref(l()),initialValue:i,setInitialValue:u}}const o=function(e,n,r,a){if(t.isRef(e))return t.unref(e);if(void 0!==e)return e;return I(n.values,t.unref(a),t.unref(r))}(n,r,i,e);r.stageInitialValue(t.unref(e),o,!0);const s=t.computed({get:()=>I(r.values,t.unref(e)),set(n){r.setFieldValue(t.unref(e),n,!1)}});return{value:s,initialValue:i,setInitialValue:u}}(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=D(t)}}}(),d=le>=Number.MAX_SAFE_INTEGER?0:++le,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((()=>!A(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,flags:{pendingUnmount:{[d]:!1}},errors:o,setState:v}}const u=n.form.createPathState(e,{bails:n.bails,label:n.label,type:n.type,validate:n.validate}),i=t.computed((()=>u.errors));return{id:Array.isArray(u.id)?u.id[u.id.length-1]:u.id,path:e,value:r,errors:i,meta:u,initialValue:a,flags:u.__flags,setState:function(a){var u,i,o;"value"in a&&(r.value=a.value),"errors"in a&&(null===(u=n.form)||void 0===u||u.setFieldError(t.unref(e),a.errors)),"touched"in a&&(null===(i=n.form)||void 0===i||i.setFieldTouched(t.unref(e),null!==(o=a.touched)&&void 0!==o&&o)),"initialValue"in a&&l(a.initialValue)}}}function ie(e,n,r){return y(null==r?void 0:r.type)?function(e,n,r){const a=(null==r?void 0:r.standalone)?void 0:P(d),l=null==r?void 0:r.checkedValue,u=null==r?void 0:r.uncheckedValue;function i(n){const i=n.handleChange,o=t.computed((()=>{const e=t.unref(n.value),r=t.unref(l);return Array.isArray(e)?e.findIndex((e=>A(e,r)))>=0:A(r,e)}));function s(s,d=!0){var c,v;if(o.value===(null===(c=null==s?void 0:s.target)||void 0===c?void 0:c.checked))return void(d&&n.validate());const f=t.toValue(e),p=null==a?void 0:a.getPathState(f),m=G(s);let h=null!==(v=t.unref(l))&&void 0!==v?v:m;a&&(null==p?void 0:p.multiple)&&"checkbox"===p.type?h=_(I(a.values,f)||[],h,void 0):"checkbox"===(null==r?void 0:r.type)&&(h=_(t.unref(n.value),h,t.unref(u))),i(h,d)}return Object.assign(Object.assign({},n),{checked:o,checkedValue:l,uncheckedValue:u,handleChange:s})}return i(oe(e,n,r))}(e,n,r):oe(e,n,r)}function oe(e,r,a){const{initialValue:l,validateOnMount:u,bails:i,type:s,checkedValue:f,label:y,validateOnValueUpdate:g,uncheckedValue:b,controlled:V,keepValueOnUnmount:O,syncVModel:F,form:j}=function(e){const n=()=>({initialValue:void 0,validateOnMount:!1,bails:!0,label:void 0,validateOnValueUpdate:!0,keepValueOnUnmount:void 0,syncVModel:!1,controlled:!0}),r=!!(null==e?void 0:e.syncVModel),a="string"==typeof(null==e?void 0:e.syncVModel)?e.syncVModel:(null==e?void 0:e.modelPropName)||"modelValue",l=r&&!("initialValue"in(e||{}))?se(t.getCurrentInstance(),a):null==e?void 0:e.initialValue;if(!e)return Object.assign(Object.assign({},n()),{initialValue:l});const u="valueProp"in e?e.valueProp:e.checkedValue,i="standalone"in e?!e.standalone:e.controlled,o=(null==e?void 0:e.modelPropName)||(null==e?void 0:e.syncVModel)||!1;return Object.assign(Object.assign(Object.assign({},n()),e||{}),{initialValue:l,controlled:null==i||i,checkedValue:u,syncVModel:o})}(a),w=V?P(d):void 0,S=j||w,k=t.computed((()=>o(t.toValue(e)))),M=t.computed((()=>{if(t.unref(null==S?void 0:S.schema))return;const e=t.unref(r);return h(e)||m(e)||n(e)||Array.isArray(e)?e:X(e)})),{id:C,value:B,initialValue:U,meta:_,setState:R,errors:$,flags:D}=ue(k,{modelValue:l,form:S,bails:i,label:y,type:s,validate:M.value?W:void 0}),z=t.computed((()=>$.value[0]));F&&function({prop:e,value:n,handleChange:r}){const a=t.getCurrentInstance();if(!a||!e)return;const l="string"==typeof e?e:"modelValue",u=`update:${l}`;if(!(l in a.props))return;t.watch(n,(e=>{A(e,se(a,l))||a.emit(u,e)})),t.watch((()=>se(a,l)),(e=>{if(e===v&&void 0===n.value)return;const t=e===v?void 0:e;A(t,n.value)||r(t)}))}({value:B,prop:F,handleChange:H});async function q(e){var n,r;return(null==S?void 0:S.validateSchema)?null!==(n=(await S.validateSchema(e)).results[t.unref(k)])&&void 0!==n?n:{valid:!0,errors:[]}:M.value?ee(B.value,M.value,{name:t.unref(k),label:t.unref(y),values:null!==(r=null==S?void 0:S.values)&&void 0!==r?r:{},bails:i}):{valid:!0,errors:[]}}const L=N((async()=>(_.pending=!0,_.validated=!0,q("validated-only"))),(e=>{if(!D.pendingUnmount[te.id])return R({errors:e.errors}),_.pending=!1,_.valid=e.valid,e})),K=N((async()=>q("silent")),(e=>(_.valid=e.valid,e)));function W(e){return"silent"===(null==e?void 0:e.mode)?K():L()}function H(e,t=!0){Y(G(e),t)}function J(e){var t;const n=e&&"value"in e?e.value:U.value;R({value:E(n),initialValue:E(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,K()}t.onMounted((()=>{if(u)return L();S&&S.validateSchema||K()}));const Q=t.getCurrentInstance();function Y(e,t=!0){B.value=Q&&F?x(e,Q.props.modelModifiers):e;(t?L:K)()}const Z=t.computed({get:()=>B.value,set(e){Y(e,g)}}),te={id:C,name:k,label:y,value:Z,meta:_,errors:$,errorMessage:z,type:s,checkedValue:f,uncheckedValue:b,bails:i,keepValueOnUnmount:O,resetField:J,handleReset:()=>J(),validate:W,handleChange:H,handleBlur:(e,t=!1)=>{_.touched=!0,t&&L()},setState:R,setTouched:function(e){_.touched=e},setErrors:function(e){R({errors:Array.isArray(e)?e:[e]})},setValue:Y};if(t.provide(c,te),t.isRef(r)&&"function"!=typeof t.unref(r)&&t.watch(r,((e,t)=>{A(e,t)||(_.validated?L():K())}),{deep:!0}),!S)return te;const ne=t.computed((()=>{const e=M.value;return!e||n(e)||h(e)||m(e)||Array.isArray(e)?{}:Object.keys(e).reduce(((t,n)=>{const r=(a=e[n],Array.isArray(a)?a.filter(p):T(a).filter((e=>p(a[e]))).map((e=>a[e]))).map((e=>e.__locatorRef)).reduce(((e,t)=>{const n=I(S.values,t)||S.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;!A(e,t)&&(_.validated?L():K())})),t.onBeforeUnmount((()=>{var e;const n=null!==(e=t.unref(te.keepValueOnUnmount))&&void 0!==e?e:t.unref(S.keepValuesOnUnmount),r=t.toValue(k);if(n||!S||D.pendingUnmount[te.id])return void(null==S||S.removePathState(r,C));D.pendingUnmount[te.id]=!0;const a=S.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=>A(e,t.unref(te.checkedValue))));if(e>-1){const t=[...a.value];t.splice(e,1),S.setFieldValue(r,t)}Array.isArray(a.id)&&a.id.splice(a.id.indexOf(te.id),1)}else S.unsetPathValue(t.toValue(k));S.removePathState(r,C)}})),te}function se(e,t){if(e)return e.props[t]}function de(e,t){let n=e.as||"";return e.as||t.slots.default||(n="input"),n}function ce(e,t){return y(t.attrs.type)?j(e,"modelValue")?e.modelValue:void 0:j(e,"modelValue")?e.modelValue:t.attrs.value}const ve=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:()=>Y().bails},label:{type:String,default:void 0},uncheckedValue:{type:null,default:void 0},modelValue:{type:null,default:v},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"),u=t.toRef(e,"label"),i=t.toRef(e,"uncheckedValue"),o=t.toRef(e,"keepValue"),{errors:s,value:d,errorMessage:c,validate:v,handleChange:f,handleBlur:p,setTouched:m,resetField:h,handleReset:g,meta:b,checked:O,setErrors:F}=ie(l,a,{validateOnMount:e.validateOnMount,bails:e.bails,standalone:e.standalone,type:r.attrs.type,initialValue:ce(e,r),checkedValue:r.attrs.value,uncheckedValue:i,label:u,validateOnValueUpdate:!1,keepValueOnUnmount:o,syncVModel:!0}),j=function(e,t=!0){f(e,t),r.emit("update:modelValue",d.value)},A=t.computed((()=>{const{validateOnInput:t,validateOnChange:a,validateOnBlur:l,validateOnModelUpdate:u}=function(e){var t,n,r,a;const{validateOnInput:l,validateOnChange:u,validateOnBlur:i,validateOnModelUpdate:o}=Y();return{validateOnInput:null!==(t=e.validateOnInput)&&void 0!==t?t:l,validateOnChange:null!==(n=e.validateOnChange)&&void 0!==n?n:u,validateOnBlur:null!==(r=e.validateOnBlur)&&void 0!==r?r:i,validateOnModelUpdate:null!==(a=e.validateOnModelUpdate)&&void 0!==a?a:o}}(e);const i={name:e.name,onBlur:function(e){p(e,l),n(r.attrs.onBlur)&&r.attrs.onBlur(e)},onInput:function(e){j(e,t),n(r.attrs.onInput)&&r.attrs.onInput(e)},onChange:function(e){j(e,a),n(r.attrs.onChange)&&r.attrs.onChange(e)},"onUpdate:modelValue":e=>j(e,u)};return i})),w=t.computed((()=>{const t=Object.assign({},A.value);y(r.attrs.type)&&O&&(t.checked=O.value);return V(de(e,r),r.attrs)&&(t.value=d.value),t})),S=t.computed((()=>Object.assign(Object.assign({},A.value),{modelValue:d.value})));function E(){return{field:w.value,componentField:S.value,value:d.value,meta:b,errors:s.value,errorMessage:c.value,validate:v,resetField:h,handleChange:j,handleInput:e=>j(e,!1),handleReset:g,handleBlur:A.value.onBlur,setTouched:m,setErrors:F}}return r.expose({setErrors:F,setTouched:m,reset:h,validate:v,handleChange:f}),()=>{const n=t.resolveDynamicComponent(de(e,r)),a=L(n,r,E);return n?t.h(n,Object.assign(Object.assign({},r.attrs),w.value),a):a}}});let fe=0;const pe=["bails","fieldsCount","id","multiple","type","validate"];function me(e){const r=t.unref(null==e?void 0:e.initialValues)||{},a=t.unref(null==e?void 0:e.validationSchema);return a&&m(a)&&n(a.cast)?E(a.cast(r)||{}):E(r)}function he(e){var r;const a=fe++;let l=0;const u=t.ref(!1),s=t.ref(!1),c=t.ref(0),v=[],f=t.reactive(me(e)),p=t.ref([]),y=t.ref({}),g=t.ref({}),b=function(e){let n=null,r=[];return function(...a){const l=t.nextTick((()=>{if(n!==l)return;const t=e(...a);r.forEach((e=>e(t))),r=[],n=null}));return n=l,new Promise((e=>r.push(e)))}}((()=>{g.value=p.value.reduce(((e,n)=>(e[o(t.toValue(n.path))]=n,e)),{})}));function V(e,t){const n=Q(e);if(n){if("string"==typeof e){const t=o(e);y.value[t]&&delete y.value[t]}n.errors=D(t),n.valid=!n.errors.length}else"string"==typeof e&&(y.value[o(e)]=D(t))}function F(e){T(e).forEach((t=>{V(t,e[t])}))}(null==e?void 0:e.initialErrors)&&F(e.initialErrors);const j=t.computed((()=>{const e=p.value.reduce(((e,t)=>(t.errors.length&&(e[t.path]=t.errors),e)),{});return Object.assign(Object.assign({},y.value),e)})),w=t.computed((()=>T(j.value).reduce(((e,t)=>{const n=j.value[t];return(null==n?void 0:n.length)&&(e[t]=n[0]),e}),{}))),S=t.computed((()=>p.value.reduce(((e,t)=>(e[t.path]={name:t.path||"",label:t.label||""},e)),{}))),k=t.computed((()=>p.value.reduce(((e,t)=>{var n;return e[t.path]=null===(n=t.bails)||void 0===n||n,e}),{}))),C=Object.assign({},(null==e?void 0:e.initialErrors)||{}),P=null!==(r=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==r&&r,{initialValues:U,originalInitialValues:_,setInitialValues:x}=function(e,n,r){const a=me(r),l=null==r?void 0:r.initialValues,u=t.ref(a),o=t.ref(E(a));function s(t,r=!1){u.value=i(E(u.value)||{},E(t)),o.value=i(E(o.value)||{},E(t)),r&&e.value.forEach((e=>{if(e.touched)return;const t=I(u.value,e.path);M(n,e.path,E(t))}))}t.isRef(l)&&t.watch(l,(e=>{e&&s(e,!0)}),{deep:!0});return{initialValues:u,originalInitialValues:o,setInitialValues:s}}(p,f,e),$=function(e,n,r,a){const l={touched:"some",pending:"some",valid:"every"},u=t.computed((()=>!A(n,t.unref(r))));function i(){const t=e.value;return T(l).reduce(((e,n)=>{const r=l[n];return e[n]=t[r]((e=>e[n])),e}),{})}const o=t.reactive(i());return t.watchEffect((()=>{const e=i();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&&!T(a.value).length,dirty:u.value})))}(p,f,_,w),z=t.computed((()=>p.value.reduce(((e,t)=>{const n=I(f,t.path);return M(e,t.path,n),e}),{}))),L=null==e?void 0:e.validationSchema;function K(e,n){var r,a;const u=t.computed((()=>I(U.value,t.toValue(e)))),i=g.value[t.toValue(e)];if(i){"checkbox"!==(null==n?void 0:n.type)&&"radio"!==(null==n?void 0:n.type)||(i.multiple=!0);const e=l++;return Array.isArray(i.id)?i.id.push(e):i.id=[i.id,e],i.fieldsCount++,i.__flags.pendingUnmount[e]=!1,i}const o=t.computed((()=>I(f,t.toValue(e)))),s=t.toValue(e),d=l++,c=t.reactive({id:d,path:e,touched:!1,pending:!1,valid:!0,validated:!!(null===(r=C[s])||void 0===r?void 0:r.length),initialValue:u,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((()=>!A(t.unref(o),t.unref(u))))});return p.value.push(c),g.value[s]=c,b(),w.value[s]&&!C[s]&&t.nextTick((()=>{ye(s,{mode:"silent"})})),t.isRef(e)&&t.watch(e,(e=>{b();const n=E(o.value);g.value[e]=c,t.nextTick((()=>{M(f,e,n)}))})),c}const W=R(Ve,5),X=R(Ve,5),H=N((async e=>"silent"===await e?W():X()),((e,[t])=>{const n=T(le.errorBag.value);return[...new Set([...T(e.results),...p.value.map((e=>e.path)),...n])].sort().reduce(((n,r)=>{const a=r,l=Q(a)||function(e){const t=p.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),u=(e.results[a]||{errors:[]}).errors,i={errors:u,valid:!u.length};return n.results[a]=i,i.valid||(n.errors[a]=i.errors[0]),l&&y.value[a]&&delete y.value[a],l?(l.valid=i.valid,"silent"===t?n:"validated-only"!==t||l.validated?(V(l,i.errors),n):n):(V(a,u),n)}),{valid:e.valid,results:{},errors:{}})}));function J(e){p.value.forEach(e)}function Q(e){const t="string"==typeof e?o(e):e;return"string"==typeof t?g.value[t]:t}let Z,ee=[];function ne(e){return function(t,n){return function(r){return r instanceof Event&&(r.preventDefault(),r.stopPropagation()),J((e=>e.touched=!0)),u.value=!0,c.value++,he().then((a=>{const l=E(f);if(a.valid&&"function"==typeof t){const n=E(z.value);let u=e?n:l;return a.values&&(u=a.values),t(u,{evt:r,controlledValues:n,setErrors:F,setFieldError:V,setTouched:de,setFieldTouched:se,setValues:ie,setFieldValue:ue,resetForm:ve,resetField:ce})}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 re=ne(!1);re.withControlled=ne(!0);const le={formId:a,values:f,controlledValues:z,errorBag:j,errors:w,schema:L,submitCount:c,meta:$,isSubmitting:u,isValidating:s,fieldArrays:v,keepValuesOnUnmount:P,validateSchema:t.unref(L)?H:void 0,validate:he,setFieldError:V,validateField:ye,setFieldValue:ue,setValues:ie,setErrors:F,setFieldTouched:se,setTouched:de,resetForm:ve,resetField:ce,handleSubmit:re,stageInitialValue:function(t,n,r=!1){be(t,n),M(f,t,n),r&&!(null==e?void 0:e.initialValues)&&M(_.value,t,E(n))},unsetInitialValue:ge,setFieldInitialValue:be,useFieldModel:function(e){if(!Array.isArray(e))return oe(e);return e.map(oe)},createPathState:K,getPathState:Q,unsetPathValue:function(e){return ee.push(e),Z||(Z=t.nextTick((()=>{[...ee].sort().reverse().forEach((e=>{B(f,e)})),ee=[],Z=null}))),Z},removePathState:function(e,n){const r=p.value.findIndex((t=>t.path===e)),a=p.value[r];if(-1!==r&&a){if(t.nextTick((()=>{ye(e,{mode:"silent",warn:!1})})),a.multiple&&a.fieldsCount&&a.fieldsCount--,Array.isArray(a.id)){const e=a.id.indexOf(n);e>=0&&a.id.splice(e,1),delete a.__flags.pendingUnmount[n]}(!a.multiple||a.fieldsCount<=0)&&(p.value.splice(r,1),ge(e),b(),delete g.value[e])}},initialValues:U,getAllPathStates:()=>p.value,markForUnmount:function(e){return J((t=>{t.path.startsWith(e)&&T(t.__flags.pendingUnmount).forEach((e=>{t.__flags.pendingUnmount[e]=!0}))}))}};function ue(e,t,n=!0){const r=E(t),a="string"==typeof e?e:e.path;Q(a)||K(a),M(f,a,r),n&&ye(a)}function ie(e,t=!0){i(f,e),v.forEach((e=>e&&e.reset())),t&&he()}function oe(e){const n=Q(t.unref(e))||K(e);return t.computed({get:()=>n.value,set(r){const a=t.unref(e);ue(a,r,!1),n.validated=!0,n.pending=!0,ye(a).then((()=>{n.pending=!1}))}})}function se(e,t){const n=Q(e);n&&(n.touched=t)}function de(e){"boolean"!=typeof e?T(e).forEach((t=>{se(t,!!e[t])})):J((t=>{t.touched=e}))}function ce(e,t){var n;const r=t&&"value"in t?t.value:I(U.value,e);be(e,E(r)),ue(e,r,!1),se(e,null!==(n=null==t?void 0:t.touched)&&void 0!==n&&n),V(e,(null==t?void 0:t.errors)||[])}function ve(e){let r=(null==e?void 0:e.values)?e.values:_.value;r=m(L)&&n(L.cast)?L.cast(r):r,x(r),J((t=>{var n;t.validated=!1,t.touched=(null===(n=null==e?void 0:e.touched)||void 0===n?void 0:n[t.path])||!1,ue(t.path,I(r,t.path),!1),V(t.path,void 0)})),ie(r,!1),F((null==e?void 0:e.errors)||{}),c.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{he({mode:"silent"})}))}async function he(e){const t=(null==e?void 0:e.mode)||"force";if("force"===t&&J((e=>e.validated=!0)),le.validateSchema)return le.validateSchema(t);s.value=!0;const n=await Promise.all(p.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 ye(e,n){var r;const a=Q(e);if(a&&(a.validated=!0),L){const{results:t}=await H((null==n?void 0:n.mode)||"validated-only");return t[e]||{errors:[],valid:!0}}if(null==a?void 0:a.validate)return a.validate(n);return!a&&(null===(r=null==n?void 0:n.warn)||void 0===r||r)&&t.warn(`field with path ${e} was not found`),Promise.resolve({errors:[],valid:!0})}function ge(e){B(U.value,e)}function be(e,t){M(U.value,e,E(t))}async function Ve(){const e=t.unref(L);if(!e)return{valid:!0,results:{},errors:{}};s.value=!0;const n=h(e)||m(e)?await async function(e,t){const n=m(e)?e:te(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,f):await ae(e,f,{names:S.value,bailsMap:k.value});return s.value=!1,n}const Oe=re(((e,{evt:t})=>{O(t)&&t.target.submit()}));return t.onMounted((()=>{(null==e?void 0:e.initialErrors)&&F(e.initialErrors),(null==e?void 0:e.initialTouched)&&de(e.initialTouched),(null==e?void 0:e.validateOnMount)?he():le.validateSchema&&le.validateSchema("silent")})),t.isRef(L)&&t.watch(L,(()=>{var e;null===(e=le.validateSchema)||void 0===e||e.call(le,"validated-only")})),t.provide(d,le),Object.assign(Object.assign({},le),{values:t.readonly(f),handleReset:()=>ve(),submitForm:Oe,defineComponentBinds:function(e,r){const a=Q(t.toValue(e))||K(e),l=()=>n(r)?r(q(a,pe)):r||{};function u(){var e;a.touched=!0;(null!==(e=l().validateOnBlur)&&void 0!==e?e:Y().validateOnBlur)&&ye(a.path)}function i(e){var t;const n=null!==(t=l().validateOnModelUpdate)&&void 0!==t?t:Y().validateOnModelUpdate;ue(a.path,e,n)}return t.computed((()=>{if(n(r)){const e=r(a),t=e.model||"modelValue";return Object.assign({onBlur:u,[t]:a.value,[`onUpdate:${t}`]:i},e.props||{})}const e=(null==r?void 0:r.model)||"modelValue",t={onBlur:u,[e]:a.value,[`onUpdate:${e}`]:i};return(null==r?void 0:r.mapProps)?Object.assign(Object.assign({},t),r.mapProps(q(a,pe))):t}))},defineInputBinds:function(e,r){const a=Q(t.toValue(e))||K(e),l=()=>n(r)?r(q(a,pe)):r||{};function u(){var e;a.touched=!0;(null!==(e=l().validateOnBlur)&&void 0!==e?e:Y().validateOnBlur)&&ye(a.path)}function i(e){var t;const n=G(e),r=null!==(t=l().validateOnInput)&&void 0!==t?t:Y().validateOnInput;ue(a.path,n,r)}function o(e){var t;const n=G(e),r=null!==(t=l().validateOnChange)&&void 0!==t?t:Y().validateOnChange;ue(a.path,n,r)}return t.computed((()=>{const e={value:a.value,onChange:o,onInput:i,onBlur:u};return n(r)?Object.assign(Object.assign({},e),r(q(a,pe)).attrs||{}):(null==r?void 0:r.mapAttrs)?Object.assign(Object.assign({},e),r.mapAttrs(q(a,pe))):e}))}})}const ye=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:u,errorBag:i,values:o,meta:s,isSubmitting:d,isValidating:c,submitCount:v,controlledValues:f,validate:p,validateField:m,handleReset:h,resetForm:y,handleSubmit:g,setErrors:b,setFieldError:V,setFieldValue:j,setValues:A,setFieldTouched:w,setTouched:S,resetField:k}=he({validationSchema:a.value?a:void 0,initialValues:r,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:l}),I=g(((e,{evt:t})=>{O(t)&&t.target.submit()}),e.onInvalidSubmit),M=e.onSubmit?g(e.onSubmit,e.onInvalidSubmit):I;function C(e){F(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 T(){return E(o)}function P(){return E(s.value)}function U(){return E(u.value)}function _(){return{meta:s.value,errors:u.value,errorBag:i.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:b,setFieldError:V,setFieldValue:j,setValues:A,setFieldTouched:w,setTouched:S,resetForm:y,resetField:k,getValues:T,getMeta:P,getErrors:U}}return n.expose({setFieldError:V,setErrors:b,setFieldValue:j,setValues:A,setFieldTouched:w,setTouched:S,resetForm:y,validate:p,validateField:m,resetField:k,getValues:T,getMeta:P,getErrors:U}),function(){const r="form"===e.as?e.as:t.resolveDynamicComponent(e.as),a=L(r,n,_);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:M,onReset:C}),a)}}}),ge=ye;function be(e){const n=P(d,void 0),a=t.ref([]),l=()=>{},u={fields:a,remove:l,push:l,swap:l,insert:l,update:l,replace:l,prepend:l,move:l};if(!n)return U("FieldArray requires being a child of `<Form/>` or `useForm` being called before it. Array fields may not work correctly"),u;if(!t.unref(e))return U("FieldArray requires a field path to be provided, did you forget to pass the `name` prop?"),u;const i=n.fieldArrays.find((n=>t.unref(n.path)===t.unref(e)));if(i)return i;let o=0;function s(){return I(null==n?void 0:n.values,t.unref(e),[])||[]}function c(){const e=s();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,u,i){if(i&&!r(u)&&i[u])return i[u];const s=o++,d={key:s,value:$({get(){const r=I(null==n?void 0:n.values,t.unref(e),[])||[],u=a.value.findIndex((e=>e.key===s));return-1===u?l:r[u]},set(e){const t=a.value.findIndex((e=>e.key===s));-1!==t?m(t,e):U("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),u=I(null==n?void 0:n.values,l);!Array.isArray(u)||u.length-1<r||(M(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),u=I(null==n?void 0:n.values,l);if(!u||!Array.isArray(u))return;const i=[...u];i.splice(r,1);const o=l+`[${r}]`;n.markForUnmount(o),n.unsetInitialValue(o),M(n.values,l,i),a.value.splice(r,1),p()},push:function(l){const u=E(l),i=t.unref(e),o=I(null==n?void 0:n.values,i),s=r(o)?[]:o;if(!Array.isArray(s))return;const d=[...s];d.push(u),n.stageInitialValue(i+`[${d.length-1}]`,u),M(n.values,i,d),a.value.push(f(u)),p()},swap:function(r,l){const u=t.unref(e),i=I(null==n?void 0:n.values,u);if(!Array.isArray(i)||!(r in i)||!(l in i))return;const o=[...i],s=[...a.value],d=o[r];o[r]=o[l],o[l]=d;const c=s[r];s[r]=s[l],s[l]=c,M(n.values,u,o),a.value=s,v()},insert:function(r,l){const u=E(l),i=t.unref(e),o=I(null==n?void 0:n.values,i);if(!Array.isArray(o)||o.length<r)return;const s=[...o],d=[...a.value];s.splice(r,0,u),d.splice(r,0,f(u)),M(n.values,i,s),a.value=d,p()},update:m,replace:function(r){const a=t.unref(e);n.stageInitialValue(a,r),M(n.values,a,r),c(),p()},prepend:function(l){const u=E(l),i=t.unref(e),o=I(null==n?void 0:n.values,i),s=r(o)?[]:o;if(!Array.isArray(s))return;const d=[u,...s];n.stageInitialValue(i+`[${d.length-1}]`,u),M(n.values,i,d),a.value.unshift(f(u)),p()},move:function(l,u){const i=t.unref(e),o=I(null==n?void 0:n.values,i),s=r(o)?[]:[...o];if(!Array.isArray(o)||!(l in o)||!(u in o))return;const d=[...a.value],c=d[l];d.splice(l,1),d.splice(u,0,c);const v=s[l];s.splice(l,1),s.splice(u,0,v),M(n.values,i,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(s,(e=>{A(e,a.value.map((e=>e.value)))||c()})),h}const Ve=t.defineComponent({name:"FieldArray",inheritAttrs:!1,props:{name:{type:String,required:!0}},setup(e,n){const{push:r,remove:a,swap:l,insert:u,replace:i,update:o,prepend:s,move:d,fields:c}=be(t.toRef(e,"name"));function v(){return{fields:c.value,push:r,remove:a,swap:l,insert:u,update:o,replace:i,prepend:s,move:d}}return n.expose({push:r,remove:a,swap:l,insert:u,update:o,replace:i,prepend:s,move:d}),()=>L(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(d,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,u=L(r,n,l),i=Object.assign({role:"alert"},n.attrs);return r||!Array.isArray(u)&&u||!(null==u?void 0:u.length)?!Array.isArray(u)&&u||(null==u?void 0:u.length)?t.h(r,i,u):t.h(r||"span",i,a.value):u}}});e.ErrorMessage=Oe,e.Field=ve,e.FieldArray=Ve,e.FieldContextKey=c,e.Form=ge,e.FormContextKey=d,e.IS_ABSENT=v,e.configure=Z,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),s[e]=t},e.normalizeRules=X,e.useField=ie,e.useFieldArray=be,e.useFieldError=function(e){const n=P(d),r=e?void 0:t.inject(c);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=P(d),r=e?void 0:t.inject(c);return t.computed((()=>e?I(null==n?void 0:n.values,t.unref(e)):t.unref(null==r?void 0:r.value)))},e.useForm=he,e.useFormErrors=function(){const e=P(d);return e||U("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=P(d);return e||U("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=z(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=z(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=z(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=P(d);return e||U("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=P(d);return e||U("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=P(d);return e||U("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=P(d);return e||U("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=P(d);return e||U("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=P(d);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),function(t){if(e)return e.resetForm(t)}},e.useSetFieldError=function(e){const n=P(d),r=e?void 0:t.inject(c);return function(a){e&&n&&n.setFieldError(t.toValue(e),a),r&&r.setErrors(a||[])}},e.useSetFieldTouched=function(e){const n=P(d),r=e?void 0:t.inject(c);return function(a){e&&n&&n.setFieldTouched(t.toValue(e),a),r&&r.setTouched(a)}},e.useSetFieldValue=function(e){const n=P(d),r=e?void 0:t.inject(c);return function(a,l=!0){e&&n&&n.setFieldValue(t.toValue(e),a,l),r&&r.setValue(a,l)}},e.useSetFormErrors=function(){const e=P(d);return function(t){e&&e.setErrors(t)}},e.useSetFormTouched=function(){const e=P(d);return function(t){e&&e.setTouched(t)}},e.useSetFormValues=function(){const e=P(d);return function(t){e&&e.setValues(t)}},e.useSubmitCount=function(){const e=P(d);return e||U("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=P(d);t||U("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=P(d),r=e?void 0:t.inject(c);return function(){return r?r.validate():n&&e?null==n?void 0:n.validateField(t.unref(e)):(U(`field with name ${t.unref(e)} was not found`),Promise.resolve({errors:[],valid:!0}))}},e.useValidateForm=function(){const e=P(d);return e||U("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=ee,e.validateObject=ae}));
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 l=e=>null!==e&&!!e&&"object"==typeof e&&!Array.isArray(e);function a(e){return Number(e)>=0}function u(e){if(!function(e){return"object"==typeof e&&null!==e}(e)||"[object Object]"!==function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}(e))return!1;if(null===Object.getPrototypeOf(e))return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function i(e,t){return Object.keys(t).forEach((n=>{if(u(t[n]))return e[n]||(e[n]={}),void i(e[n],t[n]);e[n]=t[n]})),e}function o(e){const t=e.split(".");if(!t.length)return"";let n=String(t[0]);for(let e=1;e<t.length;e++)a(t[e])?n+=`[${t[e]}]`:n+=`.${t[e]}`;return n}const s={};const d=Symbol("vee-validate-form"),c=Symbol("vee-validate-field-instance"),v=Symbol("Default empty value"),f="undefined"!=typeof window;function p(e){return n(e)&&!!e.__locatorRef}function m(e){return!!e&&n(e.parse)&&"VVTypedSchema"===e.__type}function h(e){return!!e&&n(e.validate)}function y(e){return"checkbox"===e||"radio"===e}function g(e){return/^\[.+\]$/i.test(e)}function b(e){return"SELECT"===e.tagName}function V(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&&!y(t.type)}function O(e){return j(e)&&e.target&&"submit"in e.target}function j(e){return!!e&&(!!("undefined"!=typeof Event&&n(Event)&&e instanceof Event)||!(!e||!e.srcElement))}function A(e,t){return t in e&&e[t]!==v}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,l;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(S(e)&&S(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();for(r=n=(l=Object.keys(e)).length;0!=r--;){var a=l[r];if(!F(e[a],t[a]))return!1}return!0}return e!=e&&t!=t}function S(e){return!!f&&e instanceof File}function E(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,l=0,a=Object.prototype.toString.call(e);if("[object Object]"===a?r=Object.create(e.__proto__||null):"[object Array]"===a?r=Array(e.length):"[object Set]"===a?(r=new Set,e.forEach((function(e){r.add(w(e))}))):"[object Map]"===a?(r=new Map,e.forEach((function(e,t){r.set(w(t),w(e))}))):"[object Date]"===a?r=new Date(+e):"[object RegExp]"===a?r=new RegExp(e.source,e.flags):"[object DataView]"===a?r=new e.constructor(w(e.buffer)):"[object ArrayBuffer]"===a?r=e.slice(0):"Array]"===a.slice(-6)&&(r=new e.constructor(e)),r){for(n=Object.getOwnPropertySymbols(e);l<n.length;l++)E(r,n[l],Object.getOwnPropertyDescriptor(e,n[l]));for(l=0,n=Object.getOwnPropertyNames(e);l<n.length;l++)Object.hasOwnProperty.call(r,t=n[l])&&r[t]===e[t]||E(r,t,Object.getOwnPropertyDescriptor(e,t))}return r||e}function k(e){return g(e)?e.replace(/\[|\]/gi,""):e}function I(e,t,n){if(!e)return n;if(g(t))return e[k(t)];return(t||"").split(/\.|\[(\d+)\]/).filter(Boolean).reduce(((e,t)=>{return(l(r=e)||Array.isArray(r))&&t in e?e[t]:n;var r}),e)}function M(e,t,n){if(g(t))return void(e[k(t)]=n);const l=t.split(/\.|\[(\d+)\]/).filter(Boolean);let u=e;for(let e=0;e<l.length;e++){if(e===l.length-1)return void(u[l[e]]=n);l[e]in u&&!r(u[l[e]])||(u[l[e]]=a(l[e+1])?[]:{}),u=u[l[e]]}}function C(e,t){Array.isArray(e)&&a(t)?e.splice(Number(t),1):l(e)&&delete e[t]}function B(e,t){if(g(t))return void delete e[k(t)];const n=t.split(/\.|\[(\d+)\]/).filter(Boolean);let a=e;for(let e=0;e<n.length;e++){if(e===n.length-1){C(a,n[e]);break}if(!(n[e]in a)||r(a[n[e]]))break;a=a[n[e]]}const u=n.map(((t,r)=>I(e,n.slice(0,r).join("."))));for(let t=u.length-1;t>=0;t--)i=u[t],(Array.isArray(i)?0===i.length:l(i)&&0===Object.keys(i).length)&&(0!==t?C(u[t-1],n[t-1]):C(e,n[0]));var i}function T(e){return Object.keys(e)}function P(e,n=void 0){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function U(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 _(e,t=0){let n=null,r=[];return function(...l){return n&&clearTimeout(n),n=setTimeout((()=>{const t=e(...l);r.forEach((e=>e(t))),r=[]}),t),new Promise((e=>r.push(e)))}}function R(e,t){return l(t)&&t.number?function(e){const t=parseFloat(e);return isNaN(t)?e:t}(e):e}function x(e,t){let n;return async function(...r){const l=e(...r);n=l;const a=await l;return l!==n||(n=void 0,t(a,r)),a}}function N({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 Array.isArray(e)?e:e?[e]:[]}function D(e){const n=P(d),r=e?t.computed((()=>null==n?void 0:n.getPathState(t.toValue(e)))):void 0,l=e?void 0:t.inject(c);return!l&&(null==r||r.value),r||l}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(!j(e))return e;const t=e.target;if(y(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(b(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map(L);var n;if(b(t)){const e=Array.from(t.options).find((e=>e.selected));return e?L(e):t.value}return function(e){return"number"===e.type||"range"===e.type?Number.isNaN(e.valueAsNumber)?e.value:e.valueAsNumber:e.value}(t)}function G(e){const t={};return Object.defineProperty(t,"_$$isNormalized",{value:!0,writable:!1,enumerable:!1,configurable:!1}),e?l(e)&&e._$$isNormalized?e:l(e)?Object.keys(e).reduce(((t,n)=>{const r=function(e){if(!0===e)return[];if(Array.isArray(e))return e;if(l(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=>I(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 l=null==r?void 0:r.bails,a={name:(null==r?void 0:r.name)||"{field}",rules:t,label:null==r?void 0:r.label,bails:null==l||l,formData:(null==r?void 0:r.values)||{}},u=await async function(e,t){if(m(e.rules)||h(e.rules))return async function(e,t){const n=m(t)?t:ee(t),r=await n.parse(e),l=[];for(const e of r.errors)e.errors.length&&l.push(...e.errors);return{errors:l}}(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],l=r.length,a=[];for(let u=0;u<l;u++){const l=r[u],i=await l(t,n);if(!("string"!=typeof i&&!Array.isArray(i)&&i)){if(Array.isArray(i))a.push(...i);else{const e="string"==typeof i?i:ne(n);a.push(e)}if(e.bails)return{errors:a}}}return{errors:a}}const r=Object.assign(Object.assign({},e),{rules:G(e.rules)}),l=[],a=Object.keys(r.rules),u=a.length;for(let n=0;n<u;n++){const u=a[n],i=await te(r,t,{name:u,params:r.rules[u]});if(i.error&&(l.push(i.error),e.bails))return{errors:l}}return{errors:l}}(a,e),i=u.errors;return{errors:i,valid:!i.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=(l=n.name,s[l]);var l;if(!r)throw new Error(`No such validator '${n.name}' exists.`);const a=function(e,t){const n=e=>p(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),u={field:e.label||e.name,name:e.name,label:e.label,value:t,form:e.formData,rule:Object.assign(Object.assign({},n),{params:a})},i=await r(t,a,u);return"string"==typeof i?{error:i}:{error:i?void 0:ne(u)}}function ne(e){const t=Q().generateMessage;return t?t(e):"Field is invalid"}async function re(e,t,n){const r=T(e).map((async r=>{var l,a,u;const i=null===(l=null==n?void 0:n.names)||void 0===l?void 0:l[r],o=await Z(I(t,r),e[r],{name:(null==i?void 0:i.name)||r,label:null==i?void 0:i.label,values:t,bails:null===(u=null===(a=null==n?void 0:n.bailsMap)||void 0===a?void 0:a[r])||void 0===u||u});return Object.assign(Object.assign({},o),{path:r})}));let l=!0;const a=await Promise.all(r),u={},i={};for(const e of a)u[e.path]={valid:e.valid,errors:e.errors},e.valid||(l=!1,i[e.path]=e.errors[0]);return{valid:l,results:u,errors:i}}let le=0;function ae(e,n){const{value:r,initialValue:l,setInitialValue:a}=function(e,n,r){const l=t.ref(t.unref(n));function a(){return r?I(r.initialValues.value,t.unref(e),t.unref(l)):t.unref(l)}function u(n){r?r.stageInitialValue(t.unref(e),n,!0):l.value=n}const i=t.computed(a);if(!r){return{value:t.ref(a()),initialValue:i,setInitialValue:u}}const o=function(e,n,r,l){if(t.isRef(e))return t.unref(e);if(void 0!==e)return e;return I(n.values,t.unref(l),t.unref(r))}(n,r,i,e);r.stageInitialValue(t.unref(e),o,!0);const s=t.computed({get:()=>I(r.values,t.unref(e)),set(n){r.setFieldValue(t.unref(e),n,!1)}});return{value:s,initialValue:i,setInitialValue:u}}(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=le>=Number.MAX_SAFE_INTEGER?0:++le,c=function(e,n,r){const l=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=>{l.valid=!e.length}),{immediate:!0,flush:"sync"}),l}(r,l,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&&a(e.initialValue)}return{id:d,path:e,value:r,initialValue:l,meta:c,flags:{pendingUnmount:{[d]:!1}},errors:o,setState:v}}const u=n.form.createPathState(e,{bails:n.bails,label:n.label,type:n.type,validate:n.validate}),i=t.computed((()=>u.errors));return{id:Array.isArray(u.id)?u.id[u.id.length-1]:u.id,path:e,value:r,errors:i,meta:u,initialValue:l,flags:u.__flags,setState:function(l){var u,i,o;"value"in l&&(r.value=l.value),"errors"in l&&(null===(u=n.form)||void 0===u||u.setFieldError(t.unref(e),l.errors)),"touched"in l&&(null===(i=n.form)||void 0===i||i.setFieldTouched(t.unref(e),null!==(o=l.touched)&&void 0!==o&&o)),"initialValue"in l&&a(l.initialValue)}}}function ue(e,n,r){return y(null==r?void 0:r.type)?function(e,n,r){const l=(null==r?void 0:r.standalone)?void 0:P(d),a=null==r?void 0:r.checkedValue,u=null==r?void 0:r.uncheckedValue;function i(n){const i=n.handleChange,o=t.computed((()=>{const e=t.toValue(n.value),r=t.toValue(a);return Array.isArray(e)?e.findIndex((e=>F(e,r)))>=0:F(r,e)}));function s(s,d=!0){var c,v;if(o.value===(null===(c=null==s?void 0:s.target)||void 0===c?void 0:c.checked))return void(d&&n.validate());const f=t.toValue(e),p=null==l?void 0:l.getPathState(f),m=W(s);let h=null!==(v=t.toValue(a))&&void 0!==v?v:m;l&&(null==p?void 0:p.multiple)&&"checkbox"===p.type?h=U(I(l.values,f)||[],h,void 0):"checkbox"===(null==r?void 0:r.type)&&(h=U(t.toValue(n.value),h,t.toValue(u))),i(h,d)}return Object.assign(Object.assign({},n),{checked:o,checkedValue:a,uncheckedValue:u,handleChange:s})}return i(ie(e,n,r))}(e,n,r):ie(e,n,r)}function ie(e,r,l){const{initialValue:a,validateOnMount:u,bails:i,type:s,checkedValue:f,label:y,validateOnValueUpdate:g,uncheckedValue:b,controlled:V,keepValueOnUnmount:O,syncVModel:j,form:A}=function(e){const n=()=>({initialValue:void 0,validateOnMount:!1,bails:!0,label:void 0,validateOnValueUpdate:!0,keepValueOnUnmount:void 0,syncVModel:!1,controlled:!0}),r=!!(null==e?void 0:e.syncVModel),l="string"==typeof(null==e?void 0:e.syncVModel)?e.syncVModel:(null==e?void 0:e.modelPropName)||"modelValue",a=r&&!("initialValue"in(e||{}))?oe(t.getCurrentInstance(),l):null==e?void 0:e.initialValue;if(!e)return Object.assign(Object.assign({},n()),{initialValue:a});const u="valueProp"in e?e.valueProp:e.checkedValue,i="standalone"in e?!e.standalone:e.controlled,o=(null==e?void 0:e.modelPropName)||(null==e?void 0:e.syncVModel)||!1;return Object.assign(Object.assign(Object.assign({},n()),e||{}),{initialValue:a,controlled:null==i||i,checkedValue:u,syncVModel:o})}(l),S=V?P(d):void 0,E=A||S,k=t.computed((()=>o(t.toValue(e)))),M=t.computed((()=>{if(t.toValue(null==E?void 0:E.schema))return;const e=t.unref(r);return h(e)||m(e)||n(e)||Array.isArray(e)?e:G(e)})),{id:C,value:B,initialValue:U,meta:_,setState:N,errors:$,flags:D}=ae(k,{modelValue:a,form:E,bails:i,label:y,type:s,validate:M.value?X:void 0}),z=t.computed((()=>$.value[0]));j&&function({prop:e,value:n,handleChange:r}){const l=t.getCurrentInstance();if(!l||!e)return;const a="string"==typeof e?e:"modelValue",u=`update:${a}`;if(!(a in l.props))return;t.watch(n,(e=>{F(e,oe(l,a))||l.emit(u,e)})),t.watch((()=>oe(l,a)),(e=>{if(e===v&&void 0===n.value)return;const t=e===v?void 0:e;F(t,n.value)||r(t)}))}({value:B,prop:j,handleChange:H});async function q(e){var n,r;return(null==E?void 0:E.validateSchema)?null!==(n=(await E.validateSchema(e)).results[t.toValue(k)])&&void 0!==n?n:{valid:!0,errors:[]}:M.value?Z(B.value,M.value,{name:t.toValue(k),label:t.toValue(y),values:null!==(r=null==E?void 0:E.values)&&void 0!==r?r:{},bails:i}):{valid:!0,errors:[]}}const L=x((async()=>(_.pending=!0,_.validated=!0,q("validated-only"))),(e=>{if(!D.pendingUnmount[te.id])return N({errors:e.errors}),_.pending=!1,_.valid=e.valid,e})),K=x((async()=>q("silent")),(e=>(_.valid=e.valid,e)));function X(e){return"silent"===(null==e?void 0:e.mode)?K():L()}function H(e,t=!0){Y(W(e),t)}function J(e){var t;const n=e&&"value"in e?e.value:U.value;N({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,K()}t.onMounted((()=>{if(u)return L();E&&E.validateSchema||K()}));const Q=t.getCurrentInstance();function Y(e,t=!0){B.value=Q&&j?R(e,Q.props.modelModifiers):e;(t?L:K)()}const ee=t.computed({get:()=>B.value,set(e){Y(e,g)}}),te={id:C,name:k,label:y,value:ee,meta:_,errors:$,errorMessage:z,type:s,checkedValue:f,uncheckedValue:b,bails:i,keepValueOnUnmount:O,resetField:J,handleReset:()=>J(),validate:X,handleChange:H,handleBlur:(e,t=!1)=>{_.touched=!0,t&&L()},setState:N,setTouched:function(e){_.touched=e},setErrors:function(e){N({errors:Array.isArray(e)?e:[e]})},setValue:Y};if(t.provide(c,te),t.isRef(r)&&"function"!=typeof t.unref(r)&&t.watch(r,((e,t)=>{F(e,t)||(_.validated?L():K())}),{deep:!0}),!E)return te;const ne=t.computed((()=>{const e=M.value;return!e||n(e)||h(e)||m(e)||Array.isArray(e)?{}:Object.keys(e).reduce(((t,n)=>{const r=(l=e[n],Array.isArray(l)?l.filter(p):T(l).filter((e=>p(l[e]))).map((e=>l[e]))).map((e=>e.__locatorRef)).reduce(((e,t)=>{const n=I(E.values,t)||E.values[t];return void 0!==n&&(e[t]=n),e}),{});var l;return Object.assign(t,r),t}),{})}));return t.watch(ne,((e,t)=>{if(!Object.keys(e).length)return;!F(e,t)&&(_.validated?L():K())})),t.onBeforeUnmount((()=>{var e;const n=null!==(e=t.toValue(te.keepValueOnUnmount))&&void 0!==e?e:t.toValue(E.keepValuesOnUnmount),r=t.toValue(k);if(n||!E||D.pendingUnmount[te.id])return void(null==E||E.removePathState(r,C));D.pendingUnmount[te.id]=!0;const l=E.getPathState(r);if(Array.isArray(null==l?void 0:l.id)&&(null==l?void 0:l.multiple)?null==l?void 0:l.id.includes(te.id):(null==l?void 0:l.id)===te.id){if((null==l?void 0:l.multiple)&&Array.isArray(l.value)){const e=l.value.findIndex((e=>F(e,t.toValue(te.checkedValue))));if(e>-1){const t=[...l.value];t.splice(e,1),E.setFieldValue(r,t)}Array.isArray(l.id)&&l.id.splice(l.id.indexOf(te.id),1)}else E.unsetPathValue(t.toValue(k));E.removePathState(r,C)}})),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 y(t.attrs.type)?A(e,"modelValue")?e.modelValue:void 0:A(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:v},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 l=t.toRef(e,"rules"),a=t.toRef(e,"name"),u=t.toRef(e,"label"),i=t.toRef(e,"uncheckedValue"),o=t.toRef(e,"keepValue"),{errors:s,value:d,errorMessage:c,validate:v,handleChange:f,handleBlur:p,setTouched:m,resetField:h,handleReset:g,meta:b,checked:O,setErrors:j}=ue(a,l,{validateOnMount:e.validateOnMount,bails:e.bails,standalone:e.standalone,type:r.attrs.type,initialValue:de(e,r),checkedValue:r.attrs.value,uncheckedValue:i,label:u,validateOnValueUpdate:!1,keepValueOnUnmount:o,syncVModel:!0}),A=function(e,t=!0){f(e,t),r.emit("update:modelValue",d.value)},F=t.computed((()=>{const{validateOnInput:t,validateOnChange:l,validateOnBlur:a,validateOnModelUpdate:u}=function(e){var t,n,r,l;const{validateOnInput:a,validateOnChange:u,validateOnBlur:i,validateOnModelUpdate:o}=Q();return{validateOnInput:null!==(t=e.validateOnInput)&&void 0!==t?t:a,validateOnChange:null!==(n=e.validateOnChange)&&void 0!==n?n:u,validateOnBlur:null!==(r=e.validateOnBlur)&&void 0!==r?r:i,validateOnModelUpdate:null!==(l=e.validateOnModelUpdate)&&void 0!==l?l:o}}(e);const i={name:e.name,onBlur:function(e){p(e,a),n(r.attrs.onBlur)&&r.attrs.onBlur(e)},onInput:function(e){A(e,t),n(r.attrs.onInput)&&r.attrs.onInput(e)},onChange:function(e){A(e,l),n(r.attrs.onChange)&&r.attrs.onChange(e)},"onUpdate:modelValue":e=>A(e,u)};return i})),S=t.computed((()=>{const t=Object.assign({},F.value);y(r.attrs.type)&&O&&(t.checked=O.value);return V(se(e,r),r.attrs)&&(t.value=d.value),t})),E=t.computed((()=>Object.assign(Object.assign({},F.value),{modelValue:d.value})));function w(){return{field:S.value,componentField:E.value,value:d.value,meta:b,errors:s.value,errorMessage:c.value,validate:v,resetField:h,handleChange:A,handleInput:e=>A(e,!1),handleReset:g,handleBlur:F.value.onBlur,setTouched:m,setErrors:j}}return r.expose({setErrors:j,setTouched:m,reset:h,validate:v,handleChange:f}),()=>{const n=t.resolveDynamicComponent(se(e,r)),l=q(n,r,w);return n?t.h(n,Object.assign(Object.assign({},r.attrs),S.value),l):l}}});let ve=0;const fe=["bails","fieldsCount","id","multiple","type","validate"];function pe(e){const r=t.unref(null==e?void 0:e.initialValues)||{},l=t.unref(null==e?void 0:e.validationSchema);return l&&m(l)&&n(l.cast)?w(l.cast(r)||{}):w(r)}function me(e){var r;const l=ve++;let a=0;const u=t.ref(!1),s=t.ref(!1),c=t.ref(0),v=[],f=t.reactive(pe(e)),p=t.ref([]),y=t.ref({}),g=t.ref({}),b=function(e){let n=null,r=[];return function(...l){const a=t.nextTick((()=>{if(n!==a)return;const t=e(...l);r.forEach((e=>e(t))),r=[],n=null}));return n=a,new Promise((e=>r.push(e)))}}((()=>{g.value=p.value.reduce(((e,n)=>(e[o(t.toValue(n.path))]=n,e)),{})}));function V(e,t){const n=Y(e);if(n){if("string"==typeof e){const t=o(e);y.value[t]&&delete y.value[t]}n.errors=$(t),n.valid=!n.errors.length}else"string"==typeof e&&(y.value[o(e)]=$(t))}function j(e){T(e).forEach((t=>{V(t,e[t])}))}(null==e?void 0:e.initialErrors)&&j(e.initialErrors);const A=t.computed((()=>{const e=p.value.reduce(((e,t)=>(t.errors.length&&(e[t.path]=t.errors),e)),{});return Object.assign(Object.assign({},y.value),e)})),S=t.computed((()=>T(A.value).reduce(((e,t)=>{const n=A.value[t];return(null==n?void 0:n.length)&&(e[t]=n[0]),e}),{}))),E=t.computed((()=>p.value.reduce(((e,t)=>(e[t.path]={name:t.path||"",label:t.label||""},e)),{}))),k=t.computed((()=>p.value.reduce(((e,t)=>{var n;return e[t.path]=null===(n=t.bails)||void 0===n||n,e}),{}))),C=Object.assign({},(null==e?void 0:e.initialErrors)||{}),P=null!==(r=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==r&&r,{initialValues:U,originalInitialValues:R,setInitialValues:N}=function(e,n,r){const l=pe(r),a=null==r?void 0:r.initialValues,u=t.ref(l),o=t.ref(w(l));function s(t,r=!1){u.value=i(w(u.value)||{},w(t)),o.value=i(w(o.value)||{},w(t)),r&&e.value.forEach((e=>{if(e.touched)return;const t=I(u.value,e.path);M(n,e.path,w(t))}))}t.isRef(a)&&t.watch(a,(e=>{e&&s(e,!0)}),{deep:!0});return{initialValues:u,originalInitialValues:o,setInitialValues:s}}(p,f,e),D=function(e,n,r,l){const a={touched:"some",pending:"some",valid:"every"},u=t.computed((()=>!F(n,t.unref(r))));function i(){const t=e.value;return T(a).reduce(((e,n)=>{const r=a[n];return e[n]=t[r]((e=>e[n])),e}),{})}const o=t.reactive(i());return t.watchEffect((()=>{const e=i();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&&!T(l.value).length,dirty:u.value})))}(p,f,R,S),q=t.computed((()=>p.value.reduce(((e,t)=>{const n=I(f,t.path);return M(e,t.path,n),e}),{}))),L=null==e?void 0:e.validationSchema;function K(e,n){var r,l;const u=t.computed((()=>I(U.value,t.toValue(e)))),i=g.value[t.toValue(e)];if(i){"checkbox"!==(null==n?void 0:n.type)&&"radio"!==(null==n?void 0:n.type)||(i.multiple=!0);const e=a++;return Array.isArray(i.id)?i.id.push(e):i.id=[i.id,e],i.fieldsCount++,i.__flags.pendingUnmount[e]=!1,i}const o=t.computed((()=>I(f,t.toValue(e)))),s=t.toValue(e),d=a++,c=t.reactive({id:d,path:e,touched:!1,pending:!1,valid:!0,validated:!!(null===(r=C[s])||void 0===r?void 0:r.length),initialValue:u,errors:t.shallowRef([]),bails:null!==(l=null==n?void 0:n.bails)&&void 0!==l&&l,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(u))))});return p.value.push(c),g.value[s]=c,b(),S.value[s]&&!C[s]&&t.nextTick((()=>{ye(s,{mode:"silent"})})),t.isRef(e)&&t.watch(e,(e=>{b();const n=w(o.value);g.value[e]=c,t.nextTick((()=>{M(f,e,n)}))})),c}const G=_(Ve,5),X=_(Ve,5),H=x((async e=>"silent"===await e?G():X()),((e,[t])=>{const n=T(ae.errorBag.value);return[...new Set([...T(e.results),...p.value.map((e=>e.path)),...n])].sort().reduce(((n,r)=>{const l=r,a=Y(l)||function(e){const t=p.value.filter((t=>e.startsWith(t.path)));return t.reduce(((e,t)=>e?t.path.length>e.path.length?t:e:t),void 0)}(l),u=(e.results[l]||{errors:[]}).errors,i={errors:u,valid:!u.length};return n.results[l]=i,i.valid||(n.errors[l]=i.errors[0]),a&&y.value[l]&&delete y.value[l],a?(a.valid=i.valid,"silent"===t?n:"validated-only"!==t||a.validated?(V(a,i.errors),n):n):(V(l,u),n)}),{valid:e.valid,results:{},errors:{}})}));function J(e){p.value.forEach(e)}function Y(e){const t="string"==typeof e?o(e):e;return"string"==typeof t?g.value[t]:t}let Z,te=[];function ne(e){return function(t,n){return function(r){return r instanceof Event&&(r.preventDefault(),r.stopPropagation()),J((e=>e.touched=!0)),u.value=!0,c.value++,he().then((l=>{const a=w(f);if(l.valid&&"function"==typeof t){const n=w(q.value);let u=e?n:a;return l.values&&(u=l.values),t(u,{evt:r,controlledValues:n,setErrors:j,setFieldError:V,setTouched:de,setFieldTouched:se,setValues:ie,setFieldValue:ue,resetForm:me,resetField:ce})}l.valid||"function"!=typeof n||n({values:a,evt:r,errors:l.errors,results:l.results})})).then((e=>(u.value=!1,e)),(e=>{throw u.value=!1,e}))}}}const le=ne(!1);le.withControlled=ne(!0);const ae={formId:l,values:f,controlledValues:q,errorBag:A,errors:S,schema:L,submitCount:c,meta:D,isSubmitting:u,isValidating:s,fieldArrays:v,keepValuesOnUnmount:P,validateSchema:t.unref(L)?H:void 0,validate:he,setFieldError:V,validateField:ye,setFieldValue:ue,setValues:ie,setErrors:j,setFieldTouched:se,setTouched:de,resetForm:me,resetField:ce,handleSubmit:le,stageInitialValue:function(t,n,r=!1){be(t,n),M(f,t,n),r&&!(null==e?void 0:e.initialValues)&&M(R.value,t,w(n))},unsetInitialValue:ge,setFieldInitialValue:be,useFieldModel:function(e){if(!Array.isArray(e))return oe(e);return e.map(oe)},createPathState:K,getPathState:Y,unsetPathValue:function(e){return te.push(e),Z||(Z=t.nextTick((()=>{[...te].sort().reverse().forEach((e=>{B(f,e)})),te=[],Z=null}))),Z},removePathState:function(e,n){const r=p.value.findIndex((t=>t.path===e)),l=p.value[r];if(-1!==r&&l){if(t.nextTick((()=>{ye(e,{mode:"silent",warn:!1})})),l.multiple&&l.fieldsCount&&l.fieldsCount--,Array.isArray(l.id)){const e=l.id.indexOf(n);e>=0&&l.id.splice(e,1),delete l.__flags.pendingUnmount[n]}(!l.multiple||l.fieldsCount<=0)&&(p.value.splice(r,1),ge(e),b(),delete g.value[e])}},initialValues:U,getAllPathStates:()=>p.value,markForUnmount:function(e){return J((t=>{t.path.startsWith(e)&&T(t.__flags.pendingUnmount).forEach((e=>{t.__flags.pendingUnmount[e]=!0}))}))},isFieldTouched:function(e){var t;return!!(null===(t=Y(e))||void 0===t?void 0:t.touched)},isFieldDirty:function(e){var t;return!!(null===(t=Y(e))||void 0===t?void 0:t.dirty)},isFieldValid:function(e){var t;return!!(null===(t=Y(e))||void 0===t?void 0:t.valid)}};function ue(e,t,n=!0){const r=w(t),l="string"==typeof e?e:e.path;Y(l)||K(l),M(f,l,r),n&&ye(l)}function ie(e,t=!0){i(f,e),v.forEach((e=>e&&e.reset())),t&&he()}function oe(e){const n=Y(t.unref(e))||K(e);return t.computed({get:()=>n.value,set(r){const l=t.unref(e);ue(l,r,!1),n.validated=!0,n.pending=!0,ye(l).then((()=>{n.pending=!1}))}})}function se(e,t){const n=Y(e);n&&(n.touched=t)}function de(e){"boolean"!=typeof e?T(e).forEach((t=>{se(t,!!e[t])})):J((t=>{t.touched=e}))}function ce(e,t){var n;const r=t&&"value"in t?t.value:I(U.value,e);be(e,w(r)),ue(e,r,!1),se(e,null!==(n=null==t?void 0:t.touched)&&void 0!==n&&n),V(e,(null==t?void 0:t.errors)||[])}function me(e){let r=(null==e?void 0:e.values)?e.values:R.value;r=m(L)&&n(L.cast)?L.cast(r):r,N(r),J((t=>{var n;t.validated=!1,t.touched=(null===(n=null==e?void 0:e.touched)||void 0===n?void 0:n[t.path])||!1,ue(t.path,I(r,t.path),!1),V(t.path,void 0)})),ie(r,!1),j((null==e?void 0:e.errors)||{}),c.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{he({mode:"silent"})}))}async function he(e){const t=(null==e?void 0:e.mode)||"force";if("force"===t&&J((e=>e.validated=!0)),ae.validateSchema)return ae.validateSchema(t);s.value=!0;const n=await Promise.all(p.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={},l={};for(const e of n)r[e.key]={valid:e.valid,errors:e.errors},e.errors.length&&(l[e.key]=e.errors[0]);return{valid:n.every((e=>e.valid)),results:r,errors:l}}async function ye(e,t){const n=Y(e);if(n&&(n.validated=!0),L){const{results:n}=await H((null==t?void 0:t.mode)||"validated-only");return n[e]||{errors:[],valid:!0}}return(null==n?void 0:n.validate)?n.validate(t):(!n&&(null==t?void 0:t.warn),Promise.resolve({errors:[],valid:!0}))}function ge(e){B(U.value,e)}function be(e,t){M(U.value,e,w(t))}async function Ve(){const e=t.unref(L);if(!e)return{valid:!0,results:{},errors:{}};s.value=!0;const n=h(e)||m(e)?await async function(e,t){const n=m(e)?e:ee(e),r=await n.parse(t),l={},a={};for(const e of r.errors){const t=e.errors,n=(e.path||"").replace(/\["(\d+)"\]/g,((e,t)=>`[${t}]`));l[n]={valid:!t.length,errors:t},t.length&&(a[n]=t[0])}return{valid:!r.errors.length,results:l,errors:a,values:r.value}}(e,f):await re(e,f,{names:E.value,bailsMap:k.value});return s.value=!1,n}const Oe=le(((e,{evt:t})=>{O(t)&&t.target.submit()}));return t.onMounted((()=>{(null==e?void 0:e.initialErrors)&&j(e.initialErrors),(null==e?void 0:e.initialTouched)&&de(e.initialTouched),(null==e?void 0:e.validateOnMount)?he():ae.validateSchema&&ae.validateSchema("silent")})),t.isRef(L)&&t.watch(L,(()=>{var e;null===(e=ae.validateSchema)||void 0===e||e.call(ae,"validated-only")})),t.provide(d,ae),Object.assign(Object.assign({},ae),{values:t.readonly(f),handleReset:()=>me(),submitForm:Oe,defineComponentBinds:function(e,r){const l=Y(t.toValue(e))||K(e),a=()=>n(r)?r(z(l,fe)):r||{};function u(){var e;l.touched=!0;(null!==(e=a().validateOnBlur)&&void 0!==e?e:Q().validateOnBlur)&&ye(l.path)}function i(e){var t;const n=null!==(t=a().validateOnModelUpdate)&&void 0!==t?t:Q().validateOnModelUpdate;ue(l.path,e,n)}return t.computed((()=>{if(n(r)){const e=r(l),t=e.model||"modelValue";return Object.assign({onBlur:u,[t]:l.value,[`onUpdate:${t}`]:i},e.props||{})}const e=(null==r?void 0:r.model)||"modelValue",t={onBlur:u,[e]:l.value,[`onUpdate:${e}`]:i};return(null==r?void 0:r.mapProps)?Object.assign(Object.assign({},t),r.mapProps(z(l,fe))):t}))},defineInputBinds:function(e,r){const l=Y(t.toValue(e))||K(e),a=()=>n(r)?r(z(l,fe)):r||{};function u(){var e;l.touched=!0;(null!==(e=a().validateOnBlur)&&void 0!==e?e:Q().validateOnBlur)&&ye(l.path)}function i(e){var t;const n=W(e),r=null!==(t=a().validateOnInput)&&void 0!==t?t:Q().validateOnInput;ue(l.path,n,r)}function o(e){var t;const n=W(e),r=null!==(t=a().validateOnChange)&&void 0!==t?t:Q().validateOnChange;ue(l.path,n,r)}return t.computed((()=>{const e={value:l.value,onChange:o,onInput:i,onBlur:u};return n(r)?Object.assign(Object.assign({},e),r(z(l,fe)).attrs||{}):(null==r?void 0:r.mapAttrs)?Object.assign(Object.assign({},e),r.mapAttrs(z(l,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"),l=t.toRef(e,"validationSchema"),a=t.toRef(e,"keepValues"),{errors:u,errorBag:i,values:o,meta:s,isSubmitting:d,isValidating:c,submitCount:v,controlledValues:f,validate:p,validateField:m,handleReset:h,resetForm:y,handleSubmit:g,setErrors:b,setFieldError:V,setFieldValue:A,setValues:F,setFieldTouched:S,setTouched:E,resetField:k}=me({validationSchema:l.value?l:void 0,initialValues:r,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:a}),I=g(((e,{evt:t})=>{O(t)&&t.target.submit()}),e.onInvalidSubmit),M=e.onSubmit?g(e.onSubmit,e.onInvalidSubmit):I;function C(e){j(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 T(){return w(o)}function P(){return w(s.value)}function U(){return w(u.value)}function _(){return{meta:s.value,errors:u.value,errorBag:i.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:b,setFieldError:V,setFieldValue:A,setValues:F,setFieldTouched:S,setTouched:E,resetForm:y,resetField:k,getValues:T,getMeta:P,getErrors:U}}return n.expose({setFieldError:V,setErrors:b,setFieldValue:A,setValues:F,setFieldTouched:S,setTouched:E,resetForm:y,validate:p,validateField:m,resetField:k,getValues:T,getMeta:P,getErrors:U}),function(){const r="form"===e.as?e.as:t.resolveDynamicComponent(e.as),l=q(r,n,_);if(!e.as)return l;const a="form"===e.as?{novalidate:!0}:{};return t.h(r,Object.assign(Object.assign(Object.assign({},a),n.attrs),{onSubmit:M,onReset:C}),l)}}}),ye=he;function ge(e){const n=P(d,void 0),l=t.ref([]),a=()=>{},u={fields:l,remove:a,push:a,swap:a,insert:a,update:a,replace:a,prepend:a,move:a};if(!n)return u;if(!t.unref(e))return u;const i=n.fieldArrays.find((n=>t.unref(n.path)===t.unref(e)));if(i)return i;let o=0;function s(){return I(null==n?void 0:n.values,t.unref(e),[])||[]}function c(){const e=s();Array.isArray(e)&&(l.value=e.map(((e,t)=>f(e,t,l.value))),v())}function v(){const e=l.value.length;for(let t=0;t<e;t++){const n=l.value[t];n.isFirst=0===t,n.isLast=t===e-1}}function f(a,u,i){if(i&&!r(u)&&i[u])return i[u];const s=o++,d={key:s,value:N({get(){const r=I(null==n?void 0:n.values,t.unref(e),[])||[],u=l.value.findIndex((e=>e.key===s));return-1===u?a:r[u]},set(e){const t=l.value.findIndex((e=>e.key===s));-1!==t&&m(t,e)}}),isFirst:!1,isLast:!1};return d}function p(){v(),null==n||n.validate({mode:"silent"})}function m(r,l){const a=t.unref(e),u=I(null==n?void 0:n.values,a);!Array.isArray(u)||u.length-1<r||(M(n.values,`${a}[${r}]`,l),null==n||n.validate({mode:"validated-only"}))}c();const h={fields:l,remove:function(r){const a=t.unref(e),u=I(null==n?void 0:n.values,a);if(!u||!Array.isArray(u))return;const i=[...u];i.splice(r,1);const o=a+`[${r}]`;n.markForUnmount(o),n.unsetInitialValue(o),M(n.values,a,i),l.value.splice(r,1),p()},push:function(a){const u=w(a),i=t.unref(e),o=I(null==n?void 0:n.values,i),s=r(o)?[]:o;if(!Array.isArray(s))return;const d=[...s];d.push(u),n.stageInitialValue(i+`[${d.length-1}]`,u),M(n.values,i,d),l.value.push(f(u)),p()},swap:function(r,a){const u=t.unref(e),i=I(null==n?void 0:n.values,u);if(!Array.isArray(i)||!(r in i)||!(a in i))return;const o=[...i],s=[...l.value],d=o[r];o[r]=o[a],o[a]=d;const c=s[r];s[r]=s[a],s[a]=c,M(n.values,u,o),l.value=s,v()},insert:function(r,a){const u=w(a),i=t.unref(e),o=I(null==n?void 0:n.values,i);if(!Array.isArray(o)||o.length<r)return;const s=[...o],d=[...l.value];s.splice(r,0,u),d.splice(r,0,f(u)),M(n.values,i,s),l.value=d,p()},update:m,replace:function(r){const l=t.unref(e);n.stageInitialValue(l,r),M(n.values,l,r),c(),p()},prepend:function(a){const u=w(a),i=t.unref(e),o=I(null==n?void 0:n.values,i),s=r(o)?[]:o;if(!Array.isArray(s))return;const d=[u,...s];n.stageInitialValue(i+`[${d.length-1}]`,u),M(n.values,i,d),l.value.unshift(f(u)),p()},move:function(a,u){const i=t.unref(e),o=I(null==n?void 0:n.values,i),s=r(o)?[]:[...o];if(!Array.isArray(o)||!(a in o)||!(u in o))return;const d=[...l.value],c=d[a];d.splice(a,1),d.splice(u,0,c);const v=s[a];s.splice(a,1),s.splice(u,0,v),M(n.values,i,s),l.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(s,(e=>{F(e,l.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:l,swap:a,insert:u,replace:i,update:o,prepend:s,move:d,fields:c}=ge(t.toRef(e,"name"));function v(){return{fields:c.value,push:r,remove:l,swap:a,insert:u,update:o,replace:i,prepend:s,move:d}}return n.expose({push:r,remove:l,swap:a,insert:u,update:o,replace:i,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(d,void 0),l=t.computed((()=>null==r?void 0:r.errors.value[e.name]));function a(){return{message:l.value}}return()=>{if(!l.value)return;const r=e.as?t.resolveDynamicComponent(e.as):e.as,u=q(r,n,a),i=Object.assign({role:"alert"},n.attrs);return r||!Array.isArray(u)&&u||!(null==u?void 0:u.length)?!Array.isArray(u)&&u||(null==u?void 0:u.length)?t.h(r,i,u):t.h(r||"span",i,l.value):u}}});e.ErrorMessage=Ve,e.Field=ce,e.FieldArray=be,e.FieldContextKey=c,e.Form=ye,e.FormContextKey=d,e.IS_ABSENT=v,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),s[e]=t},e.normalizeRules=G,e.useField=ue,e.useFieldArray=ge,e.useFieldError=function(e){const n=P(d),r=e?void 0:t.inject(c);return t.computed((()=>e?null==n?void 0:n.errors.value[t.toValue(e)]:null==r?void 0:r.errorMessage.value))},e.useFieldValue=function(e){const n=P(d),r=e?void 0:t.inject(c);return t.computed((()=>e?I(null==n?void 0:n.values,t.toValue(e)):t.toValue(null==r?void 0:r.value)))},e.useForm=me,e.useFormErrors=function(){const e=P(d);return t.computed((()=>(null==e?void 0:e.errors.value)||{}))},e.useFormValues=function(){const e=P(d);return 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=P(d);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.dirty)&&void 0!==t&&t}))},e.useIsFormTouched=function(){const e=P(d);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.touched)&&void 0!==t&&t}))},e.useIsFormValid=function(){const e=P(d);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.valid)&&void 0!==t&&t}))},e.useIsSubmitting=function(){const e=P(d);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isSubmitting.value)&&void 0!==t&&t}))},e.useIsValidating=function(){const e=P(d);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isValidating.value)&&void 0!==t&&t}))},e.useResetForm=function(){const e=P(d);return function(t){if(e)return e.resetForm(t)}},e.useSetFieldError=function(e){const n=P(d),r=e?void 0:t.inject(c);return function(l){e&&n?n.setFieldError(t.toValue(e),l):r&&r.setErrors(l||[])}},e.useSetFieldTouched=function(e){const n=P(d),r=e?void 0:t.inject(c);return function(l){e&&n?n.setFieldTouched(t.toValue(e),l):r&&r.setTouched(l)}},e.useSetFieldValue=function(e){const n=P(d),r=e?void 0:t.inject(c);return function(l,a=!0){e&&n?n.setFieldValue(t.toValue(e),l,a):r&&r.setValue(l,a)}},e.useSetFormErrors=function(){const e=P(d);return function(t){e&&e.setErrors(t)}},e.useSetFormTouched=function(){const e=P(d);return function(t){e&&e.setTouched(t)}},e.useSetFormValues=function(){const e=P(d);return function(t){e&&e.setValues(t)}},e.useSubmitCount=function(){const e=P(d);return 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=P(d),n=t?t.handleSubmit(e):void 0;return function(e){if(n)return n(e)}},e.useValidateField=function(e){const n=P(d),r=e?void 0:t.inject(c);return function(){return r?r.validate():n&&e?null==n?void 0:n.validateField(t.toValue(e)):Promise.resolve({errors:[],valid:!0})}},e.useValidateForm=function(){const e=P(d);return 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.11.0",
3
+ "version": "4.11.2",
4
4
  "description": "Form Validation for Vue.js",
5
5
  "author": "Abdelrahman Awad <logaretm1@gmail.com>",
6
6
  "license": "MIT",
@@ -32,6 +32,6 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@vue/devtools-api": "^6.5.0",
35
- "type-fest": "^4.0.0"
35
+ "type-fest": "^4.2.0"
36
36
  }
37
37
  }