@volverjs/form-vue 1.1.0-beta.2 → 1.1.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1,3 +1,3 @@
1
- (function(U,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("vue"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","vue","@vueuse/core"],u):(U=typeof globalThis<"u"?globalThis:U||self,u(U["@volverjs/form-vue"]={},U.Vue,U.VueUseCore))})(this,function(U,u,Ve){"use strict";var E=(r=>(r.text="text",r.number="number",r.email="email",r.password="password",r.tel="tel",r.url="url",r.search="search",r.date="date",r.time="time",r.datetimeLocal="datetime-local",r.month="month",r.week="week",r.color="color",r.select="select",r.checkbox="checkbox",r.radio="radio",r.textarea="textarea",r.radioGroup="radioGroup",r.checkboxGroup="checkboxGroup",r.combobox="combobox",r.custom="custom",r))(E||{}),L=(r=>(r.invalid="invalid",r.valid="valid",r.submitting="submitting",r.reset="reset",r.updated="updated",r.unknown="unknown",r))(L||{}),V;(function(r){r.assertEqual=n=>{};function e(n){}r.assertIs=e;function t(n){throw new Error}r.assertNever=t,r.arrayToEnum=n=>{const a={};for(const i of n)a[i]=i;return a},r.getValidEnumValues=n=>{const a=r.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(const o of a)i[o]=n[o];return r.objectValues(i)},r.objectValues=n=>r.objectKeys(n).map(function(a){return n[a]}),r.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const a=[];for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&a.push(i);return a},r.find=(n,a)=>{for(const i of n)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=s,r.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(V||(V={}));var Ze;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Ze||(Ze={}));const g=V.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Y=r=>{switch(typeof r){case"undefined":return g.undefined;case"string":return g.string;case"number":return Number.isNaN(r)?g.nan:g.number;case"boolean":return g.boolean;case"function":return g.function;case"bigint":return g.bigint;case"symbol":return g.symbol;case"object":return Array.isArray(r)?g.array:r===null?g.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?g.promise:typeof Map<"u"&&r instanceof Map?g.map:typeof Set<"u"&&r instanceof Set?g.set:typeof Date<"u"&&r instanceof Date?g.date:g.object;default:return g.unknown}},m=V.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class W extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(a){return a.message},s={_errors:[]},n=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else{let o=s,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return n(this),s}static assert(e){if(!(e instanceof W))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,V.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const n of this.issues)if(n.path.length>0){const a=n.path[0];t[a]=t[a]||[],t[a].push(e(n))}else s.push(e(n));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}W.create=r=>new W(r);const Se=(r,e)=>{let t;switch(r.code){case m.invalid_type:r.received===g.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case m.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,V.jsonStringifyReplacer)}`;break;case m.unrecognized_keys:t=`Unrecognized key(s) in object: ${V.joinValues(r.keys,", ")}`;break;case m.invalid_union:t="Invalid input";break;case m.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${V.joinValues(r.options)}`;break;case m.invalid_enum_value:t=`Invalid enum value. Expected ${V.joinValues(r.options)}, received '${r.received}'`;break;case m.invalid_arguments:t="Invalid function arguments";break;case m.invalid_return_type:t="Invalid function return type";break;case m.invalid_date:t="Invalid date";break;case m.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:V.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case m.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case m.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case m.custom:t="Invalid input";break;case m.invalid_intersection_types:t="Intersection results could not be merged";break;case m.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case m.not_finite:t="Number must be finite";break;default:t=e.defaultError,V.assertNever(r)}return{message:t}};let mt=Se;function yt(){return mt}const vt=r=>{const{data:e,path:t,errorMaps:s,issueData:n}=r,a=[...t,...n.path||[]],i={...n,path:a};if(n.message!==void 0)return{...n,path:a,message:n.message};let o="";const c=s.filter(l=>!!l).slice().reverse();for(const l of c)o=l(i,{data:e,defaultError:o}).message;return{...n,path:a,message:o}};function v(r,e){const t=yt(),s=vt({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Se?void 0:Se].filter(n=>!!n)});r.common.issues.push(s)}class M{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const n of t){if(n.status==="aborted")return j;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const n of t){const a=await n.key,i=await n.value;s.push({key:a,value:i})}return M.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const n of t){const{key:a,value:i}=n;if(a.status==="aborted"||i.status==="aborted")return j;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||n.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}}const j=Object.freeze({status:"aborted"}),oe=r=>({status:"dirty",value:r}),F=r=>({status:"valid",value:r}),$e=r=>r.status==="aborted",Pe=r=>r.status==="dirty",re=r=>r.status==="valid",fe=r=>typeof Promise<"u"&&r instanceof Promise;var b;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(b||(b={}));class q{constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const De=(r,e)=>{if(re(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new W(r.common.issues);return this._error=t,this._error}}};function T(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:n}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(i,o)=>{const{message:c}=r;return i.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??s??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:c??t??o.defaultError}},description:n}}class N{get description(){return this._def.description}_getType(e){return Y(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Y(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new M,ctx:{common:e.parent.common,data:e.data,parsedType:Y(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(fe(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){const s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Y(e)},n=this._parseSync({data:e,path:s.path,parent:s});return De(s,n)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Y(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:t});return re(s)?{value:s.value}:{issues:t.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(s=>re(s)?{value:s.value}:{issues:t.common.issues})}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Y(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await(fe(n)?n:Promise.resolve(n));return De(s,a)}refine(e,t){const s=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{const i=e(n),o=()=>a.addIssue({code:m.custom,...s(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof t=="function"?t(s,n):t),!1))}_refinement(e){return new Q({schema:this,typeName:S.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return G.create(this,this._def)}nullable(){return X.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return B.create(this)}promise(){return ve.create(this,this._def)}or(e){return pe.create([this,e],this._def)}and(e){return me.create(this,e,this._def)}transform(e){return new Q({...T(this._def),schema:this,typeName:S.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ge({...T(this._def),innerType:this,defaultValue:t,typeName:S.ZodDefault})}brand(){return new Mt({typeName:S.ZodBranded,type:this,...T(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Ce({...T(this._def),innerType:this,catchValue:t,typeName:S.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ne.create(this,e)}readonly(){return Re.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const gt=/^c[^\s-]{8,}$/i,_t=/^[0-9a-z]+$/,bt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,xt=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,kt=/^[a-z0-9_-]{21}$/i,wt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ot=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,St=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,jt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let je;const Tt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ct=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Nt=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Rt=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,It=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Et=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ze="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",At=new RegExp(`^${ze}$`);function Me(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);const t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function Vt(r){return new RegExp(`^${Me(r)}$`)}function Zt(r){let e=`${ze}T${Me(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function $t(r,e){return!!((e==="v4"||!e)&&Tt.test(r)||(e==="v6"||!e)&&Nt.test(r))}function Pt(r,e){if(!wt.test(r))return!1;try{const[t]=r.split(".");if(!t)return!1;const s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),n=JSON.parse(atob(s));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function Dt(r,e){return!!((e==="v4"||!e)&&Ct.test(r)||(e==="v6"||!e)&&Rt.test(r))}class K extends N{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==g.string){const a=this._getOrReturnCtx(e);return v(a,{code:m.invalid_type,expected:g.string,received:a.parsedType}),j}const s=new M;let n;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),v(n,{code:m.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="max")e.data.length>a.value&&(n=this._getOrReturnCtx(e,n),v(n,{code:m.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(n=this._getOrReturnCtx(e,n),i?v(n,{code:m.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&v(n,{code:m.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty())}else if(a.kind==="email")St.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"email",code:m.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")je||(je=new RegExp(jt,"u")),je.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"emoji",code:m.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")xt.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"uuid",code:m.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")kt.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"nanoid",code:m.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")gt.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"cuid",code:m.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")_t.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"cuid2",code:m.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")bt.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"ulid",code:m.invalid_string,message:a.message}),s.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),v(n,{validation:"url",code:m.invalid_string,message:a.message}),s.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"regex",code:m.invalid_string,message:a.message}),s.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(e,n),v(n,{code:m.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),s.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(n=this._getOrReturnCtx(e,n),v(n,{code:m.invalid_string,validation:{startsWith:a.value},message:a.message}),s.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),v(n,{code:m.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?Zt(a).test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{code:m.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?At.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{code:m.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?Vt(a).test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{code:m.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?Ot.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"duration",code:m.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?$t(e.data,a.version)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"ip",code:m.invalid_string,message:a.message}),s.dirty()):a.kind==="jwt"?Pt(e.data,a.alg)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"jwt",code:m.invalid_string,message:a.message}),s.dirty()):a.kind==="cidr"?Dt(e.data,a.version)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"cidr",code:m.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?It.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"base64",code:m.invalid_string,message:a.message}),s.dirty()):a.kind==="base64url"?Et.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"base64url",code:m.invalid_string,message:a.message}),s.dirty()):V.assertNever(a);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:m.invalid_string,...b.errToObj(s)})}_addCheck(e){return new K({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...b.errToObj(e)})}url(e){return this._addCheck({kind:"url",...b.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...b.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...b.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...b.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...b.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...b.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...b.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...b.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...b.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...b.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...b.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...b.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...b.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...b.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...b.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...b.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...b.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...b.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...b.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...b.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...b.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...b.errToObj(t)})}nonempty(e){return this.min(1,b.errToObj(e))}trim(){return new K({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new K({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new K({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}K.create=r=>new K({checks:[],typeName:S.ZodString,coerce:r?.coerce??!1,...T(r)});function zt(r,e){const t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=t>s?t:s,a=Number.parseInt(r.toFixed(n).replace(".","")),i=Number.parseInt(e.toFixed(n).replace(".",""));return a%i/10**n}class ce extends N{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==g.number){const a=this._getOrReturnCtx(e);return v(a,{code:m.invalid_type,expected:g.number,received:a.parsedType}),j}let s;const n=new M;for(const a of this._def.checks)a.kind==="int"?V.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{code:m.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),v(s,{code:m.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),v(s,{code:m.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?zt(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),v(s,{code:m.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{code:m.not_finite,message:a.message}),n.dirty()):V.assertNever(a);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,b.toString(t))}gt(e,t){return this.setLimit("min",e,!1,b.toString(t))}lte(e,t){return this.setLimit("max",e,!0,b.toString(t))}lt(e,t){return this.setLimit("max",e,!1,b.toString(t))}setLimit(e,t,s,n){return new ce({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:b.toString(n)}]})}_addCheck(e){return new ce({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:b.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:b.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:b.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:b.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:b.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&V.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}ce.create=r=>new ce({checks:[],typeName:S.ZodNumber,coerce:r?.coerce||!1,...T(r)});class ue extends N{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==g.bigint)return this._getInvalidInput(e);let s;const n=new M;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),v(s,{code:m.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),v(s,{code:m.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),v(s,{code:m.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):V.assertNever(a);return{status:n.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return v(t,{code:m.invalid_type,expected:g.bigint,received:t.parsedType}),j}gte(e,t){return this.setLimit("min",e,!0,b.toString(t))}gt(e,t){return this.setLimit("min",e,!1,b.toString(t))}lte(e,t){return this.setLimit("max",e,!0,b.toString(t))}lt(e,t){return this.setLimit("max",e,!1,b.toString(t))}setLimit(e,t,s,n){return new ue({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:b.toString(n)}]})}_addCheck(e){return new ue({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:b.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ue.create=r=>new ue({checks:[],typeName:S.ZodBigInt,coerce:r?.coerce??!1,...T(r)});class Le extends N{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==g.boolean){const s=this._getOrReturnCtx(e);return v(s,{code:m.invalid_type,expected:g.boolean,received:s.parsedType}),j}return F(e.data)}}Le.create=r=>new Le({typeName:S.ZodBoolean,coerce:r?.coerce||!1,...T(r)});class he extends N{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==g.date){const a=this._getOrReturnCtx(e);return v(a,{code:m.invalid_type,expected:g.date,received:a.parsedType}),j}if(Number.isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return v(a,{code:m.invalid_date}),j}const s=new M;let n;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(n=this._getOrReturnCtx(e,n),v(n,{code:m.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),s.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(n=this._getOrReturnCtx(e,n),v(n,{code:m.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):V.assertNever(a);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new he({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:b.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:b.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}he.create=r=>new he({checks:[],coerce:r?.coerce||!1,typeName:S.ZodDate,...T(r)});class Ue extends N{_parse(e){if(this._getType(e)!==g.symbol){const s=this._getOrReturnCtx(e);return v(s,{code:m.invalid_type,expected:g.symbol,received:s.parsedType}),j}return F(e.data)}}Ue.create=r=>new Ue({typeName:S.ZodSymbol,...T(r)});class Fe extends N{_parse(e){if(this._getType(e)!==g.undefined){const s=this._getOrReturnCtx(e);return v(s,{code:m.invalid_type,expected:g.undefined,received:s.parsedType}),j}return F(e.data)}}Fe.create=r=>new Fe({typeName:S.ZodUndefined,...T(r)});class Be extends N{_parse(e){if(this._getType(e)!==g.null){const s=this._getOrReturnCtx(e);return v(s,{code:m.invalid_type,expected:g.null,received:s.parsedType}),j}return F(e.data)}}Be.create=r=>new Be({typeName:S.ZodNull,...T(r)});class Je extends N{constructor(){super(...arguments),this._any=!0}_parse(e){return F(e.data)}}Je.create=r=>new Je({typeName:S.ZodAny,...T(r)});class We extends N{constructor(){super(...arguments),this._unknown=!0}_parse(e){return F(e.data)}}We.create=r=>new We({typeName:S.ZodUnknown,...T(r)});class H extends N{_parse(e){const t=this._getOrReturnCtx(e);return v(t,{code:m.invalid_type,expected:g.never,received:t.parsedType}),j}}H.create=r=>new H({typeName:S.ZodNever,...T(r)});class qe extends N{_parse(e){if(this._getType(e)!==g.undefined){const s=this._getOrReturnCtx(e);return v(s,{code:m.invalid_type,expected:g.void,received:s.parsedType}),j}return F(e.data)}}qe.create=r=>new qe({typeName:S.ZodVoid,...T(r)});class B extends N{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==g.array)return v(t,{code:m.invalid_type,expected:g.array,received:t.parsedType}),j;if(n.exactLength!==null){const i=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(i||o)&&(v(t,{code:i?m.too_big:m.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(v(t,{code:m.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(v(t,{code:m.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>n.type._parseAsync(new q(t,i,t.path,o)))).then(i=>M.mergeArray(s,i));const a=[...t.data].map((i,o)=>n.type._parseSync(new q(t,i,t.path,o)));return M.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new B({...this._def,minLength:{value:e,message:b.toString(t)}})}max(e,t){return new B({...this._def,maxLength:{value:e,message:b.toString(t)}})}length(e,t){return new B({...this._def,exactLength:{value:e,message:b.toString(t)}})}nonempty(e){return this.min(1,e)}}B.create=(r,e)=>new B({type:r,minLength:null,maxLength:null,exactLength:null,typeName:S.ZodArray,...T(e)});function ne(r){if(r instanceof $){const e={};for(const t in r.shape){const s=r.shape[t];e[t]=G.create(ne(s))}return new $({...r._def,shape:()=>e})}else return r instanceof B?new B({...r._def,type:ne(r.element)}):r instanceof G?G.create(ne(r.unwrap())):r instanceof X?X.create(ne(r.unwrap())):r instanceof te?te.create(r.items.map(e=>ne(e))):r}class $ extends N{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=V.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==g.object){const l=this._getOrReturnCtx(e);return v(l,{code:m.invalid_type,expected:g.object,received:l.parsedType}),j}const{status:s,ctx:n}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof H&&this._def.unknownKeys==="strip"))for(const l in n.data)i.includes(l)||o.push(l);const c=[];for(const l of i){const f=a[l],h=n.data[l];c.push({key:{status:"valid",value:l},value:f._parse(new q(n,h,n.path,l)),alwaysSet:l in n.data})}if(this._def.catchall instanceof H){const l=this._def.unknownKeys;if(l==="passthrough")for(const f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:n.data[f]}});else if(l==="strict")o.length>0&&(v(n,{code:m.unrecognized_keys,keys:o}),s.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const f of o){const h=n.data[f];c.push({key:{status:"valid",value:f},value:l._parse(new q(n,h,n.path,f)),alwaysSet:f in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const l=[];for(const f of c){const h=await f.key,w=await f.value;l.push({key:h,value:w,alwaysSet:f.alwaysSet})}return l}).then(l=>M.mergeObjectSync(s,l)):M.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(e){return b.errToObj,new $({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{const n=this._def.errorMap?.(t,s).message??s.defaultError;return t.code==="unrecognized_keys"?{message:b.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new $({...this._def,unknownKeys:"strip"})}passthrough(){return new $({...this._def,unknownKeys:"passthrough"})}extend(e){return new $({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new $({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:S.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new $({...this._def,catchall:e})}pick(e){const t={};for(const s of V.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new $({...this._def,shape:()=>t})}omit(e){const t={};for(const s of V.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new $({...this._def,shape:()=>t})}deepPartial(){return ne(this)}partial(e){const t={};for(const s of V.objectKeys(this.shape)){const n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional()}return new $({...this._def,shape:()=>t})}required(e){const t={};for(const s of V.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof G;)a=a._def.innerType;t[s]=a}return new $({...this._def,shape:()=>t})}keyof(){return He(V.objectKeys(this.shape))}}$.create=(r,e)=>new $({shape:()=>r,unknownKeys:"strip",catchall:H.create(),typeName:S.ZodObject,...T(e)}),$.strictCreate=(r,e)=>new $({shape:()=>r,unknownKeys:"strict",catchall:H.create(),typeName:S.ZodObject,...T(e)}),$.lazycreate=(r,e)=>new $({shape:r,unknownKeys:"strip",catchall:H.create(),typeName:S.ZodObject,...T(e)});class pe extends N{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function n(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new W(o.ctx.common.issues));return v(t,{code:m.invalid_union,unionErrors:i}),j}if(t.common.async)return Promise.all(s.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(n);{let a;const i=[];for(const c of s){const l={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:l});if(f.status==="valid")return f;f.status==="dirty"&&!a&&(a={result:f,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new W(c));return v(t,{code:m.invalid_union,unionErrors:o}),j}}get options(){return this._def.options}}pe.create=(r,e)=>new pe({options:r,typeName:S.ZodUnion,...T(e)});function Te(r,e){const t=Y(r),s=Y(e);if(r===e)return{valid:!0,data:r};if(t===g.object&&s===g.object){const n=V.objectKeys(e),a=V.objectKeys(r).filter(o=>n.indexOf(o)!==-1),i={...r,...e};for(const o of a){const c=Te(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===g.array&&s===g.array){if(r.length!==e.length)return{valid:!1};const n=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],c=Te(i,o);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return t===g.date&&s===g.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class me extends N{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=(a,i)=>{if($e(a)||$e(i))return j;const o=Te(a.value,i.value);return o.valid?((Pe(a)||Pe(i))&&t.dirty(),{status:t.value,value:o.data}):(v(s,{code:m.invalid_intersection_types}),j)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}me.create=(r,e,t)=>new me({left:r,right:e,typeName:S.ZodIntersection,...T(t)});class te extends N{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==g.array)return v(s,{code:m.invalid_type,expected:g.array,received:s.parsedType}),j;if(s.data.length<this._def.items.length)return v(s,{code:m.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),j;!this._def.rest&&s.data.length>this._def.items.length&&(v(s,{code:m.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...s.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new q(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(a).then(i=>M.mergeArray(t,i)):M.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new te({...this._def,rest:e})}}te.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new te({items:r,typeName:S.ZodTuple,rest:null,...T(e)})};class ye extends N{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==g.object)return v(s,{code:m.invalid_type,expected:g.object,received:s.parsedType}),j;const n=[],a=this._def.keyType,i=this._def.valueType;for(const o in s.data)n.push({key:a._parse(new q(s,o,s.path,o)),value:i._parse(new q(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?M.mergeObjectAsync(t,n):M.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof N?new ye({keyType:e,valueType:t,typeName:S.ZodRecord,...T(s)}):new ye({keyType:K.create(),valueType:e,typeName:S.ZodRecord,...T(t)})}}class Ge extends N{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==g.map)return v(s,{code:m.invalid_type,expected:g.map,received:s.parsedType}),j;const n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,c],l)=>({key:n._parse(new q(s,o,s.path,[l,"key"])),value:a._parse(new q(s,c,s.path,[l,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const l=await c.key,f=await c.value;if(l.status==="aborted"||f.status==="aborted")return j;(l.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(l.value,f.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of i){const l=c.key,f=c.value;if(l.status==="aborted"||f.status==="aborted")return j;(l.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(l.value,f.value)}return{status:t.value,value:o}}}}Ge.create=(r,e,t)=>new Ge({valueType:e,keyType:r,typeName:S.ZodMap,...T(t)});class de extends N{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==g.set)return v(s,{code:m.invalid_type,expected:g.set,received:s.parsedType}),j;const n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(v(s,{code:m.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(v(s,{code:m.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const a=this._def.valueType;function i(c){const l=new Set;for(const f of c){if(f.status==="aborted")return j;f.status==="dirty"&&t.dirty(),l.add(f.value)}return{status:t.value,value:l}}const o=[...s.data.values()].map((c,l)=>a._parse(new q(s,c,s.path,l)));return s.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new de({...this._def,minSize:{value:e,message:b.toString(t)}})}max(e,t){return new de({...this._def,maxSize:{value:e,message:b.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}de.create=(r,e)=>new de({valueType:r,minSize:null,maxSize:null,typeName:S.ZodSet,...T(e)});class Ke extends N{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Ke.create=(r,e)=>new Ke({getter:r,typeName:S.ZodLazy,...T(e)});class Ye extends N{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return v(t,{received:t.data,code:m.invalid_literal,expected:this._def.value}),j}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ye.create=(r,e)=>new Ye({value:r,typeName:S.ZodLiteral,...T(e)});function He(r,e){return new se({values:r,typeName:S.ZodEnum,...T(e)})}class se extends N{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return v(t,{expected:V.joinValues(s),received:t.parsedType,code:m.invalid_type}),j}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return v(t,{received:t.data,code:m.invalid_enum_value,options:s}),j}return F(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return se.create(e,{...this._def,...t})}exclude(e,t=this._def){return se.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}}se.create=He;class Qe extends N{_parse(e){const t=V.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==g.string&&s.parsedType!==g.number){const n=V.objectValues(t);return v(s,{expected:V.joinValues(n),received:s.parsedType,code:m.invalid_type}),j}if(this._cache||(this._cache=new Set(V.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const n=V.objectValues(t);return v(s,{received:s.data,code:m.invalid_enum_value,options:n}),j}return F(e.data)}get enum(){return this._def.values}}Qe.create=(r,e)=>new Qe({values:r,typeName:S.ZodNativeEnum,...T(e)});class ve extends N{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.promise&&t.common.async===!1)return v(t,{code:m.invalid_type,expected:g.promise,received:t.parsedType}),j;const s=t.parsedType===g.promise?t.data:Promise.resolve(t.data);return F(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ve.create=(r,e)=>new ve({type:r,typeName:S.ZodPromise,...T(e)});class Q extends N{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===S.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{v(s,i),i.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){const i=n.transform(s.data,a);if(s.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return j;const c=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return c.status==="aborted"?j:c.status==="dirty"||t.value==="dirty"?oe(c.value):c});{if(t.value==="aborted")return j;const o=this._def.schema._parseSync({data:i,path:s.path,parent:s});return o.status==="aborted"?j:o.status==="dirty"||t.value==="dirty"?oe(o.value):o}}if(n.type==="refinement"){const i=o=>{const c=n.refinement(o,a);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?j:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?j:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!re(i))return j;const o=n.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>re(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):j);V.assertNever(n)}}Q.create=(r,e,t)=>new Q({schema:r,typeName:S.ZodEffects,effect:e,...T(t)}),Q.createWithPreprocess=(r,e,t)=>new Q({schema:e,effect:{type:"preprocess",transform:r},typeName:S.ZodEffects,...T(t)});class G extends N{_parse(e){return this._getType(e)===g.undefined?F(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}G.create=(r,e)=>new G({innerType:r,typeName:S.ZodOptional,...T(e)});class X extends N{_parse(e){return this._getType(e)===g.null?F(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}X.create=(r,e)=>new X({innerType:r,typeName:S.ZodNullable,...T(e)});class ge extends N{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===g.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ge.create=(r,e)=>new ge({innerType:r,typeName:S.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...T(e)});class Ce extends N{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return fe(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new W(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new W(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}Ce.create=(r,e)=>new Ce({innerType:r,typeName:S.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...T(e)});class Xe extends N{_parse(e){if(this._getType(e)!==g.nan){const s=this._getOrReturnCtx(e);return v(s,{code:m.invalid_type,expected:g.nan,received:s.parsedType}),j}return{status:"valid",value:e.data}}}Xe.create=r=>new Xe({typeName:S.ZodNaN,...T(r)});class Mt extends N{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ne extends N{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?j:a.status==="dirty"?(t.dirty(),oe(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})})();{const n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?j:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,t){return new Ne({in:e,out:t,typeName:S.ZodPipeline})}}class Re extends N{_parse(e){const t=this._def.innerType._parse(e),s=n=>(re(n)&&(n.value=Object.freeze(n.value)),n);return fe(t)?t.then(n=>s(n)):s(t)}unwrap(){return this._def.innerType}}Re.create=(r,e)=>new Re({innerType:r,typeName:S.ZodReadonly,...T(e)});var S;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(S||(S={})),K.create,H.create,B.create,pe.create,me.create,te.create,se.create,ve.create,G.create,X.create;function et(r,e,t){function s(o,c){var l;Object.defineProperty(o,"_zod",{value:o._zod??{},enumerable:!1}),(l=o._zod).traits??(l.traits=new Set),o._zod.traits.add(r),e(o,c);for(const f in i.prototype)f in o||Object.defineProperty(o,f,{value:i.prototype[f].bind(o)});o._zod.constr=i,o._zod.def=c}const n=t?.Parent??Object;class a extends n{}Object.defineProperty(a,"name",{value:r});function i(o){var c;const l=t?.Parent?new a:this;s(l,o),(c=l._zod).deferred??(c.deferred=[]);for(const f of l._zod.deferred)f();return l}return Object.defineProperty(i,"init",{value:s}),Object.defineProperty(i,Symbol.hasInstance,{value:o=>t?.Parent&&o instanceof t.Parent?!0:o?._zod?.traits?.has(r)}),Object.defineProperty(i,"name",{value:r}),i}class Lt extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const Ut={};function tt(r){return Ut}function Ft(r){const e=Object.values(r).filter(s=>typeof s=="number");return Object.entries(r).filter(([s,n])=>e.indexOf(+s)===-1).map(([s,n])=>n)}function Bt(r,e){return typeof e=="bigint"?e.toString():e}function _e(r){return typeof r=="string"?r:r?.message}function rt(r,e,t){const s={...r,path:r.path??[]};if(!r.message){const n=_e(r.inst?._zod.def?.error?.(r))??_e(e?.error?.(r))??_e(t.customError?.(r))??_e(t.localeError?.(r))??"Invalid input";s.message=n}return delete s.inst,delete s.continue,e?.reportInput||delete s.input,s}const nt=(r,e)=>{r.name="$ZodError",Object.defineProperty(r,"_zod",{value:r._zod,enumerable:!1}),Object.defineProperty(r,"issues",{value:e,enumerable:!1}),r.message=JSON.stringify(e,Bt,2),Object.defineProperty(r,"toString",{value:()=>r.message,enumerable:!1})},st=et("$ZodError",nt),at=et("$ZodError",nt,{Parent:Error});function it(r,e){const t=function(a){return a.message},s={_errors:[]},n=a=>{for(const i of a.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(o=>n({issues:o}));else if(i.code==="invalid_key")n({issues:i.issues});else if(i.code==="invalid_element")n({issues:i.issues});else if(i.path.length===0)s._errors.push(t(i));else{let o=s,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return n(r),s}const Jt=(r=>(e,t,s)=>{const n=s?{...s,async:!1}:{async:!1},a=e._zod.run({value:t,issues:[]},n);if(a instanceof Promise)throw new Lt;return a.issues.length?{success:!1,error:new(r??st)(a.issues.map(i=>rt(i,n,tt())))}:{success:!0,data:a.value}})(at),Wt=(r=>async(e,t,s)=>{const n=s?Object.assign(s,{async:!0}):{async:!0};let a=e._zod.run({value:t,issues:[]},n);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new r(a.issues.map(i=>rt(i,n,tt())))}:{success:!0,data:a.value}})(at);class ot{constructor(){this._map=new Map,this._idmap=new Map}add(e,...t){const s=t[0];if(this._map.set(e,s),s&&typeof s=="object"&&"id"in s){if(this._idmap.has(s.id))throw new Error(`ID ${s.id} already exists in the registry`);this._idmap.set(s.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const s={...this.get(t)??{}};delete s.id;const n={...s,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function qt(){return new ot}const Gt=qt();class ct{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??Gt,this.target=e?.target??"draft-2020-12",this.unrepresentable=e?.unrepresentable??"throw",this.override=e?.override??(()=>{}),this.io=e?.io??"output",this.seen=new Map}process(e,t={path:[],schemaPath:[]}){var s;const n=e._zod.def,a={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},i=this.seen.get(e);if(i)return i.count++,t.schemaPath.includes(e)&&(i.cycle=t.path),i.schema;const o={schema:{},count:1,cycle:void 0,path:t.path};this.seen.set(e,o);const c=e._zod.toJSONSchema?.();if(c)o.schema=c;else{const h={...t,schemaPath:[...t.schemaPath,e],path:t.path},w=e._zod.parent;if(w)o.ref=w,this.process(w,h),this.seen.get(w).isParent=!0;else{const x=o.schema;switch(n.type){case"string":{const d=x;d.type="string";const{minimum:p,maximum:y,format:k,patterns:C,contentEncoding:R}=e._zod.bag;if(typeof p=="number"&&(d.minLength=p),typeof y=="number"&&(d.maxLength=y),k&&(d.format=a[k]??k,d.format===""&&delete d.format),R&&(d.contentEncoding=R),C&&C.size>0){const P=[...C];P.length===1?d.pattern=P[0].source:P.length>1&&(o.schema.allOf=[...P.map(A=>({...this.target==="draft-7"?{type:"string"}:{},pattern:A.source}))])}break}case"number":{const d=x,{minimum:p,maximum:y,format:k,multipleOf:C,exclusiveMaximum:R,exclusiveMinimum:P}=e._zod.bag;typeof k=="string"&&k.includes("int")?d.type="integer":d.type="number",typeof P=="number"&&(d.exclusiveMinimum=P),typeof p=="number"&&(d.minimum=p,typeof P=="number"&&(P>=p?delete d.minimum:delete d.exclusiveMinimum)),typeof R=="number"&&(d.exclusiveMaximum=R),typeof y=="number"&&(d.maximum=y,typeof R=="number"&&(R<=y?delete d.maximum:delete d.exclusiveMaximum)),typeof C=="number"&&(d.multipleOf=C);break}case"boolean":{const d=x;d.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"null":{x.type="null";break}case"any":break;case"unknown":break;case"undefined":{if(this.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema");break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"never":{x.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{const d=x,{minimum:p,maximum:y}=e._zod.bag;typeof p=="number"&&(d.minItems=p),typeof y=="number"&&(d.maxItems=y),d.type="array",d.items=this.process(n.element,{...h,path:[...h.path,"items"]});break}case"object":{const d=x;d.type="object",d.properties={};const p=n.shape;for(const C in p)d.properties[C]=this.process(p[C],{...h,path:[...h.path,"properties",C]});const y=new Set(Object.keys(p)),k=new Set([...y].filter(C=>{const R=n.shape[C]._zod;return this.io==="input"?R.optin===void 0:R.optout===void 0}));k.size>0&&(d.required=Array.from(k)),n.catchall?._zod.def.type==="never"?d.additionalProperties=!1:n.catchall?n.catchall&&(d.additionalProperties=this.process(n.catchall,{...h,path:[...h.path,"additionalProperties"]})):this.io==="output"&&(d.additionalProperties=!1);break}case"union":{const d=x;d.anyOf=n.options.map((p,y)=>this.process(p,{...h,path:[...h.path,"anyOf",y]}));break}case"intersection":{const d=x,p=this.process(n.left,{...h,path:[...h.path,"allOf",0]}),y=this.process(n.right,{...h,path:[...h.path,"allOf",1]}),k=R=>"allOf"in R&&Object.keys(R).length===1,C=[...k(p)?p.allOf:[p],...k(y)?y.allOf:[y]];d.allOf=C;break}case"tuple":{const d=x;d.type="array";const p=n.items.map((C,R)=>this.process(C,{...h,path:[...h.path,"prefixItems",R]}));if(this.target==="draft-2020-12"?d.prefixItems=p:d.items=p,n.rest){const C=this.process(n.rest,{...h,path:[...h.path,"items"]});this.target==="draft-2020-12"?d.items=C:d.additionalItems=C}n.rest&&(d.items=this.process(n.rest,{...h,path:[...h.path,"items"]}));const{minimum:y,maximum:k}=e._zod.bag;typeof y=="number"&&(d.minItems=y),typeof k=="number"&&(d.maxItems=k);break}case"record":{const d=x;d.type="object",d.propertyNames=this.process(n.keyType,{...h,path:[...h.path,"propertyNames"]}),d.additionalProperties=this.process(n.valueType,{...h,path:[...h.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{const d=x,p=Ft(n.entries);p.every(y=>typeof y=="number")&&(d.type="number"),p.every(y=>typeof y=="string")&&(d.type="string"),d.enum=p;break}case"literal":{const d=x,p=[];for(const y of n.values)if(y===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof y=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");p.push(Number(y))}else p.push(y);if(p.length!==0)if(p.length===1){const y=p[0];d.type=y===null?"null":typeof y,d.const=y}else p.every(y=>typeof y=="number")&&(d.type="number"),p.every(y=>typeof y=="string")&&(d.type="string"),p.every(y=>typeof y=="boolean")&&(d.type="string"),p.every(y=>y===null)&&(d.type="null"),d.enum=p;break}case"file":{const d=x,p={type:"string",format:"binary",contentEncoding:"binary"},{minimum:y,maximum:k,mime:C}=e._zod.bag;y!==void 0&&(p.minLength=y),k!==void 0&&(p.maxLength=k),C?C.length===1?(p.contentMediaType=C[0],Object.assign(d,p)):d.anyOf=C.map(R=>({...p,contentMediaType:R})):Object.assign(d,p);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{const d=this.process(n.innerType,h);x.anyOf=[d,{type:"null"}];break}case"nonoptional":{this.process(n.innerType,h),o.ref=n.innerType;break}case"success":{const d=x;d.type="boolean";break}case"default":{this.process(n.innerType,h),o.ref=n.innerType,x.default=JSON.parse(JSON.stringify(n.defaultValue));break}case"prefault":{this.process(n.innerType,h),o.ref=n.innerType,this.io==="input"&&(x._prefault=JSON.parse(JSON.stringify(n.defaultValue)));break}case"catch":{this.process(n.innerType,h),o.ref=n.innerType;let d;try{d=n.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}x.default=d;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{const d=x,p=e._zod.pattern;if(!p)throw new Error("Pattern not found in template literal");d.type="string",d.pattern=p.source;break}case"pipe":{const d=this.io==="input"?n.in._zod.def.type==="transform"?n.out:n.in:n.out;this.process(d,h),o.ref=d;break}case"readonly":{this.process(n.innerType,h),o.ref=n.innerType,x.readOnly=!0;break}case"promise":{this.process(n.innerType,h),o.ref=n.innerType;break}case"optional":{this.process(n.innerType,h),o.ref=n.innerType;break}case"lazy":{const d=e._zod.innerType;this.process(d,h),o.ref=d;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}}}}const l=this.metadataRegistry.get(e);return l&&Object.assign(o.schema,l),this.io==="input"&&z(e)&&(delete o.schema.examples,delete o.schema.default),this.io==="input"&&o.schema._prefault&&((s=o.schema).default??(s.default=o.schema._prefault)),delete o.schema._prefault,this.seen.get(e).schema}emit(e,t){const s={cycles:t?.cycles??"ref",reused:t?.reused??"inline",external:t?.external??void 0},n=this.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const a=f=>{const h=this.target==="draft-2020-12"?"$defs":"definitions";if(s.external){const p=s.external.registry.get(f[0])?.id,y=s.external.uri??(C=>C);if(p)return{ref:y(p)};const k=f[1].defId??f[1].schema.id??`schema${this.counter++}`;return f[1].defId=k,{defId:k,ref:`${y("__shared")}#/${h}/${k}`}}if(f[1]===n)return{ref:"#"};const x=`#/${h}/`,d=f[1].schema.id??`__schema${this.counter++}`;return{defId:d,ref:x+d}},i=f=>{if(f[1].schema.$ref)return;const h=f[1],{ref:w,defId:x}=a(f);h.def={...h.schema},x&&(h.defId=x);const d=h.schema;for(const p in d)delete d[p];d.$ref=w};if(s.cycles==="throw")for(const f of this.seen.entries()){const h=f[1];if(h.cycle)throw new Error(`Cycle detected: #/${h.cycle?.join("/")}/<root>
1
+ (function(N,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vue"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","vue","@vueuse/core"],a):(N=typeof globalThis<"u"?globalThis:N||self,a(N["@volverjs/form-vue"]={},N.Vue,N.VueUseCore))})(this,function(N,a,q){"use strict";var S=(e=>(e.text="text",e.number="number",e.email="email",e.password="password",e.tel="tel",e.url="url",e.search="search",e.date="date",e.time="time",e.datetimeLocal="datetime-local",e.month="month",e.week="week",e.color="color",e.select="select",e.checkbox="checkbox",e.radio="radio",e.textarea="textarea",e.radioGroup="radioGroup",e.checkboxGroup="checkboxGroup",e.combobox="combobox",e.custom="custom",e))(S||{}),D=(e=>(e.invalid="invalid",e.valid="valid",e.submitting="submitting",e.reset="reset",e.updated="updated",e.unknown="unknown",e))(D||{}),z;(function(e){e.assertEqual=t=>{};function r(t){}e.assertIs=r;function n(t){throw new Error}e.assertNever=n,e.arrayToEnum=t=>{const i={};for(const s of t)i[s]=s;return i},e.getValidEnumValues=t=>{const i=e.objectKeys(t).filter(l=>typeof t[t[l]]!="number"),s={};for(const l of i)s[l]=t[l];return e.objectValues(s)},e.objectValues=t=>e.objectKeys(t).map(function(i){return t[i]}),e.objectKeys=typeof Object.keys=="function"?t=>Object.keys(t):t=>{const i=[];for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&i.push(s);return i},e.find=(t,i)=>{for(const s of t)if(i(s))return s},e.isInteger=typeof Number.isInteger=="function"?t=>Number.isInteger(t):t=>typeof t=="number"&&Number.isFinite(t)&&Math.floor(t)===t;function u(t,i=" | "){return t.map(s=>typeof s=="string"?`'${s}'`:s).join(i)}e.joinValues=u,e.jsonStringifyReplacer=(t,i)=>typeof i=="bigint"?i.toString():i})(z||(z={}));var H;(function(e){e.mergeShapes=(r,n)=>({...r,...n})})(H||(H={})),z.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),z.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class A extends Error{get errors(){return this.issues}constructor(r){super(),this.issues=[],this.addIssue=u=>{this.issues=[...this.issues,u]},this.addIssues=(u=[])=>{this.issues=[...this.issues,...u]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=r}format(r){const n=r||function(i){return i.message},u={_errors:[]},t=i=>{for(const s of i.issues)if(s.code==="invalid_union")s.unionErrors.map(t);else if(s.code==="invalid_return_type")t(s.returnTypeError);else if(s.code==="invalid_arguments")t(s.argumentsError);else if(s.path.length===0)u._errors.push(n(s));else{let l=u,d=0;for(;d<s.path.length;){const h=s.path[d];d===s.path.length-1?(l[h]=l[h]||{_errors:[]},l[h]._errors.push(n(s))):l[h]=l[h]||{_errors:[]},l=l[h],d++}}};return t(this),u}static assert(r){if(!(r instanceof A))throw new Error(`Not a ZodError: ${r}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,z.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(r=n=>n.message){const n={},u=[];for(const t of this.issues)if(t.path.length>0){const i=t.path[0];n[i]=n[i]||[],n[i].push(r(t))}else u.push(r(t));return{formErrors:u,fieldErrors:n}}get formErrors(){return this.flatten()}}A.create=e=>new A(e);function Q(e,r,n){function u(l,d){var h;Object.defineProperty(l,"_zod",{value:l._zod??{},enumerable:!1}),(h=l._zod).traits??(h.traits=new Set),l._zod.traits.add(e),r(l,d);for(const p in s.prototype)p in l||Object.defineProperty(l,p,{value:s.prototype[p].bind(l)});l._zod.constr=s,l._zod.def=d}const t=n?.Parent??Object;class i extends t{}Object.defineProperty(i,"name",{value:e});function s(l){var d;const h=n?.Parent?new i:this;u(h,l),(d=h._zod).deferred??(d.deferred=[]);for(const p of h._zod.deferred)p();return h}return Object.defineProperty(s,"init",{value:u}),Object.defineProperty(s,Symbol.hasInstance,{value:l=>n?.Parent&&l instanceof n.Parent?!0:l?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}class me extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const he={};function X(e){return he}function ye(e){const r=Object.values(e).filter(u=>typeof u=="number");return Object.entries(e).filter(([u,t])=>r.indexOf(+u)===-1).map(([u,t])=>t)}function ve(e,r){return typeof r=="bigint"?r.toString():r}function J(e){return typeof e=="string"?e:e?.message}function Y(e,r,n){const u={...e,path:e.path??[]};if(!e.message){const t=J(e.inst?._zod.def?.error?.(e))??J(r?.error?.(e))??J(n.customError?.(e))??J(n.localeError?.(e))??"Invalid input";u.message=t}return delete u.inst,delete u.continue,r?.reportInput||delete u.input,u}const ee=(e,r)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:r,enumerable:!1}),e.message=JSON.stringify(r,ve,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},te=Q("$ZodError",ee),re=Q("$ZodError",ee,{Parent:Error});function ne(e,r){const n=function(i){return i.message},u={_errors:[]},t=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(l=>t({issues:l}));else if(s.code==="invalid_key")t({issues:s.issues});else if(s.code==="invalid_element")t({issues:s.issues});else if(s.path.length===0)u._errors.push(n(s));else{let l=u,d=0;for(;d<s.path.length;){const h=s.path[d];d===s.path.length-1?(l[h]=l[h]||{_errors:[]},l[h]._errors.push(n(s))):l[h]=l[h]||{_errors:[]},l=l[h],d++}}};return t(e),u}const be=(e=>(r,n,u)=>{const t=u?{...u,async:!1}:{async:!1},i=r._zod.run({value:n,issues:[]},t);if(i instanceof Promise)throw new me;return i.issues.length?{success:!1,error:new(e??te)(i.issues.map(s=>Y(s,t,X())))}:{success:!0,data:i.value}})(re),ge=(e=>async(r,n,u)=>{const t=u?Object.assign(u,{async:!0}):{async:!0};let i=r._zod.run({value:n,issues:[]},t);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>Y(s,t,X())))}:{success:!0,data:i.value}})(re);class se{constructor(){this._map=new Map,this._idmap=new Map}add(r,...n){const u=n[0];if(this._map.set(r,u),u&&typeof u=="object"&&"id"in u){if(this._idmap.has(u.id))throw new Error(`ID ${u.id} already exists in the registry`);this._idmap.set(u.id,r)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(r){const n=this._map.get(r);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(r),this}get(r){const n=r._zod.parent;if(n){const u={...this.get(n)??{}};delete u.id;const t={...u,...this._map.get(r)};return Object.keys(t).length?t:void 0}return this._map.get(r)}has(r){return this._map.has(r)}}function we(){return new se}const Oe=we();class ae{constructor(r){this.counter=0,this.metadataRegistry=r?.metadata??Oe,this.target=r?.target??"draft-2020-12",this.unrepresentable=r?.unrepresentable??"throw",this.override=r?.override??(()=>{}),this.io=r?.io??"output",this.seen=new Map}process(r,n={path:[],schemaPath:[]}){var u;const t=r._zod.def,i={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},s=this.seen.get(r);if(s)return s.count++,n.schemaPath.includes(r)&&(s.cycle=n.path),s.schema;const l={schema:{},count:1,cycle:void 0,path:n.path};this.seen.set(r,l);const d=r._zod.toJSONSchema?.();if(d)l.schema=d;else{const f={...n,schemaPath:[...n.schemaPath,r],path:n.path},w=r._zod.parent;if(w)l.ref=w,this.process(w,f),this.seen.get(w).isParent=!0;else{const v=l.schema;switch(t.type){case"string":{const o=v;o.type="string";const{minimum:c,maximum:m,format:b,patterns:O,contentEncoding:j}=r._zod.bag;if(typeof c=="number"&&(o.minLength=c),typeof m=="number"&&(o.maxLength=m),b&&(o.format=i[b]??b,o.format===""&&delete o.format),j&&(o.contentEncoding=j),O&&O.size>0){const V=[...O];V.length===1?o.pattern=V[0].source:V.length>1&&(l.schema.allOf=[...V.map(k=>({...this.target==="draft-7"?{type:"string"}:{},pattern:k.source}))])}break}case"number":{const o=v,{minimum:c,maximum:m,format:b,multipleOf:O,exclusiveMaximum:j,exclusiveMinimum:V}=r._zod.bag;typeof b=="string"&&b.includes("int")?o.type="integer":o.type="number",typeof V=="number"&&(o.exclusiveMinimum=V),typeof c=="number"&&(o.minimum=c,typeof V=="number"&&(V>=c?delete o.minimum:delete o.exclusiveMinimum)),typeof j=="number"&&(o.exclusiveMaximum=j),typeof m=="number"&&(o.maximum=m,typeof j=="number"&&(j<=m?delete o.maximum:delete o.exclusiveMaximum)),typeof O=="number"&&(o.multipleOf=O);break}case"boolean":{const o=v;o.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"null":{v.type="null";break}case"any":break;case"unknown":break;case"undefined":{if(this.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema");break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"never":{v.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{const o=v,{minimum:c,maximum:m}=r._zod.bag;typeof c=="number"&&(o.minItems=c),typeof m=="number"&&(o.maxItems=m),o.type="array",o.items=this.process(t.element,{...f,path:[...f.path,"items"]});break}case"object":{const o=v;o.type="object",o.properties={};const c=t.shape;for(const O in c)o.properties[O]=this.process(c[O],{...f,path:[...f.path,"properties",O]});const m=new Set(Object.keys(c)),b=new Set([...m].filter(O=>{const j=t.shape[O]._zod;return this.io==="input"?j.optin===void 0:j.optout===void 0}));b.size>0&&(o.required=Array.from(b)),t.catchall?._zod.def.type==="never"?o.additionalProperties=!1:t.catchall?t.catchall&&(o.additionalProperties=this.process(t.catchall,{...f,path:[...f.path,"additionalProperties"]})):this.io==="output"&&(o.additionalProperties=!1);break}case"union":{const o=v;o.anyOf=t.options.map((c,m)=>this.process(c,{...f,path:[...f.path,"anyOf",m]}));break}case"intersection":{const o=v,c=this.process(t.left,{...f,path:[...f.path,"allOf",0]}),m=this.process(t.right,{...f,path:[...f.path,"allOf",1]}),b=j=>"allOf"in j&&Object.keys(j).length===1,O=[...b(c)?c.allOf:[c],...b(m)?m.allOf:[m]];o.allOf=O;break}case"tuple":{const o=v;o.type="array";const c=t.items.map((O,j)=>this.process(O,{...f,path:[...f.path,"prefixItems",j]}));if(this.target==="draft-2020-12"?o.prefixItems=c:o.items=c,t.rest){const O=this.process(t.rest,{...f,path:[...f.path,"items"]});this.target==="draft-2020-12"?o.items=O:o.additionalItems=O}t.rest&&(o.items=this.process(t.rest,{...f,path:[...f.path,"items"]}));const{minimum:m,maximum:b}=r._zod.bag;typeof m=="number"&&(o.minItems=m),typeof b=="number"&&(o.maxItems=b);break}case"record":{const o=v;o.type="object",o.propertyNames=this.process(t.keyType,{...f,path:[...f.path,"propertyNames"]}),o.additionalProperties=this.process(t.valueType,{...f,path:[...f.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{const o=v,c=ye(t.entries);c.every(m=>typeof m=="number")&&(o.type="number"),c.every(m=>typeof m=="string")&&(o.type="string"),o.enum=c;break}case"literal":{const o=v,c=[];for(const m of t.values)if(m===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof m=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");c.push(Number(m))}else c.push(m);if(c.length!==0)if(c.length===1){const m=c[0];o.type=m===null?"null":typeof m,o.const=m}else c.every(m=>typeof m=="number")&&(o.type="number"),c.every(m=>typeof m=="string")&&(o.type="string"),c.every(m=>typeof m=="boolean")&&(o.type="string"),c.every(m=>m===null)&&(o.type="null"),o.enum=c;break}case"file":{const o=v,c={type:"string",format:"binary",contentEncoding:"binary"},{minimum:m,maximum:b,mime:O}=r._zod.bag;m!==void 0&&(c.minLength=m),b!==void 0&&(c.maxLength=b),O?O.length===1?(c.contentMediaType=O[0],Object.assign(o,c)):o.anyOf=O.map(j=>({...c,contentMediaType:j})):Object.assign(o,c);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{const o=this.process(t.innerType,f);v.anyOf=[o,{type:"null"}];break}case"nonoptional":{this.process(t.innerType,f),l.ref=t.innerType;break}case"success":{const o=v;o.type="boolean";break}case"default":{this.process(t.innerType,f),l.ref=t.innerType,v.default=JSON.parse(JSON.stringify(t.defaultValue));break}case"prefault":{this.process(t.innerType,f),l.ref=t.innerType,this.io==="input"&&(v._prefault=JSON.parse(JSON.stringify(t.defaultValue)));break}case"catch":{this.process(t.innerType,f),l.ref=t.innerType;let o;try{o=t.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}v.default=o;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{const o=v,c=r._zod.pattern;if(!c)throw new Error("Pattern not found in template literal");o.type="string",o.pattern=c.source;break}case"pipe":{const o=this.io==="input"?t.in._zod.def.type==="transform"?t.out:t.in:t.out;this.process(o,f),l.ref=o;break}case"readonly":{this.process(t.innerType,f),l.ref=t.innerType,v.readOnly=!0;break}case"promise":{this.process(t.innerType,f),l.ref=t.innerType;break}case"optional":{this.process(t.innerType,f),l.ref=t.innerType;break}case"lazy":{const o=r._zod.innerType;this.process(o,f),l.ref=o;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}}}}const h=this.metadataRegistry.get(r);return h&&Object.assign(l.schema,h),this.io==="input"&&I(r)&&(delete l.schema.examples,delete l.schema.default),this.io==="input"&&l.schema._prefault&&((u=l.schema).default??(u.default=l.schema._prefault)),delete l.schema._prefault,this.seen.get(r).schema}emit(r,n){const u={cycles:n?.cycles??"ref",reused:n?.reused??"inline",external:n?.external??void 0},t=this.seen.get(r);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=p=>{const f=this.target==="draft-2020-12"?"$defs":"definitions";if(u.external){const c=u.external.registry.get(p[0])?.id,m=u.external.uri??(O=>O);if(c)return{ref:m(c)};const b=p[1].defId??p[1].schema.id??`schema${this.counter++}`;return p[1].defId=b,{defId:b,ref:`${m("__shared")}#/${f}/${b}`}}if(p[1]===t)return{ref:"#"};const v=`#/${f}/`,o=p[1].schema.id??`__schema${this.counter++}`;return{defId:o,ref:v+o}},s=p=>{if(p[1].schema.$ref)return;const f=p[1],{ref:w,defId:v}=i(p);f.def={...f.schema},v&&(f.defId=v);const o=f.schema;for(const c in o)delete o[c];o.$ref=w};if(u.cycles==="throw")for(const p of this.seen.entries()){const f=p[1];if(f.cycle)throw new Error(`Cycle detected: #/${f.cycle?.join("/")}/<root>
2
2
 
3
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const f of this.seen.entries()){const h=f[1];if(e===f[0]){i(f);continue}if(s.external){const x=s.external.registry.get(f[0])?.id;if(e!==f[0]&&x){i(f);continue}}if(this.metadataRegistry.get(f[0])?.id){i(f);continue}if(h.cycle){i(f);continue}if(h.count>1&&s.reused==="ref"){i(f);continue}}const o=(f,h)=>{const w=this.seen.get(f),x=w.def??w.schema,d={...x};if(w.ref===null)return;const p=w.ref;if(w.ref=null,p){o(p,h);const y=this.seen.get(p).schema;y.$ref&&h.target==="draft-7"?(x.allOf=x.allOf??[],x.allOf.push(y)):(Object.assign(x,y),Object.assign(x,d))}w.isParent||this.override({zodSchema:f,jsonSchema:x,path:w.path??[]})};for(const f of[...this.seen.entries()].reverse())o(f[0],{target:this.target});const c={};if(this.target==="draft-2020-12"?c.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?c.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),s.external?.uri){const f=s.external.registry.get(e)?.id;if(!f)throw new Error("Schema is missing an `id` property");c.$id=s.external.uri(f)}Object.assign(c,n.def);const l=s.external?.defs??{};for(const f of this.seen.entries()){const h=f[1];h.def&&h.defId&&(l[h.defId]=h.def)}s.external||Object.keys(l).length>0&&(this.target==="draft-2020-12"?c.$defs=l:c.definitions=l);try{return JSON.parse(JSON.stringify(c))}catch{throw new Error("Error converting schema to JSON.")}}}function Kt(r,e){if(r instanceof ot){const s=new ct(e),n={};for(const o of r._idmap.entries()){const[c,l]=o;s.process(l)}const a={},i={registry:r,uri:e?.uri,defs:n};for(const o of r._idmap.entries()){const[c,l]=o;a[c]=s.emit(l,{...e,external:i})}if(Object.keys(n).length>0){const o=s.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[o]:n}}return{schemas:a}}const t=new ct(e);return t.process(r),t.emit(r,e)}function z(r,e){const t=e??{seen:new Set};if(t.seen.has(r))return!1;t.seen.add(r);const n=r._zod.def;switch(n.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":return!1;case"array":return z(n.element,t);case"object":{for(const a in n.shape)if(z(n.shape[a],t))return!0;return!1}case"union":{for(const a of n.options)if(z(a,t))return!0;return!1}case"intersection":return z(n.left,t)||z(n.right,t);case"tuple":{for(const a of n.items)if(z(a,t))return!0;return!!(n.rest&&z(n.rest,t))}case"record":return z(n.keyType,t)||z(n.valueType,t);case"map":return z(n.keyType,t)||z(n.valueType,t);case"set":return z(n.valueType,t);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return z(n.innerType,t);case"lazy":return z(n.getter(),t);case"default":return z(n.innerType,t);case"prefault":return z(n.innerType,t);case"custom":return!1;case"transform":return!0;case"pipe":return z(n.in,t)||z(n.out,t);case"success":return!1;case"catch":return!1}throw new Error(`Unknown schema type: ${n.type}`)}const be=r=>{let e=r;for(;e instanceof Q;)e=e.innerType();return e instanceof G&&(e=e._def.innerType),e},Yt=r=>{let e=r;for(;e instanceof Q;)e=e.innerType();return e instanceof G||e instanceof X};function Ht(r){return Array.isArray(r)?"array":r===null?"null":typeof r}function Qt(r,e){const t=Ht(r);return e.type?e.type===t||e.type==="integer"&&t==="number"&&Number.isInteger(r):!0}function ae(r,e){if(r.anyOf&&Array.isArray(r.anyOf)){if(e!==void 0){for(const i of r.anyOf)if(Qt(e,i))return ae(i,e);for(const i of r.anyOf){const o=i;if(!o.type||o.type==="object")return ae(o,e)}}return ae(r.anyOf[0],e)}if(r.type!=="object"||!r.properties)switch(r.type){case"string":return typeof e=="string"?e:r.default;case"number":case"integer":return typeof e=="number"?e:r.default;case"boolean":return typeof e=="boolean"?e:r.default;case"null":return e===null?e:r.default;case"array":return Array.isArray(e)&&r.items?e.map(i=>ae(r.items,i)):r.default;default:return r.default}const t=r.properties,n=e&&typeof e=="object"&&!Array.isArray(e)?e:void 0,a={};for(const i in t){const o=n?.[i];a[i]=ae(t[i],o)}if(n&&r.additionalProperties!==!1){const i=new Set(Object.keys(t));for(const[o,c]of Object.entries(n))i.has(o)||(a[o]=c)}return a}const xe=r=>"_zod"in r;function le(r,e={}){if(xe(r)){const n=Kt(r);if(n.type!=="object"||!n.properties)return e;const a=Jt(r,e);return ae(n,a.success?a.data:e)}const t=be(r);return t instanceof $?{...(t instanceof $?t._def.unknownKeys==="passthrough":!1)?e:{},...Object.fromEntries(("shape"in t?Object.entries(t.shape):[]).map(([n,a])=>{const i=e[n],o=Yt(a);let c=be(a),l;if(c instanceof ge&&(l=c._def.defaultValue(),c=c._def.innerType),i===null&&c instanceof X)return[n,i];if(i==null&&o)return[n,l];if(c instanceof N){const f=a.safeParse(i);if(f.success)return[n,f.data??l]}if(c instanceof B&&Array.isArray(i)&&i.length){const f=be(c._def.type);if(f instanceof $)return[n,i.map(h=>le(f,h&&typeof h=="object"?h:void 0))]}if(c instanceof ye&&i){const f=be(c._def.valueType);if(f instanceof $)return[n,Object.keys(i).reduce((h,w)=>(h[w]=le(f,i[w]),h),{})]}return c instanceof $?[n,le(c,i&&typeof i=="object"?i:l)]:[n,l]}))}:e}const Xt=(r,e)=>xe(r)?Wt(r,e):r.safeParseAsync(e),er=(r,e)=>xe(r)?it(e):e.format(),tr=(r,e)=>xe(r)?it(new st(e)):new W(e).format();function rr(r,e,t,s,n){const a=u.ref(),i=u.ref(),o=u.computed(()=>i.value===L.invalid),c=u.ref(),l=u.ref(!1);let f;const h=A=>{const D=le(r,A);if(t?.class){const _=t.class;return new _(D)}return D},w=async(A=c.value,D)=>{if(f=D?.fields,l.value)return!0;const _=await Xt(r,A);if(!_.success){if(i.value=L.invalid,!f?.size)return a.value=er(r,_.error),!1;const Z=_.error.issues.filter(ee=>f?.has(ee.path.join(".")));return Z.length?(a.value=tr(r,Z),!1):(a.value=void 0,!0)}return a.value=void 0,i.value=L.valid,c.value=h(_.data),!0},x=()=>{a.value=void 0,i.value=void 0,f=void 0},d=()=>{c.value=h(),x(),i.value=L.reset},p=async A=>l.value||!await w(void 0,A)?!1:(i.value=L.submitting,!0),{ignoreUpdates:y,stop:k}=Ve.watchIgnorable(c,()=>{i.value=L.updated},{deep:!0,eventFilter:Ve.throttleFilter(t?.updateThrottle??500)}),C=u.readonly(a),R=u.readonly(i),P=u.defineComponent({name:"VvForm",props:{continuousValidation:{type:Boolean,default:!1},modelValue:{type:Object,default:()=>({})},readonly:{type:Boolean,default:t?.readonly},tag:{type:String,default:"form"},template:{type:[Array,Function],default:void 0},superRefine:{type:Function,default:void 0},validateFields:{type:Array,default:void 0}},emits:["invalid","submit","update:modelValue","update:readonly","valid","reset"],expose:["errors","invalid","readonly","status","submit","tag","template","valid","validate","clear","reset"],slots:Object,setup(A,{emit:D}){return c.value=h(u.toRaw(A.modelValue)),u.watch(()=>A.modelValue,_=>{if(_){const Z=u.isProxy(_)?u.toRaw(_):_;if(JSON.stringify(Z)===JSON.stringify(u.toRaw(c.value)))return;c.value=typeof Z?.clone=="function"?Z.clone():JSON.parse(JSON.stringify(Z))}},{deep:!0}),u.watch(i,async _=>{if(_===L.invalid){const Z=u.toRaw(a.value);D("invalid",Z),t?.onInvalid?.(Z);return}if(_===L.valid){const Z=u.toRaw(c.value);D("valid",Z),t?.onValid?.(Z),D("update:modelValue",Z),t?.onUpdate?.(Z);return}if(_===L.submitting){const Z=u.toRaw(c.value);D("submit",Z),t?.onSubmit?.(Z);return}if(_===L.reset){const Z=u.toRaw(c.value);D("reset",Z),t?.onReset?.(Z);return}if(_===L.updated){if((a.value||t?.continuousValidation||A.continuousValidation)&&await w(void 0,{superRefine:A.superRefine,fields:f??new Set(A.validateFields)}),!c.value||!A.modelValue||JSON.stringify(c.value)!==JSON.stringify(A.modelValue)){const Z=u.toRaw(c.value);D("update:modelValue",Z),t?.onUpdate?.(Z)}i.value===L.updated&&(i.value=L.unknown)}}),u.onMounted(()=>{A.readonly!==void 0&&(l.value=A.readonly)}),u.watch(()=>A.readonly,_=>{l.value=_}),u.watch(l,_=>{_!==A.readonly&&D("update:readonly",l.value)}),u.provide(e,{clear:x,errors:C,formData:c,ignoreUpdates:y,invalid:o,readonly:l,reset:d,status:R,stopUpdatesWatch:k,submit:p,validate:w,wrappers:n}),{clear:x,errors:C,formData:c,ignoreUpdates:y,invalid:o,isReadonly:l,reset:d,status:R,stopUpdatesWatch:k,submit:()=>p({superRefine:A.superRefine,fields:new Set(A.validateFields)}),validate:w,wrappers:n}},render(){const A=()=>this.$slots?.default?.({errors:C.value,formData:c.value,invalid:o.value,readonly:l.value,status:R.value,wrappers:n,clear:x,ignoreUpdates:y,reset:d,stopUpdatesWatch:k,submit:p,validate:w})??this.$slots.default;return u.h(this.tag,{onSubmit:u.withModifiers(this.submit,["prevent"]),onReset:u.withModifiers(this.reset,["prevent"])},(this.template??t?.template)&&s?[u.h(s,{schema:this.template??t?.template},{default:A})]:{default:A})}});return{clear:x,errors:a,formData:c,ignoreUpdates:y,invalid:o,readonly:l,reset:d,status:i,wrappers:n,stopUpdatesWatch:k,submit:p,validate:w,VvForm:P}}function Ie(r){return Array.isArray(r)}function nr(r){return!1}function ut(r){return r===null}function dt(r){return typeof r=="object"}function lt(r){return typeof r=="string"}function ke(r){return typeof r>"u"}const sr=/^[0-9]+$/,ar=["__proto__","prototype","constructor"];function ie(r,e,t){const s=nr()?t:void 0;if(!dt(r)||!lt(e))return s;const n=ft(e);if(n.length!==0){for(const a of n){if(a==="*")continue;const i=function(o){return o.map(c=>ke(c)||ut(c)?c:Ie(c)?i(c):c[a])};if(Ie(r)&&!sr.test(a)?r=i(r):r=r[a],ke(r)||ut(r))break}return ke(r)?s:r}}function Ee(r,e,t){if(!dt(r)||!lt(e))return;const s=ft(e);if(s.length===0)return;const n=s.length;for(let a=0;a<n;a++){const i=s[a];if(a===n-1){r[i]=t;return}if(i==="*"&&Ie(r)){const o=s.slice(a+1).join(".");for(const c of r)Ee(c,o,t);return}ke(r[i])&&(r[i]={}),r=r[i]}}function ft(r){const e=r.split(/[.]|(?:\[(\d|\*)\])/).filter(t=>!!t);return e.some(t=>ar.indexOf(t)!==-1)?[]:e}function ir(r,e,t,s){return u.defineComponent({name:"VvFormField",props:{type:{type:String,validator:n=>Object.values(E).includes(n),default:E.custom},is:{type:[Object,String],default:void 0},name:{type:[String,Number,Boolean,Symbol],required:!0},props:{type:[Object,Function],default:()=>({})},showValid:{type:Boolean,default:!1},defaultValue:{type:[String,Number,Boolean,Array,Object],default:void 0},lazyLoad:{type:Boolean,default:!1},readonly:{type:Boolean,default:void 0}},emits:["invalid","update:formData","update:modelValue","valid"],expose:["component","errors","hasProps","invalid","invalidLabel","is","type"],slots:Object,setup(n,{slots:a,emit:i}){const{props:o,name:c}=u.toRefs(n),l=u.useId(),f=u.inject(e,void 0);f&&f.fields.value.set(l,n.name);const h=u.inject(r),w=u.computed({get(){if(h?.formData)return ie(new Object(h.formData.value),String(n.name))},set(_){h?.formData&&(Ee(new Object(h.formData.value),String(n.name),_),i("update:modelValue",{newValue:w.value,formData:h?.formData}))}});u.onMounted(()=>{w.value===void 0&&n.defaultValue!==void 0&&(w.value=n.defaultValue)}),u.onBeforeUnmount(()=>{f&&f.fields.value.delete(l)});const x=u.computed(()=>{if(h?.errors.value)return ie(h.errors.value,String(n.name))}),d=u.computed(()=>x.value?._errors),p=u.computed(()=>x.value!==void 0),y=u.watch(p,_=>{if(_){i("invalid",x.value),f&&f.errors.value.set(String(n.name),x.value);return}i("valid",w.value),f&&f.errors.value.delete(n.name)}),k=u.watch(()=>h?.formData,()=>{i("update:formData",h?.formData)},{deep:!0});u.onBeforeUnmount(()=>{y(),k()});const C=_=>{_ instanceof InputEvent&&(_=_.target.value),w.value=_},R=u.computed(()=>{let _=o.value;return typeof _=="function"&&(_=_(h?.formData)),Object.keys(_).reduce((Z,ee)=>(Z[ee]=u.unref(_[ee]),Z),{})}),P=u.computed(()=>h?.readonly.value||f?.readonly.value?!0:R.value.readonly??n.readonly),A=u.computed(()=>({...R.value,name:R.value.name??n.name,invalid:p.value,valid:n.showValid?!!(!p.value&&w.value):void 0,type:(_=>{if([E.color,E.date,E.datetimeLocal,E.email,E.month,E.number,E.password,E.search,E.tel,E.text,E.time,E.url,E.week].includes(_))return _})(n.type),invalidLabel:d.value,modelValue:w.value,readonly:P.value,"onUpdate:modelValue":C}));return u.provide(t,{name:u.readonly(c),errors:u.readonly(x)}),{component:u.computed(()=>{if(n.type===E.custom)return{render(){return a.default?.({errors:x.value,formData:h?.formData.value,formErrors:h?.errors.value,invalid:p.value,invalidLabel:d.value,modelValue:w.value,readonly:P.value,onUpdate:C,submit:h?.submit,validate:h?.validate})??a.default}};if(!(s?.lazyLoad??n.lazyLoad)){let _;switch(n.type){case E.select:_=u.resolveComponent("VvSelect");break;case E.checkbox:_=u.resolveComponent("VvCheckbox");break;case E.radio:_=u.resolveComponent("VvRadio");break;case E.textarea:_=u.resolveComponent("VvTextarea");break;case E.radioGroup:_=u.resolveComponent("VvRadioGroup");break;case E.checkboxGroup:_=u.resolveComponent("VvCheckboxGroup");break;case E.combobox:_=u.resolveComponent("VvCombobox");break;default:_=u.resolveComponent("VvInputText")}if(typeof _!="string")return _;console.warn(`[@volverjs/form-vue]: ${_} not found, the component will be loaded asynchronously. To avoid this warning, please set "lazyLoad" option.`)}return u.defineAsyncComponent(async()=>{switch(s?.sideEffects&&await Promise.resolve(s.sideEffects(n.type)),n.type){case E.textarea:return import("@volverjs/ui-vue/vv-textarea");case E.radio:return import("@volverjs/ui-vue/vv-radio");case E.radioGroup:return import("@volverjs/ui-vue/vv-radio-group");case E.checkbox:return import("@volverjs/ui-vue/vv-checkbox");case E.checkboxGroup:return import("@volverjs/ui-vue/vv-checkbox-group");case E.select:return import("@volverjs/ui-vue/vv-select");case E.combobox:return import("@volverjs/ui-vue/vv-combobox")}return import("@volverjs/ui-vue/vv-input-text")})}),hasProps:A,invalid:p}},render(){return this.is?u.h(this.is,this.hasProps,this.$slots):this.type===E.custom?u.h(this.component,null,this.$slots):u.h(this.component,this.hasProps,this.$slots)}})}function or(r,e,t){return u.defineComponent({name:"VvFormFieldsGroup",props:{is:{type:[Object,String],default:void 0},names:{type:[Array,Object],required:!0},props:{type:[Object,Function],default:()=>({})},showValid:{type:Boolean,default:!1},defaultValues:{type:[Object],default:void 0},readonly:{type:Boolean,default:void 0}},emits:["invalid","update:formData","update:modelValue","valid"],expose:["component","errors","hasProps","invalid","invalidLabels","is"],slots:Object,setup(s,{slots:n,emit:a}){const{props:i,names:o,defaultValues:c}=u.toRefs(s),l=u.useId(),f=u.computed(()=>Array.isArray(o.value)?o.value:Object.values(o.value)),h=u.computed(()=>Array.isArray(o.value)?o.value:Object.keys(o.value)),w=u.computed(()=>Array.isArray(o.value)?o.value.reduce((O,I)=>(O[String(I)]=I,O),{}):o.value),x=u.computed(()=>Object.keys(w.value).reduce((O,I)=>(O[String(w.value[I])]=I,O),{})),d=u.inject(e,void 0);d&&f.value.forEach(O=>{d.fields.value.set(`${l}-${O}`,O)});const p=u.inject(r),y=u.computed({get(){return p?.formData?h.value.reduce((O,I)=>(O[I]=ie(new Object(p.formData.value),w.value[I]),O),{}):{}},set(O){p?.formData&&(h.value.forEach(I=>{Ee(new Object(p.formData.value),w.value[I],O?.[I])}),a("update:modelValue",{newValue:y.value,formData:p?.formData}))}});u.onMounted(()=>{c.value&&f.value.forEach(O=>{c.value?.[O]!==void 0&&y.value[O]===void 0&&(y.value={...y.value,[O]:c.value?.[O]})})}),u.onBeforeUnmount(()=>{d&&f.value.forEach(O=>{d.fields.value.delete(`${l}-${O}`)})});const k=u.computed(()=>{if(!p?.errors.value)return;const O=f.value.reduce((I,J)=>{if(!p.errors.value)return I;const pt=ie(p.errors.value,String(J));return pt===void 0||(I[String(J)]=pt),I},{});if(Object.keys(O).length!==0)return O}),C=u.computed(()=>{if(!k.value)return;const O=Object.keys(k.value).reduce((I,J)=>(k.value?.[J]&&(I[x.value[J]]=k.value[J]._errors),I),{});if(Object.keys(O).length!==0)return O}),R=u.computed(()=>k.value!==void 0),P=u.computed(()=>h.value.reduce((O,I)=>(O[I]=!!k.value?.[x.value[I]],O),{})),A=u.watch(R,()=>{if(R.value){a("invalid",k.value),d&&f.value.forEach(O=>{if(!k.value?.[O]){d.errors.value.delete(O);return}d.errors.value.set(O,k.value?.[O])});return}a("valid",y.value),d&&f.value.forEach(O=>{d.errors.value.delete(O)})}),D=u.watch(()=>p?.formData,()=>{a("update:formData",p?.formData)},{deep:!0});u.onBeforeUnmount(()=>{A(),D()});const _=O=>{y.value=O},Z=(O,I)=>{I instanceof InputEvent&&(I=I.target.value),h.value.includes(O)&&(y.value={...y.value,[O]:I})},ee=u.computed(()=>{let O=i.value;return typeof O=="function"&&(O=O(p?.formData)),Object.keys(O).reduce((I,J)=>(I[J]=u.unref(O[J]),I),{})}),ht=u.computed(()=>p?.readonly.value?!0:ee.value.readonly??s.readonly),hr=u.computed(()=>h.value.reduce((O,I)=>(O[`onUpdate:${I}`]=J=>{Z(I,J)},O),{"onUpdate:modelValue":_})),pr=u.computed(()=>({...hr.value,...ee.value,...y.value,modelValue:y.value,names:ee.value.name??f.value,invalid:R.value,invalids:P.value,valid:s.showValid?!!(!R.value&&y.value):void 0,invalidLabels:C.value,readonly:ht.value}));return u.provide(t,{names:u.readonly(o),errors:u.readonly(k)}),{component:u.computed(()=>({render(){return n.default?.({errors:k.value,formData:p?.formData.value,formErrors:p?.errors.value,invalid:R.value,invalids:P.value,invalidLabels:C.value,modelValue:y.value,onUpdate:_,onUpdateField:Z,readonly:ht.value,submit:p?.submit,validate:p?.validate})??n.default}})),hasProps:pr,invalid:R}},render(){return this.is?u.h(this.is,this.hasProps,this.$slots):u.h(this.component,null,this.$slots)}})}function cr(r,e){return u.defineComponent({name:"VvFormWrapper",props:{name:{type:String,required:!0},tag:{type:String,default:void 0},readonly:{type:Boolean,default:!1}},emits:["invalid","valid"],expose:["clear","errors","fields","fieldsErrors","formData","invalid","readonly","reset","submit","tag","validate","validateWrapper"],slots:Object,setup(t,{emit:s}){const n=u.inject(r),a=u.inject(e,void 0),i=u.ref(new Map),o=u.ref(new Map),{name:c}=u.toRefs(t),l=u.computed(()=>n?.invalid.value?o.value.size>0:!1);u.watch(l,d=>{if(d){s("invalid");return}s("valid")});const f=u.computed(()=>n?.readonly.value||t.readonly),h={name:u.readonly(c),errors:o,invalid:u.readonly(l),readonly:u.readonly(f),fields:i};u.provide(e,h);const w=u.computed(()=>new Map(i.value));u.watch(w,(d,p)=>{a?.fields&&(p.forEach((y,k)=>{d.has(k)||a?.fields.value.delete(k)}),d.forEach((y,k)=>{a?.fields.value.has(k)||a?.fields.value.set(k,y)}))},{deep:!0}),u.watch(o,d=>{a?.errors&&i.value.forEach(p=>{if(d.has(p)||a.errors.value.delete(p),d.has(p)){const y=d.get(p);y&&a.errors.value.set(p,y)}})},{deep:!0}),u.onMounted(()=>{if(!n?.wrappers||!c.value){console.warn("[@volverjs/form-vue]: Invalid wrapper registration state");return}if(n.wrappers.has(c.value)){console.warn(`[@volverjs/form-vue]: wrapper name "${c.value}" is already used`);return}n.wrappers.set(c.value,h)}),u.onBeforeUnmount(()=>{n?.wrappers&&c.value&&n.wrappers.delete(c.value)});const x=()=>n?.validate(void 0,{fields:new Set(i.value.values())})??Promise.resolve(!0);return{errors:n?.errors,fields:i,fieldsErrors:o,formData:n?.formData,invalid:l,readonly:f,clear:n?.clear,reset:n?.reset,submit:n?.submit,validate:n?.validate,validateWrapper:x}},render(){const t=()=>this.$slots.default?.({errors:this.errors,fieldsErrors:this.fieldsErrors,formData:this.formData,invalid:this.invalid,readonly:this.readonly,clear:this.clear,reset:this.reset,submit:this.submit,validate:this.validate,validateWrapper:this.validateWrapper});return this.tag?u.h(this.tag,null,{default:t}):t()}})}function ur(r,e){const t=u.defineComponent({name:"VvFormTemplate",props:{schema:{type:[Array,Function],required:!0},scope:{type:Object,default:()=>({})}},slots:Object,setup(s,{slots:n}){const a=u.inject(r);if(a?.formData)return()=>{const i=typeof s.schema=="function"?s.schema(a,s.scope):s.schema;let o;const c=i.reduce((l,f)=>{const h=typeof f=="function"?f(a,s.scope):f,{vvIs:w,vvName:x,vvSlots:d,vvChildren:p,vvIf:y,vvElseIf:k,vvType:C,vvDefaultValue:R,vvShowValid:P,vvContent:A,...D}=h;if(y!==void 0){if(typeof y=="string"?o=!!ie(new Object(a.formData.value),y):typeof y=="function"?o=u.unref(y(a)):o=u.unref(y),!o)return l}else if(k!==void 0&&o!==void 0){if(o||(typeof k=="string"?o=!!ie(new Object(a.formData.value),k):typeof k=="function"?o=u.unref(k(a)):o=u.unref(k),!o))return l}else o=void 0;let _;return p&&(typeof w=="string"?_=u.h(t,{schema:p}):_={default:Z=>u.h(t,{schema:p,scope:Z})}),x?(l.push(u.h(e,{name:x,is:w,type:C,defaultValue:R,showValid:P,props:D},d??_??A)),l):w?(l.push(u.h(w,D,d??_??A)),l):(_&&("default"in _?l.push(_.default(s.scope)):l.push(_)),l)},[]);return c.push(n?.default?.({errors:a?.errors.value,formData:a?.formData.value,invalid:a?.invalid.value,status:a?.status.value,submit:a?.submit,validate:a?.validate,clear:a?.clear,reset:a?.reset})),c}}});return t}function we(r,e={}){const t=Symbol("formInjectionKey"),s=Symbol("formWrapperInjectionKey"),n=Symbol("formFieldInjectionKey"),a=Symbol("formFieldsGroupInjectionKey"),i=cr(t,s),o=ir(t,s,n,e),c=or(t,s,a),l=ur(t,o),f=new Map,{clear:h,errors:w,formData:x,ignoreUpdates:d,invalid:p,readonly:y,reset:k,status:C,stopUpdatesWatch:R,submit:P,validate:A,VvForm:D}=rr(r,t,e,l,f);return{clear:h,errors:w,formData:x,formFieldInjectionKey:n,formInjectionKey:t,formWrapperInjectionKey:s,ignoreUpdates:d,invalid:p,readonly:y,reset:k,status:C,stopUpdatesWatch:R,submit:P,validate:A,wrappers:f,VvForm:D,VvFormField:o,VvFormFieldsGroup:c,VvFormTemplate:l,VvFormWrapper:i}}const Ae=Symbol("pluginInjectionKey");function dr(r){let e={};return r.schema&&(e=we(r.schema,r)),{...e,install(t,{global:s=!1}={}){t.provide(Ae,r),s&&(t.config.globalProperties.$vvForm=r,e?.VvForm&&t.component("VvForm",e.VvForm),e?.VvFormWrapper&&t.component("VvFormWrapper",e.VvFormWrapper),e?.VvFormField&&t.component("VvFormField",e.VvFormField),e?.VvFormFieldsGroup&&t.component("VvFormFieldsGroup",e.VvFormFieldsGroup),e?.VvFormTemplate&&t.component("VvFormTemplate",e.VvFormTemplate))}}}const Oe=new Map;function lr(r,e={}){if(e.scope&&Oe.has(e.scope))return Oe.get(e.scope);if(!u.getCurrentInstance()){const s=we(r,e);return e.scope&&Oe.set(e.scope,s),s}const t=we(r,{...u.inject(Ae,{}),...e});return e.scope&&Oe.set(e.scope,t),t}function fr(r,e={}){return we(r,e)}U.FormFieldType=E,U.createForm=dr,U.defaultObjectBySchema=le,U.formType=fr,U.pluginInjectionKey=Ae,U.useForm=lr,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})});
3
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const p of this.seen.entries()){const f=p[1];if(r===p[0]){s(p);continue}if(u.external){const v=u.external.registry.get(p[0])?.id;if(r!==p[0]&&v){s(p);continue}}if(this.metadataRegistry.get(p[0])?.id){s(p);continue}if(f.cycle){s(p);continue}if(f.count>1&&u.reused==="ref"){s(p);continue}}const l=(p,f)=>{const w=this.seen.get(p),v=w.def??w.schema,o={...v};if(w.ref===null)return;const c=w.ref;if(w.ref=null,c){l(c,f);const m=this.seen.get(c).schema;m.$ref&&f.target==="draft-7"?(v.allOf=v.allOf??[],v.allOf.push(m)):(Object.assign(v,m),Object.assign(v,o))}w.isParent||this.override({zodSchema:p,jsonSchema:v,path:w.path??[]})};for(const p of[...this.seen.entries()].reverse())l(p[0],{target:this.target});const d={};if(this.target==="draft-2020-12"?d.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?d.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),u.external?.uri){const p=u.external.registry.get(r)?.id;if(!p)throw new Error("Schema is missing an `id` property");d.$id=u.external.uri(p)}Object.assign(d,t.def);const h=u.external?.defs??{};for(const p of this.seen.entries()){const f=p[1];f.def&&f.defId&&(h[f.defId]=f.def)}u.external||Object.keys(h).length>0&&(this.target==="draft-2020-12"?d.$defs=h:d.definitions=h);try{return JSON.parse(JSON.stringify(d))}catch{throw new Error("Error converting schema to JSON.")}}}function je(e,r){if(e instanceof se){const u=new ae(r),t={};for(const l of e._idmap.entries()){const[d,h]=l;u.process(h)}const i={},s={registry:e,uri:r?.uri,defs:t};for(const l of e._idmap.entries()){const[d,h]=l;i[d]=u.emit(h,{...r,external:s})}if(Object.keys(t).length>0){const l=u.target==="draft-2020-12"?"$defs":"definitions";i.__shared={[l]:t}}return{schemas:i}}const n=new ae(r);return n.process(e),n.emit(e,r)}function I(e,r){const n=r??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const t=e._zod.def;switch(t.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":return!1;case"array":return I(t.element,n);case"object":{for(const i in t.shape)if(I(t.shape[i],n))return!0;return!1}case"union":{for(const i of t.options)if(I(i,n))return!0;return!1}case"intersection":return I(t.left,n)||I(t.right,n);case"tuple":{for(const i of t.items)if(I(i,n))return!0;return!!(t.rest&&I(t.rest,n))}case"record":return I(t.keyType,n)||I(t.valueType,n);case"map":return I(t.keyType,n)||I(t.valueType,n);case"set":return I(t.valueType,n);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return I(t.innerType,n);case"lazy":return I(t.getter(),n);case"default":return I(t.innerType,n);case"prefault":return I(t.innerType,n);case"custom":return!1;case"transform":return!0;case"pipe":return I(t.in,n)||I(t.out,n);case"success":return!1;case"catch":return!1}throw new Error(`Unknown schema type: ${t.type}`)}const M=e=>e._def.typeName==="ZodObject",_e=e=>e._def.typeName==="ZodDefault",Se=e=>e._def.typeName==="ZodNullable",ke=e=>e._def.typeName==="ZodRecord",Ee=e=>e._def.typeName==="ZodArray",oe=e=>e._def.typeName==="ZodEffects",ie=e=>e._def.typeName==="ZodOptional",C=e=>{let r=e;for(;oe(r);)r=r.innerType();return ie(r)&&(r=r._def.innerType),r},Ve=e=>{let r=e;for(;oe(r);)r=r.innerType();return!!ie(r)};function xe(e){return Array.isArray(e)?"array":e===null?"null":typeof e}function Ie(e,r){const n=xe(e);return r.type?r.type===n||r.type==="integer"&&n==="number"&&Number.isInteger(e):!0}function T(e,r){if(e.anyOf&&Array.isArray(e.anyOf)){if(r!==void 0){for(const s of e.anyOf)if(Ie(r,s))return T(s,r);for(const s of e.anyOf){const l=s;if(!l.type||l.type==="object")return T(l,r)}}return T(e.anyOf[0],r)}if(e.type!=="object"||!e.properties)switch(e.type){case"string":return typeof r=="string"?r:e.default;case"number":case"integer":return typeof r=="number"?r:e.default;case"boolean":return typeof r=="boolean"?r:e.default;case"null":return r===null?r:e.default;case"array":return Array.isArray(r)&&e.items?r.map(s=>T(e.items,s)):e.default;default:return e.default}const n=e.properties,t=r&&typeof r=="object"&&!Array.isArray(r)?r:void 0,i={};for(const s in n){const l=t?.[s];i[s]=T(n[s],l)}if(t&&e.additionalProperties!==!1){const s=new Set(Object.keys(n));for(const[l,d]of Object.entries(t))s.has(l)||(i[l]=d)}return i}const U=e=>"_zod"in e;function F(e,r={}){if(U(e)){const t=je(e);if(t.type!=="object"||!t.properties)return r;const i=be(e,r);return T(t,i.success?i.data:r)}const n=C(e);return M(n)?{...n._def.unknownKeys==="passthrough"?r:{},...Object.fromEntries(("shape"in n?Object.entries(n.shape):[]).map(([t,i])=>{const s=r[t],l=Ve(i);let d=C(i),h;if(_e(d)&&(h=d._def.defaultValue(),d=d._def.innerType),s===null&&Se(d))return[t,s];if(s==null&&l)return[t,h];if(d){const p=i.safeParse(s);if(p.success)return[t,p.data??h]}if(Ee(d)&&Array.isArray(s)&&s.length){const p=C(d._def.type);if(M(p))return[t,s.map(f=>F(p,f&&typeof f=="object"?f:void 0))]}if(ke(d)&&s){const p=C(d._def.valueType);if(M(p))return[t,Object.keys(s).reduce((f,w)=>(f[w]=F(p,s[w]),f),{})]}return M(d)?[t,F(d,s&&typeof s=="object"?s:h)]:[t,h]}))}:r}const De=(e,r)=>U(e)?ge(e,r):e.safeParseAsync(r),Ne=(e,r)=>U(e)?ne(r):r.format(),Pe=(e,r)=>U(e)?ne(new te(r)):new A(r).format();function Re(e,r,n,u,t){const i=a.ref(),s=a.ref(),l=a.computed(()=>s.value===D.invalid),d=a.ref(),h=a.ref(!1);let p;const f=k=>{const x=F(e,k);if(n?.class){const y=n.class;return new y(x)}return x},w=async(k=d.value,x)=>{if(p=x?.fields,h.value)return!0;const y=await De(e,k);if(!y.success){if(s.value=D.invalid,!p?.size)return i.value=Ne(e,y.error),!1;const E=y.error.issues.filter(R=>p?.has(R.path.join(".")));return E.length?(i.value=Pe(e,E),!1):(i.value=void 0,!0)}return i.value=void 0,s.value=D.valid,d.value=f(y.data),!0},v=()=>{i.value=void 0,s.value=void 0,p=void 0},o=()=>{d.value=f(),v(),s.value=D.reset},c=async k=>h.value||!await w(void 0,k)?!1:(s.value=D.submitting,!0),{ignoreUpdates:m,stop:b}=q.watchIgnorable(d,()=>{s.value=D.updated},{deep:!0,eventFilter:q.throttleFilter(n?.updateThrottle??500)}),O=a.readonly(i),j=a.readonly(s),V=a.defineComponent({name:"VvForm",props:{continuousValidation:{type:Boolean,default:!1},modelValue:{type:Object,default:()=>({})},readonly:{type:Boolean,default:n?.readonly},tag:{type:String,default:"form"},template:{type:[Array,Function],default:void 0},superRefine:{type:Function,default:void 0},validateFields:{type:Array,default:void 0}},emits:["invalid","submit","update:modelValue","update:readonly","valid","reset"],expose:["errors","invalid","readonly","status","submit","tag","template","valid","validate","clear","reset"],slots:Object,setup(k,{emit:x}){return d.value=f(a.toRaw(k.modelValue)),a.watch(()=>k.modelValue,y=>{if(y){const E=a.isProxy(y)?a.toRaw(y):y;if(JSON.stringify(E)===JSON.stringify(a.toRaw(d.value)))return;d.value=typeof E?.clone=="function"?E.clone():JSON.parse(JSON.stringify(E))}},{deep:!0}),a.watch(s,async y=>{if(y===D.invalid){const E=a.toRaw(i.value);x("invalid",E),n?.onInvalid?.(E);return}if(y===D.valid){const E=a.toRaw(d.value);x("valid",E),n?.onValid?.(E),x("update:modelValue",E),n?.onUpdate?.(E);return}if(y===D.submitting){const E=a.toRaw(d.value);x("submit",E),n?.onSubmit?.(E);return}if(y===D.reset){const E=a.toRaw(d.value);x("reset",E),n?.onReset?.(E);return}if(y===D.updated){if((i.value||n?.continuousValidation||k.continuousValidation)&&await w(void 0,{superRefine:k.superRefine,fields:p??new Set(k.validateFields)}),!d.value||!k.modelValue||JSON.stringify(d.value)!==JSON.stringify(k.modelValue)){const E=a.toRaw(d.value);x("update:modelValue",E),n?.onUpdate?.(E)}s.value===D.updated&&(s.value=D.unknown)}}),a.onMounted(()=>{k.readonly!==void 0&&(h.value=k.readonly)}),a.watch(()=>k.readonly,y=>{h.value=y}),a.watch(h,y=>{y!==k.readonly&&x("update:readonly",h.value)}),a.provide(r,{clear:v,errors:O,formData:d,ignoreUpdates:m,invalid:l,readonly:h,reset:o,status:j,stopUpdatesWatch:b,submit:c,validate:w,wrappers:t}),{clear:v,errors:O,formData:d,ignoreUpdates:m,invalid:l,isReadonly:h,reset:o,status:j,stopUpdatesWatch:b,submit:()=>c({superRefine:k.superRefine,fields:new Set(k.validateFields)}),validate:w,wrappers:t}},render(){const k=()=>this.$slots?.default?.({errors:O.value,formData:d.value,invalid:l.value,readonly:h.value,status:j.value,wrappers:t,clear:v,ignoreUpdates:m,reset:o,stopUpdatesWatch:b,submit:c,validate:w})??this.$slots.default;return a.h(this.tag,{onSubmit:a.withModifiers(this.submit,["prevent"]),onReset:a.withModifiers(this.reset,["prevent"])},(this.template??n?.template)&&u?[a.h(u,{schema:this.template??n?.template},{default:k})]:{default:k})}});return{clear:v,errors:i,formData:d,ignoreUpdates:m,invalid:l,readonly:h,reset:o,status:s,wrappers:t,stopUpdatesWatch:b,submit:c,validate:w,VvForm:V}}function K(e){return Array.isArray(e)}function Te(e){return!1}function le(e){return e===null}function ue(e){return typeof e=="object"}function ce(e){return typeof e=="string"}function Z(e){return typeof e>"u"}const $e=/^[0-9]+$/,ze=["__proto__","prototype","constructor"];function $(e,r,n){const u=Te()?n:void 0;if(!ue(e)||!ce(r))return u;const t=fe(r);if(t.length!==0){for(const i of t){if(i==="*")continue;const s=function(l){return l.map(d=>Z(d)||le(d)?d:K(d)?s(d):d[i])};if(K(e)&&!$e.test(i)?e=s(e):e=e[i],Z(e)||le(e))break}return Z(e)?u:e}}function L(e,r,n){if(!ue(e)||!ce(r))return;const u=fe(r);if(u.length===0)return;const t=u.length;for(let i=0;i<t;i++){const s=u[i];if(i===t-1){e[s]=n;return}if(s==="*"&&K(e)){const l=u.slice(i+1).join(".");for(const d of e)L(d,l,n);return}Z(e[s])&&(e[s]={}),e=e[s]}}function fe(e){const r=e.split(/[.]|(?:\[(\d|\*)\])/).filter(n=>!!n);return r.some(n=>ze.indexOf(n)!==-1)?[]:r}function Ae(e,r,n,u){return a.defineComponent({name:"VvFormField",props:{type:{type:String,validator:t=>Object.values(S).includes(t),default:S.custom},is:{type:[Object,String],default:void 0},name:{type:[String,Number,Boolean,Symbol],required:!0},props:{type:[Object,Function],default:()=>({})},showValid:{type:Boolean,default:!1},defaultValue:{type:[String,Number,Boolean,Array,Object],default:void 0},lazyLoad:{type:Boolean,default:!1},readonly:{type:Boolean,default:void 0}},emits:["invalid","update:formData","update:modelValue","valid"],expose:["component","errors","hasProps","invalid","invalidLabel","is","type"],slots:Object,setup(t,{slots:i,emit:s}){const{props:l,name:d}=a.toRefs(t),h=a.useId(),p=a.inject(r,void 0);p&&p.fields.value.set(h,t.name);const f=a.inject(e),w=a.computed({get(){if(f?.formData)return $(new Object(f.formData.value),String(t.name))},set(y){f?.formData&&(L(new Object(f.formData.value),String(t.name),y),s("update:modelValue",{newValue:w.value,formData:f?.formData}))}});a.onMounted(()=>{w.value===void 0&&t.defaultValue!==void 0&&(w.value=t.defaultValue)}),a.onBeforeUnmount(()=>{p&&p.fields.value.delete(h)});const v=a.computed(()=>{if(f?.errors.value)return $(f.errors.value,String(t.name))}),o=a.computed(()=>v.value?._errors),c=a.computed(()=>v.value!==void 0),m=a.watch(c,y=>{if(y){s("invalid",v.value),p&&p.errors.value.set(String(t.name),v.value);return}s("valid",w.value),p&&p.errors.value.delete(t.name)}),b=a.watch(()=>f?.formData,()=>{s("update:formData",f?.formData)},{deep:!0});a.onBeforeUnmount(()=>{m(),b()});const O=y=>{y instanceof InputEvent&&(y=y.target.value),w.value=y},j=a.computed(()=>{let y=l.value;return typeof y=="function"&&(y=y(f?.formData)),Object.keys(y).reduce((E,R)=>(E[R]=a.unref(y[R]),E),{})}),V=a.computed(()=>f?.readonly.value||p?.readonly.value?!0:j.value.readonly??t.readonly),k=a.computed(()=>({...j.value,name:j.value.name??t.name,invalid:c.value,valid:t.showValid?!!(!c.value&&w.value):void 0,type:(y=>{if([S.color,S.date,S.datetimeLocal,S.email,S.month,S.number,S.password,S.search,S.tel,S.text,S.time,S.url,S.week].includes(y))return y})(t.type),invalidLabel:o.value,modelValue:w.value,readonly:V.value,"onUpdate:modelValue":O}));return a.provide(n,{name:a.readonly(d),errors:a.readonly(v)}),{component:a.computed(()=>{if(t.type===S.custom)return{render(){return i.default?.({errors:v.value,formData:f?.formData.value,formErrors:f?.errors.value,invalid:c.value,invalidLabel:o.value,modelValue:w.value,readonly:V.value,onUpdate:O,submit:f?.submit,validate:f?.validate})??i.default}};if(!(u?.lazyLoad??t.lazyLoad)){let y;switch(t.type){case S.select:y=a.resolveComponent("VvSelect");break;case S.checkbox:y=a.resolveComponent("VvCheckbox");break;case S.radio:y=a.resolveComponent("VvRadio");break;case S.textarea:y=a.resolveComponent("VvTextarea");break;case S.radioGroup:y=a.resolveComponent("VvRadioGroup");break;case S.checkboxGroup:y=a.resolveComponent("VvCheckboxGroup");break;case S.combobox:y=a.resolveComponent("VvCombobox");break;default:y=a.resolveComponent("VvInputText")}if(typeof y!="string")return y;console.warn(`[@volverjs/form-vue]: ${y} not found, the component will be loaded asynchronously. To avoid this warning, please set "lazyLoad" option.`)}return a.defineAsyncComponent(async()=>{switch(u?.sideEffects&&await Promise.resolve(u.sideEffects(t.type)),t.type){case S.textarea:return import("@volverjs/ui-vue/vv-textarea");case S.radio:return import("@volverjs/ui-vue/vv-radio");case S.radioGroup:return import("@volverjs/ui-vue/vv-radio-group");case S.checkbox:return import("@volverjs/ui-vue/vv-checkbox");case S.checkboxGroup:return import("@volverjs/ui-vue/vv-checkbox-group");case S.select:return import("@volverjs/ui-vue/vv-select");case S.combobox:return import("@volverjs/ui-vue/vv-combobox")}return import("@volverjs/ui-vue/vv-input-text")})}),hasProps:k,invalid:c}},render(){return this.is?a.h(this.is,this.hasProps,this.$slots):this.type===S.custom?a.h(this.component,null,this.$slots):a.h(this.component,this.hasProps,this.$slots)}})}function Fe(e,r,n){return a.defineComponent({name:"VvFormFieldsGroup",props:{is:{type:[Object,String],default:void 0},names:{type:[Array,Object],required:!0},props:{type:[Object,Function],default:()=>({})},showValid:{type:Boolean,default:!1},defaultValues:{type:[Object],default:void 0},readonly:{type:Boolean,default:void 0}},emits:["invalid","update:formData","update:modelValue","valid"],expose:["component","errors","hasProps","invalid","invalidLabels","is"],slots:Object,setup(u,{slots:t,emit:i}){const{props:s,names:l,defaultValues:d}=a.toRefs(u),h=a.useId(),p=a.computed(()=>Array.isArray(l.value)?l.value:Object.values(l.value)),f=a.computed(()=>Array.isArray(l.value)?l.value:Object.keys(l.value)),w=a.computed(()=>Array.isArray(l.value)?l.value.reduce((g,_)=>(g[String(_)]=_,g),{}):l.value),v=a.computed(()=>Object.keys(w.value).reduce((g,_)=>(g[String(w.value[_])]=_,g),{})),o=a.inject(r,void 0);o&&p.value.forEach(g=>{o.fields.value.set(`${h}-${g}`,g)});const c=a.inject(e),m=a.computed({get(){return c?.formData?f.value.reduce((g,_)=>(g[_]=$(new Object(c.formData.value),w.value[_]),g),{}):{}},set(g){c?.formData&&(f.value.forEach(_=>{L(new Object(c.formData.value),w.value[_],g?.[_])}),i("update:modelValue",{newValue:m.value,formData:c?.formData}))}});a.onMounted(()=>{d.value&&p.value.forEach(g=>{d.value?.[g]!==void 0&&m.value[g]===void 0&&(m.value={...m.value,[g]:d.value?.[g]})})}),a.onBeforeUnmount(()=>{o&&p.value.forEach(g=>{o.fields.value.delete(`${h}-${g}`)})});const b=a.computed(()=>{if(!c?.errors.value)return;const g=p.value.reduce((_,P)=>{if(!c.errors.value)return _;const pe=$(c.errors.value,String(P));return pe===void 0||(_[String(P)]=pe),_},{});if(Object.keys(g).length!==0)return g}),O=a.computed(()=>{if(!b.value)return;const g=Object.keys(b.value).reduce((_,P)=>(b.value?.[P]&&(_[v.value[P]]=b.value[P]._errors),_),{});if(Object.keys(g).length!==0)return g}),j=a.computed(()=>b.value!==void 0),V=a.computed(()=>f.value.reduce((g,_)=>(g[_]=!!b.value?.[v.value[_]],g),{})),k=a.watch(j,()=>{if(j.value){i("invalid",b.value),o&&p.value.forEach(g=>{if(!b.value?.[g]){o.errors.value.delete(g);return}o.errors.value.set(g,b.value?.[g])});return}i("valid",m.value),o&&p.value.forEach(g=>{o.errors.value.delete(g)})}),x=a.watch(()=>c?.formData,()=>{i("update:formData",c?.formData)},{deep:!0});a.onBeforeUnmount(()=>{k(),x()});const y=g=>{m.value=g},E=(g,_)=>{_ instanceof InputEvent&&(_=_.target.value),f.value.includes(g)&&(m.value={...m.value,[g]:_})},R=a.computed(()=>{let g=s.value;return typeof g=="function"&&(g=g(c?.formData)),Object.keys(g).reduce((_,P)=>(_[P]=a.unref(g[P]),_),{})}),de=a.computed(()=>c?.readonly.value?!0:R.value.readonly??u.readonly),Be=a.computed(()=>f.value.reduce((g,_)=>(g[`onUpdate:${_}`]=P=>{E(_,P)},g),{"onUpdate:modelValue":y})),Ge=a.computed(()=>({...Be.value,...R.value,...m.value,modelValue:m.value,names:R.value.name??p.value,invalid:j.value,invalids:V.value,valid:u.showValid?!!(!j.value&&m.value):void 0,invalidLabels:O.value,readonly:de.value}));return a.provide(n,{names:a.readonly(l),errors:a.readonly(b)}),{component:a.computed(()=>({render(){return t.default?.({errors:b.value,formData:c?.formData.value,formErrors:c?.errors.value,invalid:j.value,invalids:V.value,invalidLabels:O.value,modelValue:m.value,onUpdate:y,onUpdateField:E,readonly:de.value,submit:c?.submit,validate:c?.validate})??t.default}})),hasProps:Ge,invalid:j}},render(){return this.is?a.h(this.is,this.hasProps,this.$slots):a.h(this.component,null,this.$slots)}})}function Je(e,r){return a.defineComponent({name:"VvFormWrapper",props:{name:{type:String,required:!0},tag:{type:String,default:void 0},readonly:{type:Boolean,default:!1}},emits:["invalid","valid"],expose:["clear","errors","fields","fieldsErrors","formData","invalid","readonly","reset","submit","tag","validate","validateWrapper"],slots:Object,setup(n,{emit:u}){const t=a.inject(e),i=a.inject(r,void 0),s=a.ref(new Map),l=a.ref(new Map),{name:d}=a.toRefs(n),h=a.computed(()=>t?.invalid.value?l.value.size>0:!1);a.watch(h,o=>{if(o){u("invalid");return}u("valid")});const p=a.computed(()=>t?.readonly.value||n.readonly),f={name:a.readonly(d),errors:l,invalid:a.readonly(h),readonly:a.readonly(p),fields:s};a.provide(r,f);const w=a.computed(()=>new Map(s.value));a.watch(w,(o,c)=>{i?.fields&&(c.forEach((m,b)=>{o.has(b)||i?.fields.value.delete(b)}),o.forEach((m,b)=>{i?.fields.value.has(b)||i?.fields.value.set(b,m)}))},{deep:!0}),a.watch(l,o=>{i?.errors&&s.value.forEach(c=>{if(o.has(c)||i.errors.value.delete(c),o.has(c)){const m=o.get(c);m&&i.errors.value.set(c,m)}})},{deep:!0}),a.onMounted(()=>{if(!t?.wrappers||!d.value){console.warn("[@volverjs/form-vue]: Invalid wrapper registration state");return}if(t.wrappers.has(d.value)){console.warn(`[@volverjs/form-vue]: wrapper name "${d.value}" is already used`);return}t.wrappers.set(d.value,f)}),a.onBeforeUnmount(()=>{t?.wrappers&&d.value&&t.wrappers.delete(d.value)});const v=()=>t?.validate(void 0,{fields:new Set(s.value.values())})??Promise.resolve(!0);return{errors:t?.errors,fields:s,fieldsErrors:l,formData:t?.formData,invalid:h,readonly:p,clear:t?.clear,reset:t?.reset,submit:t?.submit,validate:t?.validate,validateWrapper:v}},render(){const n=()=>this.$slots.default?.({errors:this.errors,fieldsErrors:this.fieldsErrors,formData:this.formData,invalid:this.invalid,readonly:this.readonly,clear:this.clear,reset:this.reset,submit:this.submit,validate:this.validate,validateWrapper:this.validateWrapper});return this.tag?a.h(this.tag,null,{default:n}):n()}})}function Me(e,r){const n=a.defineComponent({name:"VvFormTemplate",props:{schema:{type:[Array,Function],required:!0},scope:{type:Object,default:()=>({})}},slots:Object,setup(u,{slots:t}){const i=a.inject(e);if(i?.formData)return()=>{const s=typeof u.schema=="function"?u.schema(i,u.scope):u.schema;let l;const d=s.reduce((h,p)=>{const f=typeof p=="function"?p(i,u.scope):p,{vvIs:w,vvName:v,vvSlots:o,vvChildren:c,vvIf:m,vvElseIf:b,vvType:O,vvDefaultValue:j,vvShowValid:V,vvContent:k,...x}=f;if(m!==void 0){if(typeof m=="string"?l=!!$(new Object(i.formData.value),m):typeof m=="function"?l=a.unref(m(i)):l=a.unref(m),!l)return h}else if(b!==void 0&&l!==void 0){if(l||(typeof b=="string"?l=!!$(new Object(i.formData.value),b):typeof b=="function"?l=a.unref(b(i)):l=a.unref(b),!l))return h}else l=void 0;let y;return c&&(typeof w=="string"?y=a.h(n,{schema:c}):y={default:E=>a.h(n,{schema:c,scope:E})}),v?(h.push(a.h(r,{name:v,is:w,type:O,defaultValue:j,showValid:V,props:x},o??y??k)),h):w?(h.push(a.h(w,x,o??y??k)),h):(y&&("default"in y?h.push(y.default(u.scope)):h.push(y)),h)},[]);return d.push(t?.default?.({errors:i?.errors.value,formData:i?.formData.value,invalid:i?.invalid.value,status:i?.status.value,submit:i?.submit,validate:i?.validate,clear:i?.clear,reset:i?.reset})),d}}});return n}function B(e,r={}){const n=Symbol("formInjectionKey"),u=Symbol("formWrapperInjectionKey"),t=Symbol("formFieldInjectionKey"),i=Symbol("formFieldsGroupInjectionKey"),s=Je(n,u),l=Ae(n,u,t,r),d=Fe(n,u,i),h=Me(n,l),p=new Map,{clear:f,errors:w,formData:v,ignoreUpdates:o,invalid:c,readonly:m,reset:b,status:O,stopUpdatesWatch:j,submit:V,validate:k,VvForm:x}=Re(e,n,r,h,p);return{clear:f,errors:w,formData:v,formFieldInjectionKey:t,formInjectionKey:n,formWrapperInjectionKey:u,ignoreUpdates:o,invalid:c,readonly:m,reset:b,status:O,stopUpdatesWatch:j,submit:V,validate:k,wrappers:p,VvForm:x,VvFormField:l,VvFormFieldsGroup:d,VvFormTemplate:h,VvFormWrapper:s}}const W=Symbol("pluginInjectionKey");function Ce(e){let r={};return e.schema&&(r=B(e.schema,e)),{...r,install(n,{global:u=!1}={}){n.provide(W,e),u&&(n.config.globalProperties.$vvForm=e,r?.VvForm&&n.component("VvForm",r.VvForm),r?.VvFormWrapper&&n.component("VvFormWrapper",r.VvFormWrapper),r?.VvFormField&&n.component("VvFormField",r.VvFormField),r?.VvFormFieldsGroup&&n.component("VvFormFieldsGroup",r.VvFormFieldsGroup),r?.VvFormTemplate&&n.component("VvFormTemplate",r.VvFormTemplate))}}}const G=new Map;function Ue(e,r={}){if(r.scope&&G.has(r.scope))return G.get(r.scope);if(!a.getCurrentInstance()){const u=B(e,r);return r.scope&&G.set(r.scope,u),u}const n=B(e,{...a.inject(W,{}),...r});return r.scope&&G.set(r.scope,n),n}function Ze(e,r={}){return B(e,r)}N.FormFieldType=S,N.createForm=Ce,N.defaultObjectBySchema=F,N.formType=Ze,N.pluginInjectionKey=W,N.useForm=Ue,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})});
package/dist/utils.d.ts CHANGED
@@ -1,6 +1,13 @@
1
1
  import { FormSchema, InferSchema, VvZodError, ZodIssue } from './types';
2
2
  import type * as z3 from 'zod/v3';
3
3
  import type * as z4 from 'zod/v4/core';
4
+ export declare const isZod3Object: (value: z3.ZodTypeAny) => value is z3.ZodObject<any>;
5
+ export declare const isZod3Default: (value: z3.ZodTypeAny) => value is z3.ZodDefault<any>;
6
+ export declare const isZod3Nullable: (value: z3.ZodTypeAny) => value is z3.ZodNullable<any>;
7
+ export declare const isZod3Record: (value: z3.ZodTypeAny) => value is z3.ZodRecord<any, any>;
8
+ export declare const isZod3Array: (value: z3.ZodTypeAny) => value is z3.ZodArray<any>;
9
+ export declare const isZod3Effects: (value: z3.ZodTypeAny) => value is z3.ZodEffects<any>;
10
+ export declare const isZod3Optional: (value: z3.ZodTypeAny) => value is z3.ZodOptional<any>;
4
11
  export declare function defaultObjectByJSONSchema(schema: z4.JSONSchema.JSONSchema, original?: unknown): unknown;
5
12
  export declare const isZod4Schema: (schema: z3.ZodTypeAny | z4.$ZodType) => schema is z4.$ZodType;
6
13
  export declare function defaultObjectBySchema<Schema extends FormSchema>(schema: Schema, original?: Partial<InferSchema<Schema>> & Record<string, unknown>): Partial<InferSchema<Schema>>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@volverjs/form-vue",
3
3
  "type": "module",
4
- "version": "1.1.0-beta.2",
4
+ "version": "1.1.0-beta.3",
5
5
  "description": "Vue 3 Forms with @volverjs/ui-vue",
6
6
  "author": "8 Wave S.r.l.",
7
7
  "license": "MIT",
package/src/utils.ts CHANGED
@@ -1,12 +1,4 @@
1
1
  import {
2
- ZodDefault,
3
- ZodObject,
4
- ZodEffects,
5
- ZodSchema,
6
- ZodNullable,
7
- ZodOptional,
8
- ZodRecord,
9
- ZodArray,
10
2
  ZodError,
11
3
  } from 'zod/v3'
12
4
  import {
@@ -20,19 +12,47 @@ import type * as z3 from 'zod/v3'
20
12
  import type * as z4 from 'zod/v4/core'
21
13
  import type { FormSchema, InferSchema, VvZodError, ZodIssue } from './types'
22
14
 
15
+ export const isZod3Object = (value: z3.ZodTypeAny): value is z3.ZodObject<any> => {
16
+ return value._def.typeName === 'ZodObject'
17
+ }
18
+
19
+ export const isZod3Default = (value: z3.ZodTypeAny): value is z3.ZodDefault<any> => {
20
+ return value._def.typeName === 'ZodDefault'
21
+ }
22
+
23
+ export const isZod3Nullable = (value: z3.ZodTypeAny): value is z3.ZodNullable<any> => {
24
+ return value._def.typeName === 'ZodNullable'
25
+ }
26
+
27
+ export const isZod3Record = (value: z3.ZodTypeAny): value is z3.ZodRecord<any, any> => {
28
+ return value._def.typeName === 'ZodRecord'
29
+ }
30
+
31
+ export const isZod3Array = (value: z3.ZodTypeAny): value is z3.ZodArray<any> => {
32
+ return value._def.typeName === 'ZodArray'
33
+ }
34
+
35
+ export const isZod3Effects = (value: z3.ZodTypeAny): value is z3.ZodEffects<any> => {
36
+ return value._def.typeName === 'ZodEffects'
37
+ }
38
+
39
+ export const isZod3Optional = (value: z3.ZodTypeAny): value is z3.ZodOptional<any> => {
40
+ return value._def.typeName === 'ZodOptional'
41
+ }
42
+
23
43
  // Helper function to get the inner type of a Zod v3 schema
24
44
  const getZod3SchemaInnerType = <Type extends z3.ZodTypeAny>(
25
45
  schema:
26
46
  | Type
27
47
  | z3.ZodEffects<Type>
28
- | z3.ZodEffects<ZodEffects<Type>>
48
+ | z3.ZodEffects<z3.ZodEffects<Type>>
29
49
  | z3.ZodOptional<Type>,
30
50
  ) => {
31
51
  let toReturn = schema
32
- while (toReturn instanceof ZodEffects) {
52
+ while (isZod3Effects(toReturn)) {
33
53
  toReturn = toReturn.innerType()
34
54
  }
35
- if (toReturn instanceof ZodOptional) {
55
+ if (isZod3Optional(toReturn)) {
36
56
  toReturn = toReturn._def.innerType
37
57
  }
38
58
  return toReturn
@@ -43,18 +63,14 @@ const isZod3SchemaOptional = <Type extends z3.ZodTypeAny>(
43
63
  schema:
44
64
  | Type
45
65
  | z3.ZodEffects<Type>
46
- | z3.ZodEffects<ZodEffects<Type>>
47
- | z3.ZodOptional<Type>
48
- | z3.ZodNullable<Type>,
66
+ | z3.ZodEffects<z3.ZodEffects<Type>>
67
+ | z3.ZodOptional<Type>,
49
68
  ) => {
50
69
  let toReturn = schema
51
- while (toReturn instanceof ZodEffects) {
70
+ while (isZod3Effects(toReturn)) {
52
71
  toReturn = toReturn.innerType()
53
72
  }
54
- if (toReturn instanceof ZodOptional) {
55
- return true
56
- }
57
- if (toReturn instanceof ZodNullable) {
73
+ if (isZod3Optional(toReturn)) {
58
74
  return true
59
75
  }
60
76
  return false
@@ -178,13 +194,10 @@ export function defaultObjectBySchema<Schema extends FormSchema>(schema: Schema,
178
194
  // zod v3
179
195
  const innerType = getZod3SchemaInnerType(schema)
180
196
 
181
- if (!(innerType instanceof ZodObject)) {
197
+ if (!isZod3Object(innerType)) {
182
198
  return original
183
199
  }
184
- const unknownKeys
185
- = innerType instanceof ZodObject
186
- ? innerType._def.unknownKeys === 'passthrough'
187
- : false
200
+ const unknownKeys = innerType._def.unknownKeys === 'passthrough'
188
201
  return {
189
202
  ...(unknownKeys ? original : {}),
190
203
  ...Object.fromEntries(
@@ -194,32 +207,32 @@ export function defaultObjectBySchema<Schema extends FormSchema>(schema: Schema,
194
207
  const isOptional = isZod3SchemaOptional(subSchema)
195
208
  let innerType = getZod3SchemaInnerType(subSchema)
196
209
  let defaultValue: Partial<InferSchema<Schema>> | undefined
197
- if (innerType instanceof ZodDefault) {
210
+ if (isZod3Default(innerType)) {
198
211
  defaultValue = innerType._def.defaultValue()
199
212
  innerType = innerType._def.innerType
200
213
  }
201
214
  if (
202
215
  originalValue === null
203
- && innerType instanceof ZodNullable
216
+ && isZod3Nullable(innerType)
204
217
  ) {
205
218
  return [key, originalValue]
206
219
  }
207
220
  if ((originalValue === undefined || originalValue === null) && isOptional) {
208
221
  return [key, defaultValue]
209
222
  }
210
- if (innerType instanceof ZodSchema) {
223
+ if (innerType) {
211
224
  const parse = subSchema.safeParse(originalValue)
212
225
  if (parse.success) {
213
226
  return [key, parse.data ?? defaultValue]
214
227
  }
215
228
  }
216
229
  if (
217
- innerType instanceof ZodArray
230
+ isZod3Array(innerType)
218
231
  && Array.isArray(originalValue)
219
232
  && originalValue.length
220
233
  ) {
221
234
  const arrayType = getZod3SchemaInnerType(innerType._def.type)
222
- if (arrayType instanceof ZodObject) {
235
+ if (isZod3Object(arrayType)) {
223
236
  return [
224
237
  key,
225
238
  originalValue.map((element: unknown) =>
@@ -235,16 +248,16 @@ export function defaultObjectBySchema<Schema extends FormSchema>(schema: Schema,
235
248
  ]
236
249
  }
237
250
  }
238
- if (innerType instanceof ZodRecord && originalValue) {
251
+ if (isZod3Record(innerType) && originalValue) {
239
252
  const valueType = getZod3SchemaInnerType(innerType._def.valueType)
240
- if (valueType instanceof ZodObject) {
253
+ if (isZod3Object(valueType)) {
241
254
  return [key, Object.keys(originalValue).reduce((acc: Record<string, unknown>, recordKey: string) => {
242
255
  acc[recordKey] = defaultObjectBySchema(valueType, originalValue[recordKey])
243
256
  return acc
244
257
  }, {})]
245
258
  }
246
259
  }
247
- if (innerType instanceof ZodObject) {
260
+ if (isZod3Object(innerType)) {
248
261
  return [
249
262
  key,
250
263
  defaultObjectBySchema(