vee-validate
Advanced tools
Comparing version 4.12.0-alpha.0 to 4.12.0-alpha.1
/** | ||
* vee-validate v4.12.0-alpha.0 | ||
* vee-validate v4.12.0-alpha.1 | ||
* (c) 2023 Abdelrahman Awad | ||
* @license MIT | ||
*/ | ||
!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 T(e,t){if(V(t))return void delete e[w(t)];const n=t.split(/\.|\[(\d+)\]/).filter(Boolean);let a=e;for(let e=0;e<n.length;e++){if(e===n.length-1){C(a,n[e]);break}if(!(n[e]in a)||r(a[n[e]]))break;a=a[n[e]]}const u=n.map(((t,r)=>I(e,n.slice(0,r).join("."))));for(let t=u.length-1;t>=0;t--)i=u[t],(Array.isArray(i)?0===i.length:l(i)&&0===Object.keys(i).length)&&(0!==t?C(u[t-1],n[t-1]):C(e,n[0]));var i}function _(e){return Object.keys(e)}function R(e,n=void 0){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function B(e,t,n){if(Array.isArray(e)){const n=[...e],r=n.findIndex((e=>E(e,t)));return r>=0?n.splice(r,1):n.push(t),n}return E(e,t)?n:t}function x(e,t=0){let n=null,r=[];return function(...l){return n&&clearTimeout(n),n=setTimeout((()=>{const t=e(...l);r.forEach((e=>e(t))),r=[]}),t),new Promise((e=>r.push(e)))}}function P(e,t){return l(t)&&t.number?function(e){const t=parseFloat(e);return isNaN(t)?e:t}(e):e}function U(e,t){let n;return async function(...r){const l=e(...r);n=l;const a=await l;return l!==n||(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 D(e){return Array.isArray(e)?e:e?[e]:[]}function $(e){const n=R(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}function q(e,t,n){return t.slots.default?"string"!=typeof e&&e?{default:()=>{var e,r;return null===(r=(e=t.slots).default)||void 0===r?void 0:r.call(e,n())}}:t.slots.default(n()):t.slots.default}function 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=_(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=D(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:R(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=B(I(l.values,f)||[],h,void 0):"checkbox"===(null==r?void 0:r.type)&&(h=B(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?R(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:T,initialValue:B,meta:x,setState:N,errors:D,flags:$}=ae(w,{modelValue:a,form:k,bails:i,label:m,type:s,validate:M.value?X:void 0}),z=t.computed((()=>D.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:T,prop:A,handleChange:H,shouldValidate:()=>b&&!$.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(T.value,M.value,{name:t.toValue(w),label:t.toValue(m),values:null!==(r=null==k?void 0:k.values)&&void 0!==r?r:{},bails:i}):{valid:!0,errors:[]}}const L=U((async()=>(x.pending=!0,x.validated=!0,q("validated-only"))),(e=>{if(!$.pendingUnmount[te.id])return N({errors:e.errors}),x.pending=!1,x.valid=e.valid,e})),K=U((async()=>q("silent")),(e=>(x.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:B.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)||[]}),x.pending=!1,x.validated=!1,K()}t.onMounted((()=>{if(u)return L();k&&k.validateSchema||K()}));const Q=t.getCurrentInstance();function Y(e,t=!0){T.value=Q&&A?P(e,Q.props.modelModifiers):e;(t?L:K)()}const ee=t.computed({get:()=>T.value,set(e){Y(e,b)}}),te={id:C,name:w,label:m,value:ee,meta:x,errors:D,errorMessage:z,type:s,checkedValue:d,uncheckedValue:V,bails:i,keepValueOnUnmount:j,resetField:J,handleReset:()=>J(),validate:X,handleChange:H,handleBlur:(e,t=!1)=>{x.touched=!0,t&&L()},setState:N,setTouched:function(e){x.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)||(x.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):_(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)&&(x.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||$.pendingUnmount[te.id])return void(null==k||k.removePathState(r,C));$.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)},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=J(e);if(n){if("string"==typeof e){const t=o(e);h.value[t]&&delete h.value[t]}n.errors=D(t),n.valid=!n.errors.length}else"string"==typeof e&&(h.value[o(e)]=D(t))}function j(e){_(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((()=>_(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)||{}),R=null!==(r=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==r&&r,{initialValues:B,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),$=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 _(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&&!_(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(B.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((()=>{he(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 W=x(be,5),G=x(be,5),X=U((async e=>"silent"===await e?W():G()),((e,[t])=>{const n=_(le.errorBag.value);return[...new Set([..._(e.results),...m.value.map((e=>e.path)),...n])].sort().reduce(((n,r)=>{const l=r,a=J(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 H(e){m.value.forEach(e)}function J(e){const t="string"==typeof e?o(e):e;return"string"==typeof t?b.value[t]:t}let Y,Z=[];function te(e){return function(t,n){return function(r){return r instanceof Event&&(r.preventDefault(),r.stopPropagation()),H((e=>e.touched=!0)),u.value=!0,d.value++,me().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:se,setFieldTouched:oe,setValues:ue,setFieldValue:ae,resetForm:ce,resetField:de})}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 ne=te(!1);ne.withControlled=te(!0);const le={formId:l,values:p,controlledValues:q,errorBag:F,errors:S,schema:L,submitCount:d,meta:$,isSubmitting:u,isValidating:s,fieldArrays:f,keepValuesOnUnmount:R,validateSchema:t.unref(L)?X:void 0,validate:me,setFieldError:O,validateField:he,setFieldValue:ae,setValues:ue,setErrors:j,setFieldTouched:oe,setTouched:se,resetForm:ce,resetField:de,handleSubmit:ne,stageInitialValue:function(t,n,r=!1){ge(t,n),M(p,t,n),r&&!(null==e?void 0:e.initialValues)&&M(P.value,t,c(n))},unsetInitialValue:ye,setFieldInitialValue:ge,createPathState:K,getPathState:J,unsetPathValue:function(e){return Z.push(e),Y||(Y=t.nextTick((()=>{[...Z].sort().reverse().forEach((e=>{T(p,e)})),Z=[],Y=null}))),Y},removePathState:function(e,n){const r=m.value.findIndex((t=>t.path===e)),l=m.value[r];if(-1!==r&&l){if(t.nextTick((()=>{he(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),ye(e),V(),delete b.value[e])}},initialValues:B,getAllPathStates:()=>m.value,markForUnmount:function(e){return H((t=>{t.path.startsWith(e)&&_(t.__flags.pendingUnmount).forEach((e=>{t.__flags.pendingUnmount[e]=!0}))}))},isFieldTouched:function(e){var t;return!!(null===(t=J(e))||void 0===t?void 0:t.touched)},isFieldDirty:function(e){var t;return!!(null===(t=J(e))||void 0===t?void 0:t.dirty)},isFieldValid:function(e){var t;return!!(null===(t=J(e))||void 0===t?void 0:t.valid)}};function ae(e,t,n=!0){const r=c(t),l="string"==typeof e?e:e.path;J(l)||K(l),M(p,l,r),n&&he(l)}function ue(e,t=!0){i(p,e),f.forEach((e=>e&&e.reset())),t&&me()}function ie(e,n){const r=J(t.toValue(e))||K(e);return t.computed({get:()=>r.value,set(r){var l;ae(t.toValue(e),r,null!==(l=t.toValue(n))&&void 0!==l&&l)}})}function oe(e,t){const n=J(e);n&&(n.touched=t)}function se(e){"boolean"!=typeof e?_(e).forEach((t=>{oe(t,!!e[t])})):H((t=>{t.touched=e}))}function de(e,n){var r;const l=n&&"value"in n?n.value:I(B.value,e),a=J(e);a&&(a.__flags.pendingReset=!0),ge(e,c(l)),ae(e,l,!1),oe(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 ce(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),H((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,ae(t.path,I(l,t.path),!1),O(t.path,void 0)})),(null==r?void 0:r.force)?function(e,t=!0){_(p).forEach((e=>{delete p[e]})),_(e).forEach((t=>{ae(t,e[t],!1)})),t&&me()}(l,!1):ue(l,!1),j((null==e?void 0:e.errors)||{}),d.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{me({mode:"silent"}),H((e=>{e.__flags.pendingReset=!1}))}))}async function me(e){const t=(null==e?void 0:e.mode)||"force";if("force"===t&&H((e=>e.validated=!0)),le.validateSchema)return le.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 he(e,t){const n=J(e);if(n&&"silent"!==(null==t?void 0:t.mode)&&(n.validated=!0),L){const{results:n}=await X((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 ye(e){T(B.value,e)}function ge(e,t){M(B.value,e,c(t))}async function be(){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 Ve=ne(((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)&&se(e.initialTouched),(null==e?void 0:e.validateOnMount)?me():le.validateSchema&&le.validateSchema("silent")})),t.isRef(L)&&t.watch(L,(()=>{var e;null===(e=le.validateSchema)||void 0===e||e.call(le,"validated-only")})),t.provide(v,le),Object.assign(Object.assign({},le),{values:t.readonly(p),handleReset:()=>ce(),submitForm:Ve,defineField:function(e,r){const l=J(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)&&he(l.path)}function i(){var e;(null!==(e=a().validateOnInput)&&void 0!==e?e:Q().validateOnInput)&&t.nextTick((()=>{he(l.path)}))}function o(){var e;(null!==(e=a().validateOnChange)&&void 0!==e?e:Q().validateOnChange)&&t.nextTick((()=>{he(l.path)}))}const s=t.computed((()=>{const e={onChange:o,onInput:i,onBlur:u};return n(r)?Object.assign(Object.assign({},e),r(z(l,fe)).props||{}):(null==r?void 0:r.props)?Object.assign(Object.assign({},e),r.props(z(l,fe))):e}));return[ie(e,(()=>{var e;return null!==(e=a().validateOnModelUpdate)&&void 0!==e&&e})),s]}})}const he=t.defineComponent({name:"Form",inheritAttrs:!1,props:{as:{type:null,default:"form"},validationSchema:{type:Object,default:void 0},initialValues:{type:Object,default:void 0},initialErrors:{type:Object,default:void 0},initialTouched:{type:Object,default:void 0},validateOnMount:{type:Boolean,default:!1},onSubmit:{type:Function,default:void 0},onInvalidSubmit:{type:Function,default:void 0},keepValues:{type:Boolean,default:!1}},setup(e,n){const r=t.toRef(e,"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 T(t,n){return b("function"!=typeof t||n?n:t,e.onInvalidSubmit)(t)}function _(){return c(o)}function R(){return c(s.value)}function B(){return c(u.value)}function x(){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:T,handleReset:y,submitForm:I,setErrors:V,setFieldError:O,setFieldValue:j,setValues:S,setFieldTouched:E,setTouched:k,resetForm:g,resetField:w,getValues:_,getMeta:R,getErrors:B}}return n.expose({setFieldError:O,setErrors:V,setFieldValue:j,setValues:S,setFieldTouched:E,setTouched:k,resetForm:g,validate:m,validateField:h,resetField:w,getValues:_,getMeta:R,getErrors:B}),function(){const r="form"===e.as?e.as:e.as?t.resolveDynamicComponent(e.as):null,l=q(r,n,x);if(!r)return l;const a="form"===r?{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=R(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=R(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=R(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=R(v);return t.computed((()=>(null==e?void 0:e.errors.value)||{}))},e.useFormValues=function(){const e=R(v);return t.computed((()=>(null==e?void 0:e.values)||{}))},e.useIsFieldDirty=function(e){const n=$(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.dirty:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.dirty)&&void 0!==t&&t)}))},e.useIsFieldTouched=function(e){const n=$(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.touched:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.touched)&&void 0!==t&&t)}))},e.useIsFieldValid=function(e){const n=$(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.valid:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.valid)&&void 0!==t&&t)}))},e.useIsFormDirty=function(){const e=R(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=R(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=R(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=R(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=R(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=R(v);return function(t){if(e)return e.resetForm(t)}},e.useSetFieldError=function(e){const n=R(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=R(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=R(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=R(v);return function(t){e&&e.setErrors(t)}},e.useSetFormTouched=function(){const e=R(v);return function(t){e&&e.setTouched(t)}},e.useSetFormValues=function(){const e=R(v);return function(t,n=!0){e&&e.setValues(t,n)}},e.useSubmitCount=function(){const e=R(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=R(v),n=t?t.handleSubmit(e):void 0;return function(e){if(n)return n(e)}},e.useValidateField=function(e){const n=R(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=R(v);return function(){return e?e.validate():Promise.resolve({results:{},errors:{},valid:!0})}},e.validate=Z,e.validateObject=re})); | ||
!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 T(e,t){if(V(t))return void delete e[w(t)];const n=t.split(/\.|\[(\d+)\]/).filter(Boolean);let a=e;for(let e=0;e<n.length;e++){if(e===n.length-1){C(a,n[e]);break}if(!(n[e]in a)||r(a[n[e]]))break;a=a[n[e]]}const u=n.map(((t,r)=>I(e,n.slice(0,r).join("."))));for(let t=u.length-1;t>=0;t--)i=u[t],(Array.isArray(i)?0===i.length:l(i)&&0===Object.keys(i).length)&&(0!==t?C(u[t-1],n[t-1]):C(e,n[0]));var i}function _(e){return Object.keys(e)}function R(e,n=void 0){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function B(e,t,n){if(Array.isArray(e)){const n=[...e],r=n.findIndex((e=>E(e,t)));return r>=0?n.splice(r,1):n.push(t),n}return E(e,t)?n:t}function x(e,t=0){let n=null,r=[];return function(...l){return n&&clearTimeout(n),n=setTimeout((()=>{const t=e(...l);r.forEach((e=>e(t))),r=[]}),t),new Promise((e=>r.push(e)))}}function P(e,t){return l(t)&&t.number?function(e){const t=parseFloat(e);return isNaN(t)?e:t}(e):e}function U(e,t){let n;return async function(...r){const l=e(...r);n=l;const a=await l;return l!==n||(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 D(e){return Array.isArray(e)?e:e?[e]:[]}function $(e){const n=R(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}function q(e,t,n){return t.slots.default?"string"!=typeof e&&e?{default:()=>{var e,r;return null===(r=(e=t.slots).default)||void 0===r?void 0:r.call(e,n())}}:t.slots.default(n()):t.slots.default}function 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=_(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=D(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:R(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=B(I(l.values,f)||[],h,void 0):"checkbox"===(null==r?void 0:r.type)&&(h=B(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?R(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:T,initialValue:B,meta:x,setState:N,errors:D,flags:$}=ae(w,{modelValue:a,form:k,bails:i,label:m,type:s,validate:M.value?X:void 0}),z=t.computed((()=>D.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:T,prop:A,handleChange:H,shouldValidate:()=>b&&!$.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(T.value,M.value,{name:t.toValue(w),label:t.toValue(m),values:null!==(r=null==k?void 0:k.values)&&void 0!==r?r:{},bails:i}):{valid:!0,errors:[]}}const L=U((async()=>(x.pending=!0,x.validated=!0,q("validated-only"))),(e=>{if(!$.pendingUnmount[te.id])return N({errors:e.errors}),x.pending=!1,x.valid=e.valid,e})),K=U((async()=>q("silent")),(e=>(x.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:B.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)||[]}),x.pending=!1,x.validated=!1,K()}t.onMounted((()=>{if(u)return L();k&&k.validateSchema||K()}));const Q=t.getCurrentInstance();function Y(e,t=!0){T.value=Q&&A?P(e,Q.props.modelModifiers):e;(t?L:K)()}const ee=t.computed({get:()=>T.value,set(e){Y(e,b)}}),te={id:C,name:w,label:m,value:ee,meta:x,errors:D,errorMessage:z,type:s,checkedValue:d,uncheckedValue:V,bails:i,keepValueOnUnmount:j,resetField:J,handleReset:()=>J(),validate:X,handleChange:H,handleBlur:(e,t=!1)=>{x.touched=!0,t&&L()},setState:N,setTouched:function(e){x.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)||(x.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):_(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)&&(x.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||$.pendingUnmount[te.id])return void(null==k||k.removePathState(r,C));$.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)},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=J(e);if(n){if("string"==typeof e){const t=o(e);h.value[t]&&delete h.value[t]}n.errors=D(t),n.valid=!n.errors.length}else"string"==typeof e&&(h.value[o(e)]=D(t))}function j(e){_(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((()=>_(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)||{}),R=null!==(r=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==r&&r,{initialValues:B,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),$=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 _(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&&!_(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(B.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((()=>{he(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 W=x(be,5),G=x(be,5),X=U((async e=>"silent"===await e?W():G()),((e,[t])=>{const n=_(le.errorBag.value);return[...new Set([..._(e.results),...m.value.map((e=>e.path)),...n])].sort().reduce(((n,r)=>{const l=r,a=J(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 H(e){m.value.forEach(e)}function J(e){const t="string"==typeof e?o(e):e;return"string"==typeof t?b.value[t]:t}let Y,Z=[];function te(e){return function(t,n){return function(r){return r instanceof Event&&(r.preventDefault(),r.stopPropagation()),H((e=>e.touched=!0)),u.value=!0,d.value++,me().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:se,setFieldTouched:oe,setValues:ue,setFieldValue:ae,resetForm:ce,resetField:de})}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 ne=te(!1);ne.withControlled=te(!0);const le={formId:l,values:p,controlledValues:q,errorBag:F,errors:S,schema:L,submitCount:d,meta:$,isSubmitting:u,isValidating:s,fieldArrays:f,keepValuesOnUnmount:R,validateSchema:t.unref(L)?X:void 0,validate:me,setFieldError:O,validateField:he,setFieldValue:ae,setValues:ue,setErrors:j,setFieldTouched:oe,setTouched:se,resetForm:ce,resetField:de,handleSubmit:ne,stageInitialValue:function(t,n,r=!1){ge(t,n),M(p,t,n),r&&!(null==e?void 0:e.initialValues)&&M(P.value,t,c(n))},unsetInitialValue:ye,setFieldInitialValue:ge,createPathState:K,getPathState:J,unsetPathValue:function(e){return Z.push(e),Y||(Y=t.nextTick((()=>{[...Z].sort().reverse().forEach((e=>{T(p,e)})),Z=[],Y=null}))),Y},removePathState:function(e,n){const r=m.value.findIndex((t=>t.path===e)),l=m.value[r];if(-1!==r&&l){if(t.nextTick((()=>{he(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),ye(e),V(),delete b.value[e])}},initialValues:B,getAllPathStates:()=>m.value,markForUnmount:function(e){return H((t=>{t.path.startsWith(e)&&_(t.__flags.pendingUnmount).forEach((e=>{t.__flags.pendingUnmount[e]=!0}))}))},isFieldTouched:function(e){var t;return!!(null===(t=J(e))||void 0===t?void 0:t.touched)},isFieldDirty:function(e){var t;return!!(null===(t=J(e))||void 0===t?void 0:t.dirty)},isFieldValid:function(e){var t;return!!(null===(t=J(e))||void 0===t?void 0:t.valid)}};function ae(e,t,n=!0){const r=c(t),l="string"==typeof e?e:e.path;J(l)||K(l),M(p,l,r),n&&he(l)}function ue(e,t=!0){i(p,e),f.forEach((e=>e&&e.reset())),t&&me()}function ie(e,n){const r=J(t.toValue(e))||K(e);return t.computed({get:()=>r.value,set(r){var l;ae(t.toValue(e),r,null!==(l=t.toValue(n))&&void 0!==l&&l)}})}function oe(e,t){const n=J(e);n&&(n.touched=t)}function se(e){"boolean"!=typeof e?_(e).forEach((t=>{oe(t,!!e[t])})):H((t=>{t.touched=e}))}function de(e,n){var r;const l=n&&"value"in n?n.value:I(B.value,e),a=J(e);a&&(a.__flags.pendingReset=!0),ge(e,c(l)),ae(e,l,!1),oe(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 ce(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),H((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,ae(t.path,I(l,t.path),!1),O(t.path,void 0)})),(null==r?void 0:r.force)?function(e,t=!0){_(p).forEach((e=>{delete p[e]})),_(e).forEach((t=>{ae(t,e[t],!1)})),t&&me()}(l,!1):ue(l,!1),j((null==e?void 0:e.errors)||{}),d.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{me({mode:"silent"}),H((e=>{e.__flags.pendingReset=!1}))}))}async function me(e){const t=(null==e?void 0:e.mode)||"force";if("force"===t&&H((e=>e.validated=!0)),le.validateSchema)return le.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 he(e,t){const n=J(e);if(n&&"silent"!==(null==t?void 0:t.mode)&&(n.validated=!0),L){const{results:n}=await X((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 ye(e){T(B.value,e)}function ge(e,t){M(B.value,e,c(t))}async function be(){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 Ve=ne(((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)&&se(e.initialTouched),(null==e?void 0:e.validateOnMount)?me():le.validateSchema&&le.validateSchema("silent")})),t.isRef(L)&&t.watch(L,(()=>{var e;null===(e=le.validateSchema)||void 0===e||e.call(le,"validated-only")})),t.provide(v,le),Object.assign(Object.assign({},le),{values:t.readonly(p),handleReset:()=>ce(),submitForm:Ve,defineField:function(e,r){const l=J(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)&&he(l.path)}function i(){var e;(null!==(e=a().validateOnInput)&&void 0!==e?e:Q().validateOnInput)&&t.nextTick((()=>{he(l.path)}))}function o(){var e;(null!==(e=a().validateOnChange)&&void 0!==e?e:Q().validateOnChange)&&t.nextTick((()=>{he(l.path)}))}const s=t.computed((()=>{const e={onChange:o,onInput:i,onBlur:u};return n(r)?Object.assign(Object.assign({},e),r(z(l,fe)).props||{}):(null==r?void 0:r.props)?Object.assign(Object.assign({},e),r.props(z(l,fe))):e}));return[ie(e,(()=>{var e;return null===(e=a().validateOnModelUpdate)||void 0===e||e})),s]}})}const he=t.defineComponent({name:"Form",inheritAttrs:!1,props:{as:{type:null,default:"form"},validationSchema:{type:Object,default:void 0},initialValues:{type:Object,default:void 0},initialErrors:{type:Object,default:void 0},initialTouched:{type:Object,default:void 0},validateOnMount:{type:Boolean,default:!1},onSubmit:{type:Function,default:void 0},onInvalidSubmit:{type:Function,default:void 0},keepValues:{type:Boolean,default:!1}},setup(e,n){const r=t.toRef(e,"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 T(t,n){return b("function"!=typeof t||n?n:t,e.onInvalidSubmit)(t)}function _(){return c(o)}function R(){return c(s.value)}function B(){return c(u.value)}function x(){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:T,handleReset:y,submitForm:I,setErrors:V,setFieldError:O,setFieldValue:j,setValues:S,setFieldTouched:E,setTouched:k,resetForm:g,resetField:w,getValues:_,getMeta:R,getErrors:B}}return n.expose({setFieldError:O,setErrors:V,setFieldValue:j,setValues:S,setFieldTouched:E,setTouched:k,resetForm:g,validate:m,validateField:h,resetField:w,getValues:_,getMeta:R,getErrors:B}),function(){const r="form"===e.as?e.as:e.as?t.resolveDynamicComponent(e.as):null,l=q(r,n,x);if(!r)return l;const a="form"===r?{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=R(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=R(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=R(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=R(v);return t.computed((()=>(null==e?void 0:e.errors.value)||{}))},e.useFormValues=function(){const e=R(v);return t.computed((()=>(null==e?void 0:e.values)||{}))},e.useIsFieldDirty=function(e){const n=$(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.dirty:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.dirty)&&void 0!==t&&t)}))},e.useIsFieldTouched=function(e){const n=$(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.touched:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.touched)&&void 0!==t&&t)}))},e.useIsFieldValid=function(e){const n=$(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.valid:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.valid)&&void 0!==t&&t)}))},e.useIsFormDirty=function(){const e=R(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=R(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=R(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=R(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=R(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=R(v);return function(t){if(e)return e.resetForm(t)}},e.useSetFieldError=function(e){const n=R(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=R(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=R(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=R(v);return function(t){e&&e.setErrors(t)}},e.useSetFormTouched=function(){const e=R(v);return function(t){e&&e.setTouched(t)}},e.useSetFormValues=function(){const e=R(v);return function(t,n=!0){e&&e.setValues(t,n)}},e.useSubmitCount=function(){const e=R(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=R(v),n=t?t.handleSubmit(e):void 0;return function(e){if(n)return n(e)}},e.useValidateField=function(e){const n=R(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=R(v);return function(){return e?e.validate():Promise.resolve({results:{},errors:{},valid:!0})}},e.validate=Z,e.validateObject=re})); |
{ | ||
"name": "vee-validate", | ||
"version": "4.12.0-alpha.0", | ||
"version": "4.12.0-alpha.1", | ||
"description": "Form Validation for Vue.js", | ||
@@ -5,0 +5,0 @@ "author": "Abdelrahman Awad <logaretm1@gmail.com>", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
376043