@authhero/cloudflare-adapter 1.4.0 → 1.5.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";var ot=Object.defineProperty;var dt=(r,e,t)=>e in r?ot(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var Ve=(r,e,t)=>dt(r,typeof e!="symbol"?e+"":e,t);const ct=require("@authhero/adapter-interfaces"),ut=require("wretch");function lt(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t}function ft(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function ne(r,e){const t=r.ZodType.prototype[e];r.ZodType.prototype[e]=function(...n){const s=t.apply(this,n);return s._def.openapi=this._def.openapi,s}}function ht(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(s,a){var i,o,d,c,p,k;const O=typeof s=="string"?a:s,w=O??{},{param:P}=w,Ne=lt(w,["param"]),$=Object.assign(Object.assign({},(i=this._def.openapi)===null||i===void 0?void 0:i._internal),typeof s=="string"?{refId:s}:void 0),be=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),Ne),!((c=(d=this._def.openapi)===null||d===void 0?void 0:d.metadata)===null||c===void 0)&&c.param||P?{param:Object.assign(Object.assign({},(k=(p=this._def.openapi)===null||p===void 0?void 0:p.metadata)===null||k===void 0?void 0:k.param),P)}:void 0),B=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys($).length>0?{_internal:$}:void 0),Object.keys(be).length>0?{metadata:be}:void 0)}));if(ft(this,"ZodObject")){const te=this.extend;B.extend=function(...re){var Re,Ie,Ae,Me,Pe,$e;const De=te.apply(this,re);return De._def.openapi={_internal:{extendedFrom:!((Ie=(Re=this._def.openapi)===null||Re===void 0?void 0:Re._internal)===null||Ie===void 0)&&Ie.refId?{refId:(Me=(Ae=this._def.openapi)===null||Ae===void 0?void 0:Ae._internal)===null||Me===void 0?void 0:Me.refId,schema:this}:(Pe=this._def.openapi)===null||Pe===void 0?void 0:Pe._internal.extendedFrom},metadata:($e=De._def.openapi)===null||$e===void 0?void 0:$e.metadata},De}}return B},ne(r,"optional"),ne(r,"nullable"),ne(r,"default"),ne(r,"transform"),ne(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),a=e.apply(this),i=a._def.shape();return Object.entries(i).forEach(([o,d])=>{var c,p;d._def.openapi=(p=(c=s[o])===null||c===void 0?void 0:c._def)===null||p===void 0?void 0:p.openapi}),a._def.openapi=void 0,a};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...s){const a=t.apply(this,s);return a._def.openapi=void 0,a};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...s){const a=n.apply(this,s);return a._def.openapi=void 0,a}}var H=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});Ve(this,"res");Ve(this,"status");this.res=t==null?void 0:t.res,this.status=e}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}};new Set(".\\+*[^]$()");var x;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},r.getValidEnumValues=s=>{const a=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return r.objectValues(i)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},r.find=(s,a)=>{for(const i of s)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(x||(x={}));var Be;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Be||(Be={}));const f=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),D=r=>{switch(typeof r){case"undefined":return f.undefined;case"string":return f.string;case"number":return isNaN(r)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(r)?f.array:r===null?f.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?f.promise:typeof Map<"u"&&r instanceof Map?f.map:typeof Set<"u"&&r instanceof Set?f.set:typeof Date<"u"&&r instanceof Date?f.date:f.object;default:return f.unknown}},u=x.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),pt=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class S extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};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},n={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,d=0;for(;d<i.path.length;){const c=i.path[d];d===i.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(t(i))):o[c]=o[c]||{_errors:[]},o=o[c],d++}}};return s(this),n}static assert(e){if(!(e instanceof S))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}S.create=r=>new S(r);const Q=(r,e)=>{let t;switch(r.code){case u.invalid_type:r.received===f.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case u.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,x.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:t=`Unrecognized key(s) in object: ${x.joinValues(r.keys,", ")}`;break;case u.invalid_union:t="Invalid input";break;case u.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${x.joinValues(r.options)}`;break;case u.invalid_enum_value:t=`Invalid enum value. Expected ${x.joinValues(r.options)}, received '${r.received}'`;break;case u.invalid_arguments:t="Invalid function arguments";break;case u.invalid_return_type:t="Invalid function return type";break;case u.invalid_date:t="Invalid date";break;case u.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:x.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case u.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case u.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case u.custom:t="Invalid input";break;case u.invalid_intersection_types:t="Intersection results could not be merged";break;case u.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case u.not_finite:t="Number must be finite";break;default:t=e.defaultError,x.assertNever(r)}return{message:t}};let Xe=Q;function mt(r){Xe=r}function ke(){return Xe}const we=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="";const d=n.filter(c=>!!c).slice().reverse();for(const c of d)o=c(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}},_t=[];function l(r,e){const t=ke(),n=we({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Q?void 0:Q].filter(s=>!!s)});r.common.issues.push(n)}class T{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return y;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const a=await s.key,i=await s.value;n.push({key:a,value:i})}return T.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return y;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const y=Object.freeze({status:"aborted"}),X=r=>({status:"dirty",value:r}),Z=r=>({status:"valid",value:r}),We=r=>r.status==="aborted",qe=r=>r.status==="dirty",ie=r=>r.status==="valid",oe=r=>typeof Promise<"u"&&r instanceof Promise;function Te(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function Ke(r,e,t,n,s){if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var m;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(m||(m={}));var se,ae;class R{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Ye=(r,e)=>{if(ie(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 S(r.common.issues);return this._error=t,this._error}}};function v(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,o)=>{var d,c;const{message:p}=r;return i.code==="invalid_enum_value"?{message:p??o.defaultError}:typeof o.data>"u"?{message:(d=p??n)!==null&&d!==void 0?d:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(c=p??t)!==null&&c!==void 0?c:o.defaultError}},description:s}}class g{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 D(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:D(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new T,ctx:{common:e.parent.common,data:e.data,parsedType:D(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(oe(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 n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:D(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Ye(s,a)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={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:D(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(oe(s)?s:Promise.resolve(s));return Ye(n,a)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:u.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(d=>d?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new C({schema:this,typeName:_.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return N.create(this,this._def)}nullable(){return z.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return E.create(this,this._def)}promise(){return ee.create(this,this._def)}or(e){return le.create([this,e],this._def)}and(e){return fe.create(this,e,this._def)}transform(e){return new C({...v(this._def),schema:this,typeName:_.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ye({...v(this._def),innerType:this,defaultValue:t,typeName:_.ZodDefault})}brand(){return new He({typeName:_.ZodBranded,type:this,...v(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ve({...v(this._def),innerType:this,catchValue:t,typeName:_.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return xe.create(this,e)}readonly(){return ge.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const yt=/^c[^\s-]{8,}$/i,vt=/^[0-9a-z]+$/,gt=/^[0-9A-HJKMNP-TV-Z]{26}$/,xt=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,bt=/^[a-z0-9_-]{21}$/i,kt=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,wt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Tt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Le;const Zt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,St=/^(([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})))$/,Ot=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Qe="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",jt=new RegExp(`^${Qe}$`);function Fe(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Et(r){return new RegExp(`^${Fe(r)}$`)}function et(r){let e=`${Qe}T${Fe(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Ct(r,e){return!!((e==="v4"||!e)&&Zt.test(r)||(e==="v6"||!e)&&St.test(r))}class j extends g{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){const a=this._getOrReturnCtx(e);return l(a,{code:u.invalid_type,expected:f.string,received:a.parsedType}),y}const n=new T;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:u.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:u.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?l(s,{code:u.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&l(s,{code:u.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")wt.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"email",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")Le||(Le=new RegExp(Tt,"u")),Le.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"emoji",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")xt.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"uuid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")bt.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"nanoid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")yt.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"cuid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")vt.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"cuid2",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")gt.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"ulid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),l(s,{validation:"url",code:u.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"regex",code:u.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),l(s,{code:u.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.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)||(s=this._getOrReturnCtx(e,s),l(s,{code:u.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),l(s,{code:u.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?et(a).test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:u.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?jt.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:u.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Et(a).test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:u.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?kt.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"duration",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Ct(e.data,a.version)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"ip",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Ot.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"base64",code:u.invalid_string,message:a.message}),n.dirty()):x.assertNever(a);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:u.invalid_string,...m.errToObj(n)})}_addCheck(e){return new j({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...m.errToObj(e)})}url(e){return this._addCheck({kind:"url",...m.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...m.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...m.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...m.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...m.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...m.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...m.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...m.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...m.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...m.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...m.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...m.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...m.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...m.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...m.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...m.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...m.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...m.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...m.errToObj(t)})}nonempty(e){return this.min(1,m.errToObj(e))}trim(){return new j({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new j({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new j({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}j.create=r=>{var e;return new j({checks:[],typeName:_.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...v(r)})};function Nt(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=parseInt(r.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}class V extends g{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){const a=this._getOrReturnCtx(e);return l(a,{code:u.invalid_type,expected:f.number,received:a.parsedType}),y}let n;const s=new T;for(const a of this._def.checks)a.kind==="int"?x.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:u.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),l(n,{code:u.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),l(n,{code:u.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Nt(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),l(n,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:u.not_finite,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,n,s){return new V({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:m.toString(s)}]})}_addCheck(e){return new V({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:m.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:m.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:m.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:m.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"&&x.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}V.create=r=>new V({checks:[],typeName:_.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...v(r)});class L extends g{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)!==f.bigint){const a=this._getOrReturnCtx(e);return l(a,{code:u.invalid_type,expected:f.bigint,received:a.parsedType}),y}let n;const s=new T;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),l(n,{code:u.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),l(n,{code:u.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),l(n,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,n,s){return new L({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:m.toString(s)}]})}_addCheck(e){return new L({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}L.create=r=>{var e;return new L({checks:[],typeName:_.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...v(r)})};class de extends g{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:f.boolean,received:n.parsedType}),y}return Z(e.data)}}de.create=r=>new de({typeName:_.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...v(r)});class q extends g{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){const a=this._getOrReturnCtx(e);return l(a,{code:u.invalid_type,expected:f.date,received:a.parsedType}),y}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return l(a,{code:u.invalid_date}),y}const n=new T;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:u.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:u.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):x.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new q({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:m.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:m.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}q.create=r=>new q({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:_.ZodDate,...v(r)});class Ze extends g{_parse(e){if(this._getType(e)!==f.symbol){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:f.symbol,received:n.parsedType}),y}return Z(e.data)}}Ze.create=r=>new Ze({typeName:_.ZodSymbol,...v(r)});class ce extends g{_parse(e){if(this._getType(e)!==f.undefined){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:f.undefined,received:n.parsedType}),y}return Z(e.data)}}ce.create=r=>new ce({typeName:_.ZodUndefined,...v(r)});class ue extends g{_parse(e){if(this._getType(e)!==f.null){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:f.null,received:n.parsedType}),y}return Z(e.data)}}ue.create=r=>new ue({typeName:_.ZodNull,...v(r)});class F extends g{constructor(){super(...arguments),this._any=!0}_parse(e){return Z(e.data)}}F.create=r=>new F({typeName:_.ZodAny,...v(r)});class W extends g{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Z(e.data)}}W.create=r=>new W({typeName:_.ZodUnknown,...v(r)});class M extends g{_parse(e){const t=this._getOrReturnCtx(e);return l(t,{code:u.invalid_type,expected:f.never,received:t.parsedType}),y}}M.create=r=>new M({typeName:_.ZodNever,...v(r)});class Se extends g{_parse(e){if(this._getType(e)!==f.undefined){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:f.void,received:n.parsedType}),y}return Z(e.data)}}Se.create=r=>new Se({typeName:_.ZodVoid,...v(r)});class E extends g{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==f.array)return l(t,{code:u.invalid_type,expected:f.array,received:t.parsedType}),y;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(l(t,{code:i?u.too_big:u.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(l(t,{code:u.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(l(t,{code:u.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new R(t,i,t.path,o)))).then(i=>T.mergeArray(n,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new R(t,i,t.path,o)));return T.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new E({...this._def,minLength:{value:e,message:m.toString(t)}})}max(e,t){return new E({...this._def,maxLength:{value:e,message:m.toString(t)}})}length(e,t){return new E({...this._def,exactLength:{value:e,message:m.toString(t)}})}nonempty(e){return this.min(1,e)}}E.create=(r,e)=>new E({type:r,minLength:null,maxLength:null,exactLength:null,typeName:_.ZodArray,...v(e)});function G(r){if(r instanceof b){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=N.create(G(n))}return new b({...r._def,shape:()=>e})}else return r instanceof E?new E({...r._def,type:G(r.element)}):r instanceof N?N.create(G(r.unwrap())):r instanceof z?z.create(G(r.unwrap())):r instanceof I?I.create(r.items.map(e=>G(e))):r}class b extends g{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=x.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==f.object){const c=this._getOrReturnCtx(e);return l(c,{code:u.invalid_type,expected:f.object,received:c.parsedType}),y}const{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof M&&this._def.unknownKeys==="strip"))for(const c in s.data)i.includes(c)||o.push(c);const d=[];for(const c of i){const p=a[c],k=s.data[c];d.push({key:{status:"valid",value:c},value:p._parse(new R(s,k,s.path,c)),alwaysSet:c in s.data})}if(this._def.catchall instanceof M){const c=this._def.unknownKeys;if(c==="passthrough")for(const p of o)d.push({key:{status:"valid",value:p},value:{status:"valid",value:s.data[p]}});else if(c==="strict")o.length>0&&(l(s,{code:u.unrecognized_keys,keys:o}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const p of o){const k=s.data[p];d.push({key:{status:"valid",value:p},value:c._parse(new R(s,k,s.path,p)),alwaysSet:p in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const c=[];for(const p of d){const k=await p.key,O=await p.value;c.push({key:k,value:O,alwaysSet:p.alwaysSet})}return c}).then(c=>T.mergeObjectSync(n,c)):T.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return m.errToObj,new b({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,a,i,o;const d=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=m.errToObj(e).message)!==null&&o!==void 0?o:d}:{message:d}}}:{}})}strip(){return new b({...this._def,unknownKeys:"strip"})}passthrough(){return new b({...this._def,unknownKeys:"passthrough"})}extend(e){return new b({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new b({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:_.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new b({...this._def,catchall:e})}pick(e){const t={};return x.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new b({...this._def,shape:()=>t})}omit(e){const t={};return x.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new b({...this._def,shape:()=>t})}deepPartial(){return G(this)}partial(e){const t={};return x.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new b({...this._def,shape:()=>t})}required(e){const t={};return x.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof N;)a=a._def.innerType;t[n]=a}}),new b({...this._def,shape:()=>t})}keyof(){return tt(x.objectKeys(this.shape))}}b.create=(r,e)=>new b({shape:()=>r,unknownKeys:"strip",catchall:M.create(),typeName:_.ZodObject,...v(e)});b.strictCreate=(r,e)=>new b({shape:()=>r,unknownKeys:"strict",catchall:M.create(),typeName:_.ZodObject,...v(e)});b.lazycreate=(r,e)=>new b({shape:r,unknownKeys:"strip",catchall:M.create(),typeName:_.ZodObject,...v(e)});class le extends g{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(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 S(o.ctx.common.issues));return l(t,{code:u.invalid_union,unionErrors:i}),y}if(t.common.async)return Promise.all(n.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(s);{let a;const i=[];for(const d of n){const c={...t,common:{...t.common,issues:[]},parent:null},p=d._parseSync({data:t.data,path:t.path,parent:c});if(p.status==="valid")return p;p.status==="dirty"&&!a&&(a={result:p,ctx:c}),c.common.issues.length&&i.push(c.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(d=>new S(d));return l(t,{code:u.invalid_union,unionErrors:o}),y}}get options(){return this._def.options}}le.create=(r,e)=>new le({options:r,typeName:_.ZodUnion,...v(e)});const A=r=>r instanceof pe?A(r.schema):r instanceof C?A(r.innerType()):r instanceof me?[r.value]:r instanceof U?r.options:r instanceof _e?x.objectValues(r.enum):r instanceof ye?A(r._def.innerType):r instanceof ce?[void 0]:r instanceof ue?[null]:r instanceof N?[void 0,...A(r.unwrap())]:r instanceof z?[null,...A(r.unwrap())]:r instanceof He||r instanceof ge?A(r.unwrap()):r instanceof ve?A(r._def.innerType):[];class Ce extends g{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return l(t,{code:u.invalid_type,expected:f.object,received:t.parsedType}),y;const n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);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:u.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const a of t){const i=A(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new Ce({typeName:_.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...v(n)})}}function Je(r,e){const t=D(r),n=D(e);if(r===e)return{valid:!0,data:r};if(t===f.object&&n===f.object){const s=x.objectKeys(e),a=x.objectKeys(r).filter(o=>s.indexOf(o)!==-1),i={...r,...e};for(const o of a){const d=Je(r[o],e[o]);if(!d.valid)return{valid:!1};i[o]=d.data}return{valid:!0,data:i}}else if(t===f.array&&n===f.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],d=Je(i,o);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return t===f.date&&n===f.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class fe extends g{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(We(a)||We(i))return y;const o=Je(a.value,i.value);return o.valid?((qe(a)||qe(i))&&t.dirty(),{status:t.value,value:o.data}):(l(n,{code:u.invalid_intersection_types}),y)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}fe.create=(r,e,t)=>new fe({left:r,right:e,typeName:_.ZodIntersection,...v(t)});class I extends g{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.array)return l(n,{code:u.invalid_type,expected:f.array,received:n.parsedType}),y;if(n.data.length<this._def.items.length)return l(n,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;!this._def.rest&&n.data.length>this._def.items.length&&(l(n,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...n.data].map((i,o)=>{const d=this._def.items[o]||this._def.rest;return d?d._parse(new R(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>T.mergeArray(t,i)):T.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new I({...this._def,rest:e})}}I.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new I({items:r,typeName:_.ZodTuple,rest:null,...v(e)})};class he extends g{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.object)return l(n,{code:u.invalid_type,expected:f.object,received:n.parsedType}),y;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:a._parse(new R(n,o,n.path,o)),value:i._parse(new R(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?T.mergeObjectAsync(t,s):T.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof g?new he({keyType:e,valueType:t,typeName:_.ZodRecord,...v(n)}):new he({keyType:j.create(),valueType:e,typeName:_.ZodRecord,...v(t)})}}class Oe extends g{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.map)return l(n,{code:u.invalid_type,expected:f.map,received:n.parsedType}),y;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,d],c)=>({key:s._parse(new R(n,o,n.path,[c,"key"])),value:a._parse(new R(n,d,n.path,[c,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const d of i){const c=await d.key,p=await d.value;if(c.status==="aborted"||p.status==="aborted")return y;(c.status==="dirty"||p.status==="dirty")&&t.dirty(),o.set(c.value,p.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const d of i){const c=d.key,p=d.value;if(c.status==="aborted"||p.status==="aborted")return y;(c.status==="dirty"||p.status==="dirty")&&t.dirty(),o.set(c.value,p.value)}return{status:t.value,value:o}}}}Oe.create=(r,e,t)=>new Oe({valueType:e,keyType:r,typeName:_.ZodMap,...v(t)});class J extends g{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.set)return l(n,{code:u.invalid_type,expected:f.set,received:n.parsedType}),y;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(l(n,{code:u.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(l(n,{code:u.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(d){const c=new Set;for(const p of d){if(p.status==="aborted")return y;p.status==="dirty"&&t.dirty(),c.add(p.value)}return{status:t.value,value:c}}const o=[...n.data.values()].map((d,c)=>a._parse(new R(n,d,n.path,c)));return n.common.async?Promise.all(o).then(d=>i(d)):i(o)}min(e,t){return new J({...this._def,minSize:{value:e,message:m.toString(t)}})}max(e,t){return new J({...this._def,maxSize:{value:e,message:m.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}J.create=(r,e)=>new J({valueType:r,minSize:null,maxSize:null,typeName:_.ZodSet,...v(e)});class K extends g{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return l(t,{code:u.invalid_type,expected:f.function,received:t.parsedType}),y;function n(o,d){return we({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ke(),Q].filter(c=>!!c),issueData:{code:u.invalid_arguments,argumentsError:d}})}function s(o,d){return we({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ke(),Q].filter(c=>!!c),issueData:{code:u.invalid_return_type,returnTypeError:d}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof ee){const o=this;return Z(async function(...d){const c=new S([]),p=await o._def.args.parseAsync(d,a).catch(w=>{throw c.addIssue(n(d,w)),c}),k=await Reflect.apply(i,this,p);return await o._def.returns._def.type.parseAsync(k,a).catch(w=>{throw c.addIssue(s(k,w)),c})})}else{const o=this;return Z(function(...d){const c=o._def.args.safeParse(d,a);if(!c.success)throw new S([n(d,c.error)]);const p=Reflect.apply(i,this,c.data),k=o._def.returns.safeParse(p,a);if(!k.success)throw new S([s(p,k.error)]);return k.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new K({...this._def,args:I.create(e).rest(W.create())})}returns(e){return new K({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new K({args:e||I.create([]).rest(W.create()),returns:t||W.create(),typeName:_.ZodFunction,...v(n)})}}class pe extends g{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})}}pe.create=(r,e)=>new pe({getter:r,typeName:_.ZodLazy,...v(e)});class me extends g{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return l(t,{received:t.data,code:u.invalid_literal,expected:this._def.value}),y}return{status:"valid",value:e.data}}get value(){return this._def.value}}me.create=(r,e)=>new me({value:r,typeName:_.ZodLiteral,...v(e)});function tt(r,e){return new U({values:r,typeName:_.ZodEnum,...v(e)})}class U extends g{constructor(){super(...arguments),se.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return l(t,{expected:x.joinValues(n),received:t.parsedType,code:u.invalid_type}),y}if(Te(this,se)||Ke(this,se,new Set(this._def.values)),!Te(this,se).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return l(t,{received:t.data,code:u.invalid_enum_value,options:n}),y}return Z(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return U.create(e,{...this._def,...t})}exclude(e,t=this._def){return U.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}se=new WeakMap;U.create=tt;class _e extends g{constructor(){super(...arguments),ae.set(this,void 0)}_parse(e){const t=x.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==f.string&&n.parsedType!==f.number){const s=x.objectValues(t);return l(n,{expected:x.joinValues(s),received:n.parsedType,code:u.invalid_type}),y}if(Te(this,ae)||Ke(this,ae,new Set(x.getValidEnumValues(this._def.values))),!Te(this,ae).has(e.data)){const s=x.objectValues(t);return l(n,{received:n.data,code:u.invalid_enum_value,options:s}),y}return Z(e.data)}get enum(){return this._def.values}}ae=new WeakMap;_e.create=(r,e)=>new _e({values:r,typeName:_.ZodNativeEnum,...v(e)});class ee extends g{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return l(t,{code:u.invalid_type,expected:f.promise,received:t.parsedType}),y;const n=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return Z(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ee.create=(r,e)=>new ee({type:r,typeName:_.ZodPromise,...v(e)});class C extends g{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===_.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{l(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(n.data,a);if(n.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return y;const d=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return d.status==="aborted"?y:d.status==="dirty"||t.value==="dirty"?X(d.value):d});{if(t.value==="aborted")return y;const o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?y:o.status==="dirty"||t.value==="dirty"?X(o.value):o}}if(s.type==="refinement"){const i=o=>{const d=s.refinement(o,a);if(n.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?y:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?y:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ie(i))return i;const o=s.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:n.data,path:n.path,parent:n}).then(i=>ie(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);x.assertNever(s)}}C.create=(r,e,t)=>new C({schema:r,typeName:_.ZodEffects,effect:e,...v(t)});C.createWithPreprocess=(r,e,t)=>new C({schema:e,effect:{type:"preprocess",transform:r},typeName:_.ZodEffects,...v(t)});class N extends g{_parse(e){return this._getType(e)===f.undefined?Z(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}N.create=(r,e)=>new N({innerType:r,typeName:_.ZodOptional,...v(e)});class z extends g{_parse(e){return this._getType(e)===f.null?Z(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}z.create=(r,e)=>new z({innerType:r,typeName:_.ZodNullable,...v(e)});class ye extends g{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===f.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ye.create=(r,e)=>new ye({innerType:r,typeName:_.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...v(e)});class ve extends g{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return oe(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new S(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new S(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ve.create=(r,e)=>new ve({innerType:r,typeName:_.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...v(e)});class je extends g{_parse(e){if(this._getType(e)!==f.nan){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:f.nan,received:n.parsedType}),y}return{status:"valid",value:e.data}}}je.create=r=>new je({typeName:_.ZodNaN,...v(r)});const Rt=Symbol("zod_brand");class He extends g{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class xe extends g{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?y:a.status==="dirty"?(t.dirty(),X(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?y:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new xe({in:e,out:t,typeName:_.ZodPipeline})}}class ge extends g{_parse(e){const t=this._def.innerType._parse(e),n=s=>(ie(s)&&(s.value=Object.freeze(s.value)),s);return oe(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}ge.create=(r,e)=>new ge({innerType:r,typeName:_.ZodReadonly,...v(e)});function rt(r,e={},t){return r?F.create().superRefine((n,s)=>{var a,i;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,d=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,c=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...c,fatal:d})}}):F.create()}const It={object:b.lazycreate};var _;(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"})(_||(_={}));const At=(r,e={message:`Input not instance of ${r.name}`})=>rt(t=>t instanceof r,e),nt=j.create,st=V.create,Mt=je.create,Pt=L.create,at=de.create,$t=q.create,Dt=Ze.create,Vt=ce.create,Lt=ue.create,Ut=F.create,zt=W.create,Bt=M.create,Wt=Se.create,qt=E.create,Jt=b.create,Ht=b.strictCreate,Yt=le.create,Gt=Ce.create,Xt=fe.create,Kt=I.create,Qt=he.create,Ft=Oe.create,er=J.create,tr=K.create,rr=pe.create,nr=me.create,sr=U.create,ar=_e.create,ir=ee.create,Ge=C.create,or=N.create,dr=z.create,cr=C.createWithPreprocess,ur=xe.create,lr=()=>nt().optional(),fr=()=>st().optional(),hr=()=>at().optional(),pr={string:r=>j.create({...r,coerce:!0}),number:r=>V.create({...r,coerce:!0}),boolean:r=>de.create({...r,coerce:!0}),bigint:r=>L.create({...r,coerce:!0}),date:r=>q.create({...r,coerce:!0})},mr=y;var h=Object.freeze({__proto__:null,defaultErrorMap:Q,setErrorMap:mt,getErrorMap:ke,makeIssue:we,EMPTY_PATH:_t,addIssueToContext:l,ParseStatus:T,INVALID:y,DIRTY:X,OK:Z,isAborted:We,isDirty:qe,isValid:ie,isAsync:oe,get util(){return x},get objectUtil(){return Be},ZodParsedType:f,getParsedType:D,ZodType:g,datetimeRegex:et,ZodString:j,ZodNumber:V,ZodBigInt:L,ZodBoolean:de,ZodDate:q,ZodSymbol:Ze,ZodUndefined:ce,ZodNull:ue,ZodAny:F,ZodUnknown:W,ZodNever:M,ZodVoid:Se,ZodArray:E,ZodObject:b,ZodUnion:le,ZodDiscriminatedUnion:Ce,ZodIntersection:fe,ZodTuple:I,ZodRecord:he,ZodMap:Oe,ZodSet:J,ZodFunction:K,ZodLazy:pe,ZodLiteral:me,ZodEnum:U,ZodNativeEnum:_e,ZodPromise:ee,ZodEffects:C,ZodTransformer:C,ZodOptional:N,ZodNullable:z,ZodDefault:ye,ZodCatch:ve,ZodNaN:je,BRAND:Rt,ZodBranded:He,ZodPipeline:xe,ZodReadonly:ge,custom:rt,Schema:g,ZodSchema:g,late:It,get ZodFirstPartyTypeKind(){return _},coerce:pr,any:Ut,array:qt,bigint:Pt,boolean:at,date:$t,discriminatedUnion:Gt,effect:Ge,enum:sr,function:tr,instanceof:At,intersection:Xt,lazy:rr,literal:nr,map:Ft,nan:Mt,nativeEnum:ar,never:Bt,null:Lt,nullable:dr,number:st,object:Jt,oboolean:hr,onumber:fr,optional:or,ostring:lr,pipeline:ur,preprocess:cr,promise:ir,record:Qt,set:er,strictObject:Ht,string:nt,symbol:Dt,transformer:Ge,tuple:Kt,undefined:Vt,union:Yt,unknown:zt,void:Wt,NEVER:mr,ZodIssueCode:u,quotelessJson:pt,ZodError:S});ht(h);const _r=(r,e)=>e.skipDedupe||e.method!=="GET",yr=(r,e)=>e.method+"@"+r,vr=r=>r.clone(),gr=({skip:r=_r,key:e=yr,resolver:t=vr}={})=>{const n=new Map;return s=>(a,i)=>{if(r(a,i))return s(a,i);const o=e(a,i);if(!n.has(o))n.set(o,[]);else return new Promise((d,c)=>{n.get(o).push([d,c])});try{return s(a,i).then(d=>(n.get(o).forEach(([c])=>c(t(d))),n.delete(o),d)).catch(d=>{throw n.get(o).forEach(([,c])=>c(d)),n.delete(o),d})}catch(d){return n.delete(o),Promise.reject(d)}}},xr=(r,e)=>r*e,br=r=>r&&r.ok,kr=({delayTimer:r=500,delayRamp:e=xr,maxAttempts:t=10,until:n=br,onRetry:s=null,retryOnNetworkError:a=!1,resolveWithLatestResponse:i=!1,skip:o}={})=>d=>(c,p)=>{let k=0;if(o&&o(c,p))return d(c,p);const O=(w,P)=>Promise.resolve(n(w,P)).then(Ne=>Ne?w&&i?w:P?Promise.reject(P):w:(k++,!t||k<=t?new Promise($=>{const be=e(r,k);setTimeout(()=>{typeof s=="function"?Promise.resolve(s({response:w,error:P,url:c,options:p})).then((B={})=>{var te,re;$(d((te=B&&B.url)!==null&&te!==void 0?te:c,(re=B&&B.options)!==null&&re!==void 0?re:p))}):$(d(c,p))},be)}).then(O).catch($=>{if(!a)throw $;return O(null,$)}):w&&i?w:Promise.reject(P||new Error("Number of attempts exceeded."))));return d(c,p).then(O).catch(w=>{if(!a)throw w;return O(null,w)})},Ee=h.object({code:h.number(),message:h.string()}),wr=h.object({message:h.string()}),Tr=h.object({emails:h.array(h.string()).optional(),http_body:h.string().optional(),http_url:h.string().optional(),txt_name:h.string().optional(),txt_value:h.string().optional()}),Zr=h.object({ciphers:h.array(h.string()).optional(),early_hints:h.string().optional(),http2:h.string().optional(),min_tls_version:h.string().optional(),tls_1_3:h.string().optional()}),Sr=h.object({id:h.string(),bundle_method:h.string().optional(),certificate_authority:h.string(),custom_certificate:h.string().optional(),custom_csr_id:h.string().optional(),custom_key:h.string().optional(),expires_on:h.string().optional(),hosts:h.array(h.string()).optional(),issuer:h.string().optional(),method:h.string(),serial_number:h.string().optional(),settings:Zr.optional(),signature:h.string().optional(),type:h.string(),uploaded_on:h.string().optional(),validation_errors:h.array(wr).optional(),validation_records:h.array(Tr).optional(),wildcard:h.boolean()}),Or=h.object({name:h.string(),type:h.string(),value:h.string()}),jr=h.object({http_body:h.string().optional(),http_url:h.string().optional()}),it=h.object({id:h.string(),ssl:Sr,hostname:h.string(),custom_metadata:h.record(h.string()).optional(),custom_origin_server:h.string().optional(),custom_origin_sni:h.string().optional(),ownership_verification:Or.optional(),ownership_verification_http:jr.optional(),status:h.string(),verification_errors:h.array(h.string()).optional(),created_at:h.string()}),Ue=h.object({errors:h.array(Ee),messages:h.array(Ee),success:h.boolean(),result:it}),Er=h.object({errors:h.array(Ee),messages:h.array(Ee),success:h.boolean(),result:h.array(it)});function Y(r){return ut(`https://api.cloudflare.com/client/v4/zones/${r.zoneId}`).headers({"X-Auth-Email":r.authEmail,"X-Auth-Key":r.authKey,"Content-Type":"application/json"}).middlewares([kr(),gr()])}function ze(r){const e=[];if(r.ssl.validation_records)for(const t of r.ssl.validation_records)t.txt_name&&t.txt_value&&e.push({name:"txt",record:t.txt_value,domain:t.txt_name});return r.ownership_verification&&e.push({name:"txt",record:r.ownership_verification.value,domain:r.ownership_verification.name}),{custom_domain_id:r.id,domain:r.hostname,primary:r.primary,status:r.status==="active"?"ready":"pending",type:"auth0_managed_certs",verification:{methods:h.array(ct.verificationMethodsSchema).parse(e)}}}function Cr(r){return{create:async(e,t)=>{const{result:n,errors:s,success:a}=Ue.parse(await Y(r).post({hostname:t.domain,ssl:{method:"txt",type:"dv"},custom_metadata:r.enterprise?{tenant_id:e}:void 0},"/custom_hostnames").json());if(!a)throw new Error(JSON.stringify(s));const i=ze({...n,primary:!1});return await r.customDomainAdapter.create(e,{custom_domain_id:i.custom_domain_id,domain:i.domain,type:i.type}),i},get:async(e,t)=>{var d;const n=await r.customDomainAdapter.get(e,t);if(!n)throw new H(404);const s=await Y(r).get(`/custom_hostnames/${encodeURIComponent(t)}`).json(),{result:a,errors:i,success:o}=Ue.parse(s);if(!o)throw new H(503,{message:JSON.stringify(i)});if(r.enterprise&&((d=a.custom_metadata)==null?void 0:d.tenant_id)!==e)throw new H(404);return ze({...n,...a})},list:async e=>{const t=await r.customDomainAdapter.list(e),n=await Y(r).get("/custom_hostnames").json(),{result:s,errors:a,success:i}=Er.parse(n);if(!i)throw new H(503,{message:JSON.stringify(a)});return s.filter(o=>t.find(d=>d.custom_domain_id===o.id)).filter(o=>{var d;return!(r.enterprise&&((d=o.custom_metadata)==null?void 0:d.tenant_id)!==e)}).map(o=>ze({...t.find(d=>d.custom_domain_id===o.id),...o}))},remove:async(e,t)=>{var s;if(r.enterprise){const{result:a,success:i}=Ue.parse(await Y(r).get(`/custom_hostnames/${encodeURIComponent(t)}`).json());if(!i||((s=a.custom_metadata)==null?void 0:s.tenant_id)!==e)throw new H(404)}const n=await Y(r).delete(`/custom_hostnames/${encodeURIComponent(t)}`).res();return n.ok&&await r.customDomainAdapter.remove(e,t),n.ok},update:async(e,t,n)=>{const s=await Y(r).patch(n,`/custom_hostnames/${encodeURIComponent(t)}`).res();if(!s.ok)throw new H(503,{message:await s.text()});return r.customDomainAdapter.update(e,t,n)}}}function Nr(r){return{customDomains:Cr(r)}}module.exports=Nr;
1
+ "use strict";var ot=Object.defineProperty;var dt=(r,e,t)=>e in r?ot(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var Ve=(r,e,t)=>dt(r,typeof e!="symbol"?e+"":e,t);const ct=require("@authhero/adapter-interfaces"),ut=require("wretch");function lt(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t}function ft(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function ne(r,e){const t=r.ZodType.prototype[e];r.ZodType.prototype[e]=function(...n){const s=t.apply(this,n);return s._def.openapi=this._def.openapi,s}}function ht(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(s,a){var i,o,d,c,p,k;const O=typeof s=="string"?a:s,w=O??{},{param:P}=w,Ne=lt(w,["param"]),$=Object.assign(Object.assign({},(i=this._def.openapi)===null||i===void 0?void 0:i._internal),typeof s=="string"?{refId:s}:void 0),be=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),Ne),!((c=(d=this._def.openapi)===null||d===void 0?void 0:d.metadata)===null||c===void 0)&&c.param||P?{param:Object.assign(Object.assign({},(k=(p=this._def.openapi)===null||p===void 0?void 0:p.metadata)===null||k===void 0?void 0:k.param),P)}:void 0),B=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys($).length>0?{_internal:$}:void 0),Object.keys(be).length>0?{metadata:be}:void 0)}));if(ft(this,"ZodObject")){const te=this.extend;B.extend=function(...re){var Re,Ie,Ae,Me,Pe,$e;const De=te.apply(this,re);return De._def.openapi={_internal:{extendedFrom:!((Ie=(Re=this._def.openapi)===null||Re===void 0?void 0:Re._internal)===null||Ie===void 0)&&Ie.refId?{refId:(Me=(Ae=this._def.openapi)===null||Ae===void 0?void 0:Ae._internal)===null||Me===void 0?void 0:Me.refId,schema:this}:(Pe=this._def.openapi)===null||Pe===void 0?void 0:Pe._internal.extendedFrom},metadata:($e=De._def.openapi)===null||$e===void 0?void 0:$e.metadata},De}}return B},ne(r,"optional"),ne(r,"nullable"),ne(r,"default"),ne(r,"transform"),ne(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),a=e.apply(this),i=a._def.shape();return Object.entries(i).forEach(([o,d])=>{var c,p;d._def.openapi=(p=(c=s[o])===null||c===void 0?void 0:c._def)===null||p===void 0?void 0:p.openapi}),a._def.openapi=void 0,a};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...s){const a=t.apply(this,s);return a._def.openapi=void 0,a};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...s){const a=n.apply(this,s);return a._def.openapi=void 0,a}}var H=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});Ve(this,"res");Ve(this,"status");this.res=t==null?void 0:t.res,this.status=e}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}};new Set(".\\+*[^]$()");var x;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},r.getValidEnumValues=s=>{const a=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return r.objectValues(i)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},r.find=(s,a)=>{for(const i of s)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(x||(x={}));var Be;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Be||(Be={}));const f=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),D=r=>{switch(typeof r){case"undefined":return f.undefined;case"string":return f.string;case"number":return isNaN(r)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(r)?f.array:r===null?f.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?f.promise:typeof Map<"u"&&r instanceof Map?f.map:typeof Set<"u"&&r instanceof Set?f.set:typeof Date<"u"&&r instanceof Date?f.date:f.object;default:return f.unknown}},u=x.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),pt=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class S extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};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},n={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,d=0;for(;d<i.path.length;){const c=i.path[d];d===i.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(t(i))):o[c]=o[c]||{_errors:[]},o=o[c],d++}}};return s(this),n}static assert(e){if(!(e instanceof S))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}S.create=r=>new S(r);const Q=(r,e)=>{let t;switch(r.code){case u.invalid_type:r.received===f.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case u.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,x.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:t=`Unrecognized key(s) in object: ${x.joinValues(r.keys,", ")}`;break;case u.invalid_union:t="Invalid input";break;case u.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${x.joinValues(r.options)}`;break;case u.invalid_enum_value:t=`Invalid enum value. Expected ${x.joinValues(r.options)}, received '${r.received}'`;break;case u.invalid_arguments:t="Invalid function arguments";break;case u.invalid_return_type:t="Invalid function return type";break;case u.invalid_date:t="Invalid date";break;case u.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:x.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case u.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case u.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case u.custom:t="Invalid input";break;case u.invalid_intersection_types:t="Intersection results could not be merged";break;case u.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case u.not_finite:t="Number must be finite";break;default:t=e.defaultError,x.assertNever(r)}return{message:t}};let Xe=Q;function mt(r){Xe=r}function ke(){return Xe}const we=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="";const d=n.filter(c=>!!c).slice().reverse();for(const c of d)o=c(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}},_t=[];function l(r,e){const t=ke(),n=we({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Q?void 0:Q].filter(s=>!!s)});r.common.issues.push(n)}class T{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return y;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const a=await s.key,i=await s.value;n.push({key:a,value:i})}return T.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return y;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const y=Object.freeze({status:"aborted"}),X=r=>({status:"dirty",value:r}),Z=r=>({status:"valid",value:r}),We=r=>r.status==="aborted",qe=r=>r.status==="dirty",ie=r=>r.status==="valid",oe=r=>typeof Promise<"u"&&r instanceof Promise;function Te(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function Ke(r,e,t,n,s){if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var m;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(m||(m={}));var se,ae;class R{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Ye=(r,e)=>{if(ie(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 S(r.common.issues);return this._error=t,this._error}}};function v(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,o)=>{var d,c;const{message:p}=r;return i.code==="invalid_enum_value"?{message:p??o.defaultError}:typeof o.data>"u"?{message:(d=p??n)!==null&&d!==void 0?d:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(c=p??t)!==null&&c!==void 0?c:o.defaultError}},description:s}}class g{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 D(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:D(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new T,ctx:{common:e.parent.common,data:e.data,parsedType:D(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(oe(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 n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:D(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Ye(s,a)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={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:D(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(oe(s)?s:Promise.resolve(s));return Ye(n,a)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:u.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(d=>d?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new C({schema:this,typeName:_.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return N.create(this,this._def)}nullable(){return z.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return E.create(this,this._def)}promise(){return ee.create(this,this._def)}or(e){return le.create([this,e],this._def)}and(e){return fe.create(this,e,this._def)}transform(e){return new C({...v(this._def),schema:this,typeName:_.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ye({...v(this._def),innerType:this,defaultValue:t,typeName:_.ZodDefault})}brand(){return new He({typeName:_.ZodBranded,type:this,...v(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ve({...v(this._def),innerType:this,catchValue:t,typeName:_.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return xe.create(this,e)}readonly(){return ge.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const yt=/^c[^\s-]{8,}$/i,vt=/^[0-9a-z]+$/,gt=/^[0-9A-HJKMNP-TV-Z]{26}$/,xt=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,bt=/^[a-z0-9_-]{21}$/i,kt=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,wt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Tt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Le;const Zt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,St=/^(([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})))$/,Ot=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Qe="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",jt=new RegExp(`^${Qe}$`);function Fe(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Et(r){return new RegExp(`^${Fe(r)}$`)}function et(r){let e=`${Qe}T${Fe(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Ct(r,e){return!!((e==="v4"||!e)&&Zt.test(r)||(e==="v6"||!e)&&St.test(r))}class j extends g{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){const a=this._getOrReturnCtx(e);return l(a,{code:u.invalid_type,expected:f.string,received:a.parsedType}),y}const n=new T;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:u.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:u.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?l(s,{code:u.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&l(s,{code:u.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")wt.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"email",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")Le||(Le=new RegExp(Tt,"u")),Le.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"emoji",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")xt.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"uuid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")bt.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"nanoid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")yt.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"cuid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")vt.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"cuid2",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")gt.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"ulid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),l(s,{validation:"url",code:u.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"regex",code:u.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),l(s,{code:u.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.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)||(s=this._getOrReturnCtx(e,s),l(s,{code:u.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),l(s,{code:u.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?et(a).test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:u.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?jt.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:u.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Et(a).test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:u.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?kt.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"duration",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Ct(e.data,a.version)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"ip",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Ot.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"base64",code:u.invalid_string,message:a.message}),n.dirty()):x.assertNever(a);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:u.invalid_string,...m.errToObj(n)})}_addCheck(e){return new j({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...m.errToObj(e)})}url(e){return this._addCheck({kind:"url",...m.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...m.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...m.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...m.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...m.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...m.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...m.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...m.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...m.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...m.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...m.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...m.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...m.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...m.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...m.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...m.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...m.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...m.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...m.errToObj(t)})}nonempty(e){return this.min(1,m.errToObj(e))}trim(){return new j({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new j({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new j({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}j.create=r=>{var e;return new j({checks:[],typeName:_.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...v(r)})};function Nt(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=parseInt(r.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}class V extends g{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){const a=this._getOrReturnCtx(e);return l(a,{code:u.invalid_type,expected:f.number,received:a.parsedType}),y}let n;const s=new T;for(const a of this._def.checks)a.kind==="int"?x.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:u.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),l(n,{code:u.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),l(n,{code:u.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Nt(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),l(n,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:u.not_finite,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,n,s){return new V({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:m.toString(s)}]})}_addCheck(e){return new V({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:m.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:m.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:m.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:m.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"&&x.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}V.create=r=>new V({checks:[],typeName:_.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...v(r)});class L extends g{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)!==f.bigint){const a=this._getOrReturnCtx(e);return l(a,{code:u.invalid_type,expected:f.bigint,received:a.parsedType}),y}let n;const s=new T;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),l(n,{code:u.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),l(n,{code:u.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),l(n,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,n,s){return new L({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:m.toString(s)}]})}_addCheck(e){return new L({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}L.create=r=>{var e;return new L({checks:[],typeName:_.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...v(r)})};class de extends g{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:f.boolean,received:n.parsedType}),y}return Z(e.data)}}de.create=r=>new de({typeName:_.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...v(r)});class q extends g{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){const a=this._getOrReturnCtx(e);return l(a,{code:u.invalid_type,expected:f.date,received:a.parsedType}),y}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return l(a,{code:u.invalid_date}),y}const n=new T;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:u.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:u.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):x.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new q({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:m.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:m.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}q.create=r=>new q({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:_.ZodDate,...v(r)});class Ze extends g{_parse(e){if(this._getType(e)!==f.symbol){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:f.symbol,received:n.parsedType}),y}return Z(e.data)}}Ze.create=r=>new Ze({typeName:_.ZodSymbol,...v(r)});class ce extends g{_parse(e){if(this._getType(e)!==f.undefined){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:f.undefined,received:n.parsedType}),y}return Z(e.data)}}ce.create=r=>new ce({typeName:_.ZodUndefined,...v(r)});class ue extends g{_parse(e){if(this._getType(e)!==f.null){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:f.null,received:n.parsedType}),y}return Z(e.data)}}ue.create=r=>new ue({typeName:_.ZodNull,...v(r)});class F extends g{constructor(){super(...arguments),this._any=!0}_parse(e){return Z(e.data)}}F.create=r=>new F({typeName:_.ZodAny,...v(r)});class W extends g{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Z(e.data)}}W.create=r=>new W({typeName:_.ZodUnknown,...v(r)});class M extends g{_parse(e){const t=this._getOrReturnCtx(e);return l(t,{code:u.invalid_type,expected:f.never,received:t.parsedType}),y}}M.create=r=>new M({typeName:_.ZodNever,...v(r)});class Se extends g{_parse(e){if(this._getType(e)!==f.undefined){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:f.void,received:n.parsedType}),y}return Z(e.data)}}Se.create=r=>new Se({typeName:_.ZodVoid,...v(r)});class E extends g{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==f.array)return l(t,{code:u.invalid_type,expected:f.array,received:t.parsedType}),y;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(l(t,{code:i?u.too_big:u.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(l(t,{code:u.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(l(t,{code:u.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new R(t,i,t.path,o)))).then(i=>T.mergeArray(n,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new R(t,i,t.path,o)));return T.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new E({...this._def,minLength:{value:e,message:m.toString(t)}})}max(e,t){return new E({...this._def,maxLength:{value:e,message:m.toString(t)}})}length(e,t){return new E({...this._def,exactLength:{value:e,message:m.toString(t)}})}nonempty(e){return this.min(1,e)}}E.create=(r,e)=>new E({type:r,minLength:null,maxLength:null,exactLength:null,typeName:_.ZodArray,...v(e)});function G(r){if(r instanceof b){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=N.create(G(n))}return new b({...r._def,shape:()=>e})}else return r instanceof E?new E({...r._def,type:G(r.element)}):r instanceof N?N.create(G(r.unwrap())):r instanceof z?z.create(G(r.unwrap())):r instanceof I?I.create(r.items.map(e=>G(e))):r}class b extends g{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=x.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==f.object){const c=this._getOrReturnCtx(e);return l(c,{code:u.invalid_type,expected:f.object,received:c.parsedType}),y}const{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof M&&this._def.unknownKeys==="strip"))for(const c in s.data)i.includes(c)||o.push(c);const d=[];for(const c of i){const p=a[c],k=s.data[c];d.push({key:{status:"valid",value:c},value:p._parse(new R(s,k,s.path,c)),alwaysSet:c in s.data})}if(this._def.catchall instanceof M){const c=this._def.unknownKeys;if(c==="passthrough")for(const p of o)d.push({key:{status:"valid",value:p},value:{status:"valid",value:s.data[p]}});else if(c==="strict")o.length>0&&(l(s,{code:u.unrecognized_keys,keys:o}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const p of o){const k=s.data[p];d.push({key:{status:"valid",value:p},value:c._parse(new R(s,k,s.path,p)),alwaysSet:p in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const c=[];for(const p of d){const k=await p.key,O=await p.value;c.push({key:k,value:O,alwaysSet:p.alwaysSet})}return c}).then(c=>T.mergeObjectSync(n,c)):T.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return m.errToObj,new b({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,a,i,o;const d=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=m.errToObj(e).message)!==null&&o!==void 0?o:d}:{message:d}}}:{}})}strip(){return new b({...this._def,unknownKeys:"strip"})}passthrough(){return new b({...this._def,unknownKeys:"passthrough"})}extend(e){return new b({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new b({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:_.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new b({...this._def,catchall:e})}pick(e){const t={};return x.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new b({...this._def,shape:()=>t})}omit(e){const t={};return x.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new b({...this._def,shape:()=>t})}deepPartial(){return G(this)}partial(e){const t={};return x.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new b({...this._def,shape:()=>t})}required(e){const t={};return x.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof N;)a=a._def.innerType;t[n]=a}}),new b({...this._def,shape:()=>t})}keyof(){return tt(x.objectKeys(this.shape))}}b.create=(r,e)=>new b({shape:()=>r,unknownKeys:"strip",catchall:M.create(),typeName:_.ZodObject,...v(e)});b.strictCreate=(r,e)=>new b({shape:()=>r,unknownKeys:"strict",catchall:M.create(),typeName:_.ZodObject,...v(e)});b.lazycreate=(r,e)=>new b({shape:r,unknownKeys:"strip",catchall:M.create(),typeName:_.ZodObject,...v(e)});class le extends g{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(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 S(o.ctx.common.issues));return l(t,{code:u.invalid_union,unionErrors:i}),y}if(t.common.async)return Promise.all(n.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(s);{let a;const i=[];for(const d of n){const c={...t,common:{...t.common,issues:[]},parent:null},p=d._parseSync({data:t.data,path:t.path,parent:c});if(p.status==="valid")return p;p.status==="dirty"&&!a&&(a={result:p,ctx:c}),c.common.issues.length&&i.push(c.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(d=>new S(d));return l(t,{code:u.invalid_union,unionErrors:o}),y}}get options(){return this._def.options}}le.create=(r,e)=>new le({options:r,typeName:_.ZodUnion,...v(e)});const A=r=>r instanceof pe?A(r.schema):r instanceof C?A(r.innerType()):r instanceof me?[r.value]:r instanceof U?r.options:r instanceof _e?x.objectValues(r.enum):r instanceof ye?A(r._def.innerType):r instanceof ce?[void 0]:r instanceof ue?[null]:r instanceof N?[void 0,...A(r.unwrap())]:r instanceof z?[null,...A(r.unwrap())]:r instanceof He||r instanceof ge?A(r.unwrap()):r instanceof ve?A(r._def.innerType):[];class Ce extends g{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return l(t,{code:u.invalid_type,expected:f.object,received:t.parsedType}),y;const n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);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:u.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const a of t){const i=A(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new Ce({typeName:_.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...v(n)})}}function Je(r,e){const t=D(r),n=D(e);if(r===e)return{valid:!0,data:r};if(t===f.object&&n===f.object){const s=x.objectKeys(e),a=x.objectKeys(r).filter(o=>s.indexOf(o)!==-1),i={...r,...e};for(const o of a){const d=Je(r[o],e[o]);if(!d.valid)return{valid:!1};i[o]=d.data}return{valid:!0,data:i}}else if(t===f.array&&n===f.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],d=Je(i,o);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return t===f.date&&n===f.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class fe extends g{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(We(a)||We(i))return y;const o=Je(a.value,i.value);return o.valid?((qe(a)||qe(i))&&t.dirty(),{status:t.value,value:o.data}):(l(n,{code:u.invalid_intersection_types}),y)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}fe.create=(r,e,t)=>new fe({left:r,right:e,typeName:_.ZodIntersection,...v(t)});class I extends g{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.array)return l(n,{code:u.invalid_type,expected:f.array,received:n.parsedType}),y;if(n.data.length<this._def.items.length)return l(n,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;!this._def.rest&&n.data.length>this._def.items.length&&(l(n,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...n.data].map((i,o)=>{const d=this._def.items[o]||this._def.rest;return d?d._parse(new R(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>T.mergeArray(t,i)):T.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new I({...this._def,rest:e})}}I.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new I({items:r,typeName:_.ZodTuple,rest:null,...v(e)})};class he extends g{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.object)return l(n,{code:u.invalid_type,expected:f.object,received:n.parsedType}),y;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:a._parse(new R(n,o,n.path,o)),value:i._parse(new R(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?T.mergeObjectAsync(t,s):T.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof g?new he({keyType:e,valueType:t,typeName:_.ZodRecord,...v(n)}):new he({keyType:j.create(),valueType:e,typeName:_.ZodRecord,...v(t)})}}class Oe extends g{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.map)return l(n,{code:u.invalid_type,expected:f.map,received:n.parsedType}),y;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,d],c)=>({key:s._parse(new R(n,o,n.path,[c,"key"])),value:a._parse(new R(n,d,n.path,[c,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const d of i){const c=await d.key,p=await d.value;if(c.status==="aborted"||p.status==="aborted")return y;(c.status==="dirty"||p.status==="dirty")&&t.dirty(),o.set(c.value,p.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const d of i){const c=d.key,p=d.value;if(c.status==="aborted"||p.status==="aborted")return y;(c.status==="dirty"||p.status==="dirty")&&t.dirty(),o.set(c.value,p.value)}return{status:t.value,value:o}}}}Oe.create=(r,e,t)=>new Oe({valueType:e,keyType:r,typeName:_.ZodMap,...v(t)});class J extends g{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.set)return l(n,{code:u.invalid_type,expected:f.set,received:n.parsedType}),y;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(l(n,{code:u.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(l(n,{code:u.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(d){const c=new Set;for(const p of d){if(p.status==="aborted")return y;p.status==="dirty"&&t.dirty(),c.add(p.value)}return{status:t.value,value:c}}const o=[...n.data.values()].map((d,c)=>a._parse(new R(n,d,n.path,c)));return n.common.async?Promise.all(o).then(d=>i(d)):i(o)}min(e,t){return new J({...this._def,minSize:{value:e,message:m.toString(t)}})}max(e,t){return new J({...this._def,maxSize:{value:e,message:m.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}J.create=(r,e)=>new J({valueType:r,minSize:null,maxSize:null,typeName:_.ZodSet,...v(e)});class K extends g{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return l(t,{code:u.invalid_type,expected:f.function,received:t.parsedType}),y;function n(o,d){return we({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ke(),Q].filter(c=>!!c),issueData:{code:u.invalid_arguments,argumentsError:d}})}function s(o,d){return we({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ke(),Q].filter(c=>!!c),issueData:{code:u.invalid_return_type,returnTypeError:d}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof ee){const o=this;return Z(async function(...d){const c=new S([]),p=await o._def.args.parseAsync(d,a).catch(w=>{throw c.addIssue(n(d,w)),c}),k=await Reflect.apply(i,this,p);return await o._def.returns._def.type.parseAsync(k,a).catch(w=>{throw c.addIssue(s(k,w)),c})})}else{const o=this;return Z(function(...d){const c=o._def.args.safeParse(d,a);if(!c.success)throw new S([n(d,c.error)]);const p=Reflect.apply(i,this,c.data),k=o._def.returns.safeParse(p,a);if(!k.success)throw new S([s(p,k.error)]);return k.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new K({...this._def,args:I.create(e).rest(W.create())})}returns(e){return new K({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new K({args:e||I.create([]).rest(W.create()),returns:t||W.create(),typeName:_.ZodFunction,...v(n)})}}class pe extends g{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})}}pe.create=(r,e)=>new pe({getter:r,typeName:_.ZodLazy,...v(e)});class me extends g{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return l(t,{received:t.data,code:u.invalid_literal,expected:this._def.value}),y}return{status:"valid",value:e.data}}get value(){return this._def.value}}me.create=(r,e)=>new me({value:r,typeName:_.ZodLiteral,...v(e)});function tt(r,e){return new U({values:r,typeName:_.ZodEnum,...v(e)})}class U extends g{constructor(){super(...arguments),se.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return l(t,{expected:x.joinValues(n),received:t.parsedType,code:u.invalid_type}),y}if(Te(this,se)||Ke(this,se,new Set(this._def.values)),!Te(this,se).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return l(t,{received:t.data,code:u.invalid_enum_value,options:n}),y}return Z(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return U.create(e,{...this._def,...t})}exclude(e,t=this._def){return U.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}se=new WeakMap;U.create=tt;class _e extends g{constructor(){super(...arguments),ae.set(this,void 0)}_parse(e){const t=x.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==f.string&&n.parsedType!==f.number){const s=x.objectValues(t);return l(n,{expected:x.joinValues(s),received:n.parsedType,code:u.invalid_type}),y}if(Te(this,ae)||Ke(this,ae,new Set(x.getValidEnumValues(this._def.values))),!Te(this,ae).has(e.data)){const s=x.objectValues(t);return l(n,{received:n.data,code:u.invalid_enum_value,options:s}),y}return Z(e.data)}get enum(){return this._def.values}}ae=new WeakMap;_e.create=(r,e)=>new _e({values:r,typeName:_.ZodNativeEnum,...v(e)});class ee extends g{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return l(t,{code:u.invalid_type,expected:f.promise,received:t.parsedType}),y;const n=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return Z(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ee.create=(r,e)=>new ee({type:r,typeName:_.ZodPromise,...v(e)});class C extends g{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===_.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{l(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(n.data,a);if(n.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return y;const d=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return d.status==="aborted"?y:d.status==="dirty"||t.value==="dirty"?X(d.value):d});{if(t.value==="aborted")return y;const o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?y:o.status==="dirty"||t.value==="dirty"?X(o.value):o}}if(s.type==="refinement"){const i=o=>{const d=s.refinement(o,a);if(n.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?y:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?y:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ie(i))return i;const o=s.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:n.data,path:n.path,parent:n}).then(i=>ie(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);x.assertNever(s)}}C.create=(r,e,t)=>new C({schema:r,typeName:_.ZodEffects,effect:e,...v(t)});C.createWithPreprocess=(r,e,t)=>new C({schema:e,effect:{type:"preprocess",transform:r},typeName:_.ZodEffects,...v(t)});class N extends g{_parse(e){return this._getType(e)===f.undefined?Z(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}N.create=(r,e)=>new N({innerType:r,typeName:_.ZodOptional,...v(e)});class z extends g{_parse(e){return this._getType(e)===f.null?Z(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}z.create=(r,e)=>new z({innerType:r,typeName:_.ZodNullable,...v(e)});class ye extends g{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===f.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ye.create=(r,e)=>new ye({innerType:r,typeName:_.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...v(e)});class ve extends g{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return oe(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new S(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new S(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ve.create=(r,e)=>new ve({innerType:r,typeName:_.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...v(e)});class je extends g{_parse(e){if(this._getType(e)!==f.nan){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:f.nan,received:n.parsedType}),y}return{status:"valid",value:e.data}}}je.create=r=>new je({typeName:_.ZodNaN,...v(r)});const Rt=Symbol("zod_brand");class He extends g{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class xe extends g{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?y:a.status==="dirty"?(t.dirty(),X(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?y:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new xe({in:e,out:t,typeName:_.ZodPipeline})}}class ge extends g{_parse(e){const t=this._def.innerType._parse(e),n=s=>(ie(s)&&(s.value=Object.freeze(s.value)),s);return oe(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}ge.create=(r,e)=>new ge({innerType:r,typeName:_.ZodReadonly,...v(e)});function rt(r,e={},t){return r?F.create().superRefine((n,s)=>{var a,i;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,d=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,c=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...c,fatal:d})}}):F.create()}const It={object:b.lazycreate};var _;(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"})(_||(_={}));const At=(r,e={message:`Input not instance of ${r.name}`})=>rt(t=>t instanceof r,e),nt=j.create,st=V.create,Mt=je.create,Pt=L.create,at=de.create,$t=q.create,Dt=Ze.create,Vt=ce.create,Lt=ue.create,Ut=F.create,zt=W.create,Bt=M.create,Wt=Se.create,qt=E.create,Jt=b.create,Ht=b.strictCreate,Yt=le.create,Gt=Ce.create,Xt=fe.create,Kt=I.create,Qt=he.create,Ft=Oe.create,er=J.create,tr=K.create,rr=pe.create,nr=me.create,sr=U.create,ar=_e.create,ir=ee.create,Ge=C.create,or=N.create,dr=z.create,cr=C.createWithPreprocess,ur=xe.create,lr=()=>nt().optional(),fr=()=>st().optional(),hr=()=>at().optional(),pr={string:r=>j.create({...r,coerce:!0}),number:r=>V.create({...r,coerce:!0}),boolean:r=>de.create({...r,coerce:!0}),bigint:r=>L.create({...r,coerce:!0}),date:r=>q.create({...r,coerce:!0})},mr=y;var h=Object.freeze({__proto__:null,defaultErrorMap:Q,setErrorMap:mt,getErrorMap:ke,makeIssue:we,EMPTY_PATH:_t,addIssueToContext:l,ParseStatus:T,INVALID:y,DIRTY:X,OK:Z,isAborted:We,isDirty:qe,isValid:ie,isAsync:oe,get util(){return x},get objectUtil(){return Be},ZodParsedType:f,getParsedType:D,ZodType:g,datetimeRegex:et,ZodString:j,ZodNumber:V,ZodBigInt:L,ZodBoolean:de,ZodDate:q,ZodSymbol:Ze,ZodUndefined:ce,ZodNull:ue,ZodAny:F,ZodUnknown:W,ZodNever:M,ZodVoid:Se,ZodArray:E,ZodObject:b,ZodUnion:le,ZodDiscriminatedUnion:Ce,ZodIntersection:fe,ZodTuple:I,ZodRecord:he,ZodMap:Oe,ZodSet:J,ZodFunction:K,ZodLazy:pe,ZodLiteral:me,ZodEnum:U,ZodNativeEnum:_e,ZodPromise:ee,ZodEffects:C,ZodTransformer:C,ZodOptional:N,ZodNullable:z,ZodDefault:ye,ZodCatch:ve,ZodNaN:je,BRAND:Rt,ZodBranded:He,ZodPipeline:xe,ZodReadonly:ge,custom:rt,Schema:g,ZodSchema:g,late:It,get ZodFirstPartyTypeKind(){return _},coerce:pr,any:Ut,array:qt,bigint:Pt,boolean:at,date:$t,discriminatedUnion:Gt,effect:Ge,enum:sr,function:tr,instanceof:At,intersection:Xt,lazy:rr,literal:nr,map:Ft,nan:Mt,nativeEnum:ar,never:Bt,null:Lt,nullable:dr,number:st,object:Jt,oboolean:hr,onumber:fr,optional:or,ostring:lr,pipeline:ur,preprocess:cr,promise:ir,record:Qt,set:er,strictObject:Ht,string:nt,symbol:Dt,transformer:Ge,tuple:Kt,undefined:Vt,union:Yt,unknown:zt,void:Wt,NEVER:mr,ZodIssueCode:u,quotelessJson:pt,ZodError:S});ht(h);const _r=(r,e)=>e.skipDedupe||e.method!=="GET",yr=(r,e)=>e.method+"@"+r,vr=r=>r.clone(),gr=({skip:r=_r,key:e=yr,resolver:t=vr}={})=>{const n=new Map;return s=>(a,i)=>{if(r(a,i))return s(a,i);const o=e(a,i);if(!n.has(o))n.set(o,[]);else return new Promise((d,c)=>{n.get(o).push([d,c])});try{return s(a,i).then(d=>(n.get(o).forEach(([c])=>c(t(d))),n.delete(o),d)).catch(d=>{throw n.get(o).forEach(([,c])=>c(d)),n.delete(o),d})}catch(d){return n.delete(o),Promise.reject(d)}}},xr=(r,e)=>r*e,br=r=>r&&r.ok,kr=({delayTimer:r=500,delayRamp:e=xr,maxAttempts:t=10,until:n=br,onRetry:s=null,retryOnNetworkError:a=!1,resolveWithLatestResponse:i=!1,skip:o}={})=>d=>(c,p)=>{let k=0;if(o&&o(c,p))return d(c,p);const O=(w,P)=>Promise.resolve(n(w,P)).then(Ne=>Ne?w&&i?w:P?Promise.reject(P):w:(k++,!t||k<=t?new Promise($=>{const be=e(r,k);setTimeout(()=>{typeof s=="function"?Promise.resolve(s({response:w,error:P,url:c,options:p})).then((B={})=>{var te,re;$(d((te=B&&B.url)!==null&&te!==void 0?te:c,(re=B&&B.options)!==null&&re!==void 0?re:p))}):$(d(c,p))},be)}).then(O).catch($=>{if(!a)throw $;return O(null,$)}):w&&i?w:Promise.reject(P||new Error("Number of attempts exceeded."))));return d(c,p).then(O).catch(w=>{if(!a)throw w;return O(null,w)})},Ee=h.object({code:h.number(),message:h.string()}),wr=h.object({message:h.string()}),Tr=h.object({emails:h.array(h.string()).optional(),http_body:h.string().optional(),http_url:h.string().optional(),txt_name:h.string().optional(),txt_value:h.string().optional()}),Zr=h.object({ciphers:h.array(h.string()).optional(),early_hints:h.string().optional(),http2:h.string().optional(),min_tls_version:h.string().optional(),tls_1_3:h.string().optional()}),Sr=h.object({id:h.string(),bundle_method:h.string().optional(),certificate_authority:h.string(),custom_certificate:h.string().optional(),custom_csr_id:h.string().optional(),custom_key:h.string().optional(),expires_on:h.string().optional(),hosts:h.array(h.string()).optional(),issuer:h.string().optional(),method:h.string(),serial_number:h.string().optional(),settings:Zr.optional(),signature:h.string().optional(),type:h.string(),uploaded_on:h.string().optional(),validation_errors:h.array(wr).optional(),validation_records:h.array(Tr).optional(),wildcard:h.boolean()}),Or=h.object({name:h.string(),type:h.string(),value:h.string()}),jr=h.object({http_body:h.string().optional(),http_url:h.string().optional()}),it=h.object({id:h.string(),ssl:Sr,hostname:h.string(),custom_metadata:h.record(h.string()).optional(),custom_origin_server:h.string().optional(),custom_origin_sni:h.string().optional(),ownership_verification:Or.optional(),ownership_verification_http:jr.optional(),status:h.string(),verification_errors:h.array(h.string()).optional(),created_at:h.string()}),Ue=h.object({errors:h.array(Ee),messages:h.array(Ee),success:h.boolean(),result:it}),Er=h.object({errors:h.array(Ee),messages:h.array(Ee),success:h.boolean(),result:h.array(it)});function Y(r){return ut(`https://api.cloudflare.com/client/v4/zones/${r.zoneId}`).headers({"X-Auth-Email":r.authEmail,"X-Auth-Key":r.authKey,"Content-Type":"application/json"}).middlewares([kr(),gr()])}function ze(r){const e=[];if(r.ssl.validation_records)for(const t of r.ssl.validation_records)t.txt_name&&t.txt_value&&e.push({name:"txt",record:t.txt_value,domain:t.txt_name});return r.ownership_verification&&e.push({name:"txt",record:r.ownership_verification.value,domain:r.ownership_verification.name}),{custom_domain_id:r.id,domain:r.hostname,primary:r.primary,status:r.status==="active"?"ready":"pending",type:"auth0_managed_certs",verification:{methods:h.array(ct.verificationMethodsSchema).parse(e)}}}function Cr(r){return{create:async(e,t)=>{const{result:n,errors:s,success:a}=Ue.parse(await Y(r).post({hostname:t.domain,ssl:{method:"txt",type:"dv"},custom_metadata:r.enterprise?{tenant_id:e}:void 0},"/custom_hostnames").json());if(!a)throw new Error(JSON.stringify(s));const i=ze({...n,primary:!1});return await r.customDomainAdapter.create(e,{custom_domain_id:i.custom_domain_id,domain:i.domain,type:i.type}),i},get:async(e,t)=>{var d;const n=await r.customDomainAdapter.get(e,t);if(!n)throw new H(404);const s=await Y(r).get(`/custom_hostnames/${encodeURIComponent(t)}`).json(),{result:a,errors:i,success:o}=Ue.parse(s);if(!o)throw new H(503,{message:JSON.stringify(i)});if(r.enterprise&&((d=a.custom_metadata)==null?void 0:d.tenant_id)!==e)throw new H(404);return ze({...n,...a})},getByDomain:async e=>r.customDomainAdapter.getByDomain(e),list:async e=>{const t=await r.customDomainAdapter.list(e),n=await Y(r).get("/custom_hostnames").json(),{result:s,errors:a,success:i}=Er.parse(n);if(!i)throw new H(503,{message:JSON.stringify(a)});return s.filter(o=>t.find(d=>d.custom_domain_id===o.id)).filter(o=>{var d;return!(r.enterprise&&((d=o.custom_metadata)==null?void 0:d.tenant_id)!==e)}).map(o=>ze({...t.find(d=>d.custom_domain_id===o.id),...o}))},remove:async(e,t)=>{var s;if(r.enterprise){const{result:a,success:i}=Ue.parse(await Y(r).get(`/custom_hostnames/${encodeURIComponent(t)}`).json());if(!i||((s=a.custom_metadata)==null?void 0:s.tenant_id)!==e)throw new H(404)}const n=await Y(r).delete(`/custom_hostnames/${encodeURIComponent(t)}`).res();return n.ok&&await r.customDomainAdapter.remove(e,t),n.ok},update:async(e,t,n)=>{const s=await Y(r).patch(n,`/custom_hostnames/${encodeURIComponent(t)}`).res();if(!s.ok)throw new H(503,{message:await s.text()});return r.customDomainAdapter.update(e,t,n)}}}function Nr(r){return{customDomains:Cr(r)}}module.exports=Nr;
@@ -133,9 +133,106 @@ declare const customDomainSchema: z.ZodObject<{
133
133
  } | undefined;
134
134
  }>;
135
135
  export type CustomDomain = z.infer<typeof customDomainSchema>;
136
+ declare const customDomainWithTenantIdSchema: z.ZodObject<z.objectUtil.extendShape<{
137
+ custom_domain_id: z.ZodString;
138
+ primary: z.ZodBoolean;
139
+ status: z.ZodEnum<[
140
+ "disabled",
141
+ "pending",
142
+ "pending_verification",
143
+ "ready"
144
+ ]>;
145
+ origin_domain_name: z.ZodOptional<z.ZodString>;
146
+ verification: z.ZodOptional<z.ZodObject<{
147
+ methods: z.ZodArray<z.ZodObject<{
148
+ name: z.ZodLiteral<"txt">;
149
+ record: z.ZodString;
150
+ domain: z.ZodString;
151
+ }, "strip", z.ZodTypeAny, {
152
+ name: "txt";
153
+ domain: string;
154
+ record: string;
155
+ }, {
156
+ name: "txt";
157
+ domain: string;
158
+ record: string;
159
+ }>, "many">;
160
+ }, "strip", z.ZodTypeAny, {
161
+ methods: {
162
+ name: "txt";
163
+ domain: string;
164
+ record: string;
165
+ }[];
166
+ }, {
167
+ methods: {
168
+ name: "txt";
169
+ domain: string;
170
+ record: string;
171
+ }[];
172
+ }>>;
173
+ tls_policy: z.ZodOptional<z.ZodString>;
174
+ domain: z.ZodString;
175
+ type: z.ZodEnum<[
176
+ "auth0_managed_certs",
177
+ "self_managed_certs"
178
+ ]>;
179
+ verification_method: z.ZodOptional<z.ZodEnum<[
180
+ "txt"
181
+ ]>>;
182
+ custom_client_ip_header: z.ZodOptional<z.ZodEnum<[
183
+ "true-client-ip",
184
+ "cf-connecting-ip",
185
+ "x-forwarded-for",
186
+ "x-azure-clientip",
187
+ "null"
188
+ ]>>;
189
+ domain_metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
190
+ }, {
191
+ tenant_id: z.ZodString;
192
+ }>, "strip", z.ZodTypeAny, {
193
+ type: "auth0_managed_certs" | "self_managed_certs";
194
+ status: "disabled" | "pending" | "pending_verification" | "ready";
195
+ primary: boolean;
196
+ domain: string;
197
+ custom_domain_id: string;
198
+ tenant_id: string;
199
+ verification_method?: "txt" | undefined;
200
+ tls_policy?: string | undefined;
201
+ custom_client_ip_header?: "null" | "true-client-ip" | "cf-connecting-ip" | "x-forwarded-for" | "x-azure-clientip" | undefined;
202
+ domain_metadata?: Record<string, string> | undefined;
203
+ origin_domain_name?: string | undefined;
204
+ verification?: {
205
+ methods: {
206
+ name: "txt";
207
+ domain: string;
208
+ record: string;
209
+ }[];
210
+ } | undefined;
211
+ }, {
212
+ type: "auth0_managed_certs" | "self_managed_certs";
213
+ status: "disabled" | "pending" | "pending_verification" | "ready";
214
+ primary: boolean;
215
+ domain: string;
216
+ custom_domain_id: string;
217
+ tenant_id: string;
218
+ verification_method?: "txt" | undefined;
219
+ tls_policy?: string | undefined;
220
+ custom_client_ip_header?: "null" | "true-client-ip" | "cf-connecting-ip" | "x-forwarded-for" | "x-azure-clientip" | undefined;
221
+ domain_metadata?: Record<string, string> | undefined;
222
+ origin_domain_name?: string | undefined;
223
+ verification?: {
224
+ methods: {
225
+ name: "txt";
226
+ domain: string;
227
+ record: string;
228
+ }[];
229
+ } | undefined;
230
+ }>;
231
+ export type CustomDomainWithTenantId = z.infer<typeof customDomainWithTenantIdSchema>;
136
232
  export interface CustomDomainsAdapter {
137
233
  create: (tenant_id: string, custom_domain: CustomDomainInsert) => Promise<CustomDomain>;
138
234
  get: (tenant_id: string, id: string) => Promise<CustomDomain | null>;
235
+ getByDomain: (domain: string) => Promise<CustomDomainWithTenantId | null>;
139
236
  list: (tenant_id: string) => Promise<CustomDomain[]>;
140
237
  remove: (tenant_id: string, id: string) => Promise<boolean>;
141
238
  update: (tenant_id: string, id: string, custom_domain: Partial<CustomDomain>) => Promise<boolean>;
@@ -3139,6 +3139,7 @@ function Cr(r) {
3139
3139
  throw new H(404);
3140
3140
  return ze({ ...n, ...a });
3141
3141
  },
3142
+ getByDomain: async (e) => r.customDomainAdapter.getByDomain(e),
3142
3143
  list: async (e) => {
3143
3144
  const t = await r.customDomainAdapter.list(e), n = await Y(r).get("/custom_hostnames").json(), { result: s, errors: a, success: i } = Er.parse(n);
3144
3145
  if (!i)
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "type": "git",
12
12
  "url": "https://github.com/markusahlstrand/authhero"
13
13
  },
14
- "version": "1.4.0",
14
+ "version": "1.5.0",
15
15
  "files": [
16
16
  "dist"
17
17
  ],
@@ -26,7 +26,6 @@
26
26
  }
27
27
  },
28
28
  "devDependencies": {
29
- "@authhero/kysely-adapter": "^10.5.0",
30
29
  "@hono/zod-openapi": "^0.18.0",
31
30
  "@rollup/plugin-commonjs": "^28.0.1",
32
31
  "@rollup/plugin-node-resolve": "^15.3.0",
@@ -39,12 +38,13 @@
39
38
  "typescript": "^5.6.3",
40
39
  "vite": "^5.4.11",
41
40
  "vitest": "^2.1.5",
42
- "@authhero/adapter-interfaces": "0.54.0"
41
+ "@authhero/adapter-interfaces": "0.55.0",
42
+ "@authhero/kysely-adapter": "10.1.0"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "@hono/zod-openapi": "^0.18.0",
46
46
  "hono": "^4.6.8",
47
- "@authhero/adapter-interfaces": "0.54.0"
47
+ "@authhero/adapter-interfaces": "0.55.0"
48
48
  },
49
49
  "dependencies": {
50
50
  "wretch": "^2.11.0"