@quintal/environment 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var g;(function(r){r.assertEqual=n=>n;function e(n){}r.assertIs=e;function t(n){throw new Error}r.assertNever=t,r.arrayToEnum=n=>{const a={};for(const i of n)a[i]=i;return a},r.getValidEnumValues=n=>{const a=r.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(const o of a)i[o]=n[o];return r.objectValues(i)},r.objectValues=n=>r.objectKeys(n).map(function(a){return n[a]}),r.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const a=[];for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&a.push(i);return a},r.find=(n,a)=>{for(const i of n)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=s,r.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(g||(g={}));var ye;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(ye||(ye={}));const u=g.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),R=r=>{switch(typeof r){case"undefined":return u.undefined;case"string":return u.string;case"number":return isNaN(r)?u.nan:u.number;case"boolean":return u.boolean;case"function":return u.function;case"bigint":return u.bigint;case"symbol":return u.symbol;case"object":return Array.isArray(r)?u.array:r===null?u.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?u.promise:typeof Map<"u"&&r instanceof Map?u.map:typeof Set<"u"&&r instanceof Set?u.set:typeof Date<"u"&&r instanceof Date?u.date:u.object;default:return u.unknown}},c=g.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"]),Ae=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Z extends Error{constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},s={_errors:[]},n=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else{let o=s,f=0;for(;f<i.path.length;){const d=i.path[f];f===i.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(t(i))):o[d]=o[d]||{_errors:[]},o=o[d],f++}}};return n(this),s}toString(){return this.message}get message(){return JSON.stringify(this.issues,g.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):s.push(e(n));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}Z.create=r=>new Z(r);const W=(r,e)=>{let t;switch(r.code){case c.invalid_type:r.received===u.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case c.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,g.jsonStringifyReplacer)}`;break;case c.unrecognized_keys:t=`Unrecognized key(s) in object: ${g.joinValues(r.keys,", ")}`;break;case c.invalid_union:t="Invalid input";break;case c.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${g.joinValues(r.options)}`;break;case c.invalid_enum_value:t=`Invalid enum value. Expected ${g.joinValues(r.options)}, received '${r.received}'`;break;case c.invalid_arguments:t="Invalid function arguments";break;case c.invalid_return_type:t="Invalid function return type";break;case c.invalid_date:t="Invalid date";break;case c.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:g.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case c.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case c.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case c.custom:t="Invalid input";break;case c.invalid_intersection_types:t="Intersection results could not be merged";break;case c.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case c.not_finite:t="Number must be finite";break;default:t=e.defaultError,g.assertNever(r)}return{message:t}};let we=W;function Me(r){we=r}function ne(){return we}const ae=r=>{const{data:e,path:t,errorMaps:s,issueData:n}=r,a=[...t,...n.path||[]],i={...n,path:a};let o="";const f=s.filter(d=>!!d).slice().reverse();for(const d of f)o=d(i,{data:e,defaultError:o}).message;return{...n,path:a,message:n.message||o}},Pe=[];function l(r,e){const t=ae({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ne(),W].filter(s=>!!s)});r.common.issues.push(t)}class k{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const n of t){if(n.status==="aborted")return m;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const n of t)s.push({key:await n.key,value:await n.value});return k.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const n of t){const{key:a,value:i}=n;if(a.status==="aborted"||i.status==="aborted")return m;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||n.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}}const m=Object.freeze({status:"aborted"}),Te=r=>({status:"dirty",value:r}),b=r=>({status:"valid",value:r}),ve=r=>r.status==="aborted",_e=r=>r.status==="dirty",q=r=>r.status==="valid",ie=r=>typeof Promise<"u"&&r instanceof Promise;var h;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(h||(h={}));class O{constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n}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 xe=(r,e)=>{if(q(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Z(r.common.issues);return this._error=t,this._error}}};function y(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:n}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(i,o)=>i.code!=="invalid_type"?{message:o.defaultError}:typeof o.data>"u"?{message:s??o.defaultError}:{message:t??o.defaultError},description:n}}class v{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)}get description(){return this._def.description}_getType(e){return R(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:R(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new k,ctx:{common:e.parent.common,data:e.data,parsedType:R(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ie(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const n={common:{issues:[],async:(s=t==null?void 0:t.async)!==null&&s!==void 0?s:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:R(e)},a=this._parseSync({data:e,path:n.path,parent:n});return xe(n,a)}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:R(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await(ie(n)?n:Promise.resolve(n));return xe(s,a)}refine(e,t){const s=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{const i=e(n),o=()=>a.addIssue({code:c.custom,...s(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(f=>f?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof t=="function"?t(s,n):t),!1))}_refinement(e){return new N({schema:this,typeName:p.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return C.create(this,this._def)}nullable(){return L.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return S.create(this,this._def)}promise(){return B.create(this,this._def)}or(e){return G.create([this,e],this._def)}and(e){return X.create(this,e,this._def)}transform(e){return new N({...y(this._def),schema:this,typeName:p.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new te({...y(this._def),innerType:this,defaultValue:t,typeName:p.ZodDefault})}brand(){return new Se({typeName:p.ZodBranded,type:this,...y(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ue({...y(this._def),innerType:this,catchValue:t,typeName:p.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return re.create(this,e)}readonly(){return fe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ve=/^c[^\s-]{8,}$/i,$e=/^[a-z][a-z0-9]*$/,Le=/^[0-9A-HJKMNP-TV-Z]{26}$/,De=/^[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,ze=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ue="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let me;const Be=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,We=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,qe=r=>r.precision?r.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}Z$`):r.precision===0?r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function Je(r,e){return!!((e==="v4"||!e)&&Be.test(r)||(e==="v6"||!e)&&We.test(r))}class T extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==u.string){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_type,expected:u.string,received:a.parsedType}),m}const s=new k;let n;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="max")e.data.length>a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(n=this._getOrReturnCtx(e,n),i?l(n,{code:c.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&l(n,{code:c.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty())}else if(a.kind==="email")ze.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"email",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")me||(me=new RegExp(Ue,"u")),me.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"emoji",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")De.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"uuid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")Ve.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"cuid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")$e.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"cuid2",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")Le.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"ulid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),l(n,{validation:"url",code:c.invalid_string,message:a.message}),s.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"regex",code:c.invalid_string,message:a.message}),s.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(e,n),l(n,{code:c.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),s.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(n=this._getOrReturnCtx(e,n),l(n,{code:c.invalid_string,validation:{startsWith:a.value},message:a.message}),s.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),l(n,{code:c.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?qe(a).test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:c.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="ip"?Je(e.data,a.version)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"ip",code:c.invalid_string,message:a.message}),s.dirty()):g.assertNever(a);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:c.invalid_string,...h.errToObj(s)})}_addCheck(e){return new T({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...h.errToObj(e)})}url(e){return this._addCheck({kind:"url",...h.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...h.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...h.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...h.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...h.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...h.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...h.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!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,...h.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...h.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...h.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...h.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...h.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...h.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...h.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...h.errToObj(t)})}nonempty(e){return this.min(1,h.errToObj(e))}trim(){return new T({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new T({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new T({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}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 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 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}}T.create=r=>{var e;return new T({checks:[],typeName:p.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...y(r)})};function Ye(r,e){const t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=t>s?t:s,a=parseInt(r.toFixed(n).replace(".","")),i=parseInt(e.toFixed(n).replace(".",""));return a%i/Math.pow(10,n)}class j extends v{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)!==u.number){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_type,expected:u.number,received:a.parsedType}),m}let s;const n=new k;for(const a of this._def.checks)a.kind==="int"?g.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:c.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:c.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:c.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?Ye(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),l(s,{code:c.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:c.not_finite,message:a.message}),n.dirty()):g.assertNever(a);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,s,n){return new j({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:h.toString(n)}]})}_addCheck(e){return new j({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:h.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:h.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:h.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:h.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:h.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&g.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}j.create=r=>new j({checks:[],typeName:p.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...y(r)});class A extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==u.bigint){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_type,expected:u.bigint,received:a.parsedType}),m}let s;const n=new k;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:c.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:c.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),l(s,{code:c.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):g.assertNever(a);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,s,n){return new A({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:h.toString(n)}]})}_addCheck(e){return new A({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:h.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}A.create=r=>{var e;return new A({checks:[],typeName:p.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...y(r)})};class J extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==u.boolean){const s=this._getOrReturnCtx(e);return l(s,{code:c.invalid_type,expected:u.boolean,received:s.parsedType}),m}return b(e.data)}}J.create=r=>new J({typeName:p.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...y(r)});class V extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==u.date){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_type,expected:u.date,received:a.parsedType}),m}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_date}),m}const s=new k;let n;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),s.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):g.assertNever(a);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new V({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:h.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:h.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}V.create=r=>new V({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:p.ZodDate,...y(r)});class oe extends v{_parse(e){if(this._getType(e)!==u.symbol){const s=this._getOrReturnCtx(e);return l(s,{code:c.invalid_type,expected:u.symbol,received:s.parsedType}),m}return b(e.data)}}oe.create=r=>new oe({typeName:p.ZodSymbol,...y(r)});class Y extends v{_parse(e){if(this._getType(e)!==u.undefined){const s=this._getOrReturnCtx(e);return l(s,{code:c.invalid_type,expected:u.undefined,received:s.parsedType}),m}return b(e.data)}}Y.create=r=>new Y({typeName:p.ZodUndefined,...y(r)});class H extends v{_parse(e){if(this._getType(e)!==u.null){const s=this._getOrReturnCtx(e);return l(s,{code:c.invalid_type,expected:u.null,received:s.parsedType}),m}return b(e.data)}}H.create=r=>new H({typeName:p.ZodNull,...y(r)});class U extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return b(e.data)}}U.create=r=>new U({typeName:p.ZodAny,...y(r)});class P extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return b(e.data)}}P.create=r=>new P({typeName:p.ZodUnknown,...y(r)});class I extends v{_parse(e){const t=this._getOrReturnCtx(e);return l(t,{code:c.invalid_type,expected:u.never,received:t.parsedType}),m}}I.create=r=>new I({typeName:p.ZodNever,...y(r)});class ce extends v{_parse(e){if(this._getType(e)!==u.undefined){const s=this._getOrReturnCtx(e);return l(s,{code:c.invalid_type,expected:u.void,received:s.parsedType}),m}return b(e.data)}}ce.create=r=>new ce({typeName:p.ZodVoid,...y(r)});class S extends v{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==u.array)return l(t,{code:c.invalid_type,expected:u.array,received:t.parsedType}),m;if(n.exactLength!==null){const i=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(i||o)&&(l(t,{code:i?c.too_big:c.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(l(t,{code:c.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(l(t,{code:c.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>n.type._parseAsync(new O(t,i,t.path,o)))).then(i=>k.mergeArray(s,i));const a=[...t.data].map((i,o)=>n.type._parseSync(new O(t,i,t.path,o)));return k.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new S({...this._def,minLength:{value:e,message:h.toString(t)}})}max(e,t){return new S({...this._def,maxLength:{value:e,message:h.toString(t)}})}length(e,t){return new S({...this._def,exactLength:{value:e,message:h.toString(t)}})}nonempty(e){return this.min(1,e)}}S.create=(r,e)=>new S({type:r,minLength:null,maxLength:null,exactLength:null,typeName:p.ZodArray,...y(e)});function D(r){if(r instanceof x){const e={};for(const t in r.shape){const s=r.shape[t];e[t]=C.create(D(s))}return new x({...r._def,shape:()=>e})}else return r instanceof S?new S({...r._def,type:D(r.element)}):r instanceof C?C.create(D(r.unwrap())):r instanceof L?L.create(D(r.unwrap())):r instanceof E?E.create(r.items.map(e=>D(e))):r}class x extends v{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=g.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==u.object){const d=this._getOrReturnCtx(e);return l(d,{code:c.invalid_type,expected:u.object,received:d.parsedType}),m}const{status:s,ctx:n}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof I&&this._def.unknownKeys==="strip"))for(const d in n.data)i.includes(d)||o.push(d);const f=[];for(const d of i){const _=a[d],w=n.data[d];f.push({key:{status:"valid",value:d},value:_._parse(new O(n,w,n.path,d)),alwaysSet:d in n.data})}if(this._def.catchall instanceof I){const d=this._def.unknownKeys;if(d==="passthrough")for(const _ of o)f.push({key:{status:"valid",value:_},value:{status:"valid",value:n.data[_]}});else if(d==="strict")o.length>0&&(l(n,{code:c.unrecognized_keys,keys:o}),s.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const _ of o){const w=n.data[_];f.push({key:{status:"valid",value:_},value:d._parse(new O(n,w,n.path,_)),alwaysSet:_ in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const d=[];for(const _ of f){const w=await _.key;d.push({key:w,value:await _.value,alwaysSet:_.alwaysSet})}return d}).then(d=>k.mergeObjectSync(s,d)):k.mergeObjectSync(s,f)}get shape(){return this._def.shape()}strict(e){return h.errToObj,new x({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var n,a,i,o;const f=(i=(a=(n=this._def).errorMap)===null||a===void 0?void 0:a.call(n,t,s).message)!==null&&i!==void 0?i:s.defaultError;return t.code==="unrecognized_keys"?{message:(o=h.errToObj(e).message)!==null&&o!==void 0?o:f}:{message:f}}}:{}})}strip(){return new x({...this._def,unknownKeys:"strip"})}passthrough(){return new x({...this._def,unknownKeys:"passthrough"})}extend(e){return new x({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new x({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:p.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new x({...this._def,catchall:e})}pick(e){const t={};return g.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])}),new x({...this._def,shape:()=>t})}omit(e){const t={};return g.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s])}),new x({...this._def,shape:()=>t})}deepPartial(){return D(this)}partial(e){const t={};return g.objectKeys(this.shape).forEach(s=>{const n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional()}),new x({...this._def,shape:()=>t})}required(e){const t={};return g.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof C;)a=a._def.innerType;t[s]=a}}),new x({...this._def,shape:()=>t})}keyof(){return Ze(g.objectKeys(this.shape))}}x.create=(r,e)=>new x({shape:()=>r,unknownKeys:"strip",catchall:I.create(),typeName:p.ZodObject,...y(e)});x.strictCreate=(r,e)=>new x({shape:()=>r,unknownKeys:"strict",catchall:I.create(),typeName:p.ZodObject,...y(e)});x.lazycreate=(r,e)=>new x({shape:r,unknownKeys:"strip",catchall:I.create(),typeName:p.ZodObject,...y(e)});class G extends v{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function n(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new Z(o.ctx.common.issues));return l(t,{code:c.invalid_union,unionErrors:i}),m}if(t.common.async)return Promise.all(s.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(n);{let a;const i=[];for(const f of s){const d={...t,common:{...t.common,issues:[]},parent:null},_=f._parseSync({data:t.data,path:t.path,parent:d});if(_.status==="valid")return _;_.status==="dirty"&&!a&&(a={result:_,ctx:d}),d.common.issues.length&&i.push(d.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(f=>new Z(f));return l(t,{code:c.invalid_union,unionErrors:o}),m}}get options(){return this._def.options}}G.create=(r,e)=>new G({options:r,typeName:p.ZodUnion,...y(e)});const se=r=>r instanceof K?se(r.schema):r instanceof N?se(r.innerType()):r instanceof F?[r.value]:r instanceof M?r.options:r instanceof ee?Object.keys(r.enum):r instanceof te?se(r._def.innerType):r instanceof Y?[void 0]:r instanceof H?[null]:null;class he extends v{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==u.object)return l(t,{code:c.invalid_type,expected:u.object,received:t.parsedType}),m;const s=this.discriminator,n=t.data[s],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(l(t,{code:c.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),m)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const n=new Map;for(const a of t){const i=se(a.shape[e]);if(!i)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,a)}}return new he({typeName:p.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...y(s)})}}function ge(r,e){const t=R(r),s=R(e);if(r===e)return{valid:!0,data:r};if(t===u.object&&s===u.object){const n=g.objectKeys(e),a=g.objectKeys(r).filter(o=>n.indexOf(o)!==-1),i={...r,...e};for(const o of a){const f=ge(r[o],e[o]);if(!f.valid)return{valid:!1};i[o]=f.data}return{valid:!0,data:i}}else if(t===u.array&&s===u.array){if(r.length!==e.length)return{valid:!1};const n=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],f=ge(i,o);if(!f.valid)return{valid:!1};n.push(f.data)}return{valid:!0,data:n}}else return t===u.date&&s===u.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class X extends v{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=(a,i)=>{if(ve(a)||ve(i))return m;const o=ge(a.value,i.value);return o.valid?((_e(a)||_e(i))&&t.dirty(),{status:t.value,value:o.data}):(l(s,{code:c.invalid_intersection_types}),m)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}X.create=(r,e,t)=>new X({left:r,right:e,typeName:p.ZodIntersection,...y(t)});class E extends v{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==u.array)return l(s,{code:c.invalid_type,expected:u.array,received:s.parsedType}),m;if(s.data.length<this._def.items.length)return l(s,{code:c.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),m;!this._def.rest&&s.data.length>this._def.items.length&&(l(s,{code:c.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...s.data].map((i,o)=>{const f=this._def.items[o]||this._def.rest;return f?f._parse(new O(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(a).then(i=>k.mergeArray(t,i)):k.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new E({...this._def,rest:e})}}E.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new E({items:r,typeName:p.ZodTuple,rest:null,...y(e)})};class Q extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==u.object)return l(s,{code:c.invalid_type,expected:u.object,received:s.parsedType}),m;const n=[],a=this._def.keyType,i=this._def.valueType;for(const o in s.data)n.push({key:a._parse(new O(s,o,s.path,o)),value:i._parse(new O(s,s.data[o],s.path,o))});return s.common.async?k.mergeObjectAsync(t,n):k.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof v?new Q({keyType:e,valueType:t,typeName:p.ZodRecord,...y(s)}):new Q({keyType:T.create(),valueType:e,typeName:p.ZodRecord,...y(t)})}}class de extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==u.map)return l(s,{code:c.invalid_type,expected:u.map,received:s.parsedType}),m;const n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,f],d)=>({key:n._parse(new O(s,o,s.path,[d,"key"])),value:a._parse(new O(s,f,s.path,[d,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const f of i){const d=await f.key,_=await f.value;if(d.status==="aborted"||_.status==="aborted")return m;(d.status==="dirty"||_.status==="dirty")&&t.dirty(),o.set(d.value,_.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const f of i){const d=f.key,_=f.value;if(d.status==="aborted"||_.status==="aborted")return m;(d.status==="dirty"||_.status==="dirty")&&t.dirty(),o.set(d.value,_.value)}return{status:t.value,value:o}}}}de.create=(r,e,t)=>new de({valueType:e,keyType:r,typeName:p.ZodMap,...y(t)});class $ extends v{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==u.set)return l(s,{code:c.invalid_type,expected:u.set,received:s.parsedType}),m;const n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(l(s,{code:c.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(l(s,{code:c.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const a=this._def.valueType;function i(f){const d=new Set;for(const _ of f){if(_.status==="aborted")return m;_.status==="dirty"&&t.dirty(),d.add(_.value)}return{status:t.value,value:d}}const o=[...s.data.values()].map((f,d)=>a._parse(new O(s,f,s.path,d)));return s.common.async?Promise.all(o).then(f=>i(f)):i(o)}min(e,t){return new $({...this._def,minSize:{value:e,message:h.toString(t)}})}max(e,t){return new $({...this._def,maxSize:{value:e,message:h.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}$.create=(r,e)=>new $({valueType:r,minSize:null,maxSize:null,typeName:p.ZodSet,...y(e)});class z extends v{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==u.function)return l(t,{code:c.invalid_type,expected:u.function,received:t.parsedType}),m;function s(o,f){return ae({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ne(),W].filter(d=>!!d),issueData:{code:c.invalid_arguments,argumentsError:f}})}function n(o,f){return ae({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ne(),W].filter(d=>!!d),issueData:{code:c.invalid_return_type,returnTypeError:f}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof B){const o=this;return b(async function(...f){const d=new Z([]),_=await o._def.args.parseAsync(f,a).catch(pe=>{throw d.addIssue(s(f,pe)),d}),w=await Reflect.apply(i,this,_);return await o._def.returns._def.type.parseAsync(w,a).catch(pe=>{throw d.addIssue(n(w,pe)),d})})}else{const o=this;return b(function(...f){const d=o._def.args.safeParse(f,a);if(!d.success)throw new Z([s(f,d.error)]);const _=Reflect.apply(i,this,d.data),w=o._def.returns.safeParse(_,a);if(!w.success)throw new Z([n(_,w.error)]);return w.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new z({...this._def,args:E.create(e).rest(P.create())})}returns(e){return new z({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new z({args:e||E.create([]).rest(P.create()),returns:t||P.create(),typeName:p.ZodFunction,...y(s)})}}class K extends v{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})}}K.create=(r,e)=>new K({getter:r,typeName:p.ZodLazy,...y(e)});class F extends v{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return l(t,{received:t.data,code:c.invalid_literal,expected:this._def.value}),m}return{status:"valid",value:e.data}}get value(){return this._def.value}}F.create=(r,e)=>new F({value:r,typeName:p.ZodLiteral,...y(e)});function Ze(r,e){return new M({values:r,typeName:p.ZodEnum,...y(e)})}class M extends v{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return l(t,{expected:g.joinValues(s),received:t.parsedType,code:c.invalid_type}),m}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),s=this._def.values;return l(t,{received:t.data,code:c.invalid_enum_value,options:s}),m}return b(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){return M.create(e)}exclude(e){return M.create(this.options.filter(t=>!e.includes(t)))}}M.create=Ze;class ee extends v{_parse(e){const t=g.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==u.string&&s.parsedType!==u.number){const n=g.objectValues(t);return l(s,{expected:g.joinValues(n),received:s.parsedType,code:c.invalid_type}),m}if(t.indexOf(e.data)===-1){const n=g.objectValues(t);return l(s,{received:s.data,code:c.invalid_enum_value,options:n}),m}return b(e.data)}get enum(){return this._def.values}}ee.create=(r,e)=>new ee({values:r,typeName:p.ZodNativeEnum,...y(e)});class B extends v{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==u.promise&&t.common.async===!1)return l(t,{code:c.invalid_type,expected:u.promise,received:t.parsedType}),m;const s=t.parsedType===u.promise?t.data:Promise.resolve(t.data);return b(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}B.create=(r,e)=>new B({type:r,typeName:p.ZodPromise,...y(e)});class N extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===p.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{l(s,i),i.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){const i=n.transform(s.data,a);return s.common.issues.length?{status:"dirty",value:s.data}:s.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:s.path,parent:s})):this._def.schema._parseSync({data:i,path:s.path,parent:s})}if(n.type==="refinement"){const i=o=>{const f=n.refinement(o,a);if(s.common.async)return Promise.resolve(f);if(f instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?m:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?m:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!q(i))return i;const o=n.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>q(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);g.assertNever(n)}}N.create=(r,e,t)=>new N({schema:r,typeName:p.ZodEffects,effect:e,...y(t)});N.createWithPreprocess=(r,e,t)=>new N({schema:e,effect:{type:"preprocess",transform:r},typeName:p.ZodEffects,...y(t)});class C extends v{_parse(e){return this._getType(e)===u.undefined?b(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}C.create=(r,e)=>new C({innerType:r,typeName:p.ZodOptional,...y(e)});class L extends v{_parse(e){return this._getType(e)===u.null?b(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}L.create=(r,e)=>new L({innerType:r,typeName:p.ZodNullable,...y(e)});class te extends v{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===u.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}te.create=(r,e)=>new te({innerType:r,typeName:p.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...y(e)});class ue extends v{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return ie(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Z(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Z(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}ue.create=(r,e)=>new ue({innerType:r,typeName:p.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...y(e)});class le extends v{_parse(e){if(this._getType(e)!==u.nan){const s=this._getOrReturnCtx(e);return l(s,{code:c.invalid_type,expected:u.nan,received:s.parsedType}),m}return{status:"valid",value:e.data}}}le.create=r=>new le({typeName:p.ZodNaN,...y(r)});const He=Symbol("zod_brand");class Se extends v{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class re extends v{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?m:a.status==="dirty"?(t.dirty(),Te(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})})();{const n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?m:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,t){return new re({in:e,out:t,typeName:p.ZodPipeline})}}class fe extends v{_parse(e){const t=this._def.innerType._parse(e);return q(t)&&(t.value=Object.freeze(t.value)),t}}fe.create=(r,e)=>new fe({innerType:r,typeName:p.ZodReadonly,...y(e)});const Ne=(r,e={},t)=>r?U.create().superRefine((s,n)=>{var a,i;if(!r(s)){const o=typeof e=="function"?e(s):typeof e=="string"?{message:e}:e,f=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,d=typeof o=="string"?{message:o}:o;n.addIssue({code:"custom",...d,fatal:f})}}):U.create(),Ge={object:x.lazycreate};var p;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(p||(p={}));const Xe=(r,e={message:`Input not instance of ${r.name}`})=>Ne(t=>t instanceof r,e),Oe=T.create,Ee=j.create,Qe=le.create,Ke=A.create,Ce=J.create,Fe=V.create,et=oe.create,tt=Y.create,rt=H.create,st=U.create,nt=P.create,at=I.create,it=ce.create,ot=S.create,ct=x.create,dt=x.strictCreate,ut=G.create,lt=he.create,ft=X.create,ht=E.create,pt=Q.create,mt=de.create,yt=$.create,vt=z.create,_t=K.create,gt=F.create,xt=M.create,kt=ee.create,bt=B.create,ke=N.create,wt=C.create,Tt=L.create,Zt=N.createWithPreprocess,St=re.create,Nt=()=>Oe().optional(),Ot=()=>Ee().optional(),Et=()=>Ce().optional(),Ct={string:r=>T.create({...r,coerce:!0}),number:r=>j.create({...r,coerce:!0}),boolean:r=>J.create({...r,coerce:!0}),bigint:r=>A.create({...r,coerce:!0}),date:r=>V.create({...r,coerce:!0})},It=m;var be=Object.freeze({__proto__:null,defaultErrorMap:W,setErrorMap:Me,getErrorMap:ne,makeIssue:ae,EMPTY_PATH:Pe,addIssueToContext:l,ParseStatus:k,INVALID:m,DIRTY:Te,OK:b,isAborted:ve,isDirty:_e,isValid:q,isAsync:ie,get util(){return g},get objectUtil(){return ye},ZodParsedType:u,getParsedType:R,ZodType:v,ZodString:T,ZodNumber:j,ZodBigInt:A,ZodBoolean:J,ZodDate:V,ZodSymbol:oe,ZodUndefined:Y,ZodNull:H,ZodAny:U,ZodUnknown:P,ZodNever:I,ZodVoid:ce,ZodArray:S,ZodObject:x,ZodUnion:G,ZodDiscriminatedUnion:he,ZodIntersection:X,ZodTuple:E,ZodRecord:Q,ZodMap:de,ZodSet:$,ZodFunction:z,ZodLazy:K,ZodLiteral:F,ZodEnum:M,ZodNativeEnum:ee,ZodPromise:B,ZodEffects:N,ZodTransformer:N,ZodOptional:C,ZodNullable:L,ZodDefault:te,ZodCatch:ue,ZodNaN:le,BRAND:He,ZodBranded:Se,ZodPipeline:re,ZodReadonly:fe,custom:Ne,Schema:v,ZodSchema:v,late:Ge,get ZodFirstPartyTypeKind(){return p},coerce:Ct,any:st,array:ot,bigint:Ke,boolean:Ce,date:Fe,discriminatedUnion:lt,effect:ke,enum:xt,function:vt,instanceof:Xe,intersection:ft,lazy:_t,literal:gt,map:mt,nan:Qe,nativeEnum:kt,never:at,null:rt,nullable:Tt,number:Ee,object:ct,oboolean:Et,onumber:Ot,optional:wt,ostring:Nt,pipeline:St,preprocess:Zt,promise:bt,record:pt,set:yt,strictObject:dt,string:Oe,symbol:et,transformer:ke,tuple:ht,undefined:tt,union:ut,unknown:nt,void:it,NEVER:It,ZodIssueCode:c,quotelessJson:Ae,ZodError:Z});function Ie(r){return Object.entries(r).reduce((e,[t,s])=>("value"in s?e[t]=s.value||void 0:e[t]=Ie(s),e),{})}function Re(r,e){const t=Object.entries(r).reduce((s,[n,a])=>("value"in a?(!a.isServerOnly||e)&&(s[n]=a.schema??be.string()):s[n]=Re(a,e),s),{});return be.object(t)}function je(r,e,t,s,n){return new Proxy(r,{get(a,i){const o=e[i];if(!o)return;const f=n?`${n}.${i}`:i;return"value"in o?o.isServerOnly&&!t?s(f):a[i]:je(r[i],e[i],t,s,f)}})}function Rt(r){const e=r.isServer??typeof window>"u",t=r.onValidationError??(o=>{throw new Error(`❌ Invalid environment variables: ${o.issues.map(({path:f,message:d})=>`${f.join(".")}: ${d}`).join(", ")}`)}),s=r.onAccessError??(o=>{throw new Error(`❌ Attempted to access server-side environment variable '${o}' on the client`)}),n=Re(r.values,e),a=Ie(r.values),i=n.safeParse(a);return i.success?je(i.data,r.values,e,s):t(i.error)}exports.createEnvironment=Rt;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var g;(function(r){r.assertEqual=n=>n;function e(n){}r.assertIs=e;function t(n){throw new Error}r.assertNever=t,r.arrayToEnum=n=>{const a={};for(const i of n)a[i]=i;return a},r.getValidEnumValues=n=>{const a=r.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(const o of a)i[o]=n[o];return r.objectValues(i)},r.objectValues=n=>r.objectKeys(n).map(function(a){return n[a]}),r.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const a=[];for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&a.push(i);return a},r.find=(n,a)=>{for(const i of n)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=s,r.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(g||(g={}));var ve;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(ve||(ve={}));const u=g.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),R=r=>{switch(typeof r){case"undefined":return u.undefined;case"string":return u.string;case"number":return isNaN(r)?u.nan:u.number;case"boolean":return u.boolean;case"function":return u.function;case"bigint":return u.bigint;case"symbol":return u.symbol;case"object":return Array.isArray(r)?u.array:r===null?u.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?u.promise:typeof Map<"u"&&r instanceof Map?u.map:typeof Set<"u"&&r instanceof Set?u.set:typeof Date<"u"&&r instanceof Date?u.date:u.object;default:return u.unknown}},c=g.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"]),Ae=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Z extends Error{constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},s={_errors:[]},n=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else{let o=s,f=0;for(;f<i.path.length;){const d=i.path[f];f===i.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(t(i))):o[d]=o[d]||{_errors:[]},o=o[d],f++}}};return n(this),s}toString(){return this.message}get message(){return JSON.stringify(this.issues,g.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):s.push(e(n));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}Z.create=r=>new Z(r);const W=(r,e)=>{let t;switch(r.code){case c.invalid_type:r.received===u.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case c.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,g.jsonStringifyReplacer)}`;break;case c.unrecognized_keys:t=`Unrecognized key(s) in object: ${g.joinValues(r.keys,", ")}`;break;case c.invalid_union:t="Invalid input";break;case c.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${g.joinValues(r.options)}`;break;case c.invalid_enum_value:t=`Invalid enum value. Expected ${g.joinValues(r.options)}, received '${r.received}'`;break;case c.invalid_arguments:t="Invalid function arguments";break;case c.invalid_return_type:t="Invalid function return type";break;case c.invalid_date:t="Invalid date";break;case c.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:g.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case c.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case c.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case c.custom:t="Invalid input";break;case c.invalid_intersection_types:t="Intersection results could not be merged";break;case c.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case c.not_finite:t="Number must be finite";break;default:t=e.defaultError,g.assertNever(r)}return{message:t}};let we=W;function Me(r){we=r}function ne(){return we}const ae=r=>{const{data:e,path:t,errorMaps:s,issueData:n}=r,a=[...t,...n.path||[]],i={...n,path:a};let o="";const f=s.filter(d=>!!d).slice().reverse();for(const d of f)o=d(i,{data:e,defaultError:o}).message;return{...n,path:a,message:n.message||o}},Pe=[];function l(r,e){const t=ae({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ne(),W].filter(s=>!!s)});r.common.issues.push(t)}class k{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const n of t){if(n.status==="aborted")return m;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const n of t)s.push({key:await n.key,value:await n.value});return k.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const n of t){const{key:a,value:i}=n;if(a.status==="aborted"||i.status==="aborted")return m;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||n.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}}const m=Object.freeze({status:"aborted"}),Te=r=>({status:"dirty",value:r}),b=r=>({status:"valid",value:r}),_e=r=>r.status==="aborted",ge=r=>r.status==="dirty",q=r=>r.status==="valid",ie=r=>typeof Promise<"u"&&r instanceof Promise;var h;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(h||(h={}));class O{constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n}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 ke=(r,e)=>{if(q(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Z(r.common.issues);return this._error=t,this._error}}};function y(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:n}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(i,o)=>i.code!=="invalid_type"?{message:o.defaultError}:typeof o.data>"u"?{message:s??o.defaultError}:{message:t??o.defaultError},description:n}}class v{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)}get description(){return this._def.description}_getType(e){return R(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:R(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new k,ctx:{common:e.parent.common,data:e.data,parsedType:R(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ie(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const n={common:{issues:[],async:(s=t==null?void 0:t.async)!==null&&s!==void 0?s:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:R(e)},a=this._parseSync({data:e,path:n.path,parent:n});return ke(n,a)}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:R(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await(ie(n)?n:Promise.resolve(n));return ke(s,a)}refine(e,t){const s=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{const i=e(n),o=()=>a.addIssue({code:c.custom,...s(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(f=>f?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof t=="function"?t(s,n):t),!1))}_refinement(e){return new N({schema:this,typeName:p.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return C.create(this,this._def)}nullable(){return L.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return S.create(this,this._def)}promise(){return B.create(this,this._def)}or(e){return G.create([this,e],this._def)}and(e){return X.create(this,e,this._def)}transform(e){return new N({...y(this._def),schema:this,typeName:p.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new te({...y(this._def),innerType:this,defaultValue:t,typeName:p.ZodDefault})}brand(){return new Se({typeName:p.ZodBranded,type:this,...y(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ue({...y(this._def),innerType:this,catchValue:t,typeName:p.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return re.create(this,e)}readonly(){return fe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ve=/^c[^\s-]{8,}$/i,$e=/^[a-z][a-z0-9]*$/,Le=/^[0-9A-HJKMNP-TV-Z]{26}$/,De=/^[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,ze=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ue="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let me;const Be=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,We=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,qe=r=>r.precision?r.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}Z$`):r.precision===0?r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function Je(r,e){return!!((e==="v4"||!e)&&Be.test(r)||(e==="v6"||!e)&&We.test(r))}class T extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==u.string){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_type,expected:u.string,received:a.parsedType}),m}const s=new k;let n;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="max")e.data.length>a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(n=this._getOrReturnCtx(e,n),i?l(n,{code:c.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&l(n,{code:c.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty())}else if(a.kind==="email")ze.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"email",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")me||(me=new RegExp(Ue,"u")),me.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"emoji",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")De.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"uuid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")Ve.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"cuid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")$e.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"cuid2",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")Le.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"ulid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),l(n,{validation:"url",code:c.invalid_string,message:a.message}),s.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"regex",code:c.invalid_string,message:a.message}),s.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(e,n),l(n,{code:c.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),s.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(n=this._getOrReturnCtx(e,n),l(n,{code:c.invalid_string,validation:{startsWith:a.value},message:a.message}),s.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),l(n,{code:c.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?qe(a).test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:c.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="ip"?Je(e.data,a.version)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"ip",code:c.invalid_string,message:a.message}),s.dirty()):g.assertNever(a);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:c.invalid_string,...h.errToObj(s)})}_addCheck(e){return new T({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...h.errToObj(e)})}url(e){return this._addCheck({kind:"url",...h.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...h.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...h.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...h.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...h.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...h.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...h.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!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,...h.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...h.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...h.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...h.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...h.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...h.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...h.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...h.errToObj(t)})}nonempty(e){return this.min(1,h.errToObj(e))}trim(){return new T({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new T({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new T({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}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 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 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}}T.create=r=>{var e;return new T({checks:[],typeName:p.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...y(r)})};function Ye(r,e){const t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=t>s?t:s,a=parseInt(r.toFixed(n).replace(".","")),i=parseInt(e.toFixed(n).replace(".",""));return a%i/Math.pow(10,n)}class j extends v{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)!==u.number){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_type,expected:u.number,received:a.parsedType}),m}let s;const n=new k;for(const a of this._def.checks)a.kind==="int"?g.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:c.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:c.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:c.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?Ye(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),l(s,{code:c.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:c.not_finite,message:a.message}),n.dirty()):g.assertNever(a);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,s,n){return new j({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:h.toString(n)}]})}_addCheck(e){return new j({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:h.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:h.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:h.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:h.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:h.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&g.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}j.create=r=>new j({checks:[],typeName:p.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...y(r)});class A extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==u.bigint){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_type,expected:u.bigint,received:a.parsedType}),m}let s;const n=new k;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:c.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:c.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),l(s,{code:c.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):g.assertNever(a);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,s,n){return new A({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:h.toString(n)}]})}_addCheck(e){return new A({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:h.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}A.create=r=>{var e;return new A({checks:[],typeName:p.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...y(r)})};class J extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==u.boolean){const s=this._getOrReturnCtx(e);return l(s,{code:c.invalid_type,expected:u.boolean,received:s.parsedType}),m}return b(e.data)}}J.create=r=>new J({typeName:p.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...y(r)});class V extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==u.date){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_type,expected:u.date,received:a.parsedType}),m}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_date}),m}const s=new k;let n;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),s.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):g.assertNever(a);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new V({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:h.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:h.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}V.create=r=>new V({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:p.ZodDate,...y(r)});class oe extends v{_parse(e){if(this._getType(e)!==u.symbol){const s=this._getOrReturnCtx(e);return l(s,{code:c.invalid_type,expected:u.symbol,received:s.parsedType}),m}return b(e.data)}}oe.create=r=>new oe({typeName:p.ZodSymbol,...y(r)});class Y extends v{_parse(e){if(this._getType(e)!==u.undefined){const s=this._getOrReturnCtx(e);return l(s,{code:c.invalid_type,expected:u.undefined,received:s.parsedType}),m}return b(e.data)}}Y.create=r=>new Y({typeName:p.ZodUndefined,...y(r)});class H extends v{_parse(e){if(this._getType(e)!==u.null){const s=this._getOrReturnCtx(e);return l(s,{code:c.invalid_type,expected:u.null,received:s.parsedType}),m}return b(e.data)}}H.create=r=>new H({typeName:p.ZodNull,...y(r)});class U extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return b(e.data)}}U.create=r=>new U({typeName:p.ZodAny,...y(r)});class P extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return b(e.data)}}P.create=r=>new P({typeName:p.ZodUnknown,...y(r)});class I extends v{_parse(e){const t=this._getOrReturnCtx(e);return l(t,{code:c.invalid_type,expected:u.never,received:t.parsedType}),m}}I.create=r=>new I({typeName:p.ZodNever,...y(r)});class ce extends v{_parse(e){if(this._getType(e)!==u.undefined){const s=this._getOrReturnCtx(e);return l(s,{code:c.invalid_type,expected:u.void,received:s.parsedType}),m}return b(e.data)}}ce.create=r=>new ce({typeName:p.ZodVoid,...y(r)});class S extends v{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==u.array)return l(t,{code:c.invalid_type,expected:u.array,received:t.parsedType}),m;if(n.exactLength!==null){const i=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(i||o)&&(l(t,{code:i?c.too_big:c.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(l(t,{code:c.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(l(t,{code:c.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>n.type._parseAsync(new O(t,i,t.path,o)))).then(i=>k.mergeArray(s,i));const a=[...t.data].map((i,o)=>n.type._parseSync(new O(t,i,t.path,o)));return k.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new S({...this._def,minLength:{value:e,message:h.toString(t)}})}max(e,t){return new S({...this._def,maxLength:{value:e,message:h.toString(t)}})}length(e,t){return new S({...this._def,exactLength:{value:e,message:h.toString(t)}})}nonempty(e){return this.min(1,e)}}S.create=(r,e)=>new S({type:r,minLength:null,maxLength:null,exactLength:null,typeName:p.ZodArray,...y(e)});function D(r){if(r instanceof x){const e={};for(const t in r.shape){const s=r.shape[t];e[t]=C.create(D(s))}return new x({...r._def,shape:()=>e})}else return r instanceof S?new S({...r._def,type:D(r.element)}):r instanceof C?C.create(D(r.unwrap())):r instanceof L?L.create(D(r.unwrap())):r instanceof E?E.create(r.items.map(e=>D(e))):r}class x extends v{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=g.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==u.object){const d=this._getOrReturnCtx(e);return l(d,{code:c.invalid_type,expected:u.object,received:d.parsedType}),m}const{status:s,ctx:n}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof I&&this._def.unknownKeys==="strip"))for(const d in n.data)i.includes(d)||o.push(d);const f=[];for(const d of i){const _=a[d],w=n.data[d];f.push({key:{status:"valid",value:d},value:_._parse(new O(n,w,n.path,d)),alwaysSet:d in n.data})}if(this._def.catchall instanceof I){const d=this._def.unknownKeys;if(d==="passthrough")for(const _ of o)f.push({key:{status:"valid",value:_},value:{status:"valid",value:n.data[_]}});else if(d==="strict")o.length>0&&(l(n,{code:c.unrecognized_keys,keys:o}),s.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const _ of o){const w=n.data[_];f.push({key:{status:"valid",value:_},value:d._parse(new O(n,w,n.path,_)),alwaysSet:_ in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const d=[];for(const _ of f){const w=await _.key;d.push({key:w,value:await _.value,alwaysSet:_.alwaysSet})}return d}).then(d=>k.mergeObjectSync(s,d)):k.mergeObjectSync(s,f)}get shape(){return this._def.shape()}strict(e){return h.errToObj,new x({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var n,a,i,o;const f=(i=(a=(n=this._def).errorMap)===null||a===void 0?void 0:a.call(n,t,s).message)!==null&&i!==void 0?i:s.defaultError;return t.code==="unrecognized_keys"?{message:(o=h.errToObj(e).message)!==null&&o!==void 0?o:f}:{message:f}}}:{}})}strip(){return new x({...this._def,unknownKeys:"strip"})}passthrough(){return new x({...this._def,unknownKeys:"passthrough"})}extend(e){return new x({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new x({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:p.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new x({...this._def,catchall:e})}pick(e){const t={};return g.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])}),new x({...this._def,shape:()=>t})}omit(e){const t={};return g.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s])}),new x({...this._def,shape:()=>t})}deepPartial(){return D(this)}partial(e){const t={};return g.objectKeys(this.shape).forEach(s=>{const n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional()}),new x({...this._def,shape:()=>t})}required(e){const t={};return g.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof C;)a=a._def.innerType;t[s]=a}}),new x({...this._def,shape:()=>t})}keyof(){return Ze(g.objectKeys(this.shape))}}x.create=(r,e)=>new x({shape:()=>r,unknownKeys:"strip",catchall:I.create(),typeName:p.ZodObject,...y(e)});x.strictCreate=(r,e)=>new x({shape:()=>r,unknownKeys:"strict",catchall:I.create(),typeName:p.ZodObject,...y(e)});x.lazycreate=(r,e)=>new x({shape:r,unknownKeys:"strip",catchall:I.create(),typeName:p.ZodObject,...y(e)});class G extends v{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function n(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new Z(o.ctx.common.issues));return l(t,{code:c.invalid_union,unionErrors:i}),m}if(t.common.async)return Promise.all(s.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(n);{let a;const i=[];for(const f of s){const d={...t,common:{...t.common,issues:[]},parent:null},_=f._parseSync({data:t.data,path:t.path,parent:d});if(_.status==="valid")return _;_.status==="dirty"&&!a&&(a={result:_,ctx:d}),d.common.issues.length&&i.push(d.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(f=>new Z(f));return l(t,{code:c.invalid_union,unionErrors:o}),m}}get options(){return this._def.options}}G.create=(r,e)=>new G({options:r,typeName:p.ZodUnion,...y(e)});const se=r=>r instanceof K?se(r.schema):r instanceof N?se(r.innerType()):r instanceof F?[r.value]:r instanceof M?r.options:r instanceof ee?Object.keys(r.enum):r instanceof te?se(r._def.innerType):r instanceof Y?[void 0]:r instanceof H?[null]:null;class he extends v{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==u.object)return l(t,{code:c.invalid_type,expected:u.object,received:t.parsedType}),m;const s=this.discriminator,n=t.data[s],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(l(t,{code:c.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),m)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const n=new Map;for(const a of t){const i=se(a.shape[e]);if(!i)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,a)}}return new he({typeName:p.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...y(s)})}}function xe(r,e){const t=R(r),s=R(e);if(r===e)return{valid:!0,data:r};if(t===u.object&&s===u.object){const n=g.objectKeys(e),a=g.objectKeys(r).filter(o=>n.indexOf(o)!==-1),i={...r,...e};for(const o of a){const f=xe(r[o],e[o]);if(!f.valid)return{valid:!1};i[o]=f.data}return{valid:!0,data:i}}else if(t===u.array&&s===u.array){if(r.length!==e.length)return{valid:!1};const n=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],f=xe(i,o);if(!f.valid)return{valid:!1};n.push(f.data)}return{valid:!0,data:n}}else return t===u.date&&s===u.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class X extends v{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=(a,i)=>{if(_e(a)||_e(i))return m;const o=xe(a.value,i.value);return o.valid?((ge(a)||ge(i))&&t.dirty(),{status:t.value,value:o.data}):(l(s,{code:c.invalid_intersection_types}),m)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}X.create=(r,e,t)=>new X({left:r,right:e,typeName:p.ZodIntersection,...y(t)});class E extends v{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==u.array)return l(s,{code:c.invalid_type,expected:u.array,received:s.parsedType}),m;if(s.data.length<this._def.items.length)return l(s,{code:c.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),m;!this._def.rest&&s.data.length>this._def.items.length&&(l(s,{code:c.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...s.data].map((i,o)=>{const f=this._def.items[o]||this._def.rest;return f?f._parse(new O(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(a).then(i=>k.mergeArray(t,i)):k.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new E({...this._def,rest:e})}}E.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new E({items:r,typeName:p.ZodTuple,rest:null,...y(e)})};class Q extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==u.object)return l(s,{code:c.invalid_type,expected:u.object,received:s.parsedType}),m;const n=[],a=this._def.keyType,i=this._def.valueType;for(const o in s.data)n.push({key:a._parse(new O(s,o,s.path,o)),value:i._parse(new O(s,s.data[o],s.path,o))});return s.common.async?k.mergeObjectAsync(t,n):k.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof v?new Q({keyType:e,valueType:t,typeName:p.ZodRecord,...y(s)}):new Q({keyType:T.create(),valueType:e,typeName:p.ZodRecord,...y(t)})}}class de extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==u.map)return l(s,{code:c.invalid_type,expected:u.map,received:s.parsedType}),m;const n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,f],d)=>({key:n._parse(new O(s,o,s.path,[d,"key"])),value:a._parse(new O(s,f,s.path,[d,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const f of i){const d=await f.key,_=await f.value;if(d.status==="aborted"||_.status==="aborted")return m;(d.status==="dirty"||_.status==="dirty")&&t.dirty(),o.set(d.value,_.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const f of i){const d=f.key,_=f.value;if(d.status==="aborted"||_.status==="aborted")return m;(d.status==="dirty"||_.status==="dirty")&&t.dirty(),o.set(d.value,_.value)}return{status:t.value,value:o}}}}de.create=(r,e,t)=>new de({valueType:e,keyType:r,typeName:p.ZodMap,...y(t)});class $ extends v{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==u.set)return l(s,{code:c.invalid_type,expected:u.set,received:s.parsedType}),m;const n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(l(s,{code:c.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(l(s,{code:c.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const a=this._def.valueType;function i(f){const d=new Set;for(const _ of f){if(_.status==="aborted")return m;_.status==="dirty"&&t.dirty(),d.add(_.value)}return{status:t.value,value:d}}const o=[...s.data.values()].map((f,d)=>a._parse(new O(s,f,s.path,d)));return s.common.async?Promise.all(o).then(f=>i(f)):i(o)}min(e,t){return new $({...this._def,minSize:{value:e,message:h.toString(t)}})}max(e,t){return new $({...this._def,maxSize:{value:e,message:h.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}$.create=(r,e)=>new $({valueType:r,minSize:null,maxSize:null,typeName:p.ZodSet,...y(e)});class z extends v{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==u.function)return l(t,{code:c.invalid_type,expected:u.function,received:t.parsedType}),m;function s(o,f){return ae({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ne(),W].filter(d=>!!d),issueData:{code:c.invalid_arguments,argumentsError:f}})}function n(o,f){return ae({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ne(),W].filter(d=>!!d),issueData:{code:c.invalid_return_type,returnTypeError:f}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof B){const o=this;return b(async function(...f){const d=new Z([]),_=await o._def.args.parseAsync(f,a).catch(pe=>{throw d.addIssue(s(f,pe)),d}),w=await Reflect.apply(i,this,_);return await o._def.returns._def.type.parseAsync(w,a).catch(pe=>{throw d.addIssue(n(w,pe)),d})})}else{const o=this;return b(function(...f){const d=o._def.args.safeParse(f,a);if(!d.success)throw new Z([s(f,d.error)]);const _=Reflect.apply(i,this,d.data),w=o._def.returns.safeParse(_,a);if(!w.success)throw new Z([n(_,w.error)]);return w.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new z({...this._def,args:E.create(e).rest(P.create())})}returns(e){return new z({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new z({args:e||E.create([]).rest(P.create()),returns:t||P.create(),typeName:p.ZodFunction,...y(s)})}}class K extends v{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})}}K.create=(r,e)=>new K({getter:r,typeName:p.ZodLazy,...y(e)});class F extends v{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return l(t,{received:t.data,code:c.invalid_literal,expected:this._def.value}),m}return{status:"valid",value:e.data}}get value(){return this._def.value}}F.create=(r,e)=>new F({value:r,typeName:p.ZodLiteral,...y(e)});function Ze(r,e){return new M({values:r,typeName:p.ZodEnum,...y(e)})}class M extends v{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return l(t,{expected:g.joinValues(s),received:t.parsedType,code:c.invalid_type}),m}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),s=this._def.values;return l(t,{received:t.data,code:c.invalid_enum_value,options:s}),m}return b(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){return M.create(e)}exclude(e){return M.create(this.options.filter(t=>!e.includes(t)))}}M.create=Ze;class ee extends v{_parse(e){const t=g.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==u.string&&s.parsedType!==u.number){const n=g.objectValues(t);return l(s,{expected:g.joinValues(n),received:s.parsedType,code:c.invalid_type}),m}if(t.indexOf(e.data)===-1){const n=g.objectValues(t);return l(s,{received:s.data,code:c.invalid_enum_value,options:n}),m}return b(e.data)}get enum(){return this._def.values}}ee.create=(r,e)=>new ee({values:r,typeName:p.ZodNativeEnum,...y(e)});class B extends v{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==u.promise&&t.common.async===!1)return l(t,{code:c.invalid_type,expected:u.promise,received:t.parsedType}),m;const s=t.parsedType===u.promise?t.data:Promise.resolve(t.data);return b(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}B.create=(r,e)=>new B({type:r,typeName:p.ZodPromise,...y(e)});class N extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===p.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{l(s,i),i.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){const i=n.transform(s.data,a);return s.common.issues.length?{status:"dirty",value:s.data}:s.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:s.path,parent:s})):this._def.schema._parseSync({data:i,path:s.path,parent:s})}if(n.type==="refinement"){const i=o=>{const f=n.refinement(o,a);if(s.common.async)return Promise.resolve(f);if(f instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?m:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?m:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!q(i))return i;const o=n.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>q(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);g.assertNever(n)}}N.create=(r,e,t)=>new N({schema:r,typeName:p.ZodEffects,effect:e,...y(t)});N.createWithPreprocess=(r,e,t)=>new N({schema:e,effect:{type:"preprocess",transform:r},typeName:p.ZodEffects,...y(t)});class C extends v{_parse(e){return this._getType(e)===u.undefined?b(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}C.create=(r,e)=>new C({innerType:r,typeName:p.ZodOptional,...y(e)});class L extends v{_parse(e){return this._getType(e)===u.null?b(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}L.create=(r,e)=>new L({innerType:r,typeName:p.ZodNullable,...y(e)});class te extends v{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===u.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}te.create=(r,e)=>new te({innerType:r,typeName:p.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...y(e)});class ue extends v{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return ie(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Z(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Z(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}ue.create=(r,e)=>new ue({innerType:r,typeName:p.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...y(e)});class le extends v{_parse(e){if(this._getType(e)!==u.nan){const s=this._getOrReturnCtx(e);return l(s,{code:c.invalid_type,expected:u.nan,received:s.parsedType}),m}return{status:"valid",value:e.data}}}le.create=r=>new le({typeName:p.ZodNaN,...y(r)});const He=Symbol("zod_brand");class Se extends v{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class re extends v{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?m:a.status==="dirty"?(t.dirty(),Te(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})})();{const n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?m:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,t){return new re({in:e,out:t,typeName:p.ZodPipeline})}}class fe extends v{_parse(e){const t=this._def.innerType._parse(e);return q(t)&&(t.value=Object.freeze(t.value)),t}}fe.create=(r,e)=>new fe({innerType:r,typeName:p.ZodReadonly,...y(e)});const Ne=(r,e={},t)=>r?U.create().superRefine((s,n)=>{var a,i;if(!r(s)){const o=typeof e=="function"?e(s):typeof e=="string"?{message:e}:e,f=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,d=typeof o=="string"?{message:o}:o;n.addIssue({code:"custom",...d,fatal:f})}}):U.create(),Ge={object:x.lazycreate};var p;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(p||(p={}));const Xe=(r,e={message:`Input not instance of ${r.name}`})=>Ne(t=>t instanceof r,e),Oe=T.create,Ee=j.create,Qe=le.create,Ke=A.create,Ce=J.create,Fe=V.create,et=oe.create,tt=Y.create,rt=H.create,st=U.create,nt=P.create,at=I.create,it=ce.create,ot=S.create,ct=x.create,dt=x.strictCreate,ut=G.create,lt=he.create,ft=X.create,ht=E.create,pt=Q.create,mt=de.create,yt=$.create,vt=z.create,_t=K.create,gt=F.create,xt=M.create,kt=ee.create,bt=B.create,be=N.create,wt=C.create,Tt=L.create,Zt=N.createWithPreprocess,St=re.create,Nt=()=>Oe().optional(),Ot=()=>Ee().optional(),Et=()=>Ce().optional(),Ct={string:r=>T.create({...r,coerce:!0}),number:r=>j.create({...r,coerce:!0}),boolean:r=>J.create({...r,coerce:!0}),bigint:r=>A.create({...r,coerce:!0}),date:r=>V.create({...r,coerce:!0})},It=m;var ye=Object.freeze({__proto__:null,defaultErrorMap:W,setErrorMap:Me,getErrorMap:ne,makeIssue:ae,EMPTY_PATH:Pe,addIssueToContext:l,ParseStatus:k,INVALID:m,DIRTY:Te,OK:b,isAborted:_e,isDirty:ge,isValid:q,isAsync:ie,get util(){return g},get objectUtil(){return ve},ZodParsedType:u,getParsedType:R,ZodType:v,ZodString:T,ZodNumber:j,ZodBigInt:A,ZodBoolean:J,ZodDate:V,ZodSymbol:oe,ZodUndefined:Y,ZodNull:H,ZodAny:U,ZodUnknown:P,ZodNever:I,ZodVoid:ce,ZodArray:S,ZodObject:x,ZodUnion:G,ZodDiscriminatedUnion:he,ZodIntersection:X,ZodTuple:E,ZodRecord:Q,ZodMap:de,ZodSet:$,ZodFunction:z,ZodLazy:K,ZodLiteral:F,ZodEnum:M,ZodNativeEnum:ee,ZodPromise:B,ZodEffects:N,ZodTransformer:N,ZodOptional:C,ZodNullable:L,ZodDefault:te,ZodCatch:ue,ZodNaN:le,BRAND:He,ZodBranded:Se,ZodPipeline:re,ZodReadonly:fe,custom:Ne,Schema:v,ZodSchema:v,late:Ge,get ZodFirstPartyTypeKind(){return p},coerce:Ct,any:st,array:ot,bigint:Ke,boolean:Ce,date:Fe,discriminatedUnion:lt,effect:be,enum:xt,function:vt,instanceof:Xe,intersection:ft,lazy:_t,literal:gt,map:mt,nan:Qe,nativeEnum:kt,never:at,null:rt,nullable:Tt,number:Ee,object:ct,oboolean:Et,onumber:Ot,optional:wt,ostring:Nt,pipeline:St,preprocess:Zt,promise:bt,record:pt,set:yt,strictObject:dt,string:Oe,symbol:et,transformer:be,tuple:ht,undefined:tt,union:ut,unknown:nt,void:it,NEVER:It,ZodIssueCode:c,quotelessJson:Ae,ZodError:Z});function Ie(r){return Object.entries(r).reduce((e,[t,s])=>(typeof s=="string"||typeof s>"u"?e[t]=s:"value"in s?e[t]=s.value||void 0:e[t]=Ie(s),e),{})}function Re(r,e){const t=Object.entries(r).reduce((s,[n,a])=>(typeof a=="string"||typeof a>"u"?s[n]=ye.string():"value"in a?(!a.isServerOnly||e)&&(s[n]=a.schema??ye.string()):s[n]=Re(a,e),s),{});return ye.object(t)}function je(r,e,t,s,n){return new Proxy(r,{get(a,i){const o=e[i];if(!o)return;if(typeof o=="string")return o;const f=n?`${n}.${i}`:i;return"value"in o?o.isServerOnly&&!t?s(f):a[i]:je(r[i],e[i],t,s,f)}})}function Rt(r){const e=r.isServer??typeof window>"u",t=r.onValidationError??(o=>{throw new Error(`❌ Invalid environment variables: ${o.issues.map(({path:f,message:d})=>`${f.join(".")}: ${d}`).join(", ")}`)}),s=r.onAccessError??(o=>{throw new Error(`❌ Attempted to access server-side environment variable '${o}' on the client`)}),n=Re(r.values,e),a=Ie(r.values),i=n.safeParse(a);return i.success?je(i.data,r.values,e,s):t(i.error)}exports.createEnvironment=Rt;
@@ -39,17 +39,17 @@ declare type EnvValue = {
39
39
  */
40
40
  schema?: ZodType;
41
41
  /**
42
- * Only make environment variable available to server usages.
42
+ * Only make environment variable available for server-side usage.
43
43
  * @defaultValue false
44
44
  */
45
45
  isServerOnly?: boolean;
46
46
  };
47
47
 
48
48
  declare type EnvValues = {
49
- [key: string]: EnvValue | EnvValues;
49
+ [key: string]: EnvValue | EnvValues | string | undefined;
50
50
  };
51
51
 
52
- declare type UnwrapEnvValue<T> = T extends EnvValue ? T extends Required<Pick<EnvValue, 'schema'>> ? ReturnType<T['schema']['parse']> : string : T extends Record<string, unknown> ? {
52
+ declare type UnwrapEnvValue<T> = T extends string ? string : T extends EnvValue ? T extends Required<Pick<EnvValue, 'schema'>> ? ReturnType<T['schema']['parse']> : string : T extends Record<string, unknown> ? {
53
53
  [TKey in keyof T]: UnwrapEnvValue<T[TKey]>;
54
54
  } : never;
55
55
 
@@ -34,14 +34,14 @@ var g;
34
34
  }
35
35
  r.joinValues = s, r.jsonStringifyReplacer = (n, a) => typeof a == "bigint" ? a.toString() : a;
36
36
  })(g || (g = {}));
37
- var ye;
37
+ var ve;
38
38
  (function(r) {
39
39
  r.mergeShapes = (e, t) => ({
40
40
  ...e,
41
41
  ...t
42
42
  // second overwrites first
43
43
  });
44
- })(ye || (ye = {}));
44
+ })(ve || (ve = {}));
45
45
  const u = g.arrayToEnum([
46
46
  "string",
47
47
  "nan",
@@ -292,7 +292,7 @@ class k {
292
292
  }
293
293
  const m = Object.freeze({
294
294
  status: "aborted"
295
- }), Te = (r) => ({ status: "dirty", value: r }), b = (r) => ({ status: "valid", value: r }), ve = (r) => r.status === "aborted", _e = (r) => r.status === "dirty", q = (r) => r.status === "valid", ie = (r) => typeof Promise < "u" && r instanceof Promise;
295
+ }), Te = (r) => ({ status: "dirty", value: r }), b = (r) => ({ status: "valid", value: r }), _e = (r) => r.status === "aborted", ge = (r) => r.status === "dirty", q = (r) => r.status === "valid", ie = (r) => typeof Promise < "u" && r instanceof Promise;
296
296
  var h;
297
297
  (function(r) {
298
298
  r.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, r.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
@@ -305,7 +305,7 @@ class O {
305
305
  return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
306
306
  }
307
307
  }
308
- const xe = (r, e) => {
308
+ const ke = (r, e) => {
309
309
  if (q(e))
310
310
  return { success: !0, data: e.value };
311
311
  if (!r.common.issues.length)
@@ -391,7 +391,7 @@ class v {
391
391
  data: e,
392
392
  parsedType: R(e)
393
393
  }, a = this._parseSync({ data: e, path: n.path, parent: n });
394
- return xe(n, a);
394
+ return ke(n, a);
395
395
  }
396
396
  async parseAsync(e, t) {
397
397
  const s = await this.safeParseAsync(e, t);
@@ -412,7 +412,7 @@ class v {
412
412
  data: e,
413
413
  parsedType: R(e)
414
414
  }, n = this._parse({ data: e, path: s.path, parent: s }), a = await (ie(n) ? n : Promise.resolve(n));
415
- return xe(s, a);
415
+ return ke(s, a);
416
416
  }
417
417
  refine(e, t) {
418
418
  const s = (n) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(n) : t;
@@ -1838,14 +1838,14 @@ class he extends v {
1838
1838
  });
1839
1839
  }
1840
1840
  }
1841
- function ge(r, e) {
1841
+ function xe(r, e) {
1842
1842
  const t = R(r), s = R(e);
1843
1843
  if (r === e)
1844
1844
  return { valid: !0, data: r };
1845
1845
  if (t === u.object && s === u.object) {
1846
1846
  const n = g.objectKeys(e), a = g.objectKeys(r).filter((o) => n.indexOf(o) !== -1), i = { ...r, ...e };
1847
1847
  for (const o of a) {
1848
- const f = ge(r[o], e[o]);
1848
+ const f = xe(r[o], e[o]);
1849
1849
  if (!f.valid)
1850
1850
  return { valid: !1 };
1851
1851
  i[o] = f.data;
@@ -1856,7 +1856,7 @@ function ge(r, e) {
1856
1856
  return { valid: !1 };
1857
1857
  const n = [];
1858
1858
  for (let a = 0; a < r.length; a++) {
1859
- const i = r[a], o = e[a], f = ge(i, o);
1859
+ const i = r[a], o = e[a], f = xe(i, o);
1860
1860
  if (!f.valid)
1861
1861
  return { valid: !1 };
1862
1862
  n.push(f.data);
@@ -1868,10 +1868,10 @@ function ge(r, e) {
1868
1868
  class X extends v {
1869
1869
  _parse(e) {
1870
1870
  const { status: t, ctx: s } = this._processInputParams(e), n = (a, i) => {
1871
- if (ve(a) || ve(i))
1871
+ if (_e(a) || _e(i))
1872
1872
  return m;
1873
- const o = ge(a.value, i.value);
1874
- return o.valid ? ((_e(a) || _e(i)) && t.dirty(), { status: t.value, value: o.data }) : (l(s, {
1873
+ const o = xe(a.value, i.value);
1874
+ return o.valid ? ((ge(a) || ge(i)) && t.dirty(), { status: t.value, value: o.data }) : (l(s, {
1875
1875
  code: c.invalid_intersection_types
1876
1876
  }), m);
1877
1877
  };
@@ -2617,7 +2617,7 @@ var p;
2617
2617
  })(p || (p = {}));
2618
2618
  const Xe = (r, e = {
2619
2619
  message: `Input not instance of ${r.name}`
2620
- }) => Ne((t) => t instanceof r, e), Oe = T.create, Ee = j.create, Qe = le.create, Ke = A.create, Ce = J.create, Fe = V.create, et = oe.create, tt = Y.create, rt = H.create, st = U.create, nt = P.create, at = I.create, it = ce.create, ot = S.create, ct = x.create, dt = x.strictCreate, ut = G.create, lt = he.create, ft = X.create, ht = E.create, pt = Q.create, mt = de.create, yt = $.create, vt = z.create, _t = K.create, gt = F.create, xt = M.create, kt = ee.create, bt = B.create, ke = N.create, wt = C.create, Tt = L.create, Zt = N.createWithPreprocess, St = re.create, Nt = () => Oe().optional(), Ot = () => Ee().optional(), Et = () => Ce().optional(), Ct = {
2620
+ }) => Ne((t) => t instanceof r, e), Oe = T.create, Ee = j.create, Qe = le.create, Ke = A.create, Ce = J.create, Fe = V.create, et = oe.create, tt = Y.create, rt = H.create, st = U.create, nt = P.create, at = I.create, it = ce.create, ot = S.create, ct = x.create, dt = x.strictCreate, ut = G.create, lt = he.create, ft = X.create, ht = E.create, pt = Q.create, mt = de.create, yt = $.create, vt = z.create, _t = K.create, gt = F.create, xt = M.create, kt = ee.create, bt = B.create, be = N.create, wt = C.create, Tt = L.create, Zt = N.createWithPreprocess, St = re.create, Nt = () => Oe().optional(), Ot = () => Ee().optional(), Et = () => Ce().optional(), Ct = {
2621
2621
  string: (r) => T.create({ ...r, coerce: !0 }),
2622
2622
  number: (r) => j.create({ ...r, coerce: !0 }),
2623
2623
  boolean: (r) => J.create({
@@ -2627,7 +2627,7 @@ const Xe = (r, e = {
2627
2627
  bigint: (r) => A.create({ ...r, coerce: !0 }),
2628
2628
  date: (r) => V.create({ ...r, coerce: !0 })
2629
2629
  }, It = m;
2630
- var be = /* @__PURE__ */ Object.freeze({
2630
+ var ye = /* @__PURE__ */ Object.freeze({
2631
2631
  __proto__: null,
2632
2632
  defaultErrorMap: W,
2633
2633
  setErrorMap: Me,
@@ -2639,15 +2639,15 @@ var be = /* @__PURE__ */ Object.freeze({
2639
2639
  INVALID: m,
2640
2640
  DIRTY: Te,
2641
2641
  OK: b,
2642
- isAborted: ve,
2643
- isDirty: _e,
2642
+ isAborted: _e,
2643
+ isDirty: ge,
2644
2644
  isValid: q,
2645
2645
  isAsync: ie,
2646
2646
  get util() {
2647
2647
  return g;
2648
2648
  },
2649
2649
  get objectUtil() {
2650
- return ye;
2650
+ return ve;
2651
2651
  },
2652
2652
  ZodParsedType: u,
2653
2653
  getParsedType: R,
@@ -2704,7 +2704,7 @@ var be = /* @__PURE__ */ Object.freeze({
2704
2704
  boolean: Ce,
2705
2705
  date: Fe,
2706
2706
  discriminatedUnion: lt,
2707
- effect: ke,
2707
+ effect: be,
2708
2708
  enum: xt,
2709
2709
  function: vt,
2710
2710
  instanceof: Xe,
@@ -2731,7 +2731,7 @@ var be = /* @__PURE__ */ Object.freeze({
2731
2731
  strictObject: dt,
2732
2732
  string: Oe,
2733
2733
  symbol: et,
2734
- transformer: ke,
2734
+ transformer: be,
2735
2735
  tuple: ht,
2736
2736
  undefined: tt,
2737
2737
  union: ut,
@@ -2744,16 +2744,16 @@ var be = /* @__PURE__ */ Object.freeze({
2744
2744
  });
2745
2745
  function Ie(r) {
2746
2746
  return Object.entries(r).reduce(
2747
- (e, [t, s]) => ("value" in s ? e[t] = s.value || void 0 : e[t] = Ie(s), e),
2747
+ (e, [t, s]) => (typeof s == "string" || typeof s > "u" ? e[t] = s : "value" in s ? e[t] = s.value || void 0 : e[t] = Ie(s), e),
2748
2748
  {}
2749
2749
  );
2750
2750
  }
2751
2751
  function Re(r, e) {
2752
2752
  const t = Object.entries(r).reduce(
2753
- (s, [n, a]) => ("value" in a ? (!a.isServerOnly || e) && (s[n] = a.schema ?? be.string()) : s[n] = Re(a, e), s),
2753
+ (s, [n, a]) => (typeof a == "string" || typeof a > "u" ? s[n] = ye.string() : "value" in a ? (!a.isServerOnly || e) && (s[n] = a.schema ?? ye.string()) : s[n] = Re(a, e), s),
2754
2754
  {}
2755
2755
  );
2756
- return be.object(t);
2756
+ return ye.object(t);
2757
2757
  }
2758
2758
  function je(r, e, t, s, n) {
2759
2759
  return new Proxy(r, {
@@ -2761,6 +2761,8 @@ function je(r, e, t, s, n) {
2761
2761
  const o = e[i];
2762
2762
  if (!o)
2763
2763
  return;
2764
+ if (typeof o == "string")
2765
+ return o;
2764
2766
  const f = n ? `${n}.${i}` : i;
2765
2767
  return "value" in o ? o.isServerOnly && !t ? s(f) : a[i] : je(
2766
2768
  r[i],
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Quintal Web Solutions
3
+ Copyright (c) 2024 Quintal Web Solutions
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,6 +1,42 @@
1
- # @quintal/environment
1
+ <!--
2
+ THIS FILE IS (PARTIALLY) AUTO-GENERATED USING `pnpm generate`.
3
+ TO EDIT THE CONTENT, PLEASE MODIFY `/workspace.ts` OR `/scripts/generate.ts`
4
+ -->
2
5
 
3
- Type-safe environment variable validation
6
+ # Quintal Environment
7
+
8
+ [![NPM version](https://img.shields.io/npm/v/@quintal/environment?style=flat-square)](https://npmjs.com/@quintal/environment)
9
+ [![NPM downloads](https://img.shields.io/npm/dt/@quintal/environment?style=flat-square)](https://npmjs.com/@quintal/environment)
10
+ [![License](https://img.shields.io/npm/l/@quintal/environment?style=flat-square)](https://github.com/quintalwebsolutions/quintal-oss/blob/main/LICENSE)
11
+ [![Bundle size](https://img.shields.io/bundlephobia/minzip/@quintal/environment?style=flat-square)](https://bundlephobia.com/package/@quintal/environment)
12
+ [![Dependencies](https://img.shields.io/librariesio/release/npm/@quintal/environment?style=flat-square)](https://libraries.io/npm/%40quintal%2Fenvironment/)
13
+ [![Code coverage](https://img.shields.io/codecov/c/github/quintalwebsolutions/quintal-oss?style=flat-square&token=3ORY9UP6H7&flag=environment&logo=codecov)](https://codecov.io/gh/quintalwebsolutions/quintal-oss)
14
+ [![Pull requests welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/quintalwebsolutions/quintal-oss/blob/main/CONTRIBUTING.md)
15
+
16
+ Framework-agnostic environment variable validation for TypeScript
17
+
18
+ You can explore [the exposed functions and types on ts-docs](https://tsdocs.dev/docs/@quintal/environment)
19
+
20
+ ## Table of Contents
21
+
22
+ - [Getting Started](#getting-started)
23
+ - [Kitchen Sink Example](#kitchen-sink-example)
24
+
25
+ ## Getting Started
26
+
27
+ ```sh
28
+ pnpm add @quintal/environment
29
+ # or
30
+ bun add @quintal/environment
31
+ # or
32
+ yarn add @quintal/environment
33
+ # or
34
+ npm install @quintal/environment
35
+ ```
36
+
37
+ <!-- END AUTO-GENERATED: Add custom documentation after this comment -->
38
+
39
+ ## Kitchen Sink Example
4
40
 
5
41
  ```ts
6
42
  export const environment = createEnvironment({
@@ -16,6 +52,7 @@ export const environment = createEnvironment({
16
52
  schema: z.coerce.number().int().default(4000),
17
53
  isServerOnly: true,
18
54
  },
55
+ simpleStringValue: process.env.SIMPLE_STRING_VALUE,
19
56
  isFeatureEnabled: {
20
57
  value: process.env.IS_FEATURE_ENABLED,
21
58
  schema: z.enum(['true', 'false']).transform((s) => s === 'true'),
@@ -48,7 +85,7 @@ export const environment = createEnvironment({
48
85
  Every environment variable is defined as an object with the following properties
49
86
 
50
87
  ```ts
51
- type EnvVariableDefinition = {
88
+ type EnvValue = {
52
89
  /**
53
90
  * The value
54
91
  * @example process.env.NODE_ENV
@@ -62,7 +99,7 @@ type EnvVariableDefinition = {
62
99
  */
63
100
  schema?: ZodType;
64
101
  /**
65
- * Only make environment variable available to server usages.
102
+ * Only make environment variable available for server-side usage.
66
103
  * @defaultValue false
67
104
  */
68
105
  isServerOnly?: boolean;
package/package.json CHANGED
@@ -1,32 +1,58 @@
1
1
  {
2
2
  "name": "@quintal/environment",
3
- "version": "0.1.0",
4
- "main": "./dist/index.cjs",
5
- "module": "./dist/index.mjs",
6
- "types": "./dist/index.d.ts",
3
+ "version": "0.2.0",
4
+ "license": "MIT",
5
+ "description": "Framework-agnostic environment variable validation for TypeScript",
6
+ "keywords": [
7
+ "environment",
8
+ "validation",
9
+ "typescript",
10
+ "zod"
11
+ ],
12
+ "author": {
13
+ "name": "William Ford",
14
+ "email": "william@quintalwebsolutions.com",
15
+ "url": "https://quintalwebsolutions.com"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/quintalwebsolutions/quintal-oss.git",
20
+ "directory": "packages/environment"
21
+ },
22
+ "homepage": "https://github.com/quintalwebsolutions/quintal-oss/tree/main/packages/environment#readme",
23
+ "bugs": "https://github.com/quintalwebsolutions/quintal-oss/labels/%40quintal%2Fenvironment",
24
+ "main": "./.dist/index.cjs",
25
+ "module": "./.dist/index.mjs",
26
+ "types": "./.dist/index.d.ts",
27
+ "files": [
28
+ ".dist"
29
+ ],
7
30
  "peerDependencies": {
8
31
  "zod": "^3.22.4"
9
32
  },
10
33
  "devDependencies": {
11
- "@types/node": "20.10.2",
12
- "@vitest/coverage-v8": "0.34.6",
13
- "happy-dom": "12.10.3",
14
- "typescript": "5.3.2",
15
- "vite": "5.0.4",
16
- "vitest": "0.34.6",
34
+ "@types/node": "20.11.24",
35
+ "@vitest/coverage-v8": "1.3.1",
36
+ "happy-dom": "13.6.2",
37
+ "typescript": "5.3.3",
38
+ "typescript-coverage-report": "1.0.0",
39
+ "vite": "5.1.4",
40
+ "vitest": "1.3.1",
17
41
  "zod": "3.22.4",
18
42
  "@quintal/config": "0.2.0"
19
43
  },
20
44
  "scripts": {
21
45
  "build": "run-s build:*",
22
- "build:clean": "shx rm -rf dist",
46
+ "build:clean": "shx rm -rf .dist",
23
47
  "build:code": "vite build",
24
- "clean": "shx rm -rf .coverage .coverage-ts .turbo dist node_modules",
48
+ "clean": "shx rm -rf .coverage .coverage-ts .dist .turbo node_modules",
25
49
  "dev": "vitest --watch",
26
50
  "lint": "pnpm lint:fix && pnpm lint:types",
27
- "lint:check": "eslint .",
28
- "lint:fix": "pnpm lint:check --fix",
29
- "lint:types": "tsc",
30
- "test": "vitest"
51
+ "lint:check": "biome ci .",
52
+ "lint:fix": "biome check --apply .",
53
+ "lint:types": "tsc --noEmit",
54
+ "test": "run-s test:*",
55
+ "test:source": "vitest",
56
+ "test:types": "typescript-coverage-report --outputDir .coverage-ts --strict"
31
57
  }
32
58
  }