vee-validate 4.11.1 → 4.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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)
@@ -168,10 +168,15 @@ interface TypedSchema<TInput = any, TOutput = TInput> {
168
168
  }>;
169
169
  cast?(values: Partial<TInput>): TInput;
170
170
  }
171
+ type InferOutput<TSchema extends TypedSchema> = TSchema extends TypedSchema<any, infer TOutput> ? TOutput : never;
172
+ type InferInput<TSchema extends TypedSchema> = TSchema extends TypedSchema<infer TInput, any> ? TInput : never;
171
173
  type YupSchema<TValues = any> = {
172
174
  __isYupSchema__: boolean;
173
175
  validate(value: any, options: GenericObject): Promise<any>;
174
176
  };
177
+ type Locator = {
178
+ __locatorRef: string;
179
+ } & ((values: GenericObject) => unknown);
175
180
  interface FieldMeta<TValue> {
176
181
  touched: boolean;
177
182
  dirty: boolean;
@@ -207,7 +212,7 @@ interface ValidationOptions$1 {
207
212
  type FieldValidator = (opts?: Partial<ValidationOptions$1>) => Promise<ValidationResult>;
208
213
  interface PathStateConfig {
209
214
  bails: boolean;
210
- label: MaybeRef<string | undefined>;
215
+ label: MaybeRefOrGetter<string | undefined>;
211
216
  type: InputType;
212
217
  validate: FieldValidator;
213
218
  }
@@ -260,12 +265,12 @@ interface PrivateFieldContext<TValue = unknown> {
260
265
  meta: FieldMeta<TValue>;
261
266
  errors: Ref<string[]>;
262
267
  errorMessage: Ref<string | undefined>;
263
- label?: MaybeRef<string | undefined>;
268
+ label?: MaybeRefOrGetter<string | undefined>;
264
269
  type?: string;
265
270
  bails?: boolean;
266
- keepValueOnUnmount?: MaybeRef<boolean | undefined>;
267
- checkedValue?: MaybeRef<TValue>;
268
- uncheckedValue?: MaybeRef<TValue>;
271
+ keepValueOnUnmount?: MaybeRefOrGetter<boolean | undefined>;
272
+ checkedValue?: MaybeRefOrGetter<TValue>;
273
+ uncheckedValue?: MaybeRefOrGetter<TValue>;
269
274
  checked?: Ref<boolean>;
270
275
  resetField(state?: Partial<FieldState<TValue>>): void;
271
276
  handleReset(): void;
@@ -316,6 +321,7 @@ interface InvalidSubmissionContext<TValues extends GenericObject = GenericObject
316
321
  }
317
322
  type InvalidSubmissionHandler<TValues extends GenericObject = GenericObject> = (ctx: InvalidSubmissionContext<TValues>) => void;
318
323
  type RawFormSchema<TValues> = Record<Path<TValues>, string | GenericValidateFunction | GenericObject>;
324
+ type FieldPathLookup<TValues extends GenericObject = GenericObject> = Partial<Record<Path<TValues>, PrivateFieldContext | PrivateFieldContext[]>>;
319
325
  type HandleSubmitFactory<TValues extends GenericObject, TOutput = TValues> = <TReturn = unknown>(cb: SubmissionHandler<TValues, TOutput, TReturn>, onSubmitValidationErrorCb?: InvalidSubmissionHandler<TValues>) => (e?: Event) => Promise<TReturn | undefined>;
320
326
  interface PrivateFormContext<TValues extends GenericObject = GenericObject, TOutput = TValues> extends FormActions<TValues> {
321
327
  formId: number;
@@ -348,6 +354,9 @@ interface PrivateFormContext<TValues extends GenericObject = GenericObject, TOut
348
354
  removePathState<TPath extends Path<TValues>>(path: TPath, id: number): void;
349
355
  unsetPathValue<TPath extends Path<TValues>>(path: TPath): void;
350
356
  markForUnmount(path: string): void;
357
+ isFieldTouched<TPath extends Path<TValues>>(path: TPath): boolean;
358
+ isFieldDirty<TPath extends Path<TValues>>(path: TPath): boolean;
359
+ isFieldValid<TPath extends Path<TValues>>(path: TPath): boolean;
351
360
  }
352
361
  interface BaseComponentBinds<TValue = unknown, TModel = 'modelValue'> {
353
362
  onBlur: () => void;
@@ -391,6 +400,22 @@ interface FormContext<TValues extends GenericObject = GenericObject, TOutput = T
391
400
  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
401
  }
393
402
 
403
+ interface DevtoolsPluginFieldState {
404
+ name: string;
405
+ value: any;
406
+ initialValue: any;
407
+ errors: string[];
408
+ meta: FieldMeta<any>;
409
+ }
410
+ interface DevtoolsPluginFormState {
411
+ meta: FormMeta<Record<string, any>>;
412
+ errors: FormErrors<Record<string, any>>;
413
+ values: Record<string, any>;
414
+ isSubmitting: boolean;
415
+ isValidating: boolean;
416
+ submitCount: number;
417
+ }
418
+
394
419
  interface ValidationOptions {
395
420
  name?: string;
396
421
  label?: string;
@@ -438,16 +463,16 @@ interface FieldOptions<TValue = unknown> {
438
463
  /**
439
464
  * @deprecated Use `checkedValue` instead.
440
465
  */
441
- valueProp?: MaybeRef<TValue>;
442
- checkedValue?: MaybeRef<TValue>;
443
- uncheckedValue?: MaybeRef<TValue>;
444
- label?: MaybeRef<string | undefined>;
466
+ valueProp?: MaybeRefOrGetter<TValue>;
467
+ checkedValue?: MaybeRefOrGetter<TValue>;
468
+ uncheckedValue?: MaybeRefOrGetter<TValue>;
469
+ label?: MaybeRefOrGetter<string | undefined>;
445
470
  controlled?: boolean;
446
471
  /**
447
472
  * @deprecated Use `controlled` instead, controlled is opposite of standalone.
448
473
  */
449
474
  standalone?: boolean;
450
- keepValueOnUnmount?: MaybeRef<boolean | undefined>;
475
+ keepValueOnUnmount?: MaybeRefOrGetter<boolean | undefined>;
451
476
  /**
452
477
  * @deprecated Pass the model prop name to `syncVModel` instead.
453
478
  */
@@ -1432,17 +1457,17 @@ declare function useResetForm<TValues extends Record<string, unknown> = Record<s
1432
1457
  /**
1433
1458
  * If a field is dirty or not
1434
1459
  */
1435
- declare function useIsFieldDirty(path?: MaybeRef<string>): vue.ComputedRef<boolean>;
1460
+ declare function useIsFieldDirty(path?: MaybeRefOrGetter<string>): vue.ComputedRef<boolean>;
1436
1461
 
1437
1462
  /**
1438
1463
  * If a field is touched or not
1439
1464
  */
1440
- declare function useIsFieldTouched(path?: MaybeRef<string>): vue.ComputedRef<boolean>;
1465
+ declare function useIsFieldTouched(path?: MaybeRefOrGetter<string>): vue.ComputedRef<boolean>;
1441
1466
 
1442
1467
  /**
1443
1468
  * If a field is validated and is valid
1444
1469
  */
1445
- declare function useIsFieldValid(path?: MaybeRef<string>): vue.ComputedRef<boolean>;
1470
+ declare function useIsFieldValid(path?: MaybeRefOrGetter<string>): vue.ComputedRef<boolean>;
1446
1471
 
1447
1472
  /**
1448
1473
  * If the form is submitting or not
@@ -1457,7 +1482,7 @@ declare function useIsValidating(): vue.ComputedRef<boolean>;
1457
1482
  /**
1458
1483
  * Validates a single field
1459
1484
  */
1460
- declare function useValidateField(path?: MaybeRef<string>): () => Promise<ValidationResult>;
1485
+ declare function useValidateField(path?: MaybeRefOrGetter<string>): () => Promise<ValidationResult>;
1461
1486
 
1462
1487
  /**
1463
1488
  * If the form is dirty or not
@@ -1487,7 +1512,7 @@ declare function useSubmitCount(): vue.ComputedRef<number>;
1487
1512
  /**
1488
1513
  * Gives access to a field's current value
1489
1514
  */
1490
- declare function useFieldValue<TValue = unknown>(path?: MaybeRef<string>): vue.ComputedRef<TValue>;
1515
+ declare function useFieldValue<TValue = unknown>(path?: MaybeRefOrGetter<string>): vue.ComputedRef<TValue>;
1491
1516
 
1492
1517
  /**
1493
1518
  * Gives access to a form's values
@@ -1502,7 +1527,7 @@ declare function useFormErrors<TValues extends Record<string, unknown> = Record<
1502
1527
  /**
1503
1528
  * Gives access to a single field error
1504
1529
  */
1505
- declare function useFieldError(path?: MaybeRef<string>): vue.ComputedRef<string>;
1530
+ declare function useFieldError(path?: MaybeRefOrGetter<string>): vue.ComputedRef<string>;
1506
1531
 
1507
1532
  declare function useSubmitForm<TValues extends Record<string, unknown> = Record<string, unknown>>(cb: SubmissionHandler<TValues>): (e?: Event) => Promise<unknown>;
1508
1533
 
@@ -1540,4 +1565,4 @@ declare const FormContextKey: InjectionKey<PrivateFormContext>;
1540
1565
  declare const FieldContextKey: InjectionKey<PrivateFieldContext<unknown>>;
1541
1566
  declare const IS_ABSENT: unique symbol;
1542
1567
 
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 };
1568
+ 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 InferInput, type InferOutput, 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.1
2
+ * vee-validate v4.11.3
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
  }
@@ -1568,7 +1570,7 @@ function _useField(path, rules, opts) {
1568
1570
  const form = controlForm || injectedForm;
1569
1571
  const name = computed(() => normalizeFormPath(toValue(path)));
1570
1572
  const validator = computed(() => {
1571
- 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);
1572
1574
  if (schema) {
1573
1575
  return undefined;
1574
1576
  }
@@ -1605,12 +1607,12 @@ function _useField(path, rules, opts) {
1605
1607
  async function validateCurrentValue(mode) {
1606
1608
  var _a, _b;
1607
1609
  if (form === null || form === void 0 ? void 0 : form.validateSchema) {
1608
- 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: [] };
1609
1611
  }
1610
1612
  if (validator.value) {
1611
1613
  return validate(value.value, validator.value, {
1612
- name: unref(name),
1613
- label: unref(label),
1614
+ name: toValue(name),
1615
+ label: toValue(label),
1614
1616
  values: (_b = form === null || form === void 0 ? void 0 : form.values) !== null && _b !== void 0 ? _b : {},
1615
1617
  bails,
1616
1618
  });
@@ -1787,7 +1789,7 @@ function _useField(path, rules, opts) {
1787
1789
  });
1788
1790
  onBeforeUnmount(() => {
1789
1791
  var _a;
1790
- 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);
1791
1793
  const path = toValue(name);
1792
1794
  if (shouldKeepValue || !form || flags.pendingUnmount[field.id]) {
1793
1795
  form === null || form === void 0 ? void 0 : form.removePathState(path, id);
@@ -1802,7 +1804,7 @@ function _useField(path, rules, opts) {
1802
1804
  return;
1803
1805
  }
1804
1806
  if ((pathState === null || pathState === void 0 ? void 0 : pathState.multiple) && Array.isArray(pathState.value)) {
1805
- const valueIdx = pathState.value.findIndex(i => isEqual(i, unref(field.checkedValue)));
1807
+ const valueIdx = pathState.value.findIndex(i => isEqual(i, toValue(field.checkedValue)));
1806
1808
  if (valueIdx > -1) {
1807
1809
  const newVal = [...pathState.value];
1808
1810
  newVal.splice(valueIdx, 1);
@@ -1855,8 +1857,8 @@ function useFieldWithChecked(name, rules, opts) {
1855
1857
  function patchCheckedApi(field) {
1856
1858
  const handleChange = field.handleChange;
1857
1859
  const checked = computed(() => {
1858
- const currentValue = unref(field.value);
1859
- const checkedVal = unref(checkedValue);
1860
+ const currentValue = toValue(field.value);
1861
+ const checkedVal = toValue(checkedValue);
1860
1862
  return Array.isArray(currentValue)
1861
1863
  ? currentValue.findIndex(v => isEqual(v, checkedVal)) >= 0
1862
1864
  : isEqual(checkedVal, currentValue);
@@ -1872,12 +1874,12 @@ function useFieldWithChecked(name, rules, opts) {
1872
1874
  const path = toValue(name);
1873
1875
  const pathState = form === null || form === void 0 ? void 0 : form.getPathState(path);
1874
1876
  const value = normalizeEventValue(e);
1875
- let newValue = (_b = unref(checkedValue)) !== null && _b !== void 0 ? _b : value;
1877
+ let newValue = (_b = toValue(checkedValue)) !== null && _b !== void 0 ? _b : value;
1876
1878
  if (form && (pathState === null || pathState === void 0 ? void 0 : pathState.multiple) && pathState.type === 'checkbox') {
1877
1879
  newValue = resolveNextCheckboxValue(getFromPath(form.values, path) || [], newValue, undefined);
1878
1880
  }
1879
1881
  else if ((opts === null || opts === void 0 ? void 0 : opts.type) === 'checkbox') {
1880
- newValue = resolveNextCheckboxValue(unref(field.value), newValue, unref(uncheckedValue));
1882
+ newValue = resolveNextCheckboxValue(toValue(field.value), newValue, toValue(uncheckedValue));
1881
1883
  }
1882
1884
  handleChange(newValue, shouldValidate);
1883
1885
  }
@@ -2519,6 +2521,9 @@ function useForm(opts) {
2519
2521
  initialValues: initialValues,
2520
2522
  getAllPathStates: () => pathStates.value,
2521
2523
  markForUnmount,
2524
+ isFieldTouched,
2525
+ isFieldDirty,
2526
+ isFieldValid,
2522
2527
  };
2523
2528
  /**
2524
2529
  * Sets a single field value
@@ -2578,6 +2583,18 @@ function useForm(opts) {
2578
2583
  pathState.touched = isTouched;
2579
2584
  }
2580
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
+ }
2581
2598
  /**
2582
2599
  * Sets the touched meta state on multiple fields
2583
2600
  */
@@ -2680,7 +2697,9 @@ function useForm(opts) {
2680
2697
  }
2681
2698
  const shouldWarn = !state && ((_a = opts === null || opts === void 0 ? void 0 : opts.warn) !== null && _a !== void 0 ? _a : true);
2682
2699
  if (shouldWarn) {
2683
- 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
+ }
2684
2703
  }
2685
2704
  return Promise.resolve({ errors: [], valid: true });
2686
2705
  }
@@ -3075,11 +3094,15 @@ function useFieldArray(arrayPath) {
3075
3094
  move: noOp,
3076
3095
  };
3077
3096
  if (!form) {
3078
- 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
+ }
3079
3100
  return noOpApi;
3080
3101
  }
3081
3102
  if (!unref(arrayPath)) {
3082
- 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
+ }
3083
3106
  return noOpApi;
3084
3107
  }
3085
3108
  const alreadyExists = form.fieldArrays.find(a => unref(a.path) === unref(arrayPath));
@@ -3126,7 +3149,9 @@ function useFieldArray(arrayPath) {
3126
3149
  set(value) {
3127
3150
  const idx = fields.value.findIndex(e => e.key === key);
3128
3151
  if (idx === -1) {
3129
- 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
+ }
3130
3155
  return;
3131
3156
  }
3132
3157
  update(idx, value);
@@ -3375,7 +3400,9 @@ const ErrorMessage = ErrorMessageImpl;
3375
3400
  function useResetForm() {
3376
3401
  const form = injectWithSelf(FormContextKey);
3377
3402
  if (!form) {
3378
- 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
+ }
3379
3406
  }
3380
3407
  return function resetForm(state) {
3381
3408
  if (!form) {
@@ -3433,7 +3460,9 @@ function useIsFieldValid(path) {
3433
3460
  function useIsSubmitting() {
3434
3461
  const form = injectWithSelf(FormContextKey);
3435
3462
  if (!form) {
3436
- 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
+ }
3437
3466
  }
3438
3467
  return computed(() => {
3439
3468
  var _a;
@@ -3447,7 +3476,9 @@ function useIsSubmitting() {
3447
3476
  function useIsValidating() {
3448
3477
  const form = injectWithSelf(FormContextKey);
3449
3478
  if (!form) {
3450
- 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
+ }
3451
3482
  }
3452
3483
  return computed(() => {
3453
3484
  var _a;
@@ -3466,9 +3497,11 @@ function useValidateField(path) {
3466
3497
  return field.validate();
3467
3498
  }
3468
3499
  if (form && path) {
3469
- 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`);
3470
3504
  }
3471
- warn(`field with name ${unref(path)} was not found`);
3472
3505
  return Promise.resolve({
3473
3506
  errors: [],
3474
3507
  valid: true,
@@ -3482,7 +3515,9 @@ function useValidateField(path) {
3482
3515
  function useIsFormDirty() {
3483
3516
  const form = injectWithSelf(FormContextKey);
3484
3517
  if (!form) {
3485
- 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
+ }
3486
3521
  }
3487
3522
  return computed(() => {
3488
3523
  var _a;
@@ -3496,7 +3531,9 @@ function useIsFormDirty() {
3496
3531
  function useIsFormTouched() {
3497
3532
  const form = injectWithSelf(FormContextKey);
3498
3533
  if (!form) {
3499
- 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
+ }
3500
3537
  }
3501
3538
  return computed(() => {
3502
3539
  var _a;
@@ -3510,7 +3547,9 @@ function useIsFormTouched() {
3510
3547
  function useIsFormValid() {
3511
3548
  const form = injectWithSelf(FormContextKey);
3512
3549
  if (!form) {
3513
- 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
+ }
3514
3553
  }
3515
3554
  return computed(() => {
3516
3555
  var _a;
@@ -3524,7 +3563,9 @@ function useIsFormValid() {
3524
3563
  function useValidateForm() {
3525
3564
  const form = injectWithSelf(FormContextKey);
3526
3565
  if (!form) {
3527
- 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
+ }
3528
3569
  }
3529
3570
  return function validateField() {
3530
3571
  if (!form) {
@@ -3540,7 +3581,9 @@ function useValidateForm() {
3540
3581
  function useSubmitCount() {
3541
3582
  const form = injectWithSelf(FormContextKey);
3542
3583
  if (!form) {
3543
- 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
+ }
3544
3587
  }
3545
3588
  return computed(() => {
3546
3589
  var _a;
@@ -3557,9 +3600,9 @@ function useFieldValue(path) {
3557
3600
  const field = path ? undefined : inject(FieldContextKey);
3558
3601
  return computed(() => {
3559
3602
  if (path) {
3560
- 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));
3561
3604
  }
3562
- return unref(field === null || field === void 0 ? void 0 : field.value);
3605
+ return toValue(field === null || field === void 0 ? void 0 : field.value);
3563
3606
  });
3564
3607
  }
3565
3608
 
@@ -3569,7 +3612,9 @@ function useFieldValue(path) {
3569
3612
  function useFormValues() {
3570
3613
  const form = injectWithSelf(FormContextKey);
3571
3614
  if (!form) {
3572
- 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
+ }
3573
3618
  }
3574
3619
  return computed(() => {
3575
3620
  return (form === null || form === void 0 ? void 0 : form.values) || {};
@@ -3582,7 +3627,9 @@ function useFormValues() {
3582
3627
  function useFormErrors() {
3583
3628
  const form = injectWithSelf(FormContextKey);
3584
3629
  if (!form) {
3585
- 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
+ }
3586
3633
  }
3587
3634
  return computed(() => {
3588
3635
  return ((form === null || form === void 0 ? void 0 : form.errors.value) || {});
@@ -3598,7 +3645,7 @@ function useFieldError(path) {
3598
3645
  const field = path ? undefined : inject(FieldContextKey);
3599
3646
  return computed(() => {
3600
3647
  if (path) {
3601
- 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)];
3602
3649
  }
3603
3650
  return field === null || field === void 0 ? void 0 : field.errorMessage.value;
3604
3651
  });
@@ -3607,7 +3654,9 @@ function useFieldError(path) {
3607
3654
  function useSubmitForm(cb) {
3608
3655
  const form = injectWithSelf(FormContextKey);
3609
3656
  if (!form) {
3610
- 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
+ }
3611
3660
  }
3612
3661
  const onSubmit = form ? form.handleSubmit(cb) : undefined;
3613
3662
  return function submitForm(e) {
@@ -3628,12 +3677,14 @@ function useSetFieldError(path) {
3628
3677
  return function setFieldError(message) {
3629
3678
  if (path && form) {
3630
3679
  form.setFieldError(toValue(path), message);
3680
+ return;
3631
3681
  }
3632
3682
  if (field) {
3633
3683
  field.setErrors(message || []);
3684
+ return;
3634
3685
  }
3635
3686
  if ((process.env.NODE_ENV !== 'production')) {
3636
- 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"?`);
3637
3688
  }
3638
3689
  };
3639
3690
  }
@@ -3648,12 +3699,14 @@ function useSetFieldTouched(path) {
3648
3699
  return function setFieldTouched(touched) {
3649
3700
  if (path && form) {
3650
3701
  form.setFieldTouched(toValue(path), touched);
3702
+ return;
3651
3703
  }
3652
3704
  if (field) {
3653
3705
  field.setTouched(touched);
3706
+ return;
3654
3707
  }
3655
3708
  if ((process.env.NODE_ENV !== 'production')) {
3656
- 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"?`);
3657
3710
  }
3658
3711
  };
3659
3712
  }
@@ -3668,12 +3721,14 @@ function useSetFieldValue(path) {
3668
3721
  return function setFieldValue(value, shouldValidate = true) {
3669
3722
  if (path && form) {
3670
3723
  form.setFieldValue(toValue(path), value, shouldValidate);
3724
+ return;
3671
3725
  }
3672
3726
  if (field) {
3673
3727
  field.setValue(value, shouldValidate);
3728
+ return;
3674
3729
  }
3675
3730
  if ((process.env.NODE_ENV !== 'production')) {
3676
- 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"?`);
3677
3732
  }
3678
3733
  };
3679
3734
  }
@@ -3686,6 +3741,7 @@ function useSetFormErrors() {
3686
3741
  function setFormErrors(fields) {
3687
3742
  if (form) {
3688
3743
  form.setErrors(fields);
3744
+ return;
3689
3745
  }
3690
3746
  if ((process.env.NODE_ENV !== 'production')) {
3691
3747
  warn(`Could not set errors because a form was not detected, did you forget to use "useForm" in a parent component?`);
@@ -3702,6 +3758,7 @@ function useSetFormTouched() {
3702
3758
  function setFormTouched(fields) {
3703
3759
  if (form) {
3704
3760
  form.setTouched(fields);
3761
+ return;
3705
3762
  }
3706
3763
  if ((process.env.NODE_ENV !== 'production')) {
3707
3764
  warn(`Could not set touched state because a form was not detected, did you forget to use "useForm" in a parent component?`);
@@ -3718,6 +3775,7 @@ function useSetFormValues() {
3718
3775
  function setFormValues(fields) {
3719
3776
  if (form) {
3720
3777
  form.setValues(fields);
3778
+ return;
3721
3779
  }
3722
3780
  if ((process.env.NODE_ENV !== 'production')) {
3723
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.1
2
+ * vee-validate v4.11.3
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) {
@@ -1170,7 +1165,7 @@
1170
1165
  const form = controlForm || injectedForm;
1171
1166
  const name = vue.computed(() => normalizeFormPath(vue.toValue(path)));
1172
1167
  const validator = vue.computed(() => {
1173
- 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);
1174
1169
  if (schema) {
1175
1170
  return undefined;
1176
1171
  }
@@ -1207,12 +1202,12 @@
1207
1202
  async function validateCurrentValue(mode) {
1208
1203
  var _a, _b;
1209
1204
  if (form === null || form === void 0 ? void 0 : form.validateSchema) {
1210
- 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: [] };
1211
1206
  }
1212
1207
  if (validator.value) {
1213
1208
  return validate(value.value, validator.value, {
1214
- name: vue.unref(name),
1215
- label: vue.unref(label),
1209
+ name: vue.toValue(name),
1210
+ label: vue.toValue(label),
1216
1211
  values: (_b = form === null || form === void 0 ? void 0 : form.values) !== null && _b !== void 0 ? _b : {},
1217
1212
  bails,
1218
1213
  });
@@ -1370,7 +1365,7 @@
1370
1365
  });
1371
1366
  vue.onBeforeUnmount(() => {
1372
1367
  var _a;
1373
- 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);
1374
1369
  const path = vue.toValue(name);
1375
1370
  if (shouldKeepValue || !form || flags.pendingUnmount[field.id]) {
1376
1371
  form === null || form === void 0 ? void 0 : form.removePathState(path, id);
@@ -1385,7 +1380,7 @@
1385
1380
  return;
1386
1381
  }
1387
1382
  if ((pathState === null || pathState === void 0 ? void 0 : pathState.multiple) && Array.isArray(pathState.value)) {
1388
- 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)));
1389
1384
  if (valueIdx > -1) {
1390
1385
  const newVal = [...pathState.value];
1391
1386
  newVal.splice(valueIdx, 1);
@@ -1438,8 +1433,8 @@
1438
1433
  function patchCheckedApi(field) {
1439
1434
  const handleChange = field.handleChange;
1440
1435
  const checked = vue.computed(() => {
1441
- const currentValue = vue.unref(field.value);
1442
- const checkedVal = vue.unref(checkedValue);
1436
+ const currentValue = vue.toValue(field.value);
1437
+ const checkedVal = vue.toValue(checkedValue);
1443
1438
  return Array.isArray(currentValue)
1444
1439
  ? currentValue.findIndex(v => isEqual(v, checkedVal)) >= 0
1445
1440
  : isEqual(checkedVal, currentValue);
@@ -1455,12 +1450,12 @@
1455
1450
  const path = vue.toValue(name);
1456
1451
  const pathState = form === null || form === void 0 ? void 0 : form.getPathState(path);
1457
1452
  const value = normalizeEventValue(e);
1458
- 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;
1459
1454
  if (form && (pathState === null || pathState === void 0 ? void 0 : pathState.multiple) && pathState.type === 'checkbox') {
1460
1455
  newValue = resolveNextCheckboxValue(getFromPath(form.values, path) || [], newValue, undefined);
1461
1456
  }
1462
1457
  else if ((opts === null || opts === void 0 ? void 0 : opts.type) === 'checkbox') {
1463
- newValue = resolveNextCheckboxValue(vue.unref(field.value), newValue, vue.unref(uncheckedValue));
1458
+ newValue = resolveNextCheckboxValue(vue.toValue(field.value), newValue, vue.toValue(uncheckedValue));
1464
1459
  }
1465
1460
  handleChange(newValue, shouldValidate);
1466
1461
  }
@@ -2099,6 +2094,9 @@
2099
2094
  initialValues: initialValues,
2100
2095
  getAllPathStates: () => pathStates.value,
2101
2096
  markForUnmount,
2097
+ isFieldTouched,
2098
+ isFieldDirty,
2099
+ isFieldValid,
2102
2100
  };
2103
2101
  /**
2104
2102
  * Sets a single field value
@@ -2158,6 +2156,18 @@
2158
2156
  pathState.touched = isTouched;
2159
2157
  }
2160
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
+ }
2161
2171
  /**
2162
2172
  * Sets the touched meta state on multiple fields
2163
2173
  */
@@ -2258,10 +2268,7 @@
2258
2268
  if (state === null || state === void 0 ? void 0 : state.validate) {
2259
2269
  return state.validate(opts);
2260
2270
  }
2261
- const shouldWarn = !state && ((_a = opts === null || opts === void 0 ? void 0 : opts.warn) !== null && _a !== void 0 ? _a : true);
2262
- if (shouldWarn) {
2263
- vue.warn(`field with path ${path} was not found`);
2264
- }
2271
+ !state && ((_a = opts === null || opts === void 0 ? void 0 : opts.warn) !== null && _a !== void 0 ? _a : true);
2265
2272
  return Promise.resolve({ errors: [], valid: true });
2266
2273
  }
2267
2274
  function unsetInitialValue(path) {
@@ -2649,11 +2656,9 @@
2649
2656
  move: noOp,
2650
2657
  };
2651
2658
  if (!form) {
2652
- warn('FieldArray requires being a child of `<Form/>` or `useForm` being called before it. Array fields may not work correctly');
2653
2659
  return noOpApi;
2654
2660
  }
2655
2661
  if (!vue.unref(arrayPath)) {
2656
- warn('FieldArray requires a field path to be provided, did you forget to pass the `name` prop?');
2657
2662
  return noOpApi;
2658
2663
  }
2659
2664
  const alreadyExists = form.fieldArrays.find(a => vue.unref(a.path) === vue.unref(arrayPath));
@@ -2700,7 +2705,6 @@
2700
2705
  set(value) {
2701
2706
  const idx = fields.value.findIndex(e => e.key === key);
2702
2707
  if (idx === -1) {
2703
- warn(`Attempting to update a non-existent array item`);
2704
2708
  return;
2705
2709
  }
2706
2710
  update(idx, value);
@@ -2948,9 +2952,6 @@
2948
2952
 
2949
2953
  function useResetForm() {
2950
2954
  const form = injectWithSelf(FormContextKey);
2951
- if (!form) {
2952
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
2953
- }
2954
2955
  return function resetForm(state) {
2955
2956
  if (!form) {
2956
2957
  return;
@@ -3006,9 +3007,6 @@
3006
3007
  */
3007
3008
  function useIsSubmitting() {
3008
3009
  const form = injectWithSelf(FormContextKey);
3009
- if (!form) {
3010
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3011
- }
3012
3010
  return vue.computed(() => {
3013
3011
  var _a;
3014
3012
  return (_a = form === null || form === void 0 ? void 0 : form.isSubmitting.value) !== null && _a !== void 0 ? _a : false;
@@ -3020,9 +3018,6 @@
3020
3018
  */
3021
3019
  function useIsValidating() {
3022
3020
  const form = injectWithSelf(FormContextKey);
3023
- if (!form) {
3024
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3025
- }
3026
3021
  return vue.computed(() => {
3027
3022
  var _a;
3028
3023
  return (_a = form === null || form === void 0 ? void 0 : form.isValidating.value) !== null && _a !== void 0 ? _a : false;
@@ -3040,9 +3035,8 @@
3040
3035
  return field.validate();
3041
3036
  }
3042
3037
  if (form && path) {
3043
- 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));
3044
3039
  }
3045
- warn(`field with name ${vue.unref(path)} was not found`);
3046
3040
  return Promise.resolve({
3047
3041
  errors: [],
3048
3042
  valid: true,
@@ -3055,9 +3049,6 @@
3055
3049
  */
3056
3050
  function useIsFormDirty() {
3057
3051
  const form = injectWithSelf(FormContextKey);
3058
- if (!form) {
3059
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3060
- }
3061
3052
  return vue.computed(() => {
3062
3053
  var _a;
3063
3054
  return (_a = form === null || form === void 0 ? void 0 : form.meta.value.dirty) !== null && _a !== void 0 ? _a : false;
@@ -3069,9 +3060,6 @@
3069
3060
  */
3070
3061
  function useIsFormTouched() {
3071
3062
  const form = injectWithSelf(FormContextKey);
3072
- if (!form) {
3073
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3074
- }
3075
3063
  return vue.computed(() => {
3076
3064
  var _a;
3077
3065
  return (_a = form === null || form === void 0 ? void 0 : form.meta.value.touched) !== null && _a !== void 0 ? _a : false;
@@ -3083,9 +3071,6 @@
3083
3071
  */
3084
3072
  function useIsFormValid() {
3085
3073
  const form = injectWithSelf(FormContextKey);
3086
- if (!form) {
3087
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3088
- }
3089
3074
  return vue.computed(() => {
3090
3075
  var _a;
3091
3076
  return (_a = form === null || form === void 0 ? void 0 : form.meta.value.valid) !== null && _a !== void 0 ? _a : false;
@@ -3097,9 +3082,6 @@
3097
3082
  */
3098
3083
  function useValidateForm() {
3099
3084
  const form = injectWithSelf(FormContextKey);
3100
- if (!form) {
3101
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3102
- }
3103
3085
  return function validateField() {
3104
3086
  if (!form) {
3105
3087
  return Promise.resolve({ results: {}, errors: {}, valid: true });
@@ -3113,9 +3095,6 @@
3113
3095
  */
3114
3096
  function useSubmitCount() {
3115
3097
  const form = injectWithSelf(FormContextKey);
3116
- if (!form) {
3117
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3118
- }
3119
3098
  return vue.computed(() => {
3120
3099
  var _a;
3121
3100
  return (_a = form === null || form === void 0 ? void 0 : form.submitCount.value) !== null && _a !== void 0 ? _a : 0;
@@ -3131,9 +3110,9 @@
3131
3110
  const field = path ? undefined : vue.inject(FieldContextKey);
3132
3111
  return vue.computed(() => {
3133
3112
  if (path) {
3134
- 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));
3135
3114
  }
3136
- 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);
3137
3116
  });
3138
3117
  }
3139
3118
 
@@ -3142,9 +3121,6 @@
3142
3121
  */
3143
3122
  function useFormValues() {
3144
3123
  const form = injectWithSelf(FormContextKey);
3145
- if (!form) {
3146
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3147
- }
3148
3124
  return vue.computed(() => {
3149
3125
  return (form === null || form === void 0 ? void 0 : form.values) || {};
3150
3126
  });
@@ -3155,9 +3131,6 @@
3155
3131
  */
3156
3132
  function useFormErrors() {
3157
3133
  const form = injectWithSelf(FormContextKey);
3158
- if (!form) {
3159
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3160
- }
3161
3134
  return vue.computed(() => {
3162
3135
  return ((form === null || form === void 0 ? void 0 : form.errors.value) || {});
3163
3136
  });
@@ -3172,7 +3145,7 @@
3172
3145
  const field = path ? undefined : vue.inject(FieldContextKey);
3173
3146
  return vue.computed(() => {
3174
3147
  if (path) {
3175
- 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)];
3176
3149
  }
3177
3150
  return field === null || field === void 0 ? void 0 : field.errorMessage.value;
3178
3151
  });
@@ -3180,9 +3153,6 @@
3180
3153
 
3181
3154
  function useSubmitForm(cb) {
3182
3155
  const form = injectWithSelf(FormContextKey);
3183
- if (!form) {
3184
- warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3185
- }
3186
3156
  const onSubmit = form ? form.handleSubmit(cb) : undefined;
3187
3157
  return function submitForm(e) {
3188
3158
  if (!onSubmit) {
@@ -3202,9 +3172,11 @@
3202
3172
  return function setFieldError(message) {
3203
3173
  if (path && form) {
3204
3174
  form.setFieldError(vue.toValue(path), message);
3175
+ return;
3205
3176
  }
3206
3177
  if (field) {
3207
3178
  field.setErrors(message || []);
3179
+ return;
3208
3180
  }
3209
3181
  };
3210
3182
  }
@@ -3219,9 +3191,11 @@
3219
3191
  return function setFieldTouched(touched) {
3220
3192
  if (path && form) {
3221
3193
  form.setFieldTouched(vue.toValue(path), touched);
3194
+ return;
3222
3195
  }
3223
3196
  if (field) {
3224
3197
  field.setTouched(touched);
3198
+ return;
3225
3199
  }
3226
3200
  };
3227
3201
  }
@@ -3236,9 +3210,11 @@
3236
3210
  return function setFieldValue(value, shouldValidate = true) {
3237
3211
  if (path && form) {
3238
3212
  form.setFieldValue(vue.toValue(path), value, shouldValidate);
3213
+ return;
3239
3214
  }
3240
3215
  if (field) {
3241
3216
  field.setValue(value, shouldValidate);
3217
+ return;
3242
3218
  }
3243
3219
  };
3244
3220
  }
@@ -3251,6 +3227,7 @@
3251
3227
  function setFormErrors(fields) {
3252
3228
  if (form) {
3253
3229
  form.setErrors(fields);
3230
+ return;
3254
3231
  }
3255
3232
  }
3256
3233
  return setFormErrors;
@@ -3264,6 +3241,7 @@
3264
3241
  function setFormTouched(fields) {
3265
3242
  if (form) {
3266
3243
  form.setTouched(fields);
3244
+ return;
3267
3245
  }
3268
3246
  }
3269
3247
  return setFormTouched;
@@ -3277,6 +3255,7 @@
3277
3255
  function setFormValues(fields) {
3278
3256
  if (form) {
3279
3257
  form.setValues(fields);
3258
+ return;
3280
3259
  }
3281
3260
  }
3282
3261
  return setFormValues;
@@ -1,6 +1,6 @@
1
1
  /**
2
- * vee-validate v4.11.1
2
+ * vee-validate v4.11.3
3
3
  * (c) 2023 Abdelrahman Awad
4
4
  * @license MIT
5
5
  */
6
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VeeValidate={},e.Vue)}(this,(function(e,t){"use strict";function n(e){return"function"==typeof e}function r(e){return null==e}const a=e=>null!==e&&!!e&&"object"==typeof e&&!Array.isArray(e);function l(e){return Number(e)>=0}function 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||"range"===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.1",
3
+ "version": "4.11.3",
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
  }