vee-validate 4.11.3 → 4.11.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/vee-validate.d.ts +15 -5
- package/dist/vee-validate.esm.js +98 -66
- package/dist/vee-validate.js +98 -66
- package/dist/vee-validate.min.js +2 -2
- package/package.json +1 -1
package/dist/vee-validate.d.ts
CHANGED
|
@@ -234,6 +234,7 @@ interface PathState<TValue = unknown> {
|
|
|
234
234
|
fieldsCount: number;
|
|
235
235
|
__flags: {
|
|
236
236
|
pendingUnmount: Record<string, boolean>;
|
|
237
|
+
pendingReset: boolean;
|
|
237
238
|
};
|
|
238
239
|
validate?: FieldValidator;
|
|
239
240
|
}
|
|
@@ -292,6 +293,9 @@ interface FormState<TValues> {
|
|
|
292
293
|
}
|
|
293
294
|
type FormErrors<TValues extends GenericObject> = Partial<Record<Path<TValues>, string | undefined>>;
|
|
294
295
|
type FormErrorBag<TValues extends GenericObject> = Partial<Record<Path<TValues>, string[]>>;
|
|
296
|
+
interface ResetFormOpts {
|
|
297
|
+
force: boolean;
|
|
298
|
+
}
|
|
295
299
|
interface FormActions<TValues extends GenericObject, TOutput = TValues> {
|
|
296
300
|
setFieldValue<T extends Path<TValues>>(field: T, value: PathValue<TValues, T>, shouldValidate?: boolean): void;
|
|
297
301
|
setFieldError(field: Path<TValues>, message: string | string[] | undefined): void;
|
|
@@ -299,7 +303,7 @@ interface FormActions<TValues extends GenericObject, TOutput = TValues> {
|
|
|
299
303
|
setValues(fields: PartialDeep<TValues>, shouldValidate?: boolean): void;
|
|
300
304
|
setFieldTouched(field: Path<TValues>, isTouched: boolean): void;
|
|
301
305
|
setTouched(fields: Partial<Record<Path<TValues>, boolean>> | boolean): void;
|
|
302
|
-
resetForm(state?: Partial<FormState<TValues
|
|
306
|
+
resetForm(state?: Partial<FormState<TValues>>, opts?: Partial<ResetFormOpts>): void;
|
|
303
307
|
resetField(field: Path<TValues>, state?: Partial<FieldState>): void;
|
|
304
308
|
}
|
|
305
309
|
interface FormValidationResult<TValues, TOutput = TValues> {
|
|
@@ -358,9 +362,15 @@ interface PrivateFormContext<TValues extends GenericObject = GenericObject, TOut
|
|
|
358
362
|
isFieldDirty<TPath extends Path<TValues>>(path: TPath): boolean;
|
|
359
363
|
isFieldValid<TPath extends Path<TValues>>(path: TPath): boolean;
|
|
360
364
|
}
|
|
361
|
-
interface
|
|
365
|
+
interface ComponentModellessBinds {
|
|
362
366
|
onBlur: () => void;
|
|
363
367
|
}
|
|
368
|
+
type ComponentModelBinds<TValue = any, TModel extends string = 'modelValue'> = ComponentModellessBinds & {
|
|
369
|
+
[TKey in `onUpdate:${TModel}`]: (value: TValue) => void;
|
|
370
|
+
};
|
|
371
|
+
type BaseComponentBinds<TValue = any, TModel extends string = 'modelValue'> = ComponentModelBinds<TValue, TModel> & {
|
|
372
|
+
[k in TModel]: TValue;
|
|
373
|
+
};
|
|
364
374
|
type PublicPathState<TValue = unknown> = Omit<PathState<TValue>, 'bails' | 'label' | 'multiple' | 'fieldsCount' | 'validate' | 'id' | 'type' | '__flags'>;
|
|
365
375
|
interface ComponentBindsConfig<TValue = unknown, TExtraProps extends GenericObject = GenericObject> {
|
|
366
376
|
mapProps: (state: PublicPathState<TValue>) => TExtraProps;
|
|
@@ -396,7 +406,7 @@ interface FormContext<TValues extends GenericObject = GenericObject, TOutput = T
|
|
|
396
406
|
values: TValues;
|
|
397
407
|
handleReset: () => void;
|
|
398
408
|
submitForm: (e?: unknown) => Promise<void>;
|
|
399
|
-
defineComponentBinds<TPath extends Path<TValues>, TValue = PathValue<TValues, TPath>, TExtras extends GenericObject = GenericObject>(path: MaybeRefOrGetter<TPath>, config?: Partial<ComponentBindsConfig<TValue, TExtras>> | LazyComponentBindsConfig<TValue, TExtras>): Ref<BaseComponentBinds<TValue> & TExtras>;
|
|
409
|
+
defineComponentBinds<TPath extends Path<TValues>, TValue = PathValue<TValues, TPath>, TModel extends string = 'modelValue', TExtras extends GenericObject = GenericObject>(path: MaybeRefOrGetter<TPath>, config?: Partial<ComponentBindsConfig<TValue, TExtras>> | LazyComponentBindsConfig<TValue, TExtras>): Ref<BaseComponentBinds<TValue, TModel> & TExtras>;
|
|
400
410
|
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>;
|
|
401
411
|
}
|
|
402
412
|
|
|
@@ -1559,10 +1569,10 @@ declare function useSetFormTouched(): (fields: Record<string, boolean> | boolean
|
|
|
1559
1569
|
/**
|
|
1560
1570
|
* Sets multiple fields values
|
|
1561
1571
|
*/
|
|
1562
|
-
declare function useSetFormValues(): (fields: Record<string, unknown
|
|
1572
|
+
declare function useSetFormValues(): (fields: Record<string, unknown>, shouldValidate?: boolean) => void;
|
|
1563
1573
|
|
|
1564
1574
|
declare const FormContextKey: InjectionKey<PrivateFormContext>;
|
|
1565
1575
|
declare const FieldContextKey: InjectionKey<PrivateFieldContext<unknown>>;
|
|
1566
1576
|
declare const IS_ABSENT: unique symbol;
|
|
1567
1577
|
|
|
1568
|
-
export { type BaseComponentBinds, type BaseInputBinds, type ComponentBindsConfig, type DevtoolsPluginFieldState, type DevtoolsPluginFormState, ErrorMessage, Field, FieldArray, type FieldArrayContext, type FieldContext, FieldContextKey, type FieldEntry, type FieldMeta, type FieldOptions, type FieldPathLookup, type FieldState, type FieldValidator, type FlattenAndSetPathsType, Form, type FormActions, type FormContext, FormContextKey, type FormErrorBag, type FormErrors, type FormMeta, type FormOptions, type FormState, type FormValidationResult, type GenericObject, type GenericValidateFunction, IS_ABSENT, type InferInput, type InferOutput, type InputBindsConfig, type InputType, type InvalidSubmissionContext, type InvalidSubmissionHandler, type IsAny, type IsEqual, type LazyComponentBindsConfig, type LazyInputBindsConfig, type Locator, type MapValuesPathsToRefs, type MaybeArray, type MaybePromise, type Path, type PathState, type PathStateConfig, type PathValue, type PrivateFieldArrayContext, type PrivateFieldContext, type PrivateFormContext, type PublicPathState, type RawFormSchema, type RuleExpression, type SchemaValidationMode, type SubmissionContext, type SubmissionHandler, type TypedSchema, type TypedSchemaError, type ValidationOptions$1 as ValidationOptions, type ValidationResult, type YupSchema, configure, defineRule, normalizeRules, useField, useFieldArray, useFieldError, useFieldValue, useForm, useFormErrors, useFormValues, useIsFieldDirty, useIsFieldTouched, useIsFieldValid, useIsFormDirty, useIsFormTouched, useIsFormValid, useIsSubmitting, useIsValidating, useResetForm, useSetFieldError, useSetFieldTouched, useSetFieldValue, useSetFormErrors, useSetFormTouched, useSetFormValues, useSubmitCount, useSubmitForm, useValidateField, useValidateForm, validate, validateObjectSchema as validateObject };
|
|
1578
|
+
export { type BaseComponentBinds, type BaseInputBinds, type ComponentBindsConfig, type DevtoolsPluginFieldState, type DevtoolsPluginFormState, ErrorMessage, Field, FieldArray, type FieldArrayContext, type FieldContext, FieldContextKey, type FieldEntry, type FieldMeta, type FieldOptions, type FieldPathLookup, type FieldState, type FieldValidator, type FlattenAndSetPathsType, Form, type FormActions, type FormContext, FormContextKey, type FormErrorBag, type FormErrors, type FormMeta, type FormOptions, type FormState, type FormValidationResult, type GenericObject, type GenericValidateFunction, IS_ABSENT, type InferInput, type InferOutput, type InputBindsConfig, type InputType, type InvalidSubmissionContext, type InvalidSubmissionHandler, type IsAny, type IsEqual, type LazyComponentBindsConfig, type LazyInputBindsConfig, type Locator, type MapValuesPathsToRefs, type MaybeArray, type MaybePromise, type Path, type PathState, type PathStateConfig, type PathValue, type PrivateFieldArrayContext, type PrivateFieldContext, type PrivateFormContext, type PublicPathState, type RawFormSchema, type ResetFormOpts, type RuleExpression, type SchemaValidationMode, type SubmissionContext, type SubmissionHandler, type TypedSchema, type TypedSchemaError, type ValidationOptions$1 as ValidationOptions, type ValidationResult, type YupSchema, configure, defineRule, normalizeRules, useField, useFieldArray, useFieldError, useFieldValue, useForm, useFormErrors, useFormValues, useIsFieldDirty, useIsFieldTouched, useIsFieldValid, useIsFormDirty, useIsFormTouched, useIsFormValid, useIsSubmitting, useIsValidating, useResetForm, useSetFieldError, useSetFieldTouched, useSetFieldValue, useSetFormErrors, useSetFormTouched, useSetFormValues, useSubmitCount, useSubmitForm, useValidateField, useValidateForm, validate, validateObjectSchema as validateObject };
|
package/dist/vee-validate.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v4.11.
|
|
2
|
+
* vee-validate v4.11.5
|
|
3
3
|
* (c) 2023 Abdelrahman Awad
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -100,6 +100,60 @@ function guardExtend(id, validator) {
|
|
|
100
100
|
throw new Error(`Extension Error: The validator '${id}' must be a function.`);
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
function set(obj, key, val) {
|
|
104
|
+
if (typeof val.value === 'object') val.value = klona(val.value);
|
|
105
|
+
if (!val.enumerable || val.get || val.set || !val.configurable || !val.writable || key === '__proto__') {
|
|
106
|
+
Object.defineProperty(obj, key, val);
|
|
107
|
+
} else obj[key] = val.value;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function klona(x) {
|
|
111
|
+
if (typeof x !== 'object') return x;
|
|
112
|
+
|
|
113
|
+
var i=0, k, list, tmp, str=Object.prototype.toString.call(x);
|
|
114
|
+
|
|
115
|
+
if (str === '[object Object]') {
|
|
116
|
+
tmp = Object.create(x.__proto__ || null);
|
|
117
|
+
} else if (str === '[object Array]') {
|
|
118
|
+
tmp = Array(x.length);
|
|
119
|
+
} else if (str === '[object Set]') {
|
|
120
|
+
tmp = new Set;
|
|
121
|
+
x.forEach(function (val) {
|
|
122
|
+
tmp.add(klona(val));
|
|
123
|
+
});
|
|
124
|
+
} else if (str === '[object Map]') {
|
|
125
|
+
tmp = new Map;
|
|
126
|
+
x.forEach(function (val, key) {
|
|
127
|
+
tmp.set(klona(key), klona(val));
|
|
128
|
+
});
|
|
129
|
+
} else if (str === '[object Date]') {
|
|
130
|
+
tmp = new Date(+x);
|
|
131
|
+
} else if (str === '[object RegExp]') {
|
|
132
|
+
tmp = new RegExp(x.source, x.flags);
|
|
133
|
+
} else if (str === '[object DataView]') {
|
|
134
|
+
tmp = new x.constructor( klona(x.buffer) );
|
|
135
|
+
} else if (str === '[object ArrayBuffer]') {
|
|
136
|
+
tmp = x.slice(0);
|
|
137
|
+
} else if (str.slice(-6) === 'Array]') {
|
|
138
|
+
// ArrayBuffer.isView(x)
|
|
139
|
+
// ~> `new` bcuz `Buffer.slice` => ref
|
|
140
|
+
tmp = new x.constructor(x);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (tmp) {
|
|
144
|
+
for (list=Object.getOwnPropertySymbols(x); i < list.length; i++) {
|
|
145
|
+
set(tmp, list[i], Object.getOwnPropertyDescriptor(x, list[i]));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
for (i=0, list=Object.getOwnPropertyNames(x); i < list.length; i++) {
|
|
149
|
+
if (Object.hasOwnProperty.call(tmp, k=list[i]) && tmp[k] === x[k]) continue;
|
|
150
|
+
set(tmp, k, Object.getOwnPropertyDescriptor(x, k));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return tmp || x;
|
|
155
|
+
}
|
|
156
|
+
|
|
103
157
|
const FormContextKey = Symbol('vee-validate-form');
|
|
104
158
|
const FieldContextKey = Symbol('vee-validate-field-instance');
|
|
105
159
|
const IS_ABSENT = Symbol('Default empty value');
|
|
@@ -277,60 +331,6 @@ function isFile(a) {
|
|
|
277
331
|
return a instanceof File;
|
|
278
332
|
}
|
|
279
333
|
|
|
280
|
-
function set(obj, key, val) {
|
|
281
|
-
if (typeof val.value === 'object') val.value = klona(val.value);
|
|
282
|
-
if (!val.enumerable || val.get || val.set || !val.configurable || !val.writable || key === '__proto__') {
|
|
283
|
-
Object.defineProperty(obj, key, val);
|
|
284
|
-
} else obj[key] = val.value;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
function klona(x) {
|
|
288
|
-
if (typeof x !== 'object') return x;
|
|
289
|
-
|
|
290
|
-
var i=0, k, list, tmp, str=Object.prototype.toString.call(x);
|
|
291
|
-
|
|
292
|
-
if (str === '[object Object]') {
|
|
293
|
-
tmp = Object.create(x.__proto__ || null);
|
|
294
|
-
} else if (str === '[object Array]') {
|
|
295
|
-
tmp = Array(x.length);
|
|
296
|
-
} else if (str === '[object Set]') {
|
|
297
|
-
tmp = new Set;
|
|
298
|
-
x.forEach(function (val) {
|
|
299
|
-
tmp.add(klona(val));
|
|
300
|
-
});
|
|
301
|
-
} else if (str === '[object Map]') {
|
|
302
|
-
tmp = new Map;
|
|
303
|
-
x.forEach(function (val, key) {
|
|
304
|
-
tmp.set(klona(key), klona(val));
|
|
305
|
-
});
|
|
306
|
-
} else if (str === '[object Date]') {
|
|
307
|
-
tmp = new Date(+x);
|
|
308
|
-
} else if (str === '[object RegExp]') {
|
|
309
|
-
tmp = new RegExp(x.source, x.flags);
|
|
310
|
-
} else if (str === '[object DataView]') {
|
|
311
|
-
tmp = new x.constructor( klona(x.buffer) );
|
|
312
|
-
} else if (str === '[object ArrayBuffer]') {
|
|
313
|
-
tmp = x.slice(0);
|
|
314
|
-
} else if (str.slice(-6) === 'Array]') {
|
|
315
|
-
// ArrayBuffer.isView(x)
|
|
316
|
-
// ~> `new` bcuz `Buffer.slice` => ref
|
|
317
|
-
tmp = new x.constructor(x);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
if (tmp) {
|
|
321
|
-
for (list=Object.getOwnPropertySymbols(x); i < list.length; i++) {
|
|
322
|
-
set(tmp, list[i], Object.getOwnPropertyDescriptor(x, list[i]));
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
for (i=0, list=Object.getOwnPropertyNames(x); i < list.length; i++) {
|
|
326
|
-
if (Object.hasOwnProperty.call(tmp, k=list[i]) && tmp[k] === x[k]) continue;
|
|
327
|
-
set(tmp, k, Object.getOwnPropertyDescriptor(x, k));
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
return tmp || x;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
334
|
function cleanupNonNestedPath(path) {
|
|
335
335
|
if (isNotNestedPath(path)) {
|
|
336
336
|
return path.replace(/\[|\]/gi, '');
|
|
@@ -952,7 +952,7 @@ function fillTargetValues(params, crossTable) {
|
|
|
952
952
|
}
|
|
953
953
|
async function validateTypedSchema(schema, values) {
|
|
954
954
|
const typedSchema = isTypedSchema(schema) ? schema : yupToTypedSchema(schema);
|
|
955
|
-
const validationResult = await typedSchema.parse(values);
|
|
955
|
+
const validationResult = await typedSchema.parse(klona(values));
|
|
956
956
|
const results = {};
|
|
957
957
|
const errors = {};
|
|
958
958
|
for (const error of validationResult.errors) {
|
|
@@ -1035,7 +1035,7 @@ function useFieldState(path, init) {
|
|
|
1035
1035
|
value,
|
|
1036
1036
|
initialValue,
|
|
1037
1037
|
meta,
|
|
1038
|
-
flags: { pendingUnmount: { [id]: false } },
|
|
1038
|
+
flags: { pendingUnmount: { [id]: false }, pendingReset: false },
|
|
1039
1039
|
errors,
|
|
1040
1040
|
setState,
|
|
1041
1041
|
};
|
|
@@ -1593,7 +1593,12 @@ function _useField(path, rules, opts) {
|
|
|
1593
1593
|
});
|
|
1594
1594
|
const errorMessage = computed(() => errors.value[0]);
|
|
1595
1595
|
if (syncVModel) {
|
|
1596
|
-
useVModel({
|
|
1596
|
+
useVModel({
|
|
1597
|
+
value,
|
|
1598
|
+
prop: syncVModel,
|
|
1599
|
+
handleChange,
|
|
1600
|
+
shouldValidate: () => validateOnValueUpdate && !flags.pendingReset,
|
|
1601
|
+
});
|
|
1597
1602
|
}
|
|
1598
1603
|
/**
|
|
1599
1604
|
* Handles common onBlur meta update
|
|
@@ -1889,7 +1894,7 @@ function useFieldWithChecked(name, rules, opts) {
|
|
|
1889
1894
|
}
|
|
1890
1895
|
return patchCheckedApi(_useField(name, rules, opts));
|
|
1891
1896
|
}
|
|
1892
|
-
function useVModel({ prop, value, handleChange }) {
|
|
1897
|
+
function useVModel({ prop, value, handleChange, shouldValidate }) {
|
|
1893
1898
|
const vm = getCurrentInstance();
|
|
1894
1899
|
/* istanbul ignore next */
|
|
1895
1900
|
if (!vm || !prop) {
|
|
@@ -1918,7 +1923,7 @@ function useVModel({ prop, value, handleChange }) {
|
|
|
1918
1923
|
if (isEqual(newValue, value.value)) {
|
|
1919
1924
|
return;
|
|
1920
1925
|
}
|
|
1921
|
-
handleChange(newValue);
|
|
1926
|
+
handleChange(newValue, shouldValidate());
|
|
1922
1927
|
});
|
|
1923
1928
|
}
|
|
1924
1929
|
function getCurrentModelValue(vm, propName) {
|
|
@@ -2013,7 +2018,7 @@ const FieldImpl = /** #__PURE__ */ defineComponent({
|
|
|
2013
2018
|
checkedValue: ctx.attrs.value,
|
|
2014
2019
|
uncheckedValue,
|
|
2015
2020
|
label,
|
|
2016
|
-
validateOnValueUpdate:
|
|
2021
|
+
validateOnValueUpdate: props.validateOnModelUpdate,
|
|
2017
2022
|
keepValueOnUnmount: keepValue,
|
|
2018
2023
|
syncVModel: true,
|
|
2019
2024
|
});
|
|
@@ -2282,6 +2287,7 @@ function useForm(opts) {
|
|
|
2282
2287
|
multiple: false,
|
|
2283
2288
|
__flags: {
|
|
2284
2289
|
pendingUnmount: { [id]: false },
|
|
2290
|
+
pendingReset: false,
|
|
2285
2291
|
},
|
|
2286
2292
|
fieldsCount: 1,
|
|
2287
2293
|
validate: config === null || config === void 0 ? void 0 : config.validate,
|
|
@@ -2540,6 +2546,19 @@ function useForm(opts) {
|
|
|
2540
2546
|
validateField(path);
|
|
2541
2547
|
}
|
|
2542
2548
|
}
|
|
2549
|
+
function forceSetValues(fields, shouldValidate = true) {
|
|
2550
|
+
// clean up old values
|
|
2551
|
+
keysOf(formValues).forEach(key => {
|
|
2552
|
+
delete formValues[key];
|
|
2553
|
+
});
|
|
2554
|
+
// set up new values
|
|
2555
|
+
keysOf(fields).forEach(path => {
|
|
2556
|
+
setFieldValue(path, fields[path], false);
|
|
2557
|
+
});
|
|
2558
|
+
if (shouldValidate) {
|
|
2559
|
+
validate();
|
|
2560
|
+
}
|
|
2561
|
+
}
|
|
2543
2562
|
/**
|
|
2544
2563
|
* Sets multiple fields values
|
|
2545
2564
|
*/
|
|
@@ -2612,30 +2631,43 @@ function useForm(opts) {
|
|
|
2612
2631
|
function resetField(field, state) {
|
|
2613
2632
|
var _a;
|
|
2614
2633
|
const newValue = state && 'value' in state ? state.value : getFromPath(initialValues.value, field);
|
|
2634
|
+
const pathState = findPathState(field);
|
|
2635
|
+
if (pathState) {
|
|
2636
|
+
pathState.__flags.pendingReset = true;
|
|
2637
|
+
}
|
|
2615
2638
|
setFieldInitialValue(field, klona(newValue));
|
|
2616
2639
|
setFieldValue(field, newValue, false);
|
|
2617
2640
|
setFieldTouched(field, (_a = state === null || state === void 0 ? void 0 : state.touched) !== null && _a !== void 0 ? _a : false);
|
|
2618
2641
|
setFieldError(field, (state === null || state === void 0 ? void 0 : state.errors) || []);
|
|
2642
|
+
nextTick(() => {
|
|
2643
|
+
if (pathState) {
|
|
2644
|
+
pathState.__flags.pendingReset = false;
|
|
2645
|
+
}
|
|
2646
|
+
});
|
|
2619
2647
|
}
|
|
2620
2648
|
/**
|
|
2621
2649
|
* Resets all fields
|
|
2622
2650
|
*/
|
|
2623
|
-
function resetForm(resetState) {
|
|
2651
|
+
function resetForm(resetState, opts) {
|
|
2624
2652
|
let newValues = (resetState === null || resetState === void 0 ? void 0 : resetState.values) ? resetState.values : originalInitialValues.value;
|
|
2625
2653
|
newValues = isTypedSchema(schema) && isCallable(schema.cast) ? schema.cast(newValues) : newValues;
|
|
2626
2654
|
setInitialValues(newValues);
|
|
2627
2655
|
mutateAllPathState(state => {
|
|
2628
2656
|
var _a;
|
|
2657
|
+
state.__flags.pendingReset = true;
|
|
2629
2658
|
state.validated = false;
|
|
2630
2659
|
state.touched = ((_a = resetState === null || resetState === void 0 ? void 0 : resetState.touched) === null || _a === void 0 ? void 0 : _a[state.path]) || false;
|
|
2631
2660
|
setFieldValue(state.path, getFromPath(newValues, state.path), false);
|
|
2632
2661
|
setFieldError(state.path, undefined);
|
|
2633
2662
|
});
|
|
2634
|
-
setValues(newValues, false);
|
|
2663
|
+
(opts === null || opts === void 0 ? void 0 : opts.force) ? forceSetValues(newValues, false) : setValues(newValues, false);
|
|
2635
2664
|
setErrors((resetState === null || resetState === void 0 ? void 0 : resetState.errors) || {});
|
|
2636
2665
|
submitCount.value = (resetState === null || resetState === void 0 ? void 0 : resetState.submitCount) || 0;
|
|
2637
2666
|
nextTick(() => {
|
|
2638
2667
|
validate({ mode: 'silent' });
|
|
2668
|
+
mutateAllPathState(state => {
|
|
2669
|
+
state.__flags.pendingReset = false;
|
|
2670
|
+
});
|
|
2639
2671
|
});
|
|
2640
2672
|
}
|
|
2641
2673
|
async function validate(opts) {
|
|
@@ -2685,7 +2717,7 @@ function useForm(opts) {
|
|
|
2685
2717
|
async function validateField(path, opts) {
|
|
2686
2718
|
var _a;
|
|
2687
2719
|
const state = findPathState(path);
|
|
2688
|
-
if (state) {
|
|
2720
|
+
if (state && (opts === null || opts === void 0 ? void 0 : opts.mode) !== 'silent') {
|
|
2689
2721
|
state.validated = true;
|
|
2690
2722
|
}
|
|
2691
2723
|
if (schema) {
|
|
@@ -3772,9 +3804,9 @@ function useSetFormTouched() {
|
|
|
3772
3804
|
*/
|
|
3773
3805
|
function useSetFormValues() {
|
|
3774
3806
|
const form = injectWithSelf(FormContextKey);
|
|
3775
|
-
function setFormValues(fields) {
|
|
3807
|
+
function setFormValues(fields, shouldValidate = true) {
|
|
3776
3808
|
if (form) {
|
|
3777
|
-
form.setValues(fields);
|
|
3809
|
+
form.setValues(fields, shouldValidate);
|
|
3778
3810
|
return;
|
|
3779
3811
|
}
|
|
3780
3812
|
if ((process.env.NODE_ENV !== 'production')) {
|
package/dist/vee-validate.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v4.11.
|
|
2
|
+
* vee-validate v4.11.5
|
|
3
3
|
* (c) 2023 Abdelrahman Awad
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -103,6 +103,60 @@
|
|
|
103
103
|
throw new Error(`Extension Error: The validator '${id}' must be a function.`);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
function set(obj, key, val) {
|
|
107
|
+
if (typeof val.value === 'object') val.value = klona(val.value);
|
|
108
|
+
if (!val.enumerable || val.get || val.set || !val.configurable || !val.writable || key === '__proto__') {
|
|
109
|
+
Object.defineProperty(obj, key, val);
|
|
110
|
+
} else obj[key] = val.value;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function klona(x) {
|
|
114
|
+
if (typeof x !== 'object') return x;
|
|
115
|
+
|
|
116
|
+
var i=0, k, list, tmp, str=Object.prototype.toString.call(x);
|
|
117
|
+
|
|
118
|
+
if (str === '[object Object]') {
|
|
119
|
+
tmp = Object.create(x.__proto__ || null);
|
|
120
|
+
} else if (str === '[object Array]') {
|
|
121
|
+
tmp = Array(x.length);
|
|
122
|
+
} else if (str === '[object Set]') {
|
|
123
|
+
tmp = new Set;
|
|
124
|
+
x.forEach(function (val) {
|
|
125
|
+
tmp.add(klona(val));
|
|
126
|
+
});
|
|
127
|
+
} else if (str === '[object Map]') {
|
|
128
|
+
tmp = new Map;
|
|
129
|
+
x.forEach(function (val, key) {
|
|
130
|
+
tmp.set(klona(key), klona(val));
|
|
131
|
+
});
|
|
132
|
+
} else if (str === '[object Date]') {
|
|
133
|
+
tmp = new Date(+x);
|
|
134
|
+
} else if (str === '[object RegExp]') {
|
|
135
|
+
tmp = new RegExp(x.source, x.flags);
|
|
136
|
+
} else if (str === '[object DataView]') {
|
|
137
|
+
tmp = new x.constructor( klona(x.buffer) );
|
|
138
|
+
} else if (str === '[object ArrayBuffer]') {
|
|
139
|
+
tmp = x.slice(0);
|
|
140
|
+
} else if (str.slice(-6) === 'Array]') {
|
|
141
|
+
// ArrayBuffer.isView(x)
|
|
142
|
+
// ~> `new` bcuz `Buffer.slice` => ref
|
|
143
|
+
tmp = new x.constructor(x);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (tmp) {
|
|
147
|
+
for (list=Object.getOwnPropertySymbols(x); i < list.length; i++) {
|
|
148
|
+
set(tmp, list[i], Object.getOwnPropertyDescriptor(x, list[i]));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
for (i=0, list=Object.getOwnPropertyNames(x); i < list.length; i++) {
|
|
152
|
+
if (Object.hasOwnProperty.call(tmp, k=list[i]) && tmp[k] === x[k]) continue;
|
|
153
|
+
set(tmp, k, Object.getOwnPropertyDescriptor(x, k));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return tmp || x;
|
|
158
|
+
}
|
|
159
|
+
|
|
106
160
|
const FormContextKey = Symbol('vee-validate-form');
|
|
107
161
|
const FieldContextKey = Symbol('vee-validate-field-instance');
|
|
108
162
|
const IS_ABSENT = Symbol('Default empty value');
|
|
@@ -280,60 +334,6 @@
|
|
|
280
334
|
return a instanceof File;
|
|
281
335
|
}
|
|
282
336
|
|
|
283
|
-
function set(obj, key, val) {
|
|
284
|
-
if (typeof val.value === 'object') val.value = klona(val.value);
|
|
285
|
-
if (!val.enumerable || val.get || val.set || !val.configurable || !val.writable || key === '__proto__') {
|
|
286
|
-
Object.defineProperty(obj, key, val);
|
|
287
|
-
} else obj[key] = val.value;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
function klona(x) {
|
|
291
|
-
if (typeof x !== 'object') return x;
|
|
292
|
-
|
|
293
|
-
var i=0, k, list, tmp, str=Object.prototype.toString.call(x);
|
|
294
|
-
|
|
295
|
-
if (str === '[object Object]') {
|
|
296
|
-
tmp = Object.create(x.__proto__ || null);
|
|
297
|
-
} else if (str === '[object Array]') {
|
|
298
|
-
tmp = Array(x.length);
|
|
299
|
-
} else if (str === '[object Set]') {
|
|
300
|
-
tmp = new Set;
|
|
301
|
-
x.forEach(function (val) {
|
|
302
|
-
tmp.add(klona(val));
|
|
303
|
-
});
|
|
304
|
-
} else if (str === '[object Map]') {
|
|
305
|
-
tmp = new Map;
|
|
306
|
-
x.forEach(function (val, key) {
|
|
307
|
-
tmp.set(klona(key), klona(val));
|
|
308
|
-
});
|
|
309
|
-
} else if (str === '[object Date]') {
|
|
310
|
-
tmp = new Date(+x);
|
|
311
|
-
} else if (str === '[object RegExp]') {
|
|
312
|
-
tmp = new RegExp(x.source, x.flags);
|
|
313
|
-
} else if (str === '[object DataView]') {
|
|
314
|
-
tmp = new x.constructor( klona(x.buffer) );
|
|
315
|
-
} else if (str === '[object ArrayBuffer]') {
|
|
316
|
-
tmp = x.slice(0);
|
|
317
|
-
} else if (str.slice(-6) === 'Array]') {
|
|
318
|
-
// ArrayBuffer.isView(x)
|
|
319
|
-
// ~> `new` bcuz `Buffer.slice` => ref
|
|
320
|
-
tmp = new x.constructor(x);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
if (tmp) {
|
|
324
|
-
for (list=Object.getOwnPropertySymbols(x); i < list.length; i++) {
|
|
325
|
-
set(tmp, list[i], Object.getOwnPropertyDescriptor(x, list[i]));
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
for (i=0, list=Object.getOwnPropertyNames(x); i < list.length; i++) {
|
|
329
|
-
if (Object.hasOwnProperty.call(tmp, k=list[i]) && tmp[k] === x[k]) continue;
|
|
330
|
-
set(tmp, k, Object.getOwnPropertyDescriptor(x, k));
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
return tmp || x;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
337
|
function cleanupNonNestedPath(path) {
|
|
338
338
|
if (isNotNestedPath(path)) {
|
|
339
339
|
return path.replace(/\[|\]/gi, '');
|
|
@@ -930,7 +930,7 @@
|
|
|
930
930
|
}
|
|
931
931
|
async function validateTypedSchema(schema, values) {
|
|
932
932
|
const typedSchema = isTypedSchema(schema) ? schema : yupToTypedSchema(schema);
|
|
933
|
-
const validationResult = await typedSchema.parse(values);
|
|
933
|
+
const validationResult = await typedSchema.parse(klona(values));
|
|
934
934
|
const results = {};
|
|
935
935
|
const errors = {};
|
|
936
936
|
for (const error of validationResult.errors) {
|
|
@@ -1013,7 +1013,7 @@
|
|
|
1013
1013
|
value,
|
|
1014
1014
|
initialValue,
|
|
1015
1015
|
meta,
|
|
1016
|
-
flags: { pendingUnmount: { [id]: false } },
|
|
1016
|
+
flags: { pendingUnmount: { [id]: false }, pendingReset: false },
|
|
1017
1017
|
errors,
|
|
1018
1018
|
setState,
|
|
1019
1019
|
};
|
|
@@ -1188,7 +1188,12 @@
|
|
|
1188
1188
|
});
|
|
1189
1189
|
const errorMessage = vue.computed(() => errors.value[0]);
|
|
1190
1190
|
if (syncVModel) {
|
|
1191
|
-
useVModel({
|
|
1191
|
+
useVModel({
|
|
1192
|
+
value,
|
|
1193
|
+
prop: syncVModel,
|
|
1194
|
+
handleChange,
|
|
1195
|
+
shouldValidate: () => validateOnValueUpdate && !flags.pendingReset,
|
|
1196
|
+
});
|
|
1192
1197
|
}
|
|
1193
1198
|
/**
|
|
1194
1199
|
* Handles common onBlur meta update
|
|
@@ -1465,7 +1470,7 @@
|
|
|
1465
1470
|
}
|
|
1466
1471
|
return patchCheckedApi(_useField(name, rules, opts));
|
|
1467
1472
|
}
|
|
1468
|
-
function useVModel({ prop, value, handleChange }) {
|
|
1473
|
+
function useVModel({ prop, value, handleChange, shouldValidate }) {
|
|
1469
1474
|
const vm = vue.getCurrentInstance();
|
|
1470
1475
|
/* istanbul ignore next */
|
|
1471
1476
|
if (!vm || !prop) {
|
|
@@ -1491,7 +1496,7 @@
|
|
|
1491
1496
|
if (isEqual(newValue, value.value)) {
|
|
1492
1497
|
return;
|
|
1493
1498
|
}
|
|
1494
|
-
handleChange(newValue);
|
|
1499
|
+
handleChange(newValue, shouldValidate());
|
|
1495
1500
|
});
|
|
1496
1501
|
}
|
|
1497
1502
|
function getCurrentModelValue(vm, propName) {
|
|
@@ -1586,7 +1591,7 @@
|
|
|
1586
1591
|
checkedValue: ctx.attrs.value,
|
|
1587
1592
|
uncheckedValue,
|
|
1588
1593
|
label,
|
|
1589
|
-
validateOnValueUpdate:
|
|
1594
|
+
validateOnValueUpdate: props.validateOnModelUpdate,
|
|
1590
1595
|
keepValueOnUnmount: keepValue,
|
|
1591
1596
|
syncVModel: true,
|
|
1592
1597
|
});
|
|
@@ -1855,6 +1860,7 @@
|
|
|
1855
1860
|
multiple: false,
|
|
1856
1861
|
__flags: {
|
|
1857
1862
|
pendingUnmount: { [id]: false },
|
|
1863
|
+
pendingReset: false,
|
|
1858
1864
|
},
|
|
1859
1865
|
fieldsCount: 1,
|
|
1860
1866
|
validate: config === null || config === void 0 ? void 0 : config.validate,
|
|
@@ -2113,6 +2119,19 @@
|
|
|
2113
2119
|
validateField(path);
|
|
2114
2120
|
}
|
|
2115
2121
|
}
|
|
2122
|
+
function forceSetValues(fields, shouldValidate = true) {
|
|
2123
|
+
// clean up old values
|
|
2124
|
+
keysOf(formValues).forEach(key => {
|
|
2125
|
+
delete formValues[key];
|
|
2126
|
+
});
|
|
2127
|
+
// set up new values
|
|
2128
|
+
keysOf(fields).forEach(path => {
|
|
2129
|
+
setFieldValue(path, fields[path], false);
|
|
2130
|
+
});
|
|
2131
|
+
if (shouldValidate) {
|
|
2132
|
+
validate();
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2116
2135
|
/**
|
|
2117
2136
|
* Sets multiple fields values
|
|
2118
2137
|
*/
|
|
@@ -2185,30 +2204,43 @@
|
|
|
2185
2204
|
function resetField(field, state) {
|
|
2186
2205
|
var _a;
|
|
2187
2206
|
const newValue = state && 'value' in state ? state.value : getFromPath(initialValues.value, field);
|
|
2207
|
+
const pathState = findPathState(field);
|
|
2208
|
+
if (pathState) {
|
|
2209
|
+
pathState.__flags.pendingReset = true;
|
|
2210
|
+
}
|
|
2188
2211
|
setFieldInitialValue(field, klona(newValue));
|
|
2189
2212
|
setFieldValue(field, newValue, false);
|
|
2190
2213
|
setFieldTouched(field, (_a = state === null || state === void 0 ? void 0 : state.touched) !== null && _a !== void 0 ? _a : false);
|
|
2191
2214
|
setFieldError(field, (state === null || state === void 0 ? void 0 : state.errors) || []);
|
|
2215
|
+
vue.nextTick(() => {
|
|
2216
|
+
if (pathState) {
|
|
2217
|
+
pathState.__flags.pendingReset = false;
|
|
2218
|
+
}
|
|
2219
|
+
});
|
|
2192
2220
|
}
|
|
2193
2221
|
/**
|
|
2194
2222
|
* Resets all fields
|
|
2195
2223
|
*/
|
|
2196
|
-
function resetForm(resetState) {
|
|
2224
|
+
function resetForm(resetState, opts) {
|
|
2197
2225
|
let newValues = (resetState === null || resetState === void 0 ? void 0 : resetState.values) ? resetState.values : originalInitialValues.value;
|
|
2198
2226
|
newValues = isTypedSchema(schema) && isCallable(schema.cast) ? schema.cast(newValues) : newValues;
|
|
2199
2227
|
setInitialValues(newValues);
|
|
2200
2228
|
mutateAllPathState(state => {
|
|
2201
2229
|
var _a;
|
|
2230
|
+
state.__flags.pendingReset = true;
|
|
2202
2231
|
state.validated = false;
|
|
2203
2232
|
state.touched = ((_a = resetState === null || resetState === void 0 ? void 0 : resetState.touched) === null || _a === void 0 ? void 0 : _a[state.path]) || false;
|
|
2204
2233
|
setFieldValue(state.path, getFromPath(newValues, state.path), false);
|
|
2205
2234
|
setFieldError(state.path, undefined);
|
|
2206
2235
|
});
|
|
2207
|
-
setValues(newValues, false);
|
|
2236
|
+
(opts === null || opts === void 0 ? void 0 : opts.force) ? forceSetValues(newValues, false) : setValues(newValues, false);
|
|
2208
2237
|
setErrors((resetState === null || resetState === void 0 ? void 0 : resetState.errors) || {});
|
|
2209
2238
|
submitCount.value = (resetState === null || resetState === void 0 ? void 0 : resetState.submitCount) || 0;
|
|
2210
2239
|
vue.nextTick(() => {
|
|
2211
2240
|
validate({ mode: 'silent' });
|
|
2241
|
+
mutateAllPathState(state => {
|
|
2242
|
+
state.__flags.pendingReset = false;
|
|
2243
|
+
});
|
|
2212
2244
|
});
|
|
2213
2245
|
}
|
|
2214
2246
|
async function validate(opts) {
|
|
@@ -2258,7 +2290,7 @@
|
|
|
2258
2290
|
async function validateField(path, opts) {
|
|
2259
2291
|
var _a;
|
|
2260
2292
|
const state = findPathState(path);
|
|
2261
|
-
if (state) {
|
|
2293
|
+
if (state && (opts === null || opts === void 0 ? void 0 : opts.mode) !== 'silent') {
|
|
2262
2294
|
state.validated = true;
|
|
2263
2295
|
}
|
|
2264
2296
|
if (schema) {
|
|
@@ -3252,9 +3284,9 @@
|
|
|
3252
3284
|
*/
|
|
3253
3285
|
function useSetFormValues() {
|
|
3254
3286
|
const form = injectWithSelf(FormContextKey);
|
|
3255
|
-
function setFormValues(fields) {
|
|
3287
|
+
function setFormValues(fields, shouldValidate = true) {
|
|
3256
3288
|
if (form) {
|
|
3257
|
-
form.setValues(fields);
|
|
3289
|
+
form.setValues(fields, shouldValidate);
|
|
3258
3290
|
return;
|
|
3259
3291
|
}
|
|
3260
3292
|
}
|
package/dist/vee-validate.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v4.11.
|
|
2
|
+
* vee-validate v4.11.5
|
|
3
3
|
* (c) 2023 Abdelrahman Awad
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VeeValidate={},e.Vue)}(this,(function(e,t){"use strict";function n(e){return"function"==typeof e}function r(e){return null==e}const l=e=>null!==e&&!!e&&"object"==typeof e&&!Array.isArray(e);function a(e){return Number(e)>=0}function u(e){if(!function(e){return"object"==typeof e&&null!==e}(e)||"[object Object]"!==function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}(e))return!1;if(null===Object.getPrototypeOf(e))return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function i(e,t){return Object.keys(t).forEach((n=>{if(u(t[n]))return e[n]||(e[n]={}),void i(e[n],t[n]);e[n]=t[n]})),e}function o(e){const t=e.split(".");if(!t.length)return"";let n=String(t[0]);for(let e=1;e<t.length;e++)a(t[e])?n+=`[${t[e]}]`:n+=`.${t[e]}`;return n}const s={};const d=Symbol("vee-validate-form"),c=Symbol("vee-validate-field-instance"),v=Symbol("Default empty value"),f="undefined"!=typeof window;function p(e){return n(e)&&!!e.__locatorRef}function m(e){return!!e&&n(e.parse)&&"VVTypedSchema"===e.__type}function h(e){return!!e&&n(e.validate)}function y(e){return"checkbox"===e||"radio"===e}function g(e){return/^\[.+\]$/i.test(e)}function b(e){return"SELECT"===e.tagName}function V(e,t){return!function(e,t){const n=![!1,null,void 0,0].includes(t.multiple)&&!Number.isNaN(t.multiple);return"select"===e&&"multiple"in t&&n}(e,t)&&"file"!==t.type&&!y(t.type)}function O(e){return j(e)&&e.target&&"submit"in e.target}function j(e){return!!e&&(!!("undefined"!=typeof Event&&n(Event)&&e instanceof Event)||!(!e||!e.srcElement))}function A(e,t){return t in e&&e[t]!==v}function F(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;var n,r,l;if(Array.isArray(e)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(!F(e[r],t[r]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;for(r of e.entries())if(!F(r[1],t.get(r[0])))return!1;return!0}if(S(e)&&S(t))return e.size===t.size&&(e.name===t.name&&(e.lastModified===t.lastModified&&e.type===t.type));if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(e[r]!==t[r])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();for(r=n=(l=Object.keys(e)).length;0!=r--;){var a=l[r];if(!F(e[a],t[a]))return!1}return!0}return e!=e&&t!=t}function S(e){return!!f&&e instanceof File}function E(e,t,n){"object"==typeof n.value&&(n.value=w(n.value)),n.enumerable&&!n.get&&!n.set&&n.configurable&&n.writable&&"__proto__"!==t?e[t]=n.value:Object.defineProperty(e,t,n)}function w(e){if("object"!=typeof e)return e;var t,n,r,l=0,a=Object.prototype.toString.call(e);if("[object Object]"===a?r=Object.create(e.__proto__||null):"[object Array]"===a?r=Array(e.length):"[object Set]"===a?(r=new Set,e.forEach((function(e){r.add(w(e))}))):"[object Map]"===a?(r=new Map,e.forEach((function(e,t){r.set(w(t),w(e))}))):"[object Date]"===a?r=new Date(+e):"[object RegExp]"===a?r=new RegExp(e.source,e.flags):"[object DataView]"===a?r=new e.constructor(w(e.buffer)):"[object ArrayBuffer]"===a?r=e.slice(0):"Array]"===a.slice(-6)&&(r=new e.constructor(e)),r){for(n=Object.getOwnPropertySymbols(e);l<n.length;l++)E(r,n[l],Object.getOwnPropertyDescriptor(e,n[l]));for(l=0,n=Object.getOwnPropertyNames(e);l<n.length;l++)Object.hasOwnProperty.call(r,t=n[l])&&r[t]===e[t]||E(r,t,Object.getOwnPropertyDescriptor(e,t))}return r||e}function k(e){return g(e)?e.replace(/\[|\]/gi,""):e}function I(e,t,n){if(!e)return n;if(g(t))return e[k(t)];return(t||"").split(/\.|\[(\d+)\]/).filter(Boolean).reduce(((e,t)=>{return(l(r=e)||Array.isArray(r))&&t in e?e[t]:n;var r}),e)}function M(e,t,n){if(g(t))return void(e[k(t)]=n);const l=t.split(/\.|\[(\d+)\]/).filter(Boolean);let u=e;for(let e=0;e<l.length;e++){if(e===l.length-1)return void(u[l[e]]=n);l[e]in u&&!r(u[l[e]])||(u[l[e]]=a(l[e+1])?[]:{}),u=u[l[e]]}}function C(e,t){Array.isArray(e)&&a(t)?e.splice(Number(t),1):l(e)&&delete e[t]}function B(e,t){if(g(t))return void delete e[k(t)];const n=t.split(/\.|\[(\d+)\]/).filter(Boolean);let a=e;for(let e=0;e<n.length;e++){if(e===n.length-1){C(a,n[e]);break}if(!(n[e]in a)||r(a[n[e]]))break;a=a[n[e]]}const u=n.map(((t,r)=>I(e,n.slice(0,r).join("."))));for(let t=u.length-1;t>=0;t--)i=u[t],(Array.isArray(i)?0===i.length:l(i)&&0===Object.keys(i).length)&&(0!==t?C(u[t-1],n[t-1]):C(e,n[0]));var i}function T(e){return Object.keys(e)}function P(e,n=void 0){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function U(e,t,n){if(Array.isArray(e)){const n=[...e],r=n.findIndex((e=>F(e,t)));return r>=0?n.splice(r,1):n.push(t),n}return F(e,t)?n:t}function _(e,t=0){let n=null,r=[];return function(...l){return n&&clearTimeout(n),n=setTimeout((()=>{const t=e(...l);r.forEach((e=>e(t))),r=[]}),t),new Promise((e=>r.push(e)))}}function R(e,t){return l(t)&&t.number?function(e){const t=parseFloat(e);return isNaN(t)?e:t}(e):e}function x(e,t){let n;return async function(...r){const l=e(...r);n=l;const a=await l;return l!==n||(n=void 0,t(a,r)),a}}function N({get:e,set:n}){const r=t.ref(w(e()));return t.watch(e,(e=>{F(e,r.value)||(r.value=w(e))}),{deep:!0}),t.watch(r,(t=>{F(t,e())||n(w(t))}),{deep:!0}),r}function $(e){return Array.isArray(e)?e:e?[e]:[]}function D(e){const n=P(d),r=e?t.computed((()=>null==n?void 0:n.getPathState(t.toValue(e)))):void 0,l=e?void 0:t.inject(c);return!l&&(null==r||r.value),r||l}function z(e,t){const n={};for(const r in e)t.includes(r)||(n[r]=e[r]);return n}const q=(e,t,n)=>t.slots.default?"string"!=typeof e&&e?{default:()=>{var e,r;return null===(r=(e=t.slots).default)||void 0===r?void 0:r.call(e,n())}}:t.slots.default(n()):t.slots.default;function L(e){if(K(e))return e._value}function K(e){return"_value"in e}function W(e){if(!j(e))return e;const t=e.target;if(y(t.type)&&K(t))return L(t);if("file"===t.type&&t.files){const e=Array.from(t.files);return t.multiple?e:e[0]}if(b(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map(L);var n;if(b(t)){const e=Array.from(t.options).find((e=>e.selected));return e?L(e):t.value}return function(e){return"number"===e.type||"range"===e.type?Number.isNaN(e.valueAsNumber)?e.value:e.valueAsNumber:e.value}(t)}function G(e){const t={};return Object.defineProperty(t,"_$$isNormalized",{value:!0,writable:!1,enumerable:!1,configurable:!1}),e?l(e)&&e._$$isNormalized?e:l(e)?Object.keys(e).reduce(((t,n)=>{const r=function(e){if(!0===e)return[];if(Array.isArray(e))return e;if(l(e))return e;return[e]}(e[n]);return!1!==e[n]&&(t[n]=X(r)),t}),t):"string"!=typeof e?t:e.split("|").reduce(((e,t)=>{const n=H(t);return n.name?(e[n.name]=X(n.params),e):e}),t):t}function X(e){const t=e=>"string"==typeof e&&"@"===e[0]?function(e){const t=t=>I(t,e)||t[e];return t.__locatorRef=e,t}(e.slice(1)):e;return Array.isArray(e)?e.map(t):e instanceof RegExp?[e]:Object.keys(e).reduce(((n,r)=>(n[r]=t(e[r]),n)),{})}const H=e=>{let t=[];const n=e.split(":")[0];return e.includes(":")&&(t=e.split(":").slice(1).join(":").split(",")),{name:n,params:t}};let J=Object.assign({},{generateMessage:({field:e})=>`${e} is not valid.`,bails:!0,validateOnBlur:!0,validateOnChange:!0,validateOnInput:!1,validateOnModelUpdate:!0});const Q=()=>J,Y=e=>{J=Object.assign(Object.assign({},J),e)};async function Z(e,t,r={}){const l=null==r?void 0:r.bails,a={name:(null==r?void 0:r.name)||"{field}",rules:t,label:null==r?void 0:r.label,bails:null==l||l,formData:(null==r?void 0:r.values)||{}},u=await async function(e,t){if(m(e.rules)||h(e.rules))return async function(e,t){const n=m(t)?t:ee(t),r=await n.parse(e),l=[];for(const e of r.errors)e.errors.length&&l.push(...e.errors);return{errors:l}}(t,e.rules);if(n(e.rules)||Array.isArray(e.rules)){const n={field:e.label||e.name,name:e.name,label:e.label,form:e.formData,value:t},r=Array.isArray(e.rules)?e.rules:[e.rules],l=r.length,a=[];for(let u=0;u<l;u++){const l=r[u],i=await l(t,n);if(!("string"!=typeof i&&!Array.isArray(i)&&i)){if(Array.isArray(i))a.push(...i);else{const e="string"==typeof i?i:ne(n);a.push(e)}if(e.bails)return{errors:a}}}return{errors:a}}const r=Object.assign(Object.assign({},e),{rules:G(e.rules)}),l=[],a=Object.keys(r.rules),u=a.length;for(let n=0;n<u;n++){const u=a[n],i=await te(r,t,{name:u,params:r.rules[u]});if(i.error&&(l.push(i.error),e.bails))return{errors:l}}return{errors:l}}(a,e),i=u.errors;return{errors:i,valid:!i.length}}function ee(e){return{__type:"VVTypedSchema",async parse(t){var n;try{return{output:await e.validate(t,{abortEarly:!1}),errors:[]}}catch(e){if(!function(e){return!!e&&"ValidationError"===e.name}(e))throw e;if(!(null===(n=e.inner)||void 0===n?void 0:n.length)&&e.errors.length)return{errors:[{path:e.path,errors:e.errors}]};const t=e.inner.reduce(((e,t)=>{const n=t.path||"";return e[n]||(e[n]={errors:[],path:n}),e[n].errors.push(...t.errors),e}),{});return{errors:Object.values(t)}}}}}async function te(e,t,n){const r=(l=n.name,s[l]);var l;if(!r)throw new Error(`No such validator '${n.name}' exists.`);const a=function(e,t){const n=e=>p(e)?e(t):e;if(Array.isArray(e))return e.map(n);return Object.keys(e).reduce(((t,r)=>(t[r]=n(e[r]),t)),{})}(n.params,e.formData),u={field:e.label||e.name,name:e.name,label:e.label,value:t,form:e.formData,rule:Object.assign(Object.assign({},n),{params:a})},i=await r(t,a,u);return"string"==typeof i?{error:i}:{error:i?void 0:ne(u)}}function ne(e){const t=Q().generateMessage;return t?t(e):"Field is invalid"}async function re(e,t,n){const r=T(e).map((async r=>{var l,a,u;const i=null===(l=null==n?void 0:n.names)||void 0===l?void 0:l[r],o=await Z(I(t,r),e[r],{name:(null==i?void 0:i.name)||r,label:null==i?void 0:i.label,values:t,bails:null===(u=null===(a=null==n?void 0:n.bailsMap)||void 0===a?void 0:a[r])||void 0===u||u});return Object.assign(Object.assign({},o),{path:r})}));let l=!0;const a=await Promise.all(r),u={},i={};for(const e of a)u[e.path]={valid:e.valid,errors:e.errors},e.valid||(l=!1,i[e.path]=e.errors[0]);return{valid:l,results:u,errors:i}}let le=0;function ae(e,n){const{value:r,initialValue:l,setInitialValue:a}=function(e,n,r){const l=t.ref(t.unref(n));function a(){return r?I(r.initialValues.value,t.unref(e),t.unref(l)):t.unref(l)}function u(n){r?r.stageInitialValue(t.unref(e),n,!0):l.value=n}const i=t.computed(a);if(!r){return{value:t.ref(a()),initialValue:i,setInitialValue:u}}const o=function(e,n,r,l){if(t.isRef(e))return t.unref(e);if(void 0!==e)return e;return I(n.values,t.unref(l),t.unref(r))}(n,r,i,e);r.stageInitialValue(t.unref(e),o,!0);const s=t.computed({get:()=>I(r.values,t.unref(e)),set(n){r.setFieldValue(t.unref(e),n,!1)}});return{value:s,initialValue:i,setInitialValue:u}}(e,n.modelValue,n.form);if(!n.form){const{errors:o,setErrors:s}=function(){const e=t.ref([]);return{errors:e,setErrors:t=>{e.value=$(t)}}}(),d=le>=Number.MAX_SAFE_INTEGER?0:++le,c=function(e,n,r){const l=t.reactive({touched:!1,pending:!1,valid:!0,validated:!!t.unref(r).length,initialValue:t.computed((()=>t.unref(n))),dirty:t.computed((()=>!F(t.unref(e),t.unref(n))))});return t.watch(r,(e=>{l.valid=!e.length}),{immediate:!0,flush:"sync"}),l}(r,l,o);function v(e){var t;"value"in e&&(r.value=e.value),"errors"in e&&s(e.errors),"touched"in e&&(c.touched=null!==(t=e.touched)&&void 0!==t?t:c.touched),"initialValue"in e&&a(e.initialValue)}return{id:d,path:e,value:r,initialValue:l,meta:c,flags:{pendingUnmount:{[d]:!1}},errors:o,setState:v}}const u=n.form.createPathState(e,{bails:n.bails,label:n.label,type:n.type,validate:n.validate}),i=t.computed((()=>u.errors));return{id:Array.isArray(u.id)?u.id[u.id.length-1]:u.id,path:e,value:r,errors:i,meta:u,initialValue:l,flags:u.__flags,setState:function(l){var u,i,o;"value"in l&&(r.value=l.value),"errors"in l&&(null===(u=n.form)||void 0===u||u.setFieldError(t.unref(e),l.errors)),"touched"in l&&(null===(i=n.form)||void 0===i||i.setFieldTouched(t.unref(e),null!==(o=l.touched)&&void 0!==o&&o)),"initialValue"in l&&a(l.initialValue)}}}function ue(e,n,r){return y(null==r?void 0:r.type)?function(e,n,r){const l=(null==r?void 0:r.standalone)?void 0:P(d),a=null==r?void 0:r.checkedValue,u=null==r?void 0:r.uncheckedValue;function i(n){const i=n.handleChange,o=t.computed((()=>{const e=t.toValue(n.value),r=t.toValue(a);return Array.isArray(e)?e.findIndex((e=>F(e,r)))>=0:F(r,e)}));function s(s,d=!0){var c,v;if(o.value===(null===(c=null==s?void 0:s.target)||void 0===c?void 0:c.checked))return void(d&&n.validate());const f=t.toValue(e),p=null==l?void 0:l.getPathState(f),m=W(s);let h=null!==(v=t.toValue(a))&&void 0!==v?v:m;l&&(null==p?void 0:p.multiple)&&"checkbox"===p.type?h=U(I(l.values,f)||[],h,void 0):"checkbox"===(null==r?void 0:r.type)&&(h=U(t.toValue(n.value),h,t.toValue(u))),i(h,d)}return Object.assign(Object.assign({},n),{checked:o,checkedValue:a,uncheckedValue:u,handleChange:s})}return i(ie(e,n,r))}(e,n,r):ie(e,n,r)}function ie(e,r,l){const{initialValue:a,validateOnMount:u,bails:i,type:s,checkedValue:f,label:y,validateOnValueUpdate:g,uncheckedValue:b,controlled:V,keepValueOnUnmount:O,syncVModel:j,form:A}=function(e){const n=()=>({initialValue:void 0,validateOnMount:!1,bails:!0,label:void 0,validateOnValueUpdate:!0,keepValueOnUnmount:void 0,syncVModel:!1,controlled:!0}),r=!!(null==e?void 0:e.syncVModel),l="string"==typeof(null==e?void 0:e.syncVModel)?e.syncVModel:(null==e?void 0:e.modelPropName)||"modelValue",a=r&&!("initialValue"in(e||{}))?oe(t.getCurrentInstance(),l):null==e?void 0:e.initialValue;if(!e)return Object.assign(Object.assign({},n()),{initialValue:a});const u="valueProp"in e?e.valueProp:e.checkedValue,i="standalone"in e?!e.standalone:e.controlled,o=(null==e?void 0:e.modelPropName)||(null==e?void 0:e.syncVModel)||!1;return Object.assign(Object.assign(Object.assign({},n()),e||{}),{initialValue:a,controlled:null==i||i,checkedValue:u,syncVModel:o})}(l),S=V?P(d):void 0,E=A||S,k=t.computed((()=>o(t.toValue(e)))),M=t.computed((()=>{if(t.toValue(null==E?void 0:E.schema))return;const e=t.unref(r);return h(e)||m(e)||n(e)||Array.isArray(e)?e:G(e)})),{id:C,value:B,initialValue:U,meta:_,setState:N,errors:$,flags:D}=ae(k,{modelValue:a,form:E,bails:i,label:y,type:s,validate:M.value?X:void 0}),z=t.computed((()=>$.value[0]));j&&function({prop:e,value:n,handleChange:r}){const l=t.getCurrentInstance();if(!l||!e)return;const a="string"==typeof e?e:"modelValue",u=`update:${a}`;if(!(a in l.props))return;t.watch(n,(e=>{F(e,oe(l,a))||l.emit(u,e)})),t.watch((()=>oe(l,a)),(e=>{if(e===v&&void 0===n.value)return;const t=e===v?void 0:e;F(t,n.value)||r(t)}))}({value:B,prop:j,handleChange:H});async function q(e){var n,r;return(null==E?void 0:E.validateSchema)?null!==(n=(await E.validateSchema(e)).results[t.toValue(k)])&&void 0!==n?n:{valid:!0,errors:[]}:M.value?Z(B.value,M.value,{name:t.toValue(k),label:t.toValue(y),values:null!==(r=null==E?void 0:E.values)&&void 0!==r?r:{},bails:i}):{valid:!0,errors:[]}}const L=x((async()=>(_.pending=!0,_.validated=!0,q("validated-only"))),(e=>{if(!D.pendingUnmount[te.id])return N({errors:e.errors}),_.pending=!1,_.valid=e.valid,e})),K=x((async()=>q("silent")),(e=>(_.valid=e.valid,e)));function X(e){return"silent"===(null==e?void 0:e.mode)?K():L()}function H(e,t=!0){Y(W(e),t)}function J(e){var t;const n=e&&"value"in e?e.value:U.value;N({value:w(n),initialValue:w(n),touched:null!==(t=null==e?void 0:e.touched)&&void 0!==t&&t,errors:(null==e?void 0:e.errors)||[]}),_.pending=!1,_.validated=!1,K()}t.onMounted((()=>{if(u)return L();E&&E.validateSchema||K()}));const Q=t.getCurrentInstance();function Y(e,t=!0){B.value=Q&&j?R(e,Q.props.modelModifiers):e;(t?L:K)()}const ee=t.computed({get:()=>B.value,set(e){Y(e,g)}}),te={id:C,name:k,label:y,value:ee,meta:_,errors:$,errorMessage:z,type:s,checkedValue:f,uncheckedValue:b,bails:i,keepValueOnUnmount:O,resetField:J,handleReset:()=>J(),validate:X,handleChange:H,handleBlur:(e,t=!1)=>{_.touched=!0,t&&L()},setState:N,setTouched:function(e){_.touched=e},setErrors:function(e){N({errors:Array.isArray(e)?e:[e]})},setValue:Y};if(t.provide(c,te),t.isRef(r)&&"function"!=typeof t.unref(r)&&t.watch(r,((e,t)=>{F(e,t)||(_.validated?L():K())}),{deep:!0}),!E)return te;const ne=t.computed((()=>{const e=M.value;return!e||n(e)||h(e)||m(e)||Array.isArray(e)?{}:Object.keys(e).reduce(((t,n)=>{const r=(l=e[n],Array.isArray(l)?l.filter(p):T(l).filter((e=>p(l[e]))).map((e=>l[e]))).map((e=>e.__locatorRef)).reduce(((e,t)=>{const n=I(E.values,t)||E.values[t];return void 0!==n&&(e[t]=n),e}),{});var l;return Object.assign(t,r),t}),{})}));return t.watch(ne,((e,t)=>{if(!Object.keys(e).length)return;!F(e,t)&&(_.validated?L():K())})),t.onBeforeUnmount((()=>{var e;const n=null!==(e=t.toValue(te.keepValueOnUnmount))&&void 0!==e?e:t.toValue(E.keepValuesOnUnmount),r=t.toValue(k);if(n||!E||D.pendingUnmount[te.id])return void(null==E||E.removePathState(r,C));D.pendingUnmount[te.id]=!0;const l=E.getPathState(r);if(Array.isArray(null==l?void 0:l.id)&&(null==l?void 0:l.multiple)?null==l?void 0:l.id.includes(te.id):(null==l?void 0:l.id)===te.id){if((null==l?void 0:l.multiple)&&Array.isArray(l.value)){const e=l.value.findIndex((e=>F(e,t.toValue(te.checkedValue))));if(e>-1){const t=[...l.value];t.splice(e,1),E.setFieldValue(r,t)}Array.isArray(l.id)&&l.id.splice(l.id.indexOf(te.id),1)}else E.unsetPathValue(t.toValue(k));E.removePathState(r,C)}})),te}function oe(e,t){if(e)return e.props[t]}function se(e,t){let n=e.as||"";return e.as||t.slots.default||(n="input"),n}function de(e,t){return y(t.attrs.type)?A(e,"modelValue")?e.modelValue:void 0:A(e,"modelValue")?e.modelValue:t.attrs.value}const ce=t.defineComponent({name:"Field",inheritAttrs:!1,props:{as:{type:[String,Object],default:void 0},name:{type:String,required:!0},rules:{type:[Object,String,Function],default:void 0},validateOnMount:{type:Boolean,default:!1},validateOnBlur:{type:Boolean,default:void 0},validateOnChange:{type:Boolean,default:void 0},validateOnInput:{type:Boolean,default:void 0},validateOnModelUpdate:{type:Boolean,default:void 0},bails:{type:Boolean,default:()=>Q().bails},label:{type:String,default:void 0},uncheckedValue:{type:null,default:void 0},modelValue:{type:null,default:v},modelModifiers:{type:null,default:()=>({})},"onUpdate:modelValue":{type:null,default:void 0},standalone:{type:Boolean,default:!1},keepValue:{type:Boolean,default:void 0}},setup(e,r){const l=t.toRef(e,"rules"),a=t.toRef(e,"name"),u=t.toRef(e,"label"),i=t.toRef(e,"uncheckedValue"),o=t.toRef(e,"keepValue"),{errors:s,value:d,errorMessage:c,validate:v,handleChange:f,handleBlur:p,setTouched:m,resetField:h,handleReset:g,meta:b,checked:O,setErrors:j}=ue(a,l,{validateOnMount:e.validateOnMount,bails:e.bails,standalone:e.standalone,type:r.attrs.type,initialValue:de(e,r),checkedValue:r.attrs.value,uncheckedValue:i,label:u,validateOnValueUpdate:!1,keepValueOnUnmount:o,syncVModel:!0}),A=function(e,t=!0){f(e,t),r.emit("update:modelValue",d.value)},F=t.computed((()=>{const{validateOnInput:t,validateOnChange:l,validateOnBlur:a,validateOnModelUpdate:u}=function(e){var t,n,r,l;const{validateOnInput:a,validateOnChange:u,validateOnBlur:i,validateOnModelUpdate:o}=Q();return{validateOnInput:null!==(t=e.validateOnInput)&&void 0!==t?t:a,validateOnChange:null!==(n=e.validateOnChange)&&void 0!==n?n:u,validateOnBlur:null!==(r=e.validateOnBlur)&&void 0!==r?r:i,validateOnModelUpdate:null!==(l=e.validateOnModelUpdate)&&void 0!==l?l:o}}(e);const i={name:e.name,onBlur:function(e){p(e,a),n(r.attrs.onBlur)&&r.attrs.onBlur(e)},onInput:function(e){A(e,t),n(r.attrs.onInput)&&r.attrs.onInput(e)},onChange:function(e){A(e,l),n(r.attrs.onChange)&&r.attrs.onChange(e)},"onUpdate:modelValue":e=>A(e,u)};return i})),S=t.computed((()=>{const t=Object.assign({},F.value);y(r.attrs.type)&&O&&(t.checked=O.value);return V(se(e,r),r.attrs)&&(t.value=d.value),t})),E=t.computed((()=>Object.assign(Object.assign({},F.value),{modelValue:d.value})));function w(){return{field:S.value,componentField:E.value,value:d.value,meta:b,errors:s.value,errorMessage:c.value,validate:v,resetField:h,handleChange:A,handleInput:e=>A(e,!1),handleReset:g,handleBlur:F.value.onBlur,setTouched:m,setErrors:j}}return r.expose({setErrors:j,setTouched:m,reset:h,validate:v,handleChange:f}),()=>{const n=t.resolveDynamicComponent(se(e,r)),l=q(n,r,w);return n?t.h(n,Object.assign(Object.assign({},r.attrs),S.value),l):l}}});let ve=0;const fe=["bails","fieldsCount","id","multiple","type","validate"];function pe(e){const r=t.unref(null==e?void 0:e.initialValues)||{},l=t.unref(null==e?void 0:e.validationSchema);return l&&m(l)&&n(l.cast)?w(l.cast(r)||{}):w(r)}function me(e){var r;const l=ve++;let a=0;const u=t.ref(!1),s=t.ref(!1),c=t.ref(0),v=[],f=t.reactive(pe(e)),p=t.ref([]),y=t.ref({}),g=t.ref({}),b=function(e){let n=null,r=[];return function(...l){const a=t.nextTick((()=>{if(n!==a)return;const t=e(...l);r.forEach((e=>e(t))),r=[],n=null}));return n=a,new Promise((e=>r.push(e)))}}((()=>{g.value=p.value.reduce(((e,n)=>(e[o(t.toValue(n.path))]=n,e)),{})}));function V(e,t){const n=Y(e);if(n){if("string"==typeof e){const t=o(e);y.value[t]&&delete y.value[t]}n.errors=$(t),n.valid=!n.errors.length}else"string"==typeof e&&(y.value[o(e)]=$(t))}function j(e){T(e).forEach((t=>{V(t,e[t])}))}(null==e?void 0:e.initialErrors)&&j(e.initialErrors);const A=t.computed((()=>{const e=p.value.reduce(((e,t)=>(t.errors.length&&(e[t.path]=t.errors),e)),{});return Object.assign(Object.assign({},y.value),e)})),S=t.computed((()=>T(A.value).reduce(((e,t)=>{const n=A.value[t];return(null==n?void 0:n.length)&&(e[t]=n[0]),e}),{}))),E=t.computed((()=>p.value.reduce(((e,t)=>(e[t.path]={name:t.path||"",label:t.label||""},e)),{}))),k=t.computed((()=>p.value.reduce(((e,t)=>{var n;return e[t.path]=null===(n=t.bails)||void 0===n||n,e}),{}))),C=Object.assign({},(null==e?void 0:e.initialErrors)||{}),P=null!==(r=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==r&&r,{initialValues:U,originalInitialValues:R,setInitialValues:N}=function(e,n,r){const l=pe(r),a=null==r?void 0:r.initialValues,u=t.ref(l),o=t.ref(w(l));function s(t,r=!1){u.value=i(w(u.value)||{},w(t)),o.value=i(w(o.value)||{},w(t)),r&&e.value.forEach((e=>{if(e.touched)return;const t=I(u.value,e.path);M(n,e.path,w(t))}))}t.isRef(a)&&t.watch(a,(e=>{e&&s(e,!0)}),{deep:!0});return{initialValues:u,originalInitialValues:o,setInitialValues:s}}(p,f,e),D=function(e,n,r,l){const a={touched:"some",pending:"some",valid:"every"},u=t.computed((()=>!F(n,t.unref(r))));function i(){const t=e.value;return T(a).reduce(((e,n)=>{const r=a[n];return e[n]=t[r]((e=>e[n])),e}),{})}const o=t.reactive(i());return t.watchEffect((()=>{const e=i();o.touched=e.touched,o.valid=e.valid,o.pending=e.pending})),t.computed((()=>Object.assign(Object.assign({initialValues:t.unref(r)},o),{valid:o.valid&&!T(l.value).length,dirty:u.value})))}(p,f,R,S),q=t.computed((()=>p.value.reduce(((e,t)=>{const n=I(f,t.path);return M(e,t.path,n),e}),{}))),L=null==e?void 0:e.validationSchema;function K(e,n){var r,l;const u=t.computed((()=>I(U.value,t.toValue(e)))),i=g.value[t.toValue(e)];if(i){"checkbox"!==(null==n?void 0:n.type)&&"radio"!==(null==n?void 0:n.type)||(i.multiple=!0);const e=a++;return Array.isArray(i.id)?i.id.push(e):i.id=[i.id,e],i.fieldsCount++,i.__flags.pendingUnmount[e]=!1,i}const o=t.computed((()=>I(f,t.toValue(e)))),s=t.toValue(e),d=a++,c=t.reactive({id:d,path:e,touched:!1,pending:!1,valid:!0,validated:!!(null===(r=C[s])||void 0===r?void 0:r.length),initialValue:u,errors:t.shallowRef([]),bails:null!==(l=null==n?void 0:n.bails)&&void 0!==l&&l,label:null==n?void 0:n.label,type:(null==n?void 0:n.type)||"default",value:o,multiple:!1,__flags:{pendingUnmount:{[d]:!1}},fieldsCount:1,validate:null==n?void 0:n.validate,dirty:t.computed((()=>!F(t.unref(o),t.unref(u))))});return p.value.push(c),g.value[s]=c,b(),S.value[s]&&!C[s]&&t.nextTick((()=>{ye(s,{mode:"silent"})})),t.isRef(e)&&t.watch(e,(e=>{b();const n=w(o.value);g.value[e]=c,t.nextTick((()=>{M(f,e,n)}))})),c}const G=_(Ve,5),X=_(Ve,5),H=x((async e=>"silent"===await e?G():X()),((e,[t])=>{const n=T(ae.errorBag.value);return[...new Set([...T(e.results),...p.value.map((e=>e.path)),...n])].sort().reduce(((n,r)=>{const l=r,a=Y(l)||function(e){const t=p.value.filter((t=>e.startsWith(t.path)));return t.reduce(((e,t)=>e?t.path.length>e.path.length?t:e:t),void 0)}(l),u=(e.results[l]||{errors:[]}).errors,i={errors:u,valid:!u.length};return n.results[l]=i,i.valid||(n.errors[l]=i.errors[0]),a&&y.value[l]&&delete y.value[l],a?(a.valid=i.valid,"silent"===t?n:"validated-only"!==t||a.validated?(V(a,i.errors),n):n):(V(l,u),n)}),{valid:e.valid,results:{},errors:{}})}));function J(e){p.value.forEach(e)}function Y(e){const t="string"==typeof e?o(e):e;return"string"==typeof t?g.value[t]:t}let Z,te=[];function ne(e){return function(t,n){return function(r){return r instanceof Event&&(r.preventDefault(),r.stopPropagation()),J((e=>e.touched=!0)),u.value=!0,c.value++,he().then((l=>{const a=w(f);if(l.valid&&"function"==typeof t){const n=w(q.value);let u=e?n:a;return l.values&&(u=l.values),t(u,{evt:r,controlledValues:n,setErrors:j,setFieldError:V,setTouched:de,setFieldTouched:se,setValues:ie,setFieldValue:ue,resetForm:me,resetField:ce})}l.valid||"function"!=typeof n||n({values:a,evt:r,errors:l.errors,results:l.results})})).then((e=>(u.value=!1,e)),(e=>{throw u.value=!1,e}))}}}const le=ne(!1);le.withControlled=ne(!0);const ae={formId:l,values:f,controlledValues:q,errorBag:A,errors:S,schema:L,submitCount:c,meta:D,isSubmitting:u,isValidating:s,fieldArrays:v,keepValuesOnUnmount:P,validateSchema:t.unref(L)?H:void 0,validate:he,setFieldError:V,validateField:ye,setFieldValue:ue,setValues:ie,setErrors:j,setFieldTouched:se,setTouched:de,resetForm:me,resetField:ce,handleSubmit:le,stageInitialValue:function(t,n,r=!1){be(t,n),M(f,t,n),r&&!(null==e?void 0:e.initialValues)&&M(R.value,t,w(n))},unsetInitialValue:ge,setFieldInitialValue:be,useFieldModel:function(e){if(!Array.isArray(e))return oe(e);return e.map(oe)},createPathState:K,getPathState:Y,unsetPathValue:function(e){return te.push(e),Z||(Z=t.nextTick((()=>{[...te].sort().reverse().forEach((e=>{B(f,e)})),te=[],Z=null}))),Z},removePathState:function(e,n){const r=p.value.findIndex((t=>t.path===e)),l=p.value[r];if(-1!==r&&l){if(t.nextTick((()=>{ye(e,{mode:"silent",warn:!1})})),l.multiple&&l.fieldsCount&&l.fieldsCount--,Array.isArray(l.id)){const e=l.id.indexOf(n);e>=0&&l.id.splice(e,1),delete l.__flags.pendingUnmount[n]}(!l.multiple||l.fieldsCount<=0)&&(p.value.splice(r,1),ge(e),b(),delete g.value[e])}},initialValues:U,getAllPathStates:()=>p.value,markForUnmount:function(e){return J((t=>{t.path.startsWith(e)&&T(t.__flags.pendingUnmount).forEach((e=>{t.__flags.pendingUnmount[e]=!0}))}))},isFieldTouched:function(e){var t;return!!(null===(t=Y(e))||void 0===t?void 0:t.touched)},isFieldDirty:function(e){var t;return!!(null===(t=Y(e))||void 0===t?void 0:t.dirty)},isFieldValid:function(e){var t;return!!(null===(t=Y(e))||void 0===t?void 0:t.valid)}};function ue(e,t,n=!0){const r=w(t),l="string"==typeof e?e:e.path;Y(l)||K(l),M(f,l,r),n&&ye(l)}function ie(e,t=!0){i(f,e),v.forEach((e=>e&&e.reset())),t&&he()}function oe(e){const n=Y(t.unref(e))||K(e);return t.computed({get:()=>n.value,set(r){const l=t.unref(e);ue(l,r,!1),n.validated=!0,n.pending=!0,ye(l).then((()=>{n.pending=!1}))}})}function se(e,t){const n=Y(e);n&&(n.touched=t)}function de(e){"boolean"!=typeof e?T(e).forEach((t=>{se(t,!!e[t])})):J((t=>{t.touched=e}))}function ce(e,t){var n;const r=t&&"value"in t?t.value:I(U.value,e);be(e,w(r)),ue(e,r,!1),se(e,null!==(n=null==t?void 0:t.touched)&&void 0!==n&&n),V(e,(null==t?void 0:t.errors)||[])}function me(e){let r=(null==e?void 0:e.values)?e.values:R.value;r=m(L)&&n(L.cast)?L.cast(r):r,N(r),J((t=>{var n;t.validated=!1,t.touched=(null===(n=null==e?void 0:e.touched)||void 0===n?void 0:n[t.path])||!1,ue(t.path,I(r,t.path),!1),V(t.path,void 0)})),ie(r,!1),j((null==e?void 0:e.errors)||{}),c.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{he({mode:"silent"})}))}async function he(e){const t=(null==e?void 0:e.mode)||"force";if("force"===t&&J((e=>e.validated=!0)),ae.validateSchema)return ae.validateSchema(t);s.value=!0;const n=await Promise.all(p.value.map((t=>t.validate?t.validate(e).then((e=>({key:t.path,valid:e.valid,errors:e.errors}))):Promise.resolve({key:t.path,valid:!0,errors:[]}))));s.value=!1;const r={},l={};for(const e of n)r[e.key]={valid:e.valid,errors:e.errors},e.errors.length&&(l[e.key]=e.errors[0]);return{valid:n.every((e=>e.valid)),results:r,errors:l}}async function ye(e,t){const n=Y(e);if(n&&(n.validated=!0),L){const{results:n}=await H((null==t?void 0:t.mode)||"validated-only");return n[e]||{errors:[],valid:!0}}return(null==n?void 0:n.validate)?n.validate(t):(!n&&(null==t?void 0:t.warn),Promise.resolve({errors:[],valid:!0}))}function ge(e){B(U.value,e)}function be(e,t){M(U.value,e,w(t))}async function Ve(){const e=t.unref(L);if(!e)return{valid:!0,results:{},errors:{}};s.value=!0;const n=h(e)||m(e)?await async function(e,t){const n=m(e)?e:ee(e),r=await n.parse(t),l={},a={};for(const e of r.errors){const t=e.errors,n=(e.path||"").replace(/\["(\d+)"\]/g,((e,t)=>`[${t}]`));l[n]={valid:!t.length,errors:t},t.length&&(a[n]=t[0])}return{valid:!r.errors.length,results:l,errors:a,values:r.value}}(e,f):await re(e,f,{names:E.value,bailsMap:k.value});return s.value=!1,n}const Oe=le(((e,{evt:t})=>{O(t)&&t.target.submit()}));return t.onMounted((()=>{(null==e?void 0:e.initialErrors)&&j(e.initialErrors),(null==e?void 0:e.initialTouched)&&de(e.initialTouched),(null==e?void 0:e.validateOnMount)?he():ae.validateSchema&&ae.validateSchema("silent")})),t.isRef(L)&&t.watch(L,(()=>{var e;null===(e=ae.validateSchema)||void 0===e||e.call(ae,"validated-only")})),t.provide(d,ae),Object.assign(Object.assign({},ae),{values:t.readonly(f),handleReset:()=>me(),submitForm:Oe,defineComponentBinds:function(e,r){const l=Y(t.toValue(e))||K(e),a=()=>n(r)?r(z(l,fe)):r||{};function u(){var e;l.touched=!0;(null!==(e=a().validateOnBlur)&&void 0!==e?e:Q().validateOnBlur)&&ye(l.path)}function i(e){var t;const n=null!==(t=a().validateOnModelUpdate)&&void 0!==t?t:Q().validateOnModelUpdate;ue(l.path,e,n)}return t.computed((()=>{if(n(r)){const e=r(l),t=e.model||"modelValue";return Object.assign({onBlur:u,[t]:l.value,[`onUpdate:${t}`]:i},e.props||{})}const e=(null==r?void 0:r.model)||"modelValue",t={onBlur:u,[e]:l.value,[`onUpdate:${e}`]:i};return(null==r?void 0:r.mapProps)?Object.assign(Object.assign({},t),r.mapProps(z(l,fe))):t}))},defineInputBinds:function(e,r){const l=Y(t.toValue(e))||K(e),a=()=>n(r)?r(z(l,fe)):r||{};function u(){var e;l.touched=!0;(null!==(e=a().validateOnBlur)&&void 0!==e?e:Q().validateOnBlur)&&ye(l.path)}function i(e){var t;const n=W(e),r=null!==(t=a().validateOnInput)&&void 0!==t?t:Q().validateOnInput;ue(l.path,n,r)}function o(e){var t;const n=W(e),r=null!==(t=a().validateOnChange)&&void 0!==t?t:Q().validateOnChange;ue(l.path,n,r)}return t.computed((()=>{const e={value:l.value,onChange:o,onInput:i,onBlur:u};return n(r)?Object.assign(Object.assign({},e),r(z(l,fe)).attrs||{}):(null==r?void 0:r.mapAttrs)?Object.assign(Object.assign({},e),r.mapAttrs(z(l,fe))):e}))}})}const he=t.defineComponent({name:"Form",inheritAttrs:!1,props:{as:{type:String,default:"form"},validationSchema:{type:Object,default:void 0},initialValues:{type:Object,default:void 0},initialErrors:{type:Object,default:void 0},initialTouched:{type:Object,default:void 0},validateOnMount:{type:Boolean,default:!1},onSubmit:{type:Function,default:void 0},onInvalidSubmit:{type:Function,default:void 0},keepValues:{type:Boolean,default:!1}},setup(e,n){const r=t.toRef(e,"initialValues"),l=t.toRef(e,"validationSchema"),a=t.toRef(e,"keepValues"),{errors:u,errorBag:i,values:o,meta:s,isSubmitting:d,isValidating:c,submitCount:v,controlledValues:f,validate:p,validateField:m,handleReset:h,resetForm:y,handleSubmit:g,setErrors:b,setFieldError:V,setFieldValue:A,setValues:F,setFieldTouched:S,setTouched:E,resetField:k}=me({validationSchema:l.value?l:void 0,initialValues:r,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:a}),I=g(((e,{evt:t})=>{O(t)&&t.target.submit()}),e.onInvalidSubmit),M=e.onSubmit?g(e.onSubmit,e.onInvalidSubmit):I;function C(e){j(e)&&e.preventDefault(),h(),"function"==typeof n.attrs.onReset&&n.attrs.onReset()}function B(t,n){return g("function"!=typeof t||n?n:t,e.onInvalidSubmit)(t)}function T(){return w(o)}function P(){return w(s.value)}function U(){return w(u.value)}function _(){return{meta:s.value,errors:u.value,errorBag:i.value,values:o,isSubmitting:d.value,isValidating:c.value,submitCount:v.value,controlledValues:f.value,validate:p,validateField:m,handleSubmit:B,handleReset:h,submitForm:I,setErrors:b,setFieldError:V,setFieldValue:A,setValues:F,setFieldTouched:S,setTouched:E,resetForm:y,resetField:k,getValues:T,getMeta:P,getErrors:U}}return n.expose({setFieldError:V,setErrors:b,setFieldValue:A,setValues:F,setFieldTouched:S,setTouched:E,resetForm:y,validate:p,validateField:m,resetField:k,getValues:T,getMeta:P,getErrors:U}),function(){const r="form"===e.as?e.as:t.resolveDynamicComponent(e.as),l=q(r,n,_);if(!e.as)return l;const a="form"===e.as?{novalidate:!0}:{};return t.h(r,Object.assign(Object.assign(Object.assign({},a),n.attrs),{onSubmit:M,onReset:C}),l)}}}),ye=he;function ge(e){const n=P(d,void 0),l=t.ref([]),a=()=>{},u={fields:l,remove:a,push:a,swap:a,insert:a,update:a,replace:a,prepend:a,move:a};if(!n)return u;if(!t.unref(e))return u;const i=n.fieldArrays.find((n=>t.unref(n.path)===t.unref(e)));if(i)return i;let o=0;function s(){return I(null==n?void 0:n.values,t.unref(e),[])||[]}function c(){const e=s();Array.isArray(e)&&(l.value=e.map(((e,t)=>f(e,t,l.value))),v())}function v(){const e=l.value.length;for(let t=0;t<e;t++){const n=l.value[t];n.isFirst=0===t,n.isLast=t===e-1}}function f(a,u,i){if(i&&!r(u)&&i[u])return i[u];const s=o++,d={key:s,value:N({get(){const r=I(null==n?void 0:n.values,t.unref(e),[])||[],u=l.value.findIndex((e=>e.key===s));return-1===u?a:r[u]},set(e){const t=l.value.findIndex((e=>e.key===s));-1!==t&&m(t,e)}}),isFirst:!1,isLast:!1};return d}function p(){v(),null==n||n.validate({mode:"silent"})}function m(r,l){const a=t.unref(e),u=I(null==n?void 0:n.values,a);!Array.isArray(u)||u.length-1<r||(M(n.values,`${a}[${r}]`,l),null==n||n.validate({mode:"validated-only"}))}c();const h={fields:l,remove:function(r){const a=t.unref(e),u=I(null==n?void 0:n.values,a);if(!u||!Array.isArray(u))return;const i=[...u];i.splice(r,1);const o=a+`[${r}]`;n.markForUnmount(o),n.unsetInitialValue(o),M(n.values,a,i),l.value.splice(r,1),p()},push:function(a){const u=w(a),i=t.unref(e),o=I(null==n?void 0:n.values,i),s=r(o)?[]:o;if(!Array.isArray(s))return;const d=[...s];d.push(u),n.stageInitialValue(i+`[${d.length-1}]`,u),M(n.values,i,d),l.value.push(f(u)),p()},swap:function(r,a){const u=t.unref(e),i=I(null==n?void 0:n.values,u);if(!Array.isArray(i)||!(r in i)||!(a in i))return;const o=[...i],s=[...l.value],d=o[r];o[r]=o[a],o[a]=d;const c=s[r];s[r]=s[a],s[a]=c,M(n.values,u,o),l.value=s,v()},insert:function(r,a){const u=w(a),i=t.unref(e),o=I(null==n?void 0:n.values,i);if(!Array.isArray(o)||o.length<r)return;const s=[...o],d=[...l.value];s.splice(r,0,u),d.splice(r,0,f(u)),M(n.values,i,s),l.value=d,p()},update:m,replace:function(r){const l=t.unref(e);n.stageInitialValue(l,r),M(n.values,l,r),c(),p()},prepend:function(a){const u=w(a),i=t.unref(e),o=I(null==n?void 0:n.values,i),s=r(o)?[]:o;if(!Array.isArray(s))return;const d=[u,...s];n.stageInitialValue(i+`[${d.length-1}]`,u),M(n.values,i,d),l.value.unshift(f(u)),p()},move:function(a,u){const i=t.unref(e),o=I(null==n?void 0:n.values,i),s=r(o)?[]:[...o];if(!Array.isArray(o)||!(a in o)||!(u in o))return;const d=[...l.value],c=d[a];d.splice(a,1),d.splice(u,0,c);const v=s[a];s.splice(a,1),s.splice(u,0,v),M(n.values,i,s),l.value=d,p()}};return n.fieldArrays.push(Object.assign({path:e,reset:c},h)),t.onBeforeUnmount((()=>{const r=n.fieldArrays.findIndex((n=>t.unref(n.path)===t.unref(e)));r>=0&&n.fieldArrays.splice(r,1)})),t.watch(s,(e=>{F(e,l.value.map((e=>e.value)))||c()})),h}const be=t.defineComponent({name:"FieldArray",inheritAttrs:!1,props:{name:{type:String,required:!0}},setup(e,n){const{push:r,remove:l,swap:a,insert:u,replace:i,update:o,prepend:s,move:d,fields:c}=ge(t.toRef(e,"name"));function v(){return{fields:c.value,push:r,remove:l,swap:a,insert:u,update:o,replace:i,prepend:s,move:d}}return n.expose({push:r,remove:l,swap:a,insert:u,update:o,replace:i,prepend:s,move:d}),()=>q(void 0,n,v)}}),Ve=t.defineComponent({name:"ErrorMessage",props:{as:{type:String,default:void 0},name:{type:String,required:!0}},setup(e,n){const r=t.inject(d,void 0),l=t.computed((()=>null==r?void 0:r.errors.value[e.name]));function a(){return{message:l.value}}return()=>{if(!l.value)return;const r=e.as?t.resolveDynamicComponent(e.as):e.as,u=q(r,n,a),i=Object.assign({role:"alert"},n.attrs);return r||!Array.isArray(u)&&u||!(null==u?void 0:u.length)?!Array.isArray(u)&&u||(null==u?void 0:u.length)?t.h(r,i,u):t.h(r||"span",i,l.value):u}}});e.ErrorMessage=Ve,e.Field=ce,e.FieldArray=be,e.FieldContextKey=c,e.Form=ye,e.FormContextKey=d,e.IS_ABSENT=v,e.configure=Y,e.defineRule=function(e,t){!function(e,t){if(n(t))return;throw new Error(`Extension Error: The validator '${e}' must be a function.`)}(e,t),s[e]=t},e.normalizeRules=G,e.useField=ue,e.useFieldArray=ge,e.useFieldError=function(e){const n=P(d),r=e?void 0:t.inject(c);return t.computed((()=>e?null==n?void 0:n.errors.value[t.toValue(e)]:null==r?void 0:r.errorMessage.value))},e.useFieldValue=function(e){const n=P(d),r=e?void 0:t.inject(c);return t.computed((()=>e?I(null==n?void 0:n.values,t.toValue(e)):t.toValue(null==r?void 0:r.value)))},e.useForm=me,e.useFormErrors=function(){const e=P(d);return t.computed((()=>(null==e?void 0:e.errors.value)||{}))},e.useFormValues=function(){const e=P(d);return t.computed((()=>(null==e?void 0:e.values)||{}))},e.useIsFieldDirty=function(e){const n=D(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.dirty:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.dirty)&&void 0!==t&&t)}))},e.useIsFieldTouched=function(e){const n=D(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.touched:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.touched)&&void 0!==t&&t)}))},e.useIsFieldValid=function(e){const n=D(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.valid:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.valid)&&void 0!==t&&t)}))},e.useIsFormDirty=function(){const e=P(d);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.dirty)&&void 0!==t&&t}))},e.useIsFormTouched=function(){const e=P(d);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.touched)&&void 0!==t&&t}))},e.useIsFormValid=function(){const e=P(d);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.valid)&&void 0!==t&&t}))},e.useIsSubmitting=function(){const e=P(d);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isSubmitting.value)&&void 0!==t&&t}))},e.useIsValidating=function(){const e=P(d);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isValidating.value)&&void 0!==t&&t}))},e.useResetForm=function(){const e=P(d);return function(t){if(e)return e.resetForm(t)}},e.useSetFieldError=function(e){const n=P(d),r=e?void 0:t.inject(c);return function(l){e&&n?n.setFieldError(t.toValue(e),l):r&&r.setErrors(l||[])}},e.useSetFieldTouched=function(e){const n=P(d),r=e?void 0:t.inject(c);return function(l){e&&n?n.setFieldTouched(t.toValue(e),l):r&&r.setTouched(l)}},e.useSetFieldValue=function(e){const n=P(d),r=e?void 0:t.inject(c);return function(l,a=!0){e&&n?n.setFieldValue(t.toValue(e),l,a):r&&r.setValue(l,a)}},e.useSetFormErrors=function(){const e=P(d);return function(t){e&&e.setErrors(t)}},e.useSetFormTouched=function(){const e=P(d);return function(t){e&&e.setTouched(t)}},e.useSetFormValues=function(){const e=P(d);return function(t){e&&e.setValues(t)}},e.useSubmitCount=function(){const e=P(d);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.submitCount.value)&&void 0!==t?t:0}))},e.useSubmitForm=function(e){const t=P(d),n=t?t.handleSubmit(e):void 0;return function(e){if(n)return n(e)}},e.useValidateField=function(e){const n=P(d),r=e?void 0:t.inject(c);return function(){return r?r.validate():n&&e?null==n?void 0:n.validateField(t.toValue(e)):Promise.resolve({errors:[],valid:!0})}},e.useValidateForm=function(){const e=P(d);return function(){return e?e.validate():Promise.resolve({results:{},errors:{},valid:!0})}},e.validate=Z,e.validateObject=re}));
|
|
6
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VeeValidate={},e.Vue)}(this,(function(e,t){"use strict";function n(e){return"function"==typeof e}function r(e){return null==e}const l=e=>null!==e&&!!e&&"object"==typeof e&&!Array.isArray(e);function a(e){return Number(e)>=0}function u(e){if(!function(e){return"object"==typeof e&&null!==e}(e)||"[object Object]"!==function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}(e))return!1;if(null===Object.getPrototypeOf(e))return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function i(e,t){return Object.keys(t).forEach((n=>{if(u(t[n]))return e[n]||(e[n]={}),void i(e[n],t[n]);e[n]=t[n]})),e}function o(e){const t=e.split(".");if(!t.length)return"";let n=String(t[0]);for(let e=1;e<t.length;e++)a(t[e])?n+=`[${t[e]}]`:n+=`.${t[e]}`;return n}const s={};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 B(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 T(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 R(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 U(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 P(e,t){return l(t)&&t.number?function(e){const t=parseFloat(e);return isNaN(t)?e:t}(e):e}function x(e,t){let n;return async function(...r){const l=e(...r);n=l;const a=await l;return l!==n||(n=void 0,t(a,r)),a}}function N({get:e,set:n}){const r=t.ref(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 $(e){return Array.isArray(e)?e:e?[e]:[]}function D(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 z(e,t){const n={};for(const r in e)t.includes(r)||(n[r]=e[r]);return n}const q=(e,t,n)=>t.slots.default?"string"!=typeof e&&e?{default:()=>{var e,r;return null===(r=(e=t.slots).default)||void 0===r?void 0:r.call(e,n())}}:t.slots.default(n()):t.slots.default;function L(e){if(K(e))return e._value}function K(e){return"_value"in e}function W(e){if(!F(e))return e;const t=e.target;if(b(t.type)&&K(t))return L(t);if("file"===t.type&&t.files){const e=Array.from(t.files);return t.multiple?e:e[0]}if(O(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map(L);var n;if(O(t)){const e=Array.from(t.options).find((e=>e.selected));return e?L(e):t.value}return function(e){return"number"===e.type||"range"===e.type?Number.isNaN(e.valueAsNumber)?e.value:e.valueAsNumber:e.value}(t)}function G(e){const t={};return Object.defineProperty(t,"_$$isNormalized",{value:!0,writable:!1,enumerable:!1,configurable:!1}),e?l(e)&&e._$$isNormalized?e:l(e)?Object.keys(e).reduce(((t,n)=>{const r=function(e){if(!0===e)return[];if(Array.isArray(e))return e;if(l(e))return e;return[e]}(e[n]);return!1!==e[n]&&(t[n]=X(r)),t}),t):"string"!=typeof e?t:e.split("|").reduce(((e,t)=>{const n=H(t);return n.name?(e[n.name]=X(n.params),e):e}),t):t}function X(e){const t=e=>"string"==typeof e&&"@"===e[0]?function(e){const t=t=>I(t,e)||t[e];return t.__locatorRef=e,t}(e.slice(1)):e;return Array.isArray(e)?e.map(t):e instanceof RegExp?[e]:Object.keys(e).reduce(((n,r)=>(n[r]=t(e[r]),n)),{})}const H=e=>{let t=[];const n=e.split(":")[0];return e.includes(":")&&(t=e.split(":").slice(1).join(":").split(",")),{name:n,params:t}};let J=Object.assign({},{generateMessage:({field:e})=>`${e} is not valid.`,bails:!0,validateOnBlur:!0,validateOnChange:!0,validateOnInput:!1,validateOnModelUpdate:!0});const Q=()=>J,Y=e=>{J=Object.assign(Object.assign({},J),e)};async function Z(e,t,r={}){const l=null==r?void 0:r.bails,a={name:(null==r?void 0:r.name)||"{field}",rules:t,label:null==r?void 0:r.label,bails:null==l||l,formData:(null==r?void 0:r.values)||{}},u=await async function(e,t){if(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=T(e).map((async r=>{var l,a,u;const i=null===(l=null==n?void 0:n.names)||void 0===l?void 0:l[r],o=await Z(I(t,r),e[r],{name:(null==i?void 0:i.name)||r,label:null==i?void 0:i.label,values:t,bails:null===(u=null===(a=null==n?void 0:n.bailsMap)||void 0===a?void 0:a[r])||void 0===u||u});return Object.assign(Object.assign({},o),{path:r})}));let l=!0;const a=await Promise.all(r),u={},i={};for(const e of a)u[e.path]={valid:e.valid,errors:e.errors},e.valid||(l=!1,i[e.path]=e.errors[0]);return{valid:l,results:u,errors:i}}let le=0;function ae(e,n){const{value:r,initialValue:l,setInitialValue:a}=function(e,n,r){const l=t.ref(t.unref(n));function a(){return r?I(r.initialValues.value,t.unref(e),t.unref(l)):t.unref(l)}function u(n){r?r.stageInitialValue(t.unref(e),n,!0):l.value=n}const i=t.computed(a);if(!r){return{value:t.ref(a()),initialValue:i,setInitialValue:u}}const o=function(e,n,r,l){if(t.isRef(e))return t.unref(e);if(void 0!==e)return e;return I(n.values,t.unref(l),t.unref(r))}(n,r,i,e);r.stageInitialValue(t.unref(e),o,!0);const s=t.computed({get:()=>I(r.values,t.unref(e)),set(n){r.setFieldValue(t.unref(e),n,!1)}});return{value:s,initialValue:i,setInitialValue:u}}(e,n.modelValue,n.form);if(!n.form){const{errors:o,setErrors:s}=function(){const e=t.ref([]);return{errors:e,setErrors:t=>{e.value=$(t)}}}(),d=le>=Number.MAX_SAFE_INTEGER?0:++le,c=function(e,n,r){const l=t.reactive({touched:!1,pending:!1,valid:!0,validated:!!t.unref(r).length,initialValue:t.computed((()=>t.unref(n))),dirty:t.computed((()=>!E(t.unref(e),t.unref(n))))});return t.watch(r,(e=>{l.valid=!e.length}),{immediate:!0,flush:"sync"}),l}(r,l,o);function v(e){var t;"value"in e&&(r.value=e.value),"errors"in e&&s(e.errors),"touched"in e&&(c.touched=null!==(t=e.touched)&&void 0!==t?t:c.touched),"initialValue"in e&&a(e.initialValue)}return{id:d,path:e,value:r,initialValue:l,meta:c,flags:{pendingUnmount:{[d]:!1},pendingReset:!1},errors:o,setState:v}}const u=n.form.createPathState(e,{bails:n.bails,label:n.label,type:n.type,validate:n.validate}),i=t.computed((()=>u.errors));return{id:Array.isArray(u.id)?u.id[u.id.length-1]:u.id,path:e,value:r,errors:i,meta:u,initialValue:l,flags:u.__flags,setState:function(l){var u,i,o;"value"in l&&(r.value=l.value),"errors"in l&&(null===(u=n.form)||void 0===u||u.setFieldError(t.unref(e),l.errors)),"touched"in l&&(null===(i=n.form)||void 0===i||i.setFieldTouched(t.unref(e),null!==(o=l.touched)&&void 0!==o&&o)),"initialValue"in l&&a(l.initialValue)}}}function ue(e,n,r){return 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=W(s);let h=null!==(v=t.toValue(a))&&void 0!==v?v:m;l&&(null==p?void 0:p.multiple)&&"checkbox"===p.type?h=R(I(l.values,f)||[],h,void 0):"checkbox"===(null==r?void 0:r.type)&&(h=R(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)})),{id:C,value:B,initialValue:R,meta:U,setState:N,errors:$,flags:D}=ae(w,{modelValue:a,form:k,bails:i,label:m,type:s,validate:M.value?X: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:B,prop:A,handleChange:H,shouldValidate:()=>b&&!D.pendingReset});async function q(e){var n,r;return(null==k?void 0:k.validateSchema)?null!==(n=(await k.validateSchema(e)).results[t.toValue(w)])&&void 0!==n?n:{valid:!0,errors:[]}:M.value?Z(B.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=x((async()=>(U.pending=!0,U.validated=!0,q("validated-only"))),(e=>{if(!D.pendingUnmount[te.id])return N({errors:e.errors}),U.pending=!1,U.valid=e.valid,e})),K=x((async()=>q("silent")),(e=>(U.valid=e.valid,e)));function X(e){return"silent"===(null==e?void 0:e.mode)?K():L()}function H(e,t=!0){Y(W(e),t)}function J(e){var t;const n=e&&"value"in e?e.value:R.value;N({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)||[]}),U.pending=!1,U.validated=!1,K()}t.onMounted((()=>{if(u)return L();k&&k.validateSchema||K()}));const Q=t.getCurrentInstance();function Y(e,t=!0){B.value=Q&&A?P(e,Q.props.modelModifiers):e;(t?L:K)()}const ee=t.computed({get:()=>B.value,set(e){Y(e,b)}}),te={id:C,name:w,label:m,value:ee,meta:U,errors:$,errorMessage:z,type:s,checkedValue:d,uncheckedValue:V,bails:i,keepValueOnUnmount:j,resetField:J,handleReset:()=>J(),validate:X,handleChange:H,handleBlur:(e,t=!1)=>{U.touched=!0,t&&L()},setState:N,setTouched:function(e){U.touched=e},setErrors:function(e){N({errors:Array.isArray(e)?e:[e]})},setValue:Y};if(t.provide(f,te),t.isRef(r)&&"function"!=typeof t.unref(r)&&t.watch(r,((e,t)=>{E(e,t)||(U.validated?L():K())}),{deep:!0}),!k)return te;const ne=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):T(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(ne,((e,t)=>{if(!Object.keys(e).length)return;!E(e,t)&&(U.validated?L():K())})),t.onBeforeUnmount((()=>{var e;const n=null!==(e=t.toValue(te.keepValueOnUnmount))&&void 0!==e?e:t.toValue(k.keepValuesOnUnmount),r=t.toValue(w);if(n||!k||D.pendingUnmount[te.id])return void(null==k||k.removePathState(r,C));D.pendingUnmount[te.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(te.id):(null==l?void 0:l.id)===te.id){if((null==l?void 0:l.multiple)&&Array.isArray(l.value)){const e=l.value.findIndex((e=>E(e,t.toValue(te.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(te.id),1)}else k.unsetPathValue(t.toValue(w));k.removePathState(r,C)}})),te}function oe(e,t){if(e)return e.props[t]}function se(e,t){let n=e.as||"";return e.as||t.slots.default||(n="input"),n}function de(e,t){return 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),r.emit("update:modelValue",d.value)},F=t.computed((()=>{const{validateOnInput:t,validateOnChange:l,validateOnBlur:a,validateOnModelUpdate:u}=function(e){var t,n,r,l;const{validateOnInput:a,validateOnChange:u,validateOnBlur:i,validateOnModelUpdate:o}=Q();return{validateOnInput:null!==(t=e.validateOnInput)&&void 0!==t?t:a,validateOnChange:null!==(n=e.validateOnChange)&&void 0!==n?n:u,validateOnBlur:null!==(r=e.validateOnBlur)&&void 0!==r?r:i,validateOnModelUpdate:null!==(l=e.validateOnModelUpdate)&&void 0!==l?l:o}}(e);const i={name:e.name,onBlur:function(e){p(e,a),n(r.attrs.onBlur)&&r.attrs.onBlur(e)},onInput:function(e){A(e,t),n(r.attrs.onInput)&&r.attrs.onInput(e)},onChange:function(e){A(e,l),n(r.attrs.onChange)&&r.attrs.onChange(e)},"onUpdate:modelValue":e=>A(e,u)};return i})),S=t.computed((()=>{const t=Object.assign({},F.value);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({setErrors:O,setTouched:m,reset:h,validate:v,handleChange:f}),()=>{const n=t.resolveDynamicComponent(se(e,r)),l=q(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=t.unref(null==e?void 0:e.initialValues)||{},l=t.unref(null==e?void 0:e.validationSchema);return l&&y(l)&&n(l.cast)?c(l.cast(r)||{}):c(r)}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=$(t),n.valid=!n.errors.length}else"string"==typeof e&&(h.value[o(e)]=$(t))}function j(e){T(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((()=>T(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:R,originalInitialValues:P,setInitialValues:N}=function(e,n,r){const l=pe(r),a=null==r?void 0:r.initialValues,u=t.ref(l),o=t.ref(c(l));function s(t,r=!1){u.value=i(c(u.value)||{},c(t)),o.value=i(c(o.value)||{},c(t)),r&&e.value.forEach((e=>{if(e.touched)return;const t=I(u.value,e.path);M(n,e.path,c(t))}))}t.isRef(a)&&t.watch(a,(e=>{e&&s(e,!0)}),{deep:!0});return{initialValues:u,originalInitialValues:o,setInitialValues:s}}(m,p,e),D=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 T(a).reduce(((e,n)=>{const r=a[n];return e[n]=t[r]((e=>e[n])),e}),{})}const o=t.reactive(i());return t.watchEffect((()=>{const e=i();o.touched=e.touched,o.valid=e.valid,o.pending=e.pending})),t.computed((()=>Object.assign(Object.assign({initialValues:t.unref(r)},o),{valid:o.valid&&!T(l.value).length,dirty:u.value})))}(m,p,P,S),q=t.computed((()=>m.value.reduce(((e,t)=>{const n=I(p,t.path);return M(e,t.path,n),e}),{}))),L=null==e?void 0:e.validationSchema;function K(e,n){var r,l;const u=t.computed((()=>I(R.value,t.toValue(e)))),i=b.value[t.toValue(e)];if(i){"checkbox"!==(null==n?void 0:n.type)&&"radio"!==(null==n?void 0:n.type)||(i.multiple=!0);const e=a++;return Array.isArray(i.id)?i.id.push(e):i.id=[i.id,e],i.fieldsCount++,i.__flags.pendingUnmount[e]=!1,i}const o=t.computed((()=>I(p,t.toValue(e)))),s=t.toValue(e),d=a++,v=t.reactive({id:d,path:e,touched:!1,pending:!1,valid:!0,validated:!!(null===(r=C[s])||void 0===r?void 0:r.length),initialValue:u,errors:t.shallowRef([]),bails:null!==(l=null==n?void 0:n.bails)&&void 0!==l&&l,label:null==n?void 0:n.label,type:(null==n?void 0:n.type)||"default",value:o,multiple:!1,__flags:{pendingUnmount:{[d]:!1},pendingReset:!1},fieldsCount:1,validate:null==n?void 0:n.validate,dirty:t.computed((()=>!E(t.unref(o),t.unref(u))))});return m.value.push(v),b.value[s]=v,V(),S.value[s]&&!C[s]&&t.nextTick((()=>{ye(s,{mode:"silent"})})),t.isRef(e)&&t.watch(e,(e=>{V();const n=c(o.value);b.value[e]=v,t.nextTick((()=>{M(p,e,n)}))})),v}const G=U(Ve,5),X=U(Ve,5),H=x((async e=>"silent"===await e?G():X()),((e,[t])=>{const n=T(ae.errorBag.value);return[...new Set([...T(e.results),...m.value.map((e=>e.path)),...n])].sort().reduce(((n,r)=>{const l=r,a=Y(l)||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)}(l),u=(e.results[l]||{errors:[]}).errors,i={errors:u,valid:!u.length};return n.results[l]=i,i.valid||(n.errors[l]=i.errors[0]),a&&h.value[l]&&delete h.value[l],a?(a.valid=i.valid,"silent"===t?n:"validated-only"!==t||a.validated?(O(a,i.errors),n):n):(O(l,u),n)}),{valid:e.valid,results:{},errors:{}})}));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(q.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:q,errorBag:F,errors:S,schema:L,submitCount:d,meta:D,isSubmitting:u,isValidating:s,fieldArrays:f,keepValuesOnUnmount:_,validateSchema:t.unref(L)?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,stageInitialValue:function(t,n,r=!1){be(t,n),M(p,t,n),r&&!(null==e?void 0:e.initialValues)&&M(P.value,t,c(n))},unsetInitialValue:ge,setFieldInitialValue:be,useFieldModel:function(e){if(!Array.isArray(e))return oe(e);return e.map(oe)},createPathState:K,getPathState:Y,unsetPathValue:function(e){return te.push(e),Z||(Z=t.nextTick((()=>{[...te].sort().reverse().forEach((e=>{B(p,e)})),te=[],Z=null}))),Z},removePathState:function(e,n){const r=m.value.findIndex((t=>t.path===e)),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:R,getAllPathStates:()=>m.value,markForUnmount:function(e){return J((t=>{t.path.startsWith(e)&&T(t.__flags.pendingUnmount).forEach((e=>{t.__flags.pendingUnmount[e]=!0}))}))},isFieldTouched:function(e){var t;return!!(null===(t=Y(e))||void 0===t?void 0:t.touched)},isFieldDirty:function(e){var t;return!!(null===(t=Y(e))||void 0===t?void 0:t.dirty)},isFieldValid:function(e){var t;return!!(null===(t=Y(e))||void 0===t?void 0:t.valid)}};function ue(e,t,n=!0){const r=c(t),l="string"==typeof e?e:e.path;Y(l)||K(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){const n=Y(t.unref(e))||K(e);return t.computed({get:()=>n.value,set(r){const l=t.unref(e);ue(l,r,!1),n.validated=!0,n.pending=!0,ye(l).then((()=>{n.pending=!1}))}})}function se(e,t){const n=Y(e);n&&(n.touched=t)}function de(e){"boolean"!=typeof e?T(e).forEach((t=>{se(t,!!e[t])})):J((t=>{t.touched=e}))}function ce(e,n){var r;const l=n&&"value"in n?n.value:I(R.value,e),a=Y(e);a&&(a.__flags.pendingReset=!0),be(e,c(l)),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=(null==e?void 0:e.values)?e.values:P.value;l=y(L)&&n(L.cast)?L.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){T(p).forEach((e=>{delete p[e]})),T(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),L){const{results:n}=await H((null==t?void 0:t.mode)||"validated-only");return n[e]||{errors:[],valid:!0}}return(null==n?void 0:n.validate)?n.validate(t):(!n&&(null==t?void 0:t.warn),Promise.resolve({errors:[],valid:!0}))}function ge(e){B(R.value,e)}function be(e,t){M(R.value,e,c(t))}async function Ve(){const e=t.unref(L);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()}));return t.onMounted((()=>{(null==e?void 0:e.initialErrors)&&j(e.initialErrors),(null==e?void 0:e.initialTouched)&&de(e.initialTouched),(null==e?void 0:e.validateOnMount)?he():ae.validateSchema&&ae.validateSchema("silent")})),t.isRef(L)&&t.watch(L,(()=>{var e;null===(e=ae.validateSchema)||void 0===e||e.call(ae,"validated-only")})),t.provide(v,ae),Object.assign(Object.assign({},ae),{values:t.readonly(p),handleReset:()=>me(),submitForm:Oe,defineComponentBinds:function(e,r){const l=Y(t.toValue(e))||K(e),a=()=>n(r)?r(z(l,fe)):r||{};function u(){var e;l.touched=!0;(null!==(e=a().validateOnBlur)&&void 0!==e?e:Q().validateOnBlur)&&ye(l.path)}function i(e){var t;const n=null!==(t=a().validateOnModelUpdate)&&void 0!==t?t:Q().validateOnModelUpdate;ue(l.path,e,n)}return t.computed((()=>{if(n(r)){const e=r(l),t=e.model||"modelValue";return Object.assign({onBlur:u,[t]:l.value,[`onUpdate:${t}`]:i},e.props||{})}const e=(null==r?void 0:r.model)||"modelValue",t={onBlur:u,[e]:l.value,[`onUpdate:${e}`]:i};return(null==r?void 0:r.mapProps)?Object.assign(Object.assign({},t),r.mapProps(z(l,fe))):t}))},defineInputBinds:function(e,r){const l=Y(t.toValue(e))||K(e),a=()=>n(r)?r(z(l,fe)):r||{};function u(){var e;l.touched=!0;(null!==(e=a().validateOnBlur)&&void 0!==e?e:Q().validateOnBlur)&&ye(l.path)}function i(e){var t;const n=W(e),r=null!==(t=a().validateOnInput)&&void 0!==t?t:Q().validateOnInput;ue(l.path,n,r)}function o(e){var t;const n=W(e),r=null!==(t=a().validateOnChange)&&void 0!==t?t:Q().validateOnChange;ue(l.path,n,r)}return t.computed((()=>{const e={value:l.value,onChange:o,onInput:i,onBlur:u};return n(r)?Object.assign(Object.assign({},e),r(z(l,fe)).attrs||{}):(null==r?void 0:r.mapAttrs)?Object.assign(Object.assign({},e),r.mapAttrs(z(l,fe))):e}))}})}const he=t.defineComponent({name:"Form",inheritAttrs:!1,props:{as:{type:String,default:"form"},validationSchema:{type:Object,default:void 0},initialValues:{type:Object,default:void 0},initialErrors:{type:Object,default:void 0},initialTouched:{type:Object,default:void 0},validateOnMount:{type:Boolean,default:!1},onSubmit:{type:Function,default:void 0},onInvalidSubmit:{type:Function,default:void 0},keepValues:{type:Boolean,default:!1}},setup(e,n){const r=t.toRef(e,"initialValues"),l=t.toRef(e,"validationSchema"),a=t.toRef(e,"keepValues"),{errors:u,errorBag:i,values:o,meta:s,isSubmitting:d,isValidating:v,submitCount:f,controlledValues:p,validate:m,validateField:h,handleReset:y,resetForm:g,handleSubmit:b,setErrors:V,setFieldError:O,setFieldValue:j,setValues:S,setFieldTouched:E,setTouched:k,resetField:w}=me({validationSchema:l.value?l:void 0,initialValues:r,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:a}),I=b(((e,{evt:t})=>{A(t)&&t.target.submit()}),e.onInvalidSubmit),M=e.onSubmit?b(e.onSubmit,e.onInvalidSubmit):I;function C(e){F(e)&&e.preventDefault(),y(),"function"==typeof n.attrs.onReset&&n.attrs.onReset()}function B(t,n){return b("function"!=typeof t||n?n:t,e.onInvalidSubmit)(t)}function T(){return c(o)}function _(){return c(s.value)}function R(){return c(u.value)}function U(){return{meta:s.value,errors:u.value,errorBag:i.value,values:o,isSubmitting:d.value,isValidating:v.value,submitCount:f.value,controlledValues:p.value,validate:m,validateField:h,handleSubmit:B,handleReset:y,submitForm:I,setErrors:V,setFieldError:O,setFieldValue:j,setValues:S,setFieldTouched:E,setTouched:k,resetForm:g,resetField:w,getValues:T,getMeta:_,getErrors:R}}return n.expose({setFieldError:O,setErrors:V,setFieldValue:j,setValues:S,setFieldTouched:E,setTouched:k,resetForm:g,validate:m,validateField:h,resetField:w,getValues:T,getMeta:_,getErrors:R}),function(){const r="form"===e.as?e.as:t.resolveDynamicComponent(e.as),l=q(r,n,U);if(!e.as)return l;const a="form"===e.as?{novalidate:!0}:{};return t.h(r,Object.assign(Object.assign(Object.assign({},a),n.attrs),{onSubmit:M,onReset:C}),l)}}}),ye=he;function ge(e){const n=_(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.unref(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.unref(e),[])||[],u=l.value.findIndex((e=>e.key===s));return-1===u?a:r[u]},set(e){const t=l.value.findIndex((e=>e.key===s));-1!==t&&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.unref(e),u=I(null==n?void 0:n.values,a);!Array.isArray(u)||u.length-1<r||(M(n.values,`${a}[${r}]`,l),null==n||n.validate({mode:"validated-only"}))}d();const y={fields:l,remove:function(r){const a=t.unref(e),u=I(null==n?void 0:n.values,a);if(!u||!Array.isArray(u))return;const i=[...u];i.splice(r,1);const o=a+`[${r}]`;n.markForUnmount(o),n.unsetInitialValue(o),M(n.values,a,i),l.value.splice(r,1),m()},push:function(a){const u=c(a),i=t.unref(e),o=I(null==n?void 0:n.values,i),s=r(o)?[]:o;if(!Array.isArray(s))return;const d=[...s];d.push(u),n.stageInitialValue(i+`[${d.length-1}]`,u),M(n.values,i,d),l.value.push(p(u)),m()},swap:function(r,a){const u=t.unref(e),i=I(null==n?void 0:n.values,u);if(!Array.isArray(i)||!(r in i)||!(a in i))return;const o=[...i],s=[...l.value],d=o[r];o[r]=o[a],o[a]=d;const c=s[r];s[r]=s[a],s[a]=c,M(n.values,u,o),l.value=s,f()},insert:function(r,a){const u=c(a),i=t.unref(e),o=I(null==n?void 0:n.values,i);if(!Array.isArray(o)||o.length<r)return;const s=[...o],d=[...l.value];s.splice(r,0,u),d.splice(r,0,p(u)),M(n.values,i,s),l.value=d,m()},update:h,replace:function(r){const l=t.unref(e);n.stageInitialValue(l,r),M(n.values,l,r),d(),m()},prepend:function(a){const u=c(a),i=t.unref(e),o=I(null==n?void 0:n.values,i),s=r(o)?[]:o;if(!Array.isArray(s))return;const d=[u,...s];n.stageInitialValue(i+`[${d.length-1}]`,u),M(n.values,i,d),l.value.unshift(p(u)),m()},move:function(a,u){const i=t.unref(e),o=I(null==n?void 0:n.values,i),s=r(o)?[]:[...o];if(!Array.isArray(o)||!(a in o)||!(u in o))return;const d=[...l.value],c=d[a];d.splice(a,1),d.splice(u,0,c);const v=s[a];s.splice(a,1),s.splice(u,0,v),M(n.values,i,s),l.value=d,m()}};return n.fieldArrays.push(Object.assign({path:e,reset:d},y)),t.onBeforeUnmount((()=>{const r=n.fieldArrays.findIndex((n=>t.unref(n.path)===t.unref(e)));r>=0&&n.fieldArrays.splice(r,1)})),t.watch(s,(e=>{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,n){const{push:r,remove:l,swap:a,insert:u,replace:i,update:o,prepend:s,move:d,fields:c}=ge(t.toRef(e,"name"));function v(){return{fields:c.value,push:r,remove:l,swap:a,insert:u,update:o,replace:i,prepend:s,move:d}}return n.expose({push:r,remove:l,swap:a,insert:u,update:o,replace:i,prepend:s,move:d}),()=>q(void 0,n,v)}}),Ve=t.defineComponent({name:"ErrorMessage",props:{as:{type:String,default:void 0},name:{type:String,required:!0}},setup(e,n){const r=t.inject(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=q(r,n,a),i=Object.assign({role:"alert"},n.attrs);return r||!Array.isArray(u)&&u||!(null==u?void 0:u.length)?!Array.isArray(u)&&u||(null==u?void 0:u.length)?t.h(r,i,u):t.h(r||"span",i,l.value):u}}});e.ErrorMessage=Ve,e.Field=ce,e.FieldArray=be,e.FieldContextKey=f,e.Form=ye,e.FormContextKey=v,e.IS_ABSENT=p,e.configure=Y,e.defineRule=function(e,t){!function(e,t){if(n(t))return;throw new Error(`Extension Error: The validator '${e}' must be a function.`)}(e,t),s[e]=t},e.normalizeRules=G,e.useField=ue,e.useFieldArray=ge,e.useFieldError=function(e){const n=_(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=D(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.dirty:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.dirty)&&void 0!==t&&t)}))},e.useIsFieldTouched=function(e){const n=D(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.touched:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.touched)&&void 0!==t&&t)}))},e.useIsFieldValid=function(e){const n=D(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.valid:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.valid)&&void 0!==t&&t)}))},e.useIsFormDirty=function(){const e=_(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}));
|