vee-validate 4.12.7 → 4.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -152,10 +152,14 @@ type ValidationRuleFunction<TValue = unknown, TParams = unknown[] | Record<strin
152
152
  type SimpleValidationRuleFunction<TValue = unknown, TParams = unknown[] | Record<string, unknown>> = (value: TValue, params: TParams) => boolean | string | Promise<boolean | string>;
153
153
  type ValidationMessageGenerator = (ctx: FieldValidationMetaInfo) => string;
154
154
 
155
- interface ValidationResult {
155
+ interface ValidationResult<TValue = unknown> {
156
156
  errors: string[];
157
157
  valid: boolean;
158
+ value?: TValue;
158
159
  }
160
+ type FlattenAndMapPathsValidationResult<TInput extends GenericObject, TOutput extends GenericObject> = {
161
+ [K in Path<TInput>]: ValidationResult<TOutput[K]>;
162
+ };
159
163
  interface TypedSchemaError {
160
164
  path?: string;
161
165
  errors: string[];
@@ -164,9 +168,12 @@ interface TypedSchemaPathDescription {
164
168
  required: boolean;
165
169
  exists: boolean;
166
170
  }
171
+ interface TypedSchemaContext {
172
+ formData: GenericObject;
173
+ }
167
174
  interface TypedSchema<TInput = any, TOutput = TInput> {
168
175
  __type: 'VVTypedSchema';
169
- parse(values: TInput): Promise<{
176
+ parse(values: TInput, context?: TypedSchemaContext): Promise<{
170
177
  value?: TOutput;
171
178
  errors: TypedSchemaError[];
172
179
  }>;
@@ -215,15 +222,15 @@ interface ValidationOptions$1 {
215
222
  mode: SchemaValidationMode;
216
223
  warn: boolean;
217
224
  }
218
- type FieldValidator = (opts?: Partial<ValidationOptions$1>) => Promise<ValidationResult>;
219
- interface PathStateConfig {
225
+ type FieldValidator<TOutput> = (opts?: Partial<ValidationOptions$1>) => Promise<ValidationResult<TOutput>>;
226
+ interface PathStateConfig<TOutput> {
220
227
  bails: boolean;
221
228
  label: MaybeRefOrGetter<string | undefined>;
222
229
  type: InputType;
223
- validate: FieldValidator;
230
+ validate: FieldValidator<TOutput>;
224
231
  schema?: MaybeRefOrGetter<TypedSchema | undefined>;
225
232
  }
226
- interface PathState<TValue = unknown> {
233
+ interface PathState<TInput = unknown, TOutput = TInput> {
227
234
  id: number | number[];
228
235
  path: string;
229
236
  touched: boolean;
@@ -232,8 +239,8 @@ interface PathState<TValue = unknown> {
232
239
  required: boolean;
233
240
  validated: boolean;
234
241
  pending: boolean;
235
- initialValue: TValue | undefined;
236
- value: TValue | undefined;
242
+ initialValue: TInput | undefined;
243
+ value: TInput | undefined;
237
244
  errors: string[];
238
245
  bails: boolean;
239
246
  label: string | undefined;
@@ -244,7 +251,7 @@ interface PathState<TValue = unknown> {
244
251
  pendingUnmount: Record<string, boolean>;
245
252
  pendingReset: boolean;
246
253
  };
247
- validate?: FieldValidator;
254
+ validate?: FieldValidator<TOutput>;
248
255
  }
249
256
  interface FieldEntry<TValue = unknown> {
250
257
  value: TValue;
@@ -267,29 +274,29 @@ interface PrivateFieldArrayContext<TValue = unknown> extends FieldArrayContext<T
267
274
  reset(): void;
268
275
  path: MaybeRefOrGetter<string>;
269
276
  }
270
- interface PrivateFieldContext<TValue = unknown> {
277
+ interface PrivateFieldContext<TInput = unknown, TOutput = TInput> {
271
278
  id: number;
272
279
  name: MaybeRef<string>;
273
- value: Ref<TValue>;
274
- meta: FieldMeta<TValue>;
280
+ value: Ref<TInput>;
281
+ meta: FieldMeta<TInput>;
275
282
  errors: Ref<string[]>;
276
283
  errorMessage: Ref<string | undefined>;
277
284
  label?: MaybeRefOrGetter<string | undefined>;
278
285
  type?: string;
279
286
  bails?: boolean;
280
287
  keepValueOnUnmount?: MaybeRefOrGetter<boolean | undefined>;
281
- checkedValue?: MaybeRefOrGetter<TValue>;
282
- uncheckedValue?: MaybeRefOrGetter<TValue>;
288
+ checkedValue?: MaybeRefOrGetter<TInput>;
289
+ uncheckedValue?: MaybeRefOrGetter<TInput>;
283
290
  checked?: Ref<boolean>;
284
- resetField(state?: Partial<FieldState<TValue>>): void;
291
+ resetField(state?: Partial<FieldState<TInput>>): void;
285
292
  handleReset(): void;
286
- validate: FieldValidator;
293
+ validate: FieldValidator<TOutput>;
287
294
  handleChange(e: Event | unknown, shouldValidate?: boolean): void;
288
295
  handleBlur(e?: Event, shouldValidate?: boolean): void;
289
- setState(state: Partial<FieldState<TValue>>): void;
296
+ setState(state: Partial<FieldState<TInput>>): void;
290
297
  setTouched(isTouched: boolean): void;
291
298
  setErrors(message: string | string[]): void;
292
- setValue(value: TValue, shouldValidate?: boolean): void;
299
+ setValue(value: TInput, shouldValidate?: boolean): void;
293
300
  }
294
301
  type FieldContext<TValue = unknown> = Omit<PrivateFieldContext<TValue>, 'id' | 'instances'>;
295
302
  type GenericValidateFunction<TValue = unknown> = (value: TValue, ctx: FieldValidationMetaInfo) => MaybePromise<boolean | MaybeArray<string>>;
@@ -314,27 +321,28 @@ interface FormActions<TValues extends GenericObject, TOutput = TValues> {
314
321
  resetForm(state?: Partial<FormState<TValues>>, opts?: Partial<ResetFormOpts>): void;
315
322
  resetField(field: Path<TValues>, state?: Partial<FieldState>): void;
316
323
  }
317
- interface FormValidationResult<TValues, TOutput = TValues> {
324
+ interface FormValidationResult<TInput extends GenericObject, TOutput extends GenericObject = TInput> {
318
325
  valid: boolean;
319
- results: Partial<Record<Path<TValues>, ValidationResult>>;
320
- errors: Partial<Record<Path<TValues>, string>>;
321
- values?: TOutput;
326
+ results: Partial<FlattenAndMapPathsValidationResult<TInput, TOutput>>;
327
+ errors: Partial<Record<Path<TInput>, string>>;
328
+ values?: Partial<TOutput>;
329
+ source: 'schema' | 'fields' | 'none';
322
330
  }
323
- interface SubmissionContext<TValues extends GenericObject = GenericObject> extends FormActions<TValues> {
331
+ interface SubmissionContext<TInput extends GenericObject = GenericObject> extends FormActions<TInput> {
324
332
  evt?: Event;
325
- controlledValues: Partial<TValues>;
333
+ controlledValues: Partial<TInput>;
326
334
  }
327
- type SubmissionHandler<TValues extends GenericObject = GenericObject, TOutput = TValues, TReturn = unknown> = (values: TOutput, ctx: SubmissionContext<TValues>) => TReturn;
328
- interface InvalidSubmissionContext<TValues extends GenericObject = GenericObject> {
329
- values: TValues;
335
+ type SubmissionHandler<TInput extends GenericObject = GenericObject, TOutput = TInput, TReturn = unknown> = (values: TOutput, ctx: SubmissionContext<TInput>) => TReturn;
336
+ interface InvalidSubmissionContext<TInput extends GenericObject = GenericObject, TOutput extends GenericObject = TInput> {
337
+ values: TInput;
330
338
  evt?: Event;
331
- errors: Partial<Record<Path<TValues>, string>>;
332
- results: Partial<Record<Path<TValues>, ValidationResult>>;
339
+ errors: Partial<Record<Path<TInput>, string>>;
340
+ results: FormValidationResult<TInput, TOutput>['results'];
333
341
  }
334
- type InvalidSubmissionHandler<TValues extends GenericObject = GenericObject> = (ctx: InvalidSubmissionContext<TValues>) => void;
342
+ type InvalidSubmissionHandler<TInput extends GenericObject = GenericObject, TOutput extends GenericObject = TInput> = (ctx: InvalidSubmissionContext<TInput, TOutput>) => void;
335
343
  type RawFormSchema<TValues> = Record<Path<TValues>, string | GenericValidateFunction | GenericObject>;
336
344
  type FieldPathLookup<TValues extends GenericObject = GenericObject> = Partial<Record<Path<TValues>, PrivateFieldContext | PrivateFieldContext[]>>;
337
- type HandleSubmitFactory<TValues extends GenericObject, TOutput = TValues> = <TReturn = unknown>(cb: SubmissionHandler<TValues, TOutput, TReturn>, onSubmitValidationErrorCb?: InvalidSubmissionHandler<TValues>) => (e?: Event) => Promise<TReturn | undefined>;
345
+ type HandleSubmitFactory<TValues extends GenericObject, TOutput extends GenericObject = TValues> = <TReturn = unknown>(cb: SubmissionHandler<TValues, TOutput, TReturn>, onSubmitValidationErrorCb?: InvalidSubmissionHandler<TValues, TOutput>) => (e?: Event) => Promise<TReturn | undefined>;
338
346
  type PublicPathState<TValue = unknown> = Omit<PathState<TValue>, 'bails' | 'label' | 'multiple' | 'fieldsCount' | 'validate' | 'id' | 'type' | '__flags'>;
339
347
  interface BaseFieldProps {
340
348
  onBlur: () => void;
@@ -383,7 +391,7 @@ interface BaseInputBinds<TValue = unknown> {
383
391
  onChange: (e: Event) => void;
384
392
  onInput: (e: Event) => void;
385
393
  }
386
- interface PrivateFormContext<TValues extends GenericObject = GenericObject, TOutput = TValues> extends FormActions<TValues> {
394
+ interface PrivateFormContext<TValues extends GenericObject = GenericObject, TOutput extends GenericObject = TValues> extends FormActions<TValues> {
387
395
  formId: number;
388
396
  values: TValues;
389
397
  initialValues: Ref<Partial<TValues>>;
@@ -399,14 +407,14 @@ interface PrivateFormContext<TValues extends GenericObject = GenericObject, TOut
399
407
  keepValuesOnUnmount: MaybeRef<boolean>;
400
408
  validateSchema?: (mode: SchemaValidationMode) => Promise<FormValidationResult<TValues, TOutput>>;
401
409
  validate(opts?: Partial<ValidationOptions$1>): Promise<FormValidationResult<TValues, TOutput>>;
402
- validateField(field: Path<TValues>, opts?: Partial<ValidationOptions$1>): Promise<ValidationResult>;
410
+ validateField<TPath extends Path<TValues>>(field: TPath, opts?: Partial<ValidationOptions$1>): Promise<ValidationResult<TOutput[TPath]>>;
403
411
  stageInitialValue(path: string, value: unknown, updateOriginal?: boolean): void;
404
412
  unsetInitialValue(path: string): void;
405
413
  handleSubmit: HandleSubmitFactory<TValues, TOutput> & {
406
414
  withControlled: HandleSubmitFactory<TValues, TOutput>;
407
415
  };
408
416
  setFieldInitialValue(path: string, value: unknown, updateOriginal?: boolean): void;
409
- createPathState<TPath extends Path<TValues>>(path: MaybeRef<TPath>, config?: Partial<PathStateConfig>): PathState<PathValue<TValues, TPath>>;
417
+ createPathState<TPath extends Path<TValues>>(path: MaybeRef<TPath>, config?: Partial<PathStateConfig<TOutput[TPath]>>): PathState<PathValue<TValues, TPath>>;
410
418
  getPathState<TPath extends Path<TValues>>(path: TPath): PathState<PathValue<TValues, TPath>> | undefined;
411
419
  getAllPathStates(): PathState[];
412
420
  removePathState<TPath extends Path<TValues>>(path: TPath, id: number): void;
@@ -433,7 +441,7 @@ interface PrivateFormContext<TValues extends GenericObject = GenericObject, TOut
433
441
  */
434
442
  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>;
435
443
  }
436
- interface FormContext<TValues extends GenericObject = GenericObject, TOutput = TValues> extends Omit<PrivateFormContext<TValues, TOutput>, 'formId' | 'schema' | 'initialValues' | 'getPathState' | 'getAllPathStates' | 'removePathState' | 'unsetPathValue' | 'validateSchema' | 'stageInitialValue' | 'setFieldInitialValue' | 'unsetInitialValue' | 'fieldArrays' | 'markForUnmount' | 'keepValuesOnUnmount' | 'values'> {
444
+ interface FormContext<TValues extends GenericObject = GenericObject, TOutput extends GenericObject = TValues> extends Omit<PrivateFormContext<TValues, TOutput>, 'formId' | 'schema' | 'initialValues' | 'getPathState' | 'getAllPathStates' | 'removePathState' | 'unsetPathValue' | 'validateSchema' | 'stageInitialValue' | 'setFieldInitialValue' | 'unsetInitialValue' | 'fieldArrays' | 'markForUnmount' | 'keepValuesOnUnmount' | 'values'> {
437
445
  values: TValues;
438
446
  handleReset: () => void;
439
447
  submitForm: (e?: unknown) => Promise<void>;
@@ -464,8 +472,8 @@ interface ValidationOptions {
464
472
  /**
465
473
  * Validates a value against the rules.
466
474
  */
467
- declare function validate<TValue = unknown>(value: TValue, rules: string | Record<string, unknown | unknown[]> | GenericValidateFunction<TValue> | GenericValidateFunction<TValue>[] | TypedSchema<TValue>, options?: ValidationOptions): Promise<ValidationResult>;
468
- declare function validateObjectSchema<TValues, TOutput>(schema: RawFormSchema<TValues>, values: TValues, opts?: Partial<{
475
+ declare function validate<TInput, TOutput>(value: TInput, rules: string | Record<string, unknown | unknown[]> | GenericValidateFunction<TInput> | GenericValidateFunction<TInput>[] | TypedSchema<TInput, TOutput>, options?: ValidationOptions): Promise<ValidationResult<TOutput>>;
476
+ declare function validateObjectSchema<TValues extends GenericObject, TOutput extends GenericObject>(schema: RawFormSchema<TValues>, values: TValues | undefined, opts?: Partial<{
469
477
  names: Record<string, {
470
478
  name: string;
471
479
  label: string;
@@ -546,7 +554,7 @@ interface FieldBindingObject<TValue = any> extends SharedBindingObject<TValue> {
546
554
  interface ComponentFieldBindingObject<TValue = any> extends SharedBindingObject<TValue> {
547
555
  modelValue?: TValue;
548
556
  }
549
- interface FieldSlotProps<TValue = unknown> extends Pick<FieldContext, 'validate' | 'resetField' | 'handleChange' | 'handleReset' | 'handleBlur' | 'setTouched' | 'setErrors'> {
557
+ interface FieldSlotProps<TValue = unknown> extends Pick<FieldContext, 'validate' | 'resetField' | 'handleChange' | 'handleReset' | 'handleBlur' | 'setTouched' | 'setErrors' | 'setValue'> {
550
558
  field: FieldBindingObject<TValue>;
551
559
  componentField: ComponentFieldBindingObject<TValue>;
552
560
  value: TValue;
@@ -908,6 +916,7 @@ declare const Field: {
908
916
  setTouched: FieldContext['setTouched'];
909
917
  reset: FieldContext['resetField'];
910
918
  validate: FieldContext['validate'];
919
+ setValue: FieldContext['setValue'];
911
920
  handleChange: FieldContext['handleChange'];
912
921
  $slots: {
913
922
  default: (arg: FieldSlotProps<any>) => VNode[];
@@ -1317,11 +1326,11 @@ interface FormOptions<TValues extends GenericObject, TOutput = TValues, TSchema
1317
1326
  validateOnMount?: boolean;
1318
1327
  keepValuesOnUnmount?: MaybeRef<boolean>;
1319
1328
  }
1320
- declare function useForm<TValues extends GenericObject = GenericObject, TOutput = TValues, TSchema extends FormSchema<TValues> | TypedSchema<TValues, TOutput> = FormSchema<TValues> | TypedSchema<TValues, TOutput>>(opts?: FormOptions<TValues, TOutput, TSchema>): FormContext<TValues, TOutput>;
1329
+ declare function useForm<TValues extends GenericObject = GenericObject, TOutput extends GenericObject = TValues, TSchema extends FormSchema<TValues> | TypedSchema<TValues, TOutput> = FormSchema<TValues> | TypedSchema<TValues, TOutput>>(opts?: FormOptions<TValues, TOutput, TSchema>): FormContext<TValues, TOutput>;
1321
1330
 
1322
1331
  declare function useFieldArray<TValue = unknown>(arrayPath: MaybeRefOrGetter<string>): FieldArrayContext<TValue>;
1323
1332
 
1324
- declare function useResetForm<TValues extends Record<string, unknown> = Record<string, unknown>>(): (state?: Partial<FormState<TValues>>) => void;
1333
+ declare function useResetForm<TValues extends Record<string, unknown> = Record<string, unknown>>(): (state?: Partial<FormState<TValues>>, opts?: ResetFormOpts) => void;
1325
1334
 
1326
1335
  /**
1327
1336
  * If a field is dirty or not
@@ -1351,7 +1360,7 @@ declare function useIsValidating(): vue.ComputedRef<boolean>;
1351
1360
  /**
1352
1361
  * Validates a single field
1353
1362
  */
1354
- declare function useValidateField(path?: MaybeRefOrGetter<string>): () => Promise<ValidationResult>;
1363
+ declare function useValidateField<TOutput>(path?: MaybeRefOrGetter<string>): () => Promise<ValidationResult<TOutput>>;
1355
1364
 
1356
1365
  /**
1357
1366
  * If the form is dirty or not
@@ -1434,4 +1443,4 @@ declare const FormContextKey: InjectionKey<PrivateFormContext>;
1434
1443
  declare const FieldContextKey: InjectionKey<PrivateFieldContext<unknown>>;
1435
1444
  declare const IS_ABSENT: unique symbol;
1436
1445
 
1437
- export { type BaseComponentBinds, type BaseFieldProps, type BaseInputBinds, type ComponentBindsConfig, type ComponentFieldBindingObject, type ComponentModelBinds, type ComponentModellessBinds, type DevtoolsPluginFieldState, type DevtoolsPluginFormState, ErrorMessage, Field, FieldArray, type FieldArrayContext, type FieldBindingObject, 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 ResetFormOpts, type RuleExpression, type SchemaValidationMode, type SubmissionContext, type SubmissionHandler, type TypedSchema, type TypedSchemaError, type TypedSchemaPathDescription, type ValidationOptions$1 as ValidationOptions, type ValidationResult, type YupSchema, cleanupNonNestedPath, configure, defineRule, isNotNestedPath, 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 };
1446
+ export { type BaseComponentBinds, type BaseFieldProps, type BaseInputBinds, type ComponentBindsConfig, type ComponentFieldBindingObject, type ComponentModelBinds, type ComponentModellessBinds, type DevtoolsPluginFieldState, type DevtoolsPluginFormState, ErrorMessage, Field, FieldArray, type FieldArrayContext, type FieldBindingObject, type FieldContext, FieldContextKey, type FieldEntry, type FieldMeta, type FieldOptions, type FieldPathLookup, type FieldState, type FieldValidator, type FlattenAndMapPathsValidationResult, 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 ResetFormOpts, type RuleExpression, type SchemaValidationMode, type SubmissionContext, type SubmissionHandler, type TypedSchema, type TypedSchemaContext, type TypedSchemaError, type TypedSchemaPathDescription, type ValidationOptions$1 as ValidationOptions, type ValidationResult, type YupSchema, cleanupNonNestedPath, configure, defineRule, isNotNestedPath, 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,5 +1,5 @@
1
1
  /**
2
- * vee-validate v4.12.7
2
+ * vee-validate v4.13.0
3
3
  * (c) 2024 Abdelrahman Awad
4
4
  * @license MIT
5
5
  */
@@ -766,21 +766,18 @@ async function validate(value, rules, options = {}) {
766
766
  formData: (options === null || options === void 0 ? void 0 : options.values) || {},
767
767
  };
768
768
  const result = await _validate(field, value);
769
- const errors = result.errors;
770
- return {
771
- errors,
772
- valid: !errors.length,
773
- };
769
+ return Object.assign(Object.assign({}, result), { valid: !result.errors.length });
774
770
  }
775
771
  /**
776
772
  * Starts the validation process.
777
773
  */
778
774
  async function _validate(field, value) {
779
- if (isTypedSchema(field.rules) || isYupValidator(field.rules)) {
780
- return validateFieldWithTypedSchema(value, field.rules);
775
+ const rules = field.rules;
776
+ if (isTypedSchema(rules) || isYupValidator(rules)) {
777
+ return validateFieldWithTypedSchema(value, Object.assign(Object.assign({}, field), { rules }));
781
778
  }
782
779
  // if a generic function or chain of generic functions
783
- if (isCallable(field.rules) || Array.isArray(field.rules)) {
780
+ if (isCallable(rules) || Array.isArray(rules)) {
784
781
  const ctx = {
785
782
  field: field.label || field.name,
786
783
  name: field.name,
@@ -789,7 +786,7 @@ async function _validate(field, value) {
789
786
  value,
790
787
  };
791
788
  // Normalize the pipeline
792
- const pipeline = Array.isArray(field.rules) ? field.rules : [field.rules];
789
+ const pipeline = Array.isArray(rules) ? rules : [rules];
793
790
  const length = pipeline.length;
794
791
  const errors = [];
795
792
  for (let i = 0; i < length; i++) {
@@ -816,7 +813,7 @@ async function _validate(field, value) {
816
813
  errors,
817
814
  };
818
815
  }
819
- const normalizedContext = Object.assign(Object.assign({}, field), { rules: normalizeRules(field.rules) });
816
+ const normalizedContext = Object.assign(Object.assign({}, field), { rules: normalizeRules(rules) });
820
817
  const errors = [];
821
818
  const rulesKeys = Object.keys(normalizedContext.rules);
822
819
  const length = rulesKeys.length;
@@ -845,10 +842,10 @@ function isYupError(err) {
845
842
  function yupToTypedSchema(yupSchema) {
846
843
  const schema = {
847
844
  __type: 'VVTypedSchema',
848
- async parse(values) {
845
+ async parse(values, context) {
849
846
  var _a;
850
847
  try {
851
- const output = await yupSchema.validate(values, { abortEarly: false });
848
+ const output = await yupSchema.validate(values, { abortEarly: false, context: (context === null || context === void 0 ? void 0 : context.formData) || {} });
852
849
  return {
853
850
  output,
854
851
  errors: [],
@@ -880,9 +877,9 @@ function yupToTypedSchema(yupSchema) {
880
877
  /**
881
878
  * Handles yup validation
882
879
  */
883
- async function validateFieldWithTypedSchema(value, schema) {
884
- const typedSchema = isTypedSchema(schema) ? schema : yupToTypedSchema(schema);
885
- const result = await typedSchema.parse(value);
880
+ async function validateFieldWithTypedSchema(value, context) {
881
+ const typedSchema = isTypedSchema(context.rules) ? context.rules : yupToTypedSchema(context.rules);
882
+ const result = await typedSchema.parse(value, { formData: context.formData });
886
883
  const messages = [];
887
884
  for (const error of result.errors) {
888
885
  if (error.errors.length) {
@@ -890,6 +887,7 @@ async function validateFieldWithTypedSchema(value, schema) {
890
887
  }
891
888
  }
892
889
  return {
890
+ value: result.value,
893
891
  errors: messages,
894
892
  };
895
893
  }
@@ -966,6 +964,7 @@ async function validateTypedSchema(schema, values) {
966
964
  results,
967
965
  errors,
968
966
  values: validationResult.value,
967
+ source: 'schema',
969
968
  };
970
969
  }
971
970
  async function validateObjectSchema(schema, values, opts) {
@@ -999,6 +998,7 @@ async function validateObjectSchema(schema, values, opts) {
999
998
  valid: isAllValid,
1000
999
  results,
1001
1000
  errors,
1001
+ source: 'schema',
1002
1002
  };
1003
1003
  }
1004
1004
 
@@ -1588,7 +1588,7 @@ function _useField(path, rules, opts) {
1588
1588
  bails,
1589
1589
  label,
1590
1590
  type,
1591
- validate: validator.value && !isTyped ? validate$1 : undefined,
1591
+ validate: validator.value ? validate$1 : undefined,
1592
1592
  schema: isTyped ? rules : undefined,
1593
1593
  });
1594
1594
  const errorMessage = computed(() => errors.value[0]);
@@ -1999,7 +1999,7 @@ const FieldImpl = /** #__PURE__ */ defineComponent({
1999
1999
  const label = toRef(props, 'label');
2000
2000
  const uncheckedValue = toRef(props, 'uncheckedValue');
2001
2001
  const keepValue = toRef(props, 'keepValue');
2002
- const { errors, value, errorMessage, validate: validateField, handleChange, handleBlur, setTouched, resetField, handleReset, meta, checked, setErrors, } = useField(name, rules, {
2002
+ const { errors, value, errorMessage, validate: validateField, handleChange, handleBlur, setTouched, resetField, handleReset, meta, checked, setErrors, setValue, } = useField(name, rules, {
2003
2003
  validateOnMount: props.validateOnMount,
2004
2004
  bails: props.bails,
2005
2005
  standalone: props.standalone,
@@ -2076,6 +2076,7 @@ const FieldImpl = /** #__PURE__ */ defineComponent({
2076
2076
  handleBlur: sharedProps.value.onBlur,
2077
2077
  setTouched,
2078
2078
  setErrors,
2079
+ setValue,
2079
2080
  };
2080
2081
  }
2081
2082
  ctx.expose({
@@ -2085,6 +2086,7 @@ const FieldImpl = /** #__PURE__ */ defineComponent({
2085
2086
  errorMessage,
2086
2087
  setErrors,
2087
2088
  setTouched,
2089
+ setValue,
2088
2090
  reset: resetField,
2089
2091
  validate: validateField,
2090
2092
  handleChange,
@@ -2381,9 +2383,15 @@ function useForm(opts) {
2381
2383
  }
2382
2384
  setFieldError(pathState, fieldResult.errors);
2383
2385
  return validation;
2384
- }, { valid: formResult.valid, results: {}, errors: {} });
2386
+ }, {
2387
+ valid: formResult.valid,
2388
+ results: {},
2389
+ errors: {},
2390
+ source: formResult.source,
2391
+ });
2385
2392
  if (formResult.values) {
2386
2393
  results.values = formResult.values;
2394
+ results.source = formResult.source;
2387
2395
  }
2388
2396
  keysOf(results.results).forEach(path => {
2389
2397
  var _a;
@@ -2452,7 +2460,10 @@ function useForm(opts) {
2452
2460
  const controlled = klona(controlledValues.value);
2453
2461
  let submittedValues = (onlyControlled ? controlled : values);
2454
2462
  if (result.values) {
2455
- submittedValues = result.values;
2463
+ submittedValues =
2464
+ result.source === 'schema'
2465
+ ? result.values
2466
+ : Object.assign({}, submittedValues, result.values);
2456
2467
  }
2457
2468
  return fn(submittedValues, {
2458
2469
  evt: e,
@@ -2693,7 +2704,7 @@ function useForm(opts) {
2693
2704
  let newValues = klona((resetState === null || resetState === void 0 ? void 0 : resetState.values) ? resetState.values : originalInitialValues.value);
2694
2705
  newValues = (opts === null || opts === void 0 ? void 0 : opts.force) ? newValues : merge(originalInitialValues.value, newValues);
2695
2706
  newValues = isTypedSchema(schema) && isCallable(schema.cast) ? schema.cast(newValues) : newValues;
2696
- setInitialValues(newValues);
2707
+ setInitialValues(newValues, { force: opts === null || opts === void 0 ? void 0 : opts.force });
2697
2708
  mutateAllPathState(state => {
2698
2709
  var _a;
2699
2710
  state.__flags.pendingReset = true;
@@ -2728,24 +2739,30 @@ function useForm(opts) {
2728
2739
  key: state.path,
2729
2740
  valid: true,
2730
2741
  errors: [],
2742
+ value: undefined,
2731
2743
  });
2732
2744
  }
2733
- return state.validate(opts).then((result) => {
2745
+ return state.validate(opts).then(result => {
2734
2746
  return {
2735
2747
  key: state.path,
2736
2748
  valid: result.valid,
2737
2749
  errors: result.errors,
2750
+ value: result.value,
2738
2751
  };
2739
2752
  });
2740
2753
  }));
2741
2754
  isValidating.value = false;
2742
2755
  const results = {};
2743
2756
  const errors = {};
2757
+ const values = {};
2744
2758
  for (const validation of validations) {
2745
2759
  results[validation.key] = {
2746
2760
  valid: validation.valid,
2747
2761
  errors: validation.errors,
2748
2762
  };
2763
+ if (validation.value) {
2764
+ setInPath(values, validation.key, validation.value);
2765
+ }
2749
2766
  if (validation.errors.length) {
2750
2767
  errors[validation.key] = validation.errors[0];
2751
2768
  }
@@ -2754,6 +2771,8 @@ function useForm(opts) {
2754
2771
  valid: validations.every(r => r.valid),
2755
2772
  results,
2756
2773
  errors,
2774
+ values,
2775
+ source: 'fields',
2757
2776
  };
2758
2777
  }
2759
2778
  async function validateField(path, opts) {
@@ -2799,7 +2818,7 @@ function useForm(opts) {
2799
2818
  async function _validateSchema() {
2800
2819
  const schemaValue = unref(schema);
2801
2820
  if (!schemaValue) {
2802
- return { valid: true, results: {}, errors: {} };
2821
+ return { valid: true, results: {}, errors: {}, source: 'none' };
2803
2822
  }
2804
2823
  isValidating.value = true;
2805
2824
  const formResult = isYupValidator(schemaValue) || isTypedSchema(schemaValue)
@@ -2986,10 +3005,16 @@ function useFormInitialValues(pathsState, formValues, opts) {
2986
3005
  // so these are the values that the reset function should use
2987
3006
  // these only change when the user explicitly changes the initial values or when the user resets them with new values.
2988
3007
  const originalInitialValues = ref(klona(values));
2989
- function setInitialValues(values, updateFields = false) {
2990
- initialValues.value = merge(klona(initialValues.value) || {}, klona(values));
2991
- originalInitialValues.value = merge(klona(originalInitialValues.value) || {}, klona(values));
2992
- if (!updateFields) {
3008
+ function setInitialValues(values, opts) {
3009
+ if (opts === null || opts === void 0 ? void 0 : opts.force) {
3010
+ initialValues.value = klona(values);
3011
+ originalInitialValues.value = klona(values);
3012
+ }
3013
+ else {
3014
+ initialValues.value = merge(klona(initialValues.value) || {}, klona(values));
3015
+ originalInitialValues.value = merge(klona(originalInitialValues.value) || {}, klona(values));
3016
+ }
3017
+ if (!(opts === null || opts === void 0 ? void 0 : opts.updateFields)) {
2993
3018
  return;
2994
3019
  }
2995
3020
  // update the pristine non-touched fields
@@ -3495,11 +3520,11 @@ function useResetForm() {
3495
3520
  warn('No vee-validate <Form /> or `useForm` was detected in the component tree');
3496
3521
  }
3497
3522
  }
3498
- return function resetForm(state) {
3523
+ return function resetForm(state, opts) {
3499
3524
  if (!form) {
3500
3525
  return;
3501
3526
  }
3502
- return form.resetForm(state);
3527
+ return form.resetForm(state, opts);
3503
3528
  };
3504
3529
  }
3505
3530
 
@@ -3660,7 +3685,7 @@ function useValidateForm() {
3660
3685
  }
3661
3686
  return function validateField() {
3662
3687
  if (!form) {
3663
- return Promise.resolve({ results: {}, errors: {}, valid: true });
3688
+ return Promise.resolve({ results: {}, errors: {}, valid: true, source: 'none' });
3664
3689
  }
3665
3690
  return form.validate();
3666
3691
  };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * vee-validate v4.12.7
2
+ * vee-validate v4.13.0
3
3
  * (c) 2024 Abdelrahman Awad
4
4
  * @license MIT
5
5
  */
@@ -744,21 +744,18 @@
744
744
  formData: (options === null || options === void 0 ? void 0 : options.values) || {},
745
745
  };
746
746
  const result = await _validate(field, value);
747
- const errors = result.errors;
748
- return {
749
- errors,
750
- valid: !errors.length,
751
- };
747
+ return Object.assign(Object.assign({}, result), { valid: !result.errors.length });
752
748
  }
753
749
  /**
754
750
  * Starts the validation process.
755
751
  */
756
752
  async function _validate(field, value) {
757
- if (isTypedSchema(field.rules) || isYupValidator(field.rules)) {
758
- return validateFieldWithTypedSchema(value, field.rules);
753
+ const rules = field.rules;
754
+ if (isTypedSchema(rules) || isYupValidator(rules)) {
755
+ return validateFieldWithTypedSchema(value, Object.assign(Object.assign({}, field), { rules }));
759
756
  }
760
757
  // if a generic function or chain of generic functions
761
- if (isCallable(field.rules) || Array.isArray(field.rules)) {
758
+ if (isCallable(rules) || Array.isArray(rules)) {
762
759
  const ctx = {
763
760
  field: field.label || field.name,
764
761
  name: field.name,
@@ -767,7 +764,7 @@
767
764
  value,
768
765
  };
769
766
  // Normalize the pipeline
770
- const pipeline = Array.isArray(field.rules) ? field.rules : [field.rules];
767
+ const pipeline = Array.isArray(rules) ? rules : [rules];
771
768
  const length = pipeline.length;
772
769
  const errors = [];
773
770
  for (let i = 0; i < length; i++) {
@@ -794,7 +791,7 @@
794
791
  errors,
795
792
  };
796
793
  }
797
- const normalizedContext = Object.assign(Object.assign({}, field), { rules: normalizeRules(field.rules) });
794
+ const normalizedContext = Object.assign(Object.assign({}, field), { rules: normalizeRules(rules) });
798
795
  const errors = [];
799
796
  const rulesKeys = Object.keys(normalizedContext.rules);
800
797
  const length = rulesKeys.length;
@@ -823,10 +820,10 @@
823
820
  function yupToTypedSchema(yupSchema) {
824
821
  const schema = {
825
822
  __type: 'VVTypedSchema',
826
- async parse(values) {
823
+ async parse(values, context) {
827
824
  var _a;
828
825
  try {
829
- const output = await yupSchema.validate(values, { abortEarly: false });
826
+ const output = await yupSchema.validate(values, { abortEarly: false, context: (context === null || context === void 0 ? void 0 : context.formData) || {} });
830
827
  return {
831
828
  output,
832
829
  errors: [],
@@ -858,9 +855,9 @@
858
855
  /**
859
856
  * Handles yup validation
860
857
  */
861
- async function validateFieldWithTypedSchema(value, schema) {
862
- const typedSchema = isTypedSchema(schema) ? schema : yupToTypedSchema(schema);
863
- const result = await typedSchema.parse(value);
858
+ async function validateFieldWithTypedSchema(value, context) {
859
+ const typedSchema = isTypedSchema(context.rules) ? context.rules : yupToTypedSchema(context.rules);
860
+ const result = await typedSchema.parse(value, { formData: context.formData });
864
861
  const messages = [];
865
862
  for (const error of result.errors) {
866
863
  if (error.errors.length) {
@@ -868,6 +865,7 @@
868
865
  }
869
866
  }
870
867
  return {
868
+ value: result.value,
871
869
  errors: messages,
872
870
  };
873
871
  }
@@ -944,6 +942,7 @@
944
942
  results,
945
943
  errors,
946
944
  values: validationResult.value,
945
+ source: 'schema',
947
946
  };
948
947
  }
949
948
  async function validateObjectSchema(schema, values, opts) {
@@ -977,6 +976,7 @@
977
976
  valid: isAllValid,
978
977
  results,
979
978
  errors,
979
+ source: 'schema',
980
980
  };
981
981
  }
982
982
 
@@ -1183,7 +1183,7 @@
1183
1183
  bails,
1184
1184
  label,
1185
1185
  type,
1186
- validate: validator.value && !isTyped ? validate$1 : undefined,
1186
+ validate: validator.value ? validate$1 : undefined,
1187
1187
  schema: isTyped ? rules : undefined,
1188
1188
  });
1189
1189
  const errorMessage = vue.computed(() => errors.value[0]);
@@ -1582,7 +1582,7 @@
1582
1582
  const label = vue.toRef(props, 'label');
1583
1583
  const uncheckedValue = vue.toRef(props, 'uncheckedValue');
1584
1584
  const keepValue = vue.toRef(props, 'keepValue');
1585
- const { errors, value, errorMessage, validate: validateField, handleChange, handleBlur, setTouched, resetField, handleReset, meta, checked, setErrors, } = useField(name, rules, {
1585
+ const { errors, value, errorMessage, validate: validateField, handleChange, handleBlur, setTouched, resetField, handleReset, meta, checked, setErrors, setValue, } = useField(name, rules, {
1586
1586
  validateOnMount: props.validateOnMount,
1587
1587
  bails: props.bails,
1588
1588
  standalone: props.standalone,
@@ -1659,6 +1659,7 @@
1659
1659
  handleBlur: sharedProps.value.onBlur,
1660
1660
  setTouched,
1661
1661
  setErrors,
1662
+ setValue,
1662
1663
  };
1663
1664
  }
1664
1665
  ctx.expose({
@@ -1668,6 +1669,7 @@
1668
1669
  errorMessage,
1669
1670
  setErrors,
1670
1671
  setTouched,
1672
+ setValue,
1671
1673
  reset: resetField,
1672
1674
  validate: validateField,
1673
1675
  handleChange,
@@ -1964,9 +1966,15 @@
1964
1966
  }
1965
1967
  setFieldError(pathState, fieldResult.errors);
1966
1968
  return validation;
1967
- }, { valid: formResult.valid, results: {}, errors: {} });
1969
+ }, {
1970
+ valid: formResult.valid,
1971
+ results: {},
1972
+ errors: {},
1973
+ source: formResult.source,
1974
+ });
1968
1975
  if (formResult.values) {
1969
1976
  results.values = formResult.values;
1977
+ results.source = formResult.source;
1970
1978
  }
1971
1979
  keysOf(results.results).forEach(path => {
1972
1980
  var _a;
@@ -2035,7 +2043,10 @@
2035
2043
  const controlled = klona(controlledValues.value);
2036
2044
  let submittedValues = (onlyControlled ? controlled : values);
2037
2045
  if (result.values) {
2038
- submittedValues = result.values;
2046
+ submittedValues =
2047
+ result.source === 'schema'
2048
+ ? result.values
2049
+ : Object.assign({}, submittedValues, result.values);
2039
2050
  }
2040
2051
  return fn(submittedValues, {
2041
2052
  evt: e,
@@ -2276,7 +2287,7 @@
2276
2287
  let newValues = klona((resetState === null || resetState === void 0 ? void 0 : resetState.values) ? resetState.values : originalInitialValues.value);
2277
2288
  newValues = (opts === null || opts === void 0 ? void 0 : opts.force) ? newValues : merge(originalInitialValues.value, newValues);
2278
2289
  newValues = isTypedSchema(schema) && isCallable(schema.cast) ? schema.cast(newValues) : newValues;
2279
- setInitialValues(newValues);
2290
+ setInitialValues(newValues, { force: opts === null || opts === void 0 ? void 0 : opts.force });
2280
2291
  mutateAllPathState(state => {
2281
2292
  var _a;
2282
2293
  state.__flags.pendingReset = true;
@@ -2311,24 +2322,30 @@
2311
2322
  key: state.path,
2312
2323
  valid: true,
2313
2324
  errors: [],
2325
+ value: undefined,
2314
2326
  });
2315
2327
  }
2316
- return state.validate(opts).then((result) => {
2328
+ return state.validate(opts).then(result => {
2317
2329
  return {
2318
2330
  key: state.path,
2319
2331
  valid: result.valid,
2320
2332
  errors: result.errors,
2333
+ value: result.value,
2321
2334
  };
2322
2335
  });
2323
2336
  }));
2324
2337
  isValidating.value = false;
2325
2338
  const results = {};
2326
2339
  const errors = {};
2340
+ const values = {};
2327
2341
  for (const validation of validations) {
2328
2342
  results[validation.key] = {
2329
2343
  valid: validation.valid,
2330
2344
  errors: validation.errors,
2331
2345
  };
2346
+ if (validation.value) {
2347
+ setInPath(values, validation.key, validation.value);
2348
+ }
2332
2349
  if (validation.errors.length) {
2333
2350
  errors[validation.key] = validation.errors[0];
2334
2351
  }
@@ -2337,6 +2354,8 @@
2337
2354
  valid: validations.every(r => r.valid),
2338
2355
  results,
2339
2356
  errors,
2357
+ values,
2358
+ source: 'fields',
2340
2359
  };
2341
2360
  }
2342
2361
  async function validateField(path, opts) {
@@ -2377,7 +2396,7 @@
2377
2396
  async function _validateSchema() {
2378
2397
  const schemaValue = vue.unref(schema);
2379
2398
  if (!schemaValue) {
2380
- return { valid: true, results: {}, errors: {} };
2399
+ return { valid: true, results: {}, errors: {}, source: 'none' };
2381
2400
  }
2382
2401
  isValidating.value = true;
2383
2402
  const formResult = isYupValidator(schemaValue) || isTypedSchema(schemaValue)
@@ -2558,10 +2577,16 @@
2558
2577
  // so these are the values that the reset function should use
2559
2578
  // these only change when the user explicitly changes the initial values or when the user resets them with new values.
2560
2579
  const originalInitialValues = vue.ref(klona(values));
2561
- function setInitialValues(values, updateFields = false) {
2562
- initialValues.value = merge(klona(initialValues.value) || {}, klona(values));
2563
- originalInitialValues.value = merge(klona(originalInitialValues.value) || {}, klona(values));
2564
- if (!updateFields) {
2580
+ function setInitialValues(values, opts) {
2581
+ if (opts === null || opts === void 0 ? void 0 : opts.force) {
2582
+ initialValues.value = klona(values);
2583
+ originalInitialValues.value = klona(values);
2584
+ }
2585
+ else {
2586
+ initialValues.value = merge(klona(initialValues.value) || {}, klona(values));
2587
+ originalInitialValues.value = merge(klona(originalInitialValues.value) || {}, klona(values));
2588
+ }
2589
+ if (!(opts === null || opts === void 0 ? void 0 : opts.updateFields)) {
2565
2590
  return;
2566
2591
  }
2567
2592
  // update the pristine non-touched fields
@@ -3053,11 +3078,11 @@
3053
3078
 
3054
3079
  function useResetForm() {
3055
3080
  const form = injectWithSelf(FormContextKey);
3056
- return function resetForm(state) {
3081
+ return function resetForm(state, opts) {
3057
3082
  if (!form) {
3058
3083
  return;
3059
3084
  }
3060
- return form.resetForm(state);
3085
+ return form.resetForm(state, opts);
3061
3086
  };
3062
3087
  }
3063
3088
 
@@ -3185,7 +3210,7 @@
3185
3210
  const form = injectWithSelf(FormContextKey);
3186
3211
  return function validateField() {
3187
3212
  if (!form) {
3188
- return Promise.resolve({ results: {}, errors: {}, valid: true });
3213
+ return Promise.resolve({ results: {}, errors: {}, valid: true, source: 'none' });
3189
3214
  }
3190
3215
  return form.validate();
3191
3216
  };
@@ -1,6 +1,6 @@
1
1
  /**
2
- * vee-validate v4.12.7
2
+ * vee-validate v4.13.0
3
3
  * (c) 2024 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 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])&&u(e[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={};function d(e,t,n){"object"==typeof n.value&&(n.value=c(n.value)),n.enumerable&&!n.get&&!n.set&&n.configurable&&n.writable&&"__proto__"!==t?e[t]=n.value:Object.defineProperty(e,t,n)}function c(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(c(e))}))):"[object Map]"===a?(r=new Map,e.forEach((function(e,t){r.set(c(t),c(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(c(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++)d(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]||d(r,t,Object.getOwnPropertyDescriptor(e,t))}return r||e}const v=Symbol("vee-validate-form"),f=Symbol("vee-validate-field-instance"),p=Symbol("Default empty value"),m="undefined"!=typeof window;function h(e){return n(e)&&!!e.__locatorRef}function y(e){return!!e&&n(e.parse)&&"VVTypedSchema"===e.__type}function g(e){return!!e&&n(e.validate)}function b(e){return"checkbox"===e||"radio"===e}function V(e){return/^\[.+\]$/i.test(e)}function O(e){return"SELECT"===e.tagName}function j(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&&!b(t.type)}function A(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 S(e,t){return t in e&&e[t]!==p}function E(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(!E(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(!E(r[1],t.get(r[0])))return!1;return!0}if(k(e)&&k(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(!E(e[a],t[a]))return!1}return!0}return e!=e&&t!=t}function k(e){return!!m&&e instanceof File}function w(e){return V(e)?e.replace(/\[|\]/gi,""):e}function I(e,t,n){if(!e)return n;if(V(t))return e[w(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(V(t))return void(e[w(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 T(e,t){if(V(t))return void delete e[w(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 B(e){return Object.keys(e)}function _(e,n=void 0){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function P(e,t,n){if(Array.isArray(e)){const n=[...e],r=n.findIndex((e=>E(e,t)));return r>=0?n.splice(r,1):n.push(t),n}return E(e,t)?n:t}function R(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 x(e,t){return l(t)&&t.number?function(e){const t=parseFloat(e);return isNaN(t)?e:t}(e):e}function U(e,t){let n;return async function(...r){const l=e(...r);n=l;const a=await l;return l!==n?a:(n=void 0,t(a,r))}}function N({get:e,set:n}){const r=t.ref(c(e()));return t.watch(e,(e=>{E(e,r.value)||(r.value=c(e))}),{deep:!0}),t.watch(r,(t=>{E(t,e())||n(c(t))}),{deep:!0}),r}function D(e){return Array.isArray(e)?e:e?[e]:[]}function $(e){const n=_(v),r=e?t.computed((()=>null==n?void 0:n.getPathState(t.toValue(e)))):void 0,l=e?void 0:t.inject(f);return!l&&(null==r||r.value),r||l}function q(e,t){const n={};for(const r in e)t.includes(r)||(n[r]=e[r]);return n}function z(e,t,n){return 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 W(e){if(L(e))return e._value}function L(e){return"_value"in e}function K(e){if(!F(e))return e;const t=e.target;if(b(t.type)&&L(t))return W(t);if("file"===t.type&&t.files){const e=Array.from(t.files);return t.multiple?e:e[0]}if(O(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map(W);var n;if(O(t)){const e=Array.from(t.options).find((e=>e.selected));return e?W(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(y(e.rules)||g(e.rules))return async function(e,t){const n=y(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=>h(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=B(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.setFieldInitialValue(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=D(t)}}}(),d=le>=Number.MAX_SAFE_INTEGER?0:++le,c=function(e,n,r,l){const a=t.computed((()=>{var e,n,r;return null!==(r=null===(n=null===(e=t.toValue(l))||void 0===e?void 0:e.describe)||void 0===n?void 0:n.call(e).required)&&void 0!==r&&r})),u=t.reactive({touched:!1,pending:!1,valid:!0,required:a,validated:!!t.unref(r).length,initialValue:t.computed((()=>t.unref(n))),dirty:t.computed((()=>!E(t.unref(e),t.unref(n))))});return t.watch(r,(e=>{u.valid=!e.length}),{immediate:!0,flush:"sync"}),u}(r,l,o,n.schema);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},pendingReset:!1},errors:o,setState:v}}const u=n.form.createPathState(e,{bails:n.bails,label:n.label,type:n.type,validate:n.validate,schema:n.schema}),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 b(null==r?void 0:r.type)?function(e,n,r){const l=(null==r?void 0:r.standalone)?void 0:_(v),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=>E(e,r)))>=0:E(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=K(s);let h=null!==(v=t.toValue(a))&&void 0!==v?v:m;l&&(null==p?void 0:p.multiple)&&"checkbox"===p.type?h=P(I(l.values,f)||[],h,void 0):"checkbox"===(null==r?void 0:r.type)&&(h=P(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:d,label:m,validateOnValueUpdate:b,uncheckedValue:V,controlled:O,keepValueOnUnmount:j,syncVModel:A,form:F}=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=O?_(v):void 0,k=F||S,w=t.computed((()=>o(t.toValue(e)))),M=t.computed((()=>{if(t.toValue(null==k?void 0:k.schema))return;const e=t.unref(r);return g(e)||y(e)||n(e)||Array.isArray(e)?e:G(e)})),C=!n(M.value)&&y(t.toValue(r)),{id:T,value:P,initialValue:R,meta:N,setState:D,errors:$,flags:q}=ae(w,{modelValue:a,form:k,bails:i,label:m,type:s,validate:M.value&&!C?H:void 0,schema:C?r:void 0}),z=t.computed((()=>$.value[0]));A&&function({prop:e,value:n,handleChange:r,shouldValidate:l}){const a=t.getCurrentInstance();if(!a||!e)return;const u="string"==typeof e?e:"modelValue",i=`update:${u}`;if(!(u in a.props))return;t.watch(n,(e=>{E(e,oe(a,u))||a.emit(i,e)})),t.watch((()=>oe(a,u)),(e=>{if(e===p&&void 0===n.value)return;const t=e===p?void 0:e;E(t,n.value)||r(t,l())}))}({value:P,prop:A,handleChange:J,shouldValidate:()=>b&&!q.pendingReset});async function W(e){var n,r;if(null==k?void 0:k.validateSchema){const{results:r}=await k.validateSchema(e);return null!==(n=r[t.toValue(w)])&&void 0!==n?n:{valid:!0,errors:[]}}return M.value?Z(P.value,M.value,{name:t.toValue(w),label:t.toValue(m),values:null!==(r=null==k?void 0:k.values)&&void 0!==r?r:{},bails:i}):{valid:!0,errors:[]}}const L=U((async()=>(N.pending=!0,N.validated=!0,W("validated-only"))),(e=>(q.pendingUnmount[ne.id]||(D({errors:e.errors}),N.pending=!1,N.valid=e.valid),e))),X=U((async()=>W("silent")),(e=>(N.valid=e.valid,e)));function H(e){return"silent"===(null==e?void 0:e.mode)?X():L()}function J(e,t=!0){ee(K(e),t)}function Q(e){var t;const n=e&&"value"in e?e.value:R.value;D({value:c(n),initialValue:c(n),touched:null!==(t=null==e?void 0:e.touched)&&void 0!==t&&t,errors:(null==e?void 0:e.errors)||[]}),N.pending=!1,N.validated=!1,X()}t.onMounted((()=>{if(u)return L();k&&k.validateSchema||X()}));const Y=t.getCurrentInstance();function ee(e,t=!0){P.value=Y&&A?x(e,Y.props.modelModifiers):e;(t?L:X)()}const te=t.computed({get:()=>P.value,set(e){ee(e,b)}}),ne={id:T,name:w,label:m,value:te,meta:N,errors:$,errorMessage:z,type:s,checkedValue:d,uncheckedValue:V,bails:i,keepValueOnUnmount:j,resetField:Q,handleReset:()=>Q(),validate:H,handleChange:J,handleBlur:(e,t=!1)=>{N.touched=!0,t&&L()},setState:D,setTouched:function(e){N.touched=e},setErrors:function(e){D({errors:Array.isArray(e)?e:[e]})},setValue:ee};if(t.provide(f,ne),t.isRef(r)&&"function"!=typeof t.unref(r)&&t.watch(r,((e,t)=>{E(e,t)||(N.validated?L():X())}),{deep:!0}),!k)return ne;const re=t.computed((()=>{const e=M.value;return!e||n(e)||g(e)||y(e)||Array.isArray(e)?{}:Object.keys(e).reduce(((t,n)=>{const r=(l=e[n],Array.isArray(l)?l.filter(h):B(l).filter((e=>h(l[e]))).map((e=>l[e]))).map((e=>e.__locatorRef)).reduce(((e,t)=>{const n=I(k.values,t)||k.values[t];return void 0!==n&&(e[t]=n),e}),{});var l;return Object.assign(t,r),t}),{})}));return t.watch(re,((e,t)=>{if(!Object.keys(e).length)return;!E(e,t)&&(N.validated?L():X())})),t.onBeforeUnmount((()=>{var e;const n=null!==(e=t.toValue(ne.keepValueOnUnmount))&&void 0!==e?e:t.toValue(k.keepValuesOnUnmount),r=t.toValue(w);if(n||!k||q.pendingUnmount[ne.id])return void(null==k||k.removePathState(r,T));q.pendingUnmount[ne.id]=!0;const l=k.getPathState(r);if(Array.isArray(null==l?void 0:l.id)&&(null==l?void 0:l.multiple)?null==l?void 0:l.id.includes(ne.id):(null==l?void 0:l.id)===ne.id){if((null==l?void 0:l.multiple)&&Array.isArray(l.value)){const e=l.value.findIndex((e=>E(e,t.toValue(ne.checkedValue))));if(e>-1){const t=[...l.value];t.splice(e,1),k.setFieldValue(r,t)}Array.isArray(l.id)&&l.id.splice(l.id.indexOf(ne.id),1)}else k.unsetPathValue(t.toValue(w));k.removePathState(r,T)}})),ne}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 b(t.attrs.type)?S(e,"modelValue")?e.modelValue:void 0:S(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:p},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:y,meta:g,checked:V,setErrors:O}=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:e.validateOnModelUpdate,keepValueOnUnmount:o,syncVModel:!0}),A=function(e,t=!0){f(e,t)},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);b(r.attrs.type)&&V&&(t.checked=V.value);return j(se(e,r),r.attrs)&&(t.value=d.value),t})),E=t.computed((()=>Object.assign(Object.assign({},F.value),{modelValue:d.value})));function k(){return{field:S.value,componentField:E.value,value:d.value,meta:g,errors:s.value,errorMessage:c.value,validate:v,resetField:h,handleChange:A,handleInput:e=>A(e,!1),handleReset:y,handleBlur:F.value.onBlur,setTouched:m,setErrors:O}}return r.expose({value:d,meta:g,errors:s,errorMessage:c,setErrors:O,setTouched:m,reset:h,validate:v,handleChange:f}),()=>{const n=t.resolveDynamicComponent(se(e,r)),l=z(n,r,k);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=(null==e?void 0:e.initialValues)||{},l=Object.assign({},t.toValue(r)),a=t.unref(null==e?void 0:e.validationSchema);return a&&y(a)&&n(a.cast)?c(a.cast(l)||{}):c(l)}function me(e){var r;const l=ve++;let a=0;const u=t.ref(!1),s=t.ref(!1),d=t.ref(0),f=[],p=t.reactive(pe(e)),m=t.ref([]),h=t.ref({}),b=t.ref({}),V=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)))}}((()=>{b.value=m.value.reduce(((e,n)=>(e[o(t.toValue(n.path))]=n,e)),{})}));function O(e,t){const n=Y(e);if(n){if("string"==typeof e){const t=o(e);h.value[t]&&delete h.value[t]}n.errors=D(t),n.valid=!n.errors.length}else"string"==typeof e&&(h.value[o(e)]=D(t))}function j(e){B(e).forEach((t=>{O(t,e[t])}))}(null==e?void 0:e.initialErrors)&&j(e.initialErrors);const F=t.computed((()=>{const e=m.value.reduce(((e,t)=>(t.errors.length&&(e[t.path]=t.errors),e)),{});return Object.assign(Object.assign({},h.value),e)})),S=t.computed((()=>B(F.value).reduce(((e,t)=>{const n=F.value[t];return(null==n?void 0:n.length)&&(e[t]=n[0]),e}),{}))),k=t.computed((()=>m.value.reduce(((e,t)=>(e[t.path]={name:t.path||"",label:t.label||""},e)),{}))),w=t.computed((()=>m.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)||{}),_=null!==(r=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==r&&r,{initialValues:P,originalInitialValues:x,setInitialValues:N}=function(e,n,r){const l=pe(r),a=t.ref(l),u=t.ref(c(l));function o(t,r=!1){a.value=i(c(a.value)||{},c(t)),u.value=i(c(u.value)||{},c(t)),r&&e.value.forEach((e=>{if(e.touched)return;const t=I(a.value,e.path);M(n,e.path,c(t))}))}return{initialValues:a,originalInitialValues:u,setInitialValues:o}}(m,p,e),$=function(e,n,r,l){const a={touched:"some",pending:"some",valid:"every"},u=t.computed((()=>!E(n,t.unref(r))));function i(){const t=e.value;return B(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&&!B(l.value).length,dirty:u.value})))}(m,p,x,S),z=t.computed((()=>m.value.reduce(((e,t)=>{const n=I(p,t.path);return M(e,t.path,n),e}),{}))),W=null==e?void 0:e.validationSchema;function L(e,n){var r,l;const u=t.computed((()=>I(P.value,t.toValue(e)))),i=b.value[t.toValue(e)],o="checkbox"===(null==n?void 0:n.type)||"radio"===(null==n?void 0:n.type);if(i&&o){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 s=t.computed((()=>I(p,t.toValue(e)))),d=t.toValue(e),v=te.findIndex((e=>e===d));-1!==v&&te.splice(v,1);const f=t.computed((()=>{var r,l,a,u;const i=t.toValue(W);if(y(i))return null!==(l=null===(r=i.describe)||void 0===r?void 0:r.call(i,t.toValue(e)).required)&&void 0!==l&&l;const o=t.toValue(null==n?void 0:n.schema);return!!y(o)&&(null!==(u=null===(a=o.describe)||void 0===a?void 0:a.call(o).required)&&void 0!==u&&u)})),h=a++,g=t.reactive({id:h,path:e,touched:!1,pending:!1,valid:!0,validated:!!(null===(r=C[d])||void 0===r?void 0:r.length),required:f,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:s,multiple:!1,__flags:{pendingUnmount:{[h]:!1},pendingReset:!1},fieldsCount:1,validate:null==n?void 0:n.validate,dirty:t.computed((()=>!E(t.unref(s),t.unref(u))))});return m.value.push(g),b.value[d]=g,V(),S.value[d]&&!C[d]&&t.nextTick((()=>{ye(d,{mode:"silent"})})),t.isRef(e)&&t.watch(e,(e=>{V();const n=c(s.value);b.value[e]=g,t.nextTick((()=>{M(p,e,n)}))})),g}const G=R(Ve,5),X=R(Ve,5),H=U((async e=>await("silent"===e?G():X())),((e,[n])=>{const r=B(ae.errorBag.value),l=[...new Set([...B(e.results),...m.value.map((e=>e.path)),...r])].sort().reduce(((r,l)=>{var a;const u=l,i=Y(u)||function(e){const t=m.value.filter((t=>e.startsWith(t.path)));return t.reduce(((e,t)=>e?t.path.length>e.path.length?t:e:t),void 0)}(u),o=(null===(a=e.results[u])||void 0===a?void 0:a.errors)||[],s=t.toValue(null==i?void 0:i.path)||u,d=function(e,t){if(!t)return e;return{valid:e.valid&&t.valid,errors:[...e.errors,...t.errors]}}({errors:o,valid:!o.length},r.results[s]);return r.results[s]=d,d.valid||(r.errors[s]=d.errors[0]),i&&h.value[s]&&delete h.value[s],i?(i.valid=d.valid,"silent"===n?r:"validated-only"!==n||i.validated?(O(i,d.errors),r):r):(O(s,o),r)}),{valid:e.valid,results:{},errors:{}});return e.values&&(l.values=e.values),B(l.results).forEach((e=>{var t;const r=Y(e);r&&"silent"!==n&&("validated-only"!==n||r.validated)&&O(r,null===(t=l.results[e])||void 0===t?void 0:t.errors)})),l}));function J(e){m.value.forEach(e)}function Y(e){const t="string"==typeof e?o(e):e;return"string"==typeof t?b.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,d.value++,he().then((l=>{const a=c(p);if(l.valid&&"function"==typeof t){const n=c(z.value);let u=e?n:a;return l.values&&(u=l.values),t(u,{evt:r,controlledValues:n,setErrors:j,setFieldError:O,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:p,controlledValues:z,errorBag:F,errors:S,schema:W,submitCount:d,meta:$,isSubmitting:u,isValidating:s,fieldArrays:f,keepValuesOnUnmount:_,validateSchema:t.unref(W)?H:void 0,validate:he,setFieldError:O,validateField:ye,setFieldValue:ue,setValues:ie,setErrors:j,setFieldTouched:se,setTouched:de,resetForm:me,resetField:ce,handleSubmit:le,useFieldModel:function(e){if(!Array.isArray(e))return oe(e);return e.map((e=>oe(e,!0)))},defineInputBinds:function(e,n){const[r,l]=je(e,n);function a(){l.value.onBlur()}function u(n){const r=K(n);ue(t.toValue(e),r,!1),l.value.onInput()}function i(n){const r=K(n);ue(t.toValue(e),r,!1),l.value.onChange()}return t.computed((()=>Object.assign(Object.assign({},l.value),{onBlur:a,onInput:u,onChange:i,value:r.value})))},defineComponentBinds:function(e,r){const[l,a]=je(e,r),u=Y(t.toValue(e));function i(e){l.value=e}return t.computed((()=>{const e=n(r)?r(q(u,fe)):r||{};return Object.assign({[e.model||"modelValue"]:l.value,[`onUpdate:${e.model||"modelValue"}`]:i},a.value)}))},defineField:je,stageInitialValue:function(t,n,r=!1){be(t,n),M(p,t,n),r&&!(null==e?void 0:e.initialValues)&&M(x.value,t,c(n))},unsetInitialValue:ge,setFieldInitialValue:be,createPathState:L,getPathState:Y,unsetPathValue:function(e){return te.push(e),Z||(Z=t.nextTick((()=>{[...te].sort().reverse().forEach((e=>{T(p,e)})),te=[],Z=null}))),Z},removePathState:function(e,n){const r=m.value.findIndex((t=>t.path===e&&(Array.isArray(t.id)?t.id.includes(n):t.id===n))),l=m.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)&&(m.value.splice(r,1),ge(e),V(),delete b.value[e])}},initialValues:P,getAllPathStates:()=>m.value,destroyPath:function(e){B(b.value).forEach((t=>{t.startsWith(e)&&delete b.value[t]})),m.value=m.value.filter((t=>!t.path.startsWith(e))),t.nextTick((()=>{V()}))},isFieldTouched:function(e){const t=Y(e);if(t)return t.touched;return m.value.filter((t=>t.path.startsWith(e))).some((e=>e.touched))},isFieldDirty:function(e){const t=Y(e);if(t)return t.dirty;return m.value.filter((t=>t.path.startsWith(e))).some((e=>e.dirty))},isFieldValid:function(e){const t=Y(e);if(t)return t.valid;return m.value.filter((t=>t.path.startsWith(e))).every((e=>e.valid))}};function ue(e,t,n=!0){const r=c(t),l="string"==typeof e?e:e.path;Y(l)||L(l),M(p,l,r),n&&ye(l)}function ie(e,t=!0){i(p,e),f.forEach((e=>e&&e.reset())),t&&he()}function oe(e,n){const r=Y(t.toValue(e))||L(e);return t.computed({get:()=>r.value,set(r){var l;ue(t.toValue(e),r,null!==(l=t.toValue(n))&&void 0!==l&&l)}})}function se(e,t){const n=Y(e);n&&(n.touched=t)}function de(e){"boolean"!=typeof e?B(e).forEach((t=>{se(t,!!e[t])})):J((t=>{t.touched=e}))}function ce(e,n){var r;const l=n&&"value"in n?n.value:I(P.value,e),a=Y(e);a&&(a.__flags.pendingReset=!0),be(e,c(l),!0),ue(e,l,!1),se(e,null!==(r=null==n?void 0:n.touched)&&void 0!==r&&r),O(e,(null==n?void 0:n.errors)||[]),t.nextTick((()=>{a&&(a.__flags.pendingReset=!1)}))}function me(e,r){let l=c((null==e?void 0:e.values)?e.values:x.value);l=(null==r?void 0:r.force)?l:i(x.value,l),l=y(W)&&n(W.cast)?W.cast(l):l,N(l),J((t=>{var n;t.__flags.pendingReset=!0,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(l,t.path),!1),O(t.path,void 0)})),(null==r?void 0:r.force)?function(e,t=!0){B(p).forEach((e=>{delete p[e]})),B(e).forEach((t=>{ue(t,e[t],!1)})),t&&he()}(l,!1):ie(l,!1),j((null==e?void 0:e.errors)||{}),d.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{he({mode:"silent"}),J((e=>{e.__flags.pendingReset=!1}))}))}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(m.value.map((t=>t.validate?t.validate(e).then((e=>({key:t.path,valid:e.valid,errors:e.errors}))):Promise.resolve({key:t.path,valid:!0,errors:[]}))));s.value=!1;const r={},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&&"silent"!==(null==t?void 0:t.mode)&&(n.validated=!0),W){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){T(P.value,e)}function be(e,t,n=!1){M(P.value,e,c(t)),n&&M(x.value,e,c(t))}async function Ve(){const e=t.unref(W);if(!e)return{valid:!0,results:{},errors:{}};s.value=!0;const n=g(e)||y(e)?await async function(e,t){const n=y(e)?e:ee(e),r=await n.parse(c(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,p):await re(e,p,{names:k.value,bailsMap:w.value});return s.value=!1,n}const Oe=le(((e,{evt:t})=>{A(t)&&t.target.submit()}));function je(e,r){const l=n(r)||null==r?void 0:r.label,a=Y(t.toValue(e))||L(e,{label:l}),u=()=>n(r)?r(q(a,fe)):r||{};function i(){var e;a.touched=!0;(null!==(e=u().validateOnBlur)&&void 0!==e?e:Q().validateOnBlur)&&ye(a.path)}function o(){var e;(null!==(e=u().validateOnInput)&&void 0!==e?e:Q().validateOnInput)&&t.nextTick((()=>{ye(a.path)}))}function s(){var e;(null!==(e=u().validateOnChange)&&void 0!==e?e:Q().validateOnChange)&&t.nextTick((()=>{ye(a.path)}))}const d=t.computed((()=>{const e={onChange:s,onInput:o,onBlur:i};return n(r)?Object.assign(Object.assign({},e),r(q(a,fe)).props||{}):(null==r?void 0:r.props)?Object.assign(Object.assign({},e),r.props(q(a,fe))):e})),c=oe(e,(()=>{var e,t,n;return null===(n=null!==(e=u().validateOnModelUpdate)&&void 0!==e?e:null===(t=Q())||void 0===t?void 0:t.validateOnModelUpdate)||void 0===n||n}));return[c,d]}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(W)&&t.watch(W,(()=>{var e;null===(e=ae.validateSchema)||void 0===e||e.call(ae,"validated-only")})),t.provide(v,ae),Object.assign(Object.assign({},ae),{values:t.readonly(p),handleReset:()=>me(),submitForm:Oe})}const he=t.defineComponent({name:"Form",inheritAttrs:!1,props:{as:{type:null,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,"validationSchema"),l=t.toRef(e,"keepValues"),{errors:a,errorBag:u,values:i,meta:o,isSubmitting:s,isValidating:d,submitCount:v,controlledValues:f,validate:p,validateField:m,handleReset:h,resetForm:y,handleSubmit:g,setErrors:b,setFieldError:V,setFieldValue:O,setValues:j,setFieldTouched:S,setTouched:E,resetField:k}=me({validationSchema:r.value?r:void 0,initialValues:e.initialValues,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:l}),w=g(((e,{evt:t})=>{A(t)&&t.target.submit()}),e.onInvalidSubmit),I=e.onSubmit?g(e.onSubmit,e.onInvalidSubmit):w;function M(e){F(e)&&e.preventDefault(),h(),"function"==typeof n.attrs.onReset&&n.attrs.onReset()}function C(t,n){return g("function"!=typeof t||n?n:t,e.onInvalidSubmit)(t)}function T(){return c(i)}function B(){return c(o.value)}function _(){return c(a.value)}function P(){return{meta:o.value,errors:a.value,errorBag:u.value,values:i,isSubmitting:s.value,isValidating:d.value,submitCount:v.value,controlledValues:f.value,validate:p,validateField:m,handleSubmit:C,handleReset:h,submitForm:w,setErrors:b,setFieldError:V,setFieldValue:O,setValues:j,setFieldTouched:S,setTouched:E,resetForm:y,resetField:k,getValues:T,getMeta:B,getErrors:_}}return n.expose({setFieldError:V,setErrors:b,setFieldValue:O,setValues:j,setFieldTouched:S,setTouched:E,resetForm:y,validate:p,validateField:m,resetField:k,getValues:T,getMeta:B,getErrors:_,values:i,meta:o,errors:a}),function(){const r="form"===e.as?e.as:e.as?t.resolveDynamicComponent(e.as):null,l=z(r,n,P);if(!r)return l;const a="form"===r?{novalidate:!0}:{};return t.h(r,Object.assign(Object.assign(Object.assign({},a),n.attrs),{onSubmit:I,onReset:M}),l)}}}),ye=he;function ge(e){const n=_(v,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.toValue(e),[])||[]}function d(){const e=s();Array.isArray(e)&&(l.value=e.map(((e,t)=>p(e,t,l.value))),f())}function f(){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 p(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.toValue(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&&h(t,e)}}),isFirst:!1,isLast:!1};return d}function m(){f(),null==n||n.validate({mode:"silent"})}function h(r,l){const a=t.toValue(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"}))}d();const y={fields:l,remove:function(r){const a=t.toValue(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.destroyPath(o),n.unsetInitialValue(o),M(n.values,a,i),l.value.splice(r,1),m()},push:function(a){const u=c(a),i=t.toValue(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(p(u)),m()},swap:function(r,a){const u=t.toValue(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,f()},insert:function(r,a){const u=c(a),i=t.toValue(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,p(u)),M(n.values,i,s),l.value=d,m()},update:h,replace:function(r){const l=t.toValue(e);n.stageInitialValue(l,r),M(n.values,l,r),d(),m()},prepend:function(a){const u=c(a),i=t.toValue(e),o=I(null==n?void 0:n.values,i),s=r(o)?[]:o;if(!Array.isArray(s))return;const d=[u,...s];M(n.values,i,d),n.stageInitialValue(i+"[0]",u),l.value.unshift(p(u)),m()},move:function(a,u){const i=t.toValue(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,m()}};return n.fieldArrays.push(Object.assign({path:e,reset:d},y)),t.onBeforeUnmount((()=>{const r=n.fieldArrays.findIndex((n=>t.toValue(n.path)===t.toValue(e)));r>=0&&n.fieldArrays.splice(r,1)})),t.watch(s,(e=>{E(e,l.value.map((e=>e.value)))||d()})),y}const be=t.defineComponent({name:"FieldArray",inheritAttrs:!1,props:{name:{type:String,required:!0}},setup(e,t){const{push:n,remove:r,swap:l,insert:a,replace:u,update:i,prepend:o,move:s,fields:d}=ge((()=>e.name));function c(){return{fields:d.value,push:n,remove:r,swap:l,insert:a,update:i,replace:u,prepend:o,move:s}}return t.expose({push:n,remove:r,swap:l,insert:a,update:i,replace:u,prepend:o,move:s}),()=>z(void 0,t,c)}}),Ve=t.defineComponent({name:"ErrorMessage",props:{as:{type:String,default:void 0},name:{type:String,required:!0}},setup(e,n){const r=t.inject(v,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=z(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=f,e.Form=ye,e.FormContextKey=v,e.IS_ABSENT=p,e.cleanupNonNestedPath=w,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.isNotNestedPath=V,e.normalizeRules=G,e.useField=ue,e.useFieldArray=ge,e.useFieldError=function(e){const n=_(v),r=e?void 0:t.inject(f);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=_(v),r=e?void 0:t.inject(f);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=_(v);return t.computed((()=>(null==e?void 0:e.errors.value)||{}))},e.useFormValues=function(){const e=_(v);return t.computed((()=>(null==e?void 0:e.values)||{}))},e.useIsFieldDirty=function(e){const n=$(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=$(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=$(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=_(v);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=_(v);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=_(v);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=_(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isSubmitting.value)&&void 0!==t&&t}))},e.useIsValidating=function(){const e=_(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isValidating.value)&&void 0!==t&&t}))},e.useResetForm=function(){const e=_(v);return function(t){if(e)return e.resetForm(t)}},e.useSetFieldError=function(e){const n=_(v),r=e?void 0:t.inject(f);return function(l){e&&n?n.setFieldError(t.toValue(e),l):r&&r.setErrors(l||[])}},e.useSetFieldTouched=function(e){const n=_(v),r=e?void 0:t.inject(f);return function(l){e&&n?n.setFieldTouched(t.toValue(e),l):r&&r.setTouched(l)}},e.useSetFieldValue=function(e){const n=_(v),r=e?void 0:t.inject(f);return function(l,a=!0){e&&n?n.setFieldValue(t.toValue(e),l,a):r&&r.setValue(l,a)}},e.useSetFormErrors=function(){const e=_(v);return function(t){e&&e.setErrors(t)}},e.useSetFormTouched=function(){const e=_(v);return function(t){e&&e.setTouched(t)}},e.useSetFormValues=function(){const e=_(v);return function(t,n=!0){e&&e.setValues(t,n)}},e.useSubmitCount=function(){const e=_(v);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=_(v),n=t?t.handleSubmit(e):void 0;return function(e){if(n)return n(e)}},e.useValidateField=function(e){const n=_(v),r=e?void 0:t.inject(f);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=_(v);return function(){return e?e.validate():Promise.resolve({results:{},errors:{},valid:!0})}},e.validate=Z,e.validateObject=re}));
6
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VeeValidate={},e.Vue)}(this,(function(e,t){"use strict";function n(e){return"function"==typeof e}function r(e){return null==e}const 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])&&u(e[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={};function d(e,t,n){"object"==typeof n.value&&(n.value=c(n.value)),n.enumerable&&!n.get&&!n.set&&n.configurable&&n.writable&&"__proto__"!==t?e[t]=n.value:Object.defineProperty(e,t,n)}function c(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(c(e))}))):"[object Map]"===a?(r=new Map,e.forEach((function(e,t){r.set(c(t),c(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(c(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++)d(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]||d(r,t,Object.getOwnPropertyDescriptor(e,t))}return r||e}const v=Symbol("vee-validate-form"),f=Symbol("vee-validate-field-instance"),p=Symbol("Default empty value"),m="undefined"!=typeof window;function h(e){return n(e)&&!!e.__locatorRef}function y(e){return!!e&&n(e.parse)&&"VVTypedSchema"===e.__type}function g(e){return!!e&&n(e.validate)}function b(e){return"checkbox"===e||"radio"===e}function V(e){return/^\[.+\]$/i.test(e)}function O(e){return"SELECT"===e.tagName}function j(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&&!b(t.type)}function A(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 S(e,t){return t in e&&e[t]!==p}function E(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(!E(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(!E(r[1],t.get(r[0])))return!1;return!0}if(k(e)&&k(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(!E(e[a],t[a]))return!1}return!0}return e!=e&&t!=t}function k(e){return!!m&&e instanceof File}function w(e){return V(e)?e.replace(/\[|\]/gi,""):e}function I(e,t,n){if(!e)return n;if(V(t))return e[w(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(V(t))return void(e[w(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 T(e,t){if(V(t))return void delete e[w(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 B(e){return Object.keys(e)}function _(e,n=void 0){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function P(e,t,n){if(Array.isArray(e)){const n=[...e],r=n.findIndex((e=>E(e,t)));return r>=0?n.splice(r,1):n.push(t),n}return E(e,t)?n:t}function x(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 U(e,t){let n;return async function(...r){const l=e(...r);n=l;const a=await l;return l!==n?a:(n=void 0,t(a,r))}}function N({get:e,set:n}){const r=t.ref(c(e()));return t.watch(e,(e=>{E(e,r.value)||(r.value=c(e))}),{deep:!0}),t.watch(r,(t=>{E(t,e())||n(c(t))}),{deep:!0}),r}function D(e){return Array.isArray(e)?e:e?[e]:[]}function $(e){const n=_(v),r=e?t.computed((()=>null==n?void 0:n.getPathState(t.toValue(e)))):void 0,l=e?void 0:t.inject(f);return!l&&(null==r||r.value),r||l}function q(e,t){const n={};for(const r in e)t.includes(r)||(n[r]=e[r]);return n}function z(e,t,n){return 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 W(e){if(L(e))return e._value}function L(e){return"_value"in e}function K(e){if(!F(e))return e;const t=e.target;if(b(t.type)&&L(t))return W(t);if("file"===t.type&&t.files){const e=Array.from(t.files);return t.multiple?e:e[0]}if(O(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map(W);var n;if(O(t)){const e=Array.from(t.options).find((e=>e.selected));return e?W(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){const r=e.rules;if(y(r)||g(r))return async function(e,t){const n=y(t.rules)?t.rules:ee(t.rules),r=await n.parse(e,{formData:t.formData}),l=[];for(const e of r.errors)e.errors.length&&l.push(...e.errors);return{value:r.value,errors:l}}(t,Object.assign(Object.assign({},e),{rules:r}));if(n(r)||Array.isArray(r)){const n={field:e.label||e.name,name:e.name,label:e.label,form:e.formData,value:t},l=Array.isArray(r)?r:[r],a=l.length,u=[];for(let r=0;r<a;r++){const a=l[r],i=await a(t,n);if(!("string"!=typeof i&&!Array.isArray(i)&&i)){if(Array.isArray(i))u.push(...i);else{const e="string"==typeof i?i:ne(n);u.push(e)}if(e.bails)return{errors:u}}}return{errors:u}}const l=Object.assign(Object.assign({},e),{rules:G(r)}),a=[],u=Object.keys(l.rules),i=u.length;for(let n=0;n<i;n++){const r=u[n],i=await te(l,t,{name:r,params:l.rules[r]});if(i.error&&(a.push(i.error),e.bails))return{errors:a}}return{errors:a}}(a,e);return Object.assign(Object.assign({},u),{valid:!u.errors.length})}function ee(e){return{__type:"VVTypedSchema",async parse(t,n){var r;try{return{output:await e.validate(t,{abortEarly:!1,context:(null==n?void 0:n.formData)||{}}),errors:[]}}catch(e){if(!function(e){return!!e&&"ValidationError"===e.name}(e))throw e;if(!(null===(r=e.inner)||void 0===r?void 0:r.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=>h(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=B(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,source:"schema"}}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.setFieldInitialValue(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=D(t)}}}(),d=le>=Number.MAX_SAFE_INTEGER?0:++le,c=function(e,n,r,l){const a=t.computed((()=>{var e,n,r;return null!==(r=null===(n=null===(e=t.toValue(l))||void 0===e?void 0:e.describe)||void 0===n?void 0:n.call(e).required)&&void 0!==r&&r})),u=t.reactive({touched:!1,pending:!1,valid:!0,required:a,validated:!!t.unref(r).length,initialValue:t.computed((()=>t.unref(n))),dirty:t.computed((()=>!E(t.unref(e),t.unref(n))))});return t.watch(r,(e=>{u.valid=!e.length}),{immediate:!0,flush:"sync"}),u}(r,l,o,n.schema);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},pendingReset:!1},errors:o,setState:v}}const u=n.form.createPathState(e,{bails:n.bails,label:n.label,type:n.type,validate:n.validate,schema:n.schema}),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 b(null==r?void 0:r.type)?function(e,n,r){const l=(null==r?void 0:r.standalone)?void 0:_(v),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=>E(e,r)))>=0:E(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=K(s);let h=null!==(v=t.toValue(a))&&void 0!==v?v:m;l&&(null==p?void 0:p.multiple)&&"checkbox"===p.type?h=P(I(l.values,f)||[],h,void 0):"checkbox"===(null==r?void 0:r.type)&&(h=P(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:d,label:m,validateOnValueUpdate:b,uncheckedValue:V,controlled:O,keepValueOnUnmount:j,syncVModel:A,form:F}=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=O?_(v):void 0,k=F||S,w=t.computed((()=>o(t.toValue(e)))),M=t.computed((()=>{if(t.toValue(null==k?void 0:k.schema))return;const e=t.unref(r);return g(e)||y(e)||n(e)||Array.isArray(e)?e:G(e)})),C=!n(M.value)&&y(t.toValue(r)),{id:T,value:P,initialValue:x,meta:N,setState:D,errors:$,flags:q}=ae(w,{modelValue:a,form:k,bails:i,label:m,type:s,validate:M.value?H:void 0,schema:C?r:void 0}),z=t.computed((()=>$.value[0]));A&&function({prop:e,value:n,handleChange:r,shouldValidate:l}){const a=t.getCurrentInstance();if(!a||!e)return;const u="string"==typeof e?e:"modelValue",i=`update:${u}`;if(!(u in a.props))return;t.watch(n,(e=>{E(e,oe(a,u))||a.emit(i,e)})),t.watch((()=>oe(a,u)),(e=>{if(e===p&&void 0===n.value)return;const t=e===p?void 0:e;E(t,n.value)||r(t,l())}))}({value:P,prop:A,handleChange:J,shouldValidate:()=>b&&!q.pendingReset});async function W(e){var n,r;if(null==k?void 0:k.validateSchema){const{results:r}=await k.validateSchema(e);return null!==(n=r[t.toValue(w)])&&void 0!==n?n:{valid:!0,errors:[]}}return M.value?Z(P.value,M.value,{name:t.toValue(w),label:t.toValue(m),values:null!==(r=null==k?void 0:k.values)&&void 0!==r?r:{},bails:i}):{valid:!0,errors:[]}}const L=U((async()=>(N.pending=!0,N.validated=!0,W("validated-only"))),(e=>(q.pendingUnmount[ne.id]||(D({errors:e.errors}),N.pending=!1,N.valid=e.valid),e))),X=U((async()=>W("silent")),(e=>(N.valid=e.valid,e)));function H(e){return"silent"===(null==e?void 0:e.mode)?X():L()}function J(e,t=!0){ee(K(e),t)}function Q(e){var t;const n=e&&"value"in e?e.value:x.value;D({value:c(n),initialValue:c(n),touched:null!==(t=null==e?void 0:e.touched)&&void 0!==t&&t,errors:(null==e?void 0:e.errors)||[]}),N.pending=!1,N.validated=!1,X()}t.onMounted((()=>{if(u)return L();k&&k.validateSchema||X()}));const Y=t.getCurrentInstance();function ee(e,t=!0){P.value=Y&&A?R(e,Y.props.modelModifiers):e;(t?L:X)()}const te=t.computed({get:()=>P.value,set(e){ee(e,b)}}),ne={id:T,name:w,label:m,value:te,meta:N,errors:$,errorMessage:z,type:s,checkedValue:d,uncheckedValue:V,bails:i,keepValueOnUnmount:j,resetField:Q,handleReset:()=>Q(),validate:H,handleChange:J,handleBlur:(e,t=!1)=>{N.touched=!0,t&&L()},setState:D,setTouched:function(e){N.touched=e},setErrors:function(e){D({errors:Array.isArray(e)?e:[e]})},setValue:ee};if(t.provide(f,ne),t.isRef(r)&&"function"!=typeof t.unref(r)&&t.watch(r,((e,t)=>{E(e,t)||(N.validated?L():X())}),{deep:!0}),!k)return ne;const re=t.computed((()=>{const e=M.value;return!e||n(e)||g(e)||y(e)||Array.isArray(e)?{}:Object.keys(e).reduce(((t,n)=>{const r=(l=e[n],Array.isArray(l)?l.filter(h):B(l).filter((e=>h(l[e]))).map((e=>l[e]))).map((e=>e.__locatorRef)).reduce(((e,t)=>{const n=I(k.values,t)||k.values[t];return void 0!==n&&(e[t]=n),e}),{});var l;return Object.assign(t,r),t}),{})}));return t.watch(re,((e,t)=>{if(!Object.keys(e).length)return;!E(e,t)&&(N.validated?L():X())})),t.onBeforeUnmount((()=>{var e;const n=null!==(e=t.toValue(ne.keepValueOnUnmount))&&void 0!==e?e:t.toValue(k.keepValuesOnUnmount),r=t.toValue(w);if(n||!k||q.pendingUnmount[ne.id])return void(null==k||k.removePathState(r,T));q.pendingUnmount[ne.id]=!0;const l=k.getPathState(r);if(Array.isArray(null==l?void 0:l.id)&&(null==l?void 0:l.multiple)?null==l?void 0:l.id.includes(ne.id):(null==l?void 0:l.id)===ne.id){if((null==l?void 0:l.multiple)&&Array.isArray(l.value)){const e=l.value.findIndex((e=>E(e,t.toValue(ne.checkedValue))));if(e>-1){const t=[...l.value];t.splice(e,1),k.setFieldValue(r,t)}Array.isArray(l.id)&&l.id.splice(l.id.indexOf(ne.id),1)}else k.unsetPathValue(t.toValue(w));k.removePathState(r,T)}})),ne}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 b(t.attrs.type)?S(e,"modelValue")?e.modelValue:void 0:S(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:p},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:y,meta:g,checked:V,setErrors:O,setValue:A}=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:e.validateOnModelUpdate,keepValueOnUnmount:o,syncVModel:!0}),F=function(e,t=!0){f(e,t)},S=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){F(e,t),n(r.attrs.onInput)&&r.attrs.onInput(e)},onChange:function(e){F(e,l),n(r.attrs.onChange)&&r.attrs.onChange(e)},"onUpdate:modelValue":e=>F(e,u)};return i})),E=t.computed((()=>{const t=Object.assign({},S.value);b(r.attrs.type)&&V&&(t.checked=V.value);return j(se(e,r),r.attrs)&&(t.value=d.value),t})),k=t.computed((()=>Object.assign(Object.assign({},S.value),{modelValue:d.value})));function w(){return{field:E.value,componentField:k.value,value:d.value,meta:g,errors:s.value,errorMessage:c.value,validate:v,resetField:h,handleChange:F,handleInput:e=>F(e,!1),handleReset:y,handleBlur:S.value.onBlur,setTouched:m,setErrors:O,setValue:A}}return r.expose({value:d,meta:g,errors:s,errorMessage:c,setErrors:O,setTouched:m,setValue:A,reset:h,validate:v,handleChange:f}),()=>{const n=t.resolveDynamicComponent(se(e,r)),l=z(n,r,w);return n?t.h(n,Object.assign(Object.assign({},r.attrs),E.value),l):l}}});let ve=0;const fe=["bails","fieldsCount","id","multiple","type","validate"];function pe(e){const r=(null==e?void 0:e.initialValues)||{},l=Object.assign({},t.toValue(r)),a=t.unref(null==e?void 0:e.validationSchema);return a&&y(a)&&n(a.cast)?c(a.cast(l)||{}):c(l)}function me(e){var r;const l=ve++;let a=0;const u=t.ref(!1),s=t.ref(!1),d=t.ref(0),f=[],p=t.reactive(pe(e)),m=t.ref([]),h=t.ref({}),b=t.ref({}),V=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)))}}((()=>{b.value=m.value.reduce(((e,n)=>(e[o(t.toValue(n.path))]=n,e)),{})}));function O(e,t){const n=Y(e);if(n){if("string"==typeof e){const t=o(e);h.value[t]&&delete h.value[t]}n.errors=D(t),n.valid=!n.errors.length}else"string"==typeof e&&(h.value[o(e)]=D(t))}function j(e){B(e).forEach((t=>{O(t,e[t])}))}(null==e?void 0:e.initialErrors)&&j(e.initialErrors);const F=t.computed((()=>{const e=m.value.reduce(((e,t)=>(t.errors.length&&(e[t.path]=t.errors),e)),{});return Object.assign(Object.assign({},h.value),e)})),S=t.computed((()=>B(F.value).reduce(((e,t)=>{const n=F.value[t];return(null==n?void 0:n.length)&&(e[t]=n[0]),e}),{}))),k=t.computed((()=>m.value.reduce(((e,t)=>(e[t.path]={name:t.path||"",label:t.label||""},e)),{}))),w=t.computed((()=>m.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)||{}),_=null!==(r=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==r&&r,{initialValues:P,originalInitialValues:R,setInitialValues:N}=function(e,n,r){const l=pe(r),a=t.ref(l),u=t.ref(c(l));function o(t,r){(null==r?void 0:r.force)?(a.value=c(t),u.value=c(t)):(a.value=i(c(a.value)||{},c(t)),u.value=i(c(u.value)||{},c(t))),(null==r?void 0:r.updateFields)&&e.value.forEach((e=>{if(e.touched)return;const t=I(a.value,e.path);M(n,e.path,c(t))}))}return{initialValues:a,originalInitialValues:u,setInitialValues:o}}(m,p,e),$=function(e,n,r,l){const a={touched:"some",pending:"some",valid:"every"},u=t.computed((()=>!E(n,t.unref(r))));function i(){const t=e.value;return B(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&&!B(l.value).length,dirty:u.value})))}(m,p,R,S),z=t.computed((()=>m.value.reduce(((e,t)=>{const n=I(p,t.path);return M(e,t.path,n),e}),{}))),W=null==e?void 0:e.validationSchema;function L(e,n){var r,l;const u=t.computed((()=>I(P.value,t.toValue(e)))),i=b.value[t.toValue(e)],o="checkbox"===(null==n?void 0:n.type)||"radio"===(null==n?void 0:n.type);if(i&&o){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 s=t.computed((()=>I(p,t.toValue(e)))),d=t.toValue(e),v=te.findIndex((e=>e===d));-1!==v&&te.splice(v,1);const f=t.computed((()=>{var r,l,a,u;const i=t.toValue(W);if(y(i))return null!==(l=null===(r=i.describe)||void 0===r?void 0:r.call(i,t.toValue(e)).required)&&void 0!==l&&l;const o=t.toValue(null==n?void 0:n.schema);return!!y(o)&&(null!==(u=null===(a=o.describe)||void 0===a?void 0:a.call(o).required)&&void 0!==u&&u)})),h=a++,g=t.reactive({id:h,path:e,touched:!1,pending:!1,valid:!0,validated:!!(null===(r=C[d])||void 0===r?void 0:r.length),required:f,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:s,multiple:!1,__flags:{pendingUnmount:{[h]:!1},pendingReset:!1},fieldsCount:1,validate:null==n?void 0:n.validate,dirty:t.computed((()=>!E(t.unref(s),t.unref(u))))});return m.value.push(g),b.value[d]=g,V(),S.value[d]&&!C[d]&&t.nextTick((()=>{ye(d,{mode:"silent"})})),t.isRef(e)&&t.watch(e,(e=>{V();const n=c(s.value);b.value[e]=g,t.nextTick((()=>{M(p,e,n)}))})),g}const G=x(Ve,5),X=x(Ve,5),H=U((async e=>await("silent"===e?G():X())),((e,[n])=>{const r=B(ae.errorBag.value),l=[...new Set([...B(e.results),...m.value.map((e=>e.path)),...r])].sort().reduce(((r,l)=>{var a;const u=l,i=Y(u)||function(e){const t=m.value.filter((t=>e.startsWith(t.path)));return t.reduce(((e,t)=>e?t.path.length>e.path.length?t:e:t),void 0)}(u),o=(null===(a=e.results[u])||void 0===a?void 0:a.errors)||[],s=t.toValue(null==i?void 0:i.path)||u,d=function(e,t){if(!t)return e;return{valid:e.valid&&t.valid,errors:[...e.errors,...t.errors]}}({errors:o,valid:!o.length},r.results[s]);return r.results[s]=d,d.valid||(r.errors[s]=d.errors[0]),i&&h.value[s]&&delete h.value[s],i?(i.valid=d.valid,"silent"===n?r:"validated-only"!==n||i.validated?(O(i,d.errors),r):r):(O(s,o),r)}),{valid:e.valid,results:{},errors:{},source:e.source});return e.values&&(l.values=e.values,l.source=e.source),B(l.results).forEach((e=>{var t;const r=Y(e);r&&"silent"!==n&&("validated-only"!==n||r.validated)&&O(r,null===(t=l.results[e])||void 0===t?void 0:t.errors)})),l}));function J(e){m.value.forEach(e)}function Y(e){const t="string"==typeof e?o(e):e;return"string"==typeof t?b.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,d.value++,he().then((l=>{const a=c(p);if(l.valid&&"function"==typeof t){const n=c(z.value);let u=e?n:a;return l.values&&(u="schema"===l.source?l.values:Object.assign({},u,l.values)),t(u,{evt:r,controlledValues:n,setErrors:j,setFieldError:O,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:p,controlledValues:z,errorBag:F,errors:S,schema:W,submitCount:d,meta:$,isSubmitting:u,isValidating:s,fieldArrays:f,keepValuesOnUnmount:_,validateSchema:t.unref(W)?H:void 0,validate:he,setFieldError:O,validateField:ye,setFieldValue:ue,setValues:ie,setErrors:j,setFieldTouched:se,setTouched:de,resetForm:me,resetField:ce,handleSubmit:le,useFieldModel:function(e){if(!Array.isArray(e))return oe(e);return e.map((e=>oe(e,!0)))},defineInputBinds:function(e,n){const[r,l]=je(e,n);function a(){l.value.onBlur()}function u(n){const r=K(n);ue(t.toValue(e),r,!1),l.value.onInput()}function i(n){const r=K(n);ue(t.toValue(e),r,!1),l.value.onChange()}return t.computed((()=>Object.assign(Object.assign({},l.value),{onBlur:a,onInput:u,onChange:i,value:r.value})))},defineComponentBinds:function(e,r){const[l,a]=je(e,r),u=Y(t.toValue(e));function i(e){l.value=e}return t.computed((()=>{const e=n(r)?r(q(u,fe)):r||{};return Object.assign({[e.model||"modelValue"]:l.value,[`onUpdate:${e.model||"modelValue"}`]:i},a.value)}))},defineField:je,stageInitialValue:function(t,n,r=!1){be(t,n),M(p,t,n),r&&!(null==e?void 0:e.initialValues)&&M(R.value,t,c(n))},unsetInitialValue:ge,setFieldInitialValue:be,createPathState:L,getPathState:Y,unsetPathValue:function(e){return te.push(e),Z||(Z=t.nextTick((()=>{[...te].sort().reverse().forEach((e=>{T(p,e)})),te=[],Z=null}))),Z},removePathState:function(e,n){const r=m.value.findIndex((t=>t.path===e&&(Array.isArray(t.id)?t.id.includes(n):t.id===n))),l=m.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)&&(m.value.splice(r,1),ge(e),V(),delete b.value[e])}},initialValues:P,getAllPathStates:()=>m.value,destroyPath:function(e){B(b.value).forEach((t=>{t.startsWith(e)&&delete b.value[t]})),m.value=m.value.filter((t=>!t.path.startsWith(e))),t.nextTick((()=>{V()}))},isFieldTouched:function(e){const t=Y(e);if(t)return t.touched;return m.value.filter((t=>t.path.startsWith(e))).some((e=>e.touched))},isFieldDirty:function(e){const t=Y(e);if(t)return t.dirty;return m.value.filter((t=>t.path.startsWith(e))).some((e=>e.dirty))},isFieldValid:function(e){const t=Y(e);if(t)return t.valid;return m.value.filter((t=>t.path.startsWith(e))).every((e=>e.valid))}};function ue(e,t,n=!0){const r=c(t),l="string"==typeof e?e:e.path;Y(l)||L(l),M(p,l,r),n&&ye(l)}function ie(e,t=!0){i(p,e),f.forEach((e=>e&&e.reset())),t&&he()}function oe(e,n){const r=Y(t.toValue(e))||L(e);return t.computed({get:()=>r.value,set(r){var l;ue(t.toValue(e),r,null!==(l=t.toValue(n))&&void 0!==l&&l)}})}function se(e,t){const n=Y(e);n&&(n.touched=t)}function de(e){"boolean"!=typeof e?B(e).forEach((t=>{se(t,!!e[t])})):J((t=>{t.touched=e}))}function ce(e,n){var r;const l=n&&"value"in n?n.value:I(P.value,e),a=Y(e);a&&(a.__flags.pendingReset=!0),be(e,c(l),!0),ue(e,l,!1),se(e,null!==(r=null==n?void 0:n.touched)&&void 0!==r&&r),O(e,(null==n?void 0:n.errors)||[]),t.nextTick((()=>{a&&(a.__flags.pendingReset=!1)}))}function me(e,r){let l=c((null==e?void 0:e.values)?e.values:R.value);l=(null==r?void 0:r.force)?l:i(R.value,l),l=y(W)&&n(W.cast)?W.cast(l):l,N(l,{force:null==r?void 0:r.force}),J((t=>{var n;t.__flags.pendingReset=!0,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(l,t.path),!1),O(t.path,void 0)})),(null==r?void 0:r.force)?function(e,t=!0){B(p).forEach((e=>{delete p[e]})),B(e).forEach((t=>{ue(t,e[t],!1)})),t&&he()}(l,!1):ie(l,!1),j((null==e?void 0:e.errors)||{}),d.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{he({mode:"silent"}),J((e=>{e.__flags.pendingReset=!1}))}))}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(m.value.map((t=>t.validate?t.validate(e).then((e=>({key:t.path,valid:e.valid,errors:e.errors,value:e.value}))):Promise.resolve({key:t.path,valid:!0,errors:[],value:void 0}))));s.value=!1;const r={},l={},a={};for(const e of n)r[e.key]={valid:e.valid,errors:e.errors},e.value&&M(a,e.key,e.value),e.errors.length&&(l[e.key]=e.errors[0]);return{valid:n.every((e=>e.valid)),results:r,errors:l,values:a,source:"fields"}}async function ye(e,t){const n=Y(e);if(n&&"silent"!==(null==t?void 0:t.mode)&&(n.validated=!0),W){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){T(P.value,e)}function be(e,t,n=!1){M(P.value,e,c(t)),n&&M(R.value,e,c(t))}async function Ve(){const e=t.unref(W);if(!e)return{valid:!0,results:{},errors:{},source:"none"};s.value=!0;const n=g(e)||y(e)?await async function(e,t){const n=y(e)?e:ee(e),r=await n.parse(c(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,source:"schema"}}(e,p):await re(e,p,{names:k.value,bailsMap:w.value});return s.value=!1,n}const Oe=le(((e,{evt:t})=>{A(t)&&t.target.submit()}));function je(e,r){const l=n(r)||null==r?void 0:r.label,a=Y(t.toValue(e))||L(e,{label:l}),u=()=>n(r)?r(q(a,fe)):r||{};function i(){var e;a.touched=!0;(null!==(e=u().validateOnBlur)&&void 0!==e?e:Q().validateOnBlur)&&ye(a.path)}function o(){var e;(null!==(e=u().validateOnInput)&&void 0!==e?e:Q().validateOnInput)&&t.nextTick((()=>{ye(a.path)}))}function s(){var e;(null!==(e=u().validateOnChange)&&void 0!==e?e:Q().validateOnChange)&&t.nextTick((()=>{ye(a.path)}))}const d=t.computed((()=>{const e={onChange:s,onInput:o,onBlur:i};return n(r)?Object.assign(Object.assign({},e),r(q(a,fe)).props||{}):(null==r?void 0:r.props)?Object.assign(Object.assign({},e),r.props(q(a,fe))):e})),c=oe(e,(()=>{var e,t,n;return null===(n=null!==(e=u().validateOnModelUpdate)&&void 0!==e?e:null===(t=Q())||void 0===t?void 0:t.validateOnModelUpdate)||void 0===n||n}));return[c,d]}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(W)&&t.watch(W,(()=>{var e;null===(e=ae.validateSchema)||void 0===e||e.call(ae,"validated-only")})),t.provide(v,ae),Object.assign(Object.assign({},ae),{values:t.readonly(p),handleReset:()=>me(),submitForm:Oe})}const he=t.defineComponent({name:"Form",inheritAttrs:!1,props:{as:{type:null,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,"validationSchema"),l=t.toRef(e,"keepValues"),{errors:a,errorBag:u,values:i,meta:o,isSubmitting:s,isValidating:d,submitCount:v,controlledValues:f,validate:p,validateField:m,handleReset:h,resetForm:y,handleSubmit:g,setErrors:b,setFieldError:V,setFieldValue:O,setValues:j,setFieldTouched:S,setTouched:E,resetField:k}=me({validationSchema:r.value?r:void 0,initialValues:e.initialValues,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:l}),w=g(((e,{evt:t})=>{A(t)&&t.target.submit()}),e.onInvalidSubmit),I=e.onSubmit?g(e.onSubmit,e.onInvalidSubmit):w;function M(e){F(e)&&e.preventDefault(),h(),"function"==typeof n.attrs.onReset&&n.attrs.onReset()}function C(t,n){return g("function"!=typeof t||n?n:t,e.onInvalidSubmit)(t)}function T(){return c(i)}function B(){return c(o.value)}function _(){return c(a.value)}function P(){return{meta:o.value,errors:a.value,errorBag:u.value,values:i,isSubmitting:s.value,isValidating:d.value,submitCount:v.value,controlledValues:f.value,validate:p,validateField:m,handleSubmit:C,handleReset:h,submitForm:w,setErrors:b,setFieldError:V,setFieldValue:O,setValues:j,setFieldTouched:S,setTouched:E,resetForm:y,resetField:k,getValues:T,getMeta:B,getErrors:_}}return n.expose({setFieldError:V,setErrors:b,setFieldValue:O,setValues:j,setFieldTouched:S,setTouched:E,resetForm:y,validate:p,validateField:m,resetField:k,getValues:T,getMeta:B,getErrors:_,values:i,meta:o,errors:a}),function(){const r="form"===e.as?e.as:e.as?t.resolveDynamicComponent(e.as):null,l=z(r,n,P);if(!r)return l;const a="form"===r?{novalidate:!0}:{};return t.h(r,Object.assign(Object.assign(Object.assign({},a),n.attrs),{onSubmit:I,onReset:M}),l)}}}),ye=he;function ge(e){const n=_(v,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.toValue(e),[])||[]}function d(){const e=s();Array.isArray(e)&&(l.value=e.map(((e,t)=>p(e,t,l.value))),f())}function f(){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 p(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.toValue(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&&h(t,e)}}),isFirst:!1,isLast:!1};return d}function m(){f(),null==n||n.validate({mode:"silent"})}function h(r,l){const a=t.toValue(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"}))}d();const y={fields:l,remove:function(r){const a=t.toValue(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.destroyPath(o),n.unsetInitialValue(o),M(n.values,a,i),l.value.splice(r,1),m()},push:function(a){const u=c(a),i=t.toValue(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(p(u)),m()},swap:function(r,a){const u=t.toValue(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,f()},insert:function(r,a){const u=c(a),i=t.toValue(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,p(u)),M(n.values,i,s),l.value=d,m()},update:h,replace:function(r){const l=t.toValue(e);n.stageInitialValue(l,r),M(n.values,l,r),d(),m()},prepend:function(a){const u=c(a),i=t.toValue(e),o=I(null==n?void 0:n.values,i),s=r(o)?[]:o;if(!Array.isArray(s))return;const d=[u,...s];M(n.values,i,d),n.stageInitialValue(i+"[0]",u),l.value.unshift(p(u)),m()},move:function(a,u){const i=t.toValue(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,m()}};return n.fieldArrays.push(Object.assign({path:e,reset:d},y)),t.onBeforeUnmount((()=>{const r=n.fieldArrays.findIndex((n=>t.toValue(n.path)===t.toValue(e)));r>=0&&n.fieldArrays.splice(r,1)})),t.watch(s,(e=>{E(e,l.value.map((e=>e.value)))||d()})),y}const be=t.defineComponent({name:"FieldArray",inheritAttrs:!1,props:{name:{type:String,required:!0}},setup(e,t){const{push:n,remove:r,swap:l,insert:a,replace:u,update:i,prepend:o,move:s,fields:d}=ge((()=>e.name));function c(){return{fields:d.value,push:n,remove:r,swap:l,insert:a,update:i,replace:u,prepend:o,move:s}}return t.expose({push:n,remove:r,swap:l,insert:a,update:i,replace:u,prepend:o,move:s}),()=>z(void 0,t,c)}}),Ve=t.defineComponent({name:"ErrorMessage",props:{as:{type:String,default:void 0},name:{type:String,required:!0}},setup(e,n){const r=t.inject(v,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=z(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=f,e.Form=ye,e.FormContextKey=v,e.IS_ABSENT=p,e.cleanupNonNestedPath=w,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.isNotNestedPath=V,e.normalizeRules=G,e.useField=ue,e.useFieldArray=ge,e.useFieldError=function(e){const n=_(v),r=e?void 0:t.inject(f);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=_(v),r=e?void 0:t.inject(f);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=_(v);return t.computed((()=>(null==e?void 0:e.errors.value)||{}))},e.useFormValues=function(){const e=_(v);return t.computed((()=>(null==e?void 0:e.values)||{}))},e.useIsFieldDirty=function(e){const n=$(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=$(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=$(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=_(v);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=_(v);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=_(v);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=_(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isSubmitting.value)&&void 0!==t&&t}))},e.useIsValidating=function(){const e=_(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isValidating.value)&&void 0!==t&&t}))},e.useResetForm=function(){const e=_(v);return function(t,n){if(e)return e.resetForm(t,n)}},e.useSetFieldError=function(e){const n=_(v),r=e?void 0:t.inject(f);return function(l){e&&n?n.setFieldError(t.toValue(e),l):r&&r.setErrors(l||[])}},e.useSetFieldTouched=function(e){const n=_(v),r=e?void 0:t.inject(f);return function(l){e&&n?n.setFieldTouched(t.toValue(e),l):r&&r.setTouched(l)}},e.useSetFieldValue=function(e){const n=_(v),r=e?void 0:t.inject(f);return function(l,a=!0){e&&n?n.setFieldValue(t.toValue(e),l,a):r&&r.setValue(l,a)}},e.useSetFormErrors=function(){const e=_(v);return function(t){e&&e.setErrors(t)}},e.useSetFormTouched=function(){const e=_(v);return function(t){e&&e.setTouched(t)}},e.useSetFormValues=function(){const e=_(v);return function(t,n=!0){e&&e.setValues(t,n)}},e.useSubmitCount=function(){const e=_(v);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=_(v),n=t?t.handleSubmit(e):void 0;return function(e){if(n)return n(e)}},e.useValidateField=function(e){const n=_(v),r=e?void 0:t.inject(f);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=_(v);return function(){return e?e.validate():Promise.resolve({results:{},errors:{},valid:!0,source:"none"})}},e.validate=Z,e.validateObject=re}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vee-validate",
3
- "version": "4.12.7",
3
+ "version": "4.13.0",
4
4
  "description": "Painless forms for Vue.js",
5
5
  "author": "Abdelrahman Awad <logaretm1@gmail.com>",
6
6
  "license": "MIT",