vee-validate
Advanced tools
Comparing version 4.12.3 to 4.12.4
/** | ||
* vee-validate v4.12.3 | ||
* vee-validate v4.12.4 | ||
* (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 B(e){return Object.keys(e)}function _(e,n=void 0){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function P(e,t,n){if(Array.isArray(e)){const n=[...e],r=n.findIndex((e=>E(e,t)));return r>=0?n.splice(r,1):n.push(t),n}return E(e,t)?n:t}function R(e,t=0){let n=null,r=[];return function(...l){return n&&clearTimeout(n),n=setTimeout((()=>{const t=e(...l);r.forEach((e=>e(t))),r=[]}),t),new Promise((e=>r.push(e)))}}function x(e,t){return l(t)&&t.number?function(e){const t=parseFloat(e);return isNaN(t)?e:t}(e):e}function U(e,t){let n;return async function(...r){const l=e(...r);n=l;const a=await l;return l!==n?a:(n=void 0,t(a,r))}}function N({get:e,set:n}){const r=t.ref(c(e()));return t.watch(e,(e=>{E(e,r.value)||(r.value=c(e))}),{deep:!0}),t.watch(r,(t=>{E(t,e())||n(c(t))}),{deep:!0}),r}function D(e){return Array.isArray(e)?e:e?[e]:[]}function $(e){const n=_(v),r=e?t.computed((()=>null==n?void 0:n.getPathState(t.toValue(e)))):void 0,l=e?void 0:t.inject(f);return!l&&(null==r||r.value),r||l}function q(e,t){const n={};for(const r in e)t.includes(r)||(n[r]=e[r]);return n}function z(e,t,n){return t.slots.default?"string"!=typeof e&&e?{default:()=>{var e,r;return null===(r=(e=t.slots).default)||void 0===r?void 0:r.call(e,n())}}:t.slots.default(n()):t.slots.default}function W(e){if(L(e))return e._value}function L(e){return"_value"in e}function K(e){if(!F(e))return e;const t=e.target;if(b(t.type)&&L(t))return W(t);if("file"===t.type&&t.files){const e=Array.from(t.files);return t.multiple?e:e[0]}if(O(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map(W);var n;if(O(t)){const e=Array.from(t.options).find((e=>e.selected));return e?W(e):t.value}return function(e){return"number"===e.type||"range"===e.type?Number.isNaN(e.valueAsNumber)?e.value:e.valueAsNumber:e.value}(t)}function G(e){const t={};return Object.defineProperty(t,"_$$isNormalized",{value:!0,writable:!1,enumerable:!1,configurable:!1}),e?l(e)&&e._$$isNormalized?e:l(e)?Object.keys(e).reduce(((t,n)=>{const r=function(e){if(!0===e)return[];if(Array.isArray(e))return e;if(l(e))return e;return[e]}(e[n]);return!1!==e[n]&&(t[n]=X(r)),t}),t):"string"!=typeof e?t:e.split("|").reduce(((e,t)=>{const n=H(t);return n.name?(e[n.name]=X(n.params),e):e}),t):t}function X(e){const t=e=>"string"==typeof e&&"@"===e[0]?function(e){const t=t=>I(t,e)||t[e];return t.__locatorRef=e,t}(e.slice(1)):e;return Array.isArray(e)?e.map(t):e instanceof RegExp?[e]:Object.keys(e).reduce(((n,r)=>(n[r]=t(e[r]),n)),{})}const H=e=>{let t=[];const n=e.split(":")[0];return e.includes(":")&&(t=e.split(":").slice(1).join(":").split(",")),{name:n,params:t}};let J=Object.assign({},{generateMessage:({field:e})=>`${e} is not valid.`,bails:!0,validateOnBlur:!0,validateOnChange:!0,validateOnInput:!1,validateOnModelUpdate:!0});const Q=()=>J,Y=e=>{J=Object.assign(Object.assign({},J),e)};async function Z(e,t,r={}){const l=null==r?void 0:r.bails,a={name:(null==r?void 0:r.name)||"{field}",rules:t,label:null==r?void 0:r.label,bails:null==l||l,formData:(null==r?void 0:r.values)||{}},u=await async function(e,t){if(y(e.rules)||g(e.rules))return async function(e,t){const n=y(t)?t:ee(t),r=await n.parse(e),l=[];for(const e of r.errors)e.errors.length&&l.push(...e.errors);return{errors:l}}(t,e.rules);if(n(e.rules)||Array.isArray(e.rules)){const n={field:e.label||e.name,name:e.name,label:e.label,form:e.formData,value:t},r=Array.isArray(e.rules)?e.rules:[e.rules],l=r.length,a=[];for(let u=0;u<l;u++){const l=r[u],i=await l(t,n);if(!("string"!=typeof i&&!Array.isArray(i)&&i)){if(Array.isArray(i))a.push(...i);else{const e="string"==typeof i?i:ne(n);a.push(e)}if(e.bails)return{errors:a}}}return{errors:a}}const r=Object.assign(Object.assign({},e),{rules:G(e.rules)}),l=[],a=Object.keys(r.rules),u=a.length;for(let n=0;n<u;n++){const u=a[n],i=await te(r,t,{name:u,params:r.rules[u]});if(i.error&&(l.push(i.error),e.bails))return{errors:l}}return{errors:l}}(a,e),i=u.errors;return{errors:i,valid:!i.length}}function ee(e){return{__type:"VVTypedSchema",async parse(t){var n;try{return{output:await e.validate(t,{abortEarly:!1}),errors:[]}}catch(e){if(!function(e){return!!e&&"ValidationError"===e.name}(e))throw e;if(!(null===(n=e.inner)||void 0===n?void 0:n.length)&&e.errors.length)return{errors:[{path:e.path,errors:e.errors}]};const t=e.inner.reduce(((e,t)=>{const n=t.path||"";return e[n]||(e[n]={errors:[],path:n}),e[n].errors.push(...t.errors),e}),{});return{errors:Object.values(t)}}}}}async function te(e,t,n){const r=(l=n.name,s[l]);var l;if(!r)throw new Error(`No such validator '${n.name}' exists.`);const a=function(e,t){const n=e=>h(e)?e(t):e;if(Array.isArray(e))return e.map(n);return Object.keys(e).reduce(((t,r)=>(t[r]=n(e[r]),t)),{})}(n.params,e.formData),u={field:e.label||e.name,name:e.name,label:e.label,value:t,form:e.formData,rule:Object.assign(Object.assign({},n),{params:a})},i=await r(t,a,u);return"string"==typeof i?{error:i}:{error:i?void 0:ne(u)}}function ne(e){const t=Q().generateMessage;return t?t(e):"Field is invalid"}async function re(e,t,n){const r=B(e).map((async r=>{var l,a,u;const i=null===(l=null==n?void 0:n.names)||void 0===l?void 0:l[r],o=await Z(I(t,r),e[r],{name:(null==i?void 0:i.name)||r,label:null==i?void 0:i.label,values:t,bails:null===(u=null===(a=null==n?void 0:n.bailsMap)||void 0===a?void 0:a[r])||void 0===u||u});return Object.assign(Object.assign({},o),{path:r})}));let l=!0;const a=await Promise.all(r),u={},i={};for(const e of a)u[e.path]={valid:e.valid,errors:e.errors},e.valid||(l=!1,i[e.path]=e.errors[0]);return{valid:l,results:u,errors:i}}let le=0;function ae(e,n){const{value:r,initialValue:l,setInitialValue:a}=function(e,n,r){const l=t.ref(t.unref(n));function a(){return r?I(r.initialValues.value,t.unref(e),t.unref(l)):t.unref(l)}function u(n){r?r.setFieldInitialValue(t.unref(e),n,!0):l.value=n}const i=t.computed(a);if(!r){return{value:t.ref(a()),initialValue:i,setInitialValue:u}}const o=function(e,n,r,l){if(t.isRef(e))return t.unref(e);if(void 0!==e)return e;return I(n.values,t.unref(l),t.unref(r))}(n,r,i,e);r.stageInitialValue(t.unref(e),o,!0);const s=t.computed({get:()=>I(r.values,t.unref(e)),set(n){r.setFieldValue(t.unref(e),n,!1)}});return{value:s,initialValue:i,setInitialValue:u}}(e,n.modelValue,n.form);if(!n.form){const{errors:o,setErrors:s}=function(){const e=t.ref([]);return{errors:e,setErrors:t=>{e.value=D(t)}}}(),d=le>=Number.MAX_SAFE_INTEGER?0:++le,c=function(e,n,r,l){var a,u;const i=null!==(u=null===(a=null==l?void 0:l.describe)||void 0===a?void 0:a.call(l).required)&&void 0!==u&&u,o=t.reactive({touched:!1,pending:!1,valid:!0,required:i,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=>{o.valid=!e.length}),{immediate:!0,flush:"sync"}),o}(r,l,o,n.schema);function v(e){var t;"value"in e&&(r.value=e.value),"errors"in e&&s(e.errors),"touched"in e&&(c.touched=null!==(t=e.touched)&&void 0!==t?t:c.touched),"initialValue"in e&&a(e.initialValue)}return{id:d,path:e,value:r,initialValue:l,meta:c,flags:{pendingUnmount:{[d]:!1},pendingReset:!1},errors:o,setState:v}}const u=n.form.createPathState(e,{bails:n.bails,label:n.label,type:n.type,validate:n.validate,schema:n.schema}),i=t.computed((()=>u.errors));return{id:Array.isArray(u.id)?u.id[u.id.length-1]:u.id,path:e,value:r,errors:i,meta:u,initialValue:l,flags:u.__flags,setState:function(l){var u,i,o;"value"in l&&(r.value=l.value),"errors"in l&&(null===(u=n.form)||void 0===u||u.setFieldError(t.unref(e),l.errors)),"touched"in l&&(null===(i=n.form)||void 0===i||i.setFieldTouched(t.unref(e),null!==(o=l.touched)&&void 0!==o&&o)),"initialValue"in l&&a(l.initialValue)}}}function ue(e,n,r){return b(null==r?void 0:r.type)?function(e,n,r){const l=(null==r?void 0:r.standalone)?void 0:_(v),a=null==r?void 0:r.checkedValue,u=null==r?void 0:r.uncheckedValue;function i(n){const i=n.handleChange,o=t.computed((()=>{const e=t.toValue(n.value),r=t.toValue(a);return Array.isArray(e)?e.findIndex((e=>E(e,r)))>=0:E(r,e)}));function s(s,d=!0){var c,v;if(o.value===(null===(c=null==s?void 0:s.target)||void 0===c?void 0:c.checked))return void(d&&n.validate());const f=t.toValue(e),p=null==l?void 0:l.getPathState(f),m=K(s);let h=null!==(v=t.toValue(a))&&void 0!==v?v:m;l&&(null==p?void 0:p.multiple)&&"checkbox"===p.type?h=P(I(l.values,f)||[],h,void 0):"checkbox"===(null==r?void 0:r.type)&&(h=P(t.toValue(n.value),h,t.toValue(u))),i(h,d)}return Object.assign(Object.assign({},n),{checked:o,checkedValue:a,uncheckedValue:u,handleChange:s})}return i(ie(e,n,r))}(e,n,r):ie(e,n,r)}function ie(e,r,l){const{initialValue:a,validateOnMount:u,bails:i,type:s,checkedValue:d,label:m,validateOnValueUpdate:b,uncheckedValue:V,controlled:O,keepValueOnUnmount:j,syncVModel:A,form:F}=function(e){const n=()=>({initialValue:void 0,validateOnMount:!1,bails:!0,label:void 0,validateOnValueUpdate:!0,keepValueOnUnmount:void 0,syncVModel:!1,controlled:!0}),r=!!(null==e?void 0:e.syncVModel),l="string"==typeof(null==e?void 0:e.syncVModel)?e.syncVModel:(null==e?void 0:e.modelPropName)||"modelValue",a=r&&!("initialValue"in(e||{}))?oe(t.getCurrentInstance(),l):null==e?void 0:e.initialValue;if(!e)return Object.assign(Object.assign({},n()),{initialValue:a});const u="valueProp"in e?e.valueProp:e.checkedValue,i="standalone"in e?!e.standalone:e.controlled,o=(null==e?void 0:e.modelPropName)||(null==e?void 0:e.syncVModel)||!1;return Object.assign(Object.assign(Object.assign({},n()),e||{}),{initialValue:a,controlled:null==i||i,checkedValue:u,syncVModel:o})}(l),S=O?_(v):void 0,k=F||S,w=t.computed((()=>o(t.toValue(e)))),M=t.computed((()=>{if(t.toValue(null==k?void 0:k.schema))return;const e=t.unref(r);return g(e)||y(e)||n(e)||Array.isArray(e)?e:G(e)})),{id:C,value:T,initialValue:P,meta:R,setState:N,errors:D,flags:$}=ae(w,{modelValue:a,form:k,bails:i,label:m,type:s,validate:M.value?X:void 0,schema:y(r)?r:void 0}),q=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 z(e){var n,r;if(null==k?void 0:k.validateSchema){const{results:r}=await k.validateSchema(e);return null!==(n=r[t.toValue(w)])&&void 0!==n?n:{valid:!0,errors:[]}}return M.value?Z(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 W=U((async()=>(R.pending=!0,R.validated=!0,z("validated-only"))),(e=>($.pendingUnmount[te.id]||(N({errors:e.errors}),R.pending=!1,R.valid=e.valid),e))),L=U((async()=>z("silent")),(e=>(R.valid=e.valid,e)));function X(e){return"silent"===(null==e?void 0:e.mode)?L():W()}function H(e,t=!0){Y(K(e),t)}function J(e){var t;const n=e&&"value"in e?e.value:P.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)||[]}),R.pending=!1,R.validated=!1,L()}t.onMounted((()=>{if(u)return W();k&&k.validateSchema||L()}));const Q=t.getCurrentInstance();function Y(e,t=!0){T.value=Q&&A?x(e,Q.props.modelModifiers):e;(t?W:L)()}const ee=t.computed({get:()=>T.value,set(e){Y(e,b)}}),te={id:C,name:w,label:m,value:ee,meta:R,errors:D,errorMessage:q,type:s,checkedValue:d,uncheckedValue:V,bails:i,keepValueOnUnmount:j,resetField:J,handleReset:()=>J(),validate:X,handleChange:H,handleBlur:(e,t=!1)=>{R.touched=!0,t&&W()},setState:N,setTouched:function(e){R.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)||(R.validated?W():L())}),{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):B(l).filter((e=>h(l[e]))).map((e=>l[e]))).map((e=>e.__locatorRef)).reduce(((e,t)=>{const n=I(k.values,t)||k.values[t];return void 0!==n&&(e[t]=n),e}),{});var l;return Object.assign(t,r),t}),{})}));return t.watch(ne,((e,t)=>{if(!Object.keys(e).length)return;!E(e,t)&&(R.validated?W():L())})),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({value:d,meta:g,errors:s,errorMessage:c,setErrors:O,setTouched:m,reset:h,validate:v,handleChange:f}),()=>{const n=t.resolveDynamicComponent(se(e,r)),l=z(n,r,k);return n?t.h(n,Object.assign(Object.assign({},r.attrs),S.value),l):l}}});let ve=0;const fe=["bails","fieldsCount","id","multiple","type","validate"];function pe(e){const r=Object.assign({},t.toValue((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=D(t),n.valid=!n.errors.length}else"string"==typeof e&&(h.value[o(e)]=D(t))}function j(e){B(e).forEach((t=>{O(t,e[t])}))}(null==e?void 0:e.initialErrors)&&j(e.initialErrors);const F=t.computed((()=>{const e=m.value.reduce(((e,t)=>(t.errors.length&&(e[t.path]=t.errors),e)),{});return Object.assign(Object.assign({},h.value),e)})),S=t.computed((()=>B(F.value).reduce(((e,t)=>{const n=F.value[t];return(null==n?void 0:n.length)&&(e[t]=n[0]),e}),{}))),k=t.computed((()=>m.value.reduce(((e,t)=>(e[t.path]={name:t.path||"",label:t.label||""},e)),{}))),w=t.computed((()=>m.value.reduce(((e,t)=>{var n;return e[t.path]=null===(n=t.bails)||void 0===n||n,e}),{}))),C=Object.assign({},(null==e?void 0:e.initialErrors)||{}),_=null!==(r=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==r&&r,{initialValues:P,originalInitialValues:x,setInitialValues:N}=function(e,n,r){const l=pe(r),a=t.ref(l),u=t.ref(c(l));function o(t,r=!1){a.value=i(c(a.value)||{},c(t)),u.value=i(c(u.value)||{},c(t)),r&&e.value.forEach((e=>{if(e.touched)return;const t=I(a.value,e.path);M(n,e.path,c(t))}))}return{initialValues:a,originalInitialValues:u,setInitialValues:o}}(m,p,e),$=function(e,n,r,l){const a={touched:"some",pending:"some",valid:"every"},u=t.computed((()=>!E(n,t.unref(r))));function i(){const t=e.value;return B(a).reduce(((e,n)=>{const r=a[n];return e[n]=t[r]((e=>e[n])),e}),{})}const o=t.reactive(i());return t.watchEffect((()=>{const e=i();o.touched=e.touched,o.valid=e.valid,o.pending=e.pending})),t.computed((()=>Object.assign(Object.assign({initialValues:t.unref(r)},o),{valid:o.valid&&!B(l.value).length,dirty:u.value})))}(m,p,x,S),z=t.computed((()=>m.value.reduce(((e,t)=>{const n=I(p,t.path);return M(e,t.path,n),e}),{}))),W=null==e?void 0:e.validationSchema;function L(e,n){var r,l;const u=t.computed((()=>I(P.value,t.toValue(e)))),i=b.value[t.toValue(e)],o="checkbox"===(null==n?void 0:n.type)||"radio"===(null==n?void 0:n.type);if(i&&o){i.multiple=!0;const e=a++;return Array.isArray(i.id)?i.id.push(e):i.id=[i.id,e],i.fieldsCount++,i.__flags.pendingUnmount[e]=!1,i}const s=t.computed((()=>I(p,t.toValue(e)))),d=t.toValue(e),v=t.computed((()=>{var r,l,a,u,i,o;return y(W)?null!==(a=null===(l=(r=W).describe)||void 0===l?void 0:l.call(r,t.toValue(e)).required)&&void 0!==a&&a:!!y(null==n?void 0:n.schema)&&(null!==(o=null===(i=(u=null==n?void 0:n.schema).describe)||void 0===i?void 0:i.call(u).required)&&void 0!==o&&o)})),f=a++,h=t.reactive({id:f,path:e,touched:!1,pending:!1,valid:!0,validated:!!(null===(r=C[d])||void 0===r?void 0:r.length),required:v,initialValue:u,errors:t.shallowRef([]),bails:null!==(l=null==n?void 0:n.bails)&&void 0!==l&&l,label:null==n?void 0:n.label,type:(null==n?void 0:n.type)||"default",value:s,multiple:!1,__flags:{pendingUnmount:{[f]:!1},pendingReset:!1},fieldsCount:1,validate:null==n?void 0:n.validate,dirty:t.computed((()=>!E(t.unref(s),t.unref(u))))});return m.value.push(h),b.value[d]=h,V(),S.value[d]&&!C[d]&&t.nextTick((()=>{ye(d,{mode:"silent"})})),t.isRef(e)&&t.watch(e,(e=>{V();const n=c(s.value);b.value[e]=h,t.nextTick((()=>{M(p,e,n)}))})),h}const G=R(Ve,5),X=R(Ve,5),H=U((async e=>await("silent"===e?G():X())),((e,[n])=>{const r=B(ae.errorBag.value),l=[...new Set([...B(e.results),...m.value.map((e=>e.path)),...r])].sort().reduce(((r,l)=>{var a;const u=l,i=Y(u)||function(e){const t=m.value.filter((t=>e.startsWith(t.path)));return t.reduce(((e,t)=>e?t.path.length>e.path.length?t:e:t),void 0)}(u),o=(null===(a=e.results[u])||void 0===a?void 0:a.errors)||[],s=t.toValue(null==i?void 0:i.path)||u,d=function(e,t){if(!t)return e;return{valid:e.valid&&t.valid,errors:[...e.errors,...t.errors]}}({errors:o,valid:!o.length},r.results[s]);return r.results[s]=d,d.valid||(r.errors[s]=d.errors[0]),i&&h.value[s]&&delete h.value[s],i?(i.valid=d.valid,"silent"===n?r:"validated-only"!==n||i.validated?(O(i,d.errors),r):r):(O(s,o),r)}),{valid:e.valid,results:{},errors:{}});return e.values&&(l.values=e.values),l}));function J(e){m.value.forEach(e)}function Y(e){const t="string"==typeof e?o(e):e;return"string"==typeof t?b.value[t]:t}let Z,te=[];function ne(e){return function(t,n){return function(r){return r instanceof Event&&(r.preventDefault(),r.stopPropagation()),J((e=>e.touched=!0)),u.value=!0,d.value++,he().then((l=>{const a=c(p);if(l.valid&&"function"==typeof t){const n=c(z.value);let u=e?n:a;return l.values&&(u=l.values),t(u,{evt:r,controlledValues:n,setErrors:j,setFieldError:O,setTouched:de,setFieldTouched:se,setValues:ie,setFieldValue:ue,resetForm:me,resetField:ce})}l.valid||"function"!=typeof n||n({values:a,evt:r,errors:l.errors,results:l.results})})).then((e=>(u.value=!1,e)),(e=>{throw u.value=!1,e}))}}}const le=ne(!1);le.withControlled=ne(!0);const ae={formId:l,values:p,controlledValues:z,errorBag:F,errors:S,schema:W,submitCount:d,meta:$,isSubmitting:u,isValidating:s,fieldArrays:f,keepValuesOnUnmount:_,validateSchema:t.unref(W)?H:void 0,validate:he,setFieldError:O,validateField:ye,setFieldValue:ue,setValues:ie,setErrors:j,setFieldTouched:se,setTouched:de,resetForm:me,resetField:ce,handleSubmit:le,useFieldModel:function(e){if(!Array.isArray(e))return oe(e);return e.map((e=>oe(e,!0)))},defineInputBinds:function(e,n){const[r,l]=je(e,n);function a(e){l.value.onBlur(e)}function u(n){const r=K(n);ue(t.toValue(e),r,!1),l.value.onInput(n)}function i(n){const r=K(n);ue(t.toValue(e),r,!1),l.value.onChange(n)}return t.computed((()=>Object.assign(Object.assign({},l.value),{onBlur:a,onInput:u,onChange:i,value:r.value})))},defineComponentBinds:function(e,r){const[l,a]=je(e,r),u=Y(t.toValue(e));function i(e){l.value=e}return t.computed((()=>{const e=n(r)?r(q(u,fe)):r||{};return Object.assign({[e.model||"modelValue"]:l.value,[`onUpdate:${e.model||"modelValue"}`]:i},a.value)}))},defineField:je,stageInitialValue:function(t,n,r=!1){be(t,n),M(p,t,n),r&&!(null==e?void 0:e.initialValues)&&M(x.value,t,c(n))},unsetInitialValue:ge,setFieldInitialValue:be,createPathState:L,getPathState:Y,unsetPathValue:function(e){return te.push(e),Z||(Z=t.nextTick((()=>{[...te].sort().reverse().forEach((e=>{T(p,e)})),te=[],Z=null}))),Z},removePathState:function(e,n){const r=m.value.findIndex((t=>t.path===e)),l=m.value[r];if(-1!==r&&l){if(t.nextTick((()=>{ye(e,{mode:"silent",warn:!1})})),l.multiple&&l.fieldsCount&&l.fieldsCount--,Array.isArray(l.id)){const e=l.id.indexOf(n);e>=0&&l.id.splice(e,1),delete l.__flags.pendingUnmount[n]}(!l.multiple||l.fieldsCount<=0)&&(m.value.splice(r,1),ge(e),V(),delete b.value[e])}},initialValues:P,getAllPathStates:()=>m.value,destroyPath:function(e){B(b.value).forEach((t=>{t.startsWith(e)&&delete b.value[t]})),m.value=m.value.filter((t=>!t.path.startsWith(e))),t.nextTick((()=>{V()}))},isFieldTouched:function(e){const t=Y(e);if(t)return t.touched;return m.value.filter((t=>t.path.startsWith(e))).some((e=>e.touched))},isFieldDirty:function(e){const t=Y(e);if(t)return t.dirty;return m.value.filter((t=>t.path.startsWith(e))).some((e=>e.dirty))},isFieldValid:function(e){const t=Y(e);if(t)return t.valid;return m.value.filter((t=>t.path.startsWith(e))).every((e=>e.valid))}};function ue(e,t,n=!0){const r=c(t),l="string"==typeof e?e:e.path;Y(l)||L(l),M(p,l,r),n&&ye(l)}function ie(e,t=!0){i(p,e),f.forEach((e=>e&&e.reset())),t&&he()}function oe(e,n){const r=Y(t.toValue(e))||L(e);return t.computed({get:()=>r.value,set(r){var l;ue(t.toValue(e),r,null!==(l=t.toValue(n))&&void 0!==l&&l)}})}function se(e,t){const n=Y(e);n&&(n.touched=t)}function de(e){"boolean"!=typeof e?B(e).forEach((t=>{se(t,!!e[t])})):J((t=>{t.touched=e}))}function ce(e,n){var r;const l=n&&"value"in n?n.value:I(P.value,e),a=Y(e);a&&(a.__flags.pendingReset=!0),be(e,c(l),!0),ue(e,l,!1),se(e,null!==(r=null==n?void 0:n.touched)&&void 0!==r&&r),O(e,(null==n?void 0:n.errors)||[]),t.nextTick((()=>{a&&(a.__flags.pendingReset=!1)}))}function me(e,r){let l=c((null==e?void 0:e.values)?e.values:x.value);l=(null==r?void 0:r.force)?l:i(x.value,l),l=y(W)&&n(W.cast)?W.cast(l):l,N(l),J((t=>{var n;t.__flags.pendingReset=!0,t.validated=!1,t.touched=(null===(n=null==e?void 0:e.touched)||void 0===n?void 0:n[t.path])||!1,ue(t.path,I(l,t.path),!1),O(t.path,void 0)})),(null==r?void 0:r.force)?function(e,t=!0){B(p).forEach((e=>{delete p[e]})),B(e).forEach((t=>{ue(t,e[t],!1)})),t&&he()}(l,!1):ie(l,!1),j((null==e?void 0:e.errors)||{}),d.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{he({mode:"silent"}),J((e=>{e.__flags.pendingReset=!1}))}))}async function he(e){const t=(null==e?void 0:e.mode)||"force";if("force"===t&&J((e=>e.validated=!0)),ae.validateSchema)return ae.validateSchema(t);s.value=!0;const n=await Promise.all(m.value.map((t=>t.validate?t.validate(e).then((e=>({key:t.path,valid:e.valid,errors:e.errors}))):Promise.resolve({key:t.path,valid:!0,errors:[]}))));s.value=!1;const r={},l={};for(const e of n)r[e.key]={valid:e.valid,errors:e.errors},e.errors.length&&(l[e.key]=e.errors[0]);return{valid:n.every((e=>e.valid)),results:r,errors:l}}async function ye(e,t){const n=Y(e);if(n&&"silent"!==(null==t?void 0:t.mode)&&(n.validated=!0),W){const{results:n}=await H((null==t?void 0:t.mode)||"validated-only");return n[e]||{errors:[],valid:!0}}return(null==n?void 0:n.validate)?n.validate(t):(!n&&(null==t?void 0:t.warn),Promise.resolve({errors:[],valid:!0}))}function ge(e){T(P.value,e)}function be(e,t,n=!1){M(P.value,e,c(t)),n&&M(x.value,e,c(t))}async function Ve(){const e=t.unref(W);if(!e)return{valid:!0,results:{},errors:{}};s.value=!0;const n=g(e)||y(e)?await async function(e,t){const n=y(e)?e:ee(e),r=await n.parse(c(t)),l={},a={};for(const e of r.errors){const t=e.errors,n=(e.path||"").replace(/\["(\d+)"\]/g,((e,t)=>`[${t}]`));l[n]={valid:!t.length,errors:t},t.length&&(a[n]=t[0])}return{valid:!r.errors.length,results:l,errors:a,values:r.value}}(e,p):await re(e,p,{names:k.value,bailsMap:w.value});return s.value=!1,n}const Oe=le(((e,{evt:t})=>{A(t)&&t.target.submit()}));function je(e,r){const l=n(r)||null==r?void 0:r.label,a=Y(t.toValue(e))||L(e,{label:l}),u=()=>n(r)?r(q(a,fe)):r||{};function i(){var e;a.touched=!0;(null!==(e=u().validateOnBlur)&&void 0!==e?e:Q().validateOnBlur)&&ye(a.path)}function o(){var e;(null!==(e=u().validateOnInput)&&void 0!==e?e:Q().validateOnInput)&&t.nextTick((()=>{ye(a.path)}))}function s(){var e;(null!==(e=u().validateOnChange)&&void 0!==e?e:Q().validateOnChange)&&t.nextTick((()=>{ye(a.path)}))}const d=t.computed((()=>{const e={onChange:s,onInput:o,onBlur:i};return n(r)?Object.assign(Object.assign({},e),r(q(a,fe)).props||{}):(null==r?void 0:r.props)?Object.assign(Object.assign({},e),r.props(q(a,fe))):e})),c=oe(e,(()=>{var e,t,n;return null===(n=null!==(e=u().validateOnModelUpdate)&&void 0!==e?e:null===(t=Q())||void 0===t?void 0:t.validateOnModelUpdate)||void 0===n||n}));return[c,d]}return t.onMounted((()=>{(null==e?void 0:e.initialErrors)&&j(e.initialErrors),(null==e?void 0:e.initialTouched)&&de(e.initialTouched),(null==e?void 0:e.validateOnMount)?he():ae.validateSchema&&ae.validateSchema("silent")})),t.isRef(W)&&t.watch(W,(()=>{var e;null===(e=ae.validateSchema)||void 0===e||e.call(ae,"validated-only")})),t.provide(v,ae),Object.assign(Object.assign({},ae),{values:t.readonly(p),handleReset:()=>me(),submitForm:Oe})}const he=t.defineComponent({name:"Form",inheritAttrs:!1,props:{as:{type:null,default:"form"},validationSchema:{type:Object,default:void 0},initialValues:{type:Object,default:void 0},initialErrors:{type:Object,default:void 0},initialTouched:{type:Object,default:void 0},validateOnMount:{type:Boolean,default:!1},onSubmit:{type:Function,default:void 0},onInvalidSubmit:{type:Function,default:void 0},keepValues:{type:Boolean,default:!1}},setup(e,n){const r=t.toRef(e,"validationSchema"),l=t.toRef(e,"keepValues"),{errors:a,errorBag:u,values:i,meta:o,isSubmitting:s,isValidating:d,submitCount:v,controlledValues:f,validate:p,validateField:m,handleReset:h,resetForm:y,handleSubmit:g,setErrors:b,setFieldError:V,setFieldValue:O,setValues:j,setFieldTouched:S,setTouched:E,resetField:k}=me({validationSchema:r.value?r:void 0,initialValues:e.initialValues,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:l}),w=g(((e,{evt:t})=>{A(t)&&t.target.submit()}),e.onInvalidSubmit),I=e.onSubmit?g(e.onSubmit,e.onInvalidSubmit):w;function M(e){F(e)&&e.preventDefault(),h(),"function"==typeof n.attrs.onReset&&n.attrs.onReset()}function C(t,n){return g("function"!=typeof t||n?n:t,e.onInvalidSubmit)(t)}function T(){return c(i)}function B(){return c(o.value)}function _(){return c(a.value)}function P(){return{meta:o.value,errors:a.value,errorBag:u.value,values:i,isSubmitting:s.value,isValidating:d.value,submitCount:v.value,controlledValues:f.value,validate:p,validateField:m,handleSubmit:C,handleReset:h,submitForm:w,setErrors:b,setFieldError:V,setFieldValue:O,setValues:j,setFieldTouched:S,setTouched:E,resetForm:y,resetField:k,getValues:T,getMeta:B,getErrors:_}}return n.expose({setFieldError:V,setErrors:b,setFieldValue:O,setValues:j,setFieldTouched:S,setTouched:E,resetForm:y,validate:p,validateField:m,resetField:k,getValues:T,getMeta:B,getErrors:_,values:i,meta:o,errors:a}),function(){const r="form"===e.as?e.as:e.as?t.resolveDynamicComponent(e.as):null,l=z(r,n,P);if(!r)return l;const a="form"===r?{novalidate:!0}:{};return t.h(r,Object.assign(Object.assign(Object.assign({},a),n.attrs),{onSubmit:I,onReset:M}),l)}}}),ye=he;function ge(e){const n=_(v,void 0),l=t.ref([]),a=()=>{},u={fields:l,remove:a,push:a,swap:a,insert:a,update:a,replace:a,prepend:a,move:a};if(!n)return u;if(!t.unref(e))return u;const i=n.fieldArrays.find((n=>t.unref(n.path)===t.unref(e)));if(i)return i;let o=0;function s(){return I(null==n?void 0:n.values,t.toValue(e),[])||[]}function d(){const e=s();Array.isArray(e)&&(l.value=e.map(((e,t)=>p(e,t,l.value))),f())}function f(){const e=l.value.length;for(let t=0;t<e;t++){const n=l.value[t];n.isFirst=0===t,n.isLast=t===e-1}}function p(a,u,i){if(i&&!r(u)&&i[u])return i[u];const s=o++,d={key:s,value:N({get(){const r=I(null==n?void 0:n.values,t.toValue(e),[])||[],u=l.value.findIndex((e=>e.key===s));return-1===u?a:r[u]},set(e){const t=l.value.findIndex((e=>e.key===s));-1!==t&&h(t,e)}}),isFirst:!1,isLast:!1};return d}function m(){f(),null==n||n.validate({mode:"silent"})}function h(r,l){const a=t.toValue(e),u=I(null==n?void 0:n.values,a);!Array.isArray(u)||u.length-1<r||(M(n.values,`${a}[${r}]`,l),null==n||n.validate({mode:"validated-only"}))}d();const y={fields:l,remove:function(r){const a=t.toValue(e),u=I(null==n?void 0:n.values,a);if(!u||!Array.isArray(u))return;const i=[...u];i.splice(r,1);const o=a+`[${r}]`;n.destroyPath(o),n.unsetInitialValue(o),M(n.values,a,i),l.value.splice(r,1),m()},push:function(a){const u=c(a),i=t.toValue(e),o=I(null==n?void 0:n.values,i),s=r(o)?[]:o;if(!Array.isArray(s))return;const d=[...s];d.push(u),n.stageInitialValue(i+`[${d.length-1}]`,u),M(n.values,i,d),l.value.push(p(u)),m()},swap:function(r,a){const u=t.toValue(e),i=I(null==n?void 0:n.values,u);if(!Array.isArray(i)||!(r in i)||!(a in i))return;const o=[...i],s=[...l.value],d=o[r];o[r]=o[a],o[a]=d;const c=s[r];s[r]=s[a],s[a]=c,M(n.values,u,o),l.value=s,f()},insert:function(r,a){const u=c(a),i=t.toValue(e),o=I(null==n?void 0:n.values,i);if(!Array.isArray(o)||o.length<r)return;const s=[...o],d=[...l.value];s.splice(r,0,u),d.splice(r,0,p(u)),M(n.values,i,s),l.value=d,m()},update:h,replace:function(r){const l=t.toValue(e);n.stageInitialValue(l,r),M(n.values,l,r),d(),m()},prepend:function(a){const u=c(a),i=t.toValue(e),o=I(null==n?void 0:n.values,i),s=r(o)?[]:o;if(!Array.isArray(s))return;const d=[u,...s];M(n.values,i,d),n.stageInitialValue(i+"[0]",u),l.value.unshift(p(u)),m()},move:function(a,u){const i=t.toValue(e),o=I(null==n?void 0:n.values,i),s=r(o)?[]:[...o];if(!Array.isArray(o)||!(a in o)||!(u in o))return;const d=[...l.value],c=d[a];d.splice(a,1),d.splice(u,0,c);const v=s[a];s.splice(a,1),s.splice(u,0,v),M(n.values,i,s),l.value=d,m()}};return n.fieldArrays.push(Object.assign({path:e,reset:d},y)),t.onBeforeUnmount((()=>{const r=n.fieldArrays.findIndex((n=>t.toValue(n.path)===t.toValue(e)));r>=0&&n.fieldArrays.splice(r,1)})),t.watch(s,(e=>{E(e,l.value.map((e=>e.value)))||d()})),y}const be=t.defineComponent({name:"FieldArray",inheritAttrs:!1,props:{name:{type:String,required:!0}},setup(e,t){const{push:n,remove:r,swap:l,insert:a,replace:u,update:i,prepend:o,move:s,fields:d}=ge((()=>e.name));function c(){return{fields:d.value,push:n,remove:r,swap:l,insert:a,update:i,replace:u,prepend:o,move:s}}return t.expose({push:n,remove:r,swap:l,insert:a,update:i,replace:u,prepend:o,move:s}),()=>z(void 0,t,c)}}),Ve=t.defineComponent({name:"ErrorMessage",props:{as:{type:String,default:void 0},name:{type:String,required:!0}},setup(e,n){const r=t.inject(v,void 0),l=t.computed((()=>null==r?void 0:r.errors.value[e.name]));function a(){return{message:l.value}}return()=>{if(!l.value)return;const r=e.as?t.resolveDynamicComponent(e.as):e.as,u=z(r,n,a),i=Object.assign({role:"alert"},n.attrs);return r||!Array.isArray(u)&&u||!(null==u?void 0:u.length)?!Array.isArray(u)&&u||(null==u?void 0:u.length)?t.h(r,i,u):t.h(r||"span",i,l.value):u}}});e.ErrorMessage=Ve,e.Field=ce,e.FieldArray=be,e.FieldContextKey=f,e.Form=ye,e.FormContextKey=v,e.IS_ABSENT=p,e.cleanupNonNestedPath=w,e.configure=Y,e.defineRule=function(e,t){!function(e,t){if(n(t))return;throw new Error(`Extension Error: The validator '${e}' must be a function.`)}(e,t),s[e]=t},e.isNotNestedPath=V,e.normalizeRules=G,e.useField=ue,e.useFieldArray=ge,e.useFieldError=function(e){const n=_(v),r=e?void 0:t.inject(f);return t.computed((()=>e?null==n?void 0:n.errors.value[t.toValue(e)]:null==r?void 0:r.errorMessage.value))},e.useFieldValue=function(e){const n=_(v),r=e?void 0:t.inject(f);return t.computed((()=>e?I(null==n?void 0:n.values,t.toValue(e)):t.toValue(null==r?void 0:r.value)))},e.useForm=me,e.useFormErrors=function(){const e=_(v);return t.computed((()=>(null==e?void 0:e.errors.value)||{}))},e.useFormValues=function(){const e=_(v);return t.computed((()=>(null==e?void 0:e.values)||{}))},e.useIsFieldDirty=function(e){const n=$(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.dirty:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.dirty)&&void 0!==t&&t)}))},e.useIsFieldTouched=function(e){const n=$(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.touched:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.touched)&&void 0!==t&&t)}))},e.useIsFieldValid=function(e){const n=$(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.valid:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.valid)&&void 0!==t&&t)}))},e.useIsFormDirty=function(){const e=_(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.dirty)&&void 0!==t&&t}))},e.useIsFormTouched=function(){const e=_(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.touched)&&void 0!==t&&t}))},e.useIsFormValid=function(){const e=_(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.valid)&&void 0!==t&&t}))},e.useIsSubmitting=function(){const e=_(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isSubmitting.value)&&void 0!==t&&t}))},e.useIsValidating=function(){const e=_(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isValidating.value)&&void 0!==t&&t}))},e.useResetForm=function(){const e=_(v);return function(t){if(e)return e.resetForm(t)}},e.useSetFieldError=function(e){const n=_(v),r=e?void 0:t.inject(f);return function(l){e&&n?n.setFieldError(t.toValue(e),l):r&&r.setErrors(l||[])}},e.useSetFieldTouched=function(e){const n=_(v),r=e?void 0:t.inject(f);return function(l){e&&n?n.setFieldTouched(t.toValue(e),l):r&&r.setTouched(l)}},e.useSetFieldValue=function(e){const n=_(v),r=e?void 0:t.inject(f);return function(l,a=!0){e&&n?n.setFieldValue(t.toValue(e),l,a):r&&r.setValue(l,a)}},e.useSetFormErrors=function(){const e=_(v);return function(t){e&&e.setErrors(t)}},e.useSetFormTouched=function(){const e=_(v);return function(t){e&&e.setTouched(t)}},e.useSetFormValues=function(){const e=_(v);return function(t,n=!0){e&&e.setValues(t,n)}},e.useSubmitCount=function(){const e=_(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.submitCount.value)&&void 0!==t?t:0}))},e.useSubmitForm=function(e){const t=_(v),n=t?t.handleSubmit(e):void 0;return function(e){if(n)return n(e)}},e.useValidateField=function(e){const n=_(v),r=e?void 0:t.inject(f);return function(){return r?r.validate():n&&e?null==n?void 0:n.validateField(t.toValue(e)):Promise.resolve({errors:[],valid:!0})}},e.useValidateForm=function(){const e=_(v);return function(){return e?e.validate():Promise.resolve({results:{},errors:{},valid:!0})}},e.validate=Z,e.validateObject=re})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VeeValidate={},e.Vue)}(this,(function(e,t){"use strict";function n(e){return"function"==typeof e}function r(e){return null==e}const l=e=>null!==e&&!!e&&"object"==typeof e&&!Array.isArray(e);function a(e){return Number(e)>=0}function u(e){if(!function(e){return"object"==typeof e&&null!==e}(e)||"[object Object]"!==function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}(e))return!1;if(null===Object.getPrototypeOf(e))return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function i(e,t){return Object.keys(t).forEach((n=>{if(u(t[n])&&u(e[n]))return e[n]||(e[n]={}),void i(e[n],t[n]);e[n]=t[n]})),e}function o(e){const t=e.split(".");if(!t.length)return"";let n=String(t[0]);for(let e=1;e<t.length;e++)a(t[e])?n+=`[${t[e]}]`:n+=`.${t[e]}`;return n}const s={};function d(e,t,n){"object"==typeof n.value&&(n.value=c(n.value)),n.enumerable&&!n.get&&!n.set&&n.configurable&&n.writable&&"__proto__"!==t?e[t]=n.value:Object.defineProperty(e,t,n)}function c(e){if("object"!=typeof e)return e;var t,n,r,l=0,a=Object.prototype.toString.call(e);if("[object Object]"===a?r=Object.create(e.__proto__||null):"[object Array]"===a?r=Array(e.length):"[object Set]"===a?(r=new Set,e.forEach((function(e){r.add(c(e))}))):"[object Map]"===a?(r=new Map,e.forEach((function(e,t){r.set(c(t),c(e))}))):"[object Date]"===a?r=new Date(+e):"[object RegExp]"===a?r=new RegExp(e.source,e.flags):"[object DataView]"===a?r=new e.constructor(c(e.buffer)):"[object ArrayBuffer]"===a?r=e.slice(0):"Array]"===a.slice(-6)&&(r=new e.constructor(e)),r){for(n=Object.getOwnPropertySymbols(e);l<n.length;l++)d(r,n[l],Object.getOwnPropertyDescriptor(e,n[l]));for(l=0,n=Object.getOwnPropertyNames(e);l<n.length;l++)Object.hasOwnProperty.call(r,t=n[l])&&r[t]===e[t]||d(r,t,Object.getOwnPropertyDescriptor(e,t))}return r||e}const v=Symbol("vee-validate-form"),f=Symbol("vee-validate-field-instance"),p=Symbol("Default empty value"),m="undefined"!=typeof window;function h(e){return n(e)&&!!e.__locatorRef}function y(e){return!!e&&n(e.parse)&&"VVTypedSchema"===e.__type}function g(e){return!!e&&n(e.validate)}function b(e){return"checkbox"===e||"radio"===e}function V(e){return/^\[.+\]$/i.test(e)}function O(e){return"SELECT"===e.tagName}function j(e,t){return!function(e,t){const n=![!1,null,void 0,0].includes(t.multiple)&&!Number.isNaN(t.multiple);return"select"===e&&"multiple"in t&&n}(e,t)&&"file"!==t.type&&!b(t.type)}function A(e){return F(e)&&e.target&&"submit"in e.target}function F(e){return!!e&&(!!("undefined"!=typeof Event&&n(Event)&&e instanceof Event)||!(!e||!e.srcElement))}function S(e,t){return t in e&&e[t]!==p}function E(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;var n,r,l;if(Array.isArray(e)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(!E(e[r],t[r]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;for(r of e.entries())if(!E(r[1],t.get(r[0])))return!1;return!0}if(k(e)&&k(t))return e.size===t.size&&(e.name===t.name&&(e.lastModified===t.lastModified&&e.type===t.type));if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(e[r]!==t[r])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();for(r=n=(l=Object.keys(e)).length;0!=r--;){var a=l[r];if(!E(e[a],t[a]))return!1}return!0}return e!=e&&t!=t}function k(e){return!!m&&e instanceof File}function w(e){return V(e)?e.replace(/\[|\]/gi,""):e}function I(e,t,n){if(!e)return n;if(V(t))return e[w(t)];return(t||"").split(/\.|\[(\d+)\]/).filter(Boolean).reduce(((e,t)=>{return(l(r=e)||Array.isArray(r))&&t in e?e[t]:n;var r}),e)}function M(e,t,n){if(V(t))return void(e[w(t)]=n);const l=t.split(/\.|\[(\d+)\]/).filter(Boolean);let u=e;for(let e=0;e<l.length;e++){if(e===l.length-1)return void(u[l[e]]=n);l[e]in u&&!r(u[l[e]])||(u[l[e]]=a(l[e+1])?[]:{}),u=u[l[e]]}}function C(e,t){Array.isArray(e)&&a(t)?e.splice(Number(t),1):l(e)&&delete e[t]}function T(e,t){if(V(t))return void delete e[w(t)];const n=t.split(/\.|\[(\d+)\]/).filter(Boolean);let a=e;for(let e=0;e<n.length;e++){if(e===n.length-1){C(a,n[e]);break}if(!(n[e]in a)||r(a[n[e]]))break;a=a[n[e]]}const u=n.map(((t,r)=>I(e,n.slice(0,r).join("."))));for(let t=u.length-1;t>=0;t--)i=u[t],(Array.isArray(i)?0===i.length:l(i)&&0===Object.keys(i).length)&&(0!==t?C(u[t-1],n[t-1]):C(e,n[0]));var i}function B(e){return Object.keys(e)}function _(e,n=void 0){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function P(e,t,n){if(Array.isArray(e)){const n=[...e],r=n.findIndex((e=>E(e,t)));return r>=0?n.splice(r,1):n.push(t),n}return E(e,t)?n:t}function R(e,t=0){let n=null,r=[];return function(...l){return n&&clearTimeout(n),n=setTimeout((()=>{const t=e(...l);r.forEach((e=>e(t))),r=[]}),t),new Promise((e=>r.push(e)))}}function x(e,t){return l(t)&&t.number?function(e){const t=parseFloat(e);return isNaN(t)?e:t}(e):e}function U(e,t){let n;return async function(...r){const l=e(...r);n=l;const a=await l;return l!==n?a:(n=void 0,t(a,r))}}function N({get:e,set:n}){const r=t.ref(c(e()));return t.watch(e,(e=>{E(e,r.value)||(r.value=c(e))}),{deep:!0}),t.watch(r,(t=>{E(t,e())||n(c(t))}),{deep:!0}),r}function D(e){return Array.isArray(e)?e:e?[e]:[]}function $(e){const n=_(v),r=e?t.computed((()=>null==n?void 0:n.getPathState(t.toValue(e)))):void 0,l=e?void 0:t.inject(f);return!l&&(null==r||r.value),r||l}function q(e,t){const n={};for(const r in e)t.includes(r)||(n[r]=e[r]);return n}function z(e,t,n){return t.slots.default?"string"!=typeof e&&e?{default:()=>{var e,r;return null===(r=(e=t.slots).default)||void 0===r?void 0:r.call(e,n())}}:t.slots.default(n()):t.slots.default}function W(e){if(L(e))return e._value}function L(e){return"_value"in e}function K(e){if(!F(e))return e;const t=e.target;if(b(t.type)&&L(t))return W(t);if("file"===t.type&&t.files){const e=Array.from(t.files);return t.multiple?e:e[0]}if(O(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map(W);var n;if(O(t)){const e=Array.from(t.options).find((e=>e.selected));return e?W(e):t.value}return function(e){return"number"===e.type||"range"===e.type?Number.isNaN(e.valueAsNumber)?e.value:e.valueAsNumber:e.value}(t)}function G(e){const t={};return Object.defineProperty(t,"_$$isNormalized",{value:!0,writable:!1,enumerable:!1,configurable:!1}),e?l(e)&&e._$$isNormalized?e:l(e)?Object.keys(e).reduce(((t,n)=>{const r=function(e){if(!0===e)return[];if(Array.isArray(e))return e;if(l(e))return e;return[e]}(e[n]);return!1!==e[n]&&(t[n]=X(r)),t}),t):"string"!=typeof e?t:e.split("|").reduce(((e,t)=>{const n=H(t);return n.name?(e[n.name]=X(n.params),e):e}),t):t}function X(e){const t=e=>"string"==typeof e&&"@"===e[0]?function(e){const t=t=>I(t,e)||t[e];return t.__locatorRef=e,t}(e.slice(1)):e;return Array.isArray(e)?e.map(t):e instanceof RegExp?[e]:Object.keys(e).reduce(((n,r)=>(n[r]=t(e[r]),n)),{})}const H=e=>{let t=[];const n=e.split(":")[0];return e.includes(":")&&(t=e.split(":").slice(1).join(":").split(",")),{name:n,params:t}};let J=Object.assign({},{generateMessage:({field:e})=>`${e} is not valid.`,bails:!0,validateOnBlur:!0,validateOnChange:!0,validateOnInput:!1,validateOnModelUpdate:!0});const Q=()=>J,Y=e=>{J=Object.assign(Object.assign({},J),e)};async function Z(e,t,r={}){const l=null==r?void 0:r.bails,a={name:(null==r?void 0:r.name)||"{field}",rules:t,label:null==r?void 0:r.label,bails:null==l||l,formData:(null==r?void 0:r.values)||{}},u=await async function(e,t){if(y(e.rules)||g(e.rules))return async function(e,t){const n=y(t)?t:ee(t),r=await n.parse(e),l=[];for(const e of r.errors)e.errors.length&&l.push(...e.errors);return{errors:l}}(t,e.rules);if(n(e.rules)||Array.isArray(e.rules)){const n={field:e.label||e.name,name:e.name,label:e.label,form:e.formData,value:t},r=Array.isArray(e.rules)?e.rules:[e.rules],l=r.length,a=[];for(let u=0;u<l;u++){const l=r[u],i=await l(t,n);if(!("string"!=typeof i&&!Array.isArray(i)&&i)){if(Array.isArray(i))a.push(...i);else{const e="string"==typeof i?i:ne(n);a.push(e)}if(e.bails)return{errors:a}}}return{errors:a}}const r=Object.assign(Object.assign({},e),{rules:G(e.rules)}),l=[],a=Object.keys(r.rules),u=a.length;for(let n=0;n<u;n++){const u=a[n],i=await te(r,t,{name:u,params:r.rules[u]});if(i.error&&(l.push(i.error),e.bails))return{errors:l}}return{errors:l}}(a,e),i=u.errors;return{errors:i,valid:!i.length}}function ee(e){return{__type:"VVTypedSchema",async parse(t){var n;try{return{output:await e.validate(t,{abortEarly:!1}),errors:[]}}catch(e){if(!function(e){return!!e&&"ValidationError"===e.name}(e))throw e;if(!(null===(n=e.inner)||void 0===n?void 0:n.length)&&e.errors.length)return{errors:[{path:e.path,errors:e.errors}]};const t=e.inner.reduce(((e,t)=>{const n=t.path||"";return e[n]||(e[n]={errors:[],path:n}),e[n].errors.push(...t.errors),e}),{});return{errors:Object.values(t)}}}}}async function te(e,t,n){const r=(l=n.name,s[l]);var l;if(!r)throw new Error(`No such validator '${n.name}' exists.`);const a=function(e,t){const n=e=>h(e)?e(t):e;if(Array.isArray(e))return e.map(n);return Object.keys(e).reduce(((t,r)=>(t[r]=n(e[r]),t)),{})}(n.params,e.formData),u={field:e.label||e.name,name:e.name,label:e.label,value:t,form:e.formData,rule:Object.assign(Object.assign({},n),{params:a})},i=await r(t,a,u);return"string"==typeof i?{error:i}:{error:i?void 0:ne(u)}}function ne(e){const t=Q().generateMessage;return t?t(e):"Field is invalid"}async function re(e,t,n){const r=B(e).map((async r=>{var l,a,u;const i=null===(l=null==n?void 0:n.names)||void 0===l?void 0:l[r],o=await Z(I(t,r),e[r],{name:(null==i?void 0:i.name)||r,label:null==i?void 0:i.label,values:t,bails:null===(u=null===(a=null==n?void 0:n.bailsMap)||void 0===a?void 0:a[r])||void 0===u||u});return Object.assign(Object.assign({},o),{path:r})}));let l=!0;const a=await Promise.all(r),u={},i={};for(const e of a)u[e.path]={valid:e.valid,errors:e.errors},e.valid||(l=!1,i[e.path]=e.errors[0]);return{valid:l,results:u,errors:i}}let le=0;function ae(e,n){const{value:r,initialValue:l,setInitialValue:a}=function(e,n,r){const l=t.ref(t.unref(n));function a(){return r?I(r.initialValues.value,t.unref(e),t.unref(l)):t.unref(l)}function u(n){r?r.setFieldInitialValue(t.unref(e),n,!0):l.value=n}const i=t.computed(a);if(!r){return{value:t.ref(a()),initialValue:i,setInitialValue:u}}const o=function(e,n,r,l){if(t.isRef(e))return t.unref(e);if(void 0!==e)return e;return I(n.values,t.unref(l),t.unref(r))}(n,r,i,e);r.stageInitialValue(t.unref(e),o,!0);const s=t.computed({get:()=>I(r.values,t.unref(e)),set(n){r.setFieldValue(t.unref(e),n,!1)}});return{value:s,initialValue:i,setInitialValue:u}}(e,n.modelValue,n.form);if(!n.form){const{errors:o,setErrors:s}=function(){const e=t.ref([]);return{errors:e,setErrors:t=>{e.value=D(t)}}}(),d=le>=Number.MAX_SAFE_INTEGER?0:++le,c=function(e,n,r,l){var a,u;const i=null!==(u=null===(a=null==l?void 0:l.describe)||void 0===a?void 0:a.call(l).required)&&void 0!==u&&u,o=t.reactive({touched:!1,pending:!1,valid:!0,required:i,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=>{o.valid=!e.length}),{immediate:!0,flush:"sync"}),o}(r,l,o,n.schema);function v(e){var t;"value"in e&&(r.value=e.value),"errors"in e&&s(e.errors),"touched"in e&&(c.touched=null!==(t=e.touched)&&void 0!==t?t:c.touched),"initialValue"in e&&a(e.initialValue)}return{id:d,path:e,value:r,initialValue:l,meta:c,flags:{pendingUnmount:{[d]:!1},pendingReset:!1},errors:o,setState:v}}const u=n.form.createPathState(e,{bails:n.bails,label:n.label,type:n.type,validate:n.validate,schema:n.schema}),i=t.computed((()=>u.errors));return{id:Array.isArray(u.id)?u.id[u.id.length-1]:u.id,path:e,value:r,errors:i,meta:u,initialValue:l,flags:u.__flags,setState:function(l){var u,i,o;"value"in l&&(r.value=l.value),"errors"in l&&(null===(u=n.form)||void 0===u||u.setFieldError(t.unref(e),l.errors)),"touched"in l&&(null===(i=n.form)||void 0===i||i.setFieldTouched(t.unref(e),null!==(o=l.touched)&&void 0!==o&&o)),"initialValue"in l&&a(l.initialValue)}}}function ue(e,n,r){return b(null==r?void 0:r.type)?function(e,n,r){const l=(null==r?void 0:r.standalone)?void 0:_(v),a=null==r?void 0:r.checkedValue,u=null==r?void 0:r.uncheckedValue;function i(n){const i=n.handleChange,o=t.computed((()=>{const e=t.toValue(n.value),r=t.toValue(a);return Array.isArray(e)?e.findIndex((e=>E(e,r)))>=0:E(r,e)}));function s(s,d=!0){var c,v;if(o.value===(null===(c=null==s?void 0:s.target)||void 0===c?void 0:c.checked))return void(d&&n.validate());const f=t.toValue(e),p=null==l?void 0:l.getPathState(f),m=K(s);let h=null!==(v=t.toValue(a))&&void 0!==v?v:m;l&&(null==p?void 0:p.multiple)&&"checkbox"===p.type?h=P(I(l.values,f)||[],h,void 0):"checkbox"===(null==r?void 0:r.type)&&(h=P(t.toValue(n.value),h,t.toValue(u))),i(h,d)}return Object.assign(Object.assign({},n),{checked:o,checkedValue:a,uncheckedValue:u,handleChange:s})}return i(ie(e,n,r))}(e,n,r):ie(e,n,r)}function ie(e,r,l){const{initialValue:a,validateOnMount:u,bails:i,type:s,checkedValue:d,label:m,validateOnValueUpdate:b,uncheckedValue:V,controlled:O,keepValueOnUnmount:j,syncVModel:A,form:F}=function(e){const n=()=>({initialValue:void 0,validateOnMount:!1,bails:!0,label:void 0,validateOnValueUpdate:!0,keepValueOnUnmount:void 0,syncVModel:!1,controlled:!0}),r=!!(null==e?void 0:e.syncVModel),l="string"==typeof(null==e?void 0:e.syncVModel)?e.syncVModel:(null==e?void 0:e.modelPropName)||"modelValue",a=r&&!("initialValue"in(e||{}))?oe(t.getCurrentInstance(),l):null==e?void 0:e.initialValue;if(!e)return Object.assign(Object.assign({},n()),{initialValue:a});const u="valueProp"in e?e.valueProp:e.checkedValue,i="standalone"in e?!e.standalone:e.controlled,o=(null==e?void 0:e.modelPropName)||(null==e?void 0:e.syncVModel)||!1;return Object.assign(Object.assign(Object.assign({},n()),e||{}),{initialValue:a,controlled:null==i||i,checkedValue:u,syncVModel:o})}(l),S=O?_(v):void 0,k=F||S,w=t.computed((()=>o(t.toValue(e)))),M=t.computed((()=>{if(t.toValue(null==k?void 0:k.schema))return;const e=t.unref(r);return g(e)||y(e)||n(e)||Array.isArray(e)?e:G(e)})),{id:C,value:T,initialValue:P,meta:R,setState:N,errors:D,flags:$}=ae(w,{modelValue:a,form:k,bails:i,label:m,type:s,validate:M.value?X:void 0,schema:y(r)?r:void 0}),q=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 z(e){var n,r;if(null==k?void 0:k.validateSchema){const{results:r}=await k.validateSchema(e);return null!==(n=r[t.toValue(w)])&&void 0!==n?n:{valid:!0,errors:[]}}return M.value?Z(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 W=U((async()=>(R.pending=!0,R.validated=!0,z("validated-only"))),(e=>($.pendingUnmount[te.id]||(N({errors:e.errors}),R.pending=!1,R.valid=e.valid),e))),L=U((async()=>z("silent")),(e=>(R.valid=e.valid,e)));function X(e){return"silent"===(null==e?void 0:e.mode)?L():W()}function H(e,t=!0){Y(K(e),t)}function J(e){var t;const n=e&&"value"in e?e.value:P.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)||[]}),R.pending=!1,R.validated=!1,L()}t.onMounted((()=>{if(u)return W();k&&k.validateSchema||L()}));const Q=t.getCurrentInstance();function Y(e,t=!0){T.value=Q&&A?x(e,Q.props.modelModifiers):e;(t?W:L)()}const ee=t.computed({get:()=>T.value,set(e){Y(e,b)}}),te={id:C,name:w,label:m,value:ee,meta:R,errors:D,errorMessage:q,type:s,checkedValue:d,uncheckedValue:V,bails:i,keepValueOnUnmount:j,resetField:J,handleReset:()=>J(),validate:X,handleChange:H,handleBlur:(e,t=!1)=>{R.touched=!0,t&&W()},setState:N,setTouched:function(e){R.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)||(R.validated?W():L())}),{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):B(l).filter((e=>h(l[e]))).map((e=>l[e]))).map((e=>e.__locatorRef)).reduce(((e,t)=>{const n=I(k.values,t)||k.values[t];return void 0!==n&&(e[t]=n),e}),{});var l;return Object.assign(t,r),t}),{})}));return t.watch(ne,((e,t)=>{if(!Object.keys(e).length)return;!E(e,t)&&(R.validated?W():L())})),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({value:d,meta:g,errors:s,errorMessage:c,setErrors:O,setTouched:m,reset:h,validate:v,handleChange:f}),()=>{const n=t.resolveDynamicComponent(se(e,r)),l=z(n,r,k);return n?t.h(n,Object.assign(Object.assign({},r.attrs),S.value),l):l}}});let ve=0;const fe=["bails","fieldsCount","id","multiple","type","validate"];function pe(e){const r=Object.assign({},t.toValue((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=D(t),n.valid=!n.errors.length}else"string"==typeof e&&(h.value[o(e)]=D(t))}function j(e){B(e).forEach((t=>{O(t,e[t])}))}(null==e?void 0:e.initialErrors)&&j(e.initialErrors);const F=t.computed((()=>{const e=m.value.reduce(((e,t)=>(t.errors.length&&(e[t.path]=t.errors),e)),{});return Object.assign(Object.assign({},h.value),e)})),S=t.computed((()=>B(F.value).reduce(((e,t)=>{const n=F.value[t];return(null==n?void 0:n.length)&&(e[t]=n[0]),e}),{}))),k=t.computed((()=>m.value.reduce(((e,t)=>(e[t.path]={name:t.path||"",label:t.label||""},e)),{}))),w=t.computed((()=>m.value.reduce(((e,t)=>{var n;return e[t.path]=null===(n=t.bails)||void 0===n||n,e}),{}))),C=Object.assign({},(null==e?void 0:e.initialErrors)||{}),_=null!==(r=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==r&&r,{initialValues:P,originalInitialValues:x,setInitialValues:N}=function(e,n,r){const l=pe(r),a=t.ref(l),u=t.ref(c(l));function o(t,r=!1){a.value=i(c(a.value)||{},c(t)),u.value=i(c(u.value)||{},c(t)),r&&e.value.forEach((e=>{if(e.touched)return;const t=I(a.value,e.path);M(n,e.path,c(t))}))}return{initialValues:a,originalInitialValues:u,setInitialValues:o}}(m,p,e),$=function(e,n,r,l){const a={touched:"some",pending:"some",valid:"every"},u=t.computed((()=>!E(n,t.unref(r))));function i(){const t=e.value;return B(a).reduce(((e,n)=>{const r=a[n];return e[n]=t[r]((e=>e[n])),e}),{})}const o=t.reactive(i());return t.watchEffect((()=>{const e=i();o.touched=e.touched,o.valid=e.valid,o.pending=e.pending})),t.computed((()=>Object.assign(Object.assign({initialValues:t.unref(r)},o),{valid:o.valid&&!B(l.value).length,dirty:u.value})))}(m,p,x,S),z=t.computed((()=>m.value.reduce(((e,t)=>{const n=I(p,t.path);return M(e,t.path,n),e}),{}))),W=null==e?void 0:e.validationSchema;function L(e,n){var r,l;const u=t.computed((()=>I(P.value,t.toValue(e)))),i=b.value[t.toValue(e)],o="checkbox"===(null==n?void 0:n.type)||"radio"===(null==n?void 0:n.type);if(i&&o){i.multiple=!0;const e=a++;return Array.isArray(i.id)?i.id.push(e):i.id=[i.id,e],i.fieldsCount++,i.__flags.pendingUnmount[e]=!1,i}const s=t.computed((()=>I(p,t.toValue(e)))),d=t.toValue(e),v=te.findIndex((e=>e===d));-1!==v&&te.splice(v,1);const f=t.computed((()=>{var r,l,a,u,i,o;return y(W)?null!==(a=null===(l=(r=W).describe)||void 0===l?void 0:l.call(r,t.toValue(e)).required)&&void 0!==a&&a:!!y(null==n?void 0:n.schema)&&(null!==(o=null===(i=(u=null==n?void 0:n.schema).describe)||void 0===i?void 0:i.call(u).required)&&void 0!==o&&o)})),h=a++,g=t.reactive({id:h,path:e,touched:!1,pending:!1,valid:!0,validated:!!(null===(r=C[d])||void 0===r?void 0:r.length),required:f,initialValue:u,errors:t.shallowRef([]),bails:null!==(l=null==n?void 0:n.bails)&&void 0!==l&&l,label:null==n?void 0:n.label,type:(null==n?void 0:n.type)||"default",value:s,multiple:!1,__flags:{pendingUnmount:{[h]:!1},pendingReset:!1},fieldsCount:1,validate:null==n?void 0:n.validate,dirty:t.computed((()=>!E(t.unref(s),t.unref(u))))});return m.value.push(g),b.value[d]=g,V(),S.value[d]&&!C[d]&&t.nextTick((()=>{ye(d,{mode:"silent"})})),t.isRef(e)&&t.watch(e,(e=>{V();const n=c(s.value);b.value[e]=g,t.nextTick((()=>{M(p,e,n)}))})),g}const G=R(Ve,5),X=R(Ve,5),H=U((async e=>await("silent"===e?G():X())),((e,[n])=>{const r=B(ae.errorBag.value),l=[...new Set([...B(e.results),...m.value.map((e=>e.path)),...r])].sort().reduce(((r,l)=>{var a;const u=l,i=Y(u)||function(e){const t=m.value.filter((t=>e.startsWith(t.path)));return t.reduce(((e,t)=>e?t.path.length>e.path.length?t:e:t),void 0)}(u),o=(null===(a=e.results[u])||void 0===a?void 0:a.errors)||[],s=t.toValue(null==i?void 0:i.path)||u,d=function(e,t){if(!t)return e;return{valid:e.valid&&t.valid,errors:[...e.errors,...t.errors]}}({errors:o,valid:!o.length},r.results[s]);return r.results[s]=d,d.valid||(r.errors[s]=d.errors[0]),i&&h.value[s]&&delete h.value[s],i?(i.valid=d.valid,"silent"===n?r:"validated-only"!==n||i.validated?(O(i,d.errors),r):r):(O(s,o),r)}),{valid:e.valid,results:{},errors:{}});return e.values&&(l.values=e.values),l}));function J(e){m.value.forEach(e)}function Y(e){const t="string"==typeof e?o(e):e;return"string"==typeof t?b.value[t]:t}let Z,te=[];function ne(e){return function(t,n){return function(r){return r instanceof Event&&(r.preventDefault(),r.stopPropagation()),J((e=>e.touched=!0)),u.value=!0,d.value++,he().then((l=>{const a=c(p);if(l.valid&&"function"==typeof t){const n=c(z.value);let u=e?n:a;return l.values&&(u=l.values),t(u,{evt:r,controlledValues:n,setErrors:j,setFieldError:O,setTouched:de,setFieldTouched:se,setValues:ie,setFieldValue:ue,resetForm:me,resetField:ce})}l.valid||"function"!=typeof n||n({values:a,evt:r,errors:l.errors,results:l.results})})).then((e=>(u.value=!1,e)),(e=>{throw u.value=!1,e}))}}}const le=ne(!1);le.withControlled=ne(!0);const ae={formId:l,values:p,controlledValues:z,errorBag:F,errors:S,schema:W,submitCount:d,meta:$,isSubmitting:u,isValidating:s,fieldArrays:f,keepValuesOnUnmount:_,validateSchema:t.unref(W)?H:void 0,validate:he,setFieldError:O,validateField:ye,setFieldValue:ue,setValues:ie,setErrors:j,setFieldTouched:se,setTouched:de,resetForm:me,resetField:ce,handleSubmit:le,useFieldModel:function(e){if(!Array.isArray(e))return oe(e);return e.map((e=>oe(e,!0)))},defineInputBinds:function(e,n){const[r,l]=je(e,n);function a(e){l.value.onBlur(e)}function u(n){const r=K(n);ue(t.toValue(e),r,!1),l.value.onInput(n)}function i(n){const r=K(n);ue(t.toValue(e),r,!1),l.value.onChange(n)}return t.computed((()=>Object.assign(Object.assign({},l.value),{onBlur:a,onInput:u,onChange:i,value:r.value})))},defineComponentBinds:function(e,r){const[l,a]=je(e,r),u=Y(t.toValue(e));function i(e){l.value=e}return t.computed((()=>{const e=n(r)?r(q(u,fe)):r||{};return Object.assign({[e.model||"modelValue"]:l.value,[`onUpdate:${e.model||"modelValue"}`]:i},a.value)}))},defineField:je,stageInitialValue:function(t,n,r=!1){be(t,n),M(p,t,n),r&&!(null==e?void 0:e.initialValues)&&M(x.value,t,c(n))},unsetInitialValue:ge,setFieldInitialValue:be,createPathState:L,getPathState:Y,unsetPathValue:function(e){return te.push(e),Z||(Z=t.nextTick((()=>{[...te].sort().reverse().forEach((e=>{T(p,e)})),te=[],Z=null}))),Z},removePathState:function(e,n){const r=m.value.findIndex((t=>t.path===e)),l=m.value[r];if(-1!==r&&l){if(t.nextTick((()=>{ye(e,{mode:"silent",warn:!1})})),l.multiple&&l.fieldsCount&&l.fieldsCount--,Array.isArray(l.id)){const e=l.id.indexOf(n);e>=0&&l.id.splice(e,1),delete l.__flags.pendingUnmount[n]}(!l.multiple||l.fieldsCount<=0)&&(m.value.splice(r,1),ge(e),V(),delete b.value[e])}},initialValues:P,getAllPathStates:()=>m.value,destroyPath:function(e){B(b.value).forEach((t=>{t.startsWith(e)&&delete b.value[t]})),m.value=m.value.filter((t=>!t.path.startsWith(e))),t.nextTick((()=>{V()}))},isFieldTouched:function(e){const t=Y(e);if(t)return t.touched;return m.value.filter((t=>t.path.startsWith(e))).some((e=>e.touched))},isFieldDirty:function(e){const t=Y(e);if(t)return t.dirty;return m.value.filter((t=>t.path.startsWith(e))).some((e=>e.dirty))},isFieldValid:function(e){const t=Y(e);if(t)return t.valid;return m.value.filter((t=>t.path.startsWith(e))).every((e=>e.valid))}};function ue(e,t,n=!0){const r=c(t),l="string"==typeof e?e:e.path;Y(l)||L(l),M(p,l,r),n&&ye(l)}function ie(e,t=!0){i(p,e),f.forEach((e=>e&&e.reset())),t&&he()}function oe(e,n){const r=Y(t.toValue(e))||L(e);return t.computed({get:()=>r.value,set(r){var l;ue(t.toValue(e),r,null!==(l=t.toValue(n))&&void 0!==l&&l)}})}function se(e,t){const n=Y(e);n&&(n.touched=t)}function de(e){"boolean"!=typeof e?B(e).forEach((t=>{se(t,!!e[t])})):J((t=>{t.touched=e}))}function ce(e,n){var r;const l=n&&"value"in n?n.value:I(P.value,e),a=Y(e);a&&(a.__flags.pendingReset=!0),be(e,c(l),!0),ue(e,l,!1),se(e,null!==(r=null==n?void 0:n.touched)&&void 0!==r&&r),O(e,(null==n?void 0:n.errors)||[]),t.nextTick((()=>{a&&(a.__flags.pendingReset=!1)}))}function me(e,r){let l=c((null==e?void 0:e.values)?e.values:x.value);l=(null==r?void 0:r.force)?l:i(x.value,l),l=y(W)&&n(W.cast)?W.cast(l):l,N(l),J((t=>{var n;t.__flags.pendingReset=!0,t.validated=!1,t.touched=(null===(n=null==e?void 0:e.touched)||void 0===n?void 0:n[t.path])||!1,ue(t.path,I(l,t.path),!1),O(t.path,void 0)})),(null==r?void 0:r.force)?function(e,t=!0){B(p).forEach((e=>{delete p[e]})),B(e).forEach((t=>{ue(t,e[t],!1)})),t&&he()}(l,!1):ie(l,!1),j((null==e?void 0:e.errors)||{}),d.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{he({mode:"silent"}),J((e=>{e.__flags.pendingReset=!1}))}))}async function he(e){const t=(null==e?void 0:e.mode)||"force";if("force"===t&&J((e=>e.validated=!0)),ae.validateSchema)return ae.validateSchema(t);s.value=!0;const n=await Promise.all(m.value.map((t=>t.validate?t.validate(e).then((e=>({key:t.path,valid:e.valid,errors:e.errors}))):Promise.resolve({key:t.path,valid:!0,errors:[]}))));s.value=!1;const r={},l={};for(const e of n)r[e.key]={valid:e.valid,errors:e.errors},e.errors.length&&(l[e.key]=e.errors[0]);return{valid:n.every((e=>e.valid)),results:r,errors:l}}async function ye(e,t){const n=Y(e);if(n&&"silent"!==(null==t?void 0:t.mode)&&(n.validated=!0),W){const{results:n}=await H((null==t?void 0:t.mode)||"validated-only");return n[e]||{errors:[],valid:!0}}return(null==n?void 0:n.validate)?n.validate(t):(!n&&(null==t?void 0:t.warn),Promise.resolve({errors:[],valid:!0}))}function ge(e){T(P.value,e)}function be(e,t,n=!1){M(P.value,e,c(t)),n&&M(x.value,e,c(t))}async function Ve(){const e=t.unref(W);if(!e)return{valid:!0,results:{},errors:{}};s.value=!0;const n=g(e)||y(e)?await async function(e,t){const n=y(e)?e:ee(e),r=await n.parse(c(t)),l={},a={};for(const e of r.errors){const t=e.errors,n=(e.path||"").replace(/\["(\d+)"\]/g,((e,t)=>`[${t}]`));l[n]={valid:!t.length,errors:t},t.length&&(a[n]=t[0])}return{valid:!r.errors.length,results:l,errors:a,values:r.value}}(e,p):await re(e,p,{names:k.value,bailsMap:w.value});return s.value=!1,n}const Oe=le(((e,{evt:t})=>{A(t)&&t.target.submit()}));function je(e,r){const l=n(r)||null==r?void 0:r.label,a=Y(t.toValue(e))||L(e,{label:l}),u=()=>n(r)?r(q(a,fe)):r||{};function i(){var e;a.touched=!0;(null!==(e=u().validateOnBlur)&&void 0!==e?e:Q().validateOnBlur)&&ye(a.path)}function o(){var e;(null!==(e=u().validateOnInput)&&void 0!==e?e:Q().validateOnInput)&&t.nextTick((()=>{ye(a.path)}))}function s(){var e;(null!==(e=u().validateOnChange)&&void 0!==e?e:Q().validateOnChange)&&t.nextTick((()=>{ye(a.path)}))}const d=t.computed((()=>{const e={onChange:s,onInput:o,onBlur:i};return n(r)?Object.assign(Object.assign({},e),r(q(a,fe)).props||{}):(null==r?void 0:r.props)?Object.assign(Object.assign({},e),r.props(q(a,fe))):e})),c=oe(e,(()=>{var e,t,n;return null===(n=null!==(e=u().validateOnModelUpdate)&&void 0!==e?e:null===(t=Q())||void 0===t?void 0:t.validateOnModelUpdate)||void 0===n||n}));return[c,d]}return t.onMounted((()=>{(null==e?void 0:e.initialErrors)&&j(e.initialErrors),(null==e?void 0:e.initialTouched)&&de(e.initialTouched),(null==e?void 0:e.validateOnMount)?he():ae.validateSchema&&ae.validateSchema("silent")})),t.isRef(W)&&t.watch(W,(()=>{var e;null===(e=ae.validateSchema)||void 0===e||e.call(ae,"validated-only")})),t.provide(v,ae),Object.assign(Object.assign({},ae),{values:t.readonly(p),handleReset:()=>me(),submitForm:Oe})}const he=t.defineComponent({name:"Form",inheritAttrs:!1,props:{as:{type:null,default:"form"},validationSchema:{type:Object,default:void 0},initialValues:{type:Object,default:void 0},initialErrors:{type:Object,default:void 0},initialTouched:{type:Object,default:void 0},validateOnMount:{type:Boolean,default:!1},onSubmit:{type:Function,default:void 0},onInvalidSubmit:{type:Function,default:void 0},keepValues:{type:Boolean,default:!1}},setup(e,n){const r=t.toRef(e,"validationSchema"),l=t.toRef(e,"keepValues"),{errors:a,errorBag:u,values:i,meta:o,isSubmitting:s,isValidating:d,submitCount:v,controlledValues:f,validate:p,validateField:m,handleReset:h,resetForm:y,handleSubmit:g,setErrors:b,setFieldError:V,setFieldValue:O,setValues:j,setFieldTouched:S,setTouched:E,resetField:k}=me({validationSchema:r.value?r:void 0,initialValues:e.initialValues,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:l}),w=g(((e,{evt:t})=>{A(t)&&t.target.submit()}),e.onInvalidSubmit),I=e.onSubmit?g(e.onSubmit,e.onInvalidSubmit):w;function M(e){F(e)&&e.preventDefault(),h(),"function"==typeof n.attrs.onReset&&n.attrs.onReset()}function C(t,n){return g("function"!=typeof t||n?n:t,e.onInvalidSubmit)(t)}function T(){return c(i)}function B(){return c(o.value)}function _(){return c(a.value)}function P(){return{meta:o.value,errors:a.value,errorBag:u.value,values:i,isSubmitting:s.value,isValidating:d.value,submitCount:v.value,controlledValues:f.value,validate:p,validateField:m,handleSubmit:C,handleReset:h,submitForm:w,setErrors:b,setFieldError:V,setFieldValue:O,setValues:j,setFieldTouched:S,setTouched:E,resetForm:y,resetField:k,getValues:T,getMeta:B,getErrors:_}}return n.expose({setFieldError:V,setErrors:b,setFieldValue:O,setValues:j,setFieldTouched:S,setTouched:E,resetForm:y,validate:p,validateField:m,resetField:k,getValues:T,getMeta:B,getErrors:_,values:i,meta:o,errors:a}),function(){const r="form"===e.as?e.as:e.as?t.resolveDynamicComponent(e.as):null,l=z(r,n,P);if(!r)return l;const a="form"===r?{novalidate:!0}:{};return t.h(r,Object.assign(Object.assign(Object.assign({},a),n.attrs),{onSubmit:I,onReset:M}),l)}}}),ye=he;function ge(e){const n=_(v,void 0),l=t.ref([]),a=()=>{},u={fields:l,remove:a,push:a,swap:a,insert:a,update:a,replace:a,prepend:a,move:a};if(!n)return u;if(!t.unref(e))return u;const i=n.fieldArrays.find((n=>t.unref(n.path)===t.unref(e)));if(i)return i;let o=0;function s(){return I(null==n?void 0:n.values,t.toValue(e),[])||[]}function d(){const e=s();Array.isArray(e)&&(l.value=e.map(((e,t)=>p(e,t,l.value))),f())}function f(){const e=l.value.length;for(let t=0;t<e;t++){const n=l.value[t];n.isFirst=0===t,n.isLast=t===e-1}}function p(a,u,i){if(i&&!r(u)&&i[u])return i[u];const s=o++,d={key:s,value:N({get(){const r=I(null==n?void 0:n.values,t.toValue(e),[])||[],u=l.value.findIndex((e=>e.key===s));return-1===u?a:r[u]},set(e){const t=l.value.findIndex((e=>e.key===s));-1!==t&&h(t,e)}}),isFirst:!1,isLast:!1};return d}function m(){f(),null==n||n.validate({mode:"silent"})}function h(r,l){const a=t.toValue(e),u=I(null==n?void 0:n.values,a);!Array.isArray(u)||u.length-1<r||(M(n.values,`${a}[${r}]`,l),null==n||n.validate({mode:"validated-only"}))}d();const y={fields:l,remove:function(r){const a=t.toValue(e),u=I(null==n?void 0:n.values,a);if(!u||!Array.isArray(u))return;const i=[...u];i.splice(r,1);const o=a+`[${r}]`;n.destroyPath(o),n.unsetInitialValue(o),M(n.values,a,i),l.value.splice(r,1),m()},push:function(a){const u=c(a),i=t.toValue(e),o=I(null==n?void 0:n.values,i),s=r(o)?[]:o;if(!Array.isArray(s))return;const d=[...s];d.push(u),n.stageInitialValue(i+`[${d.length-1}]`,u),M(n.values,i,d),l.value.push(p(u)),m()},swap:function(r,a){const u=t.toValue(e),i=I(null==n?void 0:n.values,u);if(!Array.isArray(i)||!(r in i)||!(a in i))return;const o=[...i],s=[...l.value],d=o[r];o[r]=o[a],o[a]=d;const c=s[r];s[r]=s[a],s[a]=c,M(n.values,u,o),l.value=s,f()},insert:function(r,a){const u=c(a),i=t.toValue(e),o=I(null==n?void 0:n.values,i);if(!Array.isArray(o)||o.length<r)return;const s=[...o],d=[...l.value];s.splice(r,0,u),d.splice(r,0,p(u)),M(n.values,i,s),l.value=d,m()},update:h,replace:function(r){const l=t.toValue(e);n.stageInitialValue(l,r),M(n.values,l,r),d(),m()},prepend:function(a){const u=c(a),i=t.toValue(e),o=I(null==n?void 0:n.values,i),s=r(o)?[]:o;if(!Array.isArray(s))return;const d=[u,...s];M(n.values,i,d),n.stageInitialValue(i+"[0]",u),l.value.unshift(p(u)),m()},move:function(a,u){const i=t.toValue(e),o=I(null==n?void 0:n.values,i),s=r(o)?[]:[...o];if(!Array.isArray(o)||!(a in o)||!(u in o))return;const d=[...l.value],c=d[a];d.splice(a,1),d.splice(u,0,c);const v=s[a];s.splice(a,1),s.splice(u,0,v),M(n.values,i,s),l.value=d,m()}};return n.fieldArrays.push(Object.assign({path:e,reset:d},y)),t.onBeforeUnmount((()=>{const r=n.fieldArrays.findIndex((n=>t.toValue(n.path)===t.toValue(e)));r>=0&&n.fieldArrays.splice(r,1)})),t.watch(s,(e=>{E(e,l.value.map((e=>e.value)))||d()})),y}const be=t.defineComponent({name:"FieldArray",inheritAttrs:!1,props:{name:{type:String,required:!0}},setup(e,t){const{push:n,remove:r,swap:l,insert:a,replace:u,update:i,prepend:o,move:s,fields:d}=ge((()=>e.name));function c(){return{fields:d.value,push:n,remove:r,swap:l,insert:a,update:i,replace:u,prepend:o,move:s}}return t.expose({push:n,remove:r,swap:l,insert:a,update:i,replace:u,prepend:o,move:s}),()=>z(void 0,t,c)}}),Ve=t.defineComponent({name:"ErrorMessage",props:{as:{type:String,default:void 0},name:{type:String,required:!0}},setup(e,n){const r=t.inject(v,void 0),l=t.computed((()=>null==r?void 0:r.errors.value[e.name]));function a(){return{message:l.value}}return()=>{if(!l.value)return;const r=e.as?t.resolveDynamicComponent(e.as):e.as,u=z(r,n,a),i=Object.assign({role:"alert"},n.attrs);return r||!Array.isArray(u)&&u||!(null==u?void 0:u.length)?!Array.isArray(u)&&u||(null==u?void 0:u.length)?t.h(r,i,u):t.h(r||"span",i,l.value):u}}});e.ErrorMessage=Ve,e.Field=ce,e.FieldArray=be,e.FieldContextKey=f,e.Form=ye,e.FormContextKey=v,e.IS_ABSENT=p,e.cleanupNonNestedPath=w,e.configure=Y,e.defineRule=function(e,t){!function(e,t){if(n(t))return;throw new Error(`Extension Error: The validator '${e}' must be a function.`)}(e,t),s[e]=t},e.isNotNestedPath=V,e.normalizeRules=G,e.useField=ue,e.useFieldArray=ge,e.useFieldError=function(e){const n=_(v),r=e?void 0:t.inject(f);return t.computed((()=>e?null==n?void 0:n.errors.value[t.toValue(e)]:null==r?void 0:r.errorMessage.value))},e.useFieldValue=function(e){const n=_(v),r=e?void 0:t.inject(f);return t.computed((()=>e?I(null==n?void 0:n.values,t.toValue(e)):t.toValue(null==r?void 0:r.value)))},e.useForm=me,e.useFormErrors=function(){const e=_(v);return t.computed((()=>(null==e?void 0:e.errors.value)||{}))},e.useFormValues=function(){const e=_(v);return t.computed((()=>(null==e?void 0:e.values)||{}))},e.useIsFieldDirty=function(e){const n=$(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.dirty:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.dirty)&&void 0!==t&&t)}))},e.useIsFieldTouched=function(e){const n=$(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.touched:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.touched)&&void 0!==t&&t)}))},e.useIsFieldValid=function(e){const n=$(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.valid:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.valid)&&void 0!==t&&t)}))},e.useIsFormDirty=function(){const e=_(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.dirty)&&void 0!==t&&t}))},e.useIsFormTouched=function(){const e=_(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.touched)&&void 0!==t&&t}))},e.useIsFormValid=function(){const e=_(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.valid)&&void 0!==t&&t}))},e.useIsSubmitting=function(){const e=_(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isSubmitting.value)&&void 0!==t&&t}))},e.useIsValidating=function(){const e=_(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isValidating.value)&&void 0!==t&&t}))},e.useResetForm=function(){const e=_(v);return function(t){if(e)return e.resetForm(t)}},e.useSetFieldError=function(e){const n=_(v),r=e?void 0:t.inject(f);return function(l){e&&n?n.setFieldError(t.toValue(e),l):r&&r.setErrors(l||[])}},e.useSetFieldTouched=function(e){const n=_(v),r=e?void 0:t.inject(f);return function(l){e&&n?n.setFieldTouched(t.toValue(e),l):r&&r.setTouched(l)}},e.useSetFieldValue=function(e){const n=_(v),r=e?void 0:t.inject(f);return function(l,a=!0){e&&n?n.setFieldValue(t.toValue(e),l,a):r&&r.setValue(l,a)}},e.useSetFormErrors=function(){const e=_(v);return function(t){e&&e.setErrors(t)}},e.useSetFormTouched=function(){const e=_(v);return function(t){e&&e.setTouched(t)}},e.useSetFormValues=function(){const e=_(v);return function(t,n=!0){e&&e.setValues(t,n)}},e.useSubmitCount=function(){const e=_(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.submitCount.value)&&void 0!==t?t:0}))},e.useSubmitForm=function(e){const t=_(v),n=t?t.handleSubmit(e):void 0;return function(e){if(n)return n(e)}},e.useValidateField=function(e){const n=_(v),r=e?void 0:t.inject(f);return function(){return r?r.validate():n&&e?null==n?void 0:n.validateField(t.toValue(e)):Promise.resolve({errors:[],valid:!0})}},e.useValidateForm=function(){const e=_(v);return function(){return e?e.validate():Promise.resolve({results:{},errors:{},valid:!0})}},e.validate=Z,e.validateObject=re})); |
{ | ||
"name": "vee-validate", | ||
"version": "4.12.3", | ||
"version": "4.12.4", | ||
"description": "Painless forms 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
374862
8570