@harnessio/forms 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,13 +1,13 @@
1
- "use strict";var Mt=Object.defineProperty;var Dt=(r,e,t)=>e in r?Mt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var fe=(r,e,t)=>Dt(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("lodash-es"),O=require("react"),A=require("react-hook-form"),qt=require("@hookform/resolvers");class gt extends Error{constructor(e){super(`Input component '${e}' is already registered.`)}}class Ve{constructor(e){fe(this,"componentBank");fe(this,"allowOverride");this.allowOverride=(e==null?void 0:e.allowOverride)??!1,this.componentBank=new Map}registerComponent(e){if(!this.allowOverride&&this.getComponent(e.internalType))throw new gt(e.internalType);this.componentBank.set(e.internalType,e)}getComponent(e){if(e&&!m.isEmpty(e))return this.componentBank.get(e)}listRegisteredComponents(){return Array.from(this.componentBank.keys())}clone(){const e=new Ve({allowOverride:this.allowOverride});return this.listRegisteredComponents().forEach(t=>{e.registerComponent(this.componentBank.get(t))}),e}}var xe={exports:{}},Q={};/*
1
+ "use strict";var Mt=Object.defineProperty;var Dt=(r,e,t)=>e in r?Mt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var fe=(r,e,t)=>Dt(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("lodash-es"),O=require("react"),A=require("react-hook-form"),qt=require("@hookform/resolvers");class vt extends Error{constructor(e){super(`Input component '${e}' is already registered.`)}}class Ze{constructor(e){fe(this,"componentBank");fe(this,"allowOverride");this.allowOverride=(e==null?void 0:e.allowOverride)??!1,this.componentBank=new Map}registerComponent(e){if(!this.allowOverride&&this.getComponent(e.internalType))throw new vt(e.internalType);this.componentBank.set(e.internalType,e)}getComponent(e){if(e&&!m.isEmpty(e))return this.componentBank.get(e)}listRegisteredComponents(){return Array.from(this.componentBank.keys())}clone(){const e=new Ze({allowOverride:this.allowOverride});return this.listRegisteredComponents().forEach(t=>{e.registerComponent(this.componentBank.get(t))}),e}}var xe={exports:{}},Q={};/*
2
2
  object-assign
3
3
  (c) Sindre Sorhus
4
4
  @license MIT
5
- */var ke,Ye;function Lt(){if(Ye)return ke;Ye=1;var r=Object.getOwnPropertySymbols,e=Object.prototype.hasOwnProperty,t=Object.prototype.propertyIsEnumerable;function n(s){if(s==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(s)}function a(){try{if(!Object.assign)return!1;var s=new String("abc");if(s[5]="de",Object.getOwnPropertyNames(s)[0]==="5")return!1;for(var i={},o=0;o<10;o++)i["_"+String.fromCharCode(o)]=o;var u=Object.getOwnPropertyNames(i).map(function(d){return i[d]});if(u.join("")!=="0123456789")return!1;var c={};return"abcdefghijklmnopqrst".split("").forEach(function(d){c[d]=d}),Object.keys(Object.assign({},c)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return ke=a()?Object.assign:function(s,i){for(var o,u=n(s),c,d=1;d<arguments.length;d++){o=Object(arguments[d]);for(var g in o)e.call(o,g)&&(u[g]=o[g]);if(r){c=r(o);for(var h=0;h<c.length;h++)t.call(o,c[h])&&(u[c[h]]=o[c[h]])}}return u},ke}/** @license React v17.0.2
5
+ */var ke,Qe;function Lt(){if(Qe)return ke;Qe=1;var r=Object.getOwnPropertySymbols,e=Object.prototype.hasOwnProperty,t=Object.prototype.propertyIsEnumerable;function n(s){if(s==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(s)}function a(){try{if(!Object.assign)return!1;var s=new String("abc");if(s[5]="de",Object.getOwnPropertyNames(s)[0]==="5")return!1;for(var i={},o=0;o<10;o++)i["_"+String.fromCharCode(o)]=o;var u=Object.getOwnPropertyNames(i).map(function(d){return i[d]});if(u.join("")!=="0123456789")return!1;var c={};return"abcdefghijklmnopqrst".split("").forEach(function(d){c[d]=d}),Object.keys(Object.assign({},c)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return ke=a()?Object.assign:function(s,i){for(var o,u=n(s),c,d=1;d<arguments.length;d++){o=Object(arguments[d]);for(var g in o)e.call(o,g)&&(u[g]=o[g]);if(r){c=r(o);for(var h=0;h<c.length;h++)t.call(o,c[h])&&(u[c[h]]=o[c[h]])}}return u},ke}/** @license React v17.0.2
6
6
  * react-jsx-runtime.production.min.js
7
7
  *
8
8
  * Copyright (c) Facebook, Inc. and its affiliates.
9
9
  *
10
10
  * This source code is licensed under the MIT license found in the
11
11
  * LICENSE file in the root directory of this source tree.
12
- */var Ge;function zt(){if(Ge)return Q;Ge=1,Lt();var r=O,e=60103;if(Q.Fragment=60107,typeof Symbol=="function"&&Symbol.for){var t=Symbol.for;e=t("react.element"),Q.Fragment=t("react.fragment")}var n=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a=Object.prototype.hasOwnProperty,s={key:!0,ref:!0,__self:!0,__source:!0};function i(o,u,c){var d,g={},h=null,b=null;c!==void 0&&(h=""+c),u.key!==void 0&&(h=""+u.key),u.ref!==void 0&&(b=u.ref);for(d in u)a.call(u,d)&&!s.hasOwnProperty(d)&&(g[d]=u[d]);if(o&&o.defaultProps)for(d in u=o.defaultProps,u)g[d]===void 0&&(g[d]=u[d]);return{$$typeof:e,type:o,key:h,ref:b,props:g,_owner:n.current}}return Q.jsx=i,Q.jsxs=i,Q}var Qe;function Bt(){return Qe||(Qe=1,xe.exports=zt()),xe.exports}var R=Bt();const _t=O.createContext({});function Ut({children:r,metadata:e,inputErrorHandler:t,readonly:n}){return R.jsx(_t.Provider,{value:{metadata:e,readonly:n,inputErrorHandler:t},children:r})}function vt(){const r=O.useContext(_t);return r||console.warn("useRootFormContext must be used within RootFormProvider"),r}class Wt extends O.Component{constructor(){super(...arguments);fe(this,"state",{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t,n){var s,i;console.error(t,n);const a=new Error(`Form input [${this.props.inputType}] has failed at path [${this.props.path}]. Error: ${t}, Error info: ${n}`);(i=(s=this.props).inputErrorHandler)==null||i.call(s,a)}render(){return this.state.hasError?R.jsx(R.Fragment,{}):this.props.children}}const Xe=({children:r,withoutWrapper:e=!1})=>e||!r?r:R.jsx("div",{children:r}),bt=O.memo(function({path:e,factory:t,onUpdate:n,onChange:a,initialValues:s,input:i,withoutWrapper:o=!1}){var qe,Le,ze,Be,Ue;const u=A.useFormContext(),{formState:c}=u,{fixedValues:d={}}={},{metadata:g,readonly:h,inputErrorHandler:b}=vt(),E=t==null?void 0:t.getComponent(i.inputType),T=!!(i.isVisible||typeof i.disabled=="function"||typeof((qe=i.validation)==null?void 0:qe.schema)=="function"||typeof((Le=i.warning)==null?void 0:Le.schema)=="function"),j=!!((ze=i.warning)!=null&&ze.schema||(Be=i.validation)!=null&&Be.schema),C=T?u.watch():{},Z=j?T?A.get(C,i.path):u.watch(i.path):void 0,$=O.useMemo(()=>{if(!T)return{};let se=C;return d&&Object.keys(d).forEach(le=>{const ae=d[le];se=m.set(se,le,ae)}),se},[T,C,d]),H=!i.isVisible||i.isVisible($,g),I=h||i.readonly,M=typeof i.disabled=="function"?i.disabled($,g):i.disabled,V=(Ue=i.warning)==null?void 0:Ue.schema,Me=O.useMemo(()=>{var Je,He;if(!H||typeof V>"u")return;const se=typeof V=="function"?V($,g):V,{success:le,error:ae}=se.safeParse(Z),We=(He=(Je=ae==null?void 0:ae.errors)==null?void 0:Je[0])==null?void 0:He.message;return!le&&We?We:void 0},[i.path,Z,V,H,g]),De=O.useMemo(()=>({path:e,key:e,initialValues:s,onUpdate:n,onChange:a,factory:t,readonly:I,input:i,disabled:M,warning:Me}),[t,s,i,a,n,e,I,c.errors,M,Me]),Ft=O.useMemo(()=>H?R.jsxs(R.Fragment,{children:[i.before?i.before:null,R.jsx(Wt,{path:e,inputType:i.inputType,inputErrorHandler:b,children:E==null?void 0:E.renderComponent(De)}),i.after?i.after:null]}):null,[H,i.before,i.inputType,i.after,e,E,De,c.errors]);return E?R.jsx(Xe,{withoutWrapper:o,children:Ft}):R.jsx(Xe,{withoutWrapper:o,children:R.jsxs("p",{children:["Input component not found (internal type: ",i.inputType,")"]})})});class Jt{getType(){return this.internalType}}function Ke(){return typeof window<"u"&&"requestIdleCallback"in window?window.requestIdleCallback:function(r,e){const t=Date.now(),n=(e==null?void 0:e.timeout)||1;return setTimeout(function(){r({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-t))}})},n)}}function et(){return typeof window<"u"&&"cancelIdleCallback"in window?window.cancelIdleCallback:clearTimeout}function Ht(r){const{mode:e="onSubmit",resolver:t,defaultValues:n,shouldFocusError:a,onValuesChange:s,onValidationChange:i,onSubmit:o,onInputRenderError:u,metadata:c,children:d,autoFocusPath:g,readonly:h}=r,b=A.useForm({mode:e,reValidateMode:"onChange",defaultValues:n,shouldFocusError:a,resolver:t}),E=O.useRef(!1),T=O.useRef(JSON.stringify(n??{}));O.useEffect(()=>{T.current=JSON.stringify(n??{}),b.reset(n,{})},[b.reset,n]),O.useEffect(()=>{const I=Ke(),M=et(),V=I(()=>{b.reset({},{keepErrors:!0,keepDirty:!0,keepDirtyValues:!0,keepValues:!0,keepDefaultValues:!1,keepIsSubmitted:!0,keepTouched:!0,keepIsValid:!0,keepSubmitCount:!0})});return()=>M(V)},[]);const{handleSubmit:j}=b,C=O.useRef(s);O.useEffect(()=>{C.current=s},[s]);const Z=O.useRef(i);O.useEffect(()=>{Z.current=i},[i]);const $=O.useRef(!1);O.useEffect(()=>{const I=b.watch(M=>{var V;$.current||JSON.stringify(M??{})!==T.current&&((V=C.current)==null||V.call(C,{...M}),E.current===!0&&($.current=!0,b.trigger().finally(()=>{$.current=!1})))});return()=>{I.unsubscribe()}},[b]);const H=O.useRef(!0);return O.useEffect(()=>{var I;if(H.current){H.current=!1;return}(I=Z.current)==null||I.call(Z,{isValid:b.formState.isValid,isSubmitted:b.formState.isSubmitted})},[b.formState.isValid,b.formState.isSubmitted]),O.useEffect(()=>{if(g){const I=Ke(),M=et(),V=I(()=>{b.setFocus(g)});return()=>M(V)}},[b,g]),R.jsx(Ut,{metadata:c,readonly:h,inputErrorHandler:u,children:R.jsx(A.FormProvider,{...b,children:typeof d=="function"?d({...b,submitForm:async()=>{o&&(E.current=!0,j(I=>{o(I)})())}}):d})})}const Yt=r=>{const e={},t=n=>{n.forEach(a=>{const{path:s,default:i,inputs:o}=a;Array.isArray(o)?t(o):m.get(e,s)===void 0&&m.set(e,s,i)})};return Array.isArray(r.inputs)&&t(r.inputs),e};function Gt(r,e){const t=r.inputs.map(n=>{const a=Qt(e,n.path);return a||n});return{...r,inputs:t}}function Qt(r,e){return r.inputs.find(t=>t.path===e)}const xt="__temp_",Xt=r=>xt+r.split(".").join("__");function kt(r){const e={...r};return m.forOwn(e,(t,n)=>{n.startsWith(xt)&&delete e[n]}),e}var w;(function(r){r.assertEqual=a=>{};function e(a){}r.assertIs=e;function t(a){throw new Error}r.assertNever=t,r.arrayToEnum=a=>{const s={};for(const i of a)s[i]=i;return s},r.getValidEnumValues=a=>{const s=r.objectKeys(a).filter(o=>typeof a[a[o]]!="number"),i={};for(const o of s)i[o]=a[o];return r.objectValues(i)},r.objectValues=a=>r.objectKeys(a).map(function(s){return a[s]}),r.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const s=[];for(const i in a)Object.prototype.hasOwnProperty.call(a,i)&&s.push(i);return s},r.find=(a,s)=>{for(const i of a)if(s(i))return i},r.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function n(a,s=" | "){return a.map(i=>typeof i=="string"?`'${i}'`:i).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(a,s)=>typeof s=="bigint"?s.toString():s})(w||(w={}));var tt;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(tt||(tt={}));const p=w.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),L=r=>{switch(typeof r){case"undefined":return p.undefined;case"string":return p.string;case"number":return Number.isNaN(r)?p.nan:p.number;case"boolean":return p.boolean;case"function":return p.function;case"bigint":return p.bigint;case"symbol":return p.symbol;case"object":return Array.isArray(r)?p.array:r===null?p.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?p.promise:typeof Map<"u"&&r instanceof Map?p.map:typeof Set<"u"&&r instanceof Set?p.set:typeof Date<"u"&&r instanceof Date?p.date:p.object;default:return p.unknown}},l=w.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 q extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};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(s){return s.message},n={_errors:[]},a=s=>{for(const i of s.issues)if(i.code==="invalid_union")i.unionErrors.map(a);else if(i.code==="invalid_return_type")a(i.returnTypeError);else if(i.code==="invalid_arguments")a(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,u=0;for(;u<i.path.length;){const c=i.path[u];u===i.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(t(i))):o[c]=o[c]||{_errors:[]},o=o[c],u++}}};return a(this),n}static assert(e){if(!(e instanceof q))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,w.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t=Object.create(null),n=[];for(const a of this.issues)if(a.path.length>0){const s=a.path[0];t[s]=t[s]||[],t[s].push(e(a))}else n.push(e(a));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}q.create=r=>new q(r);const Ce=(r,e)=>{let t;switch(r.code){case l.invalid_type:r.received===p.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case l.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,w.jsonStringifyReplacer)}`;break;case l.unrecognized_keys:t=`Unrecognized key(s) in object: ${w.joinValues(r.keys,", ")}`;break;case l.invalid_union:t="Invalid input";break;case l.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${w.joinValues(r.options)}`;break;case l.invalid_enum_value:t=`Invalid enum value. Expected ${w.joinValues(r.options)}, received '${r.received}'`;break;case l.invalid_arguments:t="Invalid function arguments";break;case l.invalid_return_type:t="Invalid function return type";break;case l.invalid_date:t="Invalid date";break;case l.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}"`:w.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case l.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 l.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 l.custom:t="Invalid input";break;case l.invalid_intersection_types:t="Intersection results could not be merged";break;case l.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case l.not_finite:t="Number must be finite";break;default:t=e.defaultError,w.assertNever(r)}return{message:t}};let Kt=Ce;function er(){return Kt}const tr=r=>{const{data:e,path:t,errorMaps:n,issueData:a}=r,s=[...t,...a.path||[]],i={...a,path:s};if(a.message!==void 0)return{...a,path:s,message:a.message};let o="";const u=n.filter(c=>!!c).slice().reverse();for(const c of u)o=c(i,{data:e,defaultError:o}).message;return{...a,path:s,message:o}};function f(r,e){const t=er(),n=tr({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Ce?void 0:Ce].filter(a=>!!a)});r.common.issues.push(n)}class N{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const a of t){if(a.status==="aborted")return _;a.status==="dirty"&&e.dirty(),n.push(a.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const a of t){const s=await a.key,i=await a.value;n.push({key:s,value:i})}return N.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const a of t){const{key:s,value:i}=a;if(s.status==="aborted"||i.status==="aborted")return _;s.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof i.value<"u"||a.alwaysSet)&&(n[s.value]=i.value)}return{status:e.value,value:n}}}const _=Object.freeze({status:"aborted"}),ie=r=>({status:"dirty",value:r}),P=r=>({status:"valid",value:r}),rt=r=>r.status==="aborted",nt=r=>r.status==="dirty",ee=r=>r.status==="valid",pe=r=>typeof Promise<"u"&&r instanceof Promise;var y;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(y||(y={}));class W{constructor(e,t,n,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=a}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 st=(r,e)=>{if(ee(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 q(r.common.issues);return this._error=t,this._error}}};function x(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:a}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(i,o)=>{const{message:u}=r;return i.code==="invalid_enum_value"?{message:u??o.defaultError}:typeof o.data>"u"?{message:u??n??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:u??t??o.defaultError}},description:a}}class k{get description(){return this._def.description}_getType(e){return L(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:L(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new N,ctx:{common:e.parent.common,data:e.data,parsedType:L(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(pe(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 n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){const n={common:{issues:[],async:(t==null?void 0:t.async)??!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:L(e)},a=this._parseSync({data:e,path:n.path,parent:n});return st(n,a)}"~validate"(e){var n,a;const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:L(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:t});return ee(s)?{value:s.value}:{issues:t.common.issues}}catch(s){(a=(n=s==null?void 0:s.message)==null?void 0:n.toLowerCase())!=null&&a.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(s=>ee(s)?{value:s.value}:{issues:t.common.issues})}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:L(e)},a=this._parse({data:e,path:n.path,parent:n}),s=await(pe(a)?a:Promise.resolve(a));return st(n,s)}refine(e,t){const n=a=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(a):t;return this._refinement((a,s)=>{const i=e(a),o=()=>s.addIssue({code:l.custom,...n(a)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,a)=>e(n)?!0:(a.addIssue(typeof t=="function"?t(n,a):t),!1))}_refinement(e){return new re({schema:this,typeName:v.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 B.create(this,this._def)}nullable(){return ne.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return F.create(this)}promise(){return ve.create(this,this._def)}or(e){return ge.create([this,e],this._def)}and(e){return _e.create(this,e,this._def)}transform(e){return new re({...x(this._def),schema:this,typeName:v.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Ee({...x(this._def),innerType:this,defaultValue:t,typeName:v.ZodDefault})}brand(){return new Tr({typeName:v.ZodBranded,type:this,...x(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new je({...x(this._def),innerType:this,catchValue:t,typeName:v.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Pe.create(this,e)}readonly(){return Ae.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const rr=/^c[^\s-]{8,}$/i,nr=/^[0-9a-z]+$/,sr=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ar=/^[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,ir=/^[a-z0-9_-]{21}$/i,or=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ur=/^[-+]?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)?)??$/,cr=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,dr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let we;const lr=/^(?:(?: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])$/,fr=/^(?:(?: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])$/,hr=/^(([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]))$/,mr=/^(([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])$/,pr=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,yr=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,wt="((\\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])))",gr=new RegExp(`^${wt}$`);function Tt(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 _r(r){return new RegExp(`^${Tt(r)}$`)}function vr(r){let e=`${wt}T${Tt(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 br(r,e){return!!((e==="v4"||!e)&&lr.test(r)||(e==="v6"||!e)&&hr.test(r))}function xr(r,e){if(!or.test(r))return!1;try{const[t]=r.split(".");if(!t)return!1;const n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),a=JSON.parse(atob(n));return!(typeof a!="object"||a===null||"typ"in a&&(a==null?void 0:a.typ)!=="JWT"||!a.alg||e&&a.alg!==e)}catch{return!1}}function kr(r,e){return!!((e==="v4"||!e)&&fr.test(r)||(e==="v6"||!e)&&mr.test(r))}class z extends k{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==p.string){const s=this._getOrReturnCtx(e);return f(s,{code:l.invalid_type,expected:p.string,received:s.parsedType}),_}const n=new N;let a;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:l.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:l.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){const i=e.data.length>s.value,o=e.data.length<s.value;(i||o)&&(a=this._getOrReturnCtx(e,a),i?f(a,{code:l.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&f(a,{code:l.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")cr.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"email",code:l.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")we||(we=new RegExp(dr,"u")),we.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"emoji",code:l.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")ar.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"uuid",code:l.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")ir.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"nanoid",code:l.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")rr.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cuid",code:l.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")nr.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cuid2",code:l.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")sr.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"ulid",code:l.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),f(a,{validation:"url",code:l.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"regex",code:l.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(a=this._getOrReturnCtx(e,a),f(a,{code:l.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(a=this._getOrReturnCtx(e,a),f(a,{code:l.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(a=this._getOrReturnCtx(e,a),f(a,{code:l.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?vr(s).test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:l.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?gr.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:l.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?_r(s).test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:l.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?ur.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"duration",code:l.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?br(e.data,s.version)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"ip",code:l.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?xr(e.data,s.alg)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"jwt",code:l.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?kr(e.data,s.version)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cidr",code:l.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?pr.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"base64",code:l.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?yr.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"base64url",code:l.invalid_string,message:s.message}),n.dirty()):w.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(a=>e.test(a),{validation:t,code:l.invalid_string,...y.errToObj(n)})}_addCheck(e){return new z({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...y.errToObj(e)})}url(e){return this._addCheck({kind:"url",...y.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...y.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...y.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...y.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...y.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...y.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...y.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...y.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...y.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...y.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...y.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...y.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==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...y.errToObj(e==null?void 0: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==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...y.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...y.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...y.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...y.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...y.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...y.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...y.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...y.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...y.errToObj(t)})}nonempty(e){return this.min(1,y.errToObj(e))}trim(){return new z({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new z({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new z({...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}}z.create=r=>new z({checks:[],typeName:v.ZodString,coerce:(r==null?void 0:r.coerce)??!1,...x(r)});function wr(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,a=t>n?t:n,s=Number.parseInt(r.toFixed(a).replace(".","")),i=Number.parseInt(e.toFixed(a).replace(".",""));return s%i/10**a}class ue extends k{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)!==p.number){const s=this._getOrReturnCtx(e);return f(s,{code:l.invalid_type,expected:p.number,received:s.parsedType}),_}let n;const a=new N;for(const s of this._def.checks)s.kind==="int"?w.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:l.invalid_type,expected:"integer",received:"float",message:s.message}),a.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:l.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),a.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:l.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),a.dirty()):s.kind==="multipleOf"?wr(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),f(n,{code:l.not_multiple_of,multipleOf:s.value,message:s.message}),a.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:l.not_finite,message:s.message}),a.dirty()):w.assertNever(s);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,y.toString(t))}setLimit(e,t,n,a){return new ue({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:y.toString(a)}]})}_addCheck(e){return new ue({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:y.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:y.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:y.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:y.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:y.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"&&w.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}ue.create=r=>new ue({checks:[],typeName:v.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...x(r)});class ce extends k{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)!==p.bigint)return this._getInvalidInput(e);let n;const a=new N;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:l.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),a.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:l.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),a.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),f(n,{code:l.not_multiple_of,multipleOf:s.value,message:s.message}),a.dirty()):w.assertNever(s);return{status:a.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return f(t,{code:l.invalid_type,expected:p.bigint,received:t.parsedType}),_}gte(e,t){return this.setLimit("min",e,!0,y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,y.toString(t))}setLimit(e,t,n,a){return new ce({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:y.toString(a)}]})}_addCheck(e){return new ce({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:y.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}}ce.create=r=>new ce({checks:[],typeName:v.ZodBigInt,coerce:(r==null?void 0:r.coerce)??!1,...x(r)});class at extends k{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==p.boolean){const n=this._getOrReturnCtx(e);return f(n,{code:l.invalid_type,expected:p.boolean,received:n.parsedType}),_}return P(e.data)}}at.create=r=>new at({typeName:v.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...x(r)});class ye extends k{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==p.date){const s=this._getOrReturnCtx(e);return f(s,{code:l.invalid_type,expected:p.date,received:s.parsedType}),_}if(Number.isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return f(s,{code:l.invalid_date}),_}const n=new N;let a;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:l.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:l.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):w.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ye({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:y.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:y.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}}ye.create=r=>new ye({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:v.ZodDate,...x(r)});class it extends k{_parse(e){if(this._getType(e)!==p.symbol){const n=this._getOrReturnCtx(e);return f(n,{code:l.invalid_type,expected:p.symbol,received:n.parsedType}),_}return P(e.data)}}it.create=r=>new it({typeName:v.ZodSymbol,...x(r)});class ot extends k{_parse(e){if(this._getType(e)!==p.undefined){const n=this._getOrReturnCtx(e);return f(n,{code:l.invalid_type,expected:p.undefined,received:n.parsedType}),_}return P(e.data)}}ot.create=r=>new ot({typeName:v.ZodUndefined,...x(r)});class ut extends k{_parse(e){if(this._getType(e)!==p.null){const n=this._getOrReturnCtx(e);return f(n,{code:l.invalid_type,expected:p.null,received:n.parsedType}),_}return P(e.data)}}ut.create=r=>new ut({typeName:v.ZodNull,...x(r)});class Se extends k{constructor(){super(...arguments),this._any=!0}_parse(e){return P(e.data)}}Se.create=r=>new Se({typeName:v.ZodAny,...x(r)});class ct extends k{constructor(){super(...arguments),this._unknown=!0}_parse(e){return P(e.data)}}ct.create=r=>new ct({typeName:v.ZodUnknown,...x(r)});class J extends k{_parse(e){const t=this._getOrReturnCtx(e);return f(t,{code:l.invalid_type,expected:p.never,received:t.parsedType}),_}}J.create=r=>new J({typeName:v.ZodNever,...x(r)});class dt extends k{_parse(e){if(this._getType(e)!==p.undefined){const n=this._getOrReturnCtx(e);return f(n,{code:l.invalid_type,expected:p.void,received:n.parsedType}),_}return P(e.data)}}dt.create=r=>new dt({typeName:v.ZodVoid,...x(r)});class F extends k{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),a=this._def;if(t.parsedType!==p.array)return f(t,{code:l.invalid_type,expected:p.array,received:t.parsedType}),_;if(a.exactLength!==null){const i=t.data.length>a.exactLength.value,o=t.data.length<a.exactLength.value;(i||o)&&(f(t,{code:i?l.too_big:l.too_small,minimum:o?a.exactLength.value:void 0,maximum:i?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),n.dirty())}if(a.minLength!==null&&t.data.length<a.minLength.value&&(f(t,{code:l.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),n.dirty()),a.maxLength!==null&&t.data.length>a.maxLength.value&&(f(t,{code:l.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>a.type._parseAsync(new W(t,i,t.path,o)))).then(i=>N.mergeArray(n,i));const s=[...t.data].map((i,o)=>a.type._parseSync(new W(t,i,t.path,o)));return N.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new F({...this._def,minLength:{value:e,message:y.toString(t)}})}max(e,t){return new F({...this._def,maxLength:{value:e,message:y.toString(t)}})}length(e,t){return new F({...this._def,exactLength:{value:e,message:y.toString(t)}})}nonempty(e){return this.min(1,e)}}F.create=(r,e)=>new F({type:r,minLength:null,maxLength:null,exactLength:null,typeName:v.ZodArray,...x(e)});function X(r){if(r instanceof S){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=B.create(X(n))}return new S({...r._def,shape:()=>e})}else return r instanceof F?new F({...r._def,type:X(r.element)}):r instanceof B?B.create(X(r.unwrap())):r instanceof ne?ne.create(X(r.unwrap())):r instanceof G?G.create(r.items.map(e=>X(e))):r}class S extends k{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=w.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==p.object){const c=this._getOrReturnCtx(e);return f(c,{code:l.invalid_type,expected:p.object,received:c.parsedType}),_}const{status:n,ctx:a}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof J&&this._def.unknownKeys==="strip"))for(const c in a.data)i.includes(c)||o.push(c);const u=[];for(const c of i){const d=s[c],g=a.data[c];u.push({key:{status:"valid",value:c},value:d._parse(new W(a,g,a.path,c)),alwaysSet:c in a.data})}if(this._def.catchall instanceof J){const c=this._def.unknownKeys;if(c==="passthrough")for(const d of o)u.push({key:{status:"valid",value:d},value:{status:"valid",value:a.data[d]}});else if(c==="strict")o.length>0&&(f(a,{code:l.unrecognized_keys,keys:o}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const d of o){const g=a.data[d];u.push({key:{status:"valid",value:d},value:c._parse(new W(a,g,a.path,d)),alwaysSet:d in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const c=[];for(const d of u){const g=await d.key,h=await d.value;c.push({key:g,value:h,alwaysSet:d.alwaysSet})}return c}).then(c=>N.mergeObjectSync(n,c)):N.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return y.errToObj,new S({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,i;const a=((i=(s=this._def).errorMap)==null?void 0:i.call(s,t,n).message)??n.defaultError;return t.code==="unrecognized_keys"?{message:y.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new S({...this._def,unknownKeys:"strip"})}passthrough(){return new S({...this._def,unknownKeys:"passthrough"})}extend(e){return new S({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new S({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:v.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new S({...this._def,catchall:e})}pick(e){const t={};for(const n of w.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new S({...this._def,shape:()=>t})}omit(e){const t={};for(const n of w.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new S({...this._def,shape:()=>t})}deepPartial(){return X(this)}partial(e){const t={};for(const n of w.objectKeys(this.shape)){const a=this.shape[n];e&&!e[n]?t[n]=a:t[n]=a.optional()}return new S({...this._def,shape:()=>t})}required(e){const t={};for(const n of w.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof B;)s=s._def.innerType;t[n]=s}return new S({...this._def,shape:()=>t})}keyof(){return Ot(w.objectKeys(this.shape))}}S.create=(r,e)=>new S({shape:()=>r,unknownKeys:"strip",catchall:J.create(),typeName:v.ZodObject,...x(e)});S.strictCreate=(r,e)=>new S({shape:()=>r,unknownKeys:"strict",catchall:J.create(),typeName:v.ZodObject,...x(e)});S.lazycreate=(r,e)=>new S({shape:r,unknownKeys:"strip",catchall:J.create(),typeName:v.ZodObject,...x(e)});class ge extends k{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function a(s){for(const o of s)if(o.result.status==="valid")return o.result;for(const o of s)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=s.map(o=>new q(o.ctx.common.issues));return f(t,{code:l.invalid_union,unionErrors:i}),_}if(t.common.async)return Promise.all(n.map(async s=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(a);{let s;const i=[];for(const u of n){const c={...t,common:{...t.common,issues:[]},parent:null},d=u._parseSync({data:t.data,path:t.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!s&&(s={result:d,ctx:c}),c.common.issues.length&&i.push(c.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const o=i.map(u=>new q(u));return f(t,{code:l.invalid_union,unionErrors:o}),_}}get options(){return this._def.options}}ge.create=(r,e)=>new ge({options:r,typeName:v.ZodUnion,...x(e)});function Re(r,e){const t=L(r),n=L(e);if(r===e)return{valid:!0,data:r};if(t===p.object&&n===p.object){const a=w.objectKeys(e),s=w.objectKeys(r).filter(o=>a.indexOf(o)!==-1),i={...r,...e};for(const o of s){const u=Re(r[o],e[o]);if(!u.valid)return{valid:!1};i[o]=u.data}return{valid:!0,data:i}}else if(t===p.array&&n===p.array){if(r.length!==e.length)return{valid:!1};const a=[];for(let s=0;s<r.length;s++){const i=r[s],o=e[s],u=Re(i,o);if(!u.valid)return{valid:!1};a.push(u.data)}return{valid:!0,data:a}}else return t===p.date&&n===p.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class _e extends k{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),a=(s,i)=>{if(rt(s)||rt(i))return _;const o=Re(s.value,i.value);return o.valid?((nt(s)||nt(i))&&t.dirty(),{status:t.value,value:o.data}):(f(n,{code:l.invalid_intersection_types}),_)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,i])=>a(s,i)):a(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}_e.create=(r,e,t)=>new _e({left:r,right:e,typeName:v.ZodIntersection,...x(t)});class G extends k{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.array)return f(n,{code:l.invalid_type,expected:p.array,received:n.parsedType}),_;if(n.data.length<this._def.items.length)return f(n,{code:l.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),_;!this._def.rest&&n.data.length>this._def.items.length&&(f(n,{code:l.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((i,o)=>{const u=this._def.items[o]||this._def.rest;return u?u._parse(new W(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(s).then(i=>N.mergeArray(t,i)):N.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new G({...this._def,rest:e})}}G.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new G({items:r,typeName:v.ZodTuple,rest:null,...x(e)})};class lt extends k{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.map)return f(n,{code:l.invalid_type,expected:p.map,received:n.parsedType}),_;const a=this._def.keyType,s=this._def.valueType,i=[...n.data.entries()].map(([o,u],c)=>({key:a._parse(new W(n,o,n.path,[c,"key"])),value:s._parse(new W(n,u,n.path,[c,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of i){const c=await u.key,d=await u.value;if(c.status==="aborted"||d.status==="aborted")return _;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),o.set(c.value,d.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const u of i){const c=u.key,d=u.value;if(c.status==="aborted"||d.status==="aborted")return _;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),o.set(c.value,d.value)}return{status:t.value,value:o}}}}lt.create=(r,e,t)=>new lt({valueType:e,keyType:r,typeName:v.ZodMap,...x(t)});class de extends k{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.set)return f(n,{code:l.invalid_type,expected:p.set,received:n.parsedType}),_;const a=this._def;a.minSize!==null&&n.data.size<a.minSize.value&&(f(n,{code:l.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),a.maxSize!==null&&n.data.size>a.maxSize.value&&(f(n,{code:l.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());const s=this._def.valueType;function i(u){const c=new Set;for(const d of u){if(d.status==="aborted")return _;d.status==="dirty"&&t.dirty(),c.add(d.value)}return{status:t.value,value:c}}const o=[...n.data.values()].map((u,c)=>s._parse(new W(n,u,n.path,c)));return n.common.async?Promise.all(o).then(u=>i(u)):i(o)}min(e,t){return new de({...this._def,minSize:{value:e,message:y.toString(t)}})}max(e,t){return new de({...this._def,maxSize:{value:e,message:y.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:v.ZodSet,...x(e)});class ft extends k{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})}}ft.create=(r,e)=>new ft({getter:r,typeName:v.ZodLazy,...x(e)});class ht extends k{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return f(t,{received:t.data,code:l.invalid_literal,expected:this._def.value}),_}return{status:"valid",value:e.data}}get value(){return this._def.value}}ht.create=(r,e)=>new ht({value:r,typeName:v.ZodLiteral,...x(e)});function Ot(r,e){return new te({values:r,typeName:v.ZodEnum,...x(e)})}class te extends k{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return f(t,{expected:w.joinValues(n),received:t.parsedType,code:l.invalid_type}),_}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return f(t,{received:t.data,code:l.invalid_enum_value,options:n}),_}return P(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 te.create(e,{...this._def,...t})}exclude(e,t=this._def){return te.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}te.create=Ot;class mt extends k{_parse(e){const t=w.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==p.string&&n.parsedType!==p.number){const a=w.objectValues(t);return f(n,{expected:w.joinValues(a),received:n.parsedType,code:l.invalid_type}),_}if(this._cache||(this._cache=new Set(w.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const a=w.objectValues(t);return f(n,{received:n.data,code:l.invalid_enum_value,options:a}),_}return P(e.data)}get enum(){return this._def.values}}mt.create=(r,e)=>new mt({values:r,typeName:v.ZodNativeEnum,...x(e)});class ve extends k{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.promise&&t.common.async===!1)return f(t,{code:l.invalid_type,expected:p.promise,received:t.parsedType}),_;const n=t.parsedType===p.promise?t.data:Promise.resolve(t.data);return P(n.then(a=>this._def.type.parseAsync(a,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ve.create=(r,e)=>new ve({type:r,typeName:v.ZodPromise,...x(e)});class re extends k{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===v.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),a=this._def.effect||null,s={addIssue:i=>{f(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),a.type==="preprocess"){const i=a.transform(n.data,s);if(n.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return _;const u=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return u.status==="aborted"?_:u.status==="dirty"||t.value==="dirty"?ie(u.value):u});{if(t.value==="aborted")return _;const o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?_:o.status==="dirty"||t.value==="dirty"?ie(o.value):o}}if(a.type==="refinement"){const i=o=>{const u=a.refinement(o,s);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?_:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?_:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(a.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ee(i))return _;const o=a.transform(i.value,s);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:n.data,path:n.path,parent:n}).then(i=>ee(i)?Promise.resolve(a.transform(i.value,s)).then(o=>({status:t.value,value:o})):_);w.assertNever(a)}}re.create=(r,e,t)=>new re({schema:r,typeName:v.ZodEffects,effect:e,...x(t)});re.createWithPreprocess=(r,e,t)=>new re({schema:e,effect:{type:"preprocess",transform:r},typeName:v.ZodEffects,...x(t)});class B extends k{_parse(e){return this._getType(e)===p.undefined?P(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}B.create=(r,e)=>new B({innerType:r,typeName:v.ZodOptional,...x(e)});class ne extends k{_parse(e){return this._getType(e)===p.null?P(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ne.create=(r,e)=>new ne({innerType:r,typeName:v.ZodNullable,...x(e)});class Ee extends k{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===p.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Ee.create=(r,e)=>new Ee({innerType:r,typeName:v.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...x(e)});class je extends k{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return pe(a)?a.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new q(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new q(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}je.create=(r,e)=>new je({innerType:r,typeName:v.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...x(e)});class pt extends k{_parse(e){if(this._getType(e)!==p.nan){const n=this._getOrReturnCtx(e);return f(n,{code:l.invalid_type,expected:p.nan,received:n.parsedType}),_}return{status:"valid",value:e.data}}}pt.create=r=>new pt({typeName:v.ZodNaN,...x(r)});class Tr extends k{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class Pe extends k{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?_:s.status==="dirty"?(t.dirty(),ie(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const a=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?_:a.status==="dirty"?(t.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:n.path,parent:n})}}static create(e,t){return new Pe({in:e,out:t,typeName:v.ZodPipeline})}}class Ae extends k{_parse(e){const t=this._def.innerType._parse(e),n=a=>(ee(a)&&(a.value=Object.freeze(a.value)),a);return pe(t)?t.then(a=>n(a)):n(t)}unwrap(){return this._def.innerType}}Ae.create=(r,e)=>new Ae({innerType:r,typeName:v.ZodReadonly,...x(e)});var v;(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"})(v||(v={}));const Or=z.create,U=Se.create;J.create;const Ct=F.create,Ie=S.create,St=ge.create;_e.create;const Cr=G.create;te.create;ve.create;B.create;ne.create;const Y=_,Sr="Required field";function K(r){let e;if(typeof r=="string")try{e=JSON.parse(r)}catch{e=r}else e=r;if(typeof e=="string")return e;if(m.isArray(e))return K(e[0]);const t=e;return m.isObject(t)&&(t!=null&&t.message)?e==null?void 0:e.message:"Unknown error"}function Rt(r,e,t){let n={};if(he(n,r.inputs,e,t),t!=null&&t.prefix){const s=t==null?void 0:t.prefix.replace(/.$/,"");n=m.set({},s,n)}return Ie(oe(n,e,t))}function Rr(r,e,t){const n=Object.keys(r).filter(i=>/^\d+$/.test(i)&&!i.startsWith("_")).map(i=>parseInt(i,10)).sort((i,o)=>i-o);if(n.length===0)return null;const a=Math.max(...n),s=[];for(let i=0;i<=a;i++)if(n.includes(i)){const o=r[i],u=oe({item:o},e,t);s.push(u.item||U().optional())}else s.push(U().optional());return Cr(s).rest(U()).optional()}function oe(r,e,t){const n={};return Object.keys(r).forEach(a=>{const{_requiredOnly:s,_schemaObj:i,_input:o,_isList:u,_isArrayItem:c,_isTuple:d,_schema:g}=r[a];if(d&&!u&&!c){const h=Rr(r[a],e,t);if(h){n[a]=h;return}}if(u&&i&&o){const h=Ie(oe(i,e,t)),b=St([Ct(h).optional(),Et(o,t)]),E=yt(g,o,e,t,b);n[a]=E}else if(c&&o){const h=i!=null&&i.___array?oe({___array:i.___array},e,t):{___array:U()},b=Er(h,o,t),E=yt(g,o,e,t,b);n[a]=E}else if(g&&o){const h=jr(g,o,e,t);n[a]=h}else s&&o?n[a]=Ze(o,t):n[a]=Ie(oe(r[a],e,t)).optional()}),n}function Et(r,e){return Or().superRefine((t,n)=>{var a;if((a=e==null?void 0:e.validationConfig)!=null&&a.globalValidation){const s=e.validationConfig.globalValidation(t,r,e.metadata);if(s.error)return n.addIssue({code:l.custom,message:s.error}),!1;if(!s.continue)return!0}return!0})}function Er(r,e,t){return St([Ct(r.___array).optional(),Et(e,t)])}function jr(r,e,t,n){return U().optional().superRefine(async(a,s)=>{var o,u;if(e.required&&!(await Ze(e,n).safeParseAsync(a)).success)return s.addIssue({code:l.custom,message:Ne(e,n)}),Y;if((o=n==null?void 0:n.validationConfig)!=null&&o.globalValidation){const c=(u=n==null?void 0:n.validationConfig)==null?void 0:u.globalValidation(a,e,n.metadata);if(c.error)return s.addIssue({code:l.custom,message:c.error}),Y;if(!c.continue)return!0}const i=jt(r,t);if(i){const c=await i.safeParseAsync(a);if(!c.success){const d=K(c==null?void 0:c.error.message),g=d==="Required"?Ne(e,n):d;s.addIssue({code:l.custom,message:g})}}})}function yt(r,e,t,n,a){return U().optional().superRefine(async(s,i)=>{var d,g;const u=await Ze(e,n).safeParseAsync(s);if(e.required&&!u.success){const h=K(u.error.message);return i.addIssue({code:l.custom,message:h,fatal:!0}),Y}if(!e.required&&!u.success)return Y;if((d=n==null?void 0:n.validationConfig)!=null&&d.globalValidation){const h=(g=n==null?void 0:n.validationConfig)==null?void 0:g.globalValidation(s,e,n.metadata);if(h.error)return i.addIssue({code:l.custom,message:K(h.error)}),Y;if(!h.continue)return!0}if(!m.isArray(s))return i.addIssue({code:l.custom,message:"'Value is not array'"}),Y;const c=jt(r,t);if(c){const h=await c.safeParseAsync(s);if(!h.success)return i.addIssue({code:l.custom,message:K(h.error.message)}),Y}}).pipe(a??U())}function he(r,e,t,n,a){e.forEach(s=>{var o,u,c,d,g,h,b;const i=t;if(!s.isVisible||(o=s.isVisible)!=null&&o.call(s,i,n==null?void 0:n.metadata)){const E=m.get(r,s.path);if((u=s.validation)!=null&&u.schema?m.set(r,s.path,m.merge(E,{_schema:(c=s.validation)==null?void 0:c.schema,_input:s})):s.required&&m.set(r,s.path,m.merge(E,{_requiredOnly:!0,_input:s})),s.inputs&&he(r,s.inputs,t,n),s.inputType==="list"){const T={};he(T,(g=(d=s.inputConfig)==null?void 0:d.inputs)==null?void 0:g.map(C=>({...C,path:C.relativePath})),t,n);const j=m.get(r,s.path);m.set(r,s.path,m.merge(j,{_schemaObj:T,_isList:!0,_input:s}))}if(!((h=s.validation)!=null&&h.schema)&&s.inputType==="array"){const T={};he(T,[{...s.inputConfig.input,path:"___array"}],t,n),m.set(r,s.path,m.merge(E,{_schemaObj:T,_schema:(b=s.validation)==null?void 0:b.schema,_isArrayItem:!0,_input:s}))}}}),e.forEach(s=>{var o;const i=t;if((!s.isVisible||(o=s.isVisible)!=null&&o.call(s,i,n==null?void 0:n.metadata))&&s.path){const u=s.path.split(".");u.forEach((c,d)=>{if(d>0&&/^\d+$/.test(c)){const g=u.slice(0,d).join("."),h=g?m.get(r,g):r;h&&typeof h=="object"&&(h._isTuple=!0)}})}})}function Ne(r,e){var t,n,a;return((n=(t=e==null?void 0:e.validationConfig)==null?void 0:t.requiredMessagePerInput)==null?void 0:n[r.inputType])??((a=e==null?void 0:e.validationConfig)==null?void 0:a.requiredMessage)??Sr}function Ze(r,e){var n,a,s,i,o,u;if((a=(n=e==null?void 0:e.validationConfig)==null?void 0:n.requiredSchemaPerInput)!=null&&a[r.inputType])return(i=(s=e==null?void 0:e.validationConfig)==null?void 0:s.requiredSchemaPerInput)==null?void 0:i[r.inputType];if((o=e==null?void 0:e.validationConfig)!=null&&o.requiredSchema)return(u=e==null?void 0:e.validationConfig)==null?void 0:u.requiredSchema;const t=Ne(r,e);return U().optional().superRefine((c,d)=>{typeof c=="object"&&m.isEmpty(c)&&d.addIssue({code:l.custom,message:t}),(m.isUndefined(c)||c==="")&&d.addIssue({code:l.custom,message:t})})}function jt(r,e){if(r instanceof k)return r;if(typeof r=="function")return r(e)}const Ar=r=>Array.isArray(r==null?void 0:r.errors),Ir=(r,e)=>{const t={};for(;r.length;){const n=r[0],{code:a,message:s,path:i}=n,o=i.join(".");if(!t[o])if("unionErrors"in n){const u=n.unionErrors[0].errors[0];t[o]={message:u.message,type:u.code}}else t[o]={message:s,type:a};"unionErrors"in n&&n.unionErrors.forEach(u=>u.errors.forEach(c=>r.push(c)));{const u=t[o].types,c=u&&u[n.code];t[o]=A.appendErrors(o,e,t,a,c?[].concat(c,n.message):n.message)}r.shift()}return t};function Nr(r,e){return O.useCallback(async(t,n,a)=>{try{return await Rt(r,t,e).parseAsync(t),{values:t,errors:{}}}catch(s){if(Ar(s))return{values:{},errors:qt.toNestErrors(Ir(s.errors,!0),a)};throw s}},[r,e])}const Te=(r,e)=>r.level!==e.level?r.level-e.level:r.isPrimitive?1:-1,Oe=(r,e)=>r.level!==e.level?e.level-r.level:r.isPrimitive?-1:1;function me(r,e,t){m.get(r,e)===void 0&&t===void 0||m.set(r,e,t)}function At(r,e){const t=m.cloneDeep(r),n=e.filter(o=>o.inputPriority==="early"),a=e.filter(o=>o.inputPriority==="normal"),s=e.filter(o=>o.inputPriority==="late");return n.sort(Te),a.sort(Te),s.sort(Te),[...n,...a,...s].forEach(o=>{if(o.inputTransform){const u=m.isArray(o.inputTransform)?o.inputTransform:[o.inputTransform];let c;const d=o.path.split(".");if(d.length>1){const g=d.slice(0,-1).join("."),h=m.get(t,g);typeof h=="string"||typeof h=="number"||typeof h=="boolean"?c=void 0:c=m.get(t,o.path)}else c=m.get(t,o.path);u.forEach(g=>{const h=g(c,t);h&&(c=h.value,me(t,h.path??o.path,h.value))})}}),t}function It(r,e,t){const n=e.filter(d=>d.outputPriority==="early"),a=e.filter(d=>d.outputPriority==="normal"),s=e.filter(d=>d.outputPriority==="late");n.sort(Oe),a.sort(Oe),s.sort(Oe);const i=[...n,...a,...s],o=[];let u={};t||(u=m.cloneDeep(r));const c=m.cloneDeep(r);return i.forEach(d=>{if(d.outputTransform){const g=m.isArray(d.outputTransform)?d.outputTransform:[d.outputTransform];let h=m.get(c,d.path);g.forEach(b=>{const E=m.get(u,d.path),T=b(h,c,E,u);if(T)if(h=T.value,T.path){if(T.merge){const j=m.get(u,T.path);let C;j?C=m.merge({},j,T.value):C=T.value,me(u,T.path,C)}else me(u,T.path,T.value);T.unset&&o.push(d.path)}else me(u,d.path,T.value)})}}),o.forEach(d=>{m.unset(u,d)}),u}function $e(r){return r.reduce((t,n)=>Array.isArray(n.inputs)?[...t,n,...$e(n.inputs)]:[...t,n],[])}const Vr=r=>{if(r!==void 0)return{value:r}},Pr=r=>{if(r!==void 0)return{value:r}};function Fe(r,e){return $e(r.inputs).reduce((a,s)=>{var h,b;const i=s.inputType==="text"||s.inputType==="boolean"||s.inputType==="number"||s.inputType==="textarea"||s.inputType==="select",o=!!s.inputTransform,u=!!s.outputTransform,c=Array.isArray(s.inputs)&&s.inputs.length>0,d=s.inputType==="list"||s.inputType==="array";return o||u?a.push({path:s.path,inputTransform:s.inputTransform,outputTransform:s.outputTransform,level:s.path.split(".").length,isPrimitive:i,inputPriority:((h=s.transformerPriority)==null?void 0:h.input)??"normal",outputPriority:((b=s.transformerPriority)==null?void 0:b.output)??"normal"}):e&&!(c||d)&&a.push({path:s.path,inputTransform:Vr,outputTransform:Pr,level:s.path.split(".").length,isPrimitive:i,inputPriority:"normal",outputPriority:"normal"}),a},[])}function Nt(r,e,t,n={}){const{preserve:a}=n,s=$e(r.inputs),i=m.cloneDeep(e);return s.forEach(o=>{a&&a.includes(o.path)||o.isVisible&&!o.isVisible(e,t)&&m.unset(i,o.path)}),i}function Zr(r,e){const t=Fe(e);return At(r,t)}function $r(r,e,t,n={}){const a=n.cleanOutput,s=Fe(e,a);let i=Nt(e,r,t,n);return i=It(i,s,n.cleanOutput),i=kt(i),i}function Fr(r){const e={},t=n=>{n.forEach(a=>{const{default:s,path:i,inputs:o}=a;Array.isArray(o)?t(o):s!==void 0&&m.set(e,i,s)})};return Array.isArray(r.inputs)&&t(r.inputs),e}function Mr(){return function(r,e){if(!(typeof r>"u"))return!r||!m.isPlainObject(r)?{value:r}:{value:Object.getOwnPropertyNames(r).map(t=>({key:t,value:r[t]}))}}}function Dr(r){return function(e){if(typeof e>"u")return;if(!e||!m.isArray(e))return{value:e};const t={value:e.reduce((n,a)=>({...n,[a.key]:r!=null&&r.assignKeyToValue?a.key:a.value??(r==null?void 0:r.fallbackValue)}),{})};return r!=null&&r.unsetIfEmpty&&Object.getOwnPropertyNames(t.value).length===0?{value:void 0}:t}}function qr(){return function(r){if(!(typeof r>"u"))return m.isArray(r)&&m.isEmpty(r)?{value:void 0}:{value:r}}}function Lr(r,e){return function(t,n,a,s){let i;if(r?i=m.get(e&&s?s:n,r):i=e?a:t,!(typeof i>"u")){if(m.isNull(i))return{value:void 0,path:r};if(m.isObject(i)){const o=Pt(m.cloneDeep(i));return Object.getOwnPropertyNames(o).length===0?{value:void 0,path:r}:void 0}return{value:i,path:r}}}}function zr(){return function(r){if(!(typeof r>"u"))return m.isString(r)&&m.isEmpty(r)?{value:void 0}:{value:r}}}function Br(r){return function(e,t){const n=m.get(t,r);if(typeof n=="string")return{value:n};if(!(typeof n=="number"||typeof n=="boolean")&&e!==void 0)return{value:e}}}function Ur(r){return function(e,t,n,a){if(typeof e>"u")return;if(!e)return{value:e};const s=m.get(a||t,r);if(typeof s=="object"){const i=Pt(s);if(Object.getOwnPropertyNames(i).length===1)return{value:e,path:r}}return{value:e}}}function Wr(r){return function(e,t){const n=m.get(t,r);if(typeof n=="string")return{value:[n]};if(!(typeof n=="number"||typeof n=="boolean")&&e!==void 0)return{value:e}}}function Jr(r,e){return function(t,n){if(typeof t>"u")return;if(!t)return{value:t};const a=m.get(n,r);if(m.isArray(a)){if(a.length===1)return{value:a[0],path:r};if(a.length===0&&e!=null&&e.unsetIfEmpty)return{value:void 0,path:r}}return{value:t}}}function Vt(r){return m.isNil(r)?!0:m.isArray(r)?r.length===0:typeof r=="object"?!Object.getOwnPropertyNames(r).some(e=>!Vt(r[e])):m.isUndefined(r)}function Pt(r){return m.omitBy(r,e=>typeof e=="object"?Vt(e):m.isUndefined(e))}function be(r){const{items:e,className:t,withoutWrapper:n=!0,...a}=r,s=e.map(i=>R.jsx(bt,{input:i,path:i.path,...a},`${i.inputType}_${i.path}`));return n?R.jsx(R.Fragment,{children:s}):R.jsx("div",{className:t,children:s})}be.displayName="RenderInputs";const Zt=O.forwardRef((r,e)=>{const{inputs:t,className:n,factory:a,withoutWrapper:s}=r;return s?R.jsxs(O.Fragment,{children:[t.hero,R.jsx(be,{items:t.inputs,factory:a})]}):R.jsxs("div",{className:n,ref:e,children:[t.hero,R.jsx(be,{items:t.inputs,factory:a})]})});Zt.displayName="RenderForm";function Hr(r){let e=!0;return m.forOwn(r,t=>{e=e&&(t===""||m.isNull(t)||m.isUndefined(t))}),e}const Yr=(r="")=>m.capitalize(r.split("_").join(" ")),$t=(r,e=2,t,n=1e3)=>{let a=!1;const s=()=>{requestAnimationFrame(()=>{a||(e-=1,e<=0?r():s())})};return t&&Date.now()-t<=n?(r(),()=>{}):(s(),()=>{a=!0})};function Gr(r,e){return{...r,inputs:r.inputs.map(t=>D(t,e))}}function D(r,e){var u,c,d;const{override:t,...n}=r,a=e&&t?t[e]:void 0,{inputConfig:s,...i}=a||{},o=a?{...n,...i}:n;if((n.inputConfig||s)&&(o.inputConfig={...n.inputConfig,...s}),o.inputs&&(o.inputs=o.inputs.map(g=>D(g,e))),o.inputType==="list"&&o.inputConfig){const g=((u=n.inputConfig)==null?void 0:u.inputs)||[],h=(s==null?void 0:s.inputs)||[];if(g.length>0||h.length>0){const b=Math.max(g.length,h.length);o.inputConfig.inputs=Array.from({length:b},(E,T)=>{var Z;const j=g[T],C=h[T];if(!j&&C)return D(C,e);if(j&&!C)return D(j,e);if(j&&C){const $=j.override?{...j.override}:{};return e&&C&&($[e]=(Z=j.override)!=null&&Z[e]?{...j.override[e],...C}:C),D({...j,override:$},e)}}).filter(Boolean)}else o.inputConfig.inputs&&(o.inputConfig.inputs=o.inputConfig.inputs.map(b=>D(b,e)))}if(o.inputType==="array"&&o.inputConfig){const g=(c=n.inputConfig)==null?void 0:c.input,h=s==null?void 0:s.input;if(g&&h){const b=g.override?{...g.override}:{};e&&h&&(b[e]=(d=g.override)!=null&&d[e]?{...g.override[e],...h}:h),o.inputConfig.input=D({...g,override:b},e)}else o.inputConfig.input&&(o.inputConfig.input=D(o.inputConfig.input,e))}return o}function Qr(r){const{field:{onBlur:e,...t},...n}=A.useController(r),a=O.useRef(Date.now());return{...n,field:{...t,onBlur:$t(e,2,a.current)}}}Object.defineProperty(exports,"Controller",{enumerable:!0,get:()=>A.Controller});Object.defineProperty(exports,"Form",{enumerable:!0,get:()=>A.Form});Object.defineProperty(exports,"FormProvider",{enumerable:!0,get:()=>A.FormProvider});Object.defineProperty(exports,"get",{enumerable:!0,get:()=>A.get});Object.defineProperty(exports,"set",{enumerable:!0,get:()=>A.set});Object.defineProperty(exports,"useFieldArray",{enumerable:!0,get:()=>A.useFieldArray});Object.defineProperty(exports,"useForm",{enumerable:!0,get:()=>A.useForm});Object.defineProperty(exports,"useFormContext",{enumerable:!0,get:()=>A.useFormContext});Object.defineProperty(exports,"useFormState",{enumerable:!0,get:()=>A.useFormState});Object.defineProperty(exports,"useWatch",{enumerable:!0,get:()=>A.useWatch});exports.InputComponent=Jt;exports.InputComponentRenderer=bt;exports.InputFactory=Ve;exports.InputOverrideError=gt;exports.RenderForm=Zt;exports.RenderInputs=be;exports.RootForm=Ht;exports.afterFrames=$t;exports.applyFormOverrides=Gr;exports.applyInputOverride=D;exports.arrayToObjectOutputTransformer=Dr;exports.collectDefaultValues=Fr;exports.convertDataToFormModel=Zr;exports.convertFormModelToData=$r;exports.generateReadableLabel=Yr;exports.getDefaultValuesFromFormDefinition=Yt;exports.getTemporaryPath=Xt;exports.getTransformers=Fe;exports.getValidationSchema=Rt;exports.inputTransformValues=At;exports.isChildrenEmpty=Hr;exports.objectToArrayInputTransformer=Mr;exports.outputTransformValues=It;exports.overrideFormDefinition=Gt;exports.processValidationParseResponse=K;exports.removeTemporaryFieldsValue=kt;exports.shorthandArrayInputTransformer=Wr;exports.shorthandArrayOutputTransformer=Jr;exports.shorthandObjectInputTransformer=Br;exports.shorthandObjectOutputTransformer=Ur;exports.unsetEmptyArrayOutputTransformer=qr;exports.unsetEmptyObjectOutputTransformer=Lr;exports.unsetEmptyStringOutputTransformer=zr;exports.unsetHiddenInputsValues=Nt;exports.useController=Qr;exports.useRootFormContext=vt;exports.useZodValidationResolver=Nr;
12
+ */var Xe;function zt(){if(Xe)return Q;Xe=1,Lt();var r=O,e=60103;if(Q.Fragment=60107,typeof Symbol=="function"&&Symbol.for){var t=Symbol.for;e=t("react.element"),Q.Fragment=t("react.fragment")}var n=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a=Object.prototype.hasOwnProperty,s={key:!0,ref:!0,__self:!0,__source:!0};function i(o,u,c){var d,g={},h=null,b=null;c!==void 0&&(h=""+c),u.key!==void 0&&(h=""+u.key),u.ref!==void 0&&(b=u.ref);for(d in u)a.call(u,d)&&!s.hasOwnProperty(d)&&(g[d]=u[d]);if(o&&o.defaultProps)for(d in u=o.defaultProps,u)g[d]===void 0&&(g[d]=u[d]);return{$$typeof:e,type:o,key:h,ref:b,props:g,_owner:n.current}}return Q.jsx=i,Q.jsxs=i,Q}var Ke;function Bt(){return Ke||(Ke=1,xe.exports=zt()),xe.exports}var R=Bt();const bt=O.createContext({});function Ut({children:r,metadata:e,inputErrorHandler:t,readonly:n}){return R.jsx(bt.Provider,{value:{metadata:e,readonly:n,inputErrorHandler:t},children:r})}function xt(){const r=O.useContext(bt);return r||console.warn("useRootFormContext must be used within RootFormProvider"),r}class Wt extends O.Component{constructor(){super(...arguments);fe(this,"state",{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t,n){var s,i;console.error(t,n);const a=new Error(`Form input [${this.props.inputType}] has failed at path [${this.props.path}]. Error: ${t}, Error info: ${n}`);(i=(s=this.props).inputErrorHandler)==null||i.call(s,a)}render(){return this.state.hasError?R.jsx(R.Fragment,{}):this.props.children}}const et=({children:r,withoutWrapper:e=!1})=>e||!r?r:R.jsx("div",{children:r}),kt=O.memo(function({path:e,factory:t,onUpdate:n,onChange:a,initialValues:s,input:i,withoutWrapper:o=!1}){var ze,Be,Ue,We,Je;const u=A.useFormContext(),{formState:c}=u,{fixedValues:d={}}={},{metadata:g,readonly:h,inputErrorHandler:b}=xt(),E=t==null?void 0:t.getComponent(i.inputType),T=!!(i.isVisible||typeof i.disabled=="function"||typeof((ze=i.validation)==null?void 0:ze.schema)=="function"||typeof((Be=i.warning)==null?void 0:Be.schema)=="function"),j=!!((Ue=i.warning)!=null&&Ue.schema||(We=i.validation)!=null&&We.schema),C=T?u.watch():{},Z=j?T?A.get(C,i.path):u.watch(i.path):void 0,$=O.useMemo(()=>{if(!T)return{};let se=C;return d&&Object.keys(d).forEach(le=>{const ae=d[le];se=m.set(se,le,ae)}),se},[T,C,d]),H=!i.isVisible||i.isVisible($,g),I=h||i.readonly,M=typeof i.disabled=="function"?i.disabled($,g):i.disabled,V=(Je=i.warning)==null?void 0:Je.schema,qe=O.useMemo(()=>{var Ye,Ge;if(!H||typeof V>"u")return;const se=typeof V=="function"?V($,g):V,{success:le,error:ae}=se.safeParse(Z),He=(Ge=(Ye=ae==null?void 0:ae.errors)==null?void 0:Ye[0])==null?void 0:Ge.message;return!le&&He?He:void 0},[i.path,Z,V,H,g]),Le=O.useMemo(()=>({path:e,key:e,initialValues:s,onUpdate:n,onChange:a,factory:t,readonly:I,input:i,disabled:M,warning:qe}),[t,s,i,a,n,e,I,c.errors,M,qe]),Ft=O.useMemo(()=>H?R.jsxs(R.Fragment,{children:[i.before?i.before:null,R.jsx(Wt,{path:e,inputType:i.inputType,inputErrorHandler:b,children:E==null?void 0:E.renderComponent(Le)}),i.after?i.after:null]}):null,[H,i.before,i.inputType,i.after,e,E,Le,c.errors]);return E?R.jsx(et,{withoutWrapper:o,children:Ft}):R.jsx(et,{withoutWrapper:o,children:R.jsxs("p",{children:["Input component not found (internal type: ",i.inputType,")"]})})});class Jt{getType(){return this.internalType}}function tt(){return typeof window<"u"&&"requestIdleCallback"in window?window.requestIdleCallback:function(r,e){const t=Date.now(),n=(e==null?void 0:e.timeout)||1;return setTimeout(function(){r({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-t))}})},n)}}function rt(){return typeof window<"u"&&"cancelIdleCallback"in window?window.cancelIdleCallback:clearTimeout}function Ht(r){const{mode:e="onSubmit",resolver:t,defaultValues:n,shouldFocusError:a,onValuesChange:s,onValidationChange:i,onSubmit:o,onInputRenderError:u,metadata:c,children:d,autoFocusPath:g,readonly:h}=r,b=A.useForm({mode:e,reValidateMode:"onChange",defaultValues:n,shouldFocusError:a,resolver:t}),E=O.useRef(!1),T=O.useRef(JSON.stringify(n??{}));O.useEffect(()=>{T.current=JSON.stringify(n??{}),b.reset(n,{})},[b.reset,n]),O.useEffect(()=>{const I=tt(),M=rt(),V=I(()=>{b.reset({},{keepErrors:!0,keepDirty:!0,keepDirtyValues:!0,keepValues:!0,keepDefaultValues:!1,keepIsSubmitted:!0,keepTouched:!0,keepIsValid:!0,keepSubmitCount:!0})});return()=>M(V)},[]);const{handleSubmit:j}=b,C=O.useRef(s);O.useEffect(()=>{C.current=s},[s]);const Z=O.useRef(i);O.useEffect(()=>{Z.current=i},[i]);const $=O.useRef(!1);O.useEffect(()=>{const I=b.watch(M=>{var V;$.current||JSON.stringify(M??{})!==T.current&&((V=C.current)==null||V.call(C,{...M}),E.current===!0&&($.current=!0,b.trigger().finally(()=>{$.current=!1})))});return()=>{I.unsubscribe()}},[b]);const H=O.useRef(!0);return O.useEffect(()=>{var I;if(H.current){H.current=!1;return}(I=Z.current)==null||I.call(Z,{isValid:b.formState.isValid,isSubmitted:b.formState.isSubmitted})},[b.formState.isValid,b.formState.isSubmitted]),O.useEffect(()=>{if(g){const I=tt(),M=rt(),V=I(()=>{b.setFocus(g)});return()=>M(V)}},[b,g]),R.jsx(Ut,{metadata:c,readonly:h,inputErrorHandler:u,children:R.jsx(A.FormProvider,{...b,children:typeof d=="function"?d({...b,submitForm:async()=>{o&&(E.current=!0,j(I=>{o(I)})())}}):d})})}const Yt=r=>{const e={},t=n=>{n.forEach(a=>{const{path:s,default:i,inputs:o}=a;Array.isArray(o)?t(o):m.get(e,s)===void 0&&m.set(e,s,i)})};return Array.isArray(r.inputs)&&t(r.inputs),e};function Gt(r,e){const t=r.inputs.map(n=>{const a=Qt(e,n.path);return a||n});return{...r,inputs:t}}function Qt(r,e){return r.inputs.find(t=>t.path===e)}const wt="__temp_",Xt=r=>wt+r.split(".").join("__");function Tt(r){const e={...r};return m.forOwn(e,(t,n)=>{n.startsWith(wt)&&delete e[n]}),e}var w;(function(r){r.assertEqual=a=>{};function e(a){}r.assertIs=e;function t(a){throw new Error}r.assertNever=t,r.arrayToEnum=a=>{const s={};for(const i of a)s[i]=i;return s},r.getValidEnumValues=a=>{const s=r.objectKeys(a).filter(o=>typeof a[a[o]]!="number"),i={};for(const o of s)i[o]=a[o];return r.objectValues(i)},r.objectValues=a=>r.objectKeys(a).map(function(s){return a[s]}),r.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const s=[];for(const i in a)Object.prototype.hasOwnProperty.call(a,i)&&s.push(i);return s},r.find=(a,s)=>{for(const i of a)if(s(i))return i},r.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function n(a,s=" | "){return a.map(i=>typeof i=="string"?`'${i}'`:i).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(a,s)=>typeof s=="bigint"?s.toString():s})(w||(w={}));var nt;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(nt||(nt={}));const p=w.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),L=r=>{switch(typeof r){case"undefined":return p.undefined;case"string":return p.string;case"number":return Number.isNaN(r)?p.nan:p.number;case"boolean":return p.boolean;case"function":return p.function;case"bigint":return p.bigint;case"symbol":return p.symbol;case"object":return Array.isArray(r)?p.array:r===null?p.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?p.promise:typeof Map<"u"&&r instanceof Map?p.map:typeof Set<"u"&&r instanceof Set?p.set:typeof Date<"u"&&r instanceof Date?p.date:p.object;default:return p.unknown}},l=w.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 q extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};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(s){return s.message},n={_errors:[]},a=s=>{for(const i of s.issues)if(i.code==="invalid_union")i.unionErrors.map(a);else if(i.code==="invalid_return_type")a(i.returnTypeError);else if(i.code==="invalid_arguments")a(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,u=0;for(;u<i.path.length;){const c=i.path[u];u===i.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(t(i))):o[c]=o[c]||{_errors:[]},o=o[c],u++}}};return a(this),n}static assert(e){if(!(e instanceof q))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,w.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t=Object.create(null),n=[];for(const a of this.issues)if(a.path.length>0){const s=a.path[0];t[s]=t[s]||[],t[s].push(e(a))}else n.push(e(a));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}q.create=r=>new q(r);const Ce=(r,e)=>{let t;switch(r.code){case l.invalid_type:r.received===p.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case l.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,w.jsonStringifyReplacer)}`;break;case l.unrecognized_keys:t=`Unrecognized key(s) in object: ${w.joinValues(r.keys,", ")}`;break;case l.invalid_union:t="Invalid input";break;case l.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${w.joinValues(r.options)}`;break;case l.invalid_enum_value:t=`Invalid enum value. Expected ${w.joinValues(r.options)}, received '${r.received}'`;break;case l.invalid_arguments:t="Invalid function arguments";break;case l.invalid_return_type:t="Invalid function return type";break;case l.invalid_date:t="Invalid date";break;case l.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}"`:w.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case l.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 l.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 l.custom:t="Invalid input";break;case l.invalid_intersection_types:t="Intersection results could not be merged";break;case l.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case l.not_finite:t="Number must be finite";break;default:t=e.defaultError,w.assertNever(r)}return{message:t}};let Kt=Ce;function er(){return Kt}const tr=r=>{const{data:e,path:t,errorMaps:n,issueData:a}=r,s=[...t,...a.path||[]],i={...a,path:s};if(a.message!==void 0)return{...a,path:s,message:a.message};let o="";const u=n.filter(c=>!!c).slice().reverse();for(const c of u)o=c(i,{data:e,defaultError:o}).message;return{...a,path:s,message:o}};function f(r,e){const t=er(),n=tr({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Ce?void 0:Ce].filter(a=>!!a)});r.common.issues.push(n)}class N{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const a of t){if(a.status==="aborted")return _;a.status==="dirty"&&e.dirty(),n.push(a.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const a of t){const s=await a.key,i=await a.value;n.push({key:s,value:i})}return N.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const a of t){const{key:s,value:i}=a;if(s.status==="aborted"||i.status==="aborted")return _;s.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof i.value<"u"||a.alwaysSet)&&(n[s.value]=i.value)}return{status:e.value,value:n}}}const _=Object.freeze({status:"aborted"}),ie=r=>({status:"dirty",value:r}),P=r=>({status:"valid",value:r}),st=r=>r.status==="aborted",at=r=>r.status==="dirty",ee=r=>r.status==="valid",pe=r=>typeof Promise<"u"&&r instanceof Promise;var y;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(y||(y={}));class W{constructor(e,t,n,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=a}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 it=(r,e)=>{if(ee(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 q(r.common.issues);return this._error=t,this._error}}};function x(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:a}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(i,o)=>{const{message:u}=r;return i.code==="invalid_enum_value"?{message:u??o.defaultError}:typeof o.data>"u"?{message:u??n??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:u??t??o.defaultError}},description:a}}class k{get description(){return this._def.description}_getType(e){return L(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:L(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new N,ctx:{common:e.parent.common,data:e.data,parsedType:L(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(pe(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 n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){const n={common:{issues:[],async:(t==null?void 0:t.async)??!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:L(e)},a=this._parseSync({data:e,path:n.path,parent:n});return it(n,a)}"~validate"(e){var n,a;const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:L(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:t});return ee(s)?{value:s.value}:{issues:t.common.issues}}catch(s){(a=(n=s==null?void 0:s.message)==null?void 0:n.toLowerCase())!=null&&a.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(s=>ee(s)?{value:s.value}:{issues:t.common.issues})}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:L(e)},a=this._parse({data:e,path:n.path,parent:n}),s=await(pe(a)?a:Promise.resolve(a));return it(n,s)}refine(e,t){const n=a=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(a):t;return this._refinement((a,s)=>{const i=e(a),o=()=>s.addIssue({code:l.custom,...n(a)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,a)=>e(n)?!0:(a.addIssue(typeof t=="function"?t(n,a):t),!1))}_refinement(e){return new re({schema:this,typeName:v.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 B.create(this,this._def)}nullable(){return ne.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return F.create(this)}promise(){return ve.create(this,this._def)}or(e){return ge.create([this,e],this._def)}and(e){return _e.create(this,e,this._def)}transform(e){return new re({...x(this._def),schema:this,typeName:v.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Ee({...x(this._def),innerType:this,defaultValue:t,typeName:v.ZodDefault})}brand(){return new Tr({typeName:v.ZodBranded,type:this,...x(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new je({...x(this._def),innerType:this,catchValue:t,typeName:v.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return $e.create(this,e)}readonly(){return Ae.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const rr=/^c[^\s-]{8,}$/i,nr=/^[0-9a-z]+$/,sr=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ar=/^[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,ir=/^[a-z0-9_-]{21}$/i,or=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ur=/^[-+]?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)?)??$/,cr=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,dr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let we;const lr=/^(?:(?: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])$/,fr=/^(?:(?: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])$/,hr=/^(([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]))$/,mr=/^(([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])$/,pr=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,yr=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ot="((\\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])))",gr=new RegExp(`^${Ot}$`);function Ct(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 _r(r){return new RegExp(`^${Ct(r)}$`)}function vr(r){let e=`${Ot}T${Ct(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 br(r,e){return!!((e==="v4"||!e)&&lr.test(r)||(e==="v6"||!e)&&hr.test(r))}function xr(r,e){if(!or.test(r))return!1;try{const[t]=r.split(".");if(!t)return!1;const n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),a=JSON.parse(atob(n));return!(typeof a!="object"||a===null||"typ"in a&&(a==null?void 0:a.typ)!=="JWT"||!a.alg||e&&a.alg!==e)}catch{return!1}}function kr(r,e){return!!((e==="v4"||!e)&&fr.test(r)||(e==="v6"||!e)&&mr.test(r))}class z extends k{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==p.string){const s=this._getOrReturnCtx(e);return f(s,{code:l.invalid_type,expected:p.string,received:s.parsedType}),_}const n=new N;let a;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:l.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:l.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){const i=e.data.length>s.value,o=e.data.length<s.value;(i||o)&&(a=this._getOrReturnCtx(e,a),i?f(a,{code:l.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&f(a,{code:l.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")cr.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"email",code:l.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")we||(we=new RegExp(dr,"u")),we.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"emoji",code:l.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")ar.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"uuid",code:l.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")ir.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"nanoid",code:l.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")rr.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cuid",code:l.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")nr.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cuid2",code:l.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")sr.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"ulid",code:l.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),f(a,{validation:"url",code:l.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"regex",code:l.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(a=this._getOrReturnCtx(e,a),f(a,{code:l.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(a=this._getOrReturnCtx(e,a),f(a,{code:l.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(a=this._getOrReturnCtx(e,a),f(a,{code:l.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?vr(s).test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:l.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?gr.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:l.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?_r(s).test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:l.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?ur.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"duration",code:l.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?br(e.data,s.version)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"ip",code:l.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?xr(e.data,s.alg)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"jwt",code:l.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?kr(e.data,s.version)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cidr",code:l.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?pr.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"base64",code:l.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?yr.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"base64url",code:l.invalid_string,message:s.message}),n.dirty()):w.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(a=>e.test(a),{validation:t,code:l.invalid_string,...y.errToObj(n)})}_addCheck(e){return new z({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...y.errToObj(e)})}url(e){return this._addCheck({kind:"url",...y.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...y.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...y.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...y.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...y.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...y.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...y.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...y.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...y.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...y.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...y.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...y.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==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...y.errToObj(e==null?void 0: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==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...y.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...y.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...y.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...y.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...y.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...y.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...y.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...y.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...y.errToObj(t)})}nonempty(e){return this.min(1,y.errToObj(e))}trim(){return new z({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new z({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new z({...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}}z.create=r=>new z({checks:[],typeName:v.ZodString,coerce:(r==null?void 0:r.coerce)??!1,...x(r)});function wr(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,a=t>n?t:n,s=Number.parseInt(r.toFixed(a).replace(".","")),i=Number.parseInt(e.toFixed(a).replace(".",""));return s%i/10**a}class ue extends k{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)!==p.number){const s=this._getOrReturnCtx(e);return f(s,{code:l.invalid_type,expected:p.number,received:s.parsedType}),_}let n;const a=new N;for(const s of this._def.checks)s.kind==="int"?w.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:l.invalid_type,expected:"integer",received:"float",message:s.message}),a.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:l.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),a.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:l.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),a.dirty()):s.kind==="multipleOf"?wr(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),f(n,{code:l.not_multiple_of,multipleOf:s.value,message:s.message}),a.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:l.not_finite,message:s.message}),a.dirty()):w.assertNever(s);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,y.toString(t))}setLimit(e,t,n,a){return new ue({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:y.toString(a)}]})}_addCheck(e){return new ue({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:y.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:y.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:y.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:y.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:y.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"&&w.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}ue.create=r=>new ue({checks:[],typeName:v.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...x(r)});class ce extends k{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)!==p.bigint)return this._getInvalidInput(e);let n;const a=new N;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:l.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),a.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:l.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),a.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),f(n,{code:l.not_multiple_of,multipleOf:s.value,message:s.message}),a.dirty()):w.assertNever(s);return{status:a.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return f(t,{code:l.invalid_type,expected:p.bigint,received:t.parsedType}),_}gte(e,t){return this.setLimit("min",e,!0,y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,y.toString(t))}setLimit(e,t,n,a){return new ce({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:y.toString(a)}]})}_addCheck(e){return new ce({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:y.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}}ce.create=r=>new ce({checks:[],typeName:v.ZodBigInt,coerce:(r==null?void 0:r.coerce)??!1,...x(r)});class ot extends k{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==p.boolean){const n=this._getOrReturnCtx(e);return f(n,{code:l.invalid_type,expected:p.boolean,received:n.parsedType}),_}return P(e.data)}}ot.create=r=>new ot({typeName:v.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...x(r)});class ye extends k{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==p.date){const s=this._getOrReturnCtx(e);return f(s,{code:l.invalid_type,expected:p.date,received:s.parsedType}),_}if(Number.isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return f(s,{code:l.invalid_date}),_}const n=new N;let a;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:l.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:l.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):w.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ye({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:y.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:y.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}}ye.create=r=>new ye({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:v.ZodDate,...x(r)});class ut extends k{_parse(e){if(this._getType(e)!==p.symbol){const n=this._getOrReturnCtx(e);return f(n,{code:l.invalid_type,expected:p.symbol,received:n.parsedType}),_}return P(e.data)}}ut.create=r=>new ut({typeName:v.ZodSymbol,...x(r)});class ct extends k{_parse(e){if(this._getType(e)!==p.undefined){const n=this._getOrReturnCtx(e);return f(n,{code:l.invalid_type,expected:p.undefined,received:n.parsedType}),_}return P(e.data)}}ct.create=r=>new ct({typeName:v.ZodUndefined,...x(r)});class dt extends k{_parse(e){if(this._getType(e)!==p.null){const n=this._getOrReturnCtx(e);return f(n,{code:l.invalid_type,expected:p.null,received:n.parsedType}),_}return P(e.data)}}dt.create=r=>new dt({typeName:v.ZodNull,...x(r)});class Se extends k{constructor(){super(...arguments),this._any=!0}_parse(e){return P(e.data)}}Se.create=r=>new Se({typeName:v.ZodAny,...x(r)});class lt extends k{constructor(){super(...arguments),this._unknown=!0}_parse(e){return P(e.data)}}lt.create=r=>new lt({typeName:v.ZodUnknown,...x(r)});class J extends k{_parse(e){const t=this._getOrReturnCtx(e);return f(t,{code:l.invalid_type,expected:p.never,received:t.parsedType}),_}}J.create=r=>new J({typeName:v.ZodNever,...x(r)});class ft extends k{_parse(e){if(this._getType(e)!==p.undefined){const n=this._getOrReturnCtx(e);return f(n,{code:l.invalid_type,expected:p.void,received:n.parsedType}),_}return P(e.data)}}ft.create=r=>new ft({typeName:v.ZodVoid,...x(r)});class F extends k{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),a=this._def;if(t.parsedType!==p.array)return f(t,{code:l.invalid_type,expected:p.array,received:t.parsedType}),_;if(a.exactLength!==null){const i=t.data.length>a.exactLength.value,o=t.data.length<a.exactLength.value;(i||o)&&(f(t,{code:i?l.too_big:l.too_small,minimum:o?a.exactLength.value:void 0,maximum:i?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),n.dirty())}if(a.minLength!==null&&t.data.length<a.minLength.value&&(f(t,{code:l.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),n.dirty()),a.maxLength!==null&&t.data.length>a.maxLength.value&&(f(t,{code:l.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>a.type._parseAsync(new W(t,i,t.path,o)))).then(i=>N.mergeArray(n,i));const s=[...t.data].map((i,o)=>a.type._parseSync(new W(t,i,t.path,o)));return N.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new F({...this._def,minLength:{value:e,message:y.toString(t)}})}max(e,t){return new F({...this._def,maxLength:{value:e,message:y.toString(t)}})}length(e,t){return new F({...this._def,exactLength:{value:e,message:y.toString(t)}})}nonempty(e){return this.min(1,e)}}F.create=(r,e)=>new F({type:r,minLength:null,maxLength:null,exactLength:null,typeName:v.ZodArray,...x(e)});function X(r){if(r instanceof S){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=B.create(X(n))}return new S({...r._def,shape:()=>e})}else return r instanceof F?new F({...r._def,type:X(r.element)}):r instanceof B?B.create(X(r.unwrap())):r instanceof ne?ne.create(X(r.unwrap())):r instanceof G?G.create(r.items.map(e=>X(e))):r}class S extends k{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=w.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==p.object){const c=this._getOrReturnCtx(e);return f(c,{code:l.invalid_type,expected:p.object,received:c.parsedType}),_}const{status:n,ctx:a}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof J&&this._def.unknownKeys==="strip"))for(const c in a.data)i.includes(c)||o.push(c);const u=[];for(const c of i){const d=s[c],g=a.data[c];u.push({key:{status:"valid",value:c},value:d._parse(new W(a,g,a.path,c)),alwaysSet:c in a.data})}if(this._def.catchall instanceof J){const c=this._def.unknownKeys;if(c==="passthrough")for(const d of o)u.push({key:{status:"valid",value:d},value:{status:"valid",value:a.data[d]}});else if(c==="strict")o.length>0&&(f(a,{code:l.unrecognized_keys,keys:o}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const d of o){const g=a.data[d];u.push({key:{status:"valid",value:d},value:c._parse(new W(a,g,a.path,d)),alwaysSet:d in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const c=[];for(const d of u){const g=await d.key,h=await d.value;c.push({key:g,value:h,alwaysSet:d.alwaysSet})}return c}).then(c=>N.mergeObjectSync(n,c)):N.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return y.errToObj,new S({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,i;const a=((i=(s=this._def).errorMap)==null?void 0:i.call(s,t,n).message)??n.defaultError;return t.code==="unrecognized_keys"?{message:y.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new S({...this._def,unknownKeys:"strip"})}passthrough(){return new S({...this._def,unknownKeys:"passthrough"})}extend(e){return new S({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new S({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:v.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new S({...this._def,catchall:e})}pick(e){const t={};for(const n of w.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new S({...this._def,shape:()=>t})}omit(e){const t={};for(const n of w.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new S({...this._def,shape:()=>t})}deepPartial(){return X(this)}partial(e){const t={};for(const n of w.objectKeys(this.shape)){const a=this.shape[n];e&&!e[n]?t[n]=a:t[n]=a.optional()}return new S({...this._def,shape:()=>t})}required(e){const t={};for(const n of w.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof B;)s=s._def.innerType;t[n]=s}return new S({...this._def,shape:()=>t})}keyof(){return St(w.objectKeys(this.shape))}}S.create=(r,e)=>new S({shape:()=>r,unknownKeys:"strip",catchall:J.create(),typeName:v.ZodObject,...x(e)});S.strictCreate=(r,e)=>new S({shape:()=>r,unknownKeys:"strict",catchall:J.create(),typeName:v.ZodObject,...x(e)});S.lazycreate=(r,e)=>new S({shape:r,unknownKeys:"strip",catchall:J.create(),typeName:v.ZodObject,...x(e)});class ge extends k{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function a(s){for(const o of s)if(o.result.status==="valid")return o.result;for(const o of s)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=s.map(o=>new q(o.ctx.common.issues));return f(t,{code:l.invalid_union,unionErrors:i}),_}if(t.common.async)return Promise.all(n.map(async s=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(a);{let s;const i=[];for(const u of n){const c={...t,common:{...t.common,issues:[]},parent:null},d=u._parseSync({data:t.data,path:t.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!s&&(s={result:d,ctx:c}),c.common.issues.length&&i.push(c.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const o=i.map(u=>new q(u));return f(t,{code:l.invalid_union,unionErrors:o}),_}}get options(){return this._def.options}}ge.create=(r,e)=>new ge({options:r,typeName:v.ZodUnion,...x(e)});function Re(r,e){const t=L(r),n=L(e);if(r===e)return{valid:!0,data:r};if(t===p.object&&n===p.object){const a=w.objectKeys(e),s=w.objectKeys(r).filter(o=>a.indexOf(o)!==-1),i={...r,...e};for(const o of s){const u=Re(r[o],e[o]);if(!u.valid)return{valid:!1};i[o]=u.data}return{valid:!0,data:i}}else if(t===p.array&&n===p.array){if(r.length!==e.length)return{valid:!1};const a=[];for(let s=0;s<r.length;s++){const i=r[s],o=e[s],u=Re(i,o);if(!u.valid)return{valid:!1};a.push(u.data)}return{valid:!0,data:a}}else return t===p.date&&n===p.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class _e extends k{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),a=(s,i)=>{if(st(s)||st(i))return _;const o=Re(s.value,i.value);return o.valid?((at(s)||at(i))&&t.dirty(),{status:t.value,value:o.data}):(f(n,{code:l.invalid_intersection_types}),_)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,i])=>a(s,i)):a(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}_e.create=(r,e,t)=>new _e({left:r,right:e,typeName:v.ZodIntersection,...x(t)});class G extends k{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.array)return f(n,{code:l.invalid_type,expected:p.array,received:n.parsedType}),_;if(n.data.length<this._def.items.length)return f(n,{code:l.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),_;!this._def.rest&&n.data.length>this._def.items.length&&(f(n,{code:l.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((i,o)=>{const u=this._def.items[o]||this._def.rest;return u?u._parse(new W(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(s).then(i=>N.mergeArray(t,i)):N.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new G({...this._def,rest:e})}}G.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new G({items:r,typeName:v.ZodTuple,rest:null,...x(e)})};class ht extends k{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.map)return f(n,{code:l.invalid_type,expected:p.map,received:n.parsedType}),_;const a=this._def.keyType,s=this._def.valueType,i=[...n.data.entries()].map(([o,u],c)=>({key:a._parse(new W(n,o,n.path,[c,"key"])),value:s._parse(new W(n,u,n.path,[c,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of i){const c=await u.key,d=await u.value;if(c.status==="aborted"||d.status==="aborted")return _;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),o.set(c.value,d.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const u of i){const c=u.key,d=u.value;if(c.status==="aborted"||d.status==="aborted")return _;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),o.set(c.value,d.value)}return{status:t.value,value:o}}}}ht.create=(r,e,t)=>new ht({valueType:e,keyType:r,typeName:v.ZodMap,...x(t)});class de extends k{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.set)return f(n,{code:l.invalid_type,expected:p.set,received:n.parsedType}),_;const a=this._def;a.minSize!==null&&n.data.size<a.minSize.value&&(f(n,{code:l.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),a.maxSize!==null&&n.data.size>a.maxSize.value&&(f(n,{code:l.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());const s=this._def.valueType;function i(u){const c=new Set;for(const d of u){if(d.status==="aborted")return _;d.status==="dirty"&&t.dirty(),c.add(d.value)}return{status:t.value,value:c}}const o=[...n.data.values()].map((u,c)=>s._parse(new W(n,u,n.path,c)));return n.common.async?Promise.all(o).then(u=>i(u)):i(o)}min(e,t){return new de({...this._def,minSize:{value:e,message:y.toString(t)}})}max(e,t){return new de({...this._def,maxSize:{value:e,message:y.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:v.ZodSet,...x(e)});class mt extends k{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})}}mt.create=(r,e)=>new mt({getter:r,typeName:v.ZodLazy,...x(e)});class pt extends k{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return f(t,{received:t.data,code:l.invalid_literal,expected:this._def.value}),_}return{status:"valid",value:e.data}}get value(){return this._def.value}}pt.create=(r,e)=>new pt({value:r,typeName:v.ZodLiteral,...x(e)});function St(r,e){return new te({values:r,typeName:v.ZodEnum,...x(e)})}class te extends k{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return f(t,{expected:w.joinValues(n),received:t.parsedType,code:l.invalid_type}),_}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return f(t,{received:t.data,code:l.invalid_enum_value,options:n}),_}return P(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 te.create(e,{...this._def,...t})}exclude(e,t=this._def){return te.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}te.create=St;class yt extends k{_parse(e){const t=w.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==p.string&&n.parsedType!==p.number){const a=w.objectValues(t);return f(n,{expected:w.joinValues(a),received:n.parsedType,code:l.invalid_type}),_}if(this._cache||(this._cache=new Set(w.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const a=w.objectValues(t);return f(n,{received:n.data,code:l.invalid_enum_value,options:a}),_}return P(e.data)}get enum(){return this._def.values}}yt.create=(r,e)=>new yt({values:r,typeName:v.ZodNativeEnum,...x(e)});class ve extends k{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.promise&&t.common.async===!1)return f(t,{code:l.invalid_type,expected:p.promise,received:t.parsedType}),_;const n=t.parsedType===p.promise?t.data:Promise.resolve(t.data);return P(n.then(a=>this._def.type.parseAsync(a,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ve.create=(r,e)=>new ve({type:r,typeName:v.ZodPromise,...x(e)});class re extends k{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===v.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),a=this._def.effect||null,s={addIssue:i=>{f(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),a.type==="preprocess"){const i=a.transform(n.data,s);if(n.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return _;const u=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return u.status==="aborted"?_:u.status==="dirty"||t.value==="dirty"?ie(u.value):u});{if(t.value==="aborted")return _;const o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?_:o.status==="dirty"||t.value==="dirty"?ie(o.value):o}}if(a.type==="refinement"){const i=o=>{const u=a.refinement(o,s);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?_:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?_:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(a.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ee(i))return _;const o=a.transform(i.value,s);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:n.data,path:n.path,parent:n}).then(i=>ee(i)?Promise.resolve(a.transform(i.value,s)).then(o=>({status:t.value,value:o})):_);w.assertNever(a)}}re.create=(r,e,t)=>new re({schema:r,typeName:v.ZodEffects,effect:e,...x(t)});re.createWithPreprocess=(r,e,t)=>new re({schema:e,effect:{type:"preprocess",transform:r},typeName:v.ZodEffects,...x(t)});class B extends k{_parse(e){return this._getType(e)===p.undefined?P(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}B.create=(r,e)=>new B({innerType:r,typeName:v.ZodOptional,...x(e)});class ne extends k{_parse(e){return this._getType(e)===p.null?P(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ne.create=(r,e)=>new ne({innerType:r,typeName:v.ZodNullable,...x(e)});class Ee extends k{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===p.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Ee.create=(r,e)=>new Ee({innerType:r,typeName:v.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...x(e)});class je extends k{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return pe(a)?a.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new q(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new q(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}je.create=(r,e)=>new je({innerType:r,typeName:v.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...x(e)});class gt extends k{_parse(e){if(this._getType(e)!==p.nan){const n=this._getOrReturnCtx(e);return f(n,{code:l.invalid_type,expected:p.nan,received:n.parsedType}),_}return{status:"valid",value:e.data}}}gt.create=r=>new gt({typeName:v.ZodNaN,...x(r)});class Tr extends k{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class $e extends k{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?_:s.status==="dirty"?(t.dirty(),ie(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const a=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?_:a.status==="dirty"?(t.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:n.path,parent:n})}}static create(e,t){return new $e({in:e,out:t,typeName:v.ZodPipeline})}}class Ae extends k{_parse(e){const t=this._def.innerType._parse(e),n=a=>(ee(a)&&(a.value=Object.freeze(a.value)),a);return pe(t)?t.then(a=>n(a)):n(t)}unwrap(){return this._def.innerType}}Ae.create=(r,e)=>new Ae({innerType:r,typeName:v.ZodReadonly,...x(e)});var v;(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"})(v||(v={}));const Or=z.create,U=Se.create;J.create;const Rt=F.create,Ie=S.create,Ne=ge.create;_e.create;const Cr=G.create;te.create;ve.create;B.create;ne.create;const Y=_,Sr="Required field";function K(r){let e;if(typeof r=="string")try{e=JSON.parse(r)}catch{e=r}else e=r;if(typeof e=="string")return e;if(m.isArray(e))return K(e[0]);const t=e;return m.isObject(t)&&(t!=null&&t.message)?e==null?void 0:e.message:"Unknown error"}function Et(r,e,t){let n={};if(he(n,r.inputs,e,t),t!=null&&t.prefix){const s=t==null?void 0:t.prefix.replace(/.$/,"");n=m.set({},s,n)}return Ie(oe(n,e,t))}function Rr(r,e,t){const n=Object.keys(r).filter(i=>/^\d+$/.test(i)&&!i.startsWith("_")).map(i=>parseInt(i,10)).sort((i,o)=>i-o);if(n.length===0)return null;const a=Math.max(...n),s=[];for(let i=0;i<=a;i++)if(n.includes(i)){const o=r[i],u=oe({item:o},e,t);s.push(u.item||U().optional())}else s.push(U().optional());return Cr(s).rest(U()).optional()}const Er=new Set(["_requiredOnly","_schemaObj","_input","_isList","_isArrayItem","_isTuple","_schema"]);function oe(r,e,t){const n={};return Object.keys(r).forEach(a=>{if(Er.has(a))return;const{_requiredOnly:s,_schemaObj:i,_input:o,_isList:u,_isArrayItem:c,_isTuple:d,_schema:g}=r[a];if(d&&!u&&!c){const h=Rr(r[a],e,t);if(h){n[a]=h;return}}if(u&&i&&o){const h=Ie(oe(i,e,t)),b=Ne([Rt(h).optional(),Ve(o,t)]),E=_t(g,o,e,t,b);n[a]=E}else if(c&&o){const h=i!=null&&i.___array?oe({___array:i.___array},e,t):{___array:U()},b=jr(h,o,t),E=_t(g,o,e,t,b);n[a]=E}else if(g&&o){const h=Ar(g,o,e,t);n[a]=h}else if(s&&o)n[a]=Fe(o,t);else{const h=Ie(oe(r[a],e,t)).optional();n[a]=o?Ne([h,Ve(o,t)]):h}}),n}function Ve(r,e){return Or().superRefine((t,n)=>{var a;if((a=e==null?void 0:e.validationConfig)!=null&&a.globalValidation){const s=e.validationConfig.globalValidation(t,r,e.metadata);if(s.error)return n.addIssue({code:l.custom,message:s.error}),!1;if(!s.continue)return!0}return!0})}function jr(r,e,t){return Ne([Rt(r.___array).optional(),Ve(e,t)])}function Ar(r,e,t,n){return U().optional().superRefine(async(a,s)=>{var o,u;if(e.required&&!(await Fe(e,n).safeParseAsync(a)).success)return s.addIssue({code:l.custom,message:Pe(e,n)}),Y;if((o=n==null?void 0:n.validationConfig)!=null&&o.globalValidation){const c=(u=n==null?void 0:n.validationConfig)==null?void 0:u.globalValidation(a,e,n.metadata);if(c.error)return s.addIssue({code:l.custom,message:c.error}),Y;if(!c.continue)return!0}const i=jt(r,t);if(i){const c=await i.safeParseAsync(a);if(!c.success){const d=K(c==null?void 0:c.error.message),g=d==="Required"?Pe(e,n):d;s.addIssue({code:l.custom,message:g})}}})}function _t(r,e,t,n,a){return U().optional().superRefine(async(s,i)=>{var d,g;const u=await Fe(e,n).safeParseAsync(s);if(e.required&&!u.success){const h=K(u.error.message);return i.addIssue({code:l.custom,message:h,fatal:!0}),Y}if(!e.required&&!u.success)return Y;if((d=n==null?void 0:n.validationConfig)!=null&&d.globalValidation){const h=(g=n==null?void 0:n.validationConfig)==null?void 0:g.globalValidation(s,e,n.metadata);if(h.error)return i.addIssue({code:l.custom,message:K(h.error)}),Y;if(!h.continue)return!0}if(!m.isArray(s))return i.addIssue({code:l.custom,message:"'Value is not array'"}),Y;const c=jt(r,t);if(c){const h=await c.safeParseAsync(s);if(!h.success)return i.addIssue({code:l.custom,message:K(h.error.message)}),Y}}).pipe(a??U())}function he(r,e,t,n,a){e.forEach(s=>{var o,u,c,d,g,h,b;const i=t;if(!s.isVisible||(o=s.isVisible)!=null&&o.call(s,i,n==null?void 0:n.metadata)){const E=m.get(r,s.path);if((u=s.validation)!=null&&u.schema?m.set(r,s.path,m.merge(E,{_schema:(c=s.validation)==null?void 0:c.schema,_input:s})):s.required&&m.set(r,s.path,m.merge(E,{_requiredOnly:!0,_input:s})),s.inputs&&(s.path&&m.set(r,s.path,m.merge(m.get(r,s.path),{_input:s})),he(r,s.inputs,t,n)),s.inputType==="list"){const T={};he(T,(g=(d=s.inputConfig)==null?void 0:d.inputs)==null?void 0:g.map(C=>({...C,path:C.relativePath})),t,n);const j=m.get(r,s.path);m.set(r,s.path,m.merge(j,{_schemaObj:T,_isList:!0,_input:s}))}if(!((h=s.validation)!=null&&h.schema)&&s.inputType==="array"){const T={};he(T,[{...s.inputConfig.input,path:"___array"}],t,n),m.set(r,s.path,m.merge(E,{_schemaObj:T,_schema:(b=s.validation)==null?void 0:b.schema,_isArrayItem:!0,_input:s}))}}}),e.forEach(s=>{var o;const i=t;if((!s.isVisible||(o=s.isVisible)!=null&&o.call(s,i,n==null?void 0:n.metadata))&&s.path){const u=s.path.split(".");u.forEach((c,d)=>{if(d>0&&/^\d+$/.test(c)){const g=u.slice(0,d).join("."),h=g?m.get(r,g):r;h&&typeof h=="object"&&(h._isTuple=!0)}})}})}function Pe(r,e){var t,n,a;return((n=(t=e==null?void 0:e.validationConfig)==null?void 0:t.requiredMessagePerInput)==null?void 0:n[r.inputType])??((a=e==null?void 0:e.validationConfig)==null?void 0:a.requiredMessage)??Sr}function Fe(r,e){var n,a,s,i,o,u;if((a=(n=e==null?void 0:e.validationConfig)==null?void 0:n.requiredSchemaPerInput)!=null&&a[r.inputType])return(i=(s=e==null?void 0:e.validationConfig)==null?void 0:s.requiredSchemaPerInput)==null?void 0:i[r.inputType];if((o=e==null?void 0:e.validationConfig)!=null&&o.requiredSchema)return(u=e==null?void 0:e.validationConfig)==null?void 0:u.requiredSchema;const t=Pe(r,e);return U().optional().superRefine((c,d)=>{typeof c=="object"&&m.isEmpty(c)&&d.addIssue({code:l.custom,message:t}),(m.isUndefined(c)||c==="")&&d.addIssue({code:l.custom,message:t})})}function jt(r,e){if(r instanceof k)return r;if(typeof r=="function")return r(e)}const Ir=r=>Array.isArray(r==null?void 0:r.errors),Nr=(r,e)=>{const t={};for(;r.length;){const n=r[0],{code:a,message:s,path:i}=n,o=i.join(".");if(!t[o])if("unionErrors"in n){const u=n.unionErrors[0].errors[0];t[o]={message:u.message,type:u.code}}else t[o]={message:s,type:a};"unionErrors"in n&&n.unionErrors.forEach(u=>u.errors.forEach(c=>r.push(c)));{const u=t[o].types,c=u&&u[n.code];t[o]=A.appendErrors(o,e,t,a,c?[].concat(c,n.message):n.message)}r.shift()}return t};function Vr(r,e){return O.useCallback(async(t,n,a)=>{try{return await Et(r,t,e).parseAsync(t),{values:t,errors:{}}}catch(s){if(Ir(s))return{values:{},errors:qt.toNestErrors(Nr(s.errors,!0),a)};throw s}},[r,e])}const Te=(r,e)=>r.level!==e.level?r.level-e.level:r.isPrimitive?1:-1,Oe=(r,e)=>r.level!==e.level?e.level-r.level:r.isPrimitive?-1:1;function me(r,e,t){m.get(r,e)===void 0&&t===void 0||m.set(r,e,t)}function At(r,e){const t=m.cloneDeep(r),n=e.filter(o=>o.inputPriority==="early"),a=e.filter(o=>o.inputPriority==="normal"),s=e.filter(o=>o.inputPriority==="late");return n.sort(Te),a.sort(Te),s.sort(Te),[...n,...a,...s].forEach(o=>{if(o.inputTransform){const u=m.isArray(o.inputTransform)?o.inputTransform:[o.inputTransform];let c;const d=o.path.split(".");if(d.length>1){const g=d.slice(0,-1).join("."),h=m.get(t,g);typeof h=="string"||typeof h=="number"||typeof h=="boolean"?c=void 0:c=m.get(t,o.path)}else c=m.get(t,o.path);u.forEach(g=>{const h=g(c,t);h&&(c=h.value,me(t,h.path??o.path,h.value))})}}),t}function It(r,e,t){const n=e.filter(d=>d.outputPriority==="early"),a=e.filter(d=>d.outputPriority==="normal"),s=e.filter(d=>d.outputPriority==="late");n.sort(Oe),a.sort(Oe),s.sort(Oe);const i=[...n,...a,...s],o=[];let u={};t||(u=m.cloneDeep(r));const c=m.cloneDeep(r);return i.forEach(d=>{if(d.outputTransform){const g=m.isArray(d.outputTransform)?d.outputTransform:[d.outputTransform];let h=m.get(c,d.path);g.forEach(b=>{const E=m.get(u,d.path),T=b(h,c,E,u);if(T)if(h=T.value,T.path){if(T.merge){const j=m.get(u,T.path);let C;j?C=m.merge({},j,T.value):C=T.value,me(u,T.path,C)}else me(u,T.path,T.value);T.unset&&o.push(d.path)}else me(u,d.path,T.value)})}}),o.forEach(d=>{m.unset(u,d)}),u}function Me(r){return r.reduce((t,n)=>Array.isArray(n.inputs)?[...t,n,...Me(n.inputs)]:[...t,n],[])}const Pr=r=>{if(r!==void 0)return{value:r}},Zr=r=>{if(r!==void 0)return{value:r}};function De(r,e){return Me(r.inputs).reduce((a,s)=>{var h,b;const i=s.inputType==="text"||s.inputType==="boolean"||s.inputType==="number"||s.inputType==="textarea"||s.inputType==="select",o=!!s.inputTransform,u=!!s.outputTransform,c=Array.isArray(s.inputs)&&s.inputs.length>0,d=s.inputType==="list"||s.inputType==="array";return o||u?a.push({path:s.path,inputTransform:s.inputTransform,outputTransform:s.outputTransform,level:s.path.split(".").length,isPrimitive:i,inputPriority:((h=s.transformerPriority)==null?void 0:h.input)??"normal",outputPriority:((b=s.transformerPriority)==null?void 0:b.output)??"normal"}):e&&!(c||d)&&a.push({path:s.path,inputTransform:Pr,outputTransform:Zr,level:s.path.split(".").length,isPrimitive:i,inputPriority:"normal",outputPriority:"normal"}),a},[])}function Nt(r,e,t,n={}){const{preserve:a}=n,s=Me(r.inputs),i=m.cloneDeep(e);return s.forEach(o=>{a&&a.includes(o.path)||o.isVisible&&!o.isVisible(e,t)&&m.unset(i,o.path)}),i}function $r(r,e){const t=De(e);return At(r,t)}function Fr(r,e,t,n={}){const a=n.cleanOutput,s=De(e,a);let i=Nt(e,r,t,n);return i=It(i,s,n.cleanOutput),i=Tt(i),i}function Mr(r){const e={},t=n=>{n.forEach(a=>{const{default:s,path:i,inputs:o}=a;Array.isArray(o)?t(o):s!==void 0&&m.set(e,i,s)})};return Array.isArray(r.inputs)&&t(r.inputs),e}function Dr(){return function(r,e){if(!(typeof r>"u"))return!r||!m.isPlainObject(r)?{value:r}:{value:Object.getOwnPropertyNames(r).map(t=>({key:t,value:r[t]}))}}}function qr(r){return function(e){if(typeof e>"u")return;if(!e||!m.isArray(e))return{value:e};const t={value:e.reduce((n,a)=>({...n,[a.key]:r!=null&&r.assignKeyToValue?a.key:a.value??(r==null?void 0:r.fallbackValue)}),{})};return r!=null&&r.unsetIfEmpty&&Object.getOwnPropertyNames(t.value).length===0?{value:void 0}:t}}function Lr(){return function(r){if(!(typeof r>"u"))return m.isArray(r)&&m.isEmpty(r)?{value:void 0}:{value:r}}}function zr(r,e){return function(t,n,a,s){let i;if(r?i=m.get(e&&s?s:n,r):i=e?a:t,!(typeof i>"u")){if(m.isNull(i))return{value:void 0,path:r};if(m.isObject(i)){const o=Pt(m.cloneDeep(i));return Object.getOwnPropertyNames(o).length===0?{value:void 0,path:r}:void 0}return{value:i,path:r}}}}function Br(){return function(r){if(!(typeof r>"u"))return m.isString(r)&&m.isEmpty(r)?{value:void 0}:{value:r}}}function Ur(r){return function(e,t){const n=m.get(t,r);if(typeof n=="string")return{value:n};if(!(typeof n=="number"||typeof n=="boolean")&&e!==void 0)return{value:e}}}function Wr(r){return function(e,t,n,a){if(typeof e>"u")return;if(!e)return{value:e};const s=m.get(a||t,r);if(typeof s=="object"){const i=Pt(s);if(Object.getOwnPropertyNames(i).length===1)return{value:e,path:r}}return{value:e}}}function Jr(r){return function(e,t){const n=m.get(t,r);if(typeof n=="string")return{value:[n]};if(!(typeof n=="number"||typeof n=="boolean")&&e!==void 0)return{value:e}}}function Hr(r,e){return function(t,n){if(typeof t>"u")return;if(!t)return{value:t};const a=m.get(n,r);if(m.isArray(a)){if(a.length===1)return{value:a[0],path:r};if(a.length===0&&e!=null&&e.unsetIfEmpty)return{value:void 0,path:r}}return{value:t}}}function Vt(r){return m.isNil(r)?!0:m.isArray(r)?r.length===0:typeof r=="object"?!Object.getOwnPropertyNames(r).some(e=>!Vt(r[e])):m.isUndefined(r)}function Pt(r){return m.omitBy(r,e=>typeof e=="object"?Vt(e):m.isUndefined(e))}function be(r){const{items:e,className:t,withoutWrapper:n=!0,...a}=r,s=e.map(i=>R.jsx(kt,{input:i,path:i.path,...a},`${i.inputType}_${i.path}`));return n?R.jsx(R.Fragment,{children:s}):R.jsx("div",{className:t,children:s})}be.displayName="RenderInputs";const Zt=O.forwardRef((r,e)=>{const{inputs:t,className:n,factory:a,withoutWrapper:s}=r;return s?R.jsxs(O.Fragment,{children:[t.hero,R.jsx(be,{items:t.inputs,factory:a})]}):R.jsxs("div",{className:n,ref:e,children:[t.hero,R.jsx(be,{items:t.inputs,factory:a})]})});Zt.displayName="RenderForm";function Yr(r){let e=!0;return m.forOwn(r,t=>{e=e&&(t===""||m.isNull(t)||m.isUndefined(t))}),e}const Gr=(r="")=>m.capitalize(r.split("_").join(" ")),$t=(r,e=2,t,n=1e3)=>{let a=!1;const s=()=>{requestAnimationFrame(()=>{a||(e-=1,e<=0?r():s())})};return t&&Date.now()-t<=n?(r(),()=>{}):(s(),()=>{a=!0})};function Qr(r,e){return{...r,inputs:r.inputs.map(t=>D(t,e))}}function D(r,e){var u,c,d;const{override:t,...n}=r,a=e&&t?t[e]:void 0,{inputConfig:s,...i}=a||{},o=a?{...n,...i}:n;if((n.inputConfig||s)&&(o.inputConfig={...n.inputConfig,...s}),o.inputs&&(o.inputs=o.inputs.map(g=>D(g,e))),o.inputType==="list"&&o.inputConfig){const g=((u=n.inputConfig)==null?void 0:u.inputs)||[],h=(s==null?void 0:s.inputs)||[];if(g.length>0||h.length>0){const b=Math.max(g.length,h.length);o.inputConfig.inputs=Array.from({length:b},(E,T)=>{var Z;const j=g[T],C=h[T];if(!j&&C)return D(C,e);if(j&&!C)return D(j,e);if(j&&C){const $=j.override?{...j.override}:{};return e&&C&&($[e]=(Z=j.override)!=null&&Z[e]?{...j.override[e],...C}:C),D({...j,override:$},e)}}).filter(Boolean)}else o.inputConfig.inputs&&(o.inputConfig.inputs=o.inputConfig.inputs.map(b=>D(b,e)))}if(o.inputType==="array"&&o.inputConfig){const g=(c=n.inputConfig)==null?void 0:c.input,h=s==null?void 0:s.input;if(g&&h){const b=g.override?{...g.override}:{};e&&h&&(b[e]=(d=g.override)!=null&&d[e]?{...g.override[e],...h}:h),o.inputConfig.input=D({...g,override:b},e)}else o.inputConfig.input&&(o.inputConfig.input=D(o.inputConfig.input,e))}return o}function Xr(r){const{field:{onBlur:e,...t},...n}=A.useController(r),a=O.useRef(Date.now());return{...n,field:{...t,onBlur:$t(e,2,a.current)}}}Object.defineProperty(exports,"Controller",{enumerable:!0,get:()=>A.Controller});Object.defineProperty(exports,"Form",{enumerable:!0,get:()=>A.Form});Object.defineProperty(exports,"FormProvider",{enumerable:!0,get:()=>A.FormProvider});Object.defineProperty(exports,"get",{enumerable:!0,get:()=>A.get});Object.defineProperty(exports,"set",{enumerable:!0,get:()=>A.set});Object.defineProperty(exports,"useFieldArray",{enumerable:!0,get:()=>A.useFieldArray});Object.defineProperty(exports,"useForm",{enumerable:!0,get:()=>A.useForm});Object.defineProperty(exports,"useFormContext",{enumerable:!0,get:()=>A.useFormContext});Object.defineProperty(exports,"useFormState",{enumerable:!0,get:()=>A.useFormState});Object.defineProperty(exports,"useWatch",{enumerable:!0,get:()=>A.useWatch});exports.InputComponent=Jt;exports.InputComponentRenderer=kt;exports.InputFactory=Ze;exports.InputOverrideError=vt;exports.RenderForm=Zt;exports.RenderInputs=be;exports.RootForm=Ht;exports.afterFrames=$t;exports.applyFormOverrides=Qr;exports.applyInputOverride=D;exports.arrayToObjectOutputTransformer=qr;exports.collectDefaultValues=Mr;exports.convertDataToFormModel=$r;exports.convertFormModelToData=Fr;exports.generateReadableLabel=Gr;exports.getDefaultValuesFromFormDefinition=Yt;exports.getTemporaryPath=Xt;exports.getTransformers=De;exports.getValidationSchema=Et;exports.inputTransformValues=At;exports.isChildrenEmpty=Yr;exports.objectToArrayInputTransformer=Dr;exports.outputTransformValues=It;exports.overrideFormDefinition=Gt;exports.processValidationParseResponse=K;exports.removeTemporaryFieldsValue=Tt;exports.shorthandArrayInputTransformer=Jr;exports.shorthandArrayOutputTransformer=Hr;exports.shorthandObjectInputTransformer=Ur;exports.shorthandObjectOutputTransformer=Wr;exports.unsetEmptyArrayOutputTransformer=Lr;exports.unsetEmptyObjectOutputTransformer=zr;exports.unsetEmptyStringOutputTransformer=Br;exports.unsetHiddenInputsValues=Nt;exports.useController=Xr;exports.useRootFormContext=xt;exports.useZodValidationResolver=Vr;
13
13
  //# sourceMappingURL=index.cjs.map