@jsdev_ninja/core 0.14.3 → 0.14.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.es.js +641 -593
- package/dist/core.es.js.map +1 -1
- package/dist/core.umd.js +1 -1
- package/dist/core.umd.js.map +1 -1
- package/dist/lib/entities/Chatbot/index.d.ts +96 -0
- package/dist/lib/entities/Chatbot/index.d.ts.map +1 -0
- package/dist/lib/entities/Chatbot/index.js +37 -0
- package/dist/lib/entities/index.d.ts +1 -0
- package/dist/lib/entities/index.d.ts.map +1 -1
- package/dist/lib/entities/index.js +1 -0
- package/dist/lib/firebase-api/index.d.ts +27 -0
- package/dist/lib/firebase-api/index.d.ts.map +1 -1
- package/dist/lib/firebase-api/index.js +9 -0
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/core.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(g,_){typeof exports=="object"&&typeof module<"u"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(g=typeof globalThis<"u"?globalThis:g||self,_(g.core={}))})(this,function(g){"use strict";var Jn=Object.defineProperty;var Hn=(g,_,F)=>_ in g?Jn(g,_,{enumerable:!0,configurable:!0,writable:!0,value:F}):g[_]=F;var vt=(g,_,F)=>Hn(g,typeof _!="symbol"?_+"":_,F);var _;(function(n){n.assertEqual=a=>a;function e(a){}n.assertIs=e;function t(a){throw new Error}n.assertNever=t,n.arrayToEnum=a=>{const s={};for(const o of a)s[o]=o;return s},n.getValidEnumValues=a=>{const s=n.objectKeys(a).filter(c=>typeof a[a[c]]!="number"),o={};for(const c of s)o[c]=a[c];return n.objectValues(o)},n.objectValues=a=>n.objectKeys(a).map(function(s){return a[s]}),n.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const s=[];for(const o in a)Object.prototype.hasOwnProperty.call(a,o)&&s.push(o);return s},n.find=(a,s)=>{for(const o of a)if(s(o))return o},n.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&isFinite(a)&&Math.floor(a)===a;function r(a,s=" | "){return a.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}n.joinValues=r,n.jsonStringifyReplacer=(a,s)=>typeof s=="bigint"?s.toString():s})(_||(_={}));var F;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(F||(F={}));const f=_.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),M=n=>{switch(typeof n){case"undefined":return f.undefined;case"string":return f.string;case"number":return isNaN(n)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(n)?f.array:n===null?f.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?f.promise:typeof Map<"u"&&n instanceof Map?f.map:typeof Set<"u"&&n instanceof Set?f.set:typeof Date<"u"&&n instanceof Date?f.date:f.object;default:return f.unknown}},d=_.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"]),_t=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class C extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};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},r={_errors:[]},a=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(a);else if(o.code==="invalid_return_type")a(o.returnTypeError);else if(o.code==="invalid_arguments")a(o.argumentsError);else if(o.path.length===0)r._errors.push(t(o));else{let c=r,l=0;for(;l<o.path.length;){const u=o.path[l];l===o.path.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(o))):c[u]=c[u]||{_errors:[]},c=c[u],l++}}};return a(this),r}static assert(e){if(!(e instanceof C))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,_.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const a of this.issues)a.path.length>0?(t[a.path[0]]=t[a.path[0]]||[],t[a.path[0]].push(e(a))):r.push(e(a));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}C.create=n=>new C(n);const G=(n,e)=>{let t;switch(n.code){case d.invalid_type:n.received===f.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case d.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,_.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:t=`Unrecognized key(s) in object: ${_.joinValues(n.keys,", ")}`;break;case d.invalid_union:t="Invalid input";break;case d.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${_.joinValues(n.options)}`;break;case d.invalid_enum_value:t=`Invalid enum value. Expected ${_.joinValues(n.options)}, received '${n.received}'`;break;case d.invalid_arguments:t="Invalid function arguments";break;case d.invalid_return_type:t="Invalid function return type";break;case d.invalid_date:t="Invalid date";break;case d.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:_.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case d.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case d.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case d.custom:t="Invalid input";break;case d.invalid_intersection_types:t="Intersection results could not be merged";break;case d.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case d.not_finite:t="Number must be finite";break;default:t=e.defaultError,_.assertNever(n)}return{message:t}};let Qe=G;function bt(n){Qe=n}function ke(){return Qe}const we=n=>{const{data:e,path:t,errorMaps:r,issueData:a}=n,s=[...t,...a.path||[]],o={...a,path:s};if(a.message!==void 0)return{...a,path:s,message:a.message};let c="";const l=r.filter(u=>!!u).slice().reverse();for(const u of l)c=u(o,{data:e,defaultError:c}).message;return{...a,path:s,message:c}},xt=[];function m(n,e){const t=ke(),r=we({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===G?void 0:G].filter(a=>!!a)});n.common.issues.push(r)}class S{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const a of t){if(a.status==="aborted")return v;a.status==="dirty"&&e.dirty(),r.push(a.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const a of t){const s=await a.key,o=await a.value;r.push({key:s,value:o})}return S.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const a of t){const{key:s,value:o}=a;if(s.status==="aborted"||o.status==="aborted")return v;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||a.alwaysSet)&&(r[s.value]=o.value)}return{status:e.value,value:r}}}const v=Object.freeze({status:"aborted"}),X=n=>({status:"dirty",value:n}),N=n=>({status:"valid",value:n}),Ze=n=>n.status==="aborted",je=n=>n.status==="dirty",B=n=>n.status==="valid",ne=n=>typeof Promise<"u"&&n instanceof Promise;function Te(n,e,t,r){if(typeof e=="function"?n!==e||!0:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function Ye(n,e,t,r,a){if(typeof e=="function"?n!==e||!0:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}typeof SuppressedError=="function"&&SuppressedError;var h;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(h||(h={}));var re,ae;class j{constructor(e,t,r,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=a}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Ge=(n,e)=>{if(B(e))return{success:!0,data:e.value};if(!n.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 C(n.common.issues);return this._error=t,this._error}}};function b(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:a}=n;if(e&&(t||r))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:(o,c)=>{var l,u;const{message:p}=n;return o.code==="invalid_enum_value"?{message:p??c.defaultError}:typeof c.data>"u"?{message:(l=p??r)!==null&&l!==void 0?l:c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:(u=p??t)!==null&&u!==void 0?u:c.defaultError}},description:a}}class x{get description(){return this._def.description}_getType(e){return M(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:M(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new S,ctx:{common:e.parent.common,data:e.data,parsedType:M(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ne(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 r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const a={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)},s=this._parseSync({data:e,path:a.path,parent:a});return Ge(a,s)}"~validate"(e){var t,r;const a={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:a});return B(s)?{value:s.value}:{issues:a.common.issues}}catch(s){!((r=(t=s==null?void 0:s.message)===null||t===void 0?void 0:t.toLowerCase())===null||r===void 0)&&r.includes("encountered")&&(this["~standard"].async=!0),a.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:a}).then(s=>B(s)?{value:s.value}:{issues:a.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={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:M(e)},a=this._parse({data:e,path:r.path,parent:r}),s=await(ne(a)?a:Promise.resolve(a));return Ge(r,s)}refine(e,t){const r=a=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(a):t;return this._refinement((a,s)=>{const o=e(a),c=()=>s.addIssue({code:d.custom,...r(a)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,t){return this._refinement((r,a)=>e(r)?!0:(a.addIssue(typeof t=="function"?t(r,a):t),!1))}_refinement(e){return new Z({schema:this,typeName:y.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 P.create(this,this._def)}nullable(){return q.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return D.create(this)}promise(){return ee.create(this,this._def)}or(e){return ce.create([this,e],this._def)}and(e){return ue.create(this,e,this._def)}transform(e){return new Z({...b(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new pe({...b(this._def),innerType:this,defaultValue:t,typeName:y.ZodDefault})}brand(){return new Ee({typeName:y.ZodBranded,type:this,...b(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new he({...b(this._def),innerType:this,catchValue:t,typeName:y.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ge.create(this,e)}readonly(){return ye.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const kt=/^c[^\s-]{8,}$/i,wt=/^[0-9a-z]+$/,Tt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,St=/^[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,Nt=/^[a-z0-9_-]{21}$/i,It=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ct=/^[-+]?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)?)??$/,At=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Dt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Oe;const Zt=/^(?:(?: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])$/,jt=/^(?:(?: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])$/,Ot=/^(([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]))$/,Pt=/^(([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])$/,Et=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Rt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Xe="((\\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])))",Mt=new RegExp(`^${Xe}$`);function Je(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function $t(n){return new RegExp(`^${Je(n)}$`)}function He(n){let e=`${Xe}T${Je(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Vt(n,e){return!!((e==="v4"||!e)&&Zt.test(n)||(e==="v6"||!e)&&Ot.test(n))}function Ft(n,e){if(!It.test(n))return!1;try{const[t]=n.split("."),r=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),a=JSON.parse(atob(r));return!(typeof a!="object"||a===null||!a.typ||!a.alg||e&&a.alg!==e)}catch{return!1}}function zt(n,e){return!!((e==="v4"||!e)&&jt.test(n)||(e==="v6"||!e)&&Pt.test(n))}class A extends x{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){const s=this._getOrReturnCtx(e);return m(s,{code:d.invalid_type,expected:f.string,received:s.parsedType}),v}const r=new S;let a;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(a=this._getOrReturnCtx(e,a),m(a,{code:d.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")e.data.length>s.value&&(a=this._getOrReturnCtx(e,a),m(a,{code:d.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){const o=e.data.length>s.value,c=e.data.length<s.value;(o||c)&&(a=this._getOrReturnCtx(e,a),o?m(a,{code:d.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&m(a,{code:d.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")At.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"email",code:d.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")Oe||(Oe=new RegExp(Dt,"u")),Oe.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"emoji",code:d.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")St.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"uuid",code:d.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")Nt.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"nanoid",code:d.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")kt.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"cuid",code:d.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")wt.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"cuid2",code:d.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")Tt.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"ulid",code:d.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),m(a,{validation:"url",code:d.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"regex",code:d.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(a=this._getOrReturnCtx(e,a),m(a,{code:d.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.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),m(a,{code:d.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(a=this._getOrReturnCtx(e,a),m(a,{code:d.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?He(s).test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{code:d.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?Mt.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{code:d.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?$t(s).test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{code:d.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?Ct.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"duration",code:d.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?Vt(e.data,s.version)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"ip",code:d.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?Ft(e.data,s.alg)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"jwt",code:d.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?zt(e.data,s.version)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"cidr",code:d.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?Et.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"base64",code:d.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?Rt.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"base64url",code:d.invalid_string,message:s.message}),r.dirty()):_.assertNever(s);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(a=>e.test(a),{validation:t,code:d.invalid_string,...h.errToObj(r)})}_addCheck(e){return new A({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...h.errToObj(e)})}url(e){return this._addCheck({kind:"url",...h.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...h.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...h.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...h.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...h.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...h.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...h.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...h.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...h.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...h.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...h.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...h.errToObj(e)})}datetime(e){var t,r;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:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!1,...h.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,...h.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...h.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...h.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...h.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...h.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...h.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...h.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...h.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...h.errToObj(t)})}nonempty(e){return this.min(1,h.errToObj(e))}trim(){return new A({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new A({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new A({...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}}A.create=n=>{var e;return new A({checks:[],typeName:y.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...b(n)})};function Lt(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,a=t>r?t:r,s=parseInt(n.toFixed(a).replace(".","")),o=parseInt(e.toFixed(a).replace(".",""));return s%o/Math.pow(10,a)}class z extends x{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)!==f.number){const s=this._getOrReturnCtx(e);return m(s,{code:d.invalid_type,expected:f.number,received:s.parsedType}),v}let r;const a=new S;for(const s of this._def.checks)s.kind==="int"?_.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:d.invalid_type,expected:"integer",received:"float",message:s.message}),a.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:d.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)&&(r=this._getOrReturnCtx(e,r),m(r,{code:d.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),a.dirty()):s.kind==="multipleOf"?Lt(e.data,s.value)!==0&&(r=this._getOrReturnCtx(e,r),m(r,{code:d.not_multiple_of,multipleOf:s.value,message:s.message}),a.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:d.not_finite,message:s.message}),a.dirty()):_.assertNever(s);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,r,a){return new z({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:h.toString(a)}]})}_addCheck(e){return new z({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:h.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:h.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:h.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:h.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:h.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"&&_.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}z.create=n=>new z({checks:[],typeName:y.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...b(n)});class L extends x{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)!==f.bigint)return this._getInvalidInput(e);let r;const a=new S;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:d.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)&&(r=this._getOrReturnCtx(e,r),m(r,{code:d.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),a.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),m(r,{code:d.not_multiple_of,multipleOf:s.value,message:s.message}),a.dirty()):_.assertNever(s);return{status:a.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return m(t,{code:d.invalid_type,expected:f.bigint,received:t.parsedType}),v}gte(e,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,r,a){return new L({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:h.toString(a)}]})}_addCheck(e){return new L({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:h.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:h.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}}L.create=n=>{var e;return new L({checks:[],typeName:y.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...b(n)})};class ie extends x{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){const r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_type,expected:f.boolean,received:r.parsedType}),v}return N(e.data)}}ie.create=n=>new ie({typeName:y.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...b(n)});class W extends x{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){const s=this._getOrReturnCtx(e);return m(s,{code:d.invalid_type,expected:f.date,received:s.parsedType}),v}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return m(s,{code:d.invalid_date}),v}const r=new S;let a;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(a=this._getOrReturnCtx(e,a),m(a,{code:d.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(a=this._getOrReturnCtx(e,a),m(a,{code:d.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):_.assertNever(s);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new W({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:h.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:h.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}}W.create=n=>new W({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:y.ZodDate,...b(n)});class Se extends x{_parse(e){if(this._getType(e)!==f.symbol){const r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_type,expected:f.symbol,received:r.parsedType}),v}return N(e.data)}}Se.create=n=>new Se({typeName:y.ZodSymbol,...b(n)});class se extends x{_parse(e){if(this._getType(e)!==f.undefined){const r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_type,expected:f.undefined,received:r.parsedType}),v}return N(e.data)}}se.create=n=>new se({typeName:y.ZodUndefined,...b(n)});class oe extends x{_parse(e){if(this._getType(e)!==f.null){const r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_type,expected:f.null,received:r.parsedType}),v}return N(e.data)}}oe.create=n=>new oe({typeName:y.ZodNull,...b(n)});class J extends x{constructor(){super(...arguments),this._any=!0}_parse(e){return N(e.data)}}J.create=n=>new J({typeName:y.ZodAny,...b(n)});class Q extends x{constructor(){super(...arguments),this._unknown=!0}_parse(e){return N(e.data)}}Q.create=n=>new Q({typeName:y.ZodUnknown,...b(n)});class $ extends x{_parse(e){const t=this._getOrReturnCtx(e);return m(t,{code:d.invalid_type,expected:f.never,received:t.parsedType}),v}}$.create=n=>new $({typeName:y.ZodNever,...b(n)});class Ne extends x{_parse(e){if(this._getType(e)!==f.undefined){const r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_type,expected:f.void,received:r.parsedType}),v}return N(e.data)}}Ne.create=n=>new Ne({typeName:y.ZodVoid,...b(n)});class D extends x{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),a=this._def;if(t.parsedType!==f.array)return m(t,{code:d.invalid_type,expected:f.array,received:t.parsedType}),v;if(a.exactLength!==null){const o=t.data.length>a.exactLength.value,c=t.data.length<a.exactLength.value;(o||c)&&(m(t,{code:o?d.too_big:d.too_small,minimum:c?a.exactLength.value:void 0,maximum:o?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),r.dirty())}if(a.minLength!==null&&t.data.length<a.minLength.value&&(m(t,{code:d.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),r.dirty()),a.maxLength!==null&&t.data.length>a.maxLength.value&&(m(t,{code:d.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((o,c)=>a.type._parseAsync(new j(t,o,t.path,c)))).then(o=>S.mergeArray(r,o));const s=[...t.data].map((o,c)=>a.type._parseSync(new j(t,o,t.path,c)));return S.mergeArray(r,s)}get element(){return this._def.type}min(e,t){return new D({...this._def,minLength:{value:e,message:h.toString(t)}})}max(e,t){return new D({...this._def,maxLength:{value:e,message:h.toString(t)}})}length(e,t){return new D({...this._def,exactLength:{value:e,message:h.toString(t)}})}nonempty(e){return this.min(1,e)}}D.create=(n,e)=>new D({type:n,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,...b(e)});function H(n){if(n instanceof w){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=P.create(H(r))}return new w({...n._def,shape:()=>e})}else return n instanceof D?new D({...n._def,type:H(n.element)}):n instanceof P?P.create(H(n.unwrap())):n instanceof q?q.create(H(n.unwrap())):n instanceof O?O.create(n.items.map(e=>H(e))):n}class w extends x{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=_.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==f.object){const u=this._getOrReturnCtx(e);return m(u,{code:d.invalid_type,expected:f.object,received:u.parsedType}),v}const{status:r,ctx:a}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof $&&this._def.unknownKeys==="strip"))for(const u in a.data)o.includes(u)||c.push(u);const l=[];for(const u of o){const p=s[u],k=a.data[u];l.push({key:{status:"valid",value:u},value:p._parse(new j(a,k,a.path,u)),alwaysSet:u in a.data})}if(this._def.catchall instanceof $){const u=this._def.unknownKeys;if(u==="passthrough")for(const p of c)l.push({key:{status:"valid",value:p},value:{status:"valid",value:a.data[p]}});else if(u==="strict")c.length>0&&(m(a,{code:d.unrecognized_keys,keys:c}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const p of c){const k=a.data[p];l.push({key:{status:"valid",value:p},value:u._parse(new j(a,k,a.path,p)),alwaysSet:p in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const u=[];for(const p of l){const k=await p.key,T=await p.value;u.push({key:k,value:T,alwaysSet:p.alwaysSet})}return u}).then(u=>S.mergeObjectSync(r,u)):S.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return h.errToObj,new w({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var a,s,o,c;const l=(o=(s=(a=this._def).errorMap)===null||s===void 0?void 0:s.call(a,t,r).message)!==null&&o!==void 0?o:r.defaultError;return t.code==="unrecognized_keys"?{message:(c=h.errToObj(e).message)!==null&&c!==void 0?c:l}:{message:l}}}:{}})}strip(){return new w({...this._def,unknownKeys:"strip"})}passthrough(){return new w({...this._def,unknownKeys:"passthrough"})}extend(e){return new w({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new w({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:y.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new w({...this._def,catchall:e})}pick(e){const t={};return _.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new w({...this._def,shape:()=>t})}omit(e){const t={};return _.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new w({...this._def,shape:()=>t})}deepPartial(){return H(this)}partial(e){const t={};return _.objectKeys(this.shape).forEach(r=>{const a=this.shape[r];e&&!e[r]?t[r]=a:t[r]=a.optional()}),new w({...this._def,shape:()=>t})}required(e){const t={};return _.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof P;)s=s._def.innerType;t[r]=s}}),new w({...this._def,shape:()=>t})}keyof(){return Ke(_.objectKeys(this.shape))}}w.create=(n,e)=>new w({shape:()=>n,unknownKeys:"strip",catchall:$.create(),typeName:y.ZodObject,...b(e)}),w.strictCreate=(n,e)=>new w({shape:()=>n,unknownKeys:"strict",catchall:$.create(),typeName:y.ZodObject,...b(e)}),w.lazycreate=(n,e)=>new w({shape:n,unknownKeys:"strip",catchall:$.create(),typeName:y.ZodObject,...b(e)});class ce extends x{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function a(s){for(const c of s)if(c.result.status==="valid")return c.result;for(const c of s)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;const o=s.map(c=>new C(c.ctx.common.issues));return m(t,{code:d.invalid_union,unionErrors:o}),v}if(t.common.async)return Promise.all(r.map(async s=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(a);{let s;const o=[];for(const l of r){const u={...t,common:{...t.common,issues:[]},parent:null},p=l._parseSync({data:t.data,path:t.path,parent:u});if(p.status==="valid")return p;p.status==="dirty"&&!s&&(s={result:p,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const c=o.map(l=>new C(l));return m(t,{code:d.invalid_union,unionErrors:c}),v}}get options(){return this._def.options}}ce.create=(n,e)=>new ce({options:n,typeName:y.ZodUnion,...b(e)});const V=n=>n instanceof le?V(n.schema):n instanceof Z?V(n.innerType()):n instanceof me?[n.value]:n instanceof U?n.options:n instanceof fe?_.objectValues(n.enum):n instanceof pe?V(n._def.innerType):n instanceof se?[void 0]:n instanceof oe?[null]:n instanceof P?[void 0,...V(n.unwrap())]:n instanceof q?[null,...V(n.unwrap())]:n instanceof Ee||n instanceof ye?V(n.unwrap()):n instanceof he?V(n._def.innerType):[];class Ie extends x{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return m(t,{code:d.invalid_type,expected:f.object,received:t.parsedType}),v;const r=this.discriminator,a=t.data[r],s=this.optionsMap.get(a);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(m(t,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const a=new Map;for(const s of t){const o=V(s.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const c of o){if(a.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);a.set(c,s)}}return new Ie({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...b(r)})}}function Pe(n,e){const t=M(n),r=M(e);if(n===e)return{valid:!0,data:n};if(t===f.object&&r===f.object){const a=_.objectKeys(e),s=_.objectKeys(n).filter(c=>a.indexOf(c)!==-1),o={...n,...e};for(const c of s){const l=Pe(n[c],e[c]);if(!l.valid)return{valid:!1};o[c]=l.data}return{valid:!0,data:o}}else if(t===f.array&&r===f.array){if(n.length!==e.length)return{valid:!1};const a=[];for(let s=0;s<n.length;s++){const o=n[s],c=e[s],l=Pe(o,c);if(!l.valid)return{valid:!1};a.push(l.data)}return{valid:!0,data:a}}else return t===f.date&&r===f.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class ue extends x{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),a=(s,o)=>{if(Ze(s)||Ze(o))return v;const c=Pe(s.value,o.value);return c.valid?((je(s)||je(o))&&t.dirty(),{status:t.value,value:c.data}):(m(r,{code:d.invalid_intersection_types}),v)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,o])=>a(s,o)):a(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}ue.create=(n,e,t)=>new ue({left:n,right:e,typeName:y.ZodIntersection,...b(t)});class O extends x{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.array)return m(r,{code:d.invalid_type,expected:f.array,received:r.parsedType}),v;if(r.data.length<this._def.items.length)return m(r,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&r.data.length>this._def.items.length&&(m(r,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...r.data].map((o,c)=>{const l=this._def.items[c]||this._def.rest;return l?l._parse(new j(r,o,r.path,c)):null}).filter(o=>!!o);return r.common.async?Promise.all(s).then(o=>S.mergeArray(t,o)):S.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new O({...this._def,rest:e})}}O.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new O({items:n,typeName:y.ZodTuple,rest:null,...b(e)})};class de extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.object)return m(r,{code:d.invalid_type,expected:f.object,received:r.parsedType}),v;const a=[],s=this._def.keyType,o=this._def.valueType;for(const c in r.data)a.push({key:s._parse(new j(r,c,r.path,c)),value:o._parse(new j(r,r.data[c],r.path,c)),alwaysSet:c in r.data});return r.common.async?S.mergeObjectAsync(t,a):S.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof x?new de({keyType:e,valueType:t,typeName:y.ZodRecord,...b(r)}):new de({keyType:A.create(),valueType:e,typeName:y.ZodRecord,...b(t)})}}class Ce extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.map)return m(r,{code:d.invalid_type,expected:f.map,received:r.parsedType}),v;const a=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([c,l],u)=>({key:a._parse(new j(r,c,r.path,[u,"key"])),value:s._parse(new j(r,l,r.path,[u,"value"]))}));if(r.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const l of o){const u=await l.key,p=await l.value;if(u.status==="aborted"||p.status==="aborted")return v;(u.status==="dirty"||p.status==="dirty")&&t.dirty(),c.set(u.value,p.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const l of o){const u=l.key,p=l.value;if(u.status==="aborted"||p.status==="aborted")return v;(u.status==="dirty"||p.status==="dirty")&&t.dirty(),c.set(u.value,p.value)}return{status:t.value,value:c}}}}Ce.create=(n,e,t)=>new Ce({valueType:e,keyType:n,typeName:y.ZodMap,...b(t)});class Y extends x{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.set)return m(r,{code:d.invalid_type,expected:f.set,received:r.parsedType}),v;const a=this._def;a.minSize!==null&&r.data.size<a.minSize.value&&(m(r,{code:d.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),a.maxSize!==null&&r.data.size>a.maxSize.value&&(m(r,{code:d.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());const s=this._def.valueType;function o(l){const u=new Set;for(const p of l){if(p.status==="aborted")return v;p.status==="dirty"&&t.dirty(),u.add(p.value)}return{status:t.value,value:u}}const c=[...r.data.values()].map((l,u)=>s._parse(new j(r,l,r.path,u)));return r.common.async?Promise.all(c).then(l=>o(l)):o(c)}min(e,t){return new Y({...this._def,minSize:{value:e,message:h.toString(t)}})}max(e,t){return new Y({...this._def,maxSize:{value:e,message:h.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Y.create=(n,e)=>new Y({valueType:n,minSize:null,maxSize:null,typeName:y.ZodSet,...b(e)});class K extends x{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return m(t,{code:d.invalid_type,expected:f.function,received:t.parsedType}),v;function r(c,l){return we({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ke(),G].filter(u=>!!u),issueData:{code:d.invalid_arguments,argumentsError:l}})}function a(c,l){return we({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ke(),G].filter(u=>!!u),issueData:{code:d.invalid_return_type,returnTypeError:l}})}const s={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof ee){const c=this;return N(async function(...l){const u=new C([]),p=await c._def.args.parseAsync(l,s).catch(I=>{throw u.addIssue(r(l,I)),u}),k=await Reflect.apply(o,this,p);return await c._def.returns._def.type.parseAsync(k,s).catch(I=>{throw u.addIssue(a(k,I)),u})})}else{const c=this;return N(function(...l){const u=c._def.args.safeParse(l,s);if(!u.success)throw new C([r(l,u.error)]);const p=Reflect.apply(o,this,u.data),k=c._def.returns.safeParse(p,s);if(!k.success)throw new C([a(p,k.error)]);return k.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new K({...this._def,args:O.create(e).rest(Q.create())})}returns(e){return new K({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new K({args:e||O.create([]).rest(Q.create()),returns:t||Q.create(),typeName:y.ZodFunction,...b(r)})}}class le extends x{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})}}le.create=(n,e)=>new le({getter:n,typeName:y.ZodLazy,...b(e)});class me extends x{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return m(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}}me.create=(n,e)=>new me({value:n,typeName:y.ZodLiteral,...b(e)});function Ke(n,e){return new U({values:n,typeName:y.ZodEnum,...b(e)})}class U extends x{constructor(){super(...arguments),re.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return m(t,{expected:_.joinValues(r),received:t.parsedType,code:d.invalid_type}),v}if(Te(this,re)||Ye(this,re,new Set(this._def.values)),!Te(this,re).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return m(t,{received:t.data,code:d.invalid_enum_value,options:r}),v}return N(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 U.create(e,{...this._def,...t})}exclude(e,t=this._def){return U.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}re=new WeakMap,U.create=Ke;class fe extends x{constructor(){super(...arguments),ae.set(this,void 0)}_parse(e){const t=_.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==f.string&&r.parsedType!==f.number){const a=_.objectValues(t);return m(r,{expected:_.joinValues(a),received:r.parsedType,code:d.invalid_type}),v}if(Te(this,ae)||Ye(this,ae,new Set(_.getValidEnumValues(this._def.values))),!Te(this,ae).has(e.data)){const a=_.objectValues(t);return m(r,{received:r.data,code:d.invalid_enum_value,options:a}),v}return N(e.data)}get enum(){return this._def.values}}ae=new WeakMap,fe.create=(n,e)=>new fe({values:n,typeName:y.ZodNativeEnum,...b(e)});class ee extends x{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return m(t,{code:d.invalid_type,expected:f.promise,received:t.parsedType}),v;const r=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return N(r.then(a=>this._def.type.parseAsync(a,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ee.create=(n,e)=>new ee({type:n,typeName:y.ZodPromise,...b(e)});class Z extends x{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),a=this._def.effect||null,s={addIssue:o=>{m(r,o),o.fatal?t.abort():t.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),a.type==="preprocess"){const o=a.transform(r.data,s);if(r.common.async)return Promise.resolve(o).then(async c=>{if(t.value==="aborted")return v;const l=await this._def.schema._parseAsync({data:c,path:r.path,parent:r});return l.status==="aborted"?v:l.status==="dirty"||t.value==="dirty"?X(l.value):l});{if(t.value==="aborted")return v;const c=this._def.schema._parseSync({data:o,path:r.path,parent:r});return c.status==="aborted"?v:c.status==="dirty"||t.value==="dirty"?X(c.value):c}}if(a.type==="refinement"){const o=c=>{const l=a.refinement(c,s);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(r.common.async===!1){const c=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return c.status==="aborted"?v:(c.status==="dirty"&&t.dirty(),o(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(c=>c.status==="aborted"?v:(c.status==="dirty"&&t.dirty(),o(c.value).then(()=>({status:t.value,value:c.value}))))}if(a.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!B(o))return o;const c=a.transform(o.value,s);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:c}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>B(o)?Promise.resolve(a.transform(o.value,s)).then(c=>({status:t.value,value:c})):o);_.assertNever(a)}}Z.create=(n,e,t)=>new Z({schema:n,typeName:y.ZodEffects,effect:e,...b(t)}),Z.createWithPreprocess=(n,e,t)=>new Z({schema:e,effect:{type:"preprocess",transform:n},typeName:y.ZodEffects,...b(t)});class P extends x{_parse(e){return this._getType(e)===f.undefined?N(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}P.create=(n,e)=>new P({innerType:n,typeName:y.ZodOptional,...b(e)});class q extends x{_parse(e){return this._getType(e)===f.null?N(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}q.create=(n,e)=>new q({innerType:n,typeName:y.ZodNullable,...b(e)});class pe extends x{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===f.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}pe.create=(n,e)=>new pe({innerType:n,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...b(e)});class he extends x{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return ne(a)?a.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new C(r.common.issues)},input:r.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new C(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}he.create=(n,e)=>new he({innerType:n,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...b(e)});class Ae extends x{_parse(e){if(this._getType(e)!==f.nan){const r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_type,expected:f.nan,received:r.parsedType}),v}return{status:"valid",value:e.data}}}Ae.create=n=>new Ae({typeName:y.ZodNaN,...b(n)});const Ut=Symbol("zod_brand");class Ee extends x{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class ge extends x{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?v:s.status==="dirty"?(t.dirty(),X(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const a=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?v:a.status==="dirty"?(t.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:r.path,parent:r})}}static create(e,t){return new ge({in:e,out:t,typeName:y.ZodPipeline})}}class ye extends x{_parse(e){const t=this._def.innerType._parse(e),r=a=>(B(a)&&(a.value=Object.freeze(a.value)),a);return ne(t)?t.then(a=>r(a)):r(t)}unwrap(){return this._def.innerType}}ye.create=(n,e)=>new ye({innerType:n,typeName:y.ZodReadonly,...b(e)});function et(n,e){const t=typeof n=="function"?n(e):typeof n=="string"?{message:n}:n;return typeof t=="string"?{message:t}:t}function tt(n,e={},t){return n?J.create().superRefine((r,a)=>{var s,o;const c=n(r);if(c instanceof Promise)return c.then(l=>{var u,p;if(!l){const k=et(e,r),T=(p=(u=k.fatal)!==null&&u!==void 0?u:t)!==null&&p!==void 0?p:!0;a.addIssue({code:"custom",...k,fatal:T})}});if(!c){const l=et(e,r),u=(o=(s=l.fatal)!==null&&s!==void 0?s:t)!==null&&o!==void 0?o:!0;a.addIssue({code:"custom",...l,fatal:u})}}):J.create()}const qt={object:w.lazycreate};var y;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(y||(y={}));const Bt=(n,e={message:`Input not instance of ${n.name}`})=>tt(t=>t instanceof n,e),nt=A.create,rt=z.create,Wt=Ae.create,Qt=L.create,at=ie.create,Yt=W.create,Gt=Se.create,Xt=se.create,Jt=oe.create,Ht=J.create,Kt=Q.create,en=$.create,tn=Ne.create,nn=D.create,rn=w.create,an=w.strictCreate,sn=ce.create,on=Ie.create,cn=ue.create,un=O.create,dn=de.create,ln=Ce.create,mn=Y.create,fn=K.create,pn=le.create,hn=me.create,gn=U.create,yn=fe.create,vn=ee.create,it=Z.create,_n=P.create,bn=q.create,xn=Z.createWithPreprocess,kn=ge.create;var i=Object.freeze({__proto__:null,defaultErrorMap:G,setErrorMap:bt,getErrorMap:ke,makeIssue:we,EMPTY_PATH:xt,addIssueToContext:m,ParseStatus:S,INVALID:v,DIRTY:X,OK:N,isAborted:Ze,isDirty:je,isValid:B,isAsync:ne,get util(){return _},get objectUtil(){return F},ZodParsedType:f,getParsedType:M,ZodType:x,datetimeRegex:He,ZodString:A,ZodNumber:z,ZodBigInt:L,ZodBoolean:ie,ZodDate:W,ZodSymbol:Se,ZodUndefined:se,ZodNull:oe,ZodAny:J,ZodUnknown:Q,ZodNever:$,ZodVoid:Ne,ZodArray:D,ZodObject:w,ZodUnion:ce,ZodDiscriminatedUnion:Ie,ZodIntersection:ue,ZodTuple:O,ZodRecord:de,ZodMap:Ce,ZodSet:Y,ZodFunction:K,ZodLazy:le,ZodLiteral:me,ZodEnum:U,ZodNativeEnum:fe,ZodPromise:ee,ZodEffects:Z,ZodTransformer:Z,ZodOptional:P,ZodNullable:q,ZodDefault:pe,ZodCatch:he,ZodNaN:Ae,BRAND:Ut,ZodBranded:Ee,ZodPipeline:ge,ZodReadonly:ye,custom:tt,Schema:x,ZodSchema:x,late:qt,get ZodFirstPartyTypeKind(){return y},coerce:{string:n=>A.create({...n,coerce:!0}),number:n=>z.create({...n,coerce:!0}),boolean:n=>ie.create({...n,coerce:!0}),bigint:n=>L.create({...n,coerce:!0}),date:n=>W.create({...n,coerce:!0})},any:Ht,array:nn,bigint:Qt,boolean:at,date:Yt,discriminatedUnion:on,effect:it,enum:gn,function:fn,instanceof:Bt,intersection:cn,lazy:pn,literal:hn,map:ln,nan:Wt,nativeEnum:yn,never:en,null:Jt,nullable:bn,number:rt,object:rn,oboolean:()=>at().optional(),onumber:()=>rt().optional(),optional:_n,ostring:()=>nt().optional(),pipeline:kn,preprocess:xn,promise:vn,record:dn,set:mn,strictObject:an,string:nt,symbol:Gt,transformer:it,tuple:un,undefined:Xt,union:sn,unknown:Kt,void:tn,NEVER:v,ZodIssueCode:d,quotelessJson:_t,ZodError:C});const ve=i.object({country:i.string().optional(),city:i.string().optional(),street:i.string().optional(),streetNumber:i.string().optional(),floor:i.string().optional(),apartmentEnterNumber:i.string().optional(),apartmentNumber:i.string().optional()}),E=i.string().min(1,{message:"שדה חובה"}),wn=i.string().regex(/^\d+$/,"Must be a numeric string"),Tn=i.object({url:i.string().url(),id:i.string()});function Sn(n){return!!(n!=null&&n.url)}const te=i.object({lang:i.enum(["he"]),value:i.string()}),Nn=i.array(te),Re=i.object({id:i.string().min(1),companyId:i.string().min(1),storeId:i.string().min(1),parentId:i.string().nullish(),tag:i.string().optional(),locales:i.array(te),depth:i.number()}),De=Re.extend({children:i.lazy(()=>De.array())}),In=Re.extend({index:i.number(),depth:i.number(),collapsed:i.boolean().optional(),children:i.array(De)}),_e=i.string().min(1),Me=i.object({type:i.literal("Product"),storeId:_e,companyId:_e,id:_e,objectID:_e,sku:_e,name:i.array(te),description:i.array(te),isPublished:i.boolean(),vat:i.boolean(),priceType:i.object({type:i.enum(["unit","kg","gram","liter","ml"]),value:i.number()}),price:i.number().positive(),purchasePrice:i.number().optional(),profitPercentage:i.number().optional(),currency:i.literal("ILS"),discount:i.object({type:i.enum(["number","percent","none"]),value:i.number()}),isDiscountable:i.boolean({description:"included in store discounts"}).optional(),weight:i.object({value:i.number(),unit:i.enum(["kg","gram","none"])}),volume:i.object({value:i.number(),unit:i.enum(["liter","ml","none"])}),images:i.array(i.object({url:i.string().url(),id:i.string()})),manufacturer:i.string(),brand:i.string(),importer:i.string(),supplier:i.string(),ingredients:i.array(te),created_at:i.number(),updated_at:i.number(),categoryIds:i.array(i.string().nonempty()),stock:i.object({quantity:i.number().min(0),unit:i.enum(["piece","kg","gram","liter","ml"])}).optional(),categoryList:i.array(De).optional(),categories:i.object({lvl0:i.array(i.string()),lvl1:i.array(i.string()),lvl2:i.array(i.string()),lvl3:i.array(i.string()),lvl4:i.array(i.string())}).optional(),categoryNames:i.array(i.string()).optional()}),Cn=Me.extend({image:i.instanceof(File).optional()}),$e=i.object({product:Me,originalPrice:i.number().optional(),finalPrice:i.number().optional(),finalDiscount:i.number().optional(),amount:i.number().positive({message:"Quantity must be a positive number."})}),An=i.object({type:i.literal("Cart"),id:i.string().uuid(),companyId:i.string().uuid(),storeId:i.string().uuid(),userId:i.string().uuid(),status:i.enum(["active","draft","completed"]),items:i.array($e)}),Dn=i.object({id:i.string(),name:i.string(),websiteDomains:i.array(i.string())}),Zn=i.object({type:i.literal("FavoriteProduct"),id:i.string().uuid(),companyId:i.string().uuid(),storeId:i.string().uuid(),userId:i.string().uuid(),productId:i.string().uuid()}),be=i.enum(["external","j5","none"]),st=i.object({type:i.literal("Profile"),id:E,companyId:E,storeId:E,tenantId:E,clientType:i.enum(["user","company"]),companyName:i.string().optional(),displayName:E,email:i.string().email(),phoneNumber:i.string().optional(),address:ve.optional(),isAnonymous:i.boolean(),createdDate:i.number(),lastActivityDate:i.number(),paymentType:be.optional(),organizationId:i.string().optional().nullable()}),Ve=i.object({_COMMENT:i.string().optional(),transaction_id:i.string(),date:i.string().regex(/^\d{4}-\d{2}-\d{2}$/,"Date must be in YYYY-MM-DD format"),currency:i.string().length(3,"Currency must be 3 characters"),rate:i.number().positive(),vat:i.string().regex(/^\d+\.\d{2}$/,"VAT must be in format XX.XX"),vat_price:i.number().positive(),price_discount:i.number(),price_discount_in_currency:i.number(),price_total:i.string().regex(/^\d+\.\d{2}$/,"Price total must be in format XX.XX"),price_total_in_currency:i.number().positive()}),ot=i.object({doc_uuid:i.string().uuid("Document UUID must be a valid UUID"),pdf_link:i.string().url("PDF link must be a valid URL"),pdf_link_copy:i.string().url("PDF copy link must be a valid URL"),doc_number:i.string().min(1,"Document number is required"),sent_mails:i.array(i.string().email("Each email must be valid")),success:i.boolean(),ua_uuid:i.string().uuid("UA UUID must be a valid UUID"),calculatedData:Ve,warning:i.string().optional(),date:i.number().optional()}),ct=i.object({id:i.string().min(1,"ID is required"),number:i.string().min(1,"Number is required"),date:i.number().min(1,"Date is required"),createdAt:i.number().min(1,"Created at is required"),status:i.enum(["pending","paid","cancelled"]),companyDetails:i.object({name:i.string().min(1,"Name is required").optional(),address:i.string().min(1,"Address is required").optional(),phone:i.string().min(1,"Phone is required").optional(),email:i.string().email("Email must be valid").optional()}).optional(),clientDetails:i.object({name:i.string().min(1,"Name is required").optional(),address:i.string().min(1,"Address is required").optional(),phone:i.string().min(1,"Phone is required").optional(),email:i.string().email("Email must be valid").optional()}).optional(),items:i.array(i.object({name:i.string().min(1,"Name is required").optional(),price:i.number().min(1,"Price is required").optional(),quantity:i.number().min(1,"Quantity is required").optional(),total:i.number().min(1,"Total is required").optional()})).optional(),total:i.number().min(1,"Total is required").optional(),vat:i.number().min(1,"VAT is required").optional(),link:i.string().url("Link must be a valid URL").optional()}),Fe=i.object({number:i.string(),name:i.string(),id:i.string()}),ut=i.object({id:i.string(),name:i.string(),discountPercentage:i.number().positive().min(0).max(100).optional(),nameOnInvoice:i.string().optional(),billingAccounts:i.array(Fe),paymentType:be,companyNumber:i.string().optional(),address:ve.optional(),groupId:i.string().optional()}),jn=ut.omit({id:!0}),On=i.object({doc_uuid:i.string().uuid("Document UUID must be a valid UUID"),pdf_link:i.string().url("PDF link must be a valid URL"),pdf_link_copy:i.string().url("PDF copy link must be a valid URL"),doc_number:i.string().min(1,"Document number is required"),sent_mails:i.array(i.string().email("Each email must be valid")),success:i.boolean(),ua_uuid:i.string().uuid("UA UUID must be a valid UUID"),calculatedData:Ve,warning:i.string().optional(),date:i.number().optional()}),Pn=i.object({id:i.string().min(1,"ID is required"),number:i.string().min(1,"Number is required"),date:i.string().min(1,"Date is required"),createdAt:i.number().min(1,"Created at is required"),status:i.enum(["pending","paid","cancelled"]),companyDetails:i.object({name:i.string().min(1,"Name is required").optional(),address:i.string().min(1,"Address is required").optional(),phone:i.string().min(1,"Phone is required").optional(),email:i.string().email("Email must be valid").optional()}).optional(),clientDetails:i.object({name:i.string().min(1,"Name is required").optional(),address:i.string().min(1,"Address is required").optional(),phone:i.string().min(1,"Phone is required").optional(),email:i.string().email("Email must be valid").optional()}).optional(),items:i.array(i.object({name:i.string().min(1,"Name is required").optional(),price:i.number().min(1,"Price is required").optional(),quantity:i.number().min(1,"Quantity is required").optional(),total:i.number().min(1,"Total is required").optional()})).optional(),total:i.number().min(1,"Total is required").optional(),vat:i.number().min(1,"VAT is required").optional(),link:i.string().url("Link must be a valid URL").optional()}),En=i.object({type:i.literal("Order"),createdBy:i.enum(["user","admin"]).optional(),id:E,companyId:E,storeId:E,userId:E,status:i.enum(["draft","pending","processing","in_delivery","delivered","cancelled","completed","refunded"]),paymentType:be.optional(),paymentStatus:i.enum(["pending","pending_j5","external","completed","failed","refunded"]),cart:i.object({id:i.string(),items:i.array($e),cartDiscount:i.number(),cartTotal:i.number(),cartVat:i.number(),deliveryPrice:i.number().optional()}),storeOptions:i.object({deliveryPrice:i.number().optional(),freeDeliveryPrice:i.number().optional(),isVatIncludedInPrice:i.boolean().optional()}).optional(),originalAmount:i.number().positive().optional(),actualAmount:i.number().positive().optional(),date:i.number(),deliveryDate:i.coerce.number(),client:st.optional(),address:ve.optional(),nameOnInvoice:i.string().optional(),emailOnInvoice:i.string().email().optional(),phoneNumberOnInvoice:i.string().optional(),clientComment:i.string().optional(),organizationId:i.string().optional(),billingAccount:Fe.optional(),deliveryNote:ct.optional(),invoice:Pn.optional(),ezInvoice:On.optional(),ezDeliveryNote:ot.optional()}),dt=i.enum(["individual","company"]),Rn=i.object({id:i.string(),companyId:i.string(),name:i.string(),urls:i.array(i.string()),logoUrl:i.string(),tenantId:i.string(),paymentType:be,allowAnonymousClients:i.boolean(),isVatIncludedInPrice:i.boolean(),clientTypes:i.array(dt),minimumOrder:i.number().optional(),freeDeliveryPrice:i.number().optional(),deliveryPrice:i.number().optional(),address:ve.optional(),companyNumber:i.string().optional()}),lt=i.object({minSpend:i.number().positive().optional(),stackable:i.boolean().default(!1)}).optional(),mt=i.discriminatedUnion("variantType",[i.object({variantType:i.literal("bundle"),productsId:i.array(i.string().nonempty()).min(1),requiredQuantity:i.number().positive(),bundlePrice:i.number().positive()})]),Mn=i.object({type:i.literal("Discount"),storeId:i.string().min(1),companyId:i.string().min(1),id:i.string().min(1),name:i.array(i.object({lang:i.enum(["he"]),value:i.string().nonempty()})),active:i.boolean(),startDate:i.number(),endDate:i.number(),variant:mt,conditions:lt});class ft{canApply(e,t){if(e.variant.variantType!=="bundle"||!this.isDiscountActive(e))return!1;const{productsId:r,requiredQuantity:a}=e.variant;return this.getTotalQuantity(t.cart,r)>=a}calculate(e,t){if(e.variant.variantType!=="bundle")return{applicable:!1,discountAmount:0,affectedItems:[]};const{productsId:r,requiredQuantity:a,bundlePrice:s}=e.variant,o=t.cart.filter(xe=>r.includes(xe.product.id)),c=this.getTotalQuantity(t.cart,r),l=Math.floor(c/a);if(l===0)return{applicable:!1,discountAmount:0,affectedItems:[]};const u=this.calculateOriginalPrice(o),p=this.getTotalQuantity(t.cart,r),k=this.calculateDiscountedPrice(u,s,l,a,p),T=u-k,I=this.distributeDiscount(o,T,u);return{applicable:!0,discountAmount:Number(T.toFixed(2)),affectedItems:I}}isDiscountActive(e){const t=Date.now();return e.active&&e.startDate<=t&&e.endDate>=t}getTotalQuantity(e,t){return e.filter(r=>t.includes(r.product.id)).reduce((r,a)=>r+a.amount,0)}calculateOriginalPrice(e){return e.reduce((t,r)=>t+r.product.price*r.amount,0)}calculateDiscountedPrice(e,t,r,a,s){const o=t*r,c=r*a,u=Math.max(0,s-c)/s*e;return o+u}distributeDiscount(e,t,r){const a=t/r;return e.map(s=>{const o=s.product.price*s.amount*a;return{productId:s.product.id,quantity:s.amount,originalPrice:Number(s.product.price.toFixed(2)),discountedPrice:Number((s.product.price-o/s.amount).toFixed(2)),discountAmount:Number(o.toFixed(2))}})}}class ze{static getStrategy(e){return this.strategies.get(e.variant.variantType)||null}static registerStrategy(e,t){this.strategies.set(e,t)}static getRegisteredTypes(){return Array.from(this.strategies.keys())}static clearStrategies(){this.strategies.clear()}}vt(ze,"strategies",new Map([["bundle",new ft]]));class pt{static calculateDiscounts(e,t,r){var u,p;const a={cart:e,user:r,appliedDiscounts:[]},s=this.filterActiveDiscounts(t),o=[];for(const k of s){const T=ze.getStrategy(k);if(!T||!T.canApply(k,a)||!((u=k.conditions)!=null&&u.stackable)&&o.length>0)continue;const I=T.calculate(k,a);I.applicable&&(o.push({discountId:k.id,discountName:((p=k.name[0])==null?void 0:p.value)||"Discount",discountAmount:Number(I.discountAmount.toFixed(2)),affectedItems:I.affectedItems}),a.appliedDiscounts=o)}const c=this.calculateFinalPrices(e,o),l=o.reduce((k,T)=>k+T.discountAmount,0);return{items:c,totalDiscount:Number(l.toFixed(2)),appliedDiscounts:o}}static filterActiveDiscounts(e){const t=Date.now();return e.filter(r=>r.active&&r.startDate<=t&&r.endDate>=t)}static calculateFinalPrices(e,t){return e.map(r=>{const a=t.filter(l=>l.affectedItems.some(u=>u.productId===r.product.id)),s=a.reduce((l,u)=>{const p=u.affectedItems.find(k=>k.productId===r.product.id);return l+((p==null?void 0:p.discountAmount)||0)},0),o=s/r.amount,c=r.product.price-o;return{amount:r.amount,product:r.product,originalPrice:Number(r.product.price.toFixed(2)),finalPrice:Number(Math.max(0,c).toFixed(2)),finalDiscount:Number(s.toFixed(2)),appliedDiscounts:a.map(l=>l.discountId)}})}static isDiscountActive(e){const t=Date.now();return e.active&&e.startDate<=t&&e.endDate>=t}static getActiveDiscounts(e){return this.filterActiveDiscounts(e)}}function Le(n){return Number(n.toFixed(2))}function $n(n){return n.toFixed(2)}function Vn(n){return Math.max(0,Le(n))}function Fn(n,e){if(n<=0)return 0;const t=n-e;return Le(t/n*100)}const ht=i.object({id:i.string(),name:i.string()}),zn=ht.omit({id:!0}),Ue=i.object({type:i.literal("Supplier"),id:i.string(),name:i.string(),code:i.string()}),Ln=Ue.omit({id:!0}),gt=i.object({type:i.literal("SupplierInvoice"),id:i.string(),supplier:Ue,invoiceNumber:i.string(),date:i.number(),rows:i.array(i.object({id:i.string(),rowNumber:i.number(),sku:i.string(),itemName:i.string(),quantity:i.number(),purchasePrice:i.number(),lineDiscount:i.number(),profitPercentage:i.number(),price:i.number(),totalPurchasePrice:i.number(),vat:i.boolean(),originalProduct:i.object({purchasePrice:i.number(),price:i.number(),profitPercentage:i.number()}).optional()})),productsToUpdate:i.array(i.object({sku:i.string(),itemName:i.string(),oldPurchasePrice:i.number(),newPurchasePrice:i.number(),oldPrice:i.number(),newPrice:i.number(),oldProfitPercentage:i.number(),newProfitPercentage:i.number()})),total:i.number().optional(),totalBeforeVat:i.number().optional(),vat:i.number().optional()}),Un=gt.omit({id:!0}),yt={VAT:18};function qn(n){var e,t;return((e=n.discount)==null?void 0:e.type)==="percent"?n.price*(n.discount.value??100)/100:((t=n.discount)==null?void 0:t.type)==="number"?n.discount.value??0:0}function Bn(n){var e,t;if(((e=n.discount)==null?void 0:e.type)==="percent"){const r=n.price*n.discount.value/100;return n.price-r}return((t=n.discount)==null?void 0:t.type)==="number"?n.price-n.discount.value:n.price}function Wn({cart:n,discounts:e,deliveryPrice:t=0,freeDeliveryPrice:r=0,isVatIncludedInPrice:a=!1}){const s=n.map(u=>({amount:u.amount,product:{id:u.product.id,price:u.product.price}})),o=pt.calculateDiscounts(s,e),c=n.map((u,p)=>{const k=o.items[p];return{amount:u.amount,product:{...u.product},originalPrice:u.product.price,finalPrice:k?k.finalPrice:Bn(u.product),finalDiscount:k?k.finalDiscount:qn(u.product)}}),l=c.reduce((u,p)=>{const{product:k,amount:T,finalPrice:I,finalDiscount:xe}=p;let R=0;if(k.vat){let We=0;if(a){const Gn=Number((I/(1+yt.VAT/100)).toFixed(2)),Xn=I-Gn;R=Number(Xn.toFixed(2)),R=R*T,We=Number(R.toFixed(2))}else R=I*yt.VAT/100,R=R*T,We=Number(R.toFixed(2));u.vat=Number((u.vat+We).toFixed(2))}const Be=Number(I.toFixed(2));return u.cost+=T*Be,u.discount+=xe&&T*xe,u.finalCost+=T*Be+(a?0:R),u.productsCost+=T*Be+(a?0:R),u.cost=Number(u.cost.toFixed(2)),u.discount=Number(u.discount.toFixed(2)),u.finalCost=Number(u.finalCost.toFixed(2)),u.productsCost=Number(u.productsCost.toFixed(2)),u},{discount:0,cost:0,finalCost:0,vat:0,productsCost:0,deliveryPrice:t});return l.deliveryPrice&&l.productsCost>=r?l.deliveryPrice=0:l.finalCost+=l.deliveryPrice,console.log("cartDetails",l),{items:c,...l}}const Qn={firestore:{systemCollections:{stores:"STORES",companies:"COMPANIES"},storeCollections:{products:"products","favorite-products":"favorite-products",profiles:"profiles",cart:"cart",clients:"clients",orders:"orders",categories:"categories",payments:"payments",settings:"settings",discounts:"discounts",organizations:"organizations",organizationGroups:"organizationGroups",invoices:"invoices",suppliers:"suppliers",supplierInvoices:"supplierInvoices"},getPath:({companyId:n,storeId:e,collectionName:t,id:r})=>`${n}/${e}/${t}${r?`/${r}`:""}`,getDocPath:n=>`{companyId}/{storeId}/${n}/{id}`}},qe={round:(n,e=2)=>{const t=10**e;return Math.round((n+Number.EPSILON)*t)/t}},Yn={calcSalePriceFromMargin:(n,e)=>n<=0||e<=0||n>=100?e:qe.round(e/(1-n/100)),calcMarginFromSalePrice:(n,e)=>n<=0||e<=0?0:qe.round((n-e)/n*100)};g.AddressSchema=ve,g.BaseCategorySchema=Re,g.BillingAccountSchema=Fe,g.BundleDiscountStrategy=ft,g.CalculatedDataSchema=Ve,g.CartItemProductSchema=$e,g.CartSchema=An,g.CategorySchema=De,g.CompanySchema=Dn,g.DeliveryNoteSchema=ct,g.DiscountConditionsSchema=lt,g.DiscountEngine=pt,g.DiscountSchema=Mn,g.DiscountStrategyFactory=ze,g.DiscountVariantSchema=mt,g.EzDeliveryNoteSchema=ot,g.FavoriteProductSchema=Zn,g.FileSchema=Tn,g.FirebaseAPI=Qn,g.LocaleSchema=te,g.LocaleValueSchema=Nn,g.NewOrganizationGroupSchema=zn,g.NewOrganizationSchema=jn,g.NewProductSchema=Cn,g.NewSupplierInvoiceSchema=Un,g.NewSupplierSchema=Ln,g.OrderSchema=En,g.OrganizationGroupSchema=ht,g.OrganizationSchema=ut,g.PaymentTypeSchema=be,g.ProductSchema=Me,g.ProfileSchema=st,g.StoreSchema=Rn,g.SupplierInvoiceSchema=gt,g.SupplierSchema=Ue,g.TFlattenCategorySchema=In,g.calculatePercentageDiscount=Fn,g.clientTypesSchema=dt,g.ensureNonNegative=Vn,g.formatCurrency=Le,g.formatCurrencyString=$n,g.getCartCost=Wn,g.isFile=Sn,g.math=qe,g.notEmptyTextSchema=E,g.numericTextSchema=wn,g.storeCalculator=Yn,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(h,_){typeof exports=="object"&&typeof module<"u"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(h=typeof globalThis<"u"?globalThis:h||self,_(h.core={}))})(this,function(h){"use strict";var Kn=Object.defineProperty;var er=(h,_,F)=>_ in h?Kn(h,_,{enumerable:!0,configurable:!0,writable:!0,value:F}):h[_]=F;var vt=(h,_,F)=>er(h,typeof _!="symbol"?_+"":_,F);var _;(function(n){n.assertEqual=s=>s;function e(s){}n.assertIs=e;function t(s){throw new Error}n.assertNever=t,n.arrayToEnum=s=>{const i={};for(const o of s)i[o]=o;return i},n.getValidEnumValues=s=>{const i=n.objectKeys(s).filter(c=>typeof s[s[c]]!="number"),o={};for(const c of i)o[c]=s[c];return n.objectValues(o)},n.objectValues=s=>n.objectKeys(s).map(function(i){return s[i]}),n.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},n.find=(s,i)=>{for(const o of s)if(i(o))return o},n.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}n.joinValues=r,n.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(_||(_={}));var F;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(F||(F={}));const f=_.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),$=n=>{switch(typeof n){case"undefined":return f.undefined;case"string":return f.string;case"number":return isNaN(n)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(n)?f.array:n===null?f.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?f.promise:typeof Map<"u"&&n instanceof Map?f.map:typeof Set<"u"&&n instanceof Set?f.set:typeof Date<"u"&&n instanceof Date?f.date:f.object;default:return f.unknown}},d=_.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"]),_t=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class C extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};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(i){return i.message},r={_errors:[]},s=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(t(o));else{let c=r,l=0;for(;l<o.path.length;){const u=o.path[l];l===o.path.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(o))):c[u]=c[u]||{_errors:[]},c=c[u],l++}}};return s(this),r}static assert(e){if(!(e instanceof C))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,_.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}C.create=n=>new C(n);const G=(n,e)=>{let t;switch(n.code){case d.invalid_type:n.received===f.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case d.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,_.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:t=`Unrecognized key(s) in object: ${_.joinValues(n.keys,", ")}`;break;case d.invalid_union:t="Invalid input";break;case d.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${_.joinValues(n.options)}`;break;case d.invalid_enum_value:t=`Invalid enum value. Expected ${_.joinValues(n.options)}, received '${n.received}'`;break;case d.invalid_arguments:t="Invalid function arguments";break;case d.invalid_return_type:t="Invalid function return type";break;case d.invalid_date:t="Invalid date";break;case d.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:_.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case d.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case d.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case d.custom:t="Invalid input";break;case d.invalid_intersection_types:t="Intersection results could not be merged";break;case d.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case d.not_finite:t="Number must be finite";break;default:t=e.defaultError,_.assertNever(n)}return{message:t}};let Qe=G;function bt(n){Qe=n}function xe(){return Qe}const we=n=>{const{data:e,path:t,errorMaps:r,issueData:s}=n,i=[...t,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let c="";const l=r.filter(u=>!!u).slice().reverse();for(const u of l)c=u(o,{data:e,defaultError:c}).message;return{...s,path:i,message:c}},kt=[];function m(n,e){const t=xe(),r=we({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===G?void 0:G].filter(s=>!!s)});n.common.issues.push(r)}class T{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const s of t){if(s.status==="aborted")return v;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const s of t){const i=await s.key,o=await s.value;r.push({key:i,value:o})}return T.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const s of t){const{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return v;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[i.value]=o.value)}return{status:e.value,value:r}}}const v=Object.freeze({status:"aborted"}),X=n=>({status:"dirty",value:n}),I=n=>({status:"valid",value:n}),De=n=>n.status==="aborted",Ze=n=>n.status==="dirty",B=n=>n.status==="valid",ne=n=>typeof Promise<"u"&&n instanceof Promise;function Se(n,e,t,r){if(typeof e=="function"?n!==e||!0:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function Ye(n,e,t,r,s){if(typeof e=="function"?n!==e||!0:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}typeof SuppressedError=="function"&&SuppressedError;var g;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(g||(g={}));var re,ae;class Z{constructor(e,t,r,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Ge=(n,e)=>{if(B(e))return{success:!0,data:e.value};if(!n.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 C(n.common.issues);return this._error=t,this._error}}};function b(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,c)=>{var l,u;const{message:p}=n;return o.code==="invalid_enum_value"?{message:p??c.defaultError}:typeof c.data>"u"?{message:(l=p??r)!==null&&l!==void 0?l:c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:(u=p??t)!==null&&u!==void 0?u:c.defaultError}},description:s}}class k{get description(){return this._def.description}_getType(e){return $(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:$(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new T,ctx:{common:e.parent.common,data:e.data,parsedType:$(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ne(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 r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const s={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$(e)},i=this._parseSync({data:e,path:s.path,parent:s});return Ge(s,i)}"~validate"(e){var t,r;const s={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:s});return B(i)?{value:i.value}:{issues:s.common.issues}}catch(i){!((r=(t=i==null?void 0:i.message)===null||t===void 0?void 0:t.toLowerCase())===null||r===void 0)&&r.includes("encountered")&&(this["~standard"].async=!0),s.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:s}).then(i=>B(i)?{value:i.value}:{issues:s.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={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:$(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(ne(s)?s:Promise.resolve(s));return Ge(r,i)}refine(e,t){const r=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const o=e(s),c=()=>i.addIssue({code:d.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new D({schema:this,typeName:y.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 P.create(this,this._def)}nullable(){return q.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return j.create(this)}promise(){return ee.create(this,this._def)}or(e){return ce.create([this,e],this._def)}and(e){return ue.create(this,e,this._def)}transform(e){return new D({...b(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new pe({...b(this._def),innerType:this,defaultValue:t,typeName:y.ZodDefault})}brand(){return new Ee({typeName:y.ZodBranded,type:this,...b(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new he({...b(this._def),innerType:this,catchValue:t,typeName:y.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ge.create(this,e)}readonly(){return ye.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const xt=/^c[^\s-]{8,}$/i,wt=/^[0-9a-z]+$/,St=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Tt=/^[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,It=/^[a-z0-9_-]{21}$/i,Nt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ct=/^[-+]?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)?)??$/,At=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,jt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Oe;const Dt=/^(?:(?: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])$/,Zt=/^(?:(?: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])$/,Ot=/^(([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]))$/,Pt=/^(([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])$/,Et=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Rt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Xe="((\\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])))",$t=new RegExp(`^${Xe}$`);function Je(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Mt(n){return new RegExp(`^${Je(n)}$`)}function He(n){let e=`${Xe}T${Je(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Vt(n,e){return!!((e==="v4"||!e)&&Dt.test(n)||(e==="v6"||!e)&&Ot.test(n))}function Ft(n,e){if(!Nt.test(n))return!1;try{const[t]=n.split("."),r=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||!s.typ||!s.alg||e&&s.alg!==e)}catch{return!1}}function zt(n,e){return!!((e==="v4"||!e)&&Zt.test(n)||(e==="v6"||!e)&&Pt.test(n))}class A extends k{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){const i=this._getOrReturnCtx(e);return m(i,{code:d.invalid_type,expected:f.string,received:i.parsedType}),v}const r=new T;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:d.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:d.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const o=e.data.length>i.value,c=e.data.length<i.value;(o||c)&&(s=this._getOrReturnCtx(e,s),o?m(s,{code:d.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):c&&m(s,{code:d.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")At.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"email",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Oe||(Oe=new RegExp(jt,"u")),Oe.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"emoji",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")Tt.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"uuid",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")It.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"nanoid",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")xt.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cuid",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")wt.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cuid2",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")St.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"ulid",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),m(s,{validation:"url",code:d.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"regex",code:d.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?He(i).test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?$t.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Mt(i).test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?Ct.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"duration",code:d.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Vt(e.data,i.version)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"ip",code:d.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?Ft(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"jwt",code:d.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?zt(e.data,i.version)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cidr",code:d.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?Et.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"base64",code:d.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Rt.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"base64url",code:d.invalid_string,message:i.message}),r.dirty()):_.assertNever(i);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(s=>e.test(s),{validation:t,code:d.invalid_string,...g.errToObj(r)})}_addCheck(e){return new A({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...g.errToObj(e)})}url(e){return this._addCheck({kind:"url",...g.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...g.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...g.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...g.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...g.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...g.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...g.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...g.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...g.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...g.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...g.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...g.errToObj(e)})}datetime(e){var t,r;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:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!1,...g.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,...g.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...g.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...g.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...g.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...g.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...g.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...g.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...g.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...g.errToObj(t)})}nonempty(e){return this.min(1,g.errToObj(e))}trim(){return new A({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new A({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new A({...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}}A.create=n=>{var e;return new A({checks:[],typeName:y.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...b(n)})};function Lt(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=t>r?t:r,i=parseInt(n.toFixed(s).replace(".","")),o=parseInt(e.toFixed(s).replace(".",""));return i%o/Math.pow(10,s)}class z 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)!==f.number){const i=this._getOrReturnCtx(e);return m(i,{code:d.invalid_type,expected:f.number,received:i.parsedType}),v}let r;const s=new T;for(const i of this._def.checks)i.kind==="int"?_.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:d.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:d.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:d.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Lt(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),m(r,{code:d.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:d.not_finite,message:i.message}),s.dirty()):_.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,g.toString(t))}gt(e,t){return this.setLimit("min",e,!1,g.toString(t))}lte(e,t){return this.setLimit("max",e,!0,g.toString(t))}lt(e,t){return this.setLimit("max",e,!1,g.toString(t))}setLimit(e,t,r,s){return new z({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:g.toString(s)}]})}_addCheck(e){return new z({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:g.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:g.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:g.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:g.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:g.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"&&_.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}z.create=n=>new z({checks:[],typeName:y.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...b(n)});class L 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)!==f.bigint)return this._getInvalidInput(e);let r;const s=new T;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:d.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:d.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),m(r,{code:d.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):_.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return m(t,{code:d.invalid_type,expected:f.bigint,received:t.parsedType}),v}gte(e,t){return this.setLimit("min",e,!0,g.toString(t))}gt(e,t){return this.setLimit("min",e,!1,g.toString(t))}lte(e,t){return this.setLimit("max",e,!0,g.toString(t))}lt(e,t){return this.setLimit("max",e,!1,g.toString(t))}setLimit(e,t,r,s){return new L({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:g.toString(s)}]})}_addCheck(e){return new L({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:g.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:g.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}}L.create=n=>{var e;return new L({checks:[],typeName:y.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...b(n)})};class se extends k{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){const r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_type,expected:f.boolean,received:r.parsedType}),v}return I(e.data)}}se.create=n=>new se({typeName:y.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...b(n)});class W extends k{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){const i=this._getOrReturnCtx(e);return m(i,{code:d.invalid_type,expected:f.date,received:i.parsedType}),v}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return m(i,{code:d.invalid_date}),v}const r=new T;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:d.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:d.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):_.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new W({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:g.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:g.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}}W.create=n=>new W({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:y.ZodDate,...b(n)});class Te extends k{_parse(e){if(this._getType(e)!==f.symbol){const r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_type,expected:f.symbol,received:r.parsedType}),v}return I(e.data)}}Te.create=n=>new Te({typeName:y.ZodSymbol,...b(n)});class ie extends k{_parse(e){if(this._getType(e)!==f.undefined){const r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_type,expected:f.undefined,received:r.parsedType}),v}return I(e.data)}}ie.create=n=>new ie({typeName:y.ZodUndefined,...b(n)});class oe extends k{_parse(e){if(this._getType(e)!==f.null){const r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_type,expected:f.null,received:r.parsedType}),v}return I(e.data)}}oe.create=n=>new oe({typeName:y.ZodNull,...b(n)});class J extends k{constructor(){super(...arguments),this._any=!0}_parse(e){return I(e.data)}}J.create=n=>new J({typeName:y.ZodAny,...b(n)});class Q extends k{constructor(){super(...arguments),this._unknown=!0}_parse(e){return I(e.data)}}Q.create=n=>new Q({typeName:y.ZodUnknown,...b(n)});class M extends k{_parse(e){const t=this._getOrReturnCtx(e);return m(t,{code:d.invalid_type,expected:f.never,received:t.parsedType}),v}}M.create=n=>new M({typeName:y.ZodNever,...b(n)});class Ie extends k{_parse(e){if(this._getType(e)!==f.undefined){const r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_type,expected:f.void,received:r.parsedType}),v}return I(e.data)}}Ie.create=n=>new Ie({typeName:y.ZodVoid,...b(n)});class j extends k{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==f.array)return m(t,{code:d.invalid_type,expected:f.array,received:t.parsedType}),v;if(s.exactLength!==null){const o=t.data.length>s.exactLength.value,c=t.data.length<s.exactLength.value;(o||c)&&(m(t,{code:o?d.too_big:d.too_small,minimum:c?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(m(t,{code:d.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(m(t,{code:d.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((o,c)=>s.type._parseAsync(new Z(t,o,t.path,c)))).then(o=>T.mergeArray(r,o));const i=[...t.data].map((o,c)=>s.type._parseSync(new Z(t,o,t.path,c)));return T.mergeArray(r,i)}get element(){return this._def.type}min(e,t){return new j({...this._def,minLength:{value:e,message:g.toString(t)}})}max(e,t){return new j({...this._def,maxLength:{value:e,message:g.toString(t)}})}length(e,t){return new j({...this._def,exactLength:{value:e,message:g.toString(t)}})}nonempty(e){return this.min(1,e)}}j.create=(n,e)=>new j({type:n,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,...b(e)});function H(n){if(n instanceof w){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=P.create(H(r))}return new w({...n._def,shape:()=>e})}else return n instanceof j?new j({...n._def,type:H(n.element)}):n instanceof P?P.create(H(n.unwrap())):n instanceof q?q.create(H(n.unwrap())):n instanceof O?O.create(n.items.map(e=>H(e))):n}class w 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=_.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==f.object){const u=this._getOrReturnCtx(e);return m(u,{code:d.invalid_type,expected:f.object,received:u.parsedType}),v}const{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof M&&this._def.unknownKeys==="strip"))for(const u in s.data)o.includes(u)||c.push(u);const l=[];for(const u of o){const p=i[u],x=s.data[u];l.push({key:{status:"valid",value:u},value:p._parse(new Z(s,x,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof M){const u=this._def.unknownKeys;if(u==="passthrough")for(const p of c)l.push({key:{status:"valid",value:p},value:{status:"valid",value:s.data[p]}});else if(u==="strict")c.length>0&&(m(s,{code:d.unrecognized_keys,keys:c}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const p of c){const x=s.data[p];l.push({key:{status:"valid",value:p},value:u._parse(new Z(s,x,s.path,p)),alwaysSet:p in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const p of l){const x=await p.key,S=await p.value;u.push({key:x,value:S,alwaysSet:p.alwaysSet})}return u}).then(u=>T.mergeObjectSync(r,u)):T.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return g.errToObj,new w({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var s,i,o,c;const l=(o=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,t,r).message)!==null&&o!==void 0?o:r.defaultError;return t.code==="unrecognized_keys"?{message:(c=g.errToObj(e).message)!==null&&c!==void 0?c:l}:{message:l}}}:{}})}strip(){return new w({...this._def,unknownKeys:"strip"})}passthrough(){return new w({...this._def,unknownKeys:"passthrough"})}extend(e){return new w({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new w({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:y.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new w({...this._def,catchall:e})}pick(e){const t={};return _.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new w({...this._def,shape:()=>t})}omit(e){const t={};return _.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new w({...this._def,shape:()=>t})}deepPartial(){return H(this)}partial(e){const t={};return _.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new w({...this._def,shape:()=>t})}required(e){const t={};return _.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof P;)i=i._def.innerType;t[r]=i}}),new w({...this._def,shape:()=>t})}keyof(){return Ke(_.objectKeys(this.shape))}}w.create=(n,e)=>new w({shape:()=>n,unknownKeys:"strip",catchall:M.create(),typeName:y.ZodObject,...b(e)}),w.strictCreate=(n,e)=>new w({shape:()=>n,unknownKeys:"strict",catchall:M.create(),typeName:y.ZodObject,...b(e)}),w.lazycreate=(n,e)=>new w({shape:n,unknownKeys:"strip",catchall:M.create(),typeName:y.ZodObject,...b(e)});class ce extends k{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function s(i){for(const c of i)if(c.result.status==="valid")return c.result;for(const c of i)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;const o=i.map(c=>new C(c.ctx.common.issues));return m(t,{code:d.invalid_union,unionErrors:o}),v}if(t.common.async)return Promise.all(r.map(async i=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(s);{let i;const o=[];for(const l of r){const u={...t,common:{...t.common,issues:[]},parent:null},p=l._parseSync({data:t.data,path:t.path,parent:u});if(p.status==="valid")return p;p.status==="dirty"&&!i&&(i={result:p,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const c=o.map(l=>new C(l));return m(t,{code:d.invalid_union,unionErrors:c}),v}}get options(){return this._def.options}}ce.create=(n,e)=>new ce({options:n,typeName:y.ZodUnion,...b(e)});const V=n=>n instanceof le?V(n.schema):n instanceof D?V(n.innerType()):n instanceof me?[n.value]:n instanceof U?n.options:n instanceof fe?_.objectValues(n.enum):n instanceof pe?V(n._def.innerType):n instanceof ie?[void 0]:n instanceof oe?[null]:n instanceof P?[void 0,...V(n.unwrap())]:n instanceof q?[null,...V(n.unwrap())]:n instanceof Ee||n instanceof ye?V(n.unwrap()):n instanceof he?V(n._def.innerType):[];class Ne extends k{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return m(t,{code:d.invalid_type,expected:f.object,received:t.parsedType}),v;const r=this.discriminator,s=t.data[r],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(m(t,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const s=new Map;for(const i of t){const o=V(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const c of o){if(s.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);s.set(c,i)}}return new Ne({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...b(r)})}}function Pe(n,e){const t=$(n),r=$(e);if(n===e)return{valid:!0,data:n};if(t===f.object&&r===f.object){const s=_.objectKeys(e),i=_.objectKeys(n).filter(c=>s.indexOf(c)!==-1),o={...n,...e};for(const c of i){const l=Pe(n[c],e[c]);if(!l.valid)return{valid:!1};o[c]=l.data}return{valid:!0,data:o}}else if(t===f.array&&r===f.array){if(n.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<n.length;i++){const o=n[i],c=e[i],l=Pe(o,c);if(!l.valid)return{valid:!1};s.push(l.data)}return{valid:!0,data:s}}else return t===f.date&&r===f.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class ue extends k{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(De(i)||De(o))return v;const c=Pe(i.value,o.value);return c.valid?((Ze(i)||Ze(o))&&t.dirty(),{status:t.value,value:c.data}):(m(r,{code:d.invalid_intersection_types}),v)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}ue.create=(n,e,t)=>new ue({left:n,right:e,typeName:y.ZodIntersection,...b(t)});class O extends k{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.array)return m(r,{code:d.invalid_type,expected:f.array,received:r.parsedType}),v;if(r.data.length<this._def.items.length)return m(r,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&r.data.length>this._def.items.length&&(m(r,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...r.data].map((o,c)=>{const l=this._def.items[c]||this._def.rest;return l?l._parse(new Z(r,o,r.path,c)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>T.mergeArray(t,o)):T.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new O({...this._def,rest:e})}}O.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new O({items:n,typeName:y.ZodTuple,rest:null,...b(e)})};class de extends k{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.object)return m(r,{code:d.invalid_type,expected:f.object,received:r.parsedType}),v;const s=[],i=this._def.keyType,o=this._def.valueType;for(const c in r.data)s.push({key:i._parse(new Z(r,c,r.path,c)),value:o._parse(new Z(r,r.data[c],r.path,c)),alwaysSet:c in r.data});return r.common.async?T.mergeObjectAsync(t,s):T.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof k?new de({keyType:e,valueType:t,typeName:y.ZodRecord,...b(r)}):new de({keyType:A.create(),valueType:e,typeName:y.ZodRecord,...b(t)})}}class Ce extends k{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.map)return m(r,{code:d.invalid_type,expected:f.map,received:r.parsedType}),v;const s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([c,l],u)=>({key:s._parse(new Z(r,c,r.path,[u,"key"])),value:i._parse(new Z(r,l,r.path,[u,"value"]))}));if(r.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const l of o){const u=await l.key,p=await l.value;if(u.status==="aborted"||p.status==="aborted")return v;(u.status==="dirty"||p.status==="dirty")&&t.dirty(),c.set(u.value,p.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const l of o){const u=l.key,p=l.value;if(u.status==="aborted"||p.status==="aborted")return v;(u.status==="dirty"||p.status==="dirty")&&t.dirty(),c.set(u.value,p.value)}return{status:t.value,value:c}}}}Ce.create=(n,e,t)=>new Ce({valueType:e,keyType:n,typeName:y.ZodMap,...b(t)});class Y extends k{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.set)return m(r,{code:d.invalid_type,expected:f.set,received:r.parsedType}),v;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(m(r,{code:d.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(m(r,{code:d.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=this._def.valueType;function o(l){const u=new Set;for(const p of l){if(p.status==="aborted")return v;p.status==="dirty"&&t.dirty(),u.add(p.value)}return{status:t.value,value:u}}const c=[...r.data.values()].map((l,u)=>i._parse(new Z(r,l,r.path,u)));return r.common.async?Promise.all(c).then(l=>o(l)):o(c)}min(e,t){return new Y({...this._def,minSize:{value:e,message:g.toString(t)}})}max(e,t){return new Y({...this._def,maxSize:{value:e,message:g.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Y.create=(n,e)=>new Y({valueType:n,minSize:null,maxSize:null,typeName:y.ZodSet,...b(e)});class K extends k{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return m(t,{code:d.invalid_type,expected:f.function,received:t.parsedType}),v;function r(c,l){return we({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xe(),G].filter(u=>!!u),issueData:{code:d.invalid_arguments,argumentsError:l}})}function s(c,l){return we({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xe(),G].filter(u=>!!u),issueData:{code:d.invalid_return_type,returnTypeError:l}})}const i={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof ee){const c=this;return I(async function(...l){const u=new C([]),p=await c._def.args.parseAsync(l,i).catch(N=>{throw u.addIssue(r(l,N)),u}),x=await Reflect.apply(o,this,p);return await c._def.returns._def.type.parseAsync(x,i).catch(N=>{throw u.addIssue(s(x,N)),u})})}else{const c=this;return I(function(...l){const u=c._def.args.safeParse(l,i);if(!u.success)throw new C([r(l,u.error)]);const p=Reflect.apply(o,this,u.data),x=c._def.returns.safeParse(p,i);if(!x.success)throw new C([s(p,x.error)]);return x.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new K({...this._def,args:O.create(e).rest(Q.create())})}returns(e){return new K({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new K({args:e||O.create([]).rest(Q.create()),returns:t||Q.create(),typeName:y.ZodFunction,...b(r)})}}class le 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})}}le.create=(n,e)=>new le({getter:n,typeName:y.ZodLazy,...b(e)});class me extends k{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return m(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}}me.create=(n,e)=>new me({value:n,typeName:y.ZodLiteral,...b(e)});function Ke(n,e){return new U({values:n,typeName:y.ZodEnum,...b(e)})}class U extends k{constructor(){super(...arguments),re.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return m(t,{expected:_.joinValues(r),received:t.parsedType,code:d.invalid_type}),v}if(Se(this,re)||Ye(this,re,new Set(this._def.values)),!Se(this,re).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return m(t,{received:t.data,code:d.invalid_enum_value,options:r}),v}return I(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 U.create(e,{...this._def,...t})}exclude(e,t=this._def){return U.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}re=new WeakMap,U.create=Ke;class fe extends k{constructor(){super(...arguments),ae.set(this,void 0)}_parse(e){const t=_.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==f.string&&r.parsedType!==f.number){const s=_.objectValues(t);return m(r,{expected:_.joinValues(s),received:r.parsedType,code:d.invalid_type}),v}if(Se(this,ae)||Ye(this,ae,new Set(_.getValidEnumValues(this._def.values))),!Se(this,ae).has(e.data)){const s=_.objectValues(t);return m(r,{received:r.data,code:d.invalid_enum_value,options:s}),v}return I(e.data)}get enum(){return this._def.values}}ae=new WeakMap,fe.create=(n,e)=>new fe({values:n,typeName:y.ZodNativeEnum,...b(e)});class ee extends k{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return m(t,{code:d.invalid_type,expected:f.promise,received:t.parsedType}),v;const r=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return I(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ee.create=(n,e)=>new ee({type:n,typeName:y.ZodPromise,...b(e)});class D extends k{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{m(r,o),o.fatal?t.abort():t.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const o=s.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async c=>{if(t.value==="aborted")return v;const l=await this._def.schema._parseAsync({data:c,path:r.path,parent:r});return l.status==="aborted"?v:l.status==="dirty"||t.value==="dirty"?X(l.value):l});{if(t.value==="aborted")return v;const c=this._def.schema._parseSync({data:o,path:r.path,parent:r});return c.status==="aborted"?v:c.status==="dirty"||t.value==="dirty"?X(c.value):c}}if(s.type==="refinement"){const o=c=>{const l=s.refinement(c,i);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(r.common.async===!1){const c=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return c.status==="aborted"?v:(c.status==="dirty"&&t.dirty(),o(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(c=>c.status==="aborted"?v:(c.status==="dirty"&&t.dirty(),o(c.value).then(()=>({status:t.value,value:c.value}))))}if(s.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!B(o))return o;const c=s.transform(o.value,i);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:c}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>B(o)?Promise.resolve(s.transform(o.value,i)).then(c=>({status:t.value,value:c})):o);_.assertNever(s)}}D.create=(n,e,t)=>new D({schema:n,typeName:y.ZodEffects,effect:e,...b(t)}),D.createWithPreprocess=(n,e,t)=>new D({schema:e,effect:{type:"preprocess",transform:n},typeName:y.ZodEffects,...b(t)});class P extends k{_parse(e){return this._getType(e)===f.undefined?I(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}P.create=(n,e)=>new P({innerType:n,typeName:y.ZodOptional,...b(e)});class q extends k{_parse(e){return this._getType(e)===f.null?I(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}q.create=(n,e)=>new q({innerType:n,typeName:y.ZodNullable,...b(e)});class pe extends k{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===f.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}pe.create=(n,e)=>new pe({innerType:n,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...b(e)});class he extends k{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return ne(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new C(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new C(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}he.create=(n,e)=>new he({innerType:n,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...b(e)});class Ae extends k{_parse(e){if(this._getType(e)!==f.nan){const r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_type,expected:f.nan,received:r.parsedType}),v}return{status:"valid",value:e.data}}}Ae.create=n=>new Ae({typeName:y.ZodNaN,...b(n)});const Ut=Symbol("zod_brand");class Ee extends k{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class ge extends k{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?v:i.status==="dirty"?(t.dirty(),X(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?v:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,t){return new ge({in:e,out:t,typeName:y.ZodPipeline})}}class ye extends k{_parse(e){const t=this._def.innerType._parse(e),r=s=>(B(s)&&(s.value=Object.freeze(s.value)),s);return ne(t)?t.then(s=>r(s)):r(t)}unwrap(){return this._def.innerType}}ye.create=(n,e)=>new ye({innerType:n,typeName:y.ZodReadonly,...b(e)});function et(n,e){const t=typeof n=="function"?n(e):typeof n=="string"?{message:n}:n;return typeof t=="string"?{message:t}:t}function tt(n,e={},t){return n?J.create().superRefine((r,s)=>{var i,o;const c=n(r);if(c instanceof Promise)return c.then(l=>{var u,p;if(!l){const x=et(e,r),S=(p=(u=x.fatal)!==null&&u!==void 0?u:t)!==null&&p!==void 0?p:!0;s.addIssue({code:"custom",...x,fatal:S})}});if(!c){const l=et(e,r),u=(o=(i=l.fatal)!==null&&i!==void 0?i:t)!==null&&o!==void 0?o:!0;s.addIssue({code:"custom",...l,fatal:u})}}):J.create()}const qt={object:w.lazycreate};var y;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(y||(y={}));const Bt=(n,e={message:`Input not instance of ${n.name}`})=>tt(t=>t instanceof n,e),nt=A.create,rt=z.create,Wt=Ae.create,Qt=L.create,at=se.create,Yt=W.create,Gt=Te.create,Xt=ie.create,Jt=oe.create,Ht=J.create,Kt=Q.create,en=M.create,tn=Ie.create,nn=j.create,rn=w.create,an=w.strictCreate,sn=ce.create,on=Ne.create,cn=ue.create,un=O.create,dn=de.create,ln=Ce.create,mn=Y.create,fn=K.create,pn=le.create,hn=me.create,gn=U.create,yn=fe.create,vn=ee.create,st=D.create,_n=P.create,bn=q.create,kn=D.createWithPreprocess,xn=ge.create;var a=Object.freeze({__proto__:null,defaultErrorMap:G,setErrorMap:bt,getErrorMap:xe,makeIssue:we,EMPTY_PATH:kt,addIssueToContext:m,ParseStatus:T,INVALID:v,DIRTY:X,OK:I,isAborted:De,isDirty:Ze,isValid:B,isAsync:ne,get util(){return _},get objectUtil(){return F},ZodParsedType:f,getParsedType:$,ZodType:k,datetimeRegex:He,ZodString:A,ZodNumber:z,ZodBigInt:L,ZodBoolean:se,ZodDate:W,ZodSymbol:Te,ZodUndefined:ie,ZodNull:oe,ZodAny:J,ZodUnknown:Q,ZodNever:M,ZodVoid:Ie,ZodArray:j,ZodObject:w,ZodUnion:ce,ZodDiscriminatedUnion:Ne,ZodIntersection:ue,ZodTuple:O,ZodRecord:de,ZodMap:Ce,ZodSet:Y,ZodFunction:K,ZodLazy:le,ZodLiteral:me,ZodEnum:U,ZodNativeEnum:fe,ZodPromise:ee,ZodEffects:D,ZodTransformer:D,ZodOptional:P,ZodNullable:q,ZodDefault:pe,ZodCatch:he,ZodNaN:Ae,BRAND:Ut,ZodBranded:Ee,ZodPipeline:ge,ZodReadonly:ye,custom:tt,Schema:k,ZodSchema:k,late:qt,get ZodFirstPartyTypeKind(){return y},coerce:{string:n=>A.create({...n,coerce:!0}),number:n=>z.create({...n,coerce:!0}),boolean:n=>se.create({...n,coerce:!0}),bigint:n=>L.create({...n,coerce:!0}),date:n=>W.create({...n,coerce:!0})},any:Ht,array:nn,bigint:Qt,boolean:at,date:Yt,discriminatedUnion:on,effect:st,enum:gn,function:fn,instanceof:Bt,intersection:cn,lazy:pn,literal:hn,map:ln,nan:Wt,nativeEnum:yn,never:en,null:Jt,nullable:bn,number:rt,object:rn,oboolean:()=>at().optional(),onumber:()=>rt().optional(),optional:_n,ostring:()=>nt().optional(),pipeline:xn,preprocess:kn,promise:vn,record:dn,set:mn,strictObject:an,string:nt,symbol:Gt,transformer:st,tuple:un,undefined:Xt,union:sn,unknown:Kt,void:tn,NEVER:v,ZodIssueCode:d,quotelessJson:_t,ZodError:C});const ve=a.object({country:a.string().optional(),city:a.string().optional(),street:a.string().optional(),streetNumber:a.string().optional(),floor:a.string().optional(),apartmentEnterNumber:a.string().optional(),apartmentNumber:a.string().optional()}),E=a.string().min(1,{message:"שדה חובה"}),wn=a.string().regex(/^\d+$/,"Must be a numeric string"),Sn=a.object({url:a.string().url(),id:a.string()});function Tn(n){return!!(n!=null&&n.url)}const te=a.object({lang:a.enum(["he"]),value:a.string()}),In=a.array(te),Re=a.object({id:a.string().min(1),companyId:a.string().min(1),storeId:a.string().min(1),parentId:a.string().nullish(),tag:a.string().optional(),locales:a.array(te),depth:a.number()}),je=Re.extend({children:a.lazy(()=>je.array())}),Nn=Re.extend({index:a.number(),depth:a.number(),collapsed:a.boolean().optional(),children:a.array(je)}),_e=a.string().min(1),$e=a.object({type:a.literal("Product"),storeId:_e,companyId:_e,id:_e,objectID:_e,sku:_e,name:a.array(te),description:a.array(te),isPublished:a.boolean(),vat:a.boolean(),priceType:a.object({type:a.enum(["unit","kg","gram","liter","ml"]),value:a.number()}),price:a.number().positive(),purchasePrice:a.number().optional(),profitPercentage:a.number().optional(),currency:a.literal("ILS"),discount:a.object({type:a.enum(["number","percent","none"]),value:a.number()}),isDiscountable:a.boolean({description:"included in store discounts"}).optional(),weight:a.object({value:a.number(),unit:a.enum(["kg","gram","none"])}),volume:a.object({value:a.number(),unit:a.enum(["liter","ml","none"])}),images:a.array(a.object({url:a.string().url(),id:a.string()})),manufacturer:a.string(),brand:a.string(),importer:a.string(),supplier:a.string(),ingredients:a.array(te),created_at:a.number(),updated_at:a.number(),categoryIds:a.array(a.string().nonempty()),stock:a.object({quantity:a.number().min(0),unit:a.enum(["piece","kg","gram","liter","ml"])}).optional(),categoryList:a.array(je).optional(),categories:a.object({lvl0:a.array(a.string()),lvl1:a.array(a.string()),lvl2:a.array(a.string()),lvl3:a.array(a.string()),lvl4:a.array(a.string())}).optional(),categoryNames:a.array(a.string()).optional()}),Cn=$e.extend({image:a.instanceof(File).optional()}),Me=a.object({product:$e,originalPrice:a.number().optional(),finalPrice:a.number().optional(),finalDiscount:a.number().optional(),amount:a.number().positive({message:"Quantity must be a positive number."})}),An=a.object({type:a.literal("Cart"),id:a.string().uuid(),companyId:a.string().uuid(),storeId:a.string().uuid(),userId:a.string().uuid(),status:a.enum(["active","draft","completed"]),items:a.array(Me)}),jn=a.object({id:a.string(),name:a.string(),websiteDomains:a.array(a.string())}),Dn=a.object({type:a.literal("FavoriteProduct"),id:a.string().uuid(),companyId:a.string().uuid(),storeId:a.string().uuid(),userId:a.string().uuid(),productId:a.string().uuid()}),be=a.enum(["external","j5","none"]),it=a.object({type:a.literal("Profile"),id:E,companyId:E,storeId:E,tenantId:E,clientType:a.enum(["user","company"]),companyName:a.string().optional(),displayName:E,email:a.string().email(),phoneNumber:a.string().optional(),address:ve.optional(),isAnonymous:a.boolean(),createdDate:a.number(),lastActivityDate:a.number(),paymentType:be.optional(),organizationId:a.string().optional().nullable()}),Ve=a.object({_COMMENT:a.string().optional(),transaction_id:a.string(),date:a.string().regex(/^\d{4}-\d{2}-\d{2}$/,"Date must be in YYYY-MM-DD format"),currency:a.string().length(3,"Currency must be 3 characters"),rate:a.number().positive(),vat:a.string().regex(/^\d+\.\d{2}$/,"VAT must be in format XX.XX"),vat_price:a.number().positive(),price_discount:a.number(),price_discount_in_currency:a.number(),price_total:a.string().regex(/^\d+\.\d{2}$/,"Price total must be in format XX.XX"),price_total_in_currency:a.number().positive()}),ot=a.object({doc_uuid:a.string().uuid("Document UUID must be a valid UUID"),pdf_link:a.string().url("PDF link must be a valid URL"),pdf_link_copy:a.string().url("PDF copy link must be a valid URL"),doc_number:a.string().min(1,"Document number is required"),sent_mails:a.array(a.string().email("Each email must be valid")),success:a.boolean(),ua_uuid:a.string().uuid("UA UUID must be a valid UUID"),calculatedData:Ve,warning:a.string().optional(),date:a.number().optional()}),ct=a.object({id:a.string().min(1,"ID is required"),number:a.string().min(1,"Number is required"),date:a.number().min(1,"Date is required"),createdAt:a.number().min(1,"Created at is required"),status:a.enum(["pending","paid","cancelled"]),companyDetails:a.object({name:a.string().min(1,"Name is required").optional(),address:a.string().min(1,"Address is required").optional(),phone:a.string().min(1,"Phone is required").optional(),email:a.string().email("Email must be valid").optional()}).optional(),clientDetails:a.object({name:a.string().min(1,"Name is required").optional(),address:a.string().min(1,"Address is required").optional(),phone:a.string().min(1,"Phone is required").optional(),email:a.string().email("Email must be valid").optional()}).optional(),items:a.array(a.object({name:a.string().min(1,"Name is required").optional(),price:a.number().min(1,"Price is required").optional(),quantity:a.number().min(1,"Quantity is required").optional(),total:a.number().min(1,"Total is required").optional()})).optional(),total:a.number().min(1,"Total is required").optional(),vat:a.number().min(1,"VAT is required").optional(),link:a.string().url("Link must be a valid URL").optional()}),Fe=a.object({number:a.string(),name:a.string(),id:a.string()}),ut=a.object({id:a.string(),name:a.string(),discountPercentage:a.number().positive().min(0).max(100).optional(),nameOnInvoice:a.string().optional(),billingAccounts:a.array(Fe),paymentType:be,companyNumber:a.string().optional(),address:ve.optional(),groupId:a.string().optional()}),Zn=ut.omit({id:!0}),On=a.object({doc_uuid:a.string().uuid("Document UUID must be a valid UUID"),pdf_link:a.string().url("PDF link must be a valid URL"),pdf_link_copy:a.string().url("PDF copy link must be a valid URL"),doc_number:a.string().min(1,"Document number is required"),sent_mails:a.array(a.string().email("Each email must be valid")),success:a.boolean(),ua_uuid:a.string().uuid("UA UUID must be a valid UUID"),calculatedData:Ve,warning:a.string().optional(),date:a.number().optional()}),Pn=a.object({id:a.string().min(1,"ID is required"),number:a.string().min(1,"Number is required"),date:a.string().min(1,"Date is required"),createdAt:a.number().min(1,"Created at is required"),status:a.enum(["pending","paid","cancelled"]),companyDetails:a.object({name:a.string().min(1,"Name is required").optional(),address:a.string().min(1,"Address is required").optional(),phone:a.string().min(1,"Phone is required").optional(),email:a.string().email("Email must be valid").optional()}).optional(),clientDetails:a.object({name:a.string().min(1,"Name is required").optional(),address:a.string().min(1,"Address is required").optional(),phone:a.string().min(1,"Phone is required").optional(),email:a.string().email("Email must be valid").optional()}).optional(),items:a.array(a.object({name:a.string().min(1,"Name is required").optional(),price:a.number().min(1,"Price is required").optional(),quantity:a.number().min(1,"Quantity is required").optional(),total:a.number().min(1,"Total is required").optional()})).optional(),total:a.number().min(1,"Total is required").optional(),vat:a.number().min(1,"VAT is required").optional(),link:a.string().url("Link must be a valid URL").optional()}),En=a.object({type:a.literal("Order"),createdBy:a.enum(["user","admin"]).optional(),id:E,companyId:E,storeId:E,userId:E,status:a.enum(["draft","pending","processing","in_delivery","delivered","cancelled","completed","refunded"]),paymentType:be.optional(),paymentStatus:a.enum(["pending","pending_j5","external","completed","failed","refunded"]),cart:a.object({id:a.string(),items:a.array(Me),cartDiscount:a.number(),cartTotal:a.number(),cartVat:a.number(),deliveryPrice:a.number().optional()}),storeOptions:a.object({deliveryPrice:a.number().optional(),freeDeliveryPrice:a.number().optional(),isVatIncludedInPrice:a.boolean().optional()}).optional(),originalAmount:a.number().positive().optional(),actualAmount:a.number().positive().optional(),date:a.number(),deliveryDate:a.coerce.number(),client:it.optional(),address:ve.optional(),nameOnInvoice:a.string().optional(),emailOnInvoice:a.string().email().optional(),phoneNumberOnInvoice:a.string().optional(),clientComment:a.string().optional(),organizationId:a.string().optional(),billingAccount:Fe.optional(),deliveryNote:ct.optional(),invoice:Pn.optional(),ezInvoice:On.optional(),ezDeliveryNote:ot.optional()}),dt=a.enum(["individual","company"]),Rn=a.object({id:a.string(),companyId:a.string(),name:a.string(),urls:a.array(a.string()),logoUrl:a.string(),tenantId:a.string(),paymentType:be,allowAnonymousClients:a.boolean(),isVatIncludedInPrice:a.boolean(),clientTypes:a.array(dt),minimumOrder:a.number().optional(),freeDeliveryPrice:a.number().optional(),deliveryPrice:a.number().optional(),address:ve.optional(),companyNumber:a.string().optional()}),lt=a.object({minSpend:a.number().positive().optional(),stackable:a.boolean().default(!1)}).optional(),mt=a.discriminatedUnion("variantType",[a.object({variantType:a.literal("bundle"),productsId:a.array(a.string().nonempty()).min(1),requiredQuantity:a.number().positive(),bundlePrice:a.number().positive()})]),$n=a.object({type:a.literal("Discount"),storeId:a.string().min(1),companyId:a.string().min(1),id:a.string().min(1),name:a.array(a.object({lang:a.enum(["he"]),value:a.string().nonempty()})),active:a.boolean(),startDate:a.number(),endDate:a.number(),variant:mt,conditions:lt});class ft{canApply(e,t){if(e.variant.variantType!=="bundle"||!this.isDiscountActive(e))return!1;const{productsId:r,requiredQuantity:s}=e.variant;return this.getTotalQuantity(t.cart,r)>=s}calculate(e,t){if(e.variant.variantType!=="bundle")return{applicable:!1,discountAmount:0,affectedItems:[]};const{productsId:r,requiredQuantity:s,bundlePrice:i}=e.variant,o=t.cart.filter(ke=>r.includes(ke.product.id)),c=this.getTotalQuantity(t.cart,r),l=Math.floor(c/s);if(l===0)return{applicable:!1,discountAmount:0,affectedItems:[]};const u=this.calculateOriginalPrice(o),p=this.getTotalQuantity(t.cart,r),x=this.calculateDiscountedPrice(u,i,l,s,p),S=u-x,N=this.distributeDiscount(o,S,u);return{applicable:!0,discountAmount:Number(S.toFixed(2)),affectedItems:N}}isDiscountActive(e){const t=Date.now();return e.active&&e.startDate<=t&&e.endDate>=t}getTotalQuantity(e,t){return e.filter(r=>t.includes(r.product.id)).reduce((r,s)=>r+s.amount,0)}calculateOriginalPrice(e){return e.reduce((t,r)=>t+r.product.price*r.amount,0)}calculateDiscountedPrice(e,t,r,s,i){const o=t*r,c=r*s,u=Math.max(0,i-c)/i*e;return o+u}distributeDiscount(e,t,r){const s=t/r;return e.map(i=>{const o=i.product.price*i.amount*s;return{productId:i.product.id,quantity:i.amount,originalPrice:Number(i.product.price.toFixed(2)),discountedPrice:Number((i.product.price-o/i.amount).toFixed(2)),discountAmount:Number(o.toFixed(2))}})}}class ze{static getStrategy(e){return this.strategies.get(e.variant.variantType)||null}static registerStrategy(e,t){this.strategies.set(e,t)}static getRegisteredTypes(){return Array.from(this.strategies.keys())}static clearStrategies(){this.strategies.clear()}}vt(ze,"strategies",new Map([["bundle",new ft]]));class pt{static calculateDiscounts(e,t,r){var u,p;const s={cart:e,user:r,appliedDiscounts:[]},i=this.filterActiveDiscounts(t),o=[];for(const x of i){const S=ze.getStrategy(x);if(!S||!S.canApply(x,s)||!((u=x.conditions)!=null&&u.stackable)&&o.length>0)continue;const N=S.calculate(x,s);N.applicable&&(o.push({discountId:x.id,discountName:((p=x.name[0])==null?void 0:p.value)||"Discount",discountAmount:Number(N.discountAmount.toFixed(2)),affectedItems:N.affectedItems}),s.appliedDiscounts=o)}const c=this.calculateFinalPrices(e,o),l=o.reduce((x,S)=>x+S.discountAmount,0);return{items:c,totalDiscount:Number(l.toFixed(2)),appliedDiscounts:o}}static filterActiveDiscounts(e){const t=Date.now();return e.filter(r=>r.active&&r.startDate<=t&&r.endDate>=t)}static calculateFinalPrices(e,t){return e.map(r=>{const s=t.filter(l=>l.affectedItems.some(u=>u.productId===r.product.id)),i=s.reduce((l,u)=>{const p=u.affectedItems.find(x=>x.productId===r.product.id);return l+((p==null?void 0:p.discountAmount)||0)},0),o=i/r.amount,c=r.product.price-o;return{amount:r.amount,product:r.product,originalPrice:Number(r.product.price.toFixed(2)),finalPrice:Number(Math.max(0,c).toFixed(2)),finalDiscount:Number(i.toFixed(2)),appliedDiscounts:s.map(l=>l.discountId)}})}static isDiscountActive(e){const t=Date.now();return e.active&&e.startDate<=t&&e.endDate>=t}static getActiveDiscounts(e){return this.filterActiveDiscounts(e)}}function Le(n){return Number(n.toFixed(2))}function Mn(n){return n.toFixed(2)}function Vn(n){return Math.max(0,Le(n))}function Fn(n,e){if(n<=0)return 0;const t=n-e;return Le(t/n*100)}const ht=a.object({id:a.string(),name:a.string()}),zn=ht.omit({id:!0}),Ue=a.object({type:a.literal("Supplier"),id:a.string(),name:a.string(),code:a.string()}),Ln=Ue.omit({id:!0}),gt=a.object({type:a.literal("SupplierInvoice"),id:a.string(),supplier:Ue,invoiceNumber:a.string(),date:a.number(),rows:a.array(a.object({id:a.string(),rowNumber:a.number(),sku:a.string(),itemName:a.string(),quantity:a.number(),purchasePrice:a.number(),lineDiscount:a.number(),profitPercentage:a.number(),price:a.number(),totalPurchasePrice:a.number(),vat:a.boolean(),originalProduct:a.object({purchasePrice:a.number(),price:a.number(),profitPercentage:a.number()}).optional()})),productsToUpdate:a.array(a.object({sku:a.string(),itemName:a.string(),oldPurchasePrice:a.number(),newPurchasePrice:a.number(),oldPrice:a.number(),newPrice:a.number(),oldProfitPercentage:a.number(),newProfitPercentage:a.number()})),total:a.number().optional(),totalBeforeVat:a.number().optional(),vat:a.number().optional()}),Un=gt.omit({id:!0}),qn=a.object({type:a.literal("ChatSession"),id:a.string(),storeId:a.string(),companyId:a.string(),tenantId:a.string(),userId:a.string().nullable(),userType:a.enum(["anonymous","client","admin","superAdmin"]),createdAt:a.number(),updatedAt:a.number(),messageCount:a.number(),status:a.enum(["active","archived"])}),Bn=a.discriminatedUnion("type",[a.object({type:a.literal("message"),id:a.string(),role:a.enum(["user","assistant","system"]),content:a.string(),timestamp:a.number()}),a.object({type:a.literal("function_call"),id:a.string(),name:a.string(),arguments:a.record(a.string(),a.any()),timestamp:a.number()}),a.object({type:a.literal("tool_result"),id:a.string(),name:a.string(),result:a.any(),timestamp:a.number()})]),yt={VAT:18};function Wn(n){var e,t;return((e=n.discount)==null?void 0:e.type)==="percent"?n.price*(n.discount.value??100)/100:((t=n.discount)==null?void 0:t.type)==="number"?n.discount.value??0:0}function Qn(n){var e,t;if(((e=n.discount)==null?void 0:e.type)==="percent"){const r=n.price*n.discount.value/100;return n.price-r}return((t=n.discount)==null?void 0:t.type)==="number"?n.price-n.discount.value:n.price}function Yn({cart:n,discounts:e,deliveryPrice:t=0,freeDeliveryPrice:r=0,isVatIncludedInPrice:s=!1}){const i=n.map(u=>({amount:u.amount,product:{id:u.product.id,price:u.product.price}})),o=pt.calculateDiscounts(i,e),c=n.map((u,p)=>{const x=o.items[p];return{amount:u.amount,product:{...u.product},originalPrice:u.product.price,finalPrice:x?x.finalPrice:Qn(u.product),finalDiscount:x?x.finalDiscount:Wn(u.product)}}),l=c.reduce((u,p)=>{const{product:x,amount:S,finalPrice:N,finalDiscount:ke}=p;let R=0;if(x.vat){let We=0;if(s){const Jn=Number((N/(1+yt.VAT/100)).toFixed(2)),Hn=N-Jn;R=Number(Hn.toFixed(2)),R=R*S,We=Number(R.toFixed(2))}else R=N*yt.VAT/100,R=R*S,We=Number(R.toFixed(2));u.vat=Number((u.vat+We).toFixed(2))}const Be=Number(N.toFixed(2));return u.cost+=S*Be,u.discount+=ke&&S*ke,u.finalCost+=S*Be+(s?0:R),u.productsCost+=S*Be+(s?0:R),u.cost=Number(u.cost.toFixed(2)),u.discount=Number(u.discount.toFixed(2)),u.finalCost=Number(u.finalCost.toFixed(2)),u.productsCost=Number(u.productsCost.toFixed(2)),u},{discount:0,cost:0,finalCost:0,vat:0,productsCost:0,deliveryPrice:t});return l.deliveryPrice&&l.productsCost>=r?l.deliveryPrice=0:l.finalCost+=l.deliveryPrice,console.log("cartDetails",l),{items:c,...l}}const Gn={firestore:{systemCollections:{stores:"STORES",companies:"COMPANIES"},storeCollections:{products:"products","favorite-products":"favorite-products",profiles:"profiles",cart:"cart",clients:"clients",orders:"orders",categories:"categories",payments:"payments",settings:"settings",discounts:"discounts",organizations:"organizations",organizationGroups:"organizationGroups",invoices:"invoices",suppliers:"suppliers",supplierInvoices:"supplierInvoices",chatSessions:"chatSessions",chatSessionMessages:"chatSessionMessages",contactSubmissions:"contactSubmissions"},getPath:({companyId:n,storeId:e,collectionName:t,id:r})=>`${n}/${e}/${t}${r?`/${r}`:""}`,getSubPath:({companyId:n,storeId:e,collectionName:t,subCollectionName:r,id:s,subId:i})=>`${n}/${e}/${t}/${s}/${r}${i?`/${i}`:""}`,getDocPath:n=>`{companyId}/{storeId}/${n}/{id}`,getSubDocPath:(n,e,t)=>`{companyId}/{storeId}/${n}/${e}/${t}/{id}`}},qe={round:(n,e=2)=>{const t=10**e;return Math.round((n+Number.EPSILON)*t)/t}},Xn={calcSalePriceFromMargin:(n,e)=>n<=0||e<=0||n>=100?e:qe.round(e/(1-n/100)),calcMarginFromSalePrice:(n,e)=>n<=0||e<=0?0:qe.round((n-e)/n*100)};h.AddressSchema=ve,h.BaseCategorySchema=Re,h.BillingAccountSchema=Fe,h.BundleDiscountStrategy=ft,h.CalculatedDataSchema=Ve,h.CartItemProductSchema=Me,h.CartSchema=An,h.CategorySchema=je,h.ChatSessionMessageSchema=Bn,h.ChatSessionSchema=qn,h.CompanySchema=jn,h.DeliveryNoteSchema=ct,h.DiscountConditionsSchema=lt,h.DiscountEngine=pt,h.DiscountSchema=$n,h.DiscountStrategyFactory=ze,h.DiscountVariantSchema=mt,h.EzDeliveryNoteSchema=ot,h.FavoriteProductSchema=Dn,h.FileSchema=Sn,h.FirebaseAPI=Gn,h.LocaleSchema=te,h.LocaleValueSchema=In,h.NewOrganizationGroupSchema=zn,h.NewOrganizationSchema=Zn,h.NewProductSchema=Cn,h.NewSupplierInvoiceSchema=Un,h.NewSupplierSchema=Ln,h.OrderSchema=En,h.OrganizationGroupSchema=ht,h.OrganizationSchema=ut,h.PaymentTypeSchema=be,h.ProductSchema=$e,h.ProfileSchema=it,h.StoreSchema=Rn,h.SupplierInvoiceSchema=gt,h.SupplierSchema=Ue,h.TFlattenCategorySchema=Nn,h.calculatePercentageDiscount=Fn,h.clientTypesSchema=dt,h.ensureNonNegative=Vn,h.formatCurrency=Le,h.formatCurrencyString=Mn,h.getCartCost=Yn,h.isFile=Tn,h.math=qe,h.notEmptyTextSchema=E,h.numericTextSchema=wn,h.storeCalculator=Xn,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=core.umd.js.map
|