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