@jsdev_ninja/core 0.21.0 → 0.22.0

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