@authhero/cloudflare-adapter 2.29.0 → 2.29.1

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,12 +1,12 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const vt=require("@authhero/adapter-interfaces"),bt=require("wretch");function xt(t,e){var s={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(s[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(t);r<n.length;r++)e.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(t,n[r])&&(s[n[r]]=t[n[r]]);return s}function wt(t,e){var s;return((s=t?._def)===null||s===void 0?void 0:s.typeName)===e}function ie(t,e){const s=t.ZodType.prototype[e];t.ZodType.prototype[e]=function(...n){const r=s.apply(this,n);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,f,x;const T=typeof r=="string"?a:r,C=T??{},{param:O}=C,M=xt(C,["param"]),w=Object.assign(Object.assign({},(i=this._def.openapi)===null||i===void 0?void 0:i._internal),typeof r=="string"?{refId:r}:void 0),P=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),M),!((d=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||d===void 0)&&d.param||O?{param:Object.assign(Object.assign({},(x=(f=this._def.openapi)===null||f===void 0?void 0:f.metadata)===null||x===void 0?void 0:x.param),O)}:void 0),A=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(w).length>0?{_internal:w}:void 0),Object.keys(P).length>0?{metadata:P}:void 0)}));if(wt(this,"ZodObject")){const k=this.extend;A.extend=function(...S){var N,V,Se,Ce,Ee,Te,Oe;const Ae=k.apply(this,S);return Ae._def.openapi={_internal:{extendedFrom:!((V=(N=this._def.openapi)===null||N===void 0?void 0:N._internal)===null||V===void 0)&&V.refId?{refId:(Ce=(Se=this._def.openapi)===null||Se===void 0?void 0:Se._internal)===null||Ce===void 0?void 0:Ce.refId,schema:this}:(Te=(Ee=this._def.openapi)===null||Ee===void 0?void 0:Ee._internal)===null||Te===void 0?void 0:Te.extendedFrom},metadata:(Oe=Ae._def.openapi)===null||Oe===void 0?void 0:Oe.metadata},Ae}}return A},ie(t,"optional"),ie(t,"nullable"),ie(t,"default"),ie(t,"transform"),ie(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,f;c._def.openapi=(f=(d=r[o])===null||d===void 0?void 0:d._def)===null||f===void 0?void 0:f.openapi}),a._def.openapi=void 0,a};const s=t.ZodObject.prototype.pick;t.ZodObject.prototype.pick=function(...r){const a=s.apply(this,r);return a._def.openapi=void 0,a};const n=t.ZodObject.prototype.omit;t.ZodObject.prototype.omit=function(...r){const a=n.apply(this,r);return a._def.openapi=void 0,a}}var te=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 s(r){throw new Error}t.assertNever=s,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 n(r,a=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(b||(b={}));var Re;(function(t){t.mergeShapes=(e,s)=>({...e,...s})})(Re||(Re={}));const h=b.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),q=t=>{switch(typeof t){case"undefined":return h.undefined;case"string":return h.string;case"number":return Number.isNaN(t)?h.nan:h.number;case"boolean":return h.boolean;case"function":return h.function;case"bigint":return h.bigint;case"symbol":return h.symbol;case"object":return Array.isArray(t)?h.array:t===null?h.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?h.promise:typeof Map<"u"&&t instanceof Map?h.map:typeof Set<"u"&&t instanceof Set?h.set:typeof Date<"u"&&t instanceof Date?h.date:h.object;default:return h.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"]);class B extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const s=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,s):this.__proto__=s,this.name="ZodError",this.issues=e}format(e){const s=e||function(a){return a.message},n={_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)n._errors.push(s(i));else{let o=n,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(s(i))):o[d]=o[d]||{_errors:[]},o=o[d],c++}}};return r(this),n}static assert(e){if(!(e instanceof B))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=s=>s.message){const s={},n=[];for(const r of this.issues)if(r.path.length>0){const a=r.path[0];s[a]=s[a]||[],s[a].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:s}}get formErrors(){return this.flatten()}}B.create=t=>new B(t);const me=(t,e)=>{let s;switch(t.code){case u.invalid_type:t.received===h.undefined?s="Required":s=`Expected ${t.expected}, received ${t.received}`;break;case u.invalid_literal:s=`Invalid literal value, expected ${JSON.stringify(t.expected,b.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:s=`Unrecognized key(s) in object: ${b.joinValues(t.keys,", ")}`;break;case u.invalid_union:s="Invalid input";break;case u.invalid_union_discriminator:s=`Invalid discriminator value. Expected ${b.joinValues(t.options)}`;break;case u.invalid_enum_value:s=`Invalid enum value. Expected ${b.joinValues(t.options)}, received '${t.received}'`;break;case u.invalid_arguments:s="Invalid function arguments";break;case u.invalid_return_type:s="Invalid function return type";break;case u.invalid_date:s="Invalid date";break;case u.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(s=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(s=`${s} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?s=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?s=`Invalid input: must end with "${t.validation.endsWith}"`:b.assertNever(t.validation):t.validation!=="regex"?s=`Invalid ${t.validation}`:s="Invalid";break;case u.too_small:t.type==="array"?s=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?s=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?s=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?s=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?s=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:s="Invalid input";break;case u.too_big:t.type==="array"?s=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?s=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?s=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?s=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?s=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:s="Invalid input";break;case u.custom:s="Invalid input";break;case u.invalid_intersection_types:s="Intersection results could not be merged";break;case u.not_multiple_of:s=`Number must be a multiple of ${t.multipleOf}`;break;case u.not_finite:s="Number must be finite";break;default:s=e.defaultError,b.assertNever(t)}return{message:s}};let St=me;function Xe(){return St}const et=t=>{const{data:e,path:s,errorMaps:n,issueData:r}=t,a=[...s,...r.path||[]],i={...r,path:a};if(r.message!==void 0)return{...r,path:a,message:r.message};let o="";const c=n.filter(d=>!!d).slice().reverse();for(const d of c)o=d(i,{data:e,defaultError:o}).message;return{...r,path:a,message:o}};function l(t,e){const s=Xe(),n=et({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,s,s===me?void 0:me].filter(r=>!!r)});t.common.issues.push(n)}class ${constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,s){const n=[];for(const r of s){if(r.status==="aborted")return y;r.status==="dirty"&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,s){const n=[];for(const r of s){const a=await r.key,i=await r.value;n.push({key:a,value:i})}return $.mergeObjectSync(e,n)}static mergeObjectSync(e,s){const n={};for(const r of s){const{key:a,value:i}=r;if(a.status==="aborted"||i.status==="aborted")return y;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||r.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const y=Object.freeze({status:"aborted"}),ne=t=>({status:"dirty",value:t}),j=t=>({status:"valid",value:t}),Ie=t=>t.status==="aborted",je=t=>t.status==="dirty",Y=t=>t.status==="valid",ce=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 F{constructor(e,s,n,r){this._cachedPath=[],this.parent=e,this.data=s,this._path=n,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 Je=(t,e)=>{if(Y(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 s=new B(t.common.issues);return this._error=s,this._error}}};function _(t){if(!t)return{};const{errorMap:e,invalid_type_error:s,required_error:n,description:r}=t;if(e&&(s||n))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??n??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:c??s??o.defaultError}},description:r}}class v{get description(){return this._def.description}_getType(e){return q(e.data)}_getOrReturnCtx(e,s){return s||{common:e.parent.common,data:e.data,parsedType:q(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new $,ctx:{common:e.parent.common,data:e.data,parsedType:q(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const s=this._parse(e);if(ce(s))throw new Error("Synchronous parse encountered promise.");return s}_parseAsync(e){const s=this._parse(e);return Promise.resolve(s)}parse(e,s){const n=this.safeParse(e,s);if(n.success)return n.data;throw n.error}safeParse(e,s){const n={common:{issues:[],async:s?.async??!1,contextualErrorMap:s?.errorMap},path:s?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:q(e)},r=this._parseSync({data:e,path:n.path,parent:n});return Je(n,r)}"~validate"(e){const s={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:q(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:s});return Y(n)?{value:n.value}:{issues:s.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),s.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:s}).then(n=>Y(n)?{value:n.value}:{issues:s.common.issues})}async parseAsync(e,s){const n=await this.safeParseAsync(e,s);if(n.success)return n.data;throw n.error}async safeParseAsync(e,s){const n={common:{issues:[],contextualErrorMap:s?.errorMap,async:!0},path:s?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:q(e)},r=this._parse({data:e,path:n.path,parent:n}),a=await(ce(r)?r:Promise.resolve(r));return Je(n,a)}refine(e,s){const n=r=>typeof s=="string"||typeof s>"u"?{message:s}:typeof s=="function"?s(r):s;return this._refinement((r,a)=>{const i=e(r),o=()=>a.addIssue({code:u.custom,...n(r)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,s){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof s=="function"?s(n,r):s),!1))}_refinement(e){return new Q({schema:this,typeName:m.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:s=>this["~validate"](s)}}optional(){return z.create(this,this._def)}nullable(){return ee.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return L.create(this)}promise(){return fe.create(this,this._def)}or(e){return ue.create([this,e],this._def)}and(e){return le.create(this,e,this._def)}transform(e){return new Q({..._(this._def),schema:this,typeName:m.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const s=typeof e=="function"?e:()=>e;return new ge({..._(this._def),innerType:this,defaultValue:s,typeName:m.ZodDefault})}brand(){return new at({typeName:m.ZodBranded,type:this,..._(this._def)})}catch(e){const s=typeof e=="function"?e:()=>e;return new _e({..._(this._def),innerType:this,catchValue:s,typeName:m.ZodCatch})}describe(e){const s=this.constructor;return new s({...this._def,description:e})}pipe(e){return we.create(this,e)}readonly(){return ve.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ct=/^c[^\s-]{8,}$/i,Et=/^[0-9a-z]+$/,Tt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ot=/^[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,At=/^[a-z0-9_-]{21}$/i,$t=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Nt=/^[-+]?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)?)??$/,Rt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,It="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let $e;const jt=/^(?:(?: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])$/,Dt=/^(?:(?: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])$/,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]))$/,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])$/,Mt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Pt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,tt="((\\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(`^${tt}$`);function st(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const s=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${s}`}function Bt(t){return new RegExp(`^${st(t)}$`)}function nt(t){let e=`${tt}T${st(t)}`;const s=[];return s.push(t.local?"Z?":"Z"),t.offset&&s.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${s.join("|")})`,new RegExp(`^${e}$`)}function Ft(t,e){return!!((e==="v4"||!e)&&jt.test(t)||(e==="v6"||!e)&&Lt.test(t))}function Vt(t,e){if(!$t.test(t))return!1;try{const[s]=t.split(".");if(!s)return!1;const n=s.replace(/-/g,"+").replace(/_/g,"/").padEnd(s.length+(4-s.length%4)%4,"="),r=JSON.parse(atob(n));return!(typeof r!="object"||r===null||"typ"in r&&r?.typ!=="JWT"||!r.alg||e&&r.alg!==e)}catch{return!1}}function qt(t,e){return!!((e==="v4"||!e)&&Dt.test(t)||(e==="v6"||!e)&&Zt.test(t))}class U extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.string){const a=this._getOrReturnCtx(e);return l(a,{code:u.invalid_type,expected:h.string,received:a.parsedType}),y}const n=new $;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}),n.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}),n.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}),n.dirty())}else if(a.kind==="email")Rt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"email",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")$e||($e=new RegExp(It,"u")),$e.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"emoji",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")Ot.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"uuid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")At.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"nanoid",code:u.invalid_string,message:a.message}),n.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}),n.dirty());else if(a.kind==="cuid2")Et.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"cuid2",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")Tt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"ulid",code:u.invalid_string,message:a.message}),n.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}),n.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}),n.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}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(r=this._getOrReturnCtx(e,r),l(r,{code:u.invalid_string,validation:{startsWith:a.value},message:a.message}),n.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}),n.dirty()):a.kind==="datetime"?nt(a).test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:u.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Ut.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:u.invalid_string,validation:"date",message:a.message}),n.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}),n.dirty()):a.kind==="duration"?Nt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"duration",code:u.invalid_string,message:a.message}),n.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}),n.dirty()):a.kind==="jwt"?Vt(e.data,a.alg)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"jwt",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?qt(e.data,a.version)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"cidr",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Mt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"base64",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?Pt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"base64url",code:u.invalid_string,message:a.message}),n.dirty()):b.assertNever(a);return{status:n.value,value:e.data}}_regex(e,s,n){return this.refinement(r=>e.test(r),{validation:s,code:u.invalid_string,...p.errToObj(n)})}_addCheck(e){return new U({...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,s){return this._addCheck({kind:"regex",regex:e,...p.errToObj(s)})}includes(e,s){return this._addCheck({kind:"includes",value:e,position:s?.position,...p.errToObj(s?.message)})}startsWith(e,s){return this._addCheck({kind:"startsWith",value:e,...p.errToObj(s)})}endsWith(e,s){return this._addCheck({kind:"endsWith",value:e,...p.errToObj(s)})}min(e,s){return this._addCheck({kind:"min",value:e,...p.errToObj(s)})}max(e,s){return this._addCheck({kind:"max",value:e,...p.errToObj(s)})}length(e,s){return this._addCheck({kind:"length",value:e,...p.errToObj(s)})}nonempty(e){return this.min(1,p.errToObj(e))}trim(){return new U({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new U({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new U({...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 s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxLength(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e}}U.create=t=>new U({checks:[],typeName:m.ZodString,coerce:t?.coerce??!1,..._(t)});function zt(t,e){const s=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,r=s>n?s:n,a=Number.parseInt(t.toFixed(r).replace(".","")),i=Number.parseInt(e.toFixed(r).replace(".",""));return a%i/10**r}class K 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)!==h.number){const a=this._getOrReturnCtx(e);return l(a,{code:u.invalid_type,expected:h.number,received:a.parsedType}),y}let n;const r=new $;for(const a of this._def.checks)a.kind==="int"?b.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{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)&&(n=this._getOrReturnCtx(e,n),l(n,{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)&&(n=this._getOrReturnCtx(e,n),l(n,{code:u.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="multipleOf"?zt(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),l(n,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:u.not_finite,message:a.message}),r.dirty()):b.assertNever(a);return{status:r.value,value:e.data}}gte(e,s){return this.setLimit("min",e,!0,p.toString(s))}gt(e,s){return this.setLimit("min",e,!1,p.toString(s))}lte(e,s){return this.setLimit("max",e,!0,p.toString(s))}lt(e,s){return this.setLimit("max",e,!1,p.toString(s))}setLimit(e,s,n,r){return new K({...this._def,checks:[...this._def.checks,{kind:e,value:s,inclusive:n,message:p.toString(r)}]})}_addCheck(e){return new K({...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,s){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(s)})}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 s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxValue(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.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,s=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(s===null||n.value>s)&&(s=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(s)&&Number.isFinite(e)}}K.create=t=>new K({checks:[],typeName:m.ZodNumber,coerce:t?.coerce||!1,..._(t)});class re 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)!==h.bigint)return this._getInvalidInput(e);let n;const r=new $;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),l(n,{code:u.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),l(n,{code:u.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),l(n,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):b.assertNever(a);return{status:r.value,value:e.data}}_getInvalidInput(e){const s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:h.bigint,received:s.parsedType}),y}gte(e,s){return this.setLimit("min",e,!0,p.toString(s))}gt(e,s){return this.setLimit("min",e,!1,p.toString(s))}lte(e,s){return this.setLimit("max",e,!0,p.toString(s))}lt(e,s){return this.setLimit("max",e,!1,p.toString(s))}setLimit(e,s,n,r){return new re({...this._def,checks:[...this._def.checks,{kind:e,value:s,inclusive:n,message:p.toString(r)}]})}_addCheck(e){return new re({...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,s){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(s)})}get minValue(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxValue(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e}}re.create=t=>new re({checks:[],typeName:m.ZodBigInt,coerce:t?.coerce??!1,..._(t)});class ye extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.boolean){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:h.boolean,received:n.parsedType}),y}return j(e.data)}}ye.create=t=>new ye({typeName:m.ZodBoolean,coerce:t?.coerce||!1,..._(t)});class de extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==h.date){const a=this._getOrReturnCtx(e);return l(a,{code:u.invalid_type,expected:h.date,received:a.parsedType}),y}if(Number.isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return l(a,{code:u.invalid_date}),y}const n=new $;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"}),n.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"}),n.dirty()):b.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new de({...this._def,checks:[...this._def.checks,e]})}min(e,s){return this._addCheck({kind:"min",value:e.getTime(),message:p.toString(s)})}max(e,s){return this._addCheck({kind:"max",value:e.getTime(),message:p.toString(s)})}get minDate(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e!=null?new Date(e):null}}de.create=t=>new de({checks:[],coerce:t?.coerce||!1,typeName:m.ZodDate,..._(t)});class De extends v{_parse(e){if(this._getType(e)!==h.symbol){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:h.symbol,received:n.parsedType}),y}return j(e.data)}}De.create=t=>new De({typeName:m.ZodSymbol,..._(t)});class Le extends v{_parse(e){if(this._getType(e)!==h.undefined){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:h.undefined,received:n.parsedType}),y}return j(e.data)}}Le.create=t=>new Le({typeName:m.ZodUndefined,..._(t)});class Ze extends v{_parse(e){if(this._getType(e)!==h.null){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:h.null,received:n.parsedType}),y}return j(e.data)}}Ze.create=t=>new Ze({typeName:m.ZodNull,..._(t)});class Me extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return j(e.data)}}Me.create=t=>new Me({typeName:m.ZodAny,..._(t)});class Pe extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return j(e.data)}}Pe.create=t=>new Pe({typeName:m.ZodUnknown,..._(t)});class W extends v{_parse(e){const s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:h.never,received:s.parsedType}),y}}W.create=t=>new W({typeName:m.ZodNever,..._(t)});class Ue extends v{_parse(e){if(this._getType(e)!==h.undefined){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:h.void,received:n.parsedType}),y}return j(e.data)}}Ue.create=t=>new Ue({typeName:m.ZodVoid,..._(t)});class L extends v{_parse(e){const{ctx:s,status:n}=this._processInputParams(e),r=this._def;if(s.parsedType!==h.array)return l(s,{code:u.invalid_type,expected:h.array,received:s.parsedType}),y;if(r.exactLength!==null){const i=s.data.length>r.exactLength.value,o=s.data.length<r.exactLength.value;(i||o)&&(l(s,{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}),n.dirty())}if(r.minLength!==null&&s.data.length<r.minLength.value&&(l(s,{code:u.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&s.data.length>r.maxLength.value&&(l(s,{code:u.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),s.common.async)return Promise.all([...s.data].map((i,o)=>r.type._parseAsync(new F(s,i,s.path,o)))).then(i=>$.mergeArray(n,i));const a=[...s.data].map((i,o)=>r.type._parseSync(new F(s,i,s.path,o)));return $.mergeArray(n,a)}get element(){return this._def.type}min(e,s){return new L({...this._def,minLength:{value:e,message:p.toString(s)}})}max(e,s){return new L({...this._def,maxLength:{value:e,message:p.toString(s)}})}length(e,s){return new L({...this._def,exactLength:{value:e,message:p.toString(s)}})}nonempty(e){return this.min(1,e)}}L.create=(t,e)=>new L({type:t,minLength:null,maxLength:null,exactLength:null,typeName:m.ZodArray,..._(e)});function se(t){if(t instanceof E){const e={};for(const s in t.shape){const n=t.shape[s];e[s]=z.create(se(n))}return new E({...t._def,shape:()=>e})}else return t instanceof L?new L({...t._def,type:se(t.element)}):t instanceof z?z.create(se(t.unwrap())):t instanceof ee?ee.create(se(t.unwrap())):t instanceof J?J.create(t.items.map(e=>se(e))):t}class E 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(),s=b.objectKeys(e);return this._cached={shape:e,keys:s},this._cached}_parse(e){if(this._getType(e)!==h.object){const d=this._getOrReturnCtx(e);return l(d,{code:u.invalid_type,expected:h.object,received:d.parsedType}),y}const{status:n,ctx:r}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof W&&this._def.unknownKeys==="strip"))for(const d in r.data)i.includes(d)||o.push(d);const c=[];for(const d of i){const f=a[d],x=r.data[d];c.push({key:{status:"valid",value:d},value:f._parse(new F(r,x,r.path,d)),alwaysSet:d in r.data})}if(this._def.catchall instanceof W){const d=this._def.unknownKeys;if(d==="passthrough")for(const f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:r.data[f]}});else if(d==="strict")o.length>0&&(l(r,{code:u.unrecognized_keys,keys:o}),n.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const f of o){const x=r.data[f];c.push({key:{status:"valid",value:f},value:d._parse(new F(r,x,r.path,f)),alwaysSet:f in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const d=[];for(const f of c){const x=await f.key,T=await f.value;d.push({key:x,value:T,alwaysSet:f.alwaysSet})}return d}).then(d=>$.mergeObjectSync(n,d)):$.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return p.errToObj,new E({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(s,n)=>{const r=this._def.errorMap?.(s,n).message??n.defaultError;return s.code==="unrecognized_keys"?{message:p.errToObj(e).message??r}:{message:r}}}:{}})}strip(){return new E({...this._def,unknownKeys:"strip"})}passthrough(){return new E({...this._def,unknownKeys:"passthrough"})}extend(e){return new E({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new E({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:m.ZodObject})}setKey(e,s){return this.augment({[e]:s})}catchall(e){return new E({...this._def,catchall:e})}pick(e){const s={};for(const n of b.objectKeys(e))e[n]&&this.shape[n]&&(s[n]=this.shape[n]);return new E({...this._def,shape:()=>s})}omit(e){const s={};for(const n of b.objectKeys(this.shape))e[n]||(s[n]=this.shape[n]);return new E({...this._def,shape:()=>s})}deepPartial(){return se(this)}partial(e){const s={};for(const n of b.objectKeys(this.shape)){const r=this.shape[n];e&&!e[n]?s[n]=r:s[n]=r.optional()}return new E({...this._def,shape:()=>s})}required(e){const s={};for(const n of b.objectKeys(this.shape))if(e&&!e[n])s[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof z;)a=a._def.innerType;s[n]=a}return new E({...this._def,shape:()=>s})}keyof(){return rt(b.objectKeys(this.shape))}}E.create=(t,e)=>new E({shape:()=>t,unknownKeys:"strip",catchall:W.create(),typeName:m.ZodObject,..._(e)});E.strictCreate=(t,e)=>new E({shape:()=>t,unknownKeys:"strict",catchall:W.create(),typeName:m.ZodObject,..._(e)});E.lazycreate=(t,e)=>new E({shape:t,unknownKeys:"strip",catchall:W.create(),typeName:m.ZodObject,..._(e)});class ue extends v{_parse(e){const{ctx:s}=this._processInputParams(e),n=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 s.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new B(o.ctx.common.issues));return l(s,{code:u.invalid_union,unionErrors:i}),y}if(s.common.async)return Promise.all(n.map(async a=>{const i={...s,common:{...s.common,issues:[]},parent:null};return{result:await a._parseAsync({data:s.data,path:s.path,parent:i}),ctx:i}})).then(r);{let a;const i=[];for(const c of n){const d={...s,common:{...s.common,issues:[]},parent:null},f=c._parseSync({data:s.data,path:s.path,parent:d});if(f.status==="valid")return f;f.status==="dirty"&&!a&&(a={result:f,ctx:d}),d.common.issues.length&&i.push(d.common.issues)}if(a)return s.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new B(c));return l(s,{code:u.invalid_union,unionErrors:o}),y}}get options(){return this._def.options}}ue.create=(t,e)=>new ue({options:t,typeName:m.ZodUnion,..._(e)});function Be(t,e){const s=q(t),n=q(e);if(t===e)return{valid:!0,data:t};if(s===h.object&&n===h.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=Be(t[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(s===h.array&&n===h.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=Be(i,o);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return s===h.date&&n===h.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class le extends v{_parse(e){const{status:s,ctx:n}=this._processInputParams(e),r=(a,i)=>{if(Ie(a)||Ie(i))return y;const o=Be(a.value,i.value);return o.valid?((je(a)||je(i))&&s.dirty(),{status:s.value,value:o.data}):(l(n,{code:u.invalid_intersection_types}),y)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>r(a,i)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}le.create=(t,e,s)=>new le({left:t,right:e,typeName:m.ZodIntersection,..._(s)});class J extends v{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.array)return l(n,{code:u.invalid_type,expected:h.array,received:n.parsedType}),y;if(n.data.length<this._def.items.length)return l(n,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;!this._def.rest&&n.data.length>this._def.items.length&&(l(n,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),s.dirty());const a=[...n.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new F(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>$.mergeArray(s,i)):$.mergeArray(s,a)}get items(){return this._def.items}rest(e){return new J({...this._def,rest:e})}}J.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new J({items:t,typeName:m.ZodTuple,rest:null,..._(e)})};class he extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.object)return l(n,{code:u.invalid_type,expected:h.object,received:n.parsedType}),y;const r=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)r.push({key:a._parse(new F(n,o,n.path,o)),value:i._parse(new F(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?$.mergeObjectAsync(s,r):$.mergeObjectSync(s,r)}get element(){return this._def.valueType}static create(e,s,n){return s instanceof v?new he({keyType:e,valueType:s,typeName:m.ZodRecord,..._(n)}):new he({keyType:U.create(),valueType:e,typeName:m.ZodRecord,..._(s)})}}class Fe extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.map)return l(n,{code:u.invalid_type,expected:h.map,received:n.parsedType}),y;const r=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],d)=>({key:r._parse(new F(n,o,n.path,[d,"key"])),value:a._parse(new F(n,c,n.path,[d,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const d=await c.key,f=await c.value;if(d.status==="aborted"||f.status==="aborted")return y;(d.status==="dirty"||f.status==="dirty")&&s.dirty(),o.set(d.value,f.value)}return{status:s.value,value:o}})}else{const o=new Map;for(const c of i){const d=c.key,f=c.value;if(d.status==="aborted"||f.status==="aborted")return y;(d.status==="dirty"||f.status==="dirty")&&s.dirty(),o.set(d.value,f.value)}return{status:s.value,value:o}}}}Fe.create=(t,e,s)=>new Fe({valueType:e,keyType:t,typeName:m.ZodMap,..._(s)});class ae extends v{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.set)return l(n,{code:u.invalid_type,expected:h.set,received:n.parsedType}),y;const r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(l(n,{code:u.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),s.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(l(n,{code:u.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),s.dirty());const a=this._def.valueType;function i(c){const d=new Set;for(const f of c){if(f.status==="aborted")return y;f.status==="dirty"&&s.dirty(),d.add(f.value)}return{status:s.value,value:d}}const o=[...n.data.values()].map((c,d)=>a._parse(new F(n,c,n.path,d)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,s){return new ae({...this._def,minSize:{value:e,message:p.toString(s)}})}max(e,s){return new ae({...this._def,maxSize:{value:e,message:p.toString(s)}})}size(e,s){return this.min(e,s).max(e,s)}nonempty(e){return this.min(1,e)}}ae.create=(t,e)=>new ae({valueType:t,minSize:null,maxSize:null,typeName:m.ZodSet,..._(e)});class Ve extends v{get schema(){return this._def.getter()}_parse(e){const{ctx:s}=this._processInputParams(e);return this._def.getter()._parse({data:s.data,path:s.path,parent:s})}}Ve.create=(t,e)=>new Ve({getter:t,typeName:m.ZodLazy,..._(e)});class qe extends v{_parse(e){if(e.data!==this._def.value){const s=this._getOrReturnCtx(e);return l(s,{received:s.data,code:u.invalid_literal,expected:this._def.value}),y}return{status:"valid",value:e.data}}get value(){return this._def.value}}qe.create=(t,e)=>new qe({value:t,typeName:m.ZodLiteral,..._(e)});function rt(t,e){return new X({values:t,typeName:m.ZodEnum,..._(e)})}class X extends v{_parse(e){if(typeof e.data!="string"){const s=this._getOrReturnCtx(e),n=this._def.values;return l(s,{expected:b.joinValues(n),received:s.parsedType,code:u.invalid_type}),y}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const s=this._getOrReturnCtx(e),n=this._def.values;return l(s,{received:s.data,code:u.invalid_enum_value,options:n}),y}return j(e.data)}get options(){return this._def.values}get enum(){const e={};for(const s of this._def.values)e[s]=s;return e}get Values(){const e={};for(const s of this._def.values)e[s]=s;return e}get Enum(){const e={};for(const s of this._def.values)e[s]=s;return e}extract(e,s=this._def){return X.create(e,{...this._def,...s})}exclude(e,s=this._def){return X.create(this.options.filter(n=>!e.includes(n)),{...this._def,...s})}}X.create=rt;class ze extends v{_parse(e){const s=b.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==h.string&&n.parsedType!==h.number){const r=b.objectValues(s);return l(n,{expected:b.joinValues(r),received:n.parsedType,code:u.invalid_type}),y}if(this._cache||(this._cache=new Set(b.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const r=b.objectValues(s);return l(n,{received:n.data,code:u.invalid_enum_value,options:r}),y}return j(e.data)}get enum(){return this._def.values}}ze.create=(t,e)=>new ze({values:t,typeName:m.ZodNativeEnum,..._(e)});class fe extends v{unwrap(){return this._def.type}_parse(e){const{ctx:s}=this._processInputParams(e);if(s.parsedType!==h.promise&&s.common.async===!1)return l(s,{code:u.invalid_type,expected:h.promise,received:s.parsedType}),y;const n=s.parsedType===h.promise?s.data:Promise.resolve(s.data);return j(n.then(r=>this._def.type.parseAsync(r,{path:s.path,errorMap:s.common.contextualErrorMap})))}}fe.create=(t,e)=>new fe({type:t,typeName:m.ZodPromise,..._(e)});class Q extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===m.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:s,ctx:n}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:i=>{l(n,i),i.fatal?s.abort():s.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const i=r.transform(n.data,a);if(n.common.async)return Promise.resolve(i).then(async o=>{if(s.value==="aborted")return y;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?y:c.status==="dirty"||s.value==="dirty"?ne(c.value):c});{if(s.value==="aborted")return y;const o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?y:o.status==="dirty"||s.value==="dirty"?ne(o.value):o}}if(r.type==="refinement"){const i=o=>{const c=r.refinement(o,a);if(n.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(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?y:(o.status==="dirty"&&s.dirty(),i(o.value),{status:s.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?y:(o.status==="dirty"&&s.dirty(),i(o.value).then(()=>({status:s.value,value:o.value}))))}if(r.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Y(i))return y;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:s.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>Y(i)?Promise.resolve(r.transform(i.value,a)).then(o=>({status:s.value,value:o})):y);b.assertNever(r)}}Q.create=(t,e,s)=>new Q({schema:t,typeName:m.ZodEffects,effect:e,..._(s)});Q.createWithPreprocess=(t,e,s)=>new Q({schema:e,effect:{type:"preprocess",transform:t},typeName:m.ZodEffects,..._(s)});class z extends v{_parse(e){return this._getType(e)===h.undefined?j(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}z.create=(t,e)=>new z({innerType:t,typeName:m.ZodOptional,..._(e)});class ee extends v{_parse(e){return this._getType(e)===h.null?j(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ee.create=(t,e)=>new ee({innerType:t,typeName:m.ZodNullable,..._(e)});class ge extends v{_parse(e){const{ctx:s}=this._processInputParams(e);let n=s.data;return s.parsedType===h.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:s.path,parent:s})}removeDefault(){return this._def.innerType}}ge.create=(t,e)=>new ge({innerType:t,typeName:m.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});class _e extends v{_parse(e){const{ctx:s}=this._processInputParams(e),n={...s,common:{...s.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return ce(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new B(n.common.issues)},input:n.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new B(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}_e.create=(t,e)=>new _e({innerType:t,typeName:m.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});class We extends v{_parse(e){if(this._getType(e)!==h.nan){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:h.nan,received:n.parsedType}),y}return{status:"valid",value:e.data}}}We.create=t=>new We({typeName:m.ZodNaN,..._(t)});class at extends v{_parse(e){const{ctx:s}=this._processInputParams(e),n=s.data;return this._def.type._parse({data:n,path:s.path,parent:s})}unwrap(){return this._def.type}}class we extends v{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?y:a.status==="dirty"?(s.dirty(),ne(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const r=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?y:r.status==="dirty"?(s.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:n.path,parent:n})}}static create(e,s){return new we({in:e,out:s,typeName:m.ZodPipeline})}}class ve extends v{_parse(e){const s=this._def.innerType._parse(e),n=r=>(Y(r)&&(r.value=Object.freeze(r.value)),r);return ce(s)?s.then(r=>n(r)):n(s)}unwrap(){return this._def.innerType}}ve.create=(t,e)=>new ve({innerType:t,typeName:m.ZodReadonly,..._(e)});var m;(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"})(m||(m={}));const g=U.create,it=K.create,ke=ye.create;W.create;const I=L.create,Z=E.create;ue.create;le.create;J.create;const ot=he.create;X.create;fe.create;z.create;ee.create;const Wt=Object.freeze(Object.defineProperty({__proto__:null,DIRTY:ne,INVALID:y,OK:j,ParseStatus:$,Schema:v,ZodAny:Me,ZodArray:L,ZodBigInt:re,ZodBoolean:ye,ZodBranded:at,ZodCatch:_e,ZodDate:de,ZodDefault:ge,ZodEffects:Q,ZodEnum:X,ZodError:B,get ZodFirstPartyTypeKind(){return m},ZodIntersection:le,ZodIssueCode:u,ZodLazy:Ve,ZodLiteral:qe,ZodMap:Fe,ZodNaN:We,ZodNativeEnum:ze,ZodNever:W,ZodNull:Ze,ZodNullable:ee,ZodNumber:K,ZodObject:E,ZodOptional:z,ZodParsedType:h,ZodPipeline:we,ZodPromise:fe,ZodReadonly:ve,ZodRecord:he,ZodSchema:v,ZodSet:ae,ZodString:U,ZodSymbol:De,ZodTransformer:Q,ZodTuple:J,ZodType:v,ZodUndefined:Le,ZodUnion:ue,ZodUnknown:Pe,ZodVoid:Ue,addIssueToContext:l,array:I,boolean:ke,datetimeRegex:nt,defaultErrorMap:me,getErrorMap:Xe,getParsedType:q,isAborted:Ie,isAsync:ce,isDirty:je,isValid:Y,makeIssue:et,number:it,object:Z,get objectUtil(){return Re},record:ot,string:g,get util(){return b}},Symbol.toStringTag,{value:"Module"}));kt(Wt);const Ht=(t,e)=>e.skipDedupe||e.method!=="GET",Jt=(t,e)=>e.method+"@"+t,Qt=t=>t.clone(),Gt=({skip:t=Ht,key:e=Jt,resolver:s=Qt}={})=>{const n=new Map;return r=>(a,i)=>{if(t(a,i))return r(a,i);const o=e(a,i);if(!n.has(o))n.set(o,[]);else return new Promise((c,d)=>{n.get(o).push([c,d])});try{return r(a,i).then(c=>(n.get(o).forEach(([d])=>d(s(c))),n.delete(o),c)).catch(c=>{throw n.get(o).forEach(([,d])=>d(c)),n.delete(o),c})}catch(c){return n.delete(o),Promise.reject(c)}}},Yt=(t,e)=>t*e,Kt=t=>t&&(t.ok||t.status>=400&&t.status<500),Xt=({delayTimer:t=500,delayRamp:e=Yt,maxAttempts:s=10,until:n=Kt,onRetry:r=null,retryOnNetworkError:a=!1,resolveWithLatestResponse:i=!1,skip:o}={})=>c=>(d,f)=>{let x=0;if(o&&o(d,f))return c(d,f);const T=(C,O)=>Promise.resolve(n(C,O)).then(M=>M?C&&i?C:O?Promise.reject(O):C:(x++,!s||x<=s?new Promise(w=>{const P=e(t,x);setTimeout(()=>{typeof r=="function"?Promise.resolve(r({response:C,error:O,url:d,attempt:x,options:f})).then((A={})=>{var k,S;w(c((k=A&&A.url)!==null&&k!==void 0?k:d,(S=A&&A.options)!==null&&S!==void 0?S:f))}):w(c(d,f))},P)}).then(T).catch(w=>{if(!a)throw w;return T(null,w)}):C&&i?C:Promise.reject(O||new Error("Number of attempts exceeded."))));return c(d,f).then(T).catch(C=>{if(!a)throw C;return T(null,C)})},be=Z({code:it(),message:g()}),es=Z({message:g()}),ts=Z({emails:I(g()).optional(),http_body:g().optional(),http_url:g().optional(),txt_name:g().optional(),txt_value:g().optional()}),ss=Z({ciphers:I(g()).optional(),early_hints:g().optional(),http2:g().optional(),min_tls_version:g().optional(),tls_1_3:g().optional()}),ns=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:I(g()).optional(),issuer:g().optional(),method:g(),serial_number:g().optional(),settings:ss.optional(),signature:g().optional(),type:g(),uploaded_on:g().optional(),validation_errors:I(es).optional(),validation_records:I(ts).optional(),wildcard:ke()}),rs=Z({name:g(),type:g(),value:g()}),as=Z({http_body:g().optional(),http_url:g().optional()}),ct=Z({id:g(),ssl:ns,hostname:g(),custom_metadata:ot(g()).optional(),custom_origin_server:g().optional(),custom_origin_sni:g().optional(),ownership_verification:rs.optional(),ownership_verification_http:as.optional(),status:g(),verification_errors:I(g()).optional(),created_at:g()}),oe=Z({errors:I(be),messages:I(be),success:ke(),result:ct});Z({errors:I(be),messages:I(be),success:ke(),result:I(ct)});function G(t){return bt(`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([Xt(),Gt()])}function Qe(t){const e={},s={};if(!t)return{sslOverrides:e,rest:s};for(const[n,r]of Object.entries(t))n.startsWith("ssl.")?e[n.slice(4)]=r:s[n]=r;return{sslOverrides:e,rest:s}}function Ne(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});if(t.ownership_verification&&e.push({name:"txt",record:t.ownership_verification.value,domain:t.ownership_verification.name}),t.ownership_verification_http?.http_body&&t.ownership_verification_http?.http_url&&e.push({name:"http",http_body:t.ownership_verification_http.http_body,http_url:t.ownership_verification_http.http_url}),t.ssl.validation_records)for(const n of t.ssl.validation_records)n.http_body&&n.http_url&&e.push({name:"http",http_body:n.http_body,http_url:n.http_url});const s={...t.domain_metadata||{},"ssl.method":t.ssl.method,"ssl.type":t.ssl.type,"ssl.certificate_authority":t.ssl.certificate_authority};return{custom_domain_id:t.id,domain:t.hostname,primary:t.primary,status:t.status==="active"?"ready":"pending",type:"auth0_managed_certs",verification:{methods:I(vt.verificationMethodsSchema).parse(e)},domain_metadata:s}}function is(t){return{create:async(e,s)=>{const{sslOverrides:n,rest:r}=Qe(s.domain_metadata),{result:a,errors:i,success:o}=oe.parse(await G(t).post({hostname:s.domain,ssl:{method:"txt",type:"dv",...n},custom_metadata:t.enterprise?{tenant_id:e}:void 0},"/custom_hostnames").json());if(!o)throw new Error(JSON.stringify(i));const c=Ne({...a,primary:!1,domain_metadata:r});return await t.customDomainAdapter.create(e,{custom_domain_id:c.custom_domain_id,domain:c.domain,type:c.type,domain_metadata:s.domain_metadata}),c},get:async(e,s)=>{const n=await t.customDomainAdapter.get(e,s);if(!n)throw new te(404);const r=await G(t).get(`/custom_hostnames/${encodeURIComponent(s)}`).json(),{result:a,errors:i,success:o}=oe.parse(r);if(!o)throw new te(503,{message:JSON.stringify(i)});if(t.enterprise&&a.custom_metadata?.tenant_id!==e)throw new te(404);return Ne({...n,...a})},getByDomain:async e=>t.customDomainAdapter.getByDomain(e),list:async e=>{const s=await t.customDomainAdapter.list(e);return(await Promise.all(s.map(async r=>{try{const a=await G(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:Ne({...r,...i})}catch{return null}}))).filter(r=>r!==null)},remove:async(e,s)=>{if(t.enterprise){const{result:r,success:a}=oe.parse(await G(t).get(`/custom_hostnames/${encodeURIComponent(s)}`).json());if(!a||r.custom_metadata?.tenant_id!==e)throw new te(404)}const n=await G(t).delete(`/custom_hostnames/${encodeURIComponent(s)}`).res();return n.ok&&await t.customDomainAdapter.remove(e,s),n.ok},update:async(e,s,n)=>{const{sslOverrides:r}=Qe(n.domain_metadata),a={};if(Object.keys(r).length>0){const i=await G(t).get(`/custom_hostnames/${encodeURIComponent(s)}`).json(),{result:o,success:c}=oe.parse(i);if(!c)throw new te(503,{message:"Failed to fetch current custom hostname state"});a.ssl={method:o.ssl.method,type:o.ssl.type,certificate_authority:o.ssl.certificate_authority,...r}}if(Object.keys(a).length>0){const i=await G(t).patch(a,`/custom_hostnames/${encodeURIComponent(s)}`).res();if(!i.ok)throw new te(503,{message:await i.text()})}return t.customDomainAdapter.update(e,s,n)}}}class os{constructor(e){this.config=e}config;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 s=await this.getCache(),n=this.createRequest(e),r=await s.match(n);if(!r)return null;const a=await r.text();if(!a)return await this.delete(e),null;let i;try{i=JSON.parse(a)}catch{return await this.delete(e),null}return i.expiresAt&&new Date(i.expiresAt)<new Date?(await this.delete(e),null):i.value}catch(s){return console.error(`CloudflareCache: get error for key ${e}:`,s),null}}async set(e,s,n){try{const r=await this.getCache(),a=n??this.config.defaultTtlSeconds,i=a!==void 0,o=i?Math.max(0,a):0,c={value:s,expiresAt:i?new Date(Date.now()+(o>0?o*1e3:-1)).toISOString():void 0,cachedAt:new Date().toISOString()},d=this.createRequest(e),f={"Content-Type":"application/json"};i&&o>0&&(f["Cache-Control"]=`max-age=${o}`);const x=new Response(JSON.stringify(c),{headers:f});await r.put(d,x)}catch(r){console.error(`CloudflareCache: set error for key ${e}:`,r)}}async delete(e){try{const s=await this.getCache(),n=this.createRequest(e);return await s.delete(n)}catch(s){return console.error(`CloudflareCache: delete error for key ${e}:`,s),!1}}async deleteByPrefix(e){return console.warn("CloudflareCache.deleteByPrefix() is not implemented - Cloudflare Cache API does not support prefix-based deletion"),0}async clear(){console.warn("CloudflareCache.clear() is not implemented - Cloudflare Cache API does not support clearing all entries")}}function cs(t={}){const e={defaultTtlSeconds:300,keyPrefix:"authhero",...t};return new os(e)}let ds="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",dt=(t=21)=>{let e="",s=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=ds[s[t]&63];return e};async function He(t,e){const s=t.timeout||3e4,n=new AbortController,r=setTimeout(()=>n.abort(),s);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:n.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 xe(t){return`'${t.replace(/'/g,"''")}'`}function H(t){return`"${t.replace(/"/g,'""')}"`}function ut(t){const e=s=>{if(!s)return"";try{return JSON.parse(s)}catch{return s}};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 us(t){return async(e,s)=>{const n=s.log_id||dt(),r={...s,log_id:n};return await ls(t,e,r),r}}async function ls(t,e,s){const n=a=>a?JSON.stringify(a):void 0,r={id:s.log_id,tenant_id:e,type:s.type,date:s.date,description:s.description?.substring(0,256),ip:s.ip,user_agent:s.user_agent,details:n(s.details)?.substring(0,8192),isMobile:s.isMobile?1:0,user_id:s.user_id,user_name:s.user_name,connection:s.connection,connection_id:s.connection_id,client_id:s.client_id,client_name:s.client_name,audience:s.audience,scope:s.scope,strategy:s.strategy,strategy_type:s.strategy_type,hostname:s.hostname,auth0_client:n(s.auth0_client),log_id:s.log_id,country_code:s.location_info?.country_code,city_name:s.location_info?.city_name,latitude:s.location_info?.latitude,longitude:s.location_info?.longitude,time_zone:s.location_info?.time_zone,continent_code:s.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 hs(t){return async(e,s)=>{const n=t.namespace||"default",r=t.tableName||"logs",a=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const vt=require("@authhero/adapter-interfaces"),bt=require("wretch");function xt(t,e){var s={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(s[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(t);r<n.length;r++)e.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(t,n[r])&&(s[n[r]]=t[n[r]]);return s}function wt(t,e){var s;return((s=t?._def)===null||s===void 0?void 0:s.typeName)===e}function ie(t,e){const s=t.ZodType.prototype[e];t.ZodType.prototype[e]=function(...n){const r=s.apply(this,n);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,f,x;const E=typeof r=="string"?a:r,C=E??{},{param:O}=C,M=xt(C,["param"]),w=Object.assign(Object.assign({},(i=this._def.openapi)===null||i===void 0?void 0:i._internal),typeof r=="string"?{refId:r}:void 0),P=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),M),!((d=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||d===void 0)&&d.param||O?{param:Object.assign(Object.assign({},(x=(f=this._def.openapi)===null||f===void 0?void 0:f.metadata)===null||x===void 0?void 0:x.param),O)}:void 0),A=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(w).length>0?{_internal:w}:void 0),Object.keys(P).length>0?{metadata:P}:void 0)}));if(wt(this,"ZodObject")){const k=this.extend;A.extend=function(...S){var N,V,Se,Ce,Te,Ee,Oe;const Ae=k.apply(this,S);return Ae._def.openapi={_internal:{extendedFrom:!((V=(N=this._def.openapi)===null||N===void 0?void 0:N._internal)===null||V===void 0)&&V.refId?{refId:(Ce=(Se=this._def.openapi)===null||Se===void 0?void 0:Se._internal)===null||Ce===void 0?void 0:Ce.refId,schema:this}:(Ee=(Te=this._def.openapi)===null||Te===void 0?void 0:Te._internal)===null||Ee===void 0?void 0:Ee.extendedFrom},metadata:(Oe=Ae._def.openapi)===null||Oe===void 0?void 0:Oe.metadata},Ae}}return A},ie(t,"optional"),ie(t,"nullable"),ie(t,"default"),ie(t,"transform"),ie(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,f;c._def.openapi=(f=(d=r[o])===null||d===void 0?void 0:d._def)===null||f===void 0?void 0:f.openapi}),a._def.openapi=void 0,a};const s=t.ZodObject.prototype.pick;t.ZodObject.prototype.pick=function(...r){const a=s.apply(this,r);return a._def.openapi=void 0,a};const n=t.ZodObject.prototype.omit;t.ZodObject.prototype.omit=function(...r){const a=n.apply(this,r);return a._def.openapi=void 0,a}}var te=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 s(r){throw new Error}t.assertNever=s,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 n(r,a=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(b||(b={}));var Re;(function(t){t.mergeShapes=(e,s)=>({...e,...s})})(Re||(Re={}));const h=b.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),q=t=>{switch(typeof t){case"undefined":return h.undefined;case"string":return h.string;case"number":return Number.isNaN(t)?h.nan:h.number;case"boolean":return h.boolean;case"function":return h.function;case"bigint":return h.bigint;case"symbol":return h.symbol;case"object":return Array.isArray(t)?h.array:t===null?h.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?h.promise:typeof Map<"u"&&t instanceof Map?h.map:typeof Set<"u"&&t instanceof Set?h.set:typeof Date<"u"&&t instanceof Date?h.date:h.object;default:return h.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"]);class B extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const s=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,s):this.__proto__=s,this.name="ZodError",this.issues=e}format(e){const s=e||function(a){return a.message},n={_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)n._errors.push(s(i));else{let o=n,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(s(i))):o[d]=o[d]||{_errors:[]},o=o[d],c++}}};return r(this),n}static assert(e){if(!(e instanceof B))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=s=>s.message){const s={},n=[];for(const r of this.issues)if(r.path.length>0){const a=r.path[0];s[a]=s[a]||[],s[a].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:s}}get formErrors(){return this.flatten()}}B.create=t=>new B(t);const me=(t,e)=>{let s;switch(t.code){case u.invalid_type:t.received===h.undefined?s="Required":s=`Expected ${t.expected}, received ${t.received}`;break;case u.invalid_literal:s=`Invalid literal value, expected ${JSON.stringify(t.expected,b.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:s=`Unrecognized key(s) in object: ${b.joinValues(t.keys,", ")}`;break;case u.invalid_union:s="Invalid input";break;case u.invalid_union_discriminator:s=`Invalid discriminator value. Expected ${b.joinValues(t.options)}`;break;case u.invalid_enum_value:s=`Invalid enum value. Expected ${b.joinValues(t.options)}, received '${t.received}'`;break;case u.invalid_arguments:s="Invalid function arguments";break;case u.invalid_return_type:s="Invalid function return type";break;case u.invalid_date:s="Invalid date";break;case u.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(s=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(s=`${s} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?s=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?s=`Invalid input: must end with "${t.validation.endsWith}"`:b.assertNever(t.validation):t.validation!=="regex"?s=`Invalid ${t.validation}`:s="Invalid";break;case u.too_small:t.type==="array"?s=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?s=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?s=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?s=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?s=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:s="Invalid input";break;case u.too_big:t.type==="array"?s=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?s=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?s=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?s=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?s=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:s="Invalid input";break;case u.custom:s="Invalid input";break;case u.invalid_intersection_types:s="Intersection results could not be merged";break;case u.not_multiple_of:s=`Number must be a multiple of ${t.multipleOf}`;break;case u.not_finite:s="Number must be finite";break;default:s=e.defaultError,b.assertNever(t)}return{message:s}};let St=me;function Xe(){return St}const et=t=>{const{data:e,path:s,errorMaps:n,issueData:r}=t,a=[...s,...r.path||[]],i={...r,path:a};if(r.message!==void 0)return{...r,path:a,message:r.message};let o="";const c=n.filter(d=>!!d).slice().reverse();for(const d of c)o=d(i,{data:e,defaultError:o}).message;return{...r,path:a,message:o}};function l(t,e){const s=Xe(),n=et({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,s,s===me?void 0:me].filter(r=>!!r)});t.common.issues.push(n)}class ${constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,s){const n=[];for(const r of s){if(r.status==="aborted")return y;r.status==="dirty"&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,s){const n=[];for(const r of s){const a=await r.key,i=await r.value;n.push({key:a,value:i})}return $.mergeObjectSync(e,n)}static mergeObjectSync(e,s){const n={};for(const r of s){const{key:a,value:i}=r;if(a.status==="aborted"||i.status==="aborted")return y;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||r.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const y=Object.freeze({status:"aborted"}),ne=t=>({status:"dirty",value:t}),j=t=>({status:"valid",value:t}),Ie=t=>t.status==="aborted",je=t=>t.status==="dirty",Y=t=>t.status==="valid",ce=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 F{constructor(e,s,n,r){this._cachedPath=[],this.parent=e,this.data=s,this._path=n,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 Je=(t,e)=>{if(Y(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 s=new B(t.common.issues);return this._error=s,this._error}}};function _(t){if(!t)return{};const{errorMap:e,invalid_type_error:s,required_error:n,description:r}=t;if(e&&(s||n))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??n??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:c??s??o.defaultError}},description:r}}class v{get description(){return this._def.description}_getType(e){return q(e.data)}_getOrReturnCtx(e,s){return s||{common:e.parent.common,data:e.data,parsedType:q(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new $,ctx:{common:e.parent.common,data:e.data,parsedType:q(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const s=this._parse(e);if(ce(s))throw new Error("Synchronous parse encountered promise.");return s}_parseAsync(e){const s=this._parse(e);return Promise.resolve(s)}parse(e,s){const n=this.safeParse(e,s);if(n.success)return n.data;throw n.error}safeParse(e,s){const n={common:{issues:[],async:s?.async??!1,contextualErrorMap:s?.errorMap},path:s?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:q(e)},r=this._parseSync({data:e,path:n.path,parent:n});return Je(n,r)}"~validate"(e){const s={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:q(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:s});return Y(n)?{value:n.value}:{issues:s.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),s.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:s}).then(n=>Y(n)?{value:n.value}:{issues:s.common.issues})}async parseAsync(e,s){const n=await this.safeParseAsync(e,s);if(n.success)return n.data;throw n.error}async safeParseAsync(e,s){const n={common:{issues:[],contextualErrorMap:s?.errorMap,async:!0},path:s?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:q(e)},r=this._parse({data:e,path:n.path,parent:n}),a=await(ce(r)?r:Promise.resolve(r));return Je(n,a)}refine(e,s){const n=r=>typeof s=="string"||typeof s>"u"?{message:s}:typeof s=="function"?s(r):s;return this._refinement((r,a)=>{const i=e(r),o=()=>a.addIssue({code:u.custom,...n(r)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,s){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof s=="function"?s(n,r):s),!1))}_refinement(e){return new Q({schema:this,typeName:m.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:s=>this["~validate"](s)}}optional(){return z.create(this,this._def)}nullable(){return ee.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return L.create(this)}promise(){return fe.create(this,this._def)}or(e){return ue.create([this,e],this._def)}and(e){return le.create(this,e,this._def)}transform(e){return new Q({..._(this._def),schema:this,typeName:m.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const s=typeof e=="function"?e:()=>e;return new ge({..._(this._def),innerType:this,defaultValue:s,typeName:m.ZodDefault})}brand(){return new at({typeName:m.ZodBranded,type:this,..._(this._def)})}catch(e){const s=typeof e=="function"?e:()=>e;return new _e({..._(this._def),innerType:this,catchValue:s,typeName:m.ZodCatch})}describe(e){const s=this.constructor;return new s({...this._def,description:e})}pipe(e){return we.create(this,e)}readonly(){return ve.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ct=/^c[^\s-]{8,}$/i,Tt=/^[0-9a-z]+$/,Et=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ot=/^[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,At=/^[a-z0-9_-]{21}$/i,$t=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Nt=/^[-+]?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)?)??$/,Rt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,It="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let $e;const jt=/^(?:(?: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])$/,Dt=/^(?:(?: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])$/,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]))$/,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])$/,Mt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Pt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,tt="((\\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(`^${tt}$`);function st(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const s=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${s}`}function Bt(t){return new RegExp(`^${st(t)}$`)}function nt(t){let e=`${tt}T${st(t)}`;const s=[];return s.push(t.local?"Z?":"Z"),t.offset&&s.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${s.join("|")})`,new RegExp(`^${e}$`)}function Ft(t,e){return!!((e==="v4"||!e)&&jt.test(t)||(e==="v6"||!e)&&Lt.test(t))}function Vt(t,e){if(!$t.test(t))return!1;try{const[s]=t.split(".");if(!s)return!1;const n=s.replace(/-/g,"+").replace(/_/g,"/").padEnd(s.length+(4-s.length%4)%4,"="),r=JSON.parse(atob(n));return!(typeof r!="object"||r===null||"typ"in r&&r?.typ!=="JWT"||!r.alg||e&&r.alg!==e)}catch{return!1}}function qt(t,e){return!!((e==="v4"||!e)&&Dt.test(t)||(e==="v6"||!e)&&Zt.test(t))}class U extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.string){const a=this._getOrReturnCtx(e);return l(a,{code:u.invalid_type,expected:h.string,received:a.parsedType}),y}const n=new $;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}),n.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}),n.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}),n.dirty())}else if(a.kind==="email")Rt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"email",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")$e||($e=new RegExp(It,"u")),$e.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"emoji",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")Ot.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"uuid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")At.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"nanoid",code:u.invalid_string,message:a.message}),n.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}),n.dirty());else if(a.kind==="cuid2")Tt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"cuid2",code:u.invalid_string,message:a.message}),n.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}),n.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}),n.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}),n.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}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(r=this._getOrReturnCtx(e,r),l(r,{code:u.invalid_string,validation:{startsWith:a.value},message:a.message}),n.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}),n.dirty()):a.kind==="datetime"?nt(a).test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:u.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Ut.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:u.invalid_string,validation:"date",message:a.message}),n.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}),n.dirty()):a.kind==="duration"?Nt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"duration",code:u.invalid_string,message:a.message}),n.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}),n.dirty()):a.kind==="jwt"?Vt(e.data,a.alg)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"jwt",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?qt(e.data,a.version)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"cidr",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Mt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"base64",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?Pt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"base64url",code:u.invalid_string,message:a.message}),n.dirty()):b.assertNever(a);return{status:n.value,value:e.data}}_regex(e,s,n){return this.refinement(r=>e.test(r),{validation:s,code:u.invalid_string,...p.errToObj(n)})}_addCheck(e){return new U({...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,s){return this._addCheck({kind:"regex",regex:e,...p.errToObj(s)})}includes(e,s){return this._addCheck({kind:"includes",value:e,position:s?.position,...p.errToObj(s?.message)})}startsWith(e,s){return this._addCheck({kind:"startsWith",value:e,...p.errToObj(s)})}endsWith(e,s){return this._addCheck({kind:"endsWith",value:e,...p.errToObj(s)})}min(e,s){return this._addCheck({kind:"min",value:e,...p.errToObj(s)})}max(e,s){return this._addCheck({kind:"max",value:e,...p.errToObj(s)})}length(e,s){return this._addCheck({kind:"length",value:e,...p.errToObj(s)})}nonempty(e){return this.min(1,p.errToObj(e))}trim(){return new U({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new U({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new U({...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 s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxLength(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e}}U.create=t=>new U({checks:[],typeName:m.ZodString,coerce:t?.coerce??!1,..._(t)});function zt(t,e){const s=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,r=s>n?s:n,a=Number.parseInt(t.toFixed(r).replace(".","")),i=Number.parseInt(e.toFixed(r).replace(".",""));return a%i/10**r}class K 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)!==h.number){const a=this._getOrReturnCtx(e);return l(a,{code:u.invalid_type,expected:h.number,received:a.parsedType}),y}let n;const r=new $;for(const a of this._def.checks)a.kind==="int"?b.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{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)&&(n=this._getOrReturnCtx(e,n),l(n,{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)&&(n=this._getOrReturnCtx(e,n),l(n,{code:u.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="multipleOf"?zt(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),l(n,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:u.not_finite,message:a.message}),r.dirty()):b.assertNever(a);return{status:r.value,value:e.data}}gte(e,s){return this.setLimit("min",e,!0,p.toString(s))}gt(e,s){return this.setLimit("min",e,!1,p.toString(s))}lte(e,s){return this.setLimit("max",e,!0,p.toString(s))}lt(e,s){return this.setLimit("max",e,!1,p.toString(s))}setLimit(e,s,n,r){return new K({...this._def,checks:[...this._def.checks,{kind:e,value:s,inclusive:n,message:p.toString(r)}]})}_addCheck(e){return new K({...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,s){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(s)})}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 s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxValue(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.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,s=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(s===null||n.value>s)&&(s=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(s)&&Number.isFinite(e)}}K.create=t=>new K({checks:[],typeName:m.ZodNumber,coerce:t?.coerce||!1,..._(t)});class re 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)!==h.bigint)return this._getInvalidInput(e);let n;const r=new $;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),l(n,{code:u.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),l(n,{code:u.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),l(n,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):b.assertNever(a);return{status:r.value,value:e.data}}_getInvalidInput(e){const s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:h.bigint,received:s.parsedType}),y}gte(e,s){return this.setLimit("min",e,!0,p.toString(s))}gt(e,s){return this.setLimit("min",e,!1,p.toString(s))}lte(e,s){return this.setLimit("max",e,!0,p.toString(s))}lt(e,s){return this.setLimit("max",e,!1,p.toString(s))}setLimit(e,s,n,r){return new re({...this._def,checks:[...this._def.checks,{kind:e,value:s,inclusive:n,message:p.toString(r)}]})}_addCheck(e){return new re({...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,s){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(s)})}get minValue(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxValue(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e}}re.create=t=>new re({checks:[],typeName:m.ZodBigInt,coerce:t?.coerce??!1,..._(t)});class ye extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.boolean){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:h.boolean,received:n.parsedType}),y}return j(e.data)}}ye.create=t=>new ye({typeName:m.ZodBoolean,coerce:t?.coerce||!1,..._(t)});class de extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==h.date){const a=this._getOrReturnCtx(e);return l(a,{code:u.invalid_type,expected:h.date,received:a.parsedType}),y}if(Number.isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return l(a,{code:u.invalid_date}),y}const n=new $;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"}),n.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"}),n.dirty()):b.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new de({...this._def,checks:[...this._def.checks,e]})}min(e,s){return this._addCheck({kind:"min",value:e.getTime(),message:p.toString(s)})}max(e,s){return this._addCheck({kind:"max",value:e.getTime(),message:p.toString(s)})}get minDate(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e!=null?new Date(e):null}}de.create=t=>new de({checks:[],coerce:t?.coerce||!1,typeName:m.ZodDate,..._(t)});class De extends v{_parse(e){if(this._getType(e)!==h.symbol){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:h.symbol,received:n.parsedType}),y}return j(e.data)}}De.create=t=>new De({typeName:m.ZodSymbol,..._(t)});class Le extends v{_parse(e){if(this._getType(e)!==h.undefined){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:h.undefined,received:n.parsedType}),y}return j(e.data)}}Le.create=t=>new Le({typeName:m.ZodUndefined,..._(t)});class Ze extends v{_parse(e){if(this._getType(e)!==h.null){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:h.null,received:n.parsedType}),y}return j(e.data)}}Ze.create=t=>new Ze({typeName:m.ZodNull,..._(t)});class Me extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return j(e.data)}}Me.create=t=>new Me({typeName:m.ZodAny,..._(t)});class Pe extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return j(e.data)}}Pe.create=t=>new Pe({typeName:m.ZodUnknown,..._(t)});class W extends v{_parse(e){const s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:h.never,received:s.parsedType}),y}}W.create=t=>new W({typeName:m.ZodNever,..._(t)});class Ue extends v{_parse(e){if(this._getType(e)!==h.undefined){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:h.void,received:n.parsedType}),y}return j(e.data)}}Ue.create=t=>new Ue({typeName:m.ZodVoid,..._(t)});class L extends v{_parse(e){const{ctx:s,status:n}=this._processInputParams(e),r=this._def;if(s.parsedType!==h.array)return l(s,{code:u.invalid_type,expected:h.array,received:s.parsedType}),y;if(r.exactLength!==null){const i=s.data.length>r.exactLength.value,o=s.data.length<r.exactLength.value;(i||o)&&(l(s,{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}),n.dirty())}if(r.minLength!==null&&s.data.length<r.minLength.value&&(l(s,{code:u.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&s.data.length>r.maxLength.value&&(l(s,{code:u.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),s.common.async)return Promise.all([...s.data].map((i,o)=>r.type._parseAsync(new F(s,i,s.path,o)))).then(i=>$.mergeArray(n,i));const a=[...s.data].map((i,o)=>r.type._parseSync(new F(s,i,s.path,o)));return $.mergeArray(n,a)}get element(){return this._def.type}min(e,s){return new L({...this._def,minLength:{value:e,message:p.toString(s)}})}max(e,s){return new L({...this._def,maxLength:{value:e,message:p.toString(s)}})}length(e,s){return new L({...this._def,exactLength:{value:e,message:p.toString(s)}})}nonempty(e){return this.min(1,e)}}L.create=(t,e)=>new L({type:t,minLength:null,maxLength:null,exactLength:null,typeName:m.ZodArray,..._(e)});function se(t){if(t instanceof T){const e={};for(const s in t.shape){const n=t.shape[s];e[s]=z.create(se(n))}return new T({...t._def,shape:()=>e})}else return t instanceof L?new L({...t._def,type:se(t.element)}):t instanceof z?z.create(se(t.unwrap())):t instanceof ee?ee.create(se(t.unwrap())):t instanceof J?J.create(t.items.map(e=>se(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(),s=b.objectKeys(e);return this._cached={shape:e,keys:s},this._cached}_parse(e){if(this._getType(e)!==h.object){const d=this._getOrReturnCtx(e);return l(d,{code:u.invalid_type,expected:h.object,received:d.parsedType}),y}const{status:n,ctx:r}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof W&&this._def.unknownKeys==="strip"))for(const d in r.data)i.includes(d)||o.push(d);const c=[];for(const d of i){const f=a[d],x=r.data[d];c.push({key:{status:"valid",value:d},value:f._parse(new F(r,x,r.path,d)),alwaysSet:d in r.data})}if(this._def.catchall instanceof W){const d=this._def.unknownKeys;if(d==="passthrough")for(const f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:r.data[f]}});else if(d==="strict")o.length>0&&(l(r,{code:u.unrecognized_keys,keys:o}),n.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const f of o){const x=r.data[f];c.push({key:{status:"valid",value:f},value:d._parse(new F(r,x,r.path,f)),alwaysSet:f in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const d=[];for(const f of c){const x=await f.key,E=await f.value;d.push({key:x,value:E,alwaysSet:f.alwaysSet})}return d}).then(d=>$.mergeObjectSync(n,d)):$.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return p.errToObj,new T({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(s,n)=>{const r=this._def.errorMap?.(s,n).message??n.defaultError;return s.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:m.ZodObject})}setKey(e,s){return this.augment({[e]:s})}catchall(e){return new T({...this._def,catchall:e})}pick(e){const s={};for(const n of b.objectKeys(e))e[n]&&this.shape[n]&&(s[n]=this.shape[n]);return new T({...this._def,shape:()=>s})}omit(e){const s={};for(const n of b.objectKeys(this.shape))e[n]||(s[n]=this.shape[n]);return new T({...this._def,shape:()=>s})}deepPartial(){return se(this)}partial(e){const s={};for(const n of b.objectKeys(this.shape)){const r=this.shape[n];e&&!e[n]?s[n]=r:s[n]=r.optional()}return new T({...this._def,shape:()=>s})}required(e){const s={};for(const n of b.objectKeys(this.shape))if(e&&!e[n])s[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof z;)a=a._def.innerType;s[n]=a}return new T({...this._def,shape:()=>s})}keyof(){return rt(b.objectKeys(this.shape))}}T.create=(t,e)=>new T({shape:()=>t,unknownKeys:"strip",catchall:W.create(),typeName:m.ZodObject,..._(e)});T.strictCreate=(t,e)=>new T({shape:()=>t,unknownKeys:"strict",catchall:W.create(),typeName:m.ZodObject,..._(e)});T.lazycreate=(t,e)=>new T({shape:t,unknownKeys:"strip",catchall:W.create(),typeName:m.ZodObject,..._(e)});class ue extends v{_parse(e){const{ctx:s}=this._processInputParams(e),n=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 s.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new B(o.ctx.common.issues));return l(s,{code:u.invalid_union,unionErrors:i}),y}if(s.common.async)return Promise.all(n.map(async a=>{const i={...s,common:{...s.common,issues:[]},parent:null};return{result:await a._parseAsync({data:s.data,path:s.path,parent:i}),ctx:i}})).then(r);{let a;const i=[];for(const c of n){const d={...s,common:{...s.common,issues:[]},parent:null},f=c._parseSync({data:s.data,path:s.path,parent:d});if(f.status==="valid")return f;f.status==="dirty"&&!a&&(a={result:f,ctx:d}),d.common.issues.length&&i.push(d.common.issues)}if(a)return s.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new B(c));return l(s,{code:u.invalid_union,unionErrors:o}),y}}get options(){return this._def.options}}ue.create=(t,e)=>new ue({options:t,typeName:m.ZodUnion,..._(e)});function Be(t,e){const s=q(t),n=q(e);if(t===e)return{valid:!0,data:t};if(s===h.object&&n===h.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=Be(t[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(s===h.array&&n===h.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=Be(i,o);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return s===h.date&&n===h.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class le extends v{_parse(e){const{status:s,ctx:n}=this._processInputParams(e),r=(a,i)=>{if(Ie(a)||Ie(i))return y;const o=Be(a.value,i.value);return o.valid?((je(a)||je(i))&&s.dirty(),{status:s.value,value:o.data}):(l(n,{code:u.invalid_intersection_types}),y)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>r(a,i)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}le.create=(t,e,s)=>new le({left:t,right:e,typeName:m.ZodIntersection,..._(s)});class J extends v{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.array)return l(n,{code:u.invalid_type,expected:h.array,received:n.parsedType}),y;if(n.data.length<this._def.items.length)return l(n,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;!this._def.rest&&n.data.length>this._def.items.length&&(l(n,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),s.dirty());const a=[...n.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new F(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>$.mergeArray(s,i)):$.mergeArray(s,a)}get items(){return this._def.items}rest(e){return new J({...this._def,rest:e})}}J.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new J({items:t,typeName:m.ZodTuple,rest:null,..._(e)})};class he extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.object)return l(n,{code:u.invalid_type,expected:h.object,received:n.parsedType}),y;const r=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)r.push({key:a._parse(new F(n,o,n.path,o)),value:i._parse(new F(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?$.mergeObjectAsync(s,r):$.mergeObjectSync(s,r)}get element(){return this._def.valueType}static create(e,s,n){return s instanceof v?new he({keyType:e,valueType:s,typeName:m.ZodRecord,..._(n)}):new he({keyType:U.create(),valueType:e,typeName:m.ZodRecord,..._(s)})}}class Fe extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.map)return l(n,{code:u.invalid_type,expected:h.map,received:n.parsedType}),y;const r=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],d)=>({key:r._parse(new F(n,o,n.path,[d,"key"])),value:a._parse(new F(n,c,n.path,[d,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const d=await c.key,f=await c.value;if(d.status==="aborted"||f.status==="aborted")return y;(d.status==="dirty"||f.status==="dirty")&&s.dirty(),o.set(d.value,f.value)}return{status:s.value,value:o}})}else{const o=new Map;for(const c of i){const d=c.key,f=c.value;if(d.status==="aborted"||f.status==="aborted")return y;(d.status==="dirty"||f.status==="dirty")&&s.dirty(),o.set(d.value,f.value)}return{status:s.value,value:o}}}}Fe.create=(t,e,s)=>new Fe({valueType:e,keyType:t,typeName:m.ZodMap,..._(s)});class ae extends v{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.set)return l(n,{code:u.invalid_type,expected:h.set,received:n.parsedType}),y;const r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(l(n,{code:u.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),s.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(l(n,{code:u.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),s.dirty());const a=this._def.valueType;function i(c){const d=new Set;for(const f of c){if(f.status==="aborted")return y;f.status==="dirty"&&s.dirty(),d.add(f.value)}return{status:s.value,value:d}}const o=[...n.data.values()].map((c,d)=>a._parse(new F(n,c,n.path,d)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,s){return new ae({...this._def,minSize:{value:e,message:p.toString(s)}})}max(e,s){return new ae({...this._def,maxSize:{value:e,message:p.toString(s)}})}size(e,s){return this.min(e,s).max(e,s)}nonempty(e){return this.min(1,e)}}ae.create=(t,e)=>new ae({valueType:t,minSize:null,maxSize:null,typeName:m.ZodSet,..._(e)});class Ve extends v{get schema(){return this._def.getter()}_parse(e){const{ctx:s}=this._processInputParams(e);return this._def.getter()._parse({data:s.data,path:s.path,parent:s})}}Ve.create=(t,e)=>new Ve({getter:t,typeName:m.ZodLazy,..._(e)});class qe extends v{_parse(e){if(e.data!==this._def.value){const s=this._getOrReturnCtx(e);return l(s,{received:s.data,code:u.invalid_literal,expected:this._def.value}),y}return{status:"valid",value:e.data}}get value(){return this._def.value}}qe.create=(t,e)=>new qe({value:t,typeName:m.ZodLiteral,..._(e)});function rt(t,e){return new X({values:t,typeName:m.ZodEnum,..._(e)})}class X extends v{_parse(e){if(typeof e.data!="string"){const s=this._getOrReturnCtx(e),n=this._def.values;return l(s,{expected:b.joinValues(n),received:s.parsedType,code:u.invalid_type}),y}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const s=this._getOrReturnCtx(e),n=this._def.values;return l(s,{received:s.data,code:u.invalid_enum_value,options:n}),y}return j(e.data)}get options(){return this._def.values}get enum(){const e={};for(const s of this._def.values)e[s]=s;return e}get Values(){const e={};for(const s of this._def.values)e[s]=s;return e}get Enum(){const e={};for(const s of this._def.values)e[s]=s;return e}extract(e,s=this._def){return X.create(e,{...this._def,...s})}exclude(e,s=this._def){return X.create(this.options.filter(n=>!e.includes(n)),{...this._def,...s})}}X.create=rt;class ze extends v{_parse(e){const s=b.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==h.string&&n.parsedType!==h.number){const r=b.objectValues(s);return l(n,{expected:b.joinValues(r),received:n.parsedType,code:u.invalid_type}),y}if(this._cache||(this._cache=new Set(b.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const r=b.objectValues(s);return l(n,{received:n.data,code:u.invalid_enum_value,options:r}),y}return j(e.data)}get enum(){return this._def.values}}ze.create=(t,e)=>new ze({values:t,typeName:m.ZodNativeEnum,..._(e)});class fe extends v{unwrap(){return this._def.type}_parse(e){const{ctx:s}=this._processInputParams(e);if(s.parsedType!==h.promise&&s.common.async===!1)return l(s,{code:u.invalid_type,expected:h.promise,received:s.parsedType}),y;const n=s.parsedType===h.promise?s.data:Promise.resolve(s.data);return j(n.then(r=>this._def.type.parseAsync(r,{path:s.path,errorMap:s.common.contextualErrorMap})))}}fe.create=(t,e)=>new fe({type:t,typeName:m.ZodPromise,..._(e)});class Q extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===m.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:s,ctx:n}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:i=>{l(n,i),i.fatal?s.abort():s.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const i=r.transform(n.data,a);if(n.common.async)return Promise.resolve(i).then(async o=>{if(s.value==="aborted")return y;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?y:c.status==="dirty"||s.value==="dirty"?ne(c.value):c});{if(s.value==="aborted")return y;const o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?y:o.status==="dirty"||s.value==="dirty"?ne(o.value):o}}if(r.type==="refinement"){const i=o=>{const c=r.refinement(o,a);if(n.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(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?y:(o.status==="dirty"&&s.dirty(),i(o.value),{status:s.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?y:(o.status==="dirty"&&s.dirty(),i(o.value).then(()=>({status:s.value,value:o.value}))))}if(r.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Y(i))return y;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:s.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>Y(i)?Promise.resolve(r.transform(i.value,a)).then(o=>({status:s.value,value:o})):y);b.assertNever(r)}}Q.create=(t,e,s)=>new Q({schema:t,typeName:m.ZodEffects,effect:e,..._(s)});Q.createWithPreprocess=(t,e,s)=>new Q({schema:e,effect:{type:"preprocess",transform:t},typeName:m.ZodEffects,..._(s)});class z extends v{_parse(e){return this._getType(e)===h.undefined?j(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}z.create=(t,e)=>new z({innerType:t,typeName:m.ZodOptional,..._(e)});class ee extends v{_parse(e){return this._getType(e)===h.null?j(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ee.create=(t,e)=>new ee({innerType:t,typeName:m.ZodNullable,..._(e)});class ge extends v{_parse(e){const{ctx:s}=this._processInputParams(e);let n=s.data;return s.parsedType===h.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:s.path,parent:s})}removeDefault(){return this._def.innerType}}ge.create=(t,e)=>new ge({innerType:t,typeName:m.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});class _e extends v{_parse(e){const{ctx:s}=this._processInputParams(e),n={...s,common:{...s.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return ce(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new B(n.common.issues)},input:n.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new B(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}_e.create=(t,e)=>new _e({innerType:t,typeName:m.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});class We extends v{_parse(e){if(this._getType(e)!==h.nan){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:h.nan,received:n.parsedType}),y}return{status:"valid",value:e.data}}}We.create=t=>new We({typeName:m.ZodNaN,..._(t)});class at extends v{_parse(e){const{ctx:s}=this._processInputParams(e),n=s.data;return this._def.type._parse({data:n,path:s.path,parent:s})}unwrap(){return this._def.type}}class we extends v{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?y:a.status==="dirty"?(s.dirty(),ne(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const r=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?y:r.status==="dirty"?(s.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:n.path,parent:n})}}static create(e,s){return new we({in:e,out:s,typeName:m.ZodPipeline})}}class ve extends v{_parse(e){const s=this._def.innerType._parse(e),n=r=>(Y(r)&&(r.value=Object.freeze(r.value)),r);return ce(s)?s.then(r=>n(r)):n(s)}unwrap(){return this._def.innerType}}ve.create=(t,e)=>new ve({innerType:t,typeName:m.ZodReadonly,..._(e)});var m;(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"})(m||(m={}));const g=U.create,it=K.create,ke=ye.create;W.create;const I=L.create,Z=T.create;ue.create;le.create;J.create;const ot=he.create;X.create;fe.create;z.create;ee.create;const Wt=Object.freeze(Object.defineProperty({__proto__:null,DIRTY:ne,INVALID:y,OK:j,ParseStatus:$,Schema:v,ZodAny:Me,ZodArray:L,ZodBigInt:re,ZodBoolean:ye,ZodBranded:at,ZodCatch:_e,ZodDate:de,ZodDefault:ge,ZodEffects:Q,ZodEnum:X,ZodError:B,get ZodFirstPartyTypeKind(){return m},ZodIntersection:le,ZodIssueCode:u,ZodLazy:Ve,ZodLiteral:qe,ZodMap:Fe,ZodNaN:We,ZodNativeEnum:ze,ZodNever:W,ZodNull:Ze,ZodNullable:ee,ZodNumber:K,ZodObject:T,ZodOptional:z,ZodParsedType:h,ZodPipeline:we,ZodPromise:fe,ZodReadonly:ve,ZodRecord:he,ZodSchema:v,ZodSet:ae,ZodString:U,ZodSymbol:De,ZodTransformer:Q,ZodTuple:J,ZodType:v,ZodUndefined:Le,ZodUnion:ue,ZodUnknown:Pe,ZodVoid:Ue,addIssueToContext:l,array:I,boolean:ke,datetimeRegex:nt,defaultErrorMap:me,getErrorMap:Xe,getParsedType:q,isAborted:Ie,isAsync:ce,isDirty:je,isValid:Y,makeIssue:et,number:it,object:Z,get objectUtil(){return Re},record:ot,string:g,get util(){return b}},Symbol.toStringTag,{value:"Module"}));kt(Wt);const Ht=(t,e)=>e.skipDedupe||e.method!=="GET",Jt=(t,e)=>e.method+"@"+t,Qt=t=>t.clone(),Gt=({skip:t=Ht,key:e=Jt,resolver:s=Qt}={})=>{const n=new Map;return r=>(a,i)=>{if(t(a,i))return r(a,i);const o=e(a,i);if(!n.has(o))n.set(o,[]);else return new Promise((c,d)=>{n.get(o).push([c,d])});try{return r(a,i).then(c=>(n.get(o).forEach(([d])=>d(s(c))),n.delete(o),c)).catch(c=>{throw n.get(o).forEach(([,d])=>d(c)),n.delete(o),c})}catch(c){return n.delete(o),Promise.reject(c)}}},Yt=(t,e)=>t*e,Kt=t=>t&&(t.ok||t.status>=400&&t.status<500),Xt=({delayTimer:t=500,delayRamp:e=Yt,maxAttempts:s=10,until:n=Kt,onRetry:r=null,retryOnNetworkError:a=!1,resolveWithLatestResponse:i=!1,skip:o}={})=>c=>(d,f)=>{let x=0;if(o&&o(d,f))return c(d,f);const E=(C,O)=>Promise.resolve(n(C,O)).then(M=>M?C&&i?C:O?Promise.reject(O):C:(x++,!s||x<=s?new Promise(w=>{const P=e(t,x);setTimeout(()=>{typeof r=="function"?Promise.resolve(r({response:C,error:O,url:d,attempt:x,options:f})).then((A={})=>{var k,S;w(c((k=A&&A.url)!==null&&k!==void 0?k:d,(S=A&&A.options)!==null&&S!==void 0?S:f))}):w(c(d,f))},P)}).then(E).catch(w=>{if(!a)throw w;return E(null,w)}):C&&i?C:Promise.reject(O||new Error("Number of attempts exceeded."))));return c(d,f).then(E).catch(C=>{if(!a)throw C;return E(null,C)})},be=Z({code:it(),message:g()}),es=Z({message:g()}),ts=Z({emails:I(g()).optional(),http_body:g().optional(),http_url:g().optional(),txt_name:g().optional(),txt_value:g().optional()}),ss=Z({ciphers:I(g()).optional(),early_hints:g().optional(),http2:g().optional(),min_tls_version:g().optional(),tls_1_3:g().optional()}),ns=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:I(g()).optional(),issuer:g().optional(),method:g(),serial_number:g().optional(),settings:ss.optional(),signature:g().optional(),type:g(),uploaded_on:g().optional(),validation_errors:I(es).optional(),validation_records:I(ts).optional(),wildcard:ke()}),rs=Z({name:g(),type:g(),value:g()}),as=Z({http_body:g().optional(),http_url:g().optional()}),ct=Z({id:g(),ssl:ns,hostname:g(),custom_metadata:ot(g()).optional(),custom_origin_server:g().optional(),custom_origin_sni:g().optional(),ownership_verification:rs.optional(),ownership_verification_http:as.optional(),status:g(),verification_errors:I(g()).optional(),created_at:g()}),oe=Z({errors:I(be),messages:I(be),success:ke(),result:ct});Z({errors:I(be),messages:I(be),success:ke(),result:I(ct)});function G(t){return bt(`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([Xt(),Gt()])}function Qe(t){const e={},s={};if(!t)return{sslOverrides:e,rest:s};for(const[n,r]of Object.entries(t))n.startsWith("ssl.")?e[n.slice(4)]=r:s[n]=r;return{sslOverrides:e,rest:s}}function Ne(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});if(t.ownership_verification&&e.push({name:"txt",record:t.ownership_verification.value,domain:t.ownership_verification.name}),t.ownership_verification_http?.http_body&&t.ownership_verification_http?.http_url&&e.push({name:"http",http_body:t.ownership_verification_http.http_body,http_url:t.ownership_verification_http.http_url}),t.ssl.validation_records)for(const n of t.ssl.validation_records)n.http_body&&n.http_url&&e.push({name:"http",http_body:n.http_body,http_url:n.http_url});const s={...t.domain_metadata||{},"ssl.method":t.ssl.method,"ssl.type":t.ssl.type,"ssl.certificate_authority":t.ssl.certificate_authority};return{custom_domain_id:t.id,domain:t.hostname,primary:t.primary,status:t.status==="active"?"ready":"pending",type:"auth0_managed_certs",verification:{methods:I(vt.verificationMethodsSchema).parse(e)},domain_metadata:s}}function is(t){return{create:async(e,s)=>{const{sslOverrides:n,rest:r}=Qe(s.domain_metadata),{result:a,errors:i,success:o}=oe.parse(await G(t).post({hostname:s.domain,ssl:{method:"txt",type:"dv",...n},custom_metadata:t.enterprise?{tenant_id:e}:void 0},"/custom_hostnames").json());if(!o)throw new Error(JSON.stringify(i));const c=Ne({...a,primary:!1,domain_metadata:r});return await t.customDomainAdapter.create(e,{custom_domain_id:c.custom_domain_id,domain:c.domain,type:c.type,domain_metadata:s.domain_metadata}),c},get:async(e,s)=>{const n=await t.customDomainAdapter.get(e,s);if(!n)throw new te(404);const r=await G(t).get(`/custom_hostnames/${encodeURIComponent(s)}`).json(),{result:a,errors:i,success:o}=oe.parse(r);if(!o)throw new te(503,{message:JSON.stringify(i)});if(t.enterprise&&a.custom_metadata?.tenant_id!==e)throw new te(404);return Ne({...n,...a})},getByDomain:async e=>t.customDomainAdapter.getByDomain(e),list:async e=>{const s=await t.customDomainAdapter.list(e);return(await Promise.all(s.map(async r=>{try{const a=await G(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:Ne({...r,...i})}catch{return null}}))).filter(r=>r!==null)},remove:async(e,s)=>{if(t.enterprise){const{result:r,success:a}=oe.parse(await G(t).get(`/custom_hostnames/${encodeURIComponent(s)}`).json());if(!a||r.custom_metadata?.tenant_id!==e)throw new te(404)}const n=await G(t).delete(`/custom_hostnames/${encodeURIComponent(s)}`).res();return n.ok&&await t.customDomainAdapter.remove(e,s),n.ok},update:async(e,s,n)=>{const{sslOverrides:r}=Qe(n.domain_metadata),a={};if(Object.keys(r).length>0){const i=await G(t).get(`/custom_hostnames/${encodeURIComponent(s)}`).json(),{result:o,success:c}=oe.parse(i);if(!c)throw new te(503,{message:"Failed to fetch current custom hostname state"});a.ssl={method:o.ssl.method,type:o.ssl.type,certificate_authority:o.ssl.certificate_authority,...r}}if(Object.keys(a).length>0){const i=await G(t).patch(a,`/custom_hostnames/${encodeURIComponent(s)}`).res();if(!i.ok)throw new te(503,{message:await i.text()})}return t.customDomainAdapter.update(e,s,n)}}}class os{constructor(e){this.config=e}config;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 s=await this.getCache(),n=this.createRequest(e),r=await s.match(n);if(!r)return null;const a=await r.text();if(!a)return await this.delete(e),null;let i;try{i=JSON.parse(a)}catch{return await this.delete(e),null}return i.expiresAt&&new Date(i.expiresAt)<new Date?(await this.delete(e),null):i.value}catch(s){return console.error(`CloudflareCache: get error for key ${e}:`,s),null}}async set(e,s,n){try{const r=await this.getCache(),a=n??this.config.defaultTtlSeconds,i=a!==void 0,o=i?Math.max(0,a):0,c={value:s,expiresAt:i?new Date(Date.now()+(o>0?o*1e3:-1)).toISOString():void 0,cachedAt:new Date().toISOString()},d=this.createRequest(e),f={"Content-Type":"application/json"};i&&o>0&&(f["Cache-Control"]=`max-age=${o}`);const x=new Response(JSON.stringify(c),{headers:f});await r.put(d,x)}catch(r){console.error(`CloudflareCache: set error for key ${e}:`,r)}}async delete(e){try{const s=await this.getCache(),n=this.createRequest(e);return await s.delete(n)}catch(s){return console.error(`CloudflareCache: delete error for key ${e}:`,s),!1}}async deleteByPrefix(e){return console.warn("CloudflareCache.deleteByPrefix() is not implemented - Cloudflare Cache API does not support prefix-based deletion"),0}async clear(){console.warn("CloudflareCache.clear() is not implemented - Cloudflare Cache API does not support clearing all entries")}}function cs(t={}){const e={defaultTtlSeconds:300,keyPrefix:"authhero",...t};return new os(e)}let ds="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",dt=(t=21)=>{let e="",s=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=ds[s[t]&63];return e};async function He(t,e){const s=t.timeout||3e4,n=new AbortController,r=setTimeout(()=>n.abort(),s);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:n.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 xe(t){return`'${t.replace(/'/g,"''")}'`}function H(t){return`"${t.replace(/"/g,'""')}"`}function ut(t){const e=s=>{if(!s)return"";try{return JSON.parse(s)}catch{return s}};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 us(t){return async(e,s)=>{const n=s.log_id||dt(),r={...s,log_id:n};return await ls(t,e,r),r}}async function ls(t,e,s){const n=a=>a?JSON.stringify(a):void 0,r={id:s.log_id,tenant_id:e,type:s.type,date:s.date,description:s.description?.substring(0,256),ip:s.ip,user_agent:s.user_agent,details:n(s.details)?.substring(0,8192),isMobile:s.isMobile?1:0,user_id:s.user_id,user_name:s.user_name,connection:s.connection,connection_id:s.connection_id,client_id:s.client_id,client_name:s.client_name,audience:s.audience,scope:s.scope,strategy:s.strategy,strategy_type:s.strategy_type,hostname:s.hostname,auth0_client:n(s.auth0_client),log_id:s.log_id,country_code:s.location_info?.country_code,city_name:s.location_info?.city_name,latitude:s.location_info?.latitude,longitude:s.location_info?.longitude,time_zone:s.location_info?.time_zone,continent_code:s.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 hs(t){return async(e,s)=>{const n=t.namespace||"default",r=t.tableName||"logs",a=`
2
2
  SELECT * FROM ${H(n)}.${H(r)}
3
3
  WHERE tenant_id = ${xe(e)}
4
4
  AND id = ${xe(s)}
5
5
  LIMIT 1
6
- `,i=await He(t,a);if(i.length===0)return null;const o=i[0];return o?ut(o):null}}function fs(t){const e={};return(t.match(/(\w+):(\S+)/g)||[]).forEach(n=>{const[r,a]=n.split(":");r&&a&&(e[r]=a)}),e}function ps(t){const e=[];for(const[s,n]of Object.entries(t)){const r=s.replace(/[^a-zA-Z0-9_]/g,"");r&&n&&e.push(`${H(r)} = ${xe(n)}`)}return e}function ms(t){return async(e,s={})=>{const{page:n=0,per_page:r=50,include_totals:a=!1,sort:i,q:o}=s,c=t.namespace||"default",d=t.tableName||"logs",f=[`tenant_id = ${xe(e)}`];if(o){const N=fs(o);f.push(...ps(N))}const x=f.join(" AND ");let T="ORDER BY date DESC";if(i&&i.sort_by){const N=i.sort_by.replace(/[^a-zA-Z0-9_]/g,""),V=i.sort_order==="asc"?"ASC":"DESC";T=`ORDER BY ${H(N)} ${V}`}const C=n*r,O=`LIMIT ${r} OFFSET ${C}`,M=`
6
+ `,i=await He(t,a);if(i.length===0)return null;const o=i[0];return o?ut(o):null}}function fs(t){const e={};return(t.match(/(\w+):(\S+)/g)||[]).forEach(n=>{const[r,a]=n.split(":");r&&a&&(e[r]=a)}),e}function ps(t){const e=[];for(const[s,n]of Object.entries(t)){const r=s.replace(/[^a-zA-Z0-9_]/g,"");r&&n&&e.push(`${H(r)} = ${xe(n)}`)}return e}function ms(t){return async(e,s={})=>{const{page:n=0,per_page:r=50,include_totals:a=!1,sort:i,q:o}=s,c=t.namespace||"default",d=t.tableName||"logs",f=[`tenant_id = ${xe(e)}`];if(o){const N=fs(o);f.push(...ps(N))}const x=f.join(" AND ");let E="ORDER BY date DESC";if(i&&i.sort_by){const N=i.sort_by.replace(/[^a-zA-Z0-9_]/g,""),V=i.sort_order==="asc"?"ASC":"DESC";E=`ORDER BY ${H(N)} ${V}`}const C=n*r,O=`LIMIT ${r} OFFSET ${C}`,M=`
7
7
  SELECT * FROM ${H(c)}.${H(d)}
8
8
  WHERE ${x}
9
- ${T}
9
+ ${E}
10
10
  ${O}
11
11
  `,P=(await He(t,M)).map(ut);if(!a)return{logs:P,start:0,limit:0,length:0};const A=`
12
12
  SELECT COUNT(*) as count FROM ${H(c)}.${H(d)}
@@ -17,20 +17,20 @@
17
17
  WHERE index1 = ${R(e)}
18
18
  AND blob1 = ${R(s)}
19
19
  LIMIT 1
20
- `,a=await pe(t,r);return a.length===0||!a[0]?null:ht(a[0])}}function bs(t){const e={},s=/(\w+):(?:"([^"]*)"|(\S+))/g;let n;for(;(n=s.exec(t))!==null;){const r=n[1],a=n[2]!==void 0?n[2]:n[3];!r||a===void 0||(e[r]||(e[r]=[]),e[r].push(a))}return e}function ft(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 xs(t){const e=[];for(const[s,n]of Object.entries(t)){const r=n.filter(i=>i!=="");if(r.length===0)continue;if(s==="success"){const i=[],o=new Set;for(const c of r)o.has(c)||(o.add(c),c==="true"?i.push("blob3 LIKE 's%'"):c==="false"&&i.push("blob3 LIKE 'f%'"));i.length>0&&e.push(`(${i.join(" OR ")})`);continue}const a=ft(s);if(a)if(r.length===1)e.push(`${a} = ${R(r[0])}`);else{const i=r.map(o=>R(o)).join(", ");e.push(`${a} IN (${i})`)}}return e}function ws(t){if(t==="date")return"double2";const e=ft(t);return e||"timestamp"}function ks(t){return async(e,s={})=>{const{page:n=0,per_page:r=50,include_totals:a=!1,sort:i,q:o,from_date:c,to_date:d}=s,f=t.dataset||"authhero_logs",x=[`index1 = ${R(e)}`];if(o){const S=bs(o);x.push(...xs(S))}typeof c=="number"&&Number.isFinite(c)&&x.push(`double2 >= ${Math.floor(c)*1e3}`),typeof d=="number"&&Number.isFinite(d)&&x.push(`double2 <= ${Math.floor(d)*1e3}`);const T=x.join(" AND ");let C="ORDER BY timestamp DESC";if(i&&i.sort_by){const S=ws(i.sort_by),N=i.sort_order==="asc"?"ASC":"DESC";C=`ORDER BY ${S} ${N}`}const O=n*r,M=`LIMIT ${r} OFFSET ${O}`,w=`
20
+ `,a=await pe(t,r);return a.length===0||!a[0]?null:ht(a[0])}}function bs(t){const e={},s=/(\w+):(?:"([^"]*)"|(\S+))/g;let n;for(;(n=s.exec(t))!==null;){const r=n[1],a=n[2]!==void 0?n[2]:n[3];!r||a===void 0||(e[r]||(e[r]=[]),e[r].push(a))}return e}function ft(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 xs(t){const e=[];for(const[s,n]of Object.entries(t)){const r=n.filter(i=>i!=="");if(r.length===0)continue;if(s==="success"){const i=[],o=new Set;for(const c of r)o.has(c)||(o.add(c),c==="true"?i.push("blob3 LIKE 's%'"):c==="false"&&i.push("blob3 LIKE 'f%'"));i.length>0&&e.push(`(${i.join(" OR ")})`);continue}const a=ft(s);if(a)if(r.length===1)e.push(`${a} = ${R(r[0])}`);else{const i=r.map(o=>R(o)).join(", ");e.push(`${a} IN (${i})`)}}return e}function ws(t){if(t==="date")return"double2";const e=ft(t);return e||"timestamp"}function ks(t){return async(e,s={})=>{const{page:n=0,per_page:r=50,include_totals:a=!1,sort:i,q:o,from_date:c,to_date:d}=s,f=t.dataset||"authhero_logs",x=[`index1 = ${R(e)}`];if(o){const S=bs(o);x.push(...xs(S))}typeof c=="number"&&Number.isFinite(c)&&x.push(`double2 >= ${Math.floor(c)*1e3}`),typeof d=="number"&&Number.isFinite(d)&&x.push(`double2 <= ${Math.floor(d)*1e3}`);const E=x.join(" AND ");let C="ORDER BY timestamp DESC";if(i&&i.sort_by){const S=ws(i.sort_by),N=i.sort_order==="asc"?"ASC":"DESC";C=`ORDER BY ${S} ${N}`}const O=n*r,M=`LIMIT ${r} OFFSET ${O}`,w=`
21
21
  SELECT *
22
22
  FROM ${D(f)}
23
- WHERE ${T}
23
+ WHERE ${E}
24
24
  ${C}
25
25
  ${M}
26
26
  `,A=(await pe(t,w)).map(ht);if(!a)return{logs:A,start:0,limit:0,length:0};const k=`
27
27
  SELECT count() as count
28
28
  FROM ${D(f)}
29
- WHERE ${T}
30
- `;try{const N=(await pe(t,k))[0]?.count||0;return{logs:A,start:O,limit:r,length:Number(N)}}catch{return{logs:A,start:O,limit:r,length:A.length}}}}const Ge=["s"],Ss=["pwd_leak"];function Ye(t){return`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`}function Ke(t){return t.toISOString().split("T")[0]}function Cs(t){const e=t.dataset||"authhero_logs";return{async getDaily(s,n={}){const{from:r,to:a}=n,i=new Date,o=new Date(i);o.setDate(o.getDate()-30);const c=r?Ye(r):Ke(o),d=a?Ye(a):Ke(i),f=new Date(`${c}T00:00:00Z`).getTime(),x=new Date(`${d}T23:59:59.999Z`).getTime(),T=Ge.map(w=>R(w)).join(", "),C=Ss.map(w=>R(w)).join(", "),O=`
29
+ WHERE ${E}
30
+ `;try{const N=(await pe(t,k))[0]?.count||0;return{logs:A,start:O,limit:r,length:Number(N)}}catch{return{logs:A,start:O,limit:r,length:A.length}}}}const Ge=["s"],Ss=["pwd_leak"];function Ye(t){return`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`}function Ke(t){return t.toISOString().split("T")[0]}function Cs(t){const e=t.dataset||"authhero_logs";return{async getDaily(s,n={}){const{from:r,to:a}=n,i=new Date,o=new Date(i);o.setDate(o.getDate()-30);const c=r?Ye(r):Ke(o),d=a?Ye(a):Ke(i),f=new Date(`${c}T00:00:00Z`).getTime(),x=new Date(`${d}T23:59:59.999Z`).getTime(),E=Ge.map(w=>R(w)).join(", "),C=Ss.map(w=>R(w)).join(", "),O=`
31
31
  SELECT
32
32
  toDate(toDateTime(double2 / 1000)) AS date,
33
- SUM(CASE WHEN blob3 IN (${T}) THEN 1 ELSE 0 END) AS logins,
33
+ SUM(CASE WHEN blob3 IN (${E}) THEN 1 ELSE 0 END) AS logins,
34
34
  SUM(CASE WHEN blob3 = 'ss' THEN 1 ELSE 0 END) AS signups,
35
35
  SUM(CASE WHEN blob3 IN (${C}) THEN 1 ELSE 0 END) AS leaked_passwords,
36
36
  MIN(double2) AS first_event,
@@ -49,12 +49,12 @@
49
49
  AND blob3 IN (${a})
50
50
  AND blob7 IS NOT NULL
51
51
  AND blob7 != ''
52
- `,c=(await pe(t,i))[0];return c&&c.count!==void 0&&Number(c.count)||0}}}const Es={"active-users":["s","seacft"],logins:["s","f","fp"],signups:["ss","fs"],"refresh-tokens":["seacft","fertft"],sessions:["slo"]},Ts={connection:"blob9",client_id:"blob11",user_type:"blob16",event:"blob3"},Os={connection:"blob9",client_id:"blob11",user_type:"blob16",user_id:"blob7"},As={"active-users":{expr:"uniqExact(blob7)",alias:"active_users",type:"UInt64"},logins:{expr:"count()",alias:"logins",type:"UInt64"},signups:{expr:"count()",alias:"signups",type:"UInt64"},"refresh-tokens":{expr:"count()",alias:"refresh_tokens",type:"UInt64"},sessions:{expr:"count()",alias:"sessions",type:"UInt64"}};function $s(t,e){const s=`toDateTime(intDiv(double2, 1000), ${R(e)})`;switch(t){case"hour":return`toStartOfHour(${s})`;case"week":return`toStartOfWeek(${s})`;case"month":return`toStartOfMonth(${s})`;default:return`toStartOfDay(${s})`}}function Ns(t){return t==="hour"?"DateTime":"Date"}function Rs(t,e,s){const n=new Date(t.from).getTime(),r=new Date(t.to).getTime(),a=s.map(o=>R(o)).join(", "),i=[`index1 = ${R(e)}`,`double2 >= ${n}`,`double2 < ${r}`,`blob3 IN (${a})`];for(const[o,c]of Object.entries(Os)){const d=t.filters[o];if(d&&d.length>0){const f=d.map(x=>R(x)).join(", ");i.push(`${c} IN (${f})`)}}return i.join(" AND ")}function Is(t,e,s){if(t.order_by){const n=t.order_by.startsWith("-"),r=n?t.order_by.slice(1):t.order_by;return`${D(r)} ${n?"DESC":"ASC"}`}return e.length>0?e[0]==="time"?`${D("time")} ASC`:`${D(s)} DESC`:`${D(s)} DESC`}function pt(t){const e=t.dataset||"authhero_logs";return{async query(s,n,r){const a=Es[n],i=As[n],o=[],c=[];for(const k of r.group_by)if(k==="time"){const S=$s(r.interval,r.tz);o.push(`${S} AS ${D("time")}`),c.push({name:"time",type:Ns(r.interval)})}else{const S=Ts[k];o.push(`${S} AS ${D(k)}`),c.push({name:k,type:"String"})}c.push({name:i.alias,type:i.type});const d=[...o,`${i.expr} AS ${D(i.alias)}`],f=r.group_by.length?`GROUP BY ${r.group_by.map(k=>D(k==="time"?"time":k)).join(", ")}`:"",x=r.group_by.map(k=>k==="time"?"time":k),T=Is(r,x,i.alias),C=`
52
+ `,c=(await pe(t,i))[0];return c&&c.count!==void 0&&Number(c.count)||0}}}const Ts={"active-users":["s","seacft"],logins:["s","f","fp"],signups:["ss","fs"],"refresh-tokens":["seacft","fertft"],sessions:["slo"]},Es={connection:"blob9",client_id:"blob11",user_type:"blob16",event:"blob3"},Os={connection:"blob9",client_id:"blob11",user_type:"blob16",user_id:"blob7"},As={"active-users":{expr:"count(DISTINCT blob7)",alias:"active_users",type:"UInt64"},logins:{expr:"count()",alias:"logins",type:"UInt64"},signups:{expr:"count()",alias:"signups",type:"UInt64"},"refresh-tokens":{expr:"count()",alias:"refresh_tokens",type:"UInt64"},sessions:{expr:"count()",alias:"sessions",type:"UInt64"}};function $s(t,e){const s=`toDateTime(intDiv(double2, 1000), ${R(e)})`;switch(t){case"hour":return`toStartOfHour(${s})`;case"week":return`toStartOfWeek(${s})`;case"month":return`toStartOfMonth(${s})`;default:return`toStartOfDay(${s})`}}function Ns(t){return t==="hour"?"DateTime":"Date"}function Rs(t,e,s){const n=new Date(t.from).getTime(),r=new Date(t.to).getTime(),a=s.map(o=>R(o)).join(", "),i=[`index1 = ${R(e)}`,`double2 >= ${n}`,`double2 < ${r}`,`blob3 IN (${a})`];for(const[o,c]of Object.entries(Os)){const d=t.filters[o];if(d&&d.length>0){const f=d.map(x=>R(x)).join(", ");i.push(`${c} IN (${f})`)}}return i.join(" AND ")}function Is(t,e,s){if(t.order_by){const n=t.order_by.startsWith("-"),r=n?t.order_by.slice(1):t.order_by;return`${D(r)} ${n?"DESC":"ASC"}`}return e.length>0?e[0]==="time"?`${D("time")} ASC`:`${D(s)} DESC`:`${D(s)} DESC`}function pt(t){const e=t.dataset||"authhero_logs";return{async query(s,n,r){const a=Ts[n],i=As[n],o=[],c=[];for(const k of r.group_by)if(k==="time"){const S=$s(r.interval,r.tz);o.push(`${S} AS ${D("time")}`),c.push({name:"time",type:Ns(r.interval)})}else{const S=Es[k];o.push(`${S} AS ${D(k)}`),c.push({name:k,type:"String"})}c.push({name:i.alias,type:i.type});const d=[...o,`${i.expr} AS ${D(i.alias)}`],f=r.group_by.length?`GROUP BY ${r.group_by.map(k=>D(k==="time"?"time":k)).join(", ")}`:"",x=r.group_by.map(k=>k==="time"?"time":k),E=Is(r,x,i.alias),C=`
53
53
  SELECT ${d.join(", ")}
54
54
  FROM ${D(e)}
55
55
  WHERE ${Rs(r,s,a)}
56
56
  ${f}
57
- ORDER BY ${T}
57
+ ORDER BY ${E}
58
58
  LIMIT ${Math.max(0,r.limit)} OFFSET ${Math.max(0,r.offset)}
59
59
  FORMAT JSON
60
60
  `,O=`https://api.cloudflare.com/client/v4/accounts/${t.accountId}/analytics_engine/sql`,M=t.timeout||3e4,w=new AbortController,P=setTimeout(()=>w.abort(),M),A=Date.now();try{const k=await fetch(O,{method:"POST",headers:{"Content-Type":"text/plain",Authorization:`Bearer ${t.apiToken}`},body:C,signal:w.signal});if(!k.ok){const V=await k.text();throw new Error(`Analytics Engine query failed: ${k.status} ${k.statusText} - ${V}`)}const S=await k.json();if(S.success===!1&&S.errors?.length)throw new Error(`Analytics Engine error: ${S.errors.map(V=>V.message).join(", ")}`);const N=S.data??[];return{meta:S.meta??c,data:N,rows:S.rows??N.length,rows_before_limit_at_least:S.rows_before_limit_at_least??N.length,statistics:{elapsed:(Date.now()-A)/1e3}}}finally{clearTimeout(P)}}}}function mt(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:gs(t),list:ks(t),get:vs(t)}}function js(){return{async getGeoInfo(t){try{const e=t["cf-ipcountry"],s=t["cf-ipcity"],n=t["cf-iplatitude"],r=t["cf-iplongitude"],a=t["cf-timezone"],i=t["cf-ipcontinent"];return e?{country_code:e,city_name:s||"",latitude:n||"",longitude:r||"",time_zone:a||"",continent_code:i||""}:null}catch(e){return console.warn("Failed to get geo info from Cloudflare headers:",e),null}}}}class Ds{constructor(e){this.bindings=e}bindings;async consume(e,s){const n=this.bindings[e];if(!n)return{allowed:!0};try{const{success:r}=await n.limit({key:s});return{allowed:r}}catch(r){return console.error(`CloudflareRateLimit: limit() error for scope ${e}:`,r),{allowed:!0}}}}function yt(t){if(!(!t||!Object.keys(t).some(s=>t[s])))return new Ds(t)}function gt(t){return`// Auto-generated AuthHero code hook worker
@@ -312,7 +312,7 @@ export interface ListParams {
312
312
  to_date?: number;
313
313
  }
314
314
  declare const logInsertSchema: z.ZodObject<{
315
- type: z.ZodEffects<z.ZodString, "acls_summary" | "actions_execution_failed" | "api_limit" | "api_limit_warning" | "appi" | "ciba_exchange_failed" | "ciba_exchange_succeeded" | "ciba_start_failed" | "ciba_start_succeeded" | "cls" | "cs" | "depnote" | "f" | "fc" | "fce" | "fco" | "fcoa" | "fcp" | "fcph" | "fcpn" | "fcpr" | "fcpro" | "fcu" | "fd" | "fdeac" | "fdeaz" | "fdecc" | "fdu" | "feacft" | "feccft" | "fecte" | "fede" | "federated_logout_failed" | "fens" | "feoobft" | "feotpft" | "fepft" | "fepotpft" | "fercft" | "ferrt" | "fertft" | "fh" | "fimp" | "fi" | "flo" | "flows_execution_completed" | "flows_execution_failed" | "fn" | "forms_submission_failed" | "forms_submission_succeeded" | "fp" | "fpar" | "fpurh" | "fs" | "fsa" | "fu" | "fui" | "fv" | "fvr" | "gd_auth_email_verification" | "gd_auth_fail_email_verification" | "gd_auth_failed" | "gd_auth_rejected" | "gd_auth_succeed" | "gd_enrollment_complete" | "gd_otp_rate_limit_exceed" | "gd_recovery_failed" | "gd_recovery_rate_limit_exceed" | "gd_recovery_succeed" | "gd_send_email" | "gd_send_email_verification" | "gd_send_email_verification_failure" | "gd_send_pn" | "gd_send_pn_failure" | "gd_send_sms" | "gd_send_sms_failure" | "gd_send_voice" | "gd_send_voice_failure" | "gd_start_auth" | "gd_start_enroll" | "gd_start_enroll_failed" | "gd_tenant_update" | "gd_unenroll" | "gd_update_device_account" | "gd_webauthn_challenge_failed" | "gd_webauthn_enrollment_failed" | "kms_key_management_failure" | "kms_key_management_success" | "kms_key_state_changed" | "limit_delegation" | "limit_mu" | "limit_sul" | "limit_wc" | "mfar" | "mgmt_api_read" | "my_account_authentication_method_failed" | "my_account_authentication_method_succeeded" | "oidc_backchannel_logout_failed" | "oidc_backchannel_logout_succeeded" | "organization_member_added" | "passkey_challenge_failed" | "passkey_challenge_started" | "pla" | "pwd_leak" | "reset_pwd_leak" | "resource_cleanup" | "rich_consents_access_error" | "s" | "sapi" | "fapi" | "sce" | "scoa" | "scp" | "scpn" | "scpr" | "scu" | "scv" | "sd" | "sdu" | "seacft" | "seccft" | "secte" | "sede" | "sens" | "seoobft" | "seotpft" | "sepft" | "sepkoobft" | "sepkotpft" | "sepkrcft" | "sercft" | "sertft" | "simp" | "si" | "signup_pwd_leak" | "slo" | "sh" | "spm" | "srrt" | "ss" | "ss_sso_failure" | "ss_sso_info" | "ss_sso_success" | "ssa" | "sscim" | "sui" | "sv" | "svr" | "too_many_records" | "ublkdu" | "universal_logout_failed" | "universal_logout_succeeded" | "w" | "wn" | "wum", string>;
315
+ type: z.ZodEffects<z.ZodString, "acls_summary" | "actions_execution_failed" | "api_limit" | "api_limit_warning" | "appi" | "ciba_exchange_failed" | "ciba_exchange_succeeded" | "ciba_start_failed" | "ciba_start_succeeded" | "cls" | "cs" | "depnote" | "f" | "fc" | "fce" | "fco" | "fcoa" | "fcp" | "fcph" | "fcpn" | "fcpr" | "fcpro" | "fcu" | "fd" | "fdeac" | "fdeaz" | "fdecc" | "fdu" | "feacft" | "feccft" | "fecte" | "fede" | "federated_logout_failed" | "fens" | "feoobft" | "feotpft" | "fepft" | "fepotpft" | "fercft" | "ferrt" | "fertft" | "fh" | "fimp" | "fi" | "flo" | "flows_execution_completed" | "flows_execution_failed" | "fn" | "forms_submission_failed" | "forms_submission_succeeded" | "fp" | "fpar" | "fpurh" | "fs" | "fsa" | "fu" | "fui" | "fv" | "fvr" | "gd_auth_email_verification" | "gd_auth_fail_email_verification" | "gd_auth_failed" | "gd_auth_rejected" | "gd_auth_succeed" | "gd_enrollment_complete" | "gd_otp_rate_limit_exceed" | "gd_recovery_failed" | "gd_recovery_rate_limit_exceed" | "gd_recovery_succeed" | "gd_send_email" | "gd_send_email_verification" | "gd_send_email_verification_failure" | "gd_send_pn" | "gd_send_pn_failure" | "gd_send_sms" | "gd_send_sms_failure" | "gd_send_voice" | "gd_send_voice_failure" | "gd_start_auth" | "gd_start_enroll" | "gd_start_enroll_failed" | "gd_tenant_update" | "gd_unenroll" | "gd_update_device_account" | "gd_webauthn_challenge_failed" | "gd_webauthn_enrollment_failed" | "kms_key_management_failure" | "kms_key_management_success" | "kms_key_state_changed" | "limit_delegation" | "limit_mu" | "limit_sul" | "limit_wc" | "i" | "mfar" | "mgmt_api_read" | "my_account_authentication_method_failed" | "my_account_authentication_method_succeeded" | "oidc_backchannel_logout_failed" | "oidc_backchannel_logout_succeeded" | "organization_member_added" | "passkey_challenge_failed" | "passkey_challenge_started" | "pla" | "pwd_leak" | "reset_pwd_leak" | "resource_cleanup" | "rich_consents_access_error" | "s" | "sapi" | "fapi" | "sce" | "scoa" | "scp" | "scpn" | "scpr" | "scu" | "scv" | "sd" | "sdu" | "seacft" | "seccft" | "secte" | "sede" | "sens" | "seoobft" | "seotpft" | "sepft" | "sepkoobft" | "sepkotpft" | "sepkrcft" | "sercft" | "sertft" | "simp" | "si" | "signup_pwd_leak" | "slo" | "sh" | "spm" | "srrt" | "ss" | "ss_sso_failure" | "ss_sso_info" | "ss_sso_success" | "ssa" | "sscim" | "sui" | "sv" | "svr" | "too_many_records" | "ublkdu" | "universal_logout_failed" | "universal_logout_succeeded" | "w" | "wn" | "wum", string>;
316
316
  date: z.ZodString;
317
317
  description: z.ZodOptional<z.ZodString>;
318
318
  ip: z.ZodOptional<z.ZodString>;
@@ -377,7 +377,7 @@ declare const logInsertSchema: z.ZodObject<{
377
377
  continent_code: string;
378
378
  }>>;
379
379
  }, "strip", z.ZodTypeAny, {
380
- type: "acls_summary" | "actions_execution_failed" | "api_limit" | "api_limit_warning" | "appi" | "ciba_exchange_failed" | "ciba_exchange_succeeded" | "ciba_start_failed" | "ciba_start_succeeded" | "cls" | "cs" | "depnote" | "f" | "fc" | "fce" | "fco" | "fcoa" | "fcp" | "fcph" | "fcpn" | "fcpr" | "fcpro" | "fcu" | "fd" | "fdeac" | "fdeaz" | "fdecc" | "fdu" | "feacft" | "feccft" | "fecte" | "fede" | "federated_logout_failed" | "fens" | "feoobft" | "feotpft" | "fepft" | "fepotpft" | "fercft" | "ferrt" | "fertft" | "fh" | "fimp" | "fi" | "flo" | "flows_execution_completed" | "flows_execution_failed" | "fn" | "forms_submission_failed" | "forms_submission_succeeded" | "fp" | "fpar" | "fpurh" | "fs" | "fsa" | "fu" | "fui" | "fv" | "fvr" | "gd_auth_email_verification" | "gd_auth_fail_email_verification" | "gd_auth_failed" | "gd_auth_rejected" | "gd_auth_succeed" | "gd_enrollment_complete" | "gd_otp_rate_limit_exceed" | "gd_recovery_failed" | "gd_recovery_rate_limit_exceed" | "gd_recovery_succeed" | "gd_send_email" | "gd_send_email_verification" | "gd_send_email_verification_failure" | "gd_send_pn" | "gd_send_pn_failure" | "gd_send_sms" | "gd_send_sms_failure" | "gd_send_voice" | "gd_send_voice_failure" | "gd_start_auth" | "gd_start_enroll" | "gd_start_enroll_failed" | "gd_tenant_update" | "gd_unenroll" | "gd_update_device_account" | "gd_webauthn_challenge_failed" | "gd_webauthn_enrollment_failed" | "kms_key_management_failure" | "kms_key_management_success" | "kms_key_state_changed" | "limit_delegation" | "limit_mu" | "limit_sul" | "limit_wc" | "mfar" | "mgmt_api_read" | "my_account_authentication_method_failed" | "my_account_authentication_method_succeeded" | "oidc_backchannel_logout_failed" | "oidc_backchannel_logout_succeeded" | "organization_member_added" | "passkey_challenge_failed" | "passkey_challenge_started" | "pla" | "pwd_leak" | "reset_pwd_leak" | "resource_cleanup" | "rich_consents_access_error" | "s" | "sapi" | "fapi" | "sce" | "scoa" | "scp" | "scpn" | "scpr" | "scu" | "scv" | "sd" | "sdu" | "seacft" | "seccft" | "secte" | "sede" | "sens" | "seoobft" | "seotpft" | "sepft" | "sepkoobft" | "sepkotpft" | "sepkrcft" | "sercft" | "sertft" | "simp" | "si" | "signup_pwd_leak" | "slo" | "sh" | "spm" | "srrt" | "ss" | "ss_sso_failure" | "ss_sso_info" | "ss_sso_success" | "ssa" | "sscim" | "sui" | "sv" | "svr" | "too_many_records" | "ublkdu" | "universal_logout_failed" | "universal_logout_succeeded" | "w" | "wn" | "wum";
380
+ type: "acls_summary" | "actions_execution_failed" | "api_limit" | "api_limit_warning" | "appi" | "ciba_exchange_failed" | "ciba_exchange_succeeded" | "ciba_start_failed" | "ciba_start_succeeded" | "cls" | "cs" | "depnote" | "f" | "fc" | "fce" | "fco" | "fcoa" | "fcp" | "fcph" | "fcpn" | "fcpr" | "fcpro" | "fcu" | "fd" | "fdeac" | "fdeaz" | "fdecc" | "fdu" | "feacft" | "feccft" | "fecte" | "fede" | "federated_logout_failed" | "fens" | "feoobft" | "feotpft" | "fepft" | "fepotpft" | "fercft" | "ferrt" | "fertft" | "fh" | "fimp" | "fi" | "flo" | "flows_execution_completed" | "flows_execution_failed" | "fn" | "forms_submission_failed" | "forms_submission_succeeded" | "fp" | "fpar" | "fpurh" | "fs" | "fsa" | "fu" | "fui" | "fv" | "fvr" | "gd_auth_email_verification" | "gd_auth_fail_email_verification" | "gd_auth_failed" | "gd_auth_rejected" | "gd_auth_succeed" | "gd_enrollment_complete" | "gd_otp_rate_limit_exceed" | "gd_recovery_failed" | "gd_recovery_rate_limit_exceed" | "gd_recovery_succeed" | "gd_send_email" | "gd_send_email_verification" | "gd_send_email_verification_failure" | "gd_send_pn" | "gd_send_pn_failure" | "gd_send_sms" | "gd_send_sms_failure" | "gd_send_voice" | "gd_send_voice_failure" | "gd_start_auth" | "gd_start_enroll" | "gd_start_enroll_failed" | "gd_tenant_update" | "gd_unenroll" | "gd_update_device_account" | "gd_webauthn_challenge_failed" | "gd_webauthn_enrollment_failed" | "kms_key_management_failure" | "kms_key_management_success" | "kms_key_state_changed" | "limit_delegation" | "limit_mu" | "limit_sul" | "limit_wc" | "i" | "mfar" | "mgmt_api_read" | "my_account_authentication_method_failed" | "my_account_authentication_method_succeeded" | "oidc_backchannel_logout_failed" | "oidc_backchannel_logout_succeeded" | "organization_member_added" | "passkey_challenge_failed" | "passkey_challenge_started" | "pla" | "pwd_leak" | "reset_pwd_leak" | "resource_cleanup" | "rich_consents_access_error" | "s" | "sapi" | "fapi" | "sce" | "scoa" | "scp" | "scpn" | "scpr" | "scu" | "scv" | "sd" | "sdu" | "seacft" | "seccft" | "secte" | "sede" | "sens" | "seoobft" | "seotpft" | "sepft" | "sepkoobft" | "sepkotpft" | "sepkrcft" | "sercft" | "sertft" | "simp" | "si" | "signup_pwd_leak" | "slo" | "sh" | "spm" | "srrt" | "ss" | "ss_sso_failure" | "ss_sso_info" | "ss_sso_success" | "ssa" | "sscim" | "sui" | "sv" | "svr" | "too_many_records" | "ublkdu" | "universal_logout_failed" | "universal_logout_succeeded" | "w" | "wn" | "wum";
381
381
  date: string;
382
382
  isMobile: boolean;
383
383
  description?: string | undefined;
@@ -450,7 +450,7 @@ declare const logInsertSchema: z.ZodObject<{
450
450
  export type LogInsert = z.infer<typeof logInsertSchema>;
451
451
  declare const logSchema: z.ZodObject<{
452
452
  log_id: z.ZodString;
453
- type: z.ZodEffects<z.ZodString, "acls_summary" | "actions_execution_failed" | "api_limit" | "api_limit_warning" | "appi" | "ciba_exchange_failed" | "ciba_exchange_succeeded" | "ciba_start_failed" | "ciba_start_succeeded" | "cls" | "cs" | "depnote" | "f" | "fc" | "fce" | "fco" | "fcoa" | "fcp" | "fcph" | "fcpn" | "fcpr" | "fcpro" | "fcu" | "fd" | "fdeac" | "fdeaz" | "fdecc" | "fdu" | "feacft" | "feccft" | "fecte" | "fede" | "federated_logout_failed" | "fens" | "feoobft" | "feotpft" | "fepft" | "fepotpft" | "fercft" | "ferrt" | "fertft" | "fh" | "fimp" | "fi" | "flo" | "flows_execution_completed" | "flows_execution_failed" | "fn" | "forms_submission_failed" | "forms_submission_succeeded" | "fp" | "fpar" | "fpurh" | "fs" | "fsa" | "fu" | "fui" | "fv" | "fvr" | "gd_auth_email_verification" | "gd_auth_fail_email_verification" | "gd_auth_failed" | "gd_auth_rejected" | "gd_auth_succeed" | "gd_enrollment_complete" | "gd_otp_rate_limit_exceed" | "gd_recovery_failed" | "gd_recovery_rate_limit_exceed" | "gd_recovery_succeed" | "gd_send_email" | "gd_send_email_verification" | "gd_send_email_verification_failure" | "gd_send_pn" | "gd_send_pn_failure" | "gd_send_sms" | "gd_send_sms_failure" | "gd_send_voice" | "gd_send_voice_failure" | "gd_start_auth" | "gd_start_enroll" | "gd_start_enroll_failed" | "gd_tenant_update" | "gd_unenroll" | "gd_update_device_account" | "gd_webauthn_challenge_failed" | "gd_webauthn_enrollment_failed" | "kms_key_management_failure" | "kms_key_management_success" | "kms_key_state_changed" | "limit_delegation" | "limit_mu" | "limit_sul" | "limit_wc" | "mfar" | "mgmt_api_read" | "my_account_authentication_method_failed" | "my_account_authentication_method_succeeded" | "oidc_backchannel_logout_failed" | "oidc_backchannel_logout_succeeded" | "organization_member_added" | "passkey_challenge_failed" | "passkey_challenge_started" | "pla" | "pwd_leak" | "reset_pwd_leak" | "resource_cleanup" | "rich_consents_access_error" | "s" | "sapi" | "fapi" | "sce" | "scoa" | "scp" | "scpn" | "scpr" | "scu" | "scv" | "sd" | "sdu" | "seacft" | "seccft" | "secte" | "sede" | "sens" | "seoobft" | "seotpft" | "sepft" | "sepkoobft" | "sepkotpft" | "sepkrcft" | "sercft" | "sertft" | "simp" | "si" | "signup_pwd_leak" | "slo" | "sh" | "spm" | "srrt" | "ss" | "ss_sso_failure" | "ss_sso_info" | "ss_sso_success" | "ssa" | "sscim" | "sui" | "sv" | "svr" | "too_many_records" | "ublkdu" | "universal_logout_failed" | "universal_logout_succeeded" | "w" | "wn" | "wum", string>;
453
+ type: z.ZodEffects<z.ZodString, "acls_summary" | "actions_execution_failed" | "api_limit" | "api_limit_warning" | "appi" | "ciba_exchange_failed" | "ciba_exchange_succeeded" | "ciba_start_failed" | "ciba_start_succeeded" | "cls" | "cs" | "depnote" | "f" | "fc" | "fce" | "fco" | "fcoa" | "fcp" | "fcph" | "fcpn" | "fcpr" | "fcpro" | "fcu" | "fd" | "fdeac" | "fdeaz" | "fdecc" | "fdu" | "feacft" | "feccft" | "fecte" | "fede" | "federated_logout_failed" | "fens" | "feoobft" | "feotpft" | "fepft" | "fepotpft" | "fercft" | "ferrt" | "fertft" | "fh" | "fimp" | "fi" | "flo" | "flows_execution_completed" | "flows_execution_failed" | "fn" | "forms_submission_failed" | "forms_submission_succeeded" | "fp" | "fpar" | "fpurh" | "fs" | "fsa" | "fu" | "fui" | "fv" | "fvr" | "gd_auth_email_verification" | "gd_auth_fail_email_verification" | "gd_auth_failed" | "gd_auth_rejected" | "gd_auth_succeed" | "gd_enrollment_complete" | "gd_otp_rate_limit_exceed" | "gd_recovery_failed" | "gd_recovery_rate_limit_exceed" | "gd_recovery_succeed" | "gd_send_email" | "gd_send_email_verification" | "gd_send_email_verification_failure" | "gd_send_pn" | "gd_send_pn_failure" | "gd_send_sms" | "gd_send_sms_failure" | "gd_send_voice" | "gd_send_voice_failure" | "gd_start_auth" | "gd_start_enroll" | "gd_start_enroll_failed" | "gd_tenant_update" | "gd_unenroll" | "gd_update_device_account" | "gd_webauthn_challenge_failed" | "gd_webauthn_enrollment_failed" | "kms_key_management_failure" | "kms_key_management_success" | "kms_key_state_changed" | "limit_delegation" | "limit_mu" | "limit_sul" | "limit_wc" | "i" | "mfar" | "mgmt_api_read" | "my_account_authentication_method_failed" | "my_account_authentication_method_succeeded" | "oidc_backchannel_logout_failed" | "oidc_backchannel_logout_succeeded" | "organization_member_added" | "passkey_challenge_failed" | "passkey_challenge_started" | "pla" | "pwd_leak" | "reset_pwd_leak" | "resource_cleanup" | "rich_consents_access_error" | "s" | "sapi" | "fapi" | "sce" | "scoa" | "scp" | "scpn" | "scpr" | "scu" | "scv" | "sd" | "sdu" | "seacft" | "seccft" | "secte" | "sede" | "sens" | "seoobft" | "seotpft" | "sepft" | "sepkoobft" | "sepkotpft" | "sepkrcft" | "sercft" | "sertft" | "simp" | "si" | "signup_pwd_leak" | "slo" | "sh" | "spm" | "srrt" | "ss" | "ss_sso_failure" | "ss_sso_info" | "ss_sso_success" | "ssa" | "sscim" | "sui" | "sv" | "svr" | "too_many_records" | "ublkdu" | "universal_logout_failed" | "universal_logout_succeeded" | "w" | "wn" | "wum", string>;
454
454
  date: z.ZodString;
455
455
  description: z.ZodOptional<z.ZodString>;
456
456
  ip: z.ZodOptional<z.ZodString>;
@@ -514,7 +514,7 @@ declare const logSchema: z.ZodObject<{
514
514
  continent_code: string;
515
515
  }>>;
516
516
  }, "strip", z.ZodTypeAny, {
517
- type: "acls_summary" | "actions_execution_failed" | "api_limit" | "api_limit_warning" | "appi" | "ciba_exchange_failed" | "ciba_exchange_succeeded" | "ciba_start_failed" | "ciba_start_succeeded" | "cls" | "cs" | "depnote" | "f" | "fc" | "fce" | "fco" | "fcoa" | "fcp" | "fcph" | "fcpn" | "fcpr" | "fcpro" | "fcu" | "fd" | "fdeac" | "fdeaz" | "fdecc" | "fdu" | "feacft" | "feccft" | "fecte" | "fede" | "federated_logout_failed" | "fens" | "feoobft" | "feotpft" | "fepft" | "fepotpft" | "fercft" | "ferrt" | "fertft" | "fh" | "fimp" | "fi" | "flo" | "flows_execution_completed" | "flows_execution_failed" | "fn" | "forms_submission_failed" | "forms_submission_succeeded" | "fp" | "fpar" | "fpurh" | "fs" | "fsa" | "fu" | "fui" | "fv" | "fvr" | "gd_auth_email_verification" | "gd_auth_fail_email_verification" | "gd_auth_failed" | "gd_auth_rejected" | "gd_auth_succeed" | "gd_enrollment_complete" | "gd_otp_rate_limit_exceed" | "gd_recovery_failed" | "gd_recovery_rate_limit_exceed" | "gd_recovery_succeed" | "gd_send_email" | "gd_send_email_verification" | "gd_send_email_verification_failure" | "gd_send_pn" | "gd_send_pn_failure" | "gd_send_sms" | "gd_send_sms_failure" | "gd_send_voice" | "gd_send_voice_failure" | "gd_start_auth" | "gd_start_enroll" | "gd_start_enroll_failed" | "gd_tenant_update" | "gd_unenroll" | "gd_update_device_account" | "gd_webauthn_challenge_failed" | "gd_webauthn_enrollment_failed" | "kms_key_management_failure" | "kms_key_management_success" | "kms_key_state_changed" | "limit_delegation" | "limit_mu" | "limit_sul" | "limit_wc" | "mfar" | "mgmt_api_read" | "my_account_authentication_method_failed" | "my_account_authentication_method_succeeded" | "oidc_backchannel_logout_failed" | "oidc_backchannel_logout_succeeded" | "organization_member_added" | "passkey_challenge_failed" | "passkey_challenge_started" | "pla" | "pwd_leak" | "reset_pwd_leak" | "resource_cleanup" | "rich_consents_access_error" | "s" | "sapi" | "fapi" | "sce" | "scoa" | "scp" | "scpn" | "scpr" | "scu" | "scv" | "sd" | "sdu" | "seacft" | "seccft" | "secte" | "sede" | "sens" | "seoobft" | "seotpft" | "sepft" | "sepkoobft" | "sepkotpft" | "sepkrcft" | "sercft" | "sertft" | "simp" | "si" | "signup_pwd_leak" | "slo" | "sh" | "spm" | "srrt" | "ss" | "ss_sso_failure" | "ss_sso_info" | "ss_sso_success" | "ssa" | "sscim" | "sui" | "sv" | "svr" | "too_many_records" | "ublkdu" | "universal_logout_failed" | "universal_logout_succeeded" | "w" | "wn" | "wum";
517
+ type: "acls_summary" | "actions_execution_failed" | "api_limit" | "api_limit_warning" | "appi" | "ciba_exchange_failed" | "ciba_exchange_succeeded" | "ciba_start_failed" | "ciba_start_succeeded" | "cls" | "cs" | "depnote" | "f" | "fc" | "fce" | "fco" | "fcoa" | "fcp" | "fcph" | "fcpn" | "fcpr" | "fcpro" | "fcu" | "fd" | "fdeac" | "fdeaz" | "fdecc" | "fdu" | "feacft" | "feccft" | "fecte" | "fede" | "federated_logout_failed" | "fens" | "feoobft" | "feotpft" | "fepft" | "fepotpft" | "fercft" | "ferrt" | "fertft" | "fh" | "fimp" | "fi" | "flo" | "flows_execution_completed" | "flows_execution_failed" | "fn" | "forms_submission_failed" | "forms_submission_succeeded" | "fp" | "fpar" | "fpurh" | "fs" | "fsa" | "fu" | "fui" | "fv" | "fvr" | "gd_auth_email_verification" | "gd_auth_fail_email_verification" | "gd_auth_failed" | "gd_auth_rejected" | "gd_auth_succeed" | "gd_enrollment_complete" | "gd_otp_rate_limit_exceed" | "gd_recovery_failed" | "gd_recovery_rate_limit_exceed" | "gd_recovery_succeed" | "gd_send_email" | "gd_send_email_verification" | "gd_send_email_verification_failure" | "gd_send_pn" | "gd_send_pn_failure" | "gd_send_sms" | "gd_send_sms_failure" | "gd_send_voice" | "gd_send_voice_failure" | "gd_start_auth" | "gd_start_enroll" | "gd_start_enroll_failed" | "gd_tenant_update" | "gd_unenroll" | "gd_update_device_account" | "gd_webauthn_challenge_failed" | "gd_webauthn_enrollment_failed" | "kms_key_management_failure" | "kms_key_management_success" | "kms_key_state_changed" | "limit_delegation" | "limit_mu" | "limit_sul" | "limit_wc" | "i" | "mfar" | "mgmt_api_read" | "my_account_authentication_method_failed" | "my_account_authentication_method_succeeded" | "oidc_backchannel_logout_failed" | "oidc_backchannel_logout_succeeded" | "organization_member_added" | "passkey_challenge_failed" | "passkey_challenge_started" | "pla" | "pwd_leak" | "reset_pwd_leak" | "resource_cleanup" | "rich_consents_access_error" | "s" | "sapi" | "fapi" | "sce" | "scoa" | "scp" | "scpn" | "scpr" | "scu" | "scv" | "sd" | "sdu" | "seacft" | "seccft" | "secte" | "sede" | "sens" | "seoobft" | "seotpft" | "sepft" | "sepkoobft" | "sepkotpft" | "sepkrcft" | "sercft" | "sertft" | "simp" | "si" | "signup_pwd_leak" | "slo" | "sh" | "spm" | "srrt" | "ss" | "ss_sso_failure" | "ss_sso_info" | "ss_sso_success" | "ssa" | "sscim" | "sui" | "sv" | "svr" | "too_many_records" | "ublkdu" | "universal_logout_failed" | "universal_logout_succeeded" | "w" | "wn" | "wum";
518
518
  date: string;
519
519
  isMobile: boolean;
520
520
  log_id: string;
@@ -3784,7 +3784,8 @@ const vs = {
3784
3784
  user_id: "blob7"
3785
3785
  }, ws = {
3786
3786
  "active-users": {
3787
- expr: "uniqExact(blob7)",
3787
+ // CF Analytics Engine SQL doesn't support uniq/uniqExact; COUNT(DISTINCT) is.
3788
+ expr: "count(DISTINCT blob7)",
3788
3789
  alias: "active_users",
3789
3790
  type: "UInt64"
3790
3791
  },
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "type": "git",
12
12
  "url": "https://github.com/markusahlstrand/authhero"
13
13
  },
14
- "version": "2.29.0",
14
+ "version": "2.29.1",
15
15
  "files": [
16
16
  "dist"
17
17
  ],
@@ -46,8 +46,8 @@
46
46
  "dependencies": {
47
47
  "nanoid": "^5.1.6",
48
48
  "wretch": "^3.0.2",
49
- "@authhero/adapter-interfaces": "2.3.0",
50
- "@authhero/kysely-adapter": "11.2.0"
49
+ "@authhero/adapter-interfaces": "2.4.0",
50
+ "@authhero/kysely-adapter": "11.2.1"
51
51
  },
52
52
  "scripts": {
53
53
  "build": "tsc && vite build && dts-bundle-generator --config ./dts-bundle-generator.config.ts",