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