@jsdev_ninja/core 0.13.15 → 0.13.16

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.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(y,_){typeof exports=="object"&&typeof module<"u"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(y=typeof globalThis<"u"?globalThis:y||self,_(y.core={}))})(this,function(y){"use strict";var Fn=Object.defineProperty;var zn=(y,_,F)=>_ in y?Fn(y,_,{enumerable:!0,configurable:!0,writable:!0,value:F}):y[_]=F;var lt=(y,_,F)=>zn(y,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 m=_.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 m.undefined;case"string":return m.string;case"number":return isNaN(n)?m.nan:m.number;case"boolean":return m.boolean;case"function":return m.function;case"bigint":return m.bigint;case"symbol":return m.symbol;case"object":return Array.isArray(n)?m.array:n===null?m.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?m.promise:typeof Map<"u"&&n instanceof Map?m.map:typeof Set<"u"&&n instanceof Set?m.set:typeof Date<"u"&&n instanceof Date?m.date:m.object;default:return m.unknown}},u=_.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"]),ft=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class I 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,d=0;for(;d<o.path.length;){const l=o.path[d];d===o.path.length-1?(c[l]=c[l]||{_errors:[]},c[l]._errors.push(t(o))):c[l]=c[l]||{_errors:[]},c=c[l],d++}}};return a(this),r}static assert(e){if(!(e instanceof I))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()}}I.create=n=>new I(n);const J=(n,e)=>{let t;switch(n.code){case u.invalid_type:n.received===m.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case u.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,_.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:t=`Unrecognized key(s) in object: ${_.joinValues(n.keys,", ")}`;break;case u.invalid_union:t="Invalid input";break;case u.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${_.joinValues(n.options)}`;break;case u.invalid_enum_value:t=`Invalid enum value. Expected ${_.joinValues(n.options)}, received '${n.received}'`;break;case u.invalid_arguments:t="Invalid function arguments";break;case u.invalid_return_type:t="Invalid function return type";break;case u.invalid_date:t="Invalid date";break;case u.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 u.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 u.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 u.custom:t="Invalid input";break;case u.invalid_intersection_types:t="Intersection results could not be merged";break;case u.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case u.not_finite:t="Number must be finite";break;default:t=e.defaultError,_.assertNever(n)}return{message:t}};let Ue=J;function mt(n){Ue=n}function _e(){return Ue}const be=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 d=r.filter(l=>!!l).slice().reverse();for(const l of d)c=l(o,{data:e,defaultError:c}).message;return{...a,path:s,message:c}},ht=[];function f(n,e){const t=_e(),r=be({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===J?void 0:J].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}),C=n=>({status:"valid",value:n}),Ne=n=>n.status==="aborted",Ae=n=>n.status==="dirty",q=n=>n.status==="valid",ne=n=>typeof Promise<"u"&&n instanceof Promise;function xe(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 Be(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 p;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(p||(p={}));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 qe=(n,e)=>{if(q(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 I(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 d,l;const{message:h}=n;return o.code==="invalid_enum_value"?{message:h??c.defaultError}:typeof c.data>"u"?{message:(d=h??r)!==null&&d!==void 0?d:c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:(l=h??t)!==null&&l!==void 0?l: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 qe(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 q(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=>q(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 qe(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:u.custom,...r(a)});return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!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 D({schema:this,typeName:g.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 B.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return O.create(this)}promise(){return ee.create(this,this._def)}or(e){return ce.create([this,e],this._def)}and(e){return de.create(this,e,this._def)}transform(e){return new D({...b(this._def),schema:this,typeName:g.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new he({...b(this._def),innerType:this,defaultValue:t,typeName:g.ZodDefault})}brand(){return new De({typeName:g.ZodBranded,type:this,...b(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new pe({...b(this._def),innerType:this,catchValue:t,typeName:g.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ye.create(this,e)}readonly(){return ge.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const pt=/^c[^\s-]{8,}$/i,yt=/^[0-9a-z]+$/,gt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,vt=/^[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,_t=/^[a-z0-9_-]{21}$/i,bt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,xt=/^[-+]?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)?)??$/,kt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,wt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ze;const Tt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,St=/^(?:(?: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])$/,Ct=/^(([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]))$/,It=/^(([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])$/,Nt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,At=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,We="((\\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])))",Zt=new RegExp(`^${We}$`);function Qe(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 Ot(n){return new RegExp(`^${Qe(n)}$`)}function Ye(n){let e=`${We}T${Qe(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 Dt(n,e){return!!((e==="v4"||!e)&&Tt.test(n)||(e==="v6"||!e)&&Ct.test(n))}function jt(n,e){if(!bt.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 Et(n,e){return!!((e==="v4"||!e)&&St.test(n)||(e==="v6"||!e)&&It.test(n))}class Z extends x{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==m.string){const s=this._getOrReturnCtx(e);return f(s,{code:u.invalid_type,expected:m.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),f(a,{code:u.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),f(a,{code:u.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?f(a,{code:u.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&f(a,{code:u.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")kt.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"email",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")Ze||(Ze=new RegExp(wt,"u")),Ze.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"emoji",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")vt.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"uuid",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")_t.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"nanoid",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")pt.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cuid",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")yt.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cuid2",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")gt.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"ulid",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),f(a,{validation:"url",code:u.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),f(a,{validation:"regex",code:u.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),f(a,{code:u.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),f(a,{code:u.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(a=this._getOrReturnCtx(e,a),f(a,{code:u.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?Ye(s).test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:u.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?Zt.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:u.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?Ot(s).test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:u.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?xt.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"duration",code:u.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?Dt(e.data,s.version)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"ip",code:u.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?jt(e.data,s.alg)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"jwt",code:u.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?Et(e.data,s.version)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cidr",code:u.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?Nt.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"base64",code:u.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?At.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"base64url",code:u.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:u.invalid_string,...p.errToObj(r)})}_addCheck(e){return new Z({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...p.errToObj(e)})}url(e){return this._addCheck({kind:"url",...p.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...p.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...p.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...p.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...p.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...p.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...p.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...p.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...p.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...p.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...p.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...p.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,...p.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,...p.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...p.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...p.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...p.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...p.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...p.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...p.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...p.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...p.errToObj(t)})}nonempty(e){return this.min(1,p.errToObj(e))}trim(){return new Z({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Z({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Z({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Z.create=n=>{var e;return new Z({checks:[],typeName:g.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...b(n)})};function Pt(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)!==m.number){const s=this._getOrReturnCtx(e);return f(s,{code:u.invalid_type,expected:m.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),f(r,{code:u.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),f(r,{code:u.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),f(r,{code:u.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),a.dirty()):s.kind==="multipleOf"?Pt(e.data,s.value)!==0&&(r=this._getOrReturnCtx(e,r),f(r,{code:u.not_multiple_of,multipleOf:s.value,message:s.message}),a.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:u.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,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,r,a){return new z({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:p.toString(a)}]})}_addCheck(e){return new z({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:p.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:p.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:p.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:p.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:p.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:g.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)!==m.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),f(r,{code:u.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),f(r,{code:u.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),f(r,{code:u.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 f(t,{code:u.invalid_type,expected:m.bigint,received:t.parsedType}),v}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,r,a){return new L({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:p.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:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:p.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.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:g.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...b(n)})};class se extends x{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==m.boolean){const r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:m.boolean,received:r.parsedType}),v}return C(e.data)}}se.create=n=>new se({typeName:g.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)!==m.date){const s=this._getOrReturnCtx(e);return f(s,{code:u.invalid_type,expected:m.date,received:s.parsedType}),v}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return f(s,{code:u.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),f(a,{code:u.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),f(a,{code:u.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:p.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:p.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:g.ZodDate,...b(n)});class ke extends x{_parse(e){if(this._getType(e)!==m.symbol){const r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:m.symbol,received:r.parsedType}),v}return C(e.data)}}ke.create=n=>new ke({typeName:g.ZodSymbol,...b(n)});class ie extends x{_parse(e){if(this._getType(e)!==m.undefined){const r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:m.undefined,received:r.parsedType}),v}return C(e.data)}}ie.create=n=>new ie({typeName:g.ZodUndefined,...b(n)});class oe extends x{_parse(e){if(this._getType(e)!==m.null){const r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:m.null,received:r.parsedType}),v}return C(e.data)}}oe.create=n=>new oe({typeName:g.ZodNull,...b(n)});class H extends x{constructor(){super(...arguments),this._any=!0}_parse(e){return C(e.data)}}H.create=n=>new H({typeName:g.ZodAny,...b(n)});class Q extends x{constructor(){super(...arguments),this._unknown=!0}_parse(e){return C(e.data)}}Q.create=n=>new Q({typeName:g.ZodUnknown,...b(n)});class $ extends x{_parse(e){const t=this._getOrReturnCtx(e);return f(t,{code:u.invalid_type,expected:m.never,received:t.parsedType}),v}}$.create=n=>new $({typeName:g.ZodNever,...b(n)});class we extends x{_parse(e){if(this._getType(e)!==m.undefined){const r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:m.void,received:r.parsedType}),v}return C(e.data)}}we.create=n=>new we({typeName:g.ZodVoid,...b(n)});class O extends x{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),a=this._def;if(t.parsedType!==m.array)return f(t,{code:u.invalid_type,expected:m.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)&&(f(t,{code:o?u.too_big:u.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&&(f(t,{code:u.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&&(f(t,{code:u.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 O({...this._def,minLength:{value:e,message:p.toString(t)}})}max(e,t){return new O({...this._def,maxLength:{value:e,message:p.toString(t)}})}length(e,t){return new O({...this._def,exactLength:{value:e,message:p.toString(t)}})}nonempty(e){return this.min(1,e)}}O.create=(n,e)=>new O({type:n,minLength:null,maxLength:null,exactLength:null,typeName:g.ZodArray,...b(e)});function G(n){if(n instanceof w){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=P.create(G(r))}return new w({...n._def,shape:()=>e})}else return n instanceof O?new O({...n._def,type:G(n.element)}):n instanceof P?P.create(G(n.unwrap())):n instanceof B?B.create(G(n.unwrap())):n instanceof E?E.create(n.items.map(e=>G(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)!==m.object){const l=this._getOrReturnCtx(e);return f(l,{code:u.invalid_type,expected:m.object,received:l.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 l in a.data)o.includes(l)||c.push(l);const d=[];for(const l of o){const h=s[l],k=a.data[l];d.push({key:{status:"valid",value:l},value:h._parse(new j(a,k,a.path,l)),alwaysSet:l in a.data})}if(this._def.catchall instanceof $){const l=this._def.unknownKeys;if(l==="passthrough")for(const h of c)d.push({key:{status:"valid",value:h},value:{status:"valid",value:a.data[h]}});else if(l==="strict")c.length>0&&(f(a,{code:u.unrecognized_keys,keys:c}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const h of c){const k=a.data[h];d.push({key:{status:"valid",value:h},value:l._parse(new j(a,k,a.path,h)),alwaysSet:h in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const l=[];for(const h of d){const k=await h.key,T=await h.value;l.push({key:k,value:T,alwaysSet:h.alwaysSet})}return l}).then(l=>S.mergeObjectSync(r,l)):S.mergeObjectSync(r,d)}get shape(){return this._def.shape()}strict(e){return p.errToObj,new w({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var a,s,o,c;const d=(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=p.errToObj(e).message)!==null&&c!==void 0?c:d}:{message:d}}}:{}})}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:g.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 G(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 Je(_.objectKeys(this.shape))}}w.create=(n,e)=>new w({shape:()=>n,unknownKeys:"strip",catchall:$.create(),typeName:g.ZodObject,...b(e)}),w.strictCreate=(n,e)=>new w({shape:()=>n,unknownKeys:"strict",catchall:$.create(),typeName:g.ZodObject,...b(e)}),w.lazycreate=(n,e)=>new w({shape:n,unknownKeys:"strip",catchall:$.create(),typeName:g.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 I(c.ctx.common.issues));return f(t,{code:u.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 d of r){const l={...t,common:{...t.common,issues:[]},parent:null},h=d._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!s&&(s={result:h,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const c=o.map(d=>new I(d));return f(t,{code:u.invalid_union,unionErrors:c}),v}}get options(){return this._def.options}}ce.create=(n,e)=>new ce({options:n,typeName:g.ZodUnion,...b(e)});const V=n=>n instanceof le?V(n.schema):n instanceof D?V(n.innerType()):n instanceof fe?[n.value]:n instanceof U?n.options:n instanceof me?_.objectValues(n.enum):n instanceof he?V(n._def.innerType):n instanceof ie?[void 0]:n instanceof oe?[null]:n instanceof P?[void 0,...V(n.unwrap())]:n instanceof B?[null,...V(n.unwrap())]:n instanceof De||n instanceof ge?V(n.unwrap()):n instanceof pe?V(n._def.innerType):[];class Te extends x{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==m.object)return f(t,{code:u.invalid_type,expected:m.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}):(f(t,{code:u.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 Te({typeName:g.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...b(r)})}}function Oe(n,e){const t=M(n),r=M(e);if(n===e)return{valid:!0,data:n};if(t===m.object&&r===m.object){const a=_.objectKeys(e),s=_.objectKeys(n).filter(c=>a.indexOf(c)!==-1),o={...n,...e};for(const c of s){const d=Oe(n[c],e[c]);if(!d.valid)return{valid:!1};o[c]=d.data}return{valid:!0,data:o}}else if(t===m.array&&r===m.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],d=Oe(o,c);if(!d.valid)return{valid:!1};a.push(d.data)}return{valid:!0,data:a}}else return t===m.date&&r===m.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class de extends x{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),a=(s,o)=>{if(Ne(s)||Ne(o))return v;const c=Oe(s.value,o.value);return c.valid?((Ae(s)||Ae(o))&&t.dirty(),{status:t.value,value:c.data}):(f(r,{code:u.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}))}}de.create=(n,e,t)=>new de({left:n,right:e,typeName:g.ZodIntersection,...b(t)});class E extends x{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==m.array)return f(r,{code:u.invalid_type,expected:m.array,received:r.parsedType}),v;if(r.data.length<this._def.items.length)return f(r,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&r.data.length>this._def.items.length&&(f(r,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...r.data].map((o,c)=>{const d=this._def.items[c]||this._def.rest;return d?d._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 E({...this._def,rest:e})}}E.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new E({items:n,typeName:g.ZodTuple,rest:null,...b(e)})};class ue 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!==m.object)return f(r,{code:u.invalid_type,expected:m.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 ue({keyType:e,valueType:t,typeName:g.ZodRecord,...b(r)}):new ue({keyType:Z.create(),valueType:e,typeName:g.ZodRecord,...b(t)})}}class Se 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!==m.map)return f(r,{code:u.invalid_type,expected:m.map,received:r.parsedType}),v;const a=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([c,d],l)=>({key:a._parse(new j(r,c,r.path,[l,"key"])),value:s._parse(new j(r,d,r.path,[l,"value"]))}));if(r.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const d of o){const l=await d.key,h=await d.value;if(l.status==="aborted"||h.status==="aborted")return v;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),c.set(l.value,h.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const d of o){const l=d.key,h=d.value;if(l.status==="aborted"||h.status==="aborted")return v;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),c.set(l.value,h.value)}return{status:t.value,value:c}}}}Se.create=(n,e,t)=>new Se({valueType:e,keyType:n,typeName:g.ZodMap,...b(t)});class Y extends x{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==m.set)return f(r,{code:u.invalid_type,expected:m.set,received:r.parsedType}),v;const a=this._def;a.minSize!==null&&r.data.size<a.minSize.value&&(f(r,{code:u.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&&(f(r,{code:u.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(d){const l=new Set;for(const h of d){if(h.status==="aborted")return v;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}const c=[...r.data.values()].map((d,l)=>s._parse(new j(r,d,r.path,l)));return r.common.async?Promise.all(c).then(d=>o(d)):o(c)}min(e,t){return new Y({...this._def,minSize:{value:e,message:p.toString(t)}})}max(e,t){return new Y({...this._def,maxSize:{value:e,message:p.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:g.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!==m.function)return f(t,{code:u.invalid_type,expected:m.function,received:t.parsedType}),v;function r(c,d){return be({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_e(),J].filter(l=>!!l),issueData:{code:u.invalid_arguments,argumentsError:d}})}function a(c,d){return be({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_e(),J].filter(l=>!!l),issueData:{code:u.invalid_return_type,returnTypeError:d}})}const s={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof ee){const c=this;return C(async function(...d){const l=new I([]),h=await c._def.args.parseAsync(d,s).catch(N=>{throw l.addIssue(r(d,N)),l}),k=await Reflect.apply(o,this,h);return await c._def.returns._def.type.parseAsync(k,s).catch(N=>{throw l.addIssue(a(k,N)),l})})}else{const c=this;return C(function(...d){const l=c._def.args.safeParse(d,s);if(!l.success)throw new I([r(d,l.error)]);const h=Reflect.apply(o,this,l.data),k=c._def.returns.safeParse(h,s);if(!k.success)throw new I([a(h,k.error)]);return k.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new K({...this._def,args:E.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||E.create([]).rest(Q.create()),returns:t||Q.create(),typeName:g.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:g.ZodLazy,...b(e)});class fe extends x{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return f(t,{received:t.data,code:u.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}}fe.create=(n,e)=>new fe({value:n,typeName:g.ZodLiteral,...b(e)});function Je(n,e){return new U({values:n,typeName:g.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 f(t,{expected:_.joinValues(r),received:t.parsedType,code:u.invalid_type}),v}if(xe(this,re)||Be(this,re,new Set(this._def.values)),!xe(this,re).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return f(t,{received:t.data,code:u.invalid_enum_value,options:r}),v}return C(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=Je;class me 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!==m.string&&r.parsedType!==m.number){const a=_.objectValues(t);return f(r,{expected:_.joinValues(a),received:r.parsedType,code:u.invalid_type}),v}if(xe(this,ae)||Be(this,ae,new Set(_.getValidEnumValues(this._def.values))),!xe(this,ae).has(e.data)){const a=_.objectValues(t);return f(r,{received:r.data,code:u.invalid_enum_value,options:a}),v}return C(e.data)}get enum(){return this._def.values}}ae=new WeakMap,me.create=(n,e)=>new me({values:n,typeName:g.ZodNativeEnum,...b(e)});class ee extends x{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==m.promise&&t.common.async===!1)return f(t,{code:u.invalid_type,expected:m.promise,received:t.parsedType}),v;const r=t.parsedType===m.promise?t.data:Promise.resolve(t.data);return C(r.then(a=>this._def.type.parseAsync(a,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ee.create=(n,e)=>new ee({type:n,typeName:g.ZodPromise,...b(e)});class D extends x{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===g.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=>{f(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 d=await this._def.schema._parseAsync({data:c,path:r.path,parent:r});return d.status==="aborted"?v:d.status==="dirty"||t.value==="dirty"?X(d.value):d});{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 d=a.refinement(c,s);if(r.common.async)return Promise.resolve(d);if(d 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(!q(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=>q(o)?Promise.resolve(a.transform(o.value,s)).then(c=>({status:t.value,value:c})):o);_.assertNever(a)}}D.create=(n,e,t)=>new D({schema:n,typeName:g.ZodEffects,effect:e,...b(t)}),D.createWithPreprocess=(n,e,t)=>new D({schema:e,effect:{type:"preprocess",transform:n},typeName:g.ZodEffects,...b(t)});class P extends x{_parse(e){return this._getType(e)===m.undefined?C(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}P.create=(n,e)=>new P({innerType:n,typeName:g.ZodOptional,...b(e)});class B extends x{_parse(e){return this._getType(e)===m.null?C(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}B.create=(n,e)=>new B({innerType:n,typeName:g.ZodNullable,...b(e)});class he extends x{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===m.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}he.create=(n,e)=>new he({innerType:n,typeName:g.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...b(e)});class pe 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 I(r.common.issues)},input:r.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new I(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}pe.create=(n,e)=>new pe({innerType:n,typeName:g.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...b(e)});class Ce extends x{_parse(e){if(this._getType(e)!==m.nan){const r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:m.nan,received:r.parsedType}),v}return{status:"valid",value:e.data}}}Ce.create=n=>new Ce({typeName:g.ZodNaN,...b(n)});const Rt=Symbol("zod_brand");class De 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 ye 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 ye({in:e,out:t,typeName:g.ZodPipeline})}}class ge extends x{_parse(e){const t=this._def.innerType._parse(e),r=a=>(q(a)&&(a.value=Object.freeze(a.value)),a);return ne(t)?t.then(a=>r(a)):r(t)}unwrap(){return this._def.innerType}}ge.create=(n,e)=>new ge({innerType:n,typeName:g.ZodReadonly,...b(e)});function Xe(n,e){const t=typeof n=="function"?n(e):typeof n=="string"?{message:n}:n;return typeof t=="string"?{message:t}:t}function He(n,e={},t){return n?H.create().superRefine((r,a)=>{var s,o;const c=n(r);if(c instanceof Promise)return c.then(d=>{var l,h;if(!d){const k=Xe(e,r),T=(h=(l=k.fatal)!==null&&l!==void 0?l:t)!==null&&h!==void 0?h:!0;a.addIssue({code:"custom",...k,fatal:T})}});if(!c){const d=Xe(e,r),l=(o=(s=d.fatal)!==null&&s!==void 0?s:t)!==null&&o!==void 0?o:!0;a.addIssue({code:"custom",...d,fatal:l})}}):H.create()}const Mt={object:w.lazycreate};var g;(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"})(g||(g={}));const $t=(n,e={message:`Input not instance of ${n.name}`})=>He(t=>t instanceof n,e),Ge=Z.create,Ke=z.create,Vt=Ce.create,Ft=L.create,et=se.create,zt=W.create,Lt=ke.create,Ut=ie.create,Bt=oe.create,qt=H.create,Wt=Q.create,Qt=$.create,Yt=we.create,Jt=O.create,Xt=w.create,Ht=w.strictCreate,Gt=ce.create,Kt=Te.create,en=de.create,tn=E.create,nn=ue.create,rn=Se.create,an=Y.create,sn=K.create,on=le.create,cn=fe.create,dn=U.create,un=me.create,ln=ee.create,tt=D.create,fn=P.create,mn=B.create,hn=D.createWithPreprocess,pn=ye.create;var i=Object.freeze({__proto__:null,defaultErrorMap:J,setErrorMap:mt,getErrorMap:_e,makeIssue:be,EMPTY_PATH:ht,addIssueToContext:f,ParseStatus:S,INVALID:v,DIRTY:X,OK:C,isAborted:Ne,isDirty:Ae,isValid:q,isAsync:ne,get util(){return _},get objectUtil(){return F},ZodParsedType:m,getParsedType:M,ZodType:x,datetimeRegex:Ye,ZodString:Z,ZodNumber:z,ZodBigInt:L,ZodBoolean:se,ZodDate:W,ZodSymbol:ke,ZodUndefined:ie,ZodNull:oe,ZodAny:H,ZodUnknown:Q,ZodNever:$,ZodVoid:we,ZodArray:O,ZodObject:w,ZodUnion:ce,ZodDiscriminatedUnion:Te,ZodIntersection:de,ZodTuple:E,ZodRecord:ue,ZodMap:Se,ZodSet:Y,ZodFunction:K,ZodLazy:le,ZodLiteral:fe,ZodEnum:U,ZodNativeEnum:me,ZodPromise:ee,ZodEffects:D,ZodTransformer:D,ZodOptional:P,ZodNullable:B,ZodDefault:he,ZodCatch:pe,ZodNaN:Ce,BRAND:Rt,ZodBranded:De,ZodPipeline:ye,ZodReadonly:ge,custom:He,Schema:x,ZodSchema:x,late:Mt,get ZodFirstPartyTypeKind(){return g},coerce:{string:n=>Z.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:qt,array:Jt,bigint:Ft,boolean:et,date:zt,discriminatedUnion:Kt,effect:tt,enum:dn,function:sn,instanceof:$t,intersection:en,lazy:on,literal:cn,map:rn,nan:Vt,nativeEnum:un,never:Qt,null:Bt,nullable:mn,number:Ke,object:Xt,oboolean:()=>et().optional(),onumber:()=>Ke().optional(),optional:fn,ostring:()=>Ge().optional(),pipeline:pn,preprocess:hn,promise:ln,record:nn,set:an,strictObject:Ht,string:Ge,symbol:Lt,transformer:tt,tuple:tn,undefined:Ut,union:Gt,unknown:Wt,void:Yt,NEVER:v,ZodIssueCode:u,quotelessJson:ft,ZodError:I});const nt=i.object({country:i.string(),city:i.string(),street:i.string(),streetNumber:i.string(),floor:i.string(),apartmentEnterNumber:i.string(),apartmentNumber:i.string()}),R=i.string().min(1,{message:"שדה חובה"}),yn=i.string().regex(/^\d+$/,"Must be a numeric string"),gn=i.object({url:i.string().url(),id:i.string()});function vn(n){return!!(n!=null&&n.url)}const te=i.object({lang:i.enum(["he"]),value:i.string()}),_n=i.array(te),je=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()}),Ie=je.extend({children:i.lazy(()=>Ie.array())}),bn=je.extend({index:i.number(),depth:i.number(),collapsed:i.boolean().optional(),children:i.array(Ie)}),ve=i.string().min(1),Ee=i.object({type:i.literal("Product"),storeId:ve,companyId:ve,id:ve,objectID:ve,sku:ve,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()),categoryList:i.array(Ie).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()}),xn=Ee.extend({image:i.instanceof(File).optional()}),Pe=i.object({product:Ee,originalPrice:i.number().optional(),finalPrice:i.number().optional(),finalDiscount:i.number().optional(),amount:i.number().positive({message:"Quantity must be a positive number."})}),kn=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(Pe)}),wn=i.object({id:i.string(),name:i.string(),websiteDomains:i.array(i.string())}),Tn=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()}),Re=i.enum(["default","delayed"],{description:"delayed is J5 transaction"}),rt=i.object({type:i.literal("Profile"),id:R,companyId:R,storeId:R,tenantId:R,clientType:i.enum(["user","company"]),companyName:i.string().optional(),displayName:R,email:i.string().email(),phoneNumber:i.string().optional(),address:nt.optional(),isAnonymous:i.boolean(),createdDate:i.number(),lastActivityDate:i.number(),paymentType:Re,organizationId:i.string().optional()});function Sn(){return{type:"Profile",id:"",companyId:"",storeId:"",tenantId:"",clientType:"user",displayName:"",email:"",phoneNumber:"",address:{country:"",city:"",street:"",streetNumber:"",floor:"",apartmentEnterNumber:"",apartmentNumber:""},createdDate:0,lastActivityDate:0,isAnonymous:!0,paymentType:Re.Values.default}}const Cn=i.object({type:i.literal("Order"),id:R,companyId:R,storeId:R,userId:R,status:i.enum(["draft","pending","processing","in_delivery","delivered","cancelled","completed","refunded"]),paymentStatus:i.enum(["pending","pending_j5","external","completed","failed","refunded"]),cart:i.object({id:i.string(),items:i.array(Pe),cartDiscount:i.number(),cartTotal:i.number(),cartVat:i.number(),deliveryPrice:i.number().optional()}),originalAmount:i.number().positive().optional(),actualAmount:i.number().positive().optional(),date:i.number(),deliveryDate:i.coerce.number(),client:rt.required({}),nameOnInvoice:i.string().optional(),clientComment:i.string().optional()}),at=i.enum(["individual","company"]),In=i.object({id:i.string(),companyId:i.string(),name:i.string(),urls:i.array(i.string()),logoUrl:i.string(),tenantId:i.string(),paymentType:i.enum(["external","j5"]),allowAnonymousClients:i.boolean(),isVatIncludedInPrice:i.boolean(),clientTypes:i.array(at),minimumOrder:i.number().optional(),freeDeliveryPrice:i.number().optional(),deliveryPrice:i.number().optional()}),st=i.object({minSpend:i.number().positive().optional(),stackable:i.boolean().default(!1)}).optional(),it=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()})]),Nn=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:it,conditions:st});class ot{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(A=>r.includes(A.product.id)),c=this.getTotalQuantity(t.cart,r),d=Math.floor(c/a);if(d===0)return{applicable:!1,discountAmount:0,affectedItems:[]};const l=this.calculateOriginalPrice(o),h=this.getTotalQuantity(t.cart,r),k=this.calculateDiscountedPrice(l,s,d,a,h),T=l-k,N=this.distributeDiscount(o,T,l);return{applicable:!0,discountAmount:Number(T.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,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,l=Math.max(0,s-c)/s*e;return o+l}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 Me{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()}}lt(Me,"strategies",new Map([["bundle",new ot]]));class ct{static calculateDiscounts(e,t,r){var l,h;const a={cart:e,user:r,appliedDiscounts:[]},s=this.filterActiveDiscounts(t),o=[];for(const k of s){const T=Me.getStrategy(k);if(!T||!T.canApply(k,a)||!((l=k.conditions)!=null&&l.stackable)&&o.length>0)continue;const N=T.calculate(k,a);N.applicable&&(o.push({discountId:k.id,discountName:((h=k.name[0])==null?void 0:h.value)||"Discount",discountAmount:Number(N.discountAmount.toFixed(2)),affectedItems:N.affectedItems}),a.appliedDiscounts=o)}const c=this.calculateFinalPrices(e,o),d=o.reduce((k,T)=>k+T.discountAmount,0);return{items:c,totalDiscount:Number(d.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(d=>d.affectedItems.some(l=>l.productId===r.product.id)),s=a.reduce((d,l)=>{const h=l.affectedItems.find(k=>k.productId===r.product.id);return d+((h==null?void 0:h.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(d=>d.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 $e(n){return Number(n.toFixed(2))}function An(n){return n.toFixed(2)}function Zn(n){return Math.max(0,$e(n))}function On(n,e){if(n<=0)return 0;const t=n-e;return $e(t/n*100)}const dt=i.object({id:i.string(),name:i.string(),discountPercentage:i.number().positive().min(0).max(100).optional(),nameOnInvoice:i.string().optional()}),Dn=dt.omit({id:!0}),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()}),ut=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()});function jn(n){return ut.safeParse(n).success}function En(n){return Ve.safeParse(n).success}const Fe={VAT:18};function Pn(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 Rn(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 Mn({cart:n,discounts:e,store:t}){const{isVatIncludedInPrice:r}=t,a=n.map(d=>({amount:d.amount,product:{id:d.product.id,price:d.product.price}})),s=ct.calculateDiscounts(a,e),o=n.map((d,l)=>{const h=s.items[l];return{amount:d.amount,product:{...d.product},originalPrice:d.product.price,finalPrice:h?h.finalPrice:Rn(d.product),finalDiscount:h?h.finalDiscount:Pn(d.product)}}),c=o.reduce((d,l)=>{const{product:h,amount:k,finalPrice:T,finalDiscount:N}=l;let A=0;if(h.vat){let Le=0;if(r){const Vn=T*(Fe.VAT/(100+Fe.VAT));A=Number(Vn.toFixed(2)),A=A*k,Le=Number(A.toFixed(2))}else A=T*Fe.VAT/100,A=A*k,Le=Number(A.toFixed(2));d.vat=Number((d.vat+Le).toFixed(2))}const ze=Number(T.toFixed(2));return d.cost+=k*ze,d.discount+=N&&k*N,d.finalCost+=k*ze+(r?0:A),d.productsCost+=k*ze+(r?0:A),d.cost=Number(d.cost.toFixed(2)),d.discount=Number(d.discount.toFixed(2)),d.finalCost=Number(d.finalCost.toFixed(2)),d.productsCost=Number(d.productsCost.toFixed(2)),d},{discount:0,cost:0,finalCost:0,vat:0,productsCost:0,deliveryPrice:(t==null?void 0:t.deliveryPrice)??0});return c.deliveryPrice&&c.productsCost>=(t.freeDeliveryPrice??0)?c.deliveryPrice=0:c.finalCost+=c.deliveryPrice,console.log("cartDetails",c),{items:o,...c}}const $n={firestore:{systemCollections:{stores:"STORES",companies:"COMPANIES"},storeCollections:{products:"products",profiles:"profiles",cart:"cart",clients:"clients",orders:"orders",categories:"categories",favorites:"favorites",payments:"payments",settings:"settings",discounts:"discounts",organizations:"organizations"},getPath:({companyId:n,storeId:e,collectionName:t,id:r})=>`${n}/${e}/${t}${r?`/${r}`:""}`,getDocPath:n=>`{companyId}/{storeId}/${n}/{id}`}};y.AddressSchema=nt,y.BaseCategorySchema=je,y.BundleDiscountStrategy=ot,y.CalculatedDataSchema=Ve,y.CartItemProductSchema=Pe,y.CartSchema=kn,y.CategorySchema=Ie,y.CompanySchema=wn,y.DeliveryNoteSchema=ut,y.DiscountConditionsSchema=st,y.DiscountEngine=ct,y.DiscountSchema=Nn,y.DiscountStrategyFactory=Me,y.DiscountVariantSchema=it,y.FavoriteProductSchema=Tn,y.FileSchema=gn,y.FirebaseAPI=$n,y.LocaleSchema=te,y.LocaleValueSchema=_n,y.NewOrganizationSchema=Dn,y.NewProductSchema=xn,y.OrderSchema=Cn,y.OrganizationSchema=dt,y.ProductSchema=Ee,y.ProfilePaymentTypeSchema=Re,y.ProfileSchema=rt,y.StoreSchema=In,y.TFlattenCategorySchema=bn,y.calculatePercentageDiscount=On,y.clientTypesSchema=at,y.createEmptyProfile=Sn,y.ensureNonNegative=Zn,y.formatCurrency=$e,y.formatCurrencyString=An,y.getCartCost=Mn,y.isCalculatedData=En,y.isDeliveryNote=jn,y.isFile=vn,y.notEmptyTextSchema=R,y.numericTextSchema=yn,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
1
+ (function(y,_){typeof exports=="object"&&typeof module<"u"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(y=typeof globalThis<"u"?globalThis:y||self,_(y.core={}))})(this,function(y){"use strict";var Fn=Object.defineProperty;var zn=(y,_,F)=>_ in y?Fn(y,_,{enumerable:!0,configurable:!0,writable:!0,value:F}):y[_]=F;var lt=(y,_,F)=>zn(y,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 m=_.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 m.undefined;case"string":return m.string;case"number":return isNaN(n)?m.nan:m.number;case"boolean":return m.boolean;case"function":return m.function;case"bigint":return m.bigint;case"symbol":return m.symbol;case"object":return Array.isArray(n)?m.array:n===null?m.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?m.promise:typeof Map<"u"&&n instanceof Map?m.map:typeof Set<"u"&&n instanceof Set?m.set:typeof Date<"u"&&n instanceof Date?m.date:m.object;default:return m.unknown}},u=_.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"]),ft=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class I 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,d=0;for(;d<o.path.length;){const l=o.path[d];d===o.path.length-1?(c[l]=c[l]||{_errors:[]},c[l]._errors.push(t(o))):c[l]=c[l]||{_errors:[]},c=c[l],d++}}};return a(this),r}static assert(e){if(!(e instanceof I))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()}}I.create=n=>new I(n);const J=(n,e)=>{let t;switch(n.code){case u.invalid_type:n.received===m.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case u.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,_.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:t=`Unrecognized key(s) in object: ${_.joinValues(n.keys,", ")}`;break;case u.invalid_union:t="Invalid input";break;case u.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${_.joinValues(n.options)}`;break;case u.invalid_enum_value:t=`Invalid enum value. Expected ${_.joinValues(n.options)}, received '${n.received}'`;break;case u.invalid_arguments:t="Invalid function arguments";break;case u.invalid_return_type:t="Invalid function return type";break;case u.invalid_date:t="Invalid date";break;case u.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 u.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 u.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 u.custom:t="Invalid input";break;case u.invalid_intersection_types:t="Intersection results could not be merged";break;case u.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case u.not_finite:t="Number must be finite";break;default:t=e.defaultError,_.assertNever(n)}return{message:t}};let Be=J;function mt(n){Be=n}function _e(){return Be}const be=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 d=r.filter(l=>!!l).slice().reverse();for(const l of d)c=l(o,{data:e,defaultError:c}).message;return{...a,path:s,message:c}},ht=[];function f(n,e){const t=_e(),r=be({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===J?void 0:J].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}),C=n=>({status:"valid",value:n}),Ne=n=>n.status==="aborted",Ae=n=>n.status==="dirty",q=n=>n.status==="valid",ne=n=>typeof Promise<"u"&&n instanceof Promise;function xe(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 qe(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 p;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(p||(p={}));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 We=(n,e)=>{if(q(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 I(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 d,l;const{message:h}=n;return o.code==="invalid_enum_value"?{message:h??c.defaultError}:typeof c.data>"u"?{message:(d=h??r)!==null&&d!==void 0?d:c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:(l=h??t)!==null&&l!==void 0?l: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 We(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 q(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=>q(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 We(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:u.custom,...r(a)});return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!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 D({schema:this,typeName:g.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 B.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return O.create(this)}promise(){return ee.create(this,this._def)}or(e){return ce.create([this,e],this._def)}and(e){return de.create(this,e,this._def)}transform(e){return new D({...b(this._def),schema:this,typeName:g.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new he({...b(this._def),innerType:this,defaultValue:t,typeName:g.ZodDefault})}brand(){return new De({typeName:g.ZodBranded,type:this,...b(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new pe({...b(this._def),innerType:this,catchValue:t,typeName:g.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ye.create(this,e)}readonly(){return ge.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const pt=/^c[^\s-]{8,}$/i,yt=/^[0-9a-z]+$/,gt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,vt=/^[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,_t=/^[a-z0-9_-]{21}$/i,bt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,xt=/^[-+]?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)?)??$/,kt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,wt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ze;const Tt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,St=/^(?:(?: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])$/,Ct=/^(([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]))$/,It=/^(([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])$/,Nt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,At=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Qe="((\\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])))",Zt=new RegExp(`^${Qe}$`);function Ye(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 Ot(n){return new RegExp(`^${Ye(n)}$`)}function Je(n){let e=`${Qe}T${Ye(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 Dt(n,e){return!!((e==="v4"||!e)&&Tt.test(n)||(e==="v6"||!e)&&Ct.test(n))}function jt(n,e){if(!bt.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 Et(n,e){return!!((e==="v4"||!e)&&St.test(n)||(e==="v6"||!e)&&It.test(n))}class Z extends x{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==m.string){const s=this._getOrReturnCtx(e);return f(s,{code:u.invalid_type,expected:m.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),f(a,{code:u.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),f(a,{code:u.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?f(a,{code:u.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&f(a,{code:u.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")kt.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"email",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")Ze||(Ze=new RegExp(wt,"u")),Ze.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"emoji",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")vt.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"uuid",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")_t.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"nanoid",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")pt.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cuid",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")yt.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cuid2",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")gt.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"ulid",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),f(a,{validation:"url",code:u.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),f(a,{validation:"regex",code:u.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),f(a,{code:u.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),f(a,{code:u.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(a=this._getOrReturnCtx(e,a),f(a,{code:u.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?Je(s).test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:u.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?Zt.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:u.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?Ot(s).test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:u.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?xt.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"duration",code:u.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?Dt(e.data,s.version)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"ip",code:u.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?jt(e.data,s.alg)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"jwt",code:u.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?Et(e.data,s.version)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cidr",code:u.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?Nt.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"base64",code:u.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?At.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"base64url",code:u.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:u.invalid_string,...p.errToObj(r)})}_addCheck(e){return new Z({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...p.errToObj(e)})}url(e){return this._addCheck({kind:"url",...p.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...p.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...p.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...p.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...p.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...p.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...p.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...p.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...p.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...p.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...p.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...p.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,...p.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,...p.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...p.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...p.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...p.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...p.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...p.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...p.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...p.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...p.errToObj(t)})}nonempty(e){return this.min(1,p.errToObj(e))}trim(){return new Z({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Z({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Z({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Z.create=n=>{var e;return new Z({checks:[],typeName:g.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...b(n)})};function Pt(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)!==m.number){const s=this._getOrReturnCtx(e);return f(s,{code:u.invalid_type,expected:m.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),f(r,{code:u.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),f(r,{code:u.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),f(r,{code:u.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),a.dirty()):s.kind==="multipleOf"?Pt(e.data,s.value)!==0&&(r=this._getOrReturnCtx(e,r),f(r,{code:u.not_multiple_of,multipleOf:s.value,message:s.message}),a.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:u.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,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,r,a){return new z({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:p.toString(a)}]})}_addCheck(e){return new z({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:p.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:p.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:p.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:p.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:p.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:g.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)!==m.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),f(r,{code:u.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),f(r,{code:u.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),f(r,{code:u.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 f(t,{code:u.invalid_type,expected:m.bigint,received:t.parsedType}),v}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,r,a){return new L({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:p.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:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:p.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.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:g.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...b(n)})};class se extends x{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==m.boolean){const r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:m.boolean,received:r.parsedType}),v}return C(e.data)}}se.create=n=>new se({typeName:g.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)!==m.date){const s=this._getOrReturnCtx(e);return f(s,{code:u.invalid_type,expected:m.date,received:s.parsedType}),v}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return f(s,{code:u.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),f(a,{code:u.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),f(a,{code:u.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:p.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:p.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:g.ZodDate,...b(n)});class ke extends x{_parse(e){if(this._getType(e)!==m.symbol){const r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:m.symbol,received:r.parsedType}),v}return C(e.data)}}ke.create=n=>new ke({typeName:g.ZodSymbol,...b(n)});class ie extends x{_parse(e){if(this._getType(e)!==m.undefined){const r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:m.undefined,received:r.parsedType}),v}return C(e.data)}}ie.create=n=>new ie({typeName:g.ZodUndefined,...b(n)});class oe extends x{_parse(e){if(this._getType(e)!==m.null){const r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:m.null,received:r.parsedType}),v}return C(e.data)}}oe.create=n=>new oe({typeName:g.ZodNull,...b(n)});class H extends x{constructor(){super(...arguments),this._any=!0}_parse(e){return C(e.data)}}H.create=n=>new H({typeName:g.ZodAny,...b(n)});class Q extends x{constructor(){super(...arguments),this._unknown=!0}_parse(e){return C(e.data)}}Q.create=n=>new Q({typeName:g.ZodUnknown,...b(n)});class $ extends x{_parse(e){const t=this._getOrReturnCtx(e);return f(t,{code:u.invalid_type,expected:m.never,received:t.parsedType}),v}}$.create=n=>new $({typeName:g.ZodNever,...b(n)});class we extends x{_parse(e){if(this._getType(e)!==m.undefined){const r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:m.void,received:r.parsedType}),v}return C(e.data)}}we.create=n=>new we({typeName:g.ZodVoid,...b(n)});class O extends x{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),a=this._def;if(t.parsedType!==m.array)return f(t,{code:u.invalid_type,expected:m.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)&&(f(t,{code:o?u.too_big:u.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&&(f(t,{code:u.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&&(f(t,{code:u.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 O({...this._def,minLength:{value:e,message:p.toString(t)}})}max(e,t){return new O({...this._def,maxLength:{value:e,message:p.toString(t)}})}length(e,t){return new O({...this._def,exactLength:{value:e,message:p.toString(t)}})}nonempty(e){return this.min(1,e)}}O.create=(n,e)=>new O({type:n,minLength:null,maxLength:null,exactLength:null,typeName:g.ZodArray,...b(e)});function G(n){if(n instanceof w){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=P.create(G(r))}return new w({...n._def,shape:()=>e})}else return n instanceof O?new O({...n._def,type:G(n.element)}):n instanceof P?P.create(G(n.unwrap())):n instanceof B?B.create(G(n.unwrap())):n instanceof E?E.create(n.items.map(e=>G(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)!==m.object){const l=this._getOrReturnCtx(e);return f(l,{code:u.invalid_type,expected:m.object,received:l.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 l in a.data)o.includes(l)||c.push(l);const d=[];for(const l of o){const h=s[l],k=a.data[l];d.push({key:{status:"valid",value:l},value:h._parse(new j(a,k,a.path,l)),alwaysSet:l in a.data})}if(this._def.catchall instanceof $){const l=this._def.unknownKeys;if(l==="passthrough")for(const h of c)d.push({key:{status:"valid",value:h},value:{status:"valid",value:a.data[h]}});else if(l==="strict")c.length>0&&(f(a,{code:u.unrecognized_keys,keys:c}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const h of c){const k=a.data[h];d.push({key:{status:"valid",value:h},value:l._parse(new j(a,k,a.path,h)),alwaysSet:h in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const l=[];for(const h of d){const k=await h.key,T=await h.value;l.push({key:k,value:T,alwaysSet:h.alwaysSet})}return l}).then(l=>S.mergeObjectSync(r,l)):S.mergeObjectSync(r,d)}get shape(){return this._def.shape()}strict(e){return p.errToObj,new w({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var a,s,o,c;const d=(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=p.errToObj(e).message)!==null&&c!==void 0?c:d}:{message:d}}}:{}})}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:g.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 G(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 Xe(_.objectKeys(this.shape))}}w.create=(n,e)=>new w({shape:()=>n,unknownKeys:"strip",catchall:$.create(),typeName:g.ZodObject,...b(e)}),w.strictCreate=(n,e)=>new w({shape:()=>n,unknownKeys:"strict",catchall:$.create(),typeName:g.ZodObject,...b(e)}),w.lazycreate=(n,e)=>new w({shape:n,unknownKeys:"strip",catchall:$.create(),typeName:g.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 I(c.ctx.common.issues));return f(t,{code:u.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 d of r){const l={...t,common:{...t.common,issues:[]},parent:null},h=d._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!s&&(s={result:h,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const c=o.map(d=>new I(d));return f(t,{code:u.invalid_union,unionErrors:c}),v}}get options(){return this._def.options}}ce.create=(n,e)=>new ce({options:n,typeName:g.ZodUnion,...b(e)});const V=n=>n instanceof le?V(n.schema):n instanceof D?V(n.innerType()):n instanceof fe?[n.value]:n instanceof U?n.options:n instanceof me?_.objectValues(n.enum):n instanceof he?V(n._def.innerType):n instanceof ie?[void 0]:n instanceof oe?[null]:n instanceof P?[void 0,...V(n.unwrap())]:n instanceof B?[null,...V(n.unwrap())]:n instanceof De||n instanceof ge?V(n.unwrap()):n instanceof pe?V(n._def.innerType):[];class Te extends x{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==m.object)return f(t,{code:u.invalid_type,expected:m.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}):(f(t,{code:u.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 Te({typeName:g.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...b(r)})}}function Oe(n,e){const t=M(n),r=M(e);if(n===e)return{valid:!0,data:n};if(t===m.object&&r===m.object){const a=_.objectKeys(e),s=_.objectKeys(n).filter(c=>a.indexOf(c)!==-1),o={...n,...e};for(const c of s){const d=Oe(n[c],e[c]);if(!d.valid)return{valid:!1};o[c]=d.data}return{valid:!0,data:o}}else if(t===m.array&&r===m.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],d=Oe(o,c);if(!d.valid)return{valid:!1};a.push(d.data)}return{valid:!0,data:a}}else return t===m.date&&r===m.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class de extends x{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),a=(s,o)=>{if(Ne(s)||Ne(o))return v;const c=Oe(s.value,o.value);return c.valid?((Ae(s)||Ae(o))&&t.dirty(),{status:t.value,value:c.data}):(f(r,{code:u.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}))}}de.create=(n,e,t)=>new de({left:n,right:e,typeName:g.ZodIntersection,...b(t)});class E extends x{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==m.array)return f(r,{code:u.invalid_type,expected:m.array,received:r.parsedType}),v;if(r.data.length<this._def.items.length)return f(r,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&r.data.length>this._def.items.length&&(f(r,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...r.data].map((o,c)=>{const d=this._def.items[c]||this._def.rest;return d?d._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 E({...this._def,rest:e})}}E.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new E({items:n,typeName:g.ZodTuple,rest:null,...b(e)})};class ue 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!==m.object)return f(r,{code:u.invalid_type,expected:m.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 ue({keyType:e,valueType:t,typeName:g.ZodRecord,...b(r)}):new ue({keyType:Z.create(),valueType:e,typeName:g.ZodRecord,...b(t)})}}class Se 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!==m.map)return f(r,{code:u.invalid_type,expected:m.map,received:r.parsedType}),v;const a=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([c,d],l)=>({key:a._parse(new j(r,c,r.path,[l,"key"])),value:s._parse(new j(r,d,r.path,[l,"value"]))}));if(r.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const d of o){const l=await d.key,h=await d.value;if(l.status==="aborted"||h.status==="aborted")return v;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),c.set(l.value,h.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const d of o){const l=d.key,h=d.value;if(l.status==="aborted"||h.status==="aborted")return v;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),c.set(l.value,h.value)}return{status:t.value,value:c}}}}Se.create=(n,e,t)=>new Se({valueType:e,keyType:n,typeName:g.ZodMap,...b(t)});class Y extends x{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==m.set)return f(r,{code:u.invalid_type,expected:m.set,received:r.parsedType}),v;const a=this._def;a.minSize!==null&&r.data.size<a.minSize.value&&(f(r,{code:u.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&&(f(r,{code:u.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(d){const l=new Set;for(const h of d){if(h.status==="aborted")return v;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}const c=[...r.data.values()].map((d,l)=>s._parse(new j(r,d,r.path,l)));return r.common.async?Promise.all(c).then(d=>o(d)):o(c)}min(e,t){return new Y({...this._def,minSize:{value:e,message:p.toString(t)}})}max(e,t){return new Y({...this._def,maxSize:{value:e,message:p.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:g.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!==m.function)return f(t,{code:u.invalid_type,expected:m.function,received:t.parsedType}),v;function r(c,d){return be({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_e(),J].filter(l=>!!l),issueData:{code:u.invalid_arguments,argumentsError:d}})}function a(c,d){return be({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_e(),J].filter(l=>!!l),issueData:{code:u.invalid_return_type,returnTypeError:d}})}const s={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof ee){const c=this;return C(async function(...d){const l=new I([]),h=await c._def.args.parseAsync(d,s).catch(N=>{throw l.addIssue(r(d,N)),l}),k=await Reflect.apply(o,this,h);return await c._def.returns._def.type.parseAsync(k,s).catch(N=>{throw l.addIssue(a(k,N)),l})})}else{const c=this;return C(function(...d){const l=c._def.args.safeParse(d,s);if(!l.success)throw new I([r(d,l.error)]);const h=Reflect.apply(o,this,l.data),k=c._def.returns.safeParse(h,s);if(!k.success)throw new I([a(h,k.error)]);return k.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new K({...this._def,args:E.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||E.create([]).rest(Q.create()),returns:t||Q.create(),typeName:g.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:g.ZodLazy,...b(e)});class fe extends x{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return f(t,{received:t.data,code:u.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}}fe.create=(n,e)=>new fe({value:n,typeName:g.ZodLiteral,...b(e)});function Xe(n,e){return new U({values:n,typeName:g.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 f(t,{expected:_.joinValues(r),received:t.parsedType,code:u.invalid_type}),v}if(xe(this,re)||qe(this,re,new Set(this._def.values)),!xe(this,re).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return f(t,{received:t.data,code:u.invalid_enum_value,options:r}),v}return C(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=Xe;class me 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!==m.string&&r.parsedType!==m.number){const a=_.objectValues(t);return f(r,{expected:_.joinValues(a),received:r.parsedType,code:u.invalid_type}),v}if(xe(this,ae)||qe(this,ae,new Set(_.getValidEnumValues(this._def.values))),!xe(this,ae).has(e.data)){const a=_.objectValues(t);return f(r,{received:r.data,code:u.invalid_enum_value,options:a}),v}return C(e.data)}get enum(){return this._def.values}}ae=new WeakMap,me.create=(n,e)=>new me({values:n,typeName:g.ZodNativeEnum,...b(e)});class ee extends x{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==m.promise&&t.common.async===!1)return f(t,{code:u.invalid_type,expected:m.promise,received:t.parsedType}),v;const r=t.parsedType===m.promise?t.data:Promise.resolve(t.data);return C(r.then(a=>this._def.type.parseAsync(a,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ee.create=(n,e)=>new ee({type:n,typeName:g.ZodPromise,...b(e)});class D extends x{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===g.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=>{f(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 d=await this._def.schema._parseAsync({data:c,path:r.path,parent:r});return d.status==="aborted"?v:d.status==="dirty"||t.value==="dirty"?X(d.value):d});{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 d=a.refinement(c,s);if(r.common.async)return Promise.resolve(d);if(d 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(!q(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=>q(o)?Promise.resolve(a.transform(o.value,s)).then(c=>({status:t.value,value:c})):o);_.assertNever(a)}}D.create=(n,e,t)=>new D({schema:n,typeName:g.ZodEffects,effect:e,...b(t)}),D.createWithPreprocess=(n,e,t)=>new D({schema:e,effect:{type:"preprocess",transform:n},typeName:g.ZodEffects,...b(t)});class P extends x{_parse(e){return this._getType(e)===m.undefined?C(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}P.create=(n,e)=>new P({innerType:n,typeName:g.ZodOptional,...b(e)});class B extends x{_parse(e){return this._getType(e)===m.null?C(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}B.create=(n,e)=>new B({innerType:n,typeName:g.ZodNullable,...b(e)});class he extends x{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===m.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}he.create=(n,e)=>new he({innerType:n,typeName:g.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...b(e)});class pe 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 I(r.common.issues)},input:r.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new I(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}pe.create=(n,e)=>new pe({innerType:n,typeName:g.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...b(e)});class Ce extends x{_parse(e){if(this._getType(e)!==m.nan){const r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:m.nan,received:r.parsedType}),v}return{status:"valid",value:e.data}}}Ce.create=n=>new Ce({typeName:g.ZodNaN,...b(n)});const Rt=Symbol("zod_brand");class De 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 ye 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 ye({in:e,out:t,typeName:g.ZodPipeline})}}class ge extends x{_parse(e){const t=this._def.innerType._parse(e),r=a=>(q(a)&&(a.value=Object.freeze(a.value)),a);return ne(t)?t.then(a=>r(a)):r(t)}unwrap(){return this._def.innerType}}ge.create=(n,e)=>new ge({innerType:n,typeName:g.ZodReadonly,...b(e)});function He(n,e){const t=typeof n=="function"?n(e):typeof n=="string"?{message:n}:n;return typeof t=="string"?{message:t}:t}function Ge(n,e={},t){return n?H.create().superRefine((r,a)=>{var s,o;const c=n(r);if(c instanceof Promise)return c.then(d=>{var l,h;if(!d){const k=He(e,r),T=(h=(l=k.fatal)!==null&&l!==void 0?l:t)!==null&&h!==void 0?h:!0;a.addIssue({code:"custom",...k,fatal:T})}});if(!c){const d=He(e,r),l=(o=(s=d.fatal)!==null&&s!==void 0?s:t)!==null&&o!==void 0?o:!0;a.addIssue({code:"custom",...d,fatal:l})}}):H.create()}const Mt={object:w.lazycreate};var g;(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"})(g||(g={}));const $t=(n,e={message:`Input not instance of ${n.name}`})=>Ge(t=>t instanceof n,e),Ke=Z.create,et=z.create,Vt=Ce.create,Ft=L.create,tt=se.create,zt=W.create,Lt=ke.create,Ut=ie.create,Bt=oe.create,qt=H.create,Wt=Q.create,Qt=$.create,Yt=we.create,Jt=O.create,Xt=w.create,Ht=w.strictCreate,Gt=ce.create,Kt=Te.create,en=de.create,tn=E.create,nn=ue.create,rn=Se.create,an=Y.create,sn=K.create,on=le.create,cn=fe.create,dn=U.create,un=me.create,ln=ee.create,nt=D.create,fn=P.create,mn=B.create,hn=D.createWithPreprocess,pn=ye.create;var i=Object.freeze({__proto__:null,defaultErrorMap:J,setErrorMap:mt,getErrorMap:_e,makeIssue:be,EMPTY_PATH:ht,addIssueToContext:f,ParseStatus:S,INVALID:v,DIRTY:X,OK:C,isAborted:Ne,isDirty:Ae,isValid:q,isAsync:ne,get util(){return _},get objectUtil(){return F},ZodParsedType:m,getParsedType:M,ZodType:x,datetimeRegex:Je,ZodString:Z,ZodNumber:z,ZodBigInt:L,ZodBoolean:se,ZodDate:W,ZodSymbol:ke,ZodUndefined:ie,ZodNull:oe,ZodAny:H,ZodUnknown:Q,ZodNever:$,ZodVoid:we,ZodArray:O,ZodObject:w,ZodUnion:ce,ZodDiscriminatedUnion:Te,ZodIntersection:de,ZodTuple:E,ZodRecord:ue,ZodMap:Se,ZodSet:Y,ZodFunction:K,ZodLazy:le,ZodLiteral:fe,ZodEnum:U,ZodNativeEnum:me,ZodPromise:ee,ZodEffects:D,ZodTransformer:D,ZodOptional:P,ZodNullable:B,ZodDefault:he,ZodCatch:pe,ZodNaN:Ce,BRAND:Rt,ZodBranded:De,ZodPipeline:ye,ZodReadonly:ge,custom:Ge,Schema:x,ZodSchema:x,late:Mt,get ZodFirstPartyTypeKind(){return g},coerce:{string:n=>Z.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:qt,array:Jt,bigint:Ft,boolean:tt,date:zt,discriminatedUnion:Kt,effect:nt,enum:dn,function:sn,instanceof:$t,intersection:en,lazy:on,literal:cn,map:rn,nan:Vt,nativeEnum:un,never:Qt,null:Bt,nullable:mn,number:et,object:Xt,oboolean:()=>tt().optional(),onumber:()=>et().optional(),optional:fn,ostring:()=>Ke().optional(),pipeline:pn,preprocess:hn,promise:ln,record:nn,set:an,strictObject:Ht,string:Ke,symbol:Lt,transformer:nt,tuple:tn,undefined:Ut,union:Gt,unknown:Wt,void:Yt,NEVER:v,ZodIssueCode:u,quotelessJson:ft,ZodError:I});const rt=i.object({country:i.string(),city:i.string(),street:i.string(),streetNumber:i.string(),floor:i.string(),apartmentEnterNumber:i.string(),apartmentNumber:i.string()}),R=i.string().min(1,{message:"שדה חובה"}),yn=i.string().regex(/^\d+$/,"Must be a numeric string"),gn=i.object({url:i.string().url(),id:i.string()});function vn(n){return!!(n!=null&&n.url)}const te=i.object({lang:i.enum(["he"]),value:i.string()}),_n=i.array(te),je=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()}),Ie=je.extend({children:i.lazy(()=>Ie.array())}),bn=je.extend({index:i.number(),depth:i.number(),collapsed:i.boolean().optional(),children:i.array(Ie)}),ve=i.string().min(1),Ee=i.object({type:i.literal("Product"),storeId:ve,companyId:ve,id:ve,objectID:ve,sku:ve,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()),categoryList:i.array(Ie).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()}),xn=Ee.extend({image:i.instanceof(File).optional()}),Pe=i.object({product:Ee,originalPrice:i.number().optional(),finalPrice:i.number().optional(),finalDiscount:i.number().optional(),amount:i.number().positive({message:"Quantity must be a positive number."})}),kn=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(Pe)}),wn=i.object({id:i.string(),name:i.string(),websiteDomains:i.array(i.string())}),Tn=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()}),Re=i.enum(["default","delayed"],{description:"delayed is J5 transaction"}),at=i.object({type:i.literal("Profile"),id:R,companyId:R,storeId:R,tenantId:R,clientType:i.enum(["user","company"]),companyName:i.string().optional(),displayName:R,email:i.string().email(),phoneNumber:i.string().optional(),address:rt.optional(),isAnonymous:i.boolean(),createdDate:i.number(),lastActivityDate:i.number(),paymentType:Re,organizationId:i.string().optional()});function Sn(){return{type:"Profile",id:"",companyId:"",storeId:"",tenantId:"",clientType:"user",displayName:"",email:"",phoneNumber:"",address:{country:"",city:"",street:"",streetNumber:"",floor:"",apartmentEnterNumber:"",apartmentNumber:""},createdDate:0,lastActivityDate:0,isAnonymous:!0,paymentType:Re.Values.default}}const Me=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()}),$e=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:Me,warning:i.string().optional()});function Cn(n){return $e.safeParse(n).success}function In(n){return Me.safeParse(n).success}const Nn=i.object({type:i.literal("Order"),id:R,companyId:R,storeId:R,userId:R,status:i.enum(["draft","pending","processing","in_delivery","delivered","cancelled","completed","refunded"]),paymentStatus:i.enum(["pending","pending_j5","external","completed","failed","refunded"]),cart:i.object({id:i.string(),items:i.array(Pe),cartDiscount:i.number(),cartTotal:i.number(),cartVat:i.number(),deliveryPrice:i.number().optional()}),originalAmount:i.number().positive().optional(),actualAmount:i.number().positive().optional(),date:i.number(),deliveryDate:i.coerce.number(),client:at.required({}),nameOnInvoice:i.string().optional(),clientComment:i.string().optional(),deliveryNote:$e.optional()}),st=i.enum(["individual","company"]),An=i.object({id:i.string(),companyId:i.string(),name:i.string(),urls:i.array(i.string()),logoUrl:i.string(),tenantId:i.string(),paymentType:i.enum(["external","j5"]),allowAnonymousClients:i.boolean(),isVatIncludedInPrice:i.boolean(),clientTypes:i.array(st),minimumOrder:i.number().optional(),freeDeliveryPrice:i.number().optional(),deliveryPrice:i.number().optional()}),it=i.object({minSpend:i.number().positive().optional(),stackable:i.boolean().default(!1)}).optional(),ot=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()})]),Zn=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:ot,conditions:it});class ct{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(A=>r.includes(A.product.id)),c=this.getTotalQuantity(t.cart,r),d=Math.floor(c/a);if(d===0)return{applicable:!1,discountAmount:0,affectedItems:[]};const l=this.calculateOriginalPrice(o),h=this.getTotalQuantity(t.cart,r),k=this.calculateDiscountedPrice(l,s,d,a,h),T=l-k,N=this.distributeDiscount(o,T,l);return{applicable:!0,discountAmount:Number(T.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,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,l=Math.max(0,s-c)/s*e;return o+l}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 Ve{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()}}lt(Ve,"strategies",new Map([["bundle",new ct]]));class dt{static calculateDiscounts(e,t,r){var l,h;const a={cart:e,user:r,appliedDiscounts:[]},s=this.filterActiveDiscounts(t),o=[];for(const k of s){const T=Ve.getStrategy(k);if(!T||!T.canApply(k,a)||!((l=k.conditions)!=null&&l.stackable)&&o.length>0)continue;const N=T.calculate(k,a);N.applicable&&(o.push({discountId:k.id,discountName:((h=k.name[0])==null?void 0:h.value)||"Discount",discountAmount:Number(N.discountAmount.toFixed(2)),affectedItems:N.affectedItems}),a.appliedDiscounts=o)}const c=this.calculateFinalPrices(e,o),d=o.reduce((k,T)=>k+T.discountAmount,0);return{items:c,totalDiscount:Number(d.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(d=>d.affectedItems.some(l=>l.productId===r.product.id)),s=a.reduce((d,l)=>{const h=l.affectedItems.find(k=>k.productId===r.product.id);return d+((h==null?void 0:h.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(d=>d.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 Fe(n){return Number(n.toFixed(2))}function On(n){return n.toFixed(2)}function Dn(n){return Math.max(0,Fe(n))}function jn(n,e){if(n<=0)return 0;const t=n-e;return Fe(t/n*100)}const 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(i.object({number:i.string(),name:i.string(),id:i.string()}))}),En=ut.omit({id:!0}),ze={VAT:18};function Pn(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 Rn(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 Mn({cart:n,discounts:e,store:t}){const{isVatIncludedInPrice:r}=t,a=n.map(d=>({amount:d.amount,product:{id:d.product.id,price:d.product.price}})),s=dt.calculateDiscounts(a,e),o=n.map((d,l)=>{const h=s.items[l];return{amount:d.amount,product:{...d.product},originalPrice:d.product.price,finalPrice:h?h.finalPrice:Rn(d.product),finalDiscount:h?h.finalDiscount:Pn(d.product)}}),c=o.reduce((d,l)=>{const{product:h,amount:k,finalPrice:T,finalDiscount:N}=l;let A=0;if(h.vat){let Ue=0;if(r){const Vn=T*(ze.VAT/(100+ze.VAT));A=Number(Vn.toFixed(2)),A=A*k,Ue=Number(A.toFixed(2))}else A=T*ze.VAT/100,A=A*k,Ue=Number(A.toFixed(2));d.vat=Number((d.vat+Ue).toFixed(2))}const Le=Number(T.toFixed(2));return d.cost+=k*Le,d.discount+=N&&k*N,d.finalCost+=k*Le+(r?0:A),d.productsCost+=k*Le+(r?0:A),d.cost=Number(d.cost.toFixed(2)),d.discount=Number(d.discount.toFixed(2)),d.finalCost=Number(d.finalCost.toFixed(2)),d.productsCost=Number(d.productsCost.toFixed(2)),d},{discount:0,cost:0,finalCost:0,vat:0,productsCost:0,deliveryPrice:(t==null?void 0:t.deliveryPrice)??0});return c.deliveryPrice&&c.productsCost>=(t.freeDeliveryPrice??0)?c.deliveryPrice=0:c.finalCost+=c.deliveryPrice,console.log("cartDetails",c),{items:o,...c}}const $n={firestore:{systemCollections:{stores:"STORES",companies:"COMPANIES"},storeCollections:{products:"products",profiles:"profiles",cart:"cart",clients:"clients",orders:"orders",categories:"categories",favorites:"favorites",payments:"payments",settings:"settings",discounts:"discounts",organizations:"organizations"},getPath:({companyId:n,storeId:e,collectionName:t,id:r})=>`${n}/${e}/${t}${r?`/${r}`:""}`,getDocPath:n=>`{companyId}/{storeId}/${n}/{id}`}};y.AddressSchema=rt,y.BaseCategorySchema=je,y.BundleDiscountStrategy=ct,y.CalculatedDataSchema=Me,y.CartItemProductSchema=Pe,y.CartSchema=kn,y.CategorySchema=Ie,y.CompanySchema=wn,y.DeliveryNoteSchema=$e,y.DiscountConditionsSchema=it,y.DiscountEngine=dt,y.DiscountSchema=Zn,y.DiscountStrategyFactory=Ve,y.DiscountVariantSchema=ot,y.FavoriteProductSchema=Tn,y.FileSchema=gn,y.FirebaseAPI=$n,y.LocaleSchema=te,y.LocaleValueSchema=_n,y.NewOrganizationSchema=En,y.NewProductSchema=xn,y.OrderSchema=Nn,y.OrganizationSchema=ut,y.ProductSchema=Ee,y.ProfilePaymentTypeSchema=Re,y.ProfileSchema=at,y.StoreSchema=An,y.TFlattenCategorySchema=bn,y.calculatePercentageDiscount=jn,y.clientTypesSchema=st,y.createEmptyProfile=Sn,y.ensureNonNegative=Dn,y.formatCurrency=Fe,y.formatCurrencyString=On,y.getCartCost=Mn,y.isCalculatedData=In,y.isDeliveryNote=Cn,y.isFile=vn,y.notEmptyTextSchema=R,y.numericTextSchema=yn,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
2
2
  //# sourceMappingURL=core.umd.js.map