@authhero/cloudflare-adapter 2.16.0 → 2.17.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,30 +1,52 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const gt=require("@authhero/adapter-interfaces"),vt=require("wretch");function bt(t,e){var n={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(n[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,s=Object.getOwnPropertySymbols(t);r<s.length;r++)e.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(t,s[r])&&(n[s[r]]=t[s[r]]);return n}function xt(t,e){var n;return((n=t?._def)===null||n===void 0?void 0:n.typeName)===e}function ue(t,e){const n=t.ZodType.prototype[e];t.ZodType.prototype[e]=function(...s){const r=n.apply(this,s);return r._def.openapi=this._def.openapi,r}}function kt(t){if(typeof t.ZodType.prototype.openapi<"u")return;t.ZodType.prototype.openapi=function(r,a){var i,o,c,d,h,x;const T=typeof r=="string"?a:r,w=T??{},{param:N}=w,te=bt(w,["param"]),O=Object.assign(Object.assign({},(i=this._def.openapi)===null||i===void 0?void 0:i._internal),typeof r=="string"?{refId:r}:void 0),V=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),te),!((d=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||d===void 0)&&d.param||N?{param:Object.assign(Object.assign({},(x=(h=this._def.openapi)===null||h===void 0?void 0:h.metadata)===null||x===void 0?void 0:x.param),N)}:void 0),E=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(O).length>0?{_internal:O}:void 0),Object.keys(V).length>0?{metadata:V}:void 0)}));if(xt(this,"ZodObject")){const P=this.extend;E.extend=function(...H){var Y,de,Le,De,Ve,ze,Be;const Fe=P.apply(this,H);return Fe._def.openapi={_internal:{extendedFrom:!((de=(Y=this._def.openapi)===null||Y===void 0?void 0:Y._internal)===null||de===void 0)&&de.refId?{refId:(De=(Le=this._def.openapi)===null||Le===void 0?void 0:Le._internal)===null||De===void 0?void 0:De.refId,schema:this}:(ze=(Ve=this._def.openapi)===null||Ve===void 0?void 0:Ve._internal)===null||ze===void 0?void 0:ze.extendedFrom},metadata:(Be=Fe._def.openapi)===null||Be===void 0?void 0:Be.metadata},Fe}}return E},ue(t,"optional"),ue(t,"nullable"),ue(t,"default"),ue(t,"transform"),ue(t,"refine");const e=t.ZodObject.prototype.deepPartial;t.ZodObject.prototype.deepPartial=function(){const r=this._def.shape(),a=e.apply(this),i=a._def.shape();return Object.entries(i).forEach(([o,c])=>{var d,h;c._def.openapi=(h=(d=r[o])===null||d===void 0?void 0:d._def)===null||h===void 0?void 0:h.openapi}),a._def.openapi=void 0,a};const n=t.ZodObject.prototype.pick;t.ZodObject.prototype.pick=function(...r){const a=n.apply(this,r);return a._def.openapi=void 0,a};const s=t.ZodObject.prototype.omit;t.ZodObject.prototype.omit=function(...r){const a=s.apply(this,r);return a._def.openapi=void 0,a}}var le=class extends Error{res;status;constructor(t=500,e){super(e?.message,{cause:e?.cause}),this.res=e?.res,this.status=t}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 b;(function(t){t.assertEqual=r=>{};function e(r){}t.assertIs=e;function n(r){throw new Error}t.assertNever=n,t.arrayToEnum=r=>{const a={};for(const i of r)a[i]=i;return a},t.getValidEnumValues=r=>{const a=t.objectKeys(r).filter(o=>typeof r[r[o]]!="number"),i={};for(const o of a)i[o]=r[o];return t.objectValues(i)},t.objectValues=r=>t.objectKeys(r).map(function(a){return r[a]}),t.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const a=[];for(const i in r)Object.prototype.hasOwnProperty.call(r,i)&&a.push(i);return a},t.find=(r,a)=>{for(const i of r)if(a(i))return i},t.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function s(r,a=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}t.joinValues=s,t.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(b||(b={}));var We;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(We||(We={}));const f=b.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),B=t=>{switch(typeof t){case"undefined":return f.undefined;case"string":return f.string;case"number":return Number.isNaN(t)?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(t)?f.array:t===null?f.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?f.promise:typeof Map<"u"&&t instanceof Map?f.map:typeof Set<"u"&&t instanceof Set?f.set:typeof Date<"u"&&t instanceof Date?f.date:f.object;default:return f.unknown}},u=b.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),wt=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class A extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(a){return a.message},s={_errors:[]},r=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(i.argumentsError);else if(i.path.length===0)s._errors.push(n(i));else{let o=s,c=0;for(;c<i.path.length;){const d=i.path[c];c===i.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(n(i))):o[d]=o[d]||{_errors:[]},o=o[d],c++}}};return r(this),s}static assert(e){if(!(e instanceof A))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,b.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},s=[];for(const r of this.issues)if(r.path.length>0){const a=r.path[0];n[a]=n[a]||[],n[a].push(e(r))}else s.push(e(r));return{formErrors:s,fieldErrors:n}}get formErrors(){return this.flatten()}}A.create=t=>new A(t);const ie=(t,e)=>{let n;switch(t.code){case u.invalid_type:t.received===f.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case u.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,b.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:n=`Unrecognized key(s) in object: ${b.joinValues(t.keys,", ")}`;break;case u.invalid_union:n="Invalid input";break;case u.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${b.joinValues(t.options)}`;break;case u.invalid_enum_value:n=`Invalid enum value. Expected ${b.joinValues(t.options)}, received '${t.received}'`;break;case u.invalid_arguments:n="Invalid function arguments";break;case u.invalid_return_type:n="Invalid function return type";break;case u.invalid_date:n="Invalid date";break;case u.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:b.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case u.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case u.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case u.custom:n="Invalid input";break;case u.invalid_intersection_types:n="Intersection results could not be merged";break;case u.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case u.not_finite:n="Number must be finite";break;default:n=e.defaultError,b.assertNever(t)}return{message:n}};let rt=ie;function Tt(t){rt=t}function Ee(){return rt}const Ae=t=>{const{data:e,path:n,errorMaps:s,issueData:r}=t,a=[...n,...r.path||[]],i={...r,path:a};if(r.message!==void 0)return{...r,path:a,message:r.message};let o="";const c=s.filter(d=>!!d).slice().reverse();for(const d of c)o=d(i,{data:e,defaultError:o}).message;return{...r,path:a,message:o}},St=[];function l(t,e){const n=Ee(),s=Ae({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===ie?void 0:ie].filter(r=>!!r)});t.common.issues.push(s)}class S{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const s=[];for(const r of n){if(r.status==="aborted")return m;r.status==="dirty"&&e.dirty(),s.push(r.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,n){const s=[];for(const r of n){const a=await r.key,i=await r.value;s.push({key:a,value:i})}return S.mergeObjectSync(e,s)}static mergeObjectSync(e,n){const s={};for(const r of n){const{key:a,value:i}=r;if(a.status==="aborted"||i.status==="aborted")return m;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||r.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}}const m=Object.freeze({status:"aborted"}),re=t=>({status:"dirty",value:t}),C=t=>({status:"valid",value:t}),Je=t=>t.status==="aborted",Qe=t=>t.status==="dirty",K=t=>t.status==="valid",fe=t=>typeof Promise<"u"&&t instanceof Promise;var p;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(p||(p={}));class L{constructor(e,n,s,r){this._cachedPath=[],this.parent=e,this.data=n,this._path=s,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const tt=(t,e)=>{if(K(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new A(t.common.issues);return this._error=n,this._error}}};function _(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:s,description:r}=t;if(e&&(n||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(i,o)=>{const{message:c}=t;return i.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??s??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:c??n??o.defaultError}},description:r}}class v{get description(){return this._def.description}_getType(e){return B(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:B(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new S,ctx:{common:e.parent.common,data:e.data,parsedType:B(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(fe(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const s=this.safeParse(e,n);if(s.success)return s.data;throw s.error}safeParse(e,n){const s={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:B(e)},r=this._parseSync({data:e,path:s.path,parent:s});return tt(s,r)}"~validate"(e){const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:B(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:n});return K(s)?{value:s.value}:{issues:n.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(s=>K(s)?{value:s.value}:{issues:n.common.issues})}async parseAsync(e,n){const s=await this.safeParseAsync(e,n);if(s.success)return s.data;throw s.error}async safeParseAsync(e,n){const s={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:B(e)},r=this._parse({data:e,path:s.path,parent:s}),a=await(fe(r)?r:Promise.resolve(r));return tt(s,a)}refine(e,n){const s=r=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(r):n;return this._refinement((r,a)=>{const i=e(r),o=()=>a.addIssue({code:u.custom,...s(r)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,n){return this._refinement((s,r)=>e(s)?!0:(r.addIssue(typeof n=="function"?n(s,r):n),!1))}_refinement(e){return new I({schema:this,typeName:y.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return M.create(this,this._def)}nullable(){return Q.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return j.create(this)}promise(){return ce.create(this,this._def)}or(e){return ye.create([this,e],this._def)}and(e){return _e.create(this,e,this._def)}transform(e){return new I({..._(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new ke({..._(this._def),innerType:this,defaultValue:n,typeName:y.ZodDefault})}brand(){return new Xe({typeName:y.ZodBranded,type:this,..._(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new we({..._(this._def),innerType:this,catchValue:n,typeName:y.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Se.create(this,e)}readonly(){return Te.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ct=/^c[^\s-]{8,}$/i,Ot=/^[0-9a-z]+$/,Et=/^[0-9A-HJKMNP-TV-Z]{26}$/i,At=/^[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,Rt=/^[a-z0-9_-]{21}$/i,Nt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,$t=/^[-+]?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)?)??$/,jt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,It="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let qe;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])$/,Pt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Mt=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Lt=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Dt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Vt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,at="((\\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])))",zt=new RegExp(`^${at}$`);function it(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function Bt(t){return new RegExp(`^${it(t)}$`)}function ot(t){let e=`${at}T${it(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Ft(t,e){return!!((e==="v4"||!e)&&Zt.test(t)||(e==="v6"||!e)&&Mt.test(t))}function qt(t,e){if(!Nt.test(t))return!1;try{const[n]=t.split(".");if(!n)return!1;const s=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),r=JSON.parse(atob(s));return!(typeof r!="object"||r===null||"typ"in r&&r?.typ!=="JWT"||!r.alg||e&&r.alg!==e)}catch{return!1}}function Ut(t,e){return!!((e==="v4"||!e)&&Pt.test(t)||(e==="v6"||!e)&&Lt.test(t))}class $ extends v{_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}),m}const s=new S;let r;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(r=this._getOrReturnCtx(e,r),l(r,{code:u.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="max")e.data.length>a.value&&(r=this._getOrReturnCtx(e,r),l(r,{code:u.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(r=this._getOrReturnCtx(e,r),i?l(r,{code:u.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&l(r,{code:u.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty())}else if(a.kind==="email")jt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"email",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")qe||(qe=new RegExp(It,"u")),qe.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"emoji",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")At.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"uuid",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")Rt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"nanoid",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")Ct.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"cuid",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")Ot.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"cuid2",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")Et.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"ulid",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),l(r,{validation:"url",code:u.invalid_string,message:a.message}),s.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"regex",code:u.invalid_string,message:a.message}),s.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(r=this._getOrReturnCtx(e,r),l(r,{code:u.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),s.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(r=this._getOrReturnCtx(e,r),l(r,{code:u.invalid_string,validation:{startsWith:a.value},message:a.message}),s.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(r=this._getOrReturnCtx(e,r),l(r,{code:u.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?ot(a).test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:u.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?zt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:u.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?Bt(a).test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:u.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?$t.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"duration",code:u.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?Ft(e.data,a.version)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"ip",code:u.invalid_string,message:a.message}),s.dirty()):a.kind==="jwt"?qt(e.data,a.alg)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"jwt",code:u.invalid_string,message:a.message}),s.dirty()):a.kind==="cidr"?Ut(e.data,a.version)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"cidr",code:u.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?Dt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"base64",code:u.invalid_string,message:a.message}),s.dirty()):a.kind==="base64url"?Vt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"base64url",code:u.invalid_string,message:a.message}),s.dirty()):b.assertNever(a);return{status:s.value,value:e.data}}_regex(e,n,s){return this.refinement(r=>e.test(r),{validation:n,code:u.invalid_string,...p.errToObj(s)})}_addCheck(e){return new $({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...p.errToObj(e)})}url(e){return this._addCheck({kind:"url",...p.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...p.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...p.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...p.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...p.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...p.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...p.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...p.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...p.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...p.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...p.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...p.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...p.errToObj(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?.precision>"u"?null:e?.precision,...p.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...p.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...p.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...p.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...p.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...p.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...p.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...p.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...p.errToObj(n)})}nonempty(e){return this.min(1,p.errToObj(e))}trim(){return new $({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new $({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new $({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}$.create=t=>new $({checks:[],typeName:y.ZodString,coerce:t?.coerce??!1,..._(t)});function Wt(t,e){const n=(t.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,r=n>s?n:s,a=Number.parseInt(t.toFixed(r).replace(".","")),i=Number.parseInt(e.toFixed(r).replace(".",""));return a%i/10**r}class U extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){const a=this._getOrReturnCtx(e);return l(a,{code:u.invalid_type,expected:f.number,received:a.parsedType}),m}let s;const r=new S;for(const a of this._def.checks)a.kind==="int"?b.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:u.invalid_type,expected:"integer",received:"float",message:a.message}),r.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:u.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:u.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="multipleOf"?Wt(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),l(s,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:u.not_finite,message:a.message}),r.dirty()):b.assertNever(a);return{status:r.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,p.toString(n))}gt(e,n){return this.setLimit("min",e,!1,p.toString(n))}lte(e,n){return this.setLimit("max",e,!0,p.toString(n))}lt(e,n){return this.setLimit("max",e,!1,p.toString(n))}setLimit(e,n,s,r){return new U({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:s,message:p.toString(r)}]})}_addCheck(e){return new U({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:p.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:p.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:p.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:p.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:p.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&b.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(n===null||s.value>n)&&(n=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(n)&&Number.isFinite(e)}}U.create=t=>new U({checks:[],typeName:y.ZodNumber,coerce:t?.coerce||!1,..._(t)});class W extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==f.bigint)return this._getInvalidInput(e);let s;const r=new S;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:u.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:u.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),l(s,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):b.assertNever(a);return{status:r.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:f.bigint,received:n.parsedType}),m}gte(e,n){return this.setLimit("min",e,!0,p.toString(n))}gt(e,n){return this.setLimit("min",e,!1,p.toString(n))}lte(e,n){return this.setLimit("max",e,!0,p.toString(n))}lt(e,n){return this.setLimit("max",e,!1,p.toString(n))}setLimit(e,n,s,r){return new W({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:s,message:p.toString(r)}]})}_addCheck(e){return new W({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:p.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}W.create=t=>new W({checks:[],typeName:y.ZodBigInt,coerce:t?.coerce??!1,..._(t)});class he extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){const s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:f.boolean,received:s.parsedType}),m}return C(e.data)}}he.create=t=>new he({typeName:y.ZodBoolean,coerce:t?.coerce||!1,..._(t)});class X extends v{_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}),m}if(Number.isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return l(a,{code:u.invalid_date}),m}const s=new S;let r;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(r=this._getOrReturnCtx(e,r),l(r,{code:u.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),s.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(r=this._getOrReturnCtx(e,r),l(r,{code:u.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):b.assertNever(a);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new X({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:p.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:p.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}X.create=t=>new X({checks:[],coerce:t?.coerce||!1,typeName:y.ZodDate,..._(t)});class Re extends v{_parse(e){if(this._getType(e)!==f.symbol){const s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:f.symbol,received:s.parsedType}),m}return C(e.data)}}Re.create=t=>new Re({typeName:y.ZodSymbol,..._(t)});class pe extends v{_parse(e){if(this._getType(e)!==f.undefined){const s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:f.undefined,received:s.parsedType}),m}return C(e.data)}}pe.create=t=>new pe({typeName:y.ZodUndefined,..._(t)});class me extends v{_parse(e){if(this._getType(e)!==f.null){const s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:f.null,received:s.parsedType}),m}return C(e.data)}}me.create=t=>new me({typeName:y.ZodNull,..._(t)});class oe extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return C(e.data)}}oe.create=t=>new oe({typeName:y.ZodAny,..._(t)});class G extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return C(e.data)}}G.create=t=>new G({typeName:y.ZodUnknown,..._(t)});class F extends v{_parse(e){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:f.never,received:n.parsedType}),m}}F.create=t=>new F({typeName:y.ZodNever,..._(t)});class Ne extends v{_parse(e){if(this._getType(e)!==f.undefined){const s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:f.void,received:s.parsedType}),m}return C(e.data)}}Ne.create=t=>new Ne({typeName:y.ZodVoid,..._(t)});class j extends v{_parse(e){const{ctx:n,status:s}=this._processInputParams(e),r=this._def;if(n.parsedType!==f.array)return l(n,{code:u.invalid_type,expected:f.array,received:n.parsedType}),m;if(r.exactLength!==null){const i=n.data.length>r.exactLength.value,o=n.data.length<r.exactLength.value;(i||o)&&(l(n,{code:i?u.too_big:u.too_small,minimum:o?r.exactLength.value:void 0,maximum:i?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),s.dirty())}if(r.minLength!==null&&n.data.length<r.minLength.value&&(l(n,{code:u.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),s.dirty()),r.maxLength!==null&&n.data.length>r.maxLength.value&&(l(n,{code:u.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),s.dirty()),n.common.async)return Promise.all([...n.data].map((i,o)=>r.type._parseAsync(new L(n,i,n.path,o)))).then(i=>S.mergeArray(s,i));const a=[...n.data].map((i,o)=>r.type._parseSync(new L(n,i,n.path,o)));return S.mergeArray(s,a)}get element(){return this._def.type}min(e,n){return new j({...this._def,minLength:{value:e,message:p.toString(n)}})}max(e,n){return new j({...this._def,maxLength:{value:e,message:p.toString(n)}})}length(e,n){return new j({...this._def,exactLength:{value:e,message:p.toString(n)}})}nonempty(e){return this.min(1,e)}}j.create=(t,e)=>new j({type:t,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,..._(e)});function se(t){if(t instanceof k){const e={};for(const n in t.shape){const s=t.shape[n];e[n]=M.create(se(s))}return new k({...t._def,shape:()=>e})}else return t instanceof j?new j({...t._def,type:se(t.element)}):t instanceof M?M.create(se(t.unwrap())):t instanceof Q?Q.create(se(t.unwrap())):t instanceof D?D.create(t.items.map(e=>se(e))):t}class k extends v{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),n=b.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==f.object){const d=this._getOrReturnCtx(e);return l(d,{code:u.invalid_type,expected:f.object,received:d.parsedType}),m}const{status:s,ctx:r}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof F&&this._def.unknownKeys==="strip"))for(const d in r.data)i.includes(d)||o.push(d);const c=[];for(const d of i){const h=a[d],x=r.data[d];c.push({key:{status:"valid",value:d},value:h._parse(new L(r,x,r.path,d)),alwaysSet:d in r.data})}if(this._def.catchall instanceof F){const d=this._def.unknownKeys;if(d==="passthrough")for(const h of o)c.push({key:{status:"valid",value:h},value:{status:"valid",value:r.data[h]}});else if(d==="strict")o.length>0&&(l(r,{code:u.unrecognized_keys,keys:o}),s.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const h of o){const x=r.data[h];c.push({key:{status:"valid",value:h},value:d._parse(new L(r,x,r.path,h)),alwaysSet:h in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const d=[];for(const h of c){const x=await h.key,T=await h.value;d.push({key:x,value:T,alwaysSet:h.alwaysSet})}return d}).then(d=>S.mergeObjectSync(s,d)):S.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(e){return p.errToObj,new k({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,s)=>{const r=this._def.errorMap?.(n,s).message??s.defaultError;return n.code==="unrecognized_keys"?{message:p.errToObj(e).message??r}:{message:r}}}:{}})}strip(){return new k({...this._def,unknownKeys:"strip"})}passthrough(){return new k({...this._def,unknownKeys:"passthrough"})}extend(e){return new k({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new k({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:y.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new k({...this._def,catchall:e})}pick(e){const n={};for(const s of b.objectKeys(e))e[s]&&this.shape[s]&&(n[s]=this.shape[s]);return new k({...this._def,shape:()=>n})}omit(e){const n={};for(const s of b.objectKeys(this.shape))e[s]||(n[s]=this.shape[s]);return new k({...this._def,shape:()=>n})}deepPartial(){return se(this)}partial(e){const n={};for(const s of b.objectKeys(this.shape)){const r=this.shape[s];e&&!e[s]?n[s]=r:n[s]=r.optional()}return new k({...this._def,shape:()=>n})}required(e){const n={};for(const s of b.objectKeys(this.shape))if(e&&!e[s])n[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof M;)a=a._def.innerType;n[s]=a}return new k({...this._def,shape:()=>n})}keyof(){return ct(b.objectKeys(this.shape))}}k.create=(t,e)=>new k({shape:()=>t,unknownKeys:"strip",catchall:F.create(),typeName:y.ZodObject,..._(e)});k.strictCreate=(t,e)=>new k({shape:()=>t,unknownKeys:"strict",catchall:F.create(),typeName:y.ZodObject,..._(e)});k.lazycreate=(t,e)=>new k({shape:t,unknownKeys:"strip",catchall:F.create(),typeName:y.ZodObject,..._(e)});class ye extends v{_parse(e){const{ctx:n}=this._processInputParams(e),s=this._def.options;function r(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 n.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new A(o.ctx.common.issues));return l(n,{code:u.invalid_union,unionErrors:i}),m}if(n.common.async)return Promise.all(s.map(async a=>{const i={...n,common:{...n.common,issues:[]},parent:null};return{result:await a._parseAsync({data:n.data,path:n.path,parent:i}),ctx:i}})).then(r);{let a;const i=[];for(const c of s){const d={...n,common:{...n.common,issues:[]},parent:null},h=c._parseSync({data:n.data,path:n.path,parent:d});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:d}),d.common.issues.length&&i.push(d.common.issues)}if(a)return n.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new A(c));return l(n,{code:u.invalid_union,unionErrors:o}),m}}get options(){return this._def.options}}ye.create=(t,e)=>new ye({options:t,typeName:y.ZodUnion,..._(e)});const z=t=>t instanceof ve?z(t.schema):t instanceof I?z(t.innerType()):t instanceof be?[t.value]:t instanceof J?t.options:t instanceof xe?b.objectValues(t.enum):t instanceof ke?z(t._def.innerType):t instanceof pe?[void 0]:t instanceof me?[null]:t instanceof M?[void 0,...z(t.unwrap())]:t instanceof Q?[null,...z(t.unwrap())]:t instanceof Xe||t instanceof Te?z(t.unwrap()):t instanceof we?z(t._def.innerType):[];class Me extends v{_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==f.object)return l(n,{code:u.invalid_type,expected:f.object,received:n.parsedType}),m;const s=this.discriminator,r=n.data[s],a=this.optionsMap.get(r);return a?n.common.async?a._parseAsync({data:n.data,path:n.path,parent:n}):a._parseSync({data:n.data,path:n.path,parent:n}):(l(n,{code:u.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),m)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,s){const r=new Map;for(const a of n){const i=z(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(r.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);r.set(o,a)}}return new Me({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:r,..._(s)})}}function He(t,e){const n=B(t),s=B(e);if(t===e)return{valid:!0,data:t};if(n===f.object&&s===f.object){const r=b.objectKeys(e),a=b.objectKeys(t).filter(o=>r.indexOf(o)!==-1),i={...t,...e};for(const o of a){const c=He(t[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(n===f.array&&s===f.array){if(t.length!==e.length)return{valid:!1};const r=[];for(let a=0;a<t.length;a++){const i=t[a],o=e[a],c=He(i,o);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return n===f.date&&s===f.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class _e extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e),r=(a,i)=>{if(Je(a)||Je(i))return m;const o=He(a.value,i.value);return o.valid?((Qe(a)||Qe(i))&&n.dirty(),{status:n.value,value:o.data}):(l(s,{code:u.invalid_intersection_types}),m)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>r(a,i)):r(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}_e.create=(t,e,n)=>new _e({left:t,right:e,typeName:y.ZodIntersection,..._(n)});class D extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.array)return l(s,{code:u.invalid_type,expected:f.array,received:s.parsedType}),m;if(s.data.length<this._def.items.length)return l(s,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),m;!this._def.rest&&s.data.length>this._def.items.length&&(l(s,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const a=[...s.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new L(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(a).then(i=>S.mergeArray(n,i)):S.mergeArray(n,a)}get items(){return this._def.items}rest(e){return new D({...this._def,rest:e})}}D.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new D({items:t,typeName:y.ZodTuple,rest:null,..._(e)})};class ge extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.object)return l(s,{code:u.invalid_type,expected:f.object,received:s.parsedType}),m;const r=[],a=this._def.keyType,i=this._def.valueType;for(const o in s.data)r.push({key:a._parse(new L(s,o,s.path,o)),value:i._parse(new L(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?S.mergeObjectAsync(n,r):S.mergeObjectSync(n,r)}get element(){return this._def.valueType}static create(e,n,s){return n instanceof v?new ge({keyType:e,valueType:n,typeName:y.ZodRecord,..._(s)}):new ge({keyType:$.create(),valueType:e,typeName:y.ZodRecord,..._(n)})}}class $e extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.map)return l(s,{code:u.invalid_type,expected:f.map,received:s.parsedType}),m;const r=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,c],d)=>({key:r._parse(new L(s,o,s.path,[d,"key"])),value:a._parse(new L(s,c,s.path,[d,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const d=await c.key,h=await c.value;if(d.status==="aborted"||h.status==="aborted")return m;(d.status==="dirty"||h.status==="dirty")&&n.dirty(),o.set(d.value,h.value)}return{status:n.value,value:o}})}else{const o=new Map;for(const c of i){const d=c.key,h=c.value;if(d.status==="aborted"||h.status==="aborted")return m;(d.status==="dirty"||h.status==="dirty")&&n.dirty(),o.set(d.value,h.value)}return{status:n.value,value:o}}}}$e.create=(t,e,n)=>new $e({valueType:e,keyType:t,typeName:y.ZodMap,..._(n)});class ee extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.set)return l(s,{code:u.invalid_type,expected:f.set,received:s.parsedType}),m;const r=this._def;r.minSize!==null&&s.data.size<r.minSize.value&&(l(s,{code:u.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),n.dirty()),r.maxSize!==null&&s.data.size>r.maxSize.value&&(l(s,{code:u.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),n.dirty());const a=this._def.valueType;function i(c){const d=new Set;for(const h of c){if(h.status==="aborted")return m;h.status==="dirty"&&n.dirty(),d.add(h.value)}return{status:n.value,value:d}}const o=[...s.data.values()].map((c,d)=>a._parse(new L(s,c,s.path,d)));return s.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,n){return new ee({...this._def,minSize:{value:e,message:p.toString(n)}})}max(e,n){return new ee({...this._def,maxSize:{value:e,message:p.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}ee.create=(t,e)=>new ee({valueType:t,minSize:null,maxSize:null,typeName:y.ZodSet,..._(e)});class ae extends v{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==f.function)return l(n,{code:u.invalid_type,expected:f.function,received:n.parsedType}),m;function s(o,c){return Ae({data:o,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Ee(),ie].filter(d=>!!d),issueData:{code:u.invalid_arguments,argumentsError:c}})}function r(o,c){return Ae({data:o,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Ee(),ie].filter(d=>!!d),issueData:{code:u.invalid_return_type,returnTypeError:c}})}const a={errorMap:n.common.contextualErrorMap},i=n.data;if(this._def.returns instanceof ce){const o=this;return C(async function(...c){const d=new A([]),h=await o._def.args.parseAsync(c,a).catch(w=>{throw d.addIssue(s(c,w)),d}),x=await Reflect.apply(i,this,h);return await o._def.returns._def.type.parseAsync(x,a).catch(w=>{throw d.addIssue(r(x,w)),d})})}else{const o=this;return C(function(...c){const d=o._def.args.safeParse(c,a);if(!d.success)throw new A([s(c,d.error)]);const h=Reflect.apply(i,this,d.data),x=o._def.returns.safeParse(h,a);if(!x.success)throw new A([r(h,x.error)]);return x.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ae({...this._def,args:D.create(e).rest(G.create())})}returns(e){return new ae({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,s){return new ae({args:e||D.create([]).rest(G.create()),returns:n||G.create(),typeName:y.ZodFunction,..._(s)})}}class ve extends v{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}ve.create=(t,e)=>new ve({getter:t,typeName:y.ZodLazy,..._(e)});class be extends v{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return l(n,{received:n.data,code:u.invalid_literal,expected:this._def.value}),m}return{status:"valid",value:e.data}}get value(){return this._def.value}}be.create=(t,e)=>new be({value:t,typeName:y.ZodLiteral,..._(e)});function ct(t,e){return new J({values:t,typeName:y.ZodEnum,..._(e)})}class J extends v{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),s=this._def.values;return l(n,{expected:b.joinValues(s),received:n.parsedType,code:u.invalid_type}),m}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const n=this._getOrReturnCtx(e),s=this._def.values;return l(n,{received:n.data,code:u.invalid_enum_value,options:s}),m}return C(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return J.create(e,{...this._def,...n})}exclude(e,n=this._def){return J.create(this.options.filter(s=>!e.includes(s)),{...this._def,...n})}}J.create=ct;class xe extends v{_parse(e){const n=b.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==f.string&&s.parsedType!==f.number){const r=b.objectValues(n);return l(s,{expected:b.joinValues(r),received:s.parsedType,code:u.invalid_type}),m}if(this._cache||(this._cache=new Set(b.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const r=b.objectValues(n);return l(s,{received:s.data,code:u.invalid_enum_value,options:r}),m}return C(e.data)}get enum(){return this._def.values}}xe.create=(t,e)=>new xe({values:t,typeName:y.ZodNativeEnum,..._(e)});class ce extends v{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==f.promise&&n.common.async===!1)return l(n,{code:u.invalid_type,expected:f.promise,received:n.parsedType}),m;const s=n.parsedType===f.promise?n.data:Promise.resolve(n.data);return C(s.then(r=>this._def.type.parseAsync(r,{path:n.path,errorMap:n.common.contextualErrorMap})))}}ce.create=(t,e)=>new ce({type:t,typeName:y.ZodPromise,..._(e)});class I extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:s}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:i=>{l(s,i),i.fatal?n.abort():n.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const i=r.transform(s.data,a);if(s.common.async)return Promise.resolve(i).then(async o=>{if(n.value==="aborted")return m;const c=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return c.status==="aborted"?m:c.status==="dirty"||n.value==="dirty"?re(c.value):c});{if(n.value==="aborted")return m;const o=this._def.schema._parseSync({data:i,path:s.path,parent:s});return o.status==="aborted"?m:o.status==="dirty"||n.value==="dirty"?re(o.value):o}}if(r.type==="refinement"){const i=o=>{const c=r.refinement(o,a);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?m:(o.status==="dirty"&&n.dirty(),i(o.value),{status:n.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?m:(o.status==="dirty"&&n.dirty(),i(o.value).then(()=>({status:n.value,value:o.value}))))}if(r.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!K(i))return m;const o=r.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>K(i)?Promise.resolve(r.transform(i.value,a)).then(o=>({status:n.value,value:o})):m);b.assertNever(r)}}I.create=(t,e,n)=>new I({schema:t,typeName:y.ZodEffects,effect:e,..._(n)});I.createWithPreprocess=(t,e,n)=>new I({schema:e,effect:{type:"preprocess",transform:t},typeName:y.ZodEffects,..._(n)});class M extends v{_parse(e){return this._getType(e)===f.undefined?C(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}M.create=(t,e)=>new M({innerType:t,typeName:y.ZodOptional,..._(e)});class Q extends v{_parse(e){return this._getType(e)===f.null?C(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Q.create=(t,e)=>new Q({innerType:t,typeName:y.ZodNullable,..._(e)});class ke extends v{_parse(e){const{ctx:n}=this._processInputParams(e);let s=n.data;return n.parsedType===f.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}ke.create=(t,e)=>new ke({innerType:t,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});class we extends v{_parse(e){const{ctx:n}=this._processInputParams(e),s={...n,common:{...n.common,issues:[]}},r=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return fe(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new A(s.common.issues)},input:s.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new A(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}we.create=(t,e)=>new we({innerType:t,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});class je extends v{_parse(e){if(this._getType(e)!==f.nan){const s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:f.nan,received:s.parsedType}),m}return{status:"valid",value:e.data}}}je.create=t=>new je({typeName:y.ZodNaN,..._(t)});const Jt=Symbol("zod_brand");class Xe extends v{_parse(e){const{ctx:n}=this._processInputParams(e),s=n.data;return this._def.type._parse({data:s,path:n.path,parent:n})}unwrap(){return this._def.type}}class Se extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?m:a.status==="dirty"?(n.dirty(),re(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})})();{const r=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?m:r.status==="dirty"?(n.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:s.path,parent:s})}}static create(e,n){return new Se({in:e,out:n,typeName:y.ZodPipeline})}}class Te extends v{_parse(e){const n=this._def.innerType._parse(e),s=r=>(K(r)&&(r.value=Object.freeze(r.value)),r);return fe(n)?n.then(r=>s(r)):s(n)}unwrap(){return this._def.innerType}}Te.create=(t,e)=>new Te({innerType:t,typeName:y.ZodReadonly,..._(e)});function nt(t,e){const n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function dt(t,e={},n){return t?oe.create().superRefine((s,r)=>{const a=t(s);if(a instanceof Promise)return a.then(i=>{if(!i){const o=nt(e,s),c=o.fatal??n??!0;r.addIssue({code:"custom",...o,fatal:c})}});if(!a){const i=nt(e,s),o=i.fatal??n??!0;r.addIssue({code:"custom",...i,fatal:o})}}):oe.create()}const Qt={object:k.lazycreate};var y;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(y||(y={}));const Ht=(t,e={message:`Input not instance of ${t.name}`})=>dt(n=>n instanceof t,e),g=$.create,et=U.create,Yt=je.create,Gt=W.create,Ce=he.create,Kt=X.create,Xt=Re.create,en=pe.create,tn=me.create,nn=oe.create,sn=G.create,rn=F.create,an=Ne.create,R=j.create,Z=k.create,on=k.strictCreate,cn=ye.create,dn=Me.create,un=_e.create,ln=D.create,ut=ge.create,fn=$e.create,hn=ee.create,pn=ae.create,mn=ve.create,yn=be.create,_n=J.create,gn=xe.create,vn=ce.create,st=I.create,bn=M.create,xn=Q.create,kn=I.createWithPreprocess,wn=Se.create,Tn=()=>g().optional(),Sn=()=>et().optional(),Cn=()=>Ce().optional(),On={string:(t=>$.create({...t,coerce:!0})),number:(t=>U.create({...t,coerce:!0})),boolean:(t=>he.create({...t,coerce:!0})),bigint:(t=>W.create({...t,coerce:!0})),date:(t=>X.create({...t,coerce:!0}))},En=m,An=Object.freeze(Object.defineProperty({__proto__:null,BRAND:Jt,DIRTY:re,EMPTY_PATH:St,INVALID:m,NEVER:En,OK:C,ParseStatus:S,Schema:v,ZodAny:oe,ZodArray:j,ZodBigInt:W,ZodBoolean:he,ZodBranded:Xe,ZodCatch:we,ZodDate:X,ZodDefault:ke,ZodDiscriminatedUnion:Me,ZodEffects:I,ZodEnum:J,ZodError:A,get ZodFirstPartyTypeKind(){return y},ZodFunction:ae,ZodIntersection:_e,ZodIssueCode:u,ZodLazy:ve,ZodLiteral:be,ZodMap:$e,ZodNaN:je,ZodNativeEnum:xe,ZodNever:F,ZodNull:me,ZodNullable:Q,ZodNumber:U,ZodObject:k,ZodOptional:M,ZodParsedType:f,ZodPipeline:Se,ZodPromise:ce,ZodReadonly:Te,ZodRecord:ge,ZodSchema:v,ZodSet:ee,ZodString:$,ZodSymbol:Re,ZodTransformer:I,ZodTuple:D,ZodType:v,ZodUndefined:pe,ZodUnion:ye,ZodUnknown:G,ZodVoid:Ne,addIssueToContext:l,any:nn,array:R,bigint:Gt,boolean:Ce,coerce:On,custom:dt,date:Kt,datetimeRegex:ot,defaultErrorMap:ie,discriminatedUnion:dn,effect:st,enum:_n,function:pn,getErrorMap:Ee,getParsedType:B,instanceof:Ht,intersection:un,isAborted:Je,isAsync:fe,isDirty:Qe,isValid:K,late:Qt,lazy:mn,literal:yn,makeIssue:Ae,map:fn,nan:Yt,nativeEnum:gn,never:rn,null:tn,nullable:xn,number:et,object:Z,get objectUtil(){return We},oboolean:Cn,onumber:Sn,optional:bn,ostring:Tn,pipeline:wn,preprocess:kn,promise:vn,quotelessJson:wt,record:ut,set:hn,setErrorMap:Tt,strictObject:on,string:g,symbol:Xt,transformer:st,tuple:ln,undefined:en,union:cn,unknown:sn,get util(){return b},void:an},Symbol.toStringTag,{value:"Module"}));kt(An);const Rn=(t,e)=>e.skipDedupe||e.method!=="GET",Nn=(t,e)=>e.method+"@"+t,$n=t=>t.clone(),jn=({skip:t=Rn,key:e=Nn,resolver:n=$n}={})=>{const s=new Map;return r=>(a,i)=>{if(t(a,i))return r(a,i);const o=e(a,i);if(!s.has(o))s.set(o,[]);else return new Promise((c,d)=>{s.get(o).push([c,d])});try{return r(a,i).then(c=>(s.get(o).forEach(([d])=>d(n(c))),s.delete(o),c)).catch(c=>{throw s.get(o).forEach(([,d])=>d(c)),s.delete(o),c})}catch(c){return s.delete(o),Promise.reject(c)}}},In=(t,e)=>t*e,Zn=t=>t&&(t.ok||t.status>=400&&t.status<500),Pn=({delayTimer:t=500,delayRamp:e=In,maxAttempts:n=10,until:s=Zn,onRetry:r=null,retryOnNetworkError:a=!1,resolveWithLatestResponse:i=!1,skip:o}={})=>c=>(d,h)=>{let x=0;if(o&&o(d,h))return c(d,h);const T=(w,N)=>Promise.resolve(s(w,N)).then(te=>te?w&&i?w:N?Promise.reject(N):w:(x++,!n||x<=n?new Promise(O=>{const V=e(t,x);setTimeout(()=>{typeof r=="function"?Promise.resolve(r({response:w,error:N,url:d,attempt:x,options:h})).then((E={})=>{var P,H;O(c((P=E&&E.url)!==null&&P!==void 0?P:d,(H=E&&E.options)!==null&&H!==void 0?H:h))}):O(c(d,h))},V)}).then(T).catch(O=>{if(!a)throw O;return T(null,O)}):w&&i?w:Promise.reject(N||new Error("Number of attempts exceeded."))));return c(d,h).then(T).catch(w=>{if(!a)throw w;return T(null,w)})},Ie=Z({code:et(),message:g()}),Mn=Z({message:g()}),Ln=Z({emails:R(g()).optional(),http_body:g().optional(),http_url:g().optional(),txt_name:g().optional(),txt_value:g().optional()}),Dn=Z({ciphers:R(g()).optional(),early_hints:g().optional(),http2:g().optional(),min_tls_version:g().optional(),tls_1_3:g().optional()}),Vn=Z({id:g(),bundle_method:g().optional(),certificate_authority:g(),custom_certificate:g().optional(),custom_csr_id:g().optional(),custom_key:g().optional(),expires_on:g().optional(),hosts:R(g()).optional(),issuer:g().optional(),method:g(),serial_number:g().optional(),settings:Dn.optional(),signature:g().optional(),type:g(),uploaded_on:g().optional(),validation_errors:R(Mn).optional(),validation_records:R(Ln).optional(),wildcard:Ce()}),zn=Z({name:g(),type:g(),value:g()}),Bn=Z({http_body:g().optional(),http_url:g().optional()}),lt=Z({id:g(),ssl:Vn,hostname:g(),custom_metadata:ut(g()).optional(),custom_origin_server:g().optional(),custom_origin_sni:g().optional(),ownership_verification:zn.optional(),ownership_verification_http:Bn.optional(),status:g(),verification_errors:R(g()).optional(),created_at:g()}),Oe=Z({errors:R(Ie),messages:R(Ie),success:Ce(),result:lt});Z({errors:R(Ie),messages:R(Ie),success:Ce(),result:R(lt)});function ne(t){return vt(`https://api.cloudflare.com/client/v4/zones/${t.zoneId}`).headers({"X-Auth-Email":t.authEmail,"X-Auth-Key":t.authKey,"Content-Type":"application/json"}).middlewares([Pn(),jn()])}function Ue(t){const e=[];if(t.ssl.validation_records)for(const n of t.ssl.validation_records)n.txt_name&&n.txt_value&&e.push({name:"txt",record:n.txt_value,domain:n.txt_name});return t.ownership_verification&&e.push({name:"txt",record:t.ownership_verification.value,domain:t.ownership_verification.name}),{custom_domain_id:t.id,domain:t.hostname,primary:t.primary,status:t.status==="active"?"ready":"pending",type:"auth0_managed_certs",verification:{methods:R(gt.verificationMethodsSchema).parse(e)}}}function Fn(t){return{create:async(e,n)=>{const{result:s,errors:r,success:a}=Oe.parse(await ne(t).post({hostname:n.domain,ssl:{method:"txt",type:"dv"},custom_metadata:t.enterprise?{tenant_id:e}:void 0},"/custom_hostnames").json());if(!a)throw new Error(JSON.stringify(r));const i=Ue({...s,primary:!1});return await t.customDomainAdapter.create(e,{custom_domain_id:i.custom_domain_id,domain:i.domain,type:i.type}),i},get:async(e,n)=>{const s=await t.customDomainAdapter.get(e,n);if(!s)throw new le(404);const r=await ne(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json(),{result:a,errors:i,success:o}=Oe.parse(r);if(!o)throw new le(503,{message:JSON.stringify(i)});if(t.enterprise&&a.custom_metadata?.tenant_id!==e)throw new le(404);return Ue({...s,...a})},getByDomain:async e=>t.customDomainAdapter.getByDomain(e),list:async e=>{const n=await t.customDomainAdapter.list(e);return(await Promise.all(n.map(async r=>{try{const a=await ne(t).get(`/custom_hostnames/${encodeURIComponent(r.custom_domain_id)}`).json(),{result:i,success:o}=Oe.parse(a);return!o||t.enterprise&&i.custom_metadata?.tenant_id!==e?null:Ue({...r,...i})}catch{return null}}))).filter(r=>r!==null)},remove:async(e,n)=>{if(t.enterprise){const{result:r,success:a}=Oe.parse(await ne(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json());if(!a||r.custom_metadata?.tenant_id!==e)throw new le(404)}const s=await ne(t).delete(`/custom_hostnames/${encodeURIComponent(n)}`).res();return s.ok&&await t.customDomainAdapter.remove(e,n),s.ok},update:async(e,n,s)=>{const r=await ne(t).patch(s,`/custom_hostnames/${encodeURIComponent(n)}`).res();if(!r.ok)throw new le(503,{message:await r.text()});return t.customDomainAdapter.update(e,n,s)}}}class qn{constructor(e){this.config=e}cache=null;async getCache(){if(this.cache)return this.cache;if(typeof caches>"u")throw new Error("caches API is not available - CloudflareCache should only be used in Cloudflare Workers");return this.config.cacheName?this.cache=await caches.open(this.config.cacheName):this.cache=caches.default,this.cache}getKey(e){return this.config.keyPrefix?`${this.config.keyPrefix}:${e}`:e}createRequest(e){return new Request(`https://cache.internal/${this.getKey(e)}`)}async get(e){try{const n=await this.getCache(),s=this.createRequest(e),r=await n.match(s);if(!r)return null;const a=await r.json();return a.expiresAt&&new Date(a.expiresAt)<new Date?(await this.delete(e),null):a.value}catch(n){return console.error(`CloudflareCache: get error for key ${e}:`,n),null}}async set(e,n,s){try{const r=await this.getCache(),a=s??this.config.defaultTtlSeconds,i=a!==void 0,o=i?Math.max(0,a):0,c={value:n,expiresAt:i?new Date(Date.now()+(o>0?o*1e3:-1)).toISOString():void 0,cachedAt:new Date().toISOString()},d=this.createRequest(e),h={"Content-Type":"application/json"};i&&o>0&&(h["Cache-Control"]=`max-age=${o}`);const x=new Response(JSON.stringify(c),{headers:h});await r.put(d,x)}catch(r){console.error(`CloudflareCache: set error for key ${e}:`,r)}}async delete(e){try{const n=await this.getCache(),s=this.createRequest(e);return await n.delete(s)}catch(n){return console.error(`CloudflareCache: delete error for key ${e}:`,n),!1}}async clear(){console.warn("CloudflareCache.clear() is not implemented - Cloudflare Cache API does not support clearing all entries")}}function Un(t={}){const e={defaultTtlSeconds:300,keyPrefix:"authhero",...t};return new qn(e)}const Wn="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let ft=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=Wn[n[t]&63];return e};async function Ye(t,e){const n=t.timeout||3e4,s=new AbortController,r=setTimeout(()=>s.abort(),n);try{const a=`https://api.sql.cloudflarestorage.com/api/v1/accounts/${t.accountId}/r2-sql/query/${t.warehouseName}`,i=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.authToken}`},body:JSON.stringify({query:e}),signal:s.signal});if(!i.ok)throw new Error(`R2 SQL query failed: ${i.status} ${i.statusText}`);const o=await i.json();if(!o.success&&o.errors)throw new Error(`R2 SQL error: ${o.errors.join(", ")}`);return o.data||o.result?.data||[]}finally{clearTimeout(r)}}function Ze(t){return`'${t.replace(/'/g,"''")}'`}function q(t){return`"${t.replace(/"/g,'""')}"`}function ht(t){const e=n=>{if(!n)return"";try{return JSON.parse(n)}catch{return n}};return{type:t.type,date:t.date,description:t.description,ip:t.ip,user_agent:t.user_agent,details:e(t.details),isMobile:!!t.isMobile,user_id:t.user_id,user_name:t.user_name,connection:t.connection,connection_id:t.connection_id,client_id:t.client_id,client_name:t.client_name,audience:t.audience,scope:t.scope,strategy:t.strategy,strategy_type:t.strategy_type,hostname:t.hostname,auth0_client:e(t.auth0_client),log_id:t.id,location_info:t.country_code||t.city_name||t.latitude||t.longitude||t.time_zone||t.continent_code?{country_code:t.country_code||"",city_name:t.city_name||"",latitude:t.latitude||"",longitude:t.longitude||"",time_zone:t.time_zone||"",continent_code:t.continent_code||""}:void 0}}function Jn(t){return async(e,n)=>{const s=n.log_id||ft(),r={...n,log_id:s};return await Qn(t,e,r),r}}async function Qn(t,e,n){const s=a=>a?JSON.stringify(a):void 0,r={id:n.log_id,tenant_id:e,type:n.type,date:n.date,description:n.description?.substring(0,256),ip:n.ip,user_agent:n.user_agent,details:s(n.details)?.substring(0,8192),isMobile:n.isMobile?1:0,user_id:n.user_id,user_name:n.user_name,connection:n.connection,connection_id:n.connection_id,client_id:n.client_id,client_name:n.client_name,audience:n.audience,scope:n.scope,strategy:n.strategy,strategy_type:n.strategy_type,hostname:n.hostname,auth0_client:s(n.auth0_client),log_id:n.log_id,country_code:n.location_info?.country_code,city_name:n.location_info?.city_name,latitude:n.location_info?.latitude,longitude:n.location_info?.longitude,time_zone:n.location_info?.time_zone,continent_code:n.location_info?.continent_code};try{if(t.pipelineBinding)await t.pipelineBinding.send([r]);else if(t.pipelineEndpoint){const a=t.timeout||3e4,i=new AbortController,o=setTimeout(()=>i.abort(),a);try{const c=await fetch(t.pipelineEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([r]),signal:i.signal});if(!c.ok)throw new Error(`Pipeline ingestion failed: ${c.status} ${c.statusText}`)}finally{clearTimeout(o)}}else throw new Error("Either pipelineEndpoint or pipelineBinding must be configured")}catch(a){throw console.error("Failed to send log to Pipeline:",a),a}}function Hn(t){return async(e,n)=>{const s=t.namespace||"default",r=t.tableName||"logs",a=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const xt=require("@authhero/adapter-interfaces"),kt=require("wretch");function wt(t,e){var n={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(n[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,s=Object.getOwnPropertySymbols(t);r<s.length;r++)e.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(t,s[r])&&(n[s[r]]=t[s[r]]);return n}function Tt(t,e){var n;return((n=t?._def)===null||n===void 0?void 0:n.typeName)===e}function le(t,e){const n=t.ZodType.prototype[e];t.ZodType.prototype[e]=function(...s){const r=n.apply(this,s);return r._def.openapi=this._def.openapi,r}}function St(t){if(typeof t.ZodType.prototype.openapi<"u")return;t.ZodType.prototype.openapi=function(r,a){var i,o,c,d,h,x;const S=typeof r=="string"?a:r,w=S??{},{param:A}=w,Y=wt(w,["param"]),k=Object.assign(Object.assign({},(i=this._def.openapi)===null||i===void 0?void 0:i._internal),typeof r=="string"?{refId:r}:void 0),V=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),Y),!((d=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||d===void 0)&&d.param||A?{param:Object.assign(Object.assign({},(x=(h=this._def.openapi)===null||h===void 0?void 0:h.metadata)===null||x===void 0?void 0:x.param),A)}:void 0),O=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(k).length>0?{_internal:k}:void 0),Object.keys(V).length>0?{metadata:V}:void 0)}));if(Tt(this,"ZodObject")){const D=this.extend;O.extend=function(...K){var G,ue,Pe,Ve,ze,Be,Fe;const Ue=D.apply(this,K);return Ue._def.openapi={_internal:{extendedFrom:!((ue=(G=this._def.openapi)===null||G===void 0?void 0:G._internal)===null||ue===void 0)&&ue.refId?{refId:(Ve=(Pe=this._def.openapi)===null||Pe===void 0?void 0:Pe._internal)===null||Ve===void 0?void 0:Ve.refId,schema:this}:(Be=(ze=this._def.openapi)===null||ze===void 0?void 0:ze._internal)===null||Be===void 0?void 0:Be.extendedFrom},metadata:(Fe=Ue._def.openapi)===null||Fe===void 0?void 0:Fe.metadata},Ue}}return O},le(t,"optional"),le(t,"nullable"),le(t,"default"),le(t,"transform"),le(t,"refine");const e=t.ZodObject.prototype.deepPartial;t.ZodObject.prototype.deepPartial=function(){const r=this._def.shape(),a=e.apply(this),i=a._def.shape();return Object.entries(i).forEach(([o,c])=>{var d,h;c._def.openapi=(h=(d=r[o])===null||d===void 0?void 0:d._def)===null||h===void 0?void 0:h.openapi}),a._def.openapi=void 0,a};const n=t.ZodObject.prototype.pick;t.ZodObject.prototype.pick=function(...r){const a=n.apply(this,r);return a._def.openapi=void 0,a};const s=t.ZodObject.prototype.omit;t.ZodObject.prototype.omit=function(...r){const a=s.apply(this,r);return a._def.openapi=void 0,a}}var fe=class extends Error{res;status;constructor(t=500,e){super(e?.message,{cause:e?.cause}),this.res=e?.res,this.status=t}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 b;(function(t){t.assertEqual=r=>{};function e(r){}t.assertIs=e;function n(r){throw new Error}t.assertNever=n,t.arrayToEnum=r=>{const a={};for(const i of r)a[i]=i;return a},t.getValidEnumValues=r=>{const a=t.objectKeys(r).filter(o=>typeof r[r[o]]!="number"),i={};for(const o of a)i[o]=r[o];return t.objectValues(i)},t.objectValues=r=>t.objectKeys(r).map(function(a){return r[a]}),t.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const a=[];for(const i in r)Object.prototype.hasOwnProperty.call(r,i)&&a.push(i);return a},t.find=(r,a)=>{for(const i of r)if(a(i))return i},t.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function s(r,a=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}t.joinValues=s,t.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(b||(b={}));var Qe;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Qe||(Qe={}));const f=b.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),B=t=>{switch(typeof t){case"undefined":return f.undefined;case"string":return f.string;case"number":return Number.isNaN(t)?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(t)?f.array:t===null?f.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?f.promise:typeof Map<"u"&&t instanceof Map?f.map:typeof Set<"u"&&t instanceof Set?f.set:typeof Date<"u"&&t instanceof Date?f.date:f.object;default:return f.unknown}},u=b.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Et=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class N extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(a){return a.message},s={_errors:[]},r=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(i.argumentsError);else if(i.path.length===0)s._errors.push(n(i));else{let o=s,c=0;for(;c<i.path.length;){const d=i.path[c];c===i.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(n(i))):o[d]=o[d]||{_errors:[]},o=o[d],c++}}};return r(this),s}static assert(e){if(!(e instanceof N))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,b.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},s=[];for(const r of this.issues)if(r.path.length>0){const a=r.path[0];n[a]=n[a]||[],n[a].push(e(r))}else s.push(e(r));return{formErrors:s,fieldErrors:n}}get formErrors(){return this.flatten()}}N.create=t=>new N(t);const oe=(t,e)=>{let n;switch(t.code){case u.invalid_type:t.received===f.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case u.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,b.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:n=`Unrecognized key(s) in object: ${b.joinValues(t.keys,", ")}`;break;case u.invalid_union:n="Invalid input";break;case u.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${b.joinValues(t.options)}`;break;case u.invalid_enum_value:n=`Invalid enum value. Expected ${b.joinValues(t.options)}, received '${t.received}'`;break;case u.invalid_arguments:n="Invalid function arguments";break;case u.invalid_return_type:n="Invalid function return type";break;case u.invalid_date:n="Invalid date";break;case u.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:b.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case u.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case u.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case u.custom:n="Invalid input";break;case u.invalid_intersection_types:n="Intersection results could not be merged";break;case u.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case u.not_finite:n="Number must be finite";break;default:n=e.defaultError,b.assertNever(t)}return{message:n}};let ot=oe;function Ct(t){ot=t}function Ne(){return ot}const Re=t=>{const{data:e,path:n,errorMaps:s,issueData:r}=t,a=[...n,...r.path||[]],i={...r,path:a};if(r.message!==void 0)return{...r,path:a,message:r.message};let o="";const c=s.filter(d=>!!d).slice().reverse();for(const d of c)o=d(i,{data:e,defaultError:o}).message;return{...r,path:a,message:o}},At=[];function l(t,e){const n=Ne(),s=Re({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===oe?void 0:oe].filter(r=>!!r)});t.common.issues.push(s)}class E{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const s=[];for(const r of n){if(r.status==="aborted")return m;r.status==="dirty"&&e.dirty(),s.push(r.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,n){const s=[];for(const r of n){const a=await r.key,i=await r.value;s.push({key:a,value:i})}return E.mergeObjectSync(e,s)}static mergeObjectSync(e,n){const s={};for(const r of n){const{key:a,value:i}=r;if(a.status==="aborted"||i.status==="aborted")return m;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||r.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}}const m=Object.freeze({status:"aborted"}),ae=t=>({status:"dirty",value:t}),C=t=>({status:"valid",value:t}),He=t=>t.status==="aborted",Je=t=>t.status==="dirty",ee=t=>t.status==="valid",he=t=>typeof Promise<"u"&&t instanceof Promise;var p;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(p||(p={}));class M{constructor(e,n,s,r){this._cachedPath=[],this.parent=e,this.data=n,this._path=s,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const tt=(t,e)=>{if(ee(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new N(t.common.issues);return this._error=n,this._error}}};function _(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:s,description:r}=t;if(e&&(n||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(i,o)=>{const{message:c}=t;return i.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??s??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:c??n??o.defaultError}},description:r}}class v{get description(){return this._def.description}_getType(e){return B(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:B(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new E,ctx:{common:e.parent.common,data:e.data,parsedType:B(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(he(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const s=this.safeParse(e,n);if(s.success)return s.data;throw s.error}safeParse(e,n){const s={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:B(e)},r=this._parseSync({data:e,path:s.path,parent:s});return tt(s,r)}"~validate"(e){const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:B(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:n});return ee(s)?{value:s.value}:{issues:n.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(s=>ee(s)?{value:s.value}:{issues:n.common.issues})}async parseAsync(e,n){const s=await this.safeParseAsync(e,n);if(s.success)return s.data;throw s.error}async safeParseAsync(e,n){const s={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:B(e)},r=this._parse({data:e,path:s.path,parent:s}),a=await(he(r)?r:Promise.resolve(r));return tt(s,a)}refine(e,n){const s=r=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(r):n;return this._refinement((r,a)=>{const i=e(r),o=()=>a.addIssue({code:u.custom,...s(r)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,n){return this._refinement((s,r)=>e(s)?!0:(r.addIssue(typeof n=="function"?n(s,r):n),!1))}_refinement(e){return new j({schema:this,typeName:y.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return L.create(this,this._def)}nullable(){return J.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return I.create(this)}promise(){return de.create(this,this._def)}or(e){return _e.create([this,e],this._def)}and(e){return ge.create(this,e,this._def)}transform(e){return new j({..._(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new we({..._(this._def),innerType:this,defaultValue:n,typeName:y.ZodDefault})}brand(){return new Xe({typeName:y.ZodBranded,type:this,..._(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new Te({..._(this._def),innerType:this,catchValue:n,typeName:y.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Ce.create(this,e)}readonly(){return Se.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ot=/^c[^\s-]{8,}$/i,Nt=/^[0-9a-z]+$/,Rt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,$t=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,It=/^[a-z0-9_-]{21}$/i,jt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Zt=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Dt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Lt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let qe;const Mt=/^(?:(?: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])$/,Pt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Vt=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,zt=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Bt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ft=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ct="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Ut=new RegExp(`^${ct}$`);function dt(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function qt(t){return new RegExp(`^${dt(t)}$`)}function ut(t){let e=`${ct}T${dt(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Wt(t,e){return!!((e==="v4"||!e)&&Mt.test(t)||(e==="v6"||!e)&&Vt.test(t))}function Qt(t,e){if(!jt.test(t))return!1;try{const[n]=t.split(".");if(!n)return!1;const s=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),r=JSON.parse(atob(s));return!(typeof r!="object"||r===null||"typ"in r&&r?.typ!=="JWT"||!r.alg||e&&r.alg!==e)}catch{return!1}}function Ht(t,e){return!!((e==="v4"||!e)&&Pt.test(t)||(e==="v6"||!e)&&zt.test(t))}class $ extends v{_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}),m}const s=new E;let r;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(r=this._getOrReturnCtx(e,r),l(r,{code:u.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="max")e.data.length>a.value&&(r=this._getOrReturnCtx(e,r),l(r,{code:u.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(r=this._getOrReturnCtx(e,r),i?l(r,{code:u.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&l(r,{code:u.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty())}else if(a.kind==="email")Dt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"email",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")qe||(qe=new RegExp(Lt,"u")),qe.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"emoji",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")$t.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"uuid",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")It.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"nanoid",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")Ot.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"cuid",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")Nt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"cuid2",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")Rt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"ulid",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),l(r,{validation:"url",code:u.invalid_string,message:a.message}),s.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"regex",code:u.invalid_string,message:a.message}),s.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(r=this._getOrReturnCtx(e,r),l(r,{code:u.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),s.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(r=this._getOrReturnCtx(e,r),l(r,{code:u.invalid_string,validation:{startsWith:a.value},message:a.message}),s.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(r=this._getOrReturnCtx(e,r),l(r,{code:u.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?ut(a).test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:u.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?Ut.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:u.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?qt(a).test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:u.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?Zt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"duration",code:u.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?Wt(e.data,a.version)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"ip",code:u.invalid_string,message:a.message}),s.dirty()):a.kind==="jwt"?Qt(e.data,a.alg)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"jwt",code:u.invalid_string,message:a.message}),s.dirty()):a.kind==="cidr"?Ht(e.data,a.version)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"cidr",code:u.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?Bt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"base64",code:u.invalid_string,message:a.message}),s.dirty()):a.kind==="base64url"?Ft.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"base64url",code:u.invalid_string,message:a.message}),s.dirty()):b.assertNever(a);return{status:s.value,value:e.data}}_regex(e,n,s){return this.refinement(r=>e.test(r),{validation:n,code:u.invalid_string,...p.errToObj(s)})}_addCheck(e){return new $({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...p.errToObj(e)})}url(e){return this._addCheck({kind:"url",...p.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...p.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...p.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...p.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...p.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...p.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...p.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...p.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...p.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...p.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...p.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...p.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...p.errToObj(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?.precision>"u"?null:e?.precision,...p.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...p.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...p.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...p.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...p.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...p.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...p.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...p.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...p.errToObj(n)})}nonempty(e){return this.min(1,p.errToObj(e))}trim(){return new $({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new $({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new $({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}$.create=t=>new $({checks:[],typeName:y.ZodString,coerce:t?.coerce??!1,..._(t)});function Jt(t,e){const n=(t.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,r=n>s?n:s,a=Number.parseInt(t.toFixed(r).replace(".","")),i=Number.parseInt(e.toFixed(r).replace(".",""));return a%i/10**r}class W extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){const a=this._getOrReturnCtx(e);return l(a,{code:u.invalid_type,expected:f.number,received:a.parsedType}),m}let s;const r=new E;for(const a of this._def.checks)a.kind==="int"?b.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:u.invalid_type,expected:"integer",received:"float",message:a.message}),r.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:u.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:u.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="multipleOf"?Jt(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),l(s,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:u.not_finite,message:a.message}),r.dirty()):b.assertNever(a);return{status:r.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,p.toString(n))}gt(e,n){return this.setLimit("min",e,!1,p.toString(n))}lte(e,n){return this.setLimit("max",e,!0,p.toString(n))}lt(e,n){return this.setLimit("max",e,!1,p.toString(n))}setLimit(e,n,s,r){return new W({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:s,message:p.toString(r)}]})}_addCheck(e){return new W({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:p.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:p.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:p.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:p.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:p.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&b.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(n===null||s.value>n)&&(n=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(n)&&Number.isFinite(e)}}W.create=t=>new W({checks:[],typeName:y.ZodNumber,coerce:t?.coerce||!1,..._(t)});class Q extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==f.bigint)return this._getInvalidInput(e);let s;const r=new E;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:u.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:u.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),l(s,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):b.assertNever(a);return{status:r.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:f.bigint,received:n.parsedType}),m}gte(e,n){return this.setLimit("min",e,!0,p.toString(n))}gt(e,n){return this.setLimit("min",e,!1,p.toString(n))}lte(e,n){return this.setLimit("max",e,!0,p.toString(n))}lt(e,n){return this.setLimit("max",e,!1,p.toString(n))}setLimit(e,n,s,r){return new Q({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:s,message:p.toString(r)}]})}_addCheck(e){return new Q({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:p.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}Q.create=t=>new Q({checks:[],typeName:y.ZodBigInt,coerce:t?.coerce??!1,..._(t)});class pe extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){const s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:f.boolean,received:s.parsedType}),m}return C(e.data)}}pe.create=t=>new pe({typeName:y.ZodBoolean,coerce:t?.coerce||!1,..._(t)});class te extends v{_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}),m}if(Number.isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return l(a,{code:u.invalid_date}),m}const s=new E;let r;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(r=this._getOrReturnCtx(e,r),l(r,{code:u.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),s.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(r=this._getOrReturnCtx(e,r),l(r,{code:u.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):b.assertNever(a);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new te({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:p.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:p.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}te.create=t=>new te({checks:[],coerce:t?.coerce||!1,typeName:y.ZodDate,..._(t)});class $e extends v{_parse(e){if(this._getType(e)!==f.symbol){const s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:f.symbol,received:s.parsedType}),m}return C(e.data)}}$e.create=t=>new $e({typeName:y.ZodSymbol,..._(t)});class me extends v{_parse(e){if(this._getType(e)!==f.undefined){const s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:f.undefined,received:s.parsedType}),m}return C(e.data)}}me.create=t=>new me({typeName:y.ZodUndefined,..._(t)});class ye extends v{_parse(e){if(this._getType(e)!==f.null){const s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:f.null,received:s.parsedType}),m}return C(e.data)}}ye.create=t=>new ye({typeName:y.ZodNull,..._(t)});class ce extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return C(e.data)}}ce.create=t=>new ce({typeName:y.ZodAny,..._(t)});class X extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return C(e.data)}}X.create=t=>new X({typeName:y.ZodUnknown,..._(t)});class U extends v{_parse(e){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:f.never,received:n.parsedType}),m}}U.create=t=>new U({typeName:y.ZodNever,..._(t)});class Ie extends v{_parse(e){if(this._getType(e)!==f.undefined){const s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:f.void,received:s.parsedType}),m}return C(e.data)}}Ie.create=t=>new Ie({typeName:y.ZodVoid,..._(t)});class I extends v{_parse(e){const{ctx:n,status:s}=this._processInputParams(e),r=this._def;if(n.parsedType!==f.array)return l(n,{code:u.invalid_type,expected:f.array,received:n.parsedType}),m;if(r.exactLength!==null){const i=n.data.length>r.exactLength.value,o=n.data.length<r.exactLength.value;(i||o)&&(l(n,{code:i?u.too_big:u.too_small,minimum:o?r.exactLength.value:void 0,maximum:i?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),s.dirty())}if(r.minLength!==null&&n.data.length<r.minLength.value&&(l(n,{code:u.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),s.dirty()),r.maxLength!==null&&n.data.length>r.maxLength.value&&(l(n,{code:u.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),s.dirty()),n.common.async)return Promise.all([...n.data].map((i,o)=>r.type._parseAsync(new M(n,i,n.path,o)))).then(i=>E.mergeArray(s,i));const a=[...n.data].map((i,o)=>r.type._parseSync(new M(n,i,n.path,o)));return E.mergeArray(s,a)}get element(){return this._def.type}min(e,n){return new I({...this._def,minLength:{value:e,message:p.toString(n)}})}max(e,n){return new I({...this._def,maxLength:{value:e,message:p.toString(n)}})}length(e,n){return new I({...this._def,exactLength:{value:e,message:p.toString(n)}})}nonempty(e){return this.min(1,e)}}I.create=(t,e)=>new I({type:t,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,..._(e)});function re(t){if(t instanceof T){const e={};for(const n in t.shape){const s=t.shape[n];e[n]=L.create(re(s))}return new T({...t._def,shape:()=>e})}else return t instanceof I?new I({...t._def,type:re(t.element)}):t instanceof L?L.create(re(t.unwrap())):t instanceof J?J.create(re(t.unwrap())):t instanceof P?P.create(t.items.map(e=>re(e))):t}class T extends v{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),n=b.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==f.object){const d=this._getOrReturnCtx(e);return l(d,{code:u.invalid_type,expected:f.object,received:d.parsedType}),m}const{status:s,ctx:r}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof U&&this._def.unknownKeys==="strip"))for(const d in r.data)i.includes(d)||o.push(d);const c=[];for(const d of i){const h=a[d],x=r.data[d];c.push({key:{status:"valid",value:d},value:h._parse(new M(r,x,r.path,d)),alwaysSet:d in r.data})}if(this._def.catchall instanceof U){const d=this._def.unknownKeys;if(d==="passthrough")for(const h of o)c.push({key:{status:"valid",value:h},value:{status:"valid",value:r.data[h]}});else if(d==="strict")o.length>0&&(l(r,{code:u.unrecognized_keys,keys:o}),s.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const h of o){const x=r.data[h];c.push({key:{status:"valid",value:h},value:d._parse(new M(r,x,r.path,h)),alwaysSet:h in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const d=[];for(const h of c){const x=await h.key,S=await h.value;d.push({key:x,value:S,alwaysSet:h.alwaysSet})}return d}).then(d=>E.mergeObjectSync(s,d)):E.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(e){return p.errToObj,new T({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,s)=>{const r=this._def.errorMap?.(n,s).message??s.defaultError;return n.code==="unrecognized_keys"?{message:p.errToObj(e).message??r}:{message:r}}}:{}})}strip(){return new T({...this._def,unknownKeys:"strip"})}passthrough(){return new T({...this._def,unknownKeys:"passthrough"})}extend(e){return new T({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new T({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:y.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new T({...this._def,catchall:e})}pick(e){const n={};for(const s of b.objectKeys(e))e[s]&&this.shape[s]&&(n[s]=this.shape[s]);return new T({...this._def,shape:()=>n})}omit(e){const n={};for(const s of b.objectKeys(this.shape))e[s]||(n[s]=this.shape[s]);return new T({...this._def,shape:()=>n})}deepPartial(){return re(this)}partial(e){const n={};for(const s of b.objectKeys(this.shape)){const r=this.shape[s];e&&!e[s]?n[s]=r:n[s]=r.optional()}return new T({...this._def,shape:()=>n})}required(e){const n={};for(const s of b.objectKeys(this.shape))if(e&&!e[s])n[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof L;)a=a._def.innerType;n[s]=a}return new T({...this._def,shape:()=>n})}keyof(){return lt(b.objectKeys(this.shape))}}T.create=(t,e)=>new T({shape:()=>t,unknownKeys:"strip",catchall:U.create(),typeName:y.ZodObject,..._(e)});T.strictCreate=(t,e)=>new T({shape:()=>t,unknownKeys:"strict",catchall:U.create(),typeName:y.ZodObject,..._(e)});T.lazycreate=(t,e)=>new T({shape:t,unknownKeys:"strip",catchall:U.create(),typeName:y.ZodObject,..._(e)});class _e extends v{_parse(e){const{ctx:n}=this._processInputParams(e),s=this._def.options;function r(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 n.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new N(o.ctx.common.issues));return l(n,{code:u.invalid_union,unionErrors:i}),m}if(n.common.async)return Promise.all(s.map(async a=>{const i={...n,common:{...n.common,issues:[]},parent:null};return{result:await a._parseAsync({data:n.data,path:n.path,parent:i}),ctx:i}})).then(r);{let a;const i=[];for(const c of s){const d={...n,common:{...n.common,issues:[]},parent:null},h=c._parseSync({data:n.data,path:n.path,parent:d});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:d}),d.common.issues.length&&i.push(d.common.issues)}if(a)return n.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new N(c));return l(n,{code:u.invalid_union,unionErrors:o}),m}}get options(){return this._def.options}}_e.create=(t,e)=>new _e({options:t,typeName:y.ZodUnion,..._(e)});const z=t=>t instanceof be?z(t.schema):t instanceof j?z(t.innerType()):t instanceof xe?[t.value]:t instanceof H?t.options:t instanceof ke?b.objectValues(t.enum):t instanceof we?z(t._def.innerType):t instanceof me?[void 0]:t instanceof ye?[null]:t instanceof L?[void 0,...z(t.unwrap())]:t instanceof J?[null,...z(t.unwrap())]:t instanceof Xe||t instanceof Se?z(t.unwrap()):t instanceof Te?z(t._def.innerType):[];class Me extends v{_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==f.object)return l(n,{code:u.invalid_type,expected:f.object,received:n.parsedType}),m;const s=this.discriminator,r=n.data[s],a=this.optionsMap.get(r);return a?n.common.async?a._parseAsync({data:n.data,path:n.path,parent:n}):a._parseSync({data:n.data,path:n.path,parent:n}):(l(n,{code:u.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),m)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,s){const r=new Map;for(const a of n){const i=z(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(r.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);r.set(o,a)}}return new Me({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:r,..._(s)})}}function Ye(t,e){const n=B(t),s=B(e);if(t===e)return{valid:!0,data:t};if(n===f.object&&s===f.object){const r=b.objectKeys(e),a=b.objectKeys(t).filter(o=>r.indexOf(o)!==-1),i={...t,...e};for(const o of a){const c=Ye(t[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(n===f.array&&s===f.array){if(t.length!==e.length)return{valid:!1};const r=[];for(let a=0;a<t.length;a++){const i=t[a],o=e[a],c=Ye(i,o);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return n===f.date&&s===f.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class ge extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e),r=(a,i)=>{if(He(a)||He(i))return m;const o=Ye(a.value,i.value);return o.valid?((Je(a)||Je(i))&&n.dirty(),{status:n.value,value:o.data}):(l(s,{code:u.invalid_intersection_types}),m)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>r(a,i)):r(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}ge.create=(t,e,n)=>new ge({left:t,right:e,typeName:y.ZodIntersection,..._(n)});class P extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.array)return l(s,{code:u.invalid_type,expected:f.array,received:s.parsedType}),m;if(s.data.length<this._def.items.length)return l(s,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),m;!this._def.rest&&s.data.length>this._def.items.length&&(l(s,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const a=[...s.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new M(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(a).then(i=>E.mergeArray(n,i)):E.mergeArray(n,a)}get items(){return this._def.items}rest(e){return new P({...this._def,rest:e})}}P.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new P({items:t,typeName:y.ZodTuple,rest:null,..._(e)})};class ve extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.object)return l(s,{code:u.invalid_type,expected:f.object,received:s.parsedType}),m;const r=[],a=this._def.keyType,i=this._def.valueType;for(const o in s.data)r.push({key:a._parse(new M(s,o,s.path,o)),value:i._parse(new M(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?E.mergeObjectAsync(n,r):E.mergeObjectSync(n,r)}get element(){return this._def.valueType}static create(e,n,s){return n instanceof v?new ve({keyType:e,valueType:n,typeName:y.ZodRecord,..._(s)}):new ve({keyType:$.create(),valueType:e,typeName:y.ZodRecord,..._(n)})}}class je extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.map)return l(s,{code:u.invalid_type,expected:f.map,received:s.parsedType}),m;const r=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,c],d)=>({key:r._parse(new M(s,o,s.path,[d,"key"])),value:a._parse(new M(s,c,s.path,[d,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const d=await c.key,h=await c.value;if(d.status==="aborted"||h.status==="aborted")return m;(d.status==="dirty"||h.status==="dirty")&&n.dirty(),o.set(d.value,h.value)}return{status:n.value,value:o}})}else{const o=new Map;for(const c of i){const d=c.key,h=c.value;if(d.status==="aborted"||h.status==="aborted")return m;(d.status==="dirty"||h.status==="dirty")&&n.dirty(),o.set(d.value,h.value)}return{status:n.value,value:o}}}}je.create=(t,e,n)=>new je({valueType:e,keyType:t,typeName:y.ZodMap,..._(n)});class ne extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.set)return l(s,{code:u.invalid_type,expected:f.set,received:s.parsedType}),m;const r=this._def;r.minSize!==null&&s.data.size<r.minSize.value&&(l(s,{code:u.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),n.dirty()),r.maxSize!==null&&s.data.size>r.maxSize.value&&(l(s,{code:u.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),n.dirty());const a=this._def.valueType;function i(c){const d=new Set;for(const h of c){if(h.status==="aborted")return m;h.status==="dirty"&&n.dirty(),d.add(h.value)}return{status:n.value,value:d}}const o=[...s.data.values()].map((c,d)=>a._parse(new M(s,c,s.path,d)));return s.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,n){return new ne({...this._def,minSize:{value:e,message:p.toString(n)}})}max(e,n){return new ne({...this._def,maxSize:{value:e,message:p.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}ne.create=(t,e)=>new ne({valueType:t,minSize:null,maxSize:null,typeName:y.ZodSet,..._(e)});class ie extends v{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==f.function)return l(n,{code:u.invalid_type,expected:f.function,received:n.parsedType}),m;function s(o,c){return Re({data:o,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Ne(),oe].filter(d=>!!d),issueData:{code:u.invalid_arguments,argumentsError:c}})}function r(o,c){return Re({data:o,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Ne(),oe].filter(d=>!!d),issueData:{code:u.invalid_return_type,returnTypeError:c}})}const a={errorMap:n.common.contextualErrorMap},i=n.data;if(this._def.returns instanceof de){const o=this;return C(async function(...c){const d=new N([]),h=await o._def.args.parseAsync(c,a).catch(w=>{throw d.addIssue(s(c,w)),d}),x=await Reflect.apply(i,this,h);return await o._def.returns._def.type.parseAsync(x,a).catch(w=>{throw d.addIssue(r(x,w)),d})})}else{const o=this;return C(function(...c){const d=o._def.args.safeParse(c,a);if(!d.success)throw new N([s(c,d.error)]);const h=Reflect.apply(i,this,d.data),x=o._def.returns.safeParse(h,a);if(!x.success)throw new N([r(h,x.error)]);return x.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ie({...this._def,args:P.create(e).rest(X.create())})}returns(e){return new ie({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,s){return new ie({args:e||P.create([]).rest(X.create()),returns:n||X.create(),typeName:y.ZodFunction,..._(s)})}}class be extends v{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}be.create=(t,e)=>new be({getter:t,typeName:y.ZodLazy,..._(e)});class xe extends v{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return l(n,{received:n.data,code:u.invalid_literal,expected:this._def.value}),m}return{status:"valid",value:e.data}}get value(){return this._def.value}}xe.create=(t,e)=>new xe({value:t,typeName:y.ZodLiteral,..._(e)});function lt(t,e){return new H({values:t,typeName:y.ZodEnum,..._(e)})}class H extends v{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),s=this._def.values;return l(n,{expected:b.joinValues(s),received:n.parsedType,code:u.invalid_type}),m}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const n=this._getOrReturnCtx(e),s=this._def.values;return l(n,{received:n.data,code:u.invalid_enum_value,options:s}),m}return C(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return H.create(e,{...this._def,...n})}exclude(e,n=this._def){return H.create(this.options.filter(s=>!e.includes(s)),{...this._def,...n})}}H.create=lt;class ke extends v{_parse(e){const n=b.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==f.string&&s.parsedType!==f.number){const r=b.objectValues(n);return l(s,{expected:b.joinValues(r),received:s.parsedType,code:u.invalid_type}),m}if(this._cache||(this._cache=new Set(b.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const r=b.objectValues(n);return l(s,{received:s.data,code:u.invalid_enum_value,options:r}),m}return C(e.data)}get enum(){return this._def.values}}ke.create=(t,e)=>new ke({values:t,typeName:y.ZodNativeEnum,..._(e)});class de extends v{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==f.promise&&n.common.async===!1)return l(n,{code:u.invalid_type,expected:f.promise,received:n.parsedType}),m;const s=n.parsedType===f.promise?n.data:Promise.resolve(n.data);return C(s.then(r=>this._def.type.parseAsync(r,{path:n.path,errorMap:n.common.contextualErrorMap})))}}de.create=(t,e)=>new de({type:t,typeName:y.ZodPromise,..._(e)});class j extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:s}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:i=>{l(s,i),i.fatal?n.abort():n.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const i=r.transform(s.data,a);if(s.common.async)return Promise.resolve(i).then(async o=>{if(n.value==="aborted")return m;const c=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return c.status==="aborted"?m:c.status==="dirty"||n.value==="dirty"?ae(c.value):c});{if(n.value==="aborted")return m;const o=this._def.schema._parseSync({data:i,path:s.path,parent:s});return o.status==="aborted"?m:o.status==="dirty"||n.value==="dirty"?ae(o.value):o}}if(r.type==="refinement"){const i=o=>{const c=r.refinement(o,a);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?m:(o.status==="dirty"&&n.dirty(),i(o.value),{status:n.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?m:(o.status==="dirty"&&n.dirty(),i(o.value).then(()=>({status:n.value,value:o.value}))))}if(r.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!ee(i))return m;const o=r.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>ee(i)?Promise.resolve(r.transform(i.value,a)).then(o=>({status:n.value,value:o})):m);b.assertNever(r)}}j.create=(t,e,n)=>new j({schema:t,typeName:y.ZodEffects,effect:e,..._(n)});j.createWithPreprocess=(t,e,n)=>new j({schema:e,effect:{type:"preprocess",transform:t},typeName:y.ZodEffects,..._(n)});class L extends v{_parse(e){return this._getType(e)===f.undefined?C(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}L.create=(t,e)=>new L({innerType:t,typeName:y.ZodOptional,..._(e)});class J extends v{_parse(e){return this._getType(e)===f.null?C(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}J.create=(t,e)=>new J({innerType:t,typeName:y.ZodNullable,..._(e)});class we extends v{_parse(e){const{ctx:n}=this._processInputParams(e);let s=n.data;return n.parsedType===f.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}we.create=(t,e)=>new we({innerType:t,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});class Te extends v{_parse(e){const{ctx:n}=this._processInputParams(e),s={...n,common:{...n.common,issues:[]}},r=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return he(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new N(s.common.issues)},input:s.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new N(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}Te.create=(t,e)=>new Te({innerType:t,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});class Ze extends v{_parse(e){if(this._getType(e)!==f.nan){const s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:f.nan,received:s.parsedType}),m}return{status:"valid",value:e.data}}}Ze.create=t=>new Ze({typeName:y.ZodNaN,..._(t)});const Yt=Symbol("zod_brand");class Xe extends v{_parse(e){const{ctx:n}=this._processInputParams(e),s=n.data;return this._def.type._parse({data:s,path:n.path,parent:n})}unwrap(){return this._def.type}}class Ce extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?m:a.status==="dirty"?(n.dirty(),ae(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})})();{const r=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?m:r.status==="dirty"?(n.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:s.path,parent:s})}}static create(e,n){return new Ce({in:e,out:n,typeName:y.ZodPipeline})}}class Se extends v{_parse(e){const n=this._def.innerType._parse(e),s=r=>(ee(r)&&(r.value=Object.freeze(r.value)),r);return he(n)?n.then(r=>s(r)):s(n)}unwrap(){return this._def.innerType}}Se.create=(t,e)=>new Se({innerType:t,typeName:y.ZodReadonly,..._(e)});function nt(t,e){const n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function ft(t,e={},n){return t?ce.create().superRefine((s,r)=>{const a=t(s);if(a instanceof Promise)return a.then(i=>{if(!i){const o=nt(e,s),c=o.fatal??n??!0;r.addIssue({code:"custom",...o,fatal:c})}});if(!a){const i=nt(e,s),o=i.fatal??n??!0;r.addIssue({code:"custom",...i,fatal:o})}}):ce.create()}const Kt={object:T.lazycreate};var y;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(y||(y={}));const Gt=(t,e={message:`Input not instance of ${t.name}`})=>ft(n=>n instanceof t,e),g=$.create,et=W.create,Xt=Ze.create,en=Q.create,Ae=pe.create,tn=te.create,nn=$e.create,sn=me.create,rn=ye.create,an=ce.create,on=X.create,cn=U.create,dn=Ie.create,R=I.create,Z=T.create,un=T.strictCreate,ln=_e.create,fn=Me.create,hn=ge.create,pn=P.create,ht=ve.create,mn=je.create,yn=ne.create,_n=ie.create,gn=be.create,vn=xe.create,bn=H.create,xn=ke.create,kn=de.create,st=j.create,wn=L.create,Tn=J.create,Sn=j.createWithPreprocess,En=Ce.create,Cn=()=>g().optional(),An=()=>et().optional(),On=()=>Ae().optional(),Nn={string:(t=>$.create({...t,coerce:!0})),number:(t=>W.create({...t,coerce:!0})),boolean:(t=>pe.create({...t,coerce:!0})),bigint:(t=>Q.create({...t,coerce:!0})),date:(t=>te.create({...t,coerce:!0}))},Rn=m,$n=Object.freeze(Object.defineProperty({__proto__:null,BRAND:Yt,DIRTY:ae,EMPTY_PATH:At,INVALID:m,NEVER:Rn,OK:C,ParseStatus:E,Schema:v,ZodAny:ce,ZodArray:I,ZodBigInt:Q,ZodBoolean:pe,ZodBranded:Xe,ZodCatch:Te,ZodDate:te,ZodDefault:we,ZodDiscriminatedUnion:Me,ZodEffects:j,ZodEnum:H,ZodError:N,get ZodFirstPartyTypeKind(){return y},ZodFunction:ie,ZodIntersection:ge,ZodIssueCode:u,ZodLazy:be,ZodLiteral:xe,ZodMap:je,ZodNaN:Ze,ZodNativeEnum:ke,ZodNever:U,ZodNull:ye,ZodNullable:J,ZodNumber:W,ZodObject:T,ZodOptional:L,ZodParsedType:f,ZodPipeline:Ce,ZodPromise:de,ZodReadonly:Se,ZodRecord:ve,ZodSchema:v,ZodSet:ne,ZodString:$,ZodSymbol:$e,ZodTransformer:j,ZodTuple:P,ZodType:v,ZodUndefined:me,ZodUnion:_e,ZodUnknown:X,ZodVoid:Ie,addIssueToContext:l,any:an,array:R,bigint:en,boolean:Ae,coerce:Nn,custom:ft,date:tn,datetimeRegex:ut,defaultErrorMap:oe,discriminatedUnion:fn,effect:st,enum:bn,function:_n,getErrorMap:Ne,getParsedType:B,instanceof:Gt,intersection:hn,isAborted:He,isAsync:he,isDirty:Je,isValid:ee,late:Kt,lazy:gn,literal:vn,makeIssue:Re,map:mn,nan:Xt,nativeEnum:xn,never:cn,null:rn,nullable:Tn,number:et,object:Z,get objectUtil(){return Qe},oboolean:On,onumber:An,optional:wn,ostring:Cn,pipeline:En,preprocess:Sn,promise:kn,quotelessJson:Et,record:ht,set:yn,setErrorMap:Ct,strictObject:un,string:g,symbol:nn,transformer:st,tuple:pn,undefined:sn,union:ln,unknown:on,get util(){return b},void:dn},Symbol.toStringTag,{value:"Module"}));St($n);const In=(t,e)=>e.skipDedupe||e.method!=="GET",jn=(t,e)=>e.method+"@"+t,Zn=t=>t.clone(),Dn=({skip:t=In,key:e=jn,resolver:n=Zn}={})=>{const s=new Map;return r=>(a,i)=>{if(t(a,i))return r(a,i);const o=e(a,i);if(!s.has(o))s.set(o,[]);else return new Promise((c,d)=>{s.get(o).push([c,d])});try{return r(a,i).then(c=>(s.get(o).forEach(([d])=>d(n(c))),s.delete(o),c)).catch(c=>{throw s.get(o).forEach(([,d])=>d(c)),s.delete(o),c})}catch(c){return s.delete(o),Promise.reject(c)}}},Ln=(t,e)=>t*e,Mn=t=>t&&(t.ok||t.status>=400&&t.status<500),Pn=({delayTimer:t=500,delayRamp:e=Ln,maxAttempts:n=10,until:s=Mn,onRetry:r=null,retryOnNetworkError:a=!1,resolveWithLatestResponse:i=!1,skip:o}={})=>c=>(d,h)=>{let x=0;if(o&&o(d,h))return c(d,h);const S=(w,A)=>Promise.resolve(s(w,A)).then(Y=>Y?w&&i?w:A?Promise.reject(A):w:(x++,!n||x<=n?new Promise(k=>{const V=e(t,x);setTimeout(()=>{typeof r=="function"?Promise.resolve(r({response:w,error:A,url:d,attempt:x,options:h})).then((O={})=>{var D,K;k(c((D=O&&O.url)!==null&&D!==void 0?D:d,(K=O&&O.options)!==null&&K!==void 0?K:h))}):k(c(d,h))},V)}).then(S).catch(k=>{if(!a)throw k;return S(null,k)}):w&&i?w:Promise.reject(A||new Error("Number of attempts exceeded."))));return c(d,h).then(S).catch(w=>{if(!a)throw w;return S(null,w)})},De=Z({code:et(),message:g()}),Vn=Z({message:g()}),zn=Z({emails:R(g()).optional(),http_body:g().optional(),http_url:g().optional(),txt_name:g().optional(),txt_value:g().optional()}),Bn=Z({ciphers:R(g()).optional(),early_hints:g().optional(),http2:g().optional(),min_tls_version:g().optional(),tls_1_3:g().optional()}),Fn=Z({id:g(),bundle_method:g().optional(),certificate_authority:g(),custom_certificate:g().optional(),custom_csr_id:g().optional(),custom_key:g().optional(),expires_on:g().optional(),hosts:R(g()).optional(),issuer:g().optional(),method:g(),serial_number:g().optional(),settings:Bn.optional(),signature:g().optional(),type:g(),uploaded_on:g().optional(),validation_errors:R(Vn).optional(),validation_records:R(zn).optional(),wildcard:Ae()}),Un=Z({name:g(),type:g(),value:g()}),qn=Z({http_body:g().optional(),http_url:g().optional()}),pt=Z({id:g(),ssl:Fn,hostname:g(),custom_metadata:ht(g()).optional(),custom_origin_server:g().optional(),custom_origin_sni:g().optional(),ownership_verification:Un.optional(),ownership_verification_http:qn.optional(),status:g(),verification_errors:R(g()).optional(),created_at:g()}),Oe=Z({errors:R(De),messages:R(De),success:Ae(),result:pt});Z({errors:R(De),messages:R(De),success:Ae(),result:R(pt)});function se(t){return kt(`https://api.cloudflare.com/client/v4/zones/${t.zoneId}`).headers({"X-Auth-Email":t.authEmail,"X-Auth-Key":t.authKey,"Content-Type":"application/json"}).middlewares([Pn(),Dn()])}function We(t){const e=[];if(t.ssl.validation_records)for(const n of t.ssl.validation_records)n.txt_name&&n.txt_value&&e.push({name:"txt",record:n.txt_value,domain:n.txt_name});return t.ownership_verification&&e.push({name:"txt",record:t.ownership_verification.value,domain:t.ownership_verification.name}),{custom_domain_id:t.id,domain:t.hostname,primary:t.primary,status:t.status==="active"?"ready":"pending",type:"auth0_managed_certs",verification:{methods:R(xt.verificationMethodsSchema).parse(e)}}}function Wn(t){return{create:async(e,n)=>{const{result:s,errors:r,success:a}=Oe.parse(await se(t).post({hostname:n.domain,ssl:{method:"txt",type:"dv"},custom_metadata:t.enterprise?{tenant_id:e}:void 0},"/custom_hostnames").json());if(!a)throw new Error(JSON.stringify(r));const i=We({...s,primary:!1});return await t.customDomainAdapter.create(e,{custom_domain_id:i.custom_domain_id,domain:i.domain,type:i.type}),i},get:async(e,n)=>{const s=await t.customDomainAdapter.get(e,n);if(!s)throw new fe(404);const r=await se(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json(),{result:a,errors:i,success:o}=Oe.parse(r);if(!o)throw new fe(503,{message:JSON.stringify(i)});if(t.enterprise&&a.custom_metadata?.tenant_id!==e)throw new fe(404);return We({...s,...a})},getByDomain:async e=>t.customDomainAdapter.getByDomain(e),list:async e=>{const n=await t.customDomainAdapter.list(e);return(await Promise.all(n.map(async r=>{try{const a=await se(t).get(`/custom_hostnames/${encodeURIComponent(r.custom_domain_id)}`).json(),{result:i,success:o}=Oe.parse(a);return!o||t.enterprise&&i.custom_metadata?.tenant_id!==e?null:We({...r,...i})}catch{return null}}))).filter(r=>r!==null)},remove:async(e,n)=>{if(t.enterprise){const{result:r,success:a}=Oe.parse(await se(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json());if(!a||r.custom_metadata?.tenant_id!==e)throw new fe(404)}const s=await se(t).delete(`/custom_hostnames/${encodeURIComponent(n)}`).res();return s.ok&&await t.customDomainAdapter.remove(e,n),s.ok},update:async(e,n,s)=>{const r=await se(t).patch(s,`/custom_hostnames/${encodeURIComponent(n)}`).res();if(!r.ok)throw new fe(503,{message:await r.text()});return t.customDomainAdapter.update(e,n,s)}}}class Qn{constructor(e){this.config=e}cache=null;async getCache(){if(this.cache)return this.cache;if(typeof caches>"u")throw new Error("caches API is not available - CloudflareCache should only be used in Cloudflare Workers");return this.config.cacheName?this.cache=await caches.open(this.config.cacheName):this.cache=caches.default,this.cache}getKey(e){return this.config.keyPrefix?`${this.config.keyPrefix}:${e}`:e}createRequest(e){return new Request(`https://cache.internal/${this.getKey(e)}`)}async get(e){try{const n=await this.getCache(),s=this.createRequest(e),r=await n.match(s);if(!r)return null;const a=await r.json();return a.expiresAt&&new Date(a.expiresAt)<new Date?(await this.delete(e),null):a.value}catch(n){return console.error(`CloudflareCache: get error for key ${e}:`,n),null}}async set(e,n,s){try{const r=await this.getCache(),a=s??this.config.defaultTtlSeconds,i=a!==void 0,o=i?Math.max(0,a):0,c={value:n,expiresAt:i?new Date(Date.now()+(o>0?o*1e3:-1)).toISOString():void 0,cachedAt:new Date().toISOString()},d=this.createRequest(e),h={"Content-Type":"application/json"};i&&o>0&&(h["Cache-Control"]=`max-age=${o}`);const x=new Response(JSON.stringify(c),{headers:h});await r.put(d,x)}catch(r){console.error(`CloudflareCache: set error for key ${e}:`,r)}}async delete(e){try{const n=await this.getCache(),s=this.createRequest(e);return await n.delete(s)}catch(n){return console.error(`CloudflareCache: delete error for key ${e}:`,n),!1}}async clear(){console.warn("CloudflareCache.clear() is not implemented - Cloudflare Cache API does not support clearing all entries")}}function Hn(t={}){const e={defaultTtlSeconds:300,keyPrefix:"authhero",...t};return new Qn(e)}const Jn="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let mt=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=Jn[n[t]&63];return e};async function Ke(t,e){const n=t.timeout||3e4,s=new AbortController,r=setTimeout(()=>s.abort(),n);try{const a=`https://api.sql.cloudflarestorage.com/api/v1/accounts/${t.accountId}/r2-sql/query/${t.warehouseName}`,i=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.authToken}`},body:JSON.stringify({query:e}),signal:s.signal});if(!i.ok)throw new Error(`R2 SQL query failed: ${i.status} ${i.statusText}`);const o=await i.json();if(!o.success&&o.errors)throw new Error(`R2 SQL error: ${o.errors.join(", ")}`);return o.data||o.result?.data||[]}finally{clearTimeout(r)}}function Le(t){return`'${t.replace(/'/g,"''")}'`}function q(t){return`"${t.replace(/"/g,'""')}"`}function yt(t){const e=n=>{if(!n)return"";try{return JSON.parse(n)}catch{return n}};return{type:t.type,date:t.date,description:t.description,ip:t.ip,user_agent:t.user_agent,details:e(t.details),isMobile:!!t.isMobile,user_id:t.user_id,user_name:t.user_name,connection:t.connection,connection_id:t.connection_id,client_id:t.client_id,client_name:t.client_name,audience:t.audience,scope:t.scope,strategy:t.strategy,strategy_type:t.strategy_type,hostname:t.hostname,auth0_client:e(t.auth0_client),log_id:t.id,location_info:t.country_code||t.city_name||t.latitude||t.longitude||t.time_zone||t.continent_code?{country_code:t.country_code||"",city_name:t.city_name||"",latitude:t.latitude||"",longitude:t.longitude||"",time_zone:t.time_zone||"",continent_code:t.continent_code||""}:void 0}}function Yn(t){return async(e,n)=>{const s=n.log_id||mt(),r={...n,log_id:s};return await Kn(t,e,r),r}}async function Kn(t,e,n){const s=a=>a?JSON.stringify(a):void 0,r={id:n.log_id,tenant_id:e,type:n.type,date:n.date,description:n.description?.substring(0,256),ip:n.ip,user_agent:n.user_agent,details:s(n.details)?.substring(0,8192),isMobile:n.isMobile?1:0,user_id:n.user_id,user_name:n.user_name,connection:n.connection,connection_id:n.connection_id,client_id:n.client_id,client_name:n.client_name,audience:n.audience,scope:n.scope,strategy:n.strategy,strategy_type:n.strategy_type,hostname:n.hostname,auth0_client:s(n.auth0_client),log_id:n.log_id,country_code:n.location_info?.country_code,city_name:n.location_info?.city_name,latitude:n.location_info?.latitude,longitude:n.location_info?.longitude,time_zone:n.location_info?.time_zone,continent_code:n.location_info?.continent_code};try{if(t.pipelineBinding)await t.pipelineBinding.send([r]);else if(t.pipelineEndpoint){const a=t.timeout||3e4,i=new AbortController,o=setTimeout(()=>i.abort(),a);try{const c=await fetch(t.pipelineEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([r]),signal:i.signal});if(!c.ok)throw new Error(`Pipeline ingestion failed: ${c.status} ${c.statusText}`)}finally{clearTimeout(o)}}else throw new Error("Either pipelineEndpoint or pipelineBinding must be configured")}catch(a){throw console.error("Failed to send log to Pipeline:",a),a}}function Gn(t){return async(e,n)=>{const s=t.namespace||"default",r=t.tableName||"logs",a=`
2
2
  SELECT * FROM ${q(s)}.${q(r)}
3
- WHERE tenant_id = ${Ze(e)}
4
- AND id = ${Ze(n)}
3
+ WHERE tenant_id = ${Le(e)}
4
+ AND id = ${Le(n)}
5
5
  LIMIT 1
6
- `,i=await Ye(t,a);if(i.length===0)return null;const o=i[0];return o?ht(o):null}}function Yn(t){const e={};return(t.match(/(\w+):(\S+)/g)||[]).forEach(s=>{const[r,a]=s.split(":");r&&a&&(e[r]=a)}),e}function Gn(t){const e=[];for(const[n,s]of Object.entries(t)){const r=n.replace(/[^a-zA-Z0-9_]/g,"");r&&s&&e.push(`${q(r)} = ${Ze(s)}`)}return e}function Kn(t){return async(e,n={})=>{const{page:s=0,per_page:r=50,include_totals:a=!1,sort:i,q:o}=n,c=t.namespace||"default",d=t.tableName||"logs",h=[`tenant_id = ${Ze(e)}`];if(o){const Y=Yn(o);h.push(...Gn(Y))}const x=h.join(" AND ");let T="ORDER BY date DESC";if(i&&i.sort_by){const Y=i.sort_by.replace(/[^a-zA-Z0-9_]/g,""),de=i.sort_order==="asc"?"ASC":"DESC";T=`ORDER BY ${q(Y)} ${de}`}const w=s*r,N=`LIMIT ${r} OFFSET ${w}`,te=`
6
+ `,i=await Ke(t,a);if(i.length===0)return null;const o=i[0];return o?yt(o):null}}function Xn(t){const e={};return(t.match(/(\w+):(\S+)/g)||[]).forEach(s=>{const[r,a]=s.split(":");r&&a&&(e[r]=a)}),e}function es(t){const e=[];for(const[n,s]of Object.entries(t)){const r=n.replace(/[^a-zA-Z0-9_]/g,"");r&&s&&e.push(`${q(r)} = ${Le(s)}`)}return e}function ts(t){return async(e,n={})=>{const{page:s=0,per_page:r=50,include_totals:a=!1,sort:i,q:o}=n,c=t.namespace||"default",d=t.tableName||"logs",h=[`tenant_id = ${Le(e)}`];if(o){const G=Xn(o);h.push(...es(G))}const x=h.join(" AND ");let S="ORDER BY date DESC";if(i&&i.sort_by){const G=i.sort_by.replace(/[^a-zA-Z0-9_]/g,""),ue=i.sort_order==="asc"?"ASC":"DESC";S=`ORDER BY ${q(G)} ${ue}`}const w=s*r,A=`LIMIT ${r} OFFSET ${w}`,Y=`
7
7
  SELECT * FROM ${q(c)}.${q(d)}
8
8
  WHERE ${x}
9
- ${T}
10
- ${N}
11
- `,V=(await Ye(t,te)).map(ht);if(!a)return{logs:V,start:0,limit:0,length:0};const E=`
9
+ ${S}
10
+ ${A}
11
+ `,V=(await Ke(t,Y)).map(yt);if(!a)return{logs:V,start:0,limit:0,length:0};const O=`
12
12
  SELECT COUNT(*) as count FROM ${q(c)}.${q(d)}
13
13
  WHERE ${x}
14
- `,H=(await Ye(t,E))[0]?.count||0;return{logs:V,start:w,limit:r,length:Number(H)}}}function pt(t){const e=!!t.pipelineEndpoint,n=!!t.pipelineBinding;if(!e&&!n)throw new Error('R2 SQL logs adapter requires one of: "pipelineEndpoint" or "pipelineBinding"');if(!t.authToken)throw new Error('R2 SQL logs adapter requires "authToken" configuration');if(!t.warehouseName)throw new Error('R2 SQL logs adapter requires "warehouseName" configuration');return{create:Jn(t),list:Kn(t),get:Hn(t)}}async function Ge(t,e){const n=t.timeout||3e4,s=new AbortController,r=setTimeout(()=>s.abort(),n);try{const a=`https://api.cloudflare.com/client/v4/accounts/${t.accountId}/analytics_engine/sql`,i=await fetch(a,{method:"POST",headers:{"Content-Type":"text/plain",Authorization:`Bearer ${t.apiToken}`},body:e,signal:s.signal});if(!i.ok){const c=await i.text();throw new Error(`Analytics Engine query failed: ${i.status} ${i.statusText} - ${c}`)}const o=await i.json();if(!o.success&&o.errors&&o.errors.length>0)throw new Error(`Analytics Engine error: ${o.errors.map(c=>c.message).join(", ")}`);return o.data||[]}finally{clearTimeout(r)}}function Pe(t){return`'${t.replace(/'/g,"''").replace(/\\/g,"\\\\")}'`}function Ke(t){return`"${t.replace(/"/g,'""')}"`}function mt(t){const e=r=>{if(r)try{return JSON.parse(r)}catch{return}},n=t.double2||t.timestamp,s=n?new Date(n).toISOString():"";return{log_id:t.blob1,type:t.blob3,date:s,description:t.blob4,ip:t.blob5,user_agent:t.blob6,user_id:t.blob7,user_name:t.blob8,connection:t.blob9,connection_id:t.blob10,client_id:t.blob11,client_name:t.blob12,audience:t.blob13,scope:t.blob14,strategy:t.blob15,strategy_type:t.blob16,hostname:t.blob17,details:e(t.blob18),auth0_client:e(t.blob19),location_info:e(t.blob20),isMobile:t.double1===1}}function Xn(t){return async(e,n)=>{const s=n.log_id||ft(),r={...n,log_id:s};return es(t,e,r),r}}function es(t,e,n){if(!t.analyticsEngineBinding){console.error("Analytics Engine binding not configured");return}const s=a=>a==null?"":typeof a=="string"?a:JSON.stringify(a),r=(a,i=1024)=>a.substring(0,i);try{t.analyticsEngineBinding.writeDataPoint({blobs:[r(n.log_id),r(e),r(n.type||""),r(n.description||""),r(n.ip||""),r(n.user_agent||""),r(n.user_id||""),r(n.user_name||""),r(n.connection||""),r(n.connection_id||""),r(n.client_id||""),r(n.client_name||""),r(n.audience||""),r(n.scope||""),r(n.strategy||""),r(n.strategy_type||""),r(n.hostname||""),r(s(n.details)),r(s(n.auth0_client)),r(s(n.location_info))],doubles:[n.isMobile?1:0,new Date(n.date).getTime()],indexes:[e.substring(0,96)]})}catch(a){console.error("Failed to write log to Analytics Engine:",a)}}function ts(t){return async(e,n)=>{const s=t.dataset||"authhero_logs",r=`
14
+ `,K=(await Ke(t,O))[0]?.count||0;return{logs:V,start:w,limit:r,length:Number(K)}}}function ns(){return{async getDaily(){throw new Error("Stats queries are not supported by R2 SQL logs adapter. Use Analytics Engine or Kysely adapter instead.")},async getActiveUsers(){throw new Error("Stats queries are not supported by R2 SQL logs adapter. Use Analytics Engine or Kysely adapter instead.")}}}function _t(t){const e=!!t.pipelineEndpoint,n=!!t.pipelineBinding;if(!e&&!n)throw new Error('R2 SQL logs adapter requires one of: "pipelineEndpoint" or "pipelineBinding"');if(!t.authToken)throw new Error('R2 SQL logs adapter requires "authToken" configuration');if(!t.warehouseName)throw new Error('R2 SQL logs adapter requires "warehouseName" configuration');return{create:Yn(t),list:ts(t),get:Gn(t)}}async function Ee(t,e){const n=t.timeout||3e4,s=new AbortController,r=setTimeout(()=>s.abort(),n);try{const a=`https://api.cloudflare.com/client/v4/accounts/${t.accountId}/analytics_engine/sql`,i=await fetch(a,{method:"POST",headers:{"Content-Type":"text/plain",Authorization:`Bearer ${t.apiToken}`},body:e,signal:s.signal});if(!i.ok){const c=await i.text();throw new Error(`Analytics Engine query failed: ${i.status} ${i.statusText} - ${c}`)}const o=await i.json();if(!o.success&&o.errors&&o.errors.length>0)throw new Error(`Analytics Engine error: ${o.errors.map(c=>c.message).join(", ")}`);return o.data||[]}finally{clearTimeout(r)}}function F(t){return`'${t.replace(/'/g,"''").replace(/\\/g,"\\\\")}'`}function Ge(t){return`"${t.replace(/"/g,'""')}"`}function gt(t){const e=r=>{if(r)try{return JSON.parse(r)}catch{return}},n=t.double2||t.timestamp,s=n?new Date(n).toISOString():"";return{log_id:t.blob1,type:t.blob3,date:s,description:t.blob4,ip:t.blob5,user_agent:t.blob6,user_id:t.blob7,user_name:t.blob8,connection:t.blob9,connection_id:t.blob10,client_id:t.blob11,client_name:t.blob12,audience:t.blob13,scope:t.blob14,strategy:t.blob15,strategy_type:t.blob16,hostname:t.blob17,details:e(t.blob18),auth0_client:e(t.blob19),location_info:e(t.blob20),isMobile:t.double1===1}}function ss(t){return async(e,n)=>{const s=n.log_id||mt(),r={...n,log_id:s};return rs(t,e,r),r}}function rs(t,e,n){if(!t.analyticsEngineBinding){console.error("Analytics Engine binding not configured");return}const s=a=>a==null?"":typeof a=="string"?a:JSON.stringify(a),r=(a,i=1024)=>a.substring(0,i);try{t.analyticsEngineBinding.writeDataPoint({blobs:[r(n.log_id),r(e),r(n.type||""),r(n.description||""),r(n.ip||""),r(n.user_agent||""),r(n.user_id||""),r(n.user_name||""),r(n.connection||""),r(n.connection_id||""),r(n.client_id||""),r(n.client_name||""),r(n.audience||""),r(n.scope||""),r(n.strategy||""),r(n.strategy_type||""),r(n.hostname||""),r(s(n.details)),r(s(n.auth0_client)),r(s(n.location_info))],doubles:[n.isMobile?1:0,new Date(n.date).getTime()],indexes:[e.substring(0,96)]})}catch(a){console.error("Failed to write log to Analytics Engine:",a)}}function as(t){return async(e,n)=>{const s=t.dataset||"authhero_logs",r=`
15
15
  SELECT *
16
- FROM ${Ke(s)}
17
- WHERE index1 = ${Pe(e)}
18
- AND blob1 = ${Pe(n)}
16
+ FROM ${Ge(s)}
17
+ WHERE index1 = ${F(e)}
18
+ AND blob1 = ${F(n)}
19
19
  LIMIT 1
20
- `,a=await Ge(t,r);return a.length===0||!a[0]?null:mt(a[0])}}function ns(t){const e={};return(t.match(/(\w+):(\S+)/g)||[]).forEach(s=>{const r=s.indexOf(":"),a=s.substring(0,r),i=s.substring(r+1);a&&i&&(e[a]=i)}),e}function yt(t){return{log_id:"blob1",tenant_id:"blob2",type:"blob3",description:"blob4",ip:"blob5",user_agent:"blob6",user_id:"blob7",user_name:"blob8",connection:"blob9",connection_id:"blob10",client_id:"blob11",client_name:"blob12",audience:"blob13",scope:"blob14",strategy:"blob15",strategy_type:"blob16",hostname:"blob17"}[t]||null}function ss(t){const e=[];for(const[n,s]of Object.entries(t)){const r=yt(n);r&&s&&e.push(`${r} = ${Pe(s)}`)}return e}function rs(t){if(t==="date")return"double2";const e=yt(t);return e||"timestamp"}function as(t){return async(e,n={})=>{const{page:s=0,per_page:r=50,include_totals:a=!1,sort:i,q:o}=n,c=t.dataset||"authhero_logs",d=[`index1 = ${Pe(e)}`];if(o){const E=ns(o);d.push(...ss(E))}const h=d.join(" AND ");let x="ORDER BY timestamp DESC";if(i&&i.sort_by){const E=rs(i.sort_by),P=i.sort_order==="asc"?"ASC":"DESC";x=`ORDER BY ${E} ${P}`}const T=s*r,w=`LIMIT ${r} OFFSET ${T}`,N=`
20
+ `,a=await Ee(t,r);return a.length===0||!a[0]?null:gt(a[0])}}function is(t){const e={};return(t.match(/(\w+):(\S+)/g)||[]).forEach(s=>{const r=s.indexOf(":"),a=s.substring(0,r),i=s.substring(r+1);a&&i&&(e[a]=i)}),e}function vt(t){return{log_id:"blob1",tenant_id:"blob2",type:"blob3",description:"blob4",ip:"blob5",user_agent:"blob6",user_id:"blob7",user_name:"blob8",connection:"blob9",connection_id:"blob10",client_id:"blob11",client_name:"blob12",audience:"blob13",scope:"blob14",strategy:"blob15",strategy_type:"blob16",hostname:"blob17"}[t]||null}function os(t){const e=[];for(const[n,s]of Object.entries(t)){const r=vt(n);r&&s&&e.push(`${r} = ${F(s)}`)}return e}function cs(t){if(t==="date")return"double2";const e=vt(t);return e||"timestamp"}function ds(t){return async(e,n={})=>{const{page:s=0,per_page:r=50,include_totals:a=!1,sort:i,q:o}=n,c=t.dataset||"authhero_logs",d=[`index1 = ${F(e)}`];if(o){const O=is(o);d.push(...os(O))}const h=d.join(" AND ");let x="ORDER BY timestamp DESC";if(i&&i.sort_by){const O=cs(i.sort_by),D=i.sort_order==="asc"?"ASC":"DESC";x=`ORDER BY ${O} ${D}`}const S=s*r,w=`LIMIT ${r} OFFSET ${S}`,A=`
21
21
  SELECT *
22
- FROM ${Ke(c)}
22
+ FROM ${Ge(c)}
23
23
  WHERE ${h}
24
24
  ${x}
25
25
  ${w}
26
- `,O=(await Ge(t,N)).map(mt);if(!a)return{logs:O,start:0,limit:0,length:0};const V=`
26
+ `,k=(await Ee(t,A)).map(gt);if(!a)return{logs:k,start:0,limit:0,length:0};const V=`
27
27
  SELECT count() as count
28
- FROM ${Ke(c)}
28
+ FROM ${Ge(c)}
29
29
  WHERE ${h}
30
- `;try{const P=(await Ge(t,V))[0]?.count||0;return{logs:O,start:T,limit:r,length:Number(P)}}catch{return{logs:O,start:T,limit:r,length:O.length}}}}function _t(t){return t.analyticsEngineBinding||console.warn("Analytics Engine: No binding configured. Logs will not be written to Analytics Engine."),(!t.accountId||!t.apiToken)&&console.warn("Analytics Engine: accountId and apiToken are required for querying logs via SQL API."),{create:Xn(t),list:as(t),get:ts(t)}}function is(){return{async getGeoInfo(t){try{const e=t["cf-ipcountry"],n=t["cf-ipcity"],s=t["cf-iplatitude"],r=t["cf-iplongitude"],a=t["cf-timezone"],i=t["cf-ipcontinent"];return e?{country_code:e,city_name:n||"",latitude:s||"",longitude:r||"",time_zone:a||"",continent_code:i||""}:null}catch(e){return console.warn("Failed to get geo info from Cloudflare headers:",e),null}}}}function os(t){const e={customDomains:Fn(t),cache:Un({...t.cacheName&&{cacheName:t.cacheName},...t.defaultTtlSeconds!==void 0&&{defaultTtlSeconds:t.defaultTtlSeconds},...t.keyPrefix&&{keyPrefix:t.keyPrefix}}),geo:is()};return t.r2SqlLogs?e.logs=pt(t.r2SqlLogs):t.analyticsEngineLogs&&(e.logs=_t(t.analyticsEngineLogs)),e}exports.createAnalyticsEngineLogsAdapter=_t;exports.createR2SQLLogsAdapter=pt;exports.default=os;
30
+ `;try{const D=(await Ee(t,V))[0]?.count||0;return{logs:k,start:S,limit:r,length:Number(D)}}catch{return{logs:k,start:S,limit:r,length:k.length}}}}const rt=["s","seacft","seccft","sepft","sertft","ssa"],us=["pwd_leak","signup_pwd_leak","reset_pwd_leak"];function at(t){return`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`}function it(t){return t.toISOString().split("T")[0]}function ls(t){const e=t.dataset||"authhero_logs";return{async getDaily(n,s={}){const{from:r,to:a}=s,i=new Date,o=new Date(i);o.setDate(o.getDate()-30);const c=r?at(r):it(o),d=a?at(a):it(i),h=new Date(`${c}T00:00:00Z`).getTime(),x=new Date(`${d}T23:59:59.999Z`).getTime(),S=rt.map(k=>F(k)).join(", "),w=us.map(k=>F(k)).join(", "),A=`
31
+ SELECT
32
+ toDate(toDateTime(double2 / 1000)) AS date,
33
+ SUM(CASE WHEN blob3 IN (${S}) THEN 1 ELSE 0 END) AS logins,
34
+ SUM(CASE WHEN blob3 = 'ss' THEN 1 ELSE 0 END) AS signups,
35
+ SUM(CASE WHEN blob3 IN (${w}) THEN 1 ELSE 0 END) AS leaked_passwords,
36
+ MIN(double2) AS first_event,
37
+ MAX(double2) AS last_event
38
+ FROM "${e}"
39
+ WHERE index1 = ${F(n)}
40
+ AND double2 >= ${h}
41
+ AND double2 <= ${x}
42
+ GROUP BY date
43
+ ORDER BY date ASC
44
+ `;return(await Ee(t,A)).map(k=>({date:String(k.date),logins:Number(k.logins)||0,signups:Number(k.signups)||0,leaked_passwords:Number(k.leaked_passwords)||0,created_at:k.first_event?new Date(Number(k.first_event)).toISOString():new Date().toISOString(),updated_at:k.last_event?new Date(Number(k.last_event)).toISOString():new Date().toISOString()}))},async getActiveUsers(n){const s=new Date;s.setDate(s.getDate()-30);const r=s.getTime(),a=rt.map(d=>F(d)).join(", "),i=`
45
+ SELECT COUNT(DISTINCT blob7) AS count
46
+ FROM "${e}"
47
+ WHERE index1 = ${F(n)}
48
+ AND double2 >= ${r}
49
+ AND blob3 IN (${a})
50
+ AND blob7 IS NOT NULL
51
+ AND blob7 != ''
52
+ `,c=(await Ee(t,i))[0];return c&&c.count!==void 0&&Number(c.count)||0}}}function bt(t){return t.analyticsEngineBinding||console.warn("Analytics Engine: No binding configured. Logs will not be written to Analytics Engine."),(!t.accountId||!t.apiToken)&&console.warn("Analytics Engine: accountId and apiToken are required for querying logs via SQL API."),{create:ss(t),list:ds(t),get:as(t)}}function fs(){return{async getGeoInfo(t){try{const e=t["cf-ipcountry"],n=t["cf-ipcity"],s=t["cf-iplatitude"],r=t["cf-iplongitude"],a=t["cf-timezone"],i=t["cf-ipcontinent"];return e?{country_code:e,city_name:n||"",latitude:s||"",longitude:r||"",time_zone:a||"",continent_code:i||""}:null}catch(e){return console.warn("Failed to get geo info from Cloudflare headers:",e),null}}}}function hs(t){const e={customDomains:Wn(t),cache:Hn({...t.cacheName&&{cacheName:t.cacheName},...t.defaultTtlSeconds!==void 0&&{defaultTtlSeconds:t.defaultTtlSeconds},...t.keyPrefix&&{keyPrefix:t.keyPrefix}}),geo:fs()};return t.r2SqlLogs?e.logs=_t(t.r2SqlLogs):t.analyticsEngineLogs&&(e.logs=bt(t.analyticsEngineLogs)),e}exports.createAnalyticsEngineLogsAdapter=bt;exports.createAnalyticsEngineStatsAdapter=ls;exports.createR2SQLLogsAdapter=_t;exports.createR2SQLStatsAdapter=ns;exports.default=hs;
@@ -518,6 +518,29 @@ declare const logSchema: z.ZodObject<{
518
518
  } | undefined;
519
519
  }>;
520
520
  export type Log = z.infer<typeof logSchema>;
521
+ declare const dailyStatsSchema: z.ZodObject<{
522
+ date: z.ZodString;
523
+ logins: z.ZodNumber;
524
+ signups: z.ZodNumber;
525
+ leaked_passwords: z.ZodNumber;
526
+ updated_at: z.ZodString;
527
+ created_at: z.ZodString;
528
+ }, "strip", z.ZodTypeAny, {
529
+ date: string;
530
+ created_at: string;
531
+ updated_at: string;
532
+ logins: number;
533
+ signups: number;
534
+ leaked_passwords: number;
535
+ }, {
536
+ date: string;
537
+ created_at: string;
538
+ updated_at: string;
539
+ logins: number;
540
+ signups: number;
541
+ leaked_passwords: number;
542
+ }>;
543
+ export type DailyStats = z.infer<typeof dailyStatsSchema>;
521
544
  export interface CacheAdapter {
522
545
  /**
523
546
  * Get a value from the cache
@@ -575,6 +598,20 @@ export interface GeoAdapter {
575
598
  */
576
599
  getGeoInfo(headers: Record<string, string>): Promise<GeoInfo | null>;
577
600
  }
601
+ export interface StatsListParams {
602
+ from?: string;
603
+ to?: string;
604
+ }
605
+ export interface StatsAdapter {
606
+ /**
607
+ * Get daily statistics (logins, signups, etc.) for a date range
608
+ */
609
+ getDaily(tenantId: string, params?: StatsListParams): Promise<DailyStats[]>;
610
+ /**
611
+ * Get the number of active users in the last 30 days
612
+ */
613
+ getActiveUsers(tenantId: string): Promise<number>;
614
+ }
578
615
  export interface R2SQLLogsAdapterConfig {
579
616
  /**
580
617
  * Cloudflare Pipeline HTTP endpoint URL for ingesting logs
@@ -620,6 +657,13 @@ export interface R2SQLLogsAdapterConfig {
620
657
  */
621
658
  timeout?: number;
622
659
  }
660
+ /**
661
+ * Create a stats adapter for R2 SQL that returns "not supported" errors
662
+ *
663
+ * R2 SQL logs does not currently support stats queries.
664
+ * Use the Analytics Engine stats adapter or Kysely stats adapter instead.
665
+ */
666
+ export declare function createR2SQLStatsAdapter(): StatsAdapter;
623
667
  /**
624
668
  * Create an R2 SQL logs adapter
625
669
  *
@@ -714,6 +758,10 @@ export interface AnalyticsEngineLogsAdapterConfig {
714
758
  */
715
759
  timeout?: number;
716
760
  }
761
+ /**
762
+ * Create a stats adapter that queries Analytics Engine
763
+ */
764
+ export declare function createAnalyticsEngineStatsAdapter(config: AnalyticsEngineLogsAdapterConfig): StatsAdapter;
717
765
  /**
718
766
  * Create an Analytics Engine logs adapter
719
767
  *