@authhero/cloudflare-adapter 2.25.9 → 2.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const yt=require("@authhero/adapter-interfaces"),_t=require("wretch");function gt(t,e){var n={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(n[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,s=Object.getOwnPropertySymbols(t);r<s.length;r++)e.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(t,s[r])&&(n[s[r]]=t[s[r]]);return n}function vt(t,e){var n;return((n=t?._def)===null||n===void 0?void 0:n.typeName)===e}function ae(t,e){const n=t.ZodType.prototype[e];t.ZodType.prototype[e]=function(...s){const r=n.apply(this,s);return r._def.openapi=this._def.openapi,r}}function bt(t){if(typeof t.ZodType.prototype.openapi<"u")return;t.ZodType.prototype.openapi=function(r,a){var i,o,c,u,p,k;const C=typeof r=="string"?a:r,S=C??{},{param:E}=S,F=gt(S,["param"]),x=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),F),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||E?{param:Object.assign(Object.assign({},(k=(p=this._def.openapi)===null||p===void 0?void 0:p.metadata)===null||k===void 0?void 0:k.param),E)}:void 0),O=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(x).length>0?{_internal:x}:void 0),Object.keys(P).length>0?{metadata:P}:void 0)}));if(vt(this,"ZodObject")){const j=this.extend;O.extend=function(...W){var J,re,we,Se,Ce,Te,Ee;const Oe=j.apply(this,W);return Oe._def.openapi={_internal:{extendedFrom:!((re=(J=this._def.openapi)===null||J===void 0?void 0:J._internal)===null||re===void 0)&&re.refId?{refId:(Se=(we=this._def.openapi)===null||we===void 0?void 0:we._internal)===null||Se===void 0?void 0:Se.refId,schema:this}:(Te=(Ce=this._def.openapi)===null||Ce===void 0?void 0:Ce._internal)===null||Te===void 0?void 0:Te.extendedFrom},metadata:(Ee=Oe._def.openapi)===null||Ee===void 0?void 0:Ee.metadata},Oe}}return O},ae(t,"optional"),ae(t,"nullable"),ae(t,"default"),ae(t,"transform"),ae(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 u,p;c._def.openapi=(p=(u=r[o])===null||u===void 0?void 0:u._def)===null||p===void 0?void 0:p.openapi}),a._def.openapi=void 0,a};const n=t.ZodObject.prototype.pick;t.ZodObject.prototype.pick=function(...r){const a=n.apply(this,r);return a._def.openapi=void 0,a};const s=t.ZodObject.prototype.omit;t.ZodObject.prototype.omit=function(...r){const a=s.apply(this,r);return a._def.openapi=void 0,a}}var X=class extends Error{res;status;constructor(t=500,e){super(e?.message,{cause:e?.cause}),this.res=e?.res,this.status=t}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}};new Set(".\\+*[^]$()");var b;(function(t){t.assertEqual=r=>{};function e(r){}t.assertIs=e;function n(r){throw new Error}t.assertNever=n,t.arrayToEnum=r=>{const a={};for(const i of r)a[i]=i;return a},t.getValidEnumValues=r=>{const a=t.objectKeys(r).filter(o=>typeof r[r[o]]!="number"),i={};for(const o of a)i[o]=r[o];return t.objectValues(i)},t.objectValues=r=>t.objectKeys(r).map(function(a){return r[a]}),t.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const a=[];for(const i in r)Object.prototype.hasOwnProperty.call(r,i)&&a.push(i);return a},t.find=(r,a)=>{for(const i of r)if(a(i))return i},t.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function s(r,a=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}t.joinValues=s,t.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(b||(b={}));var $e;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})($e||($e={}));const h=b.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),M=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}},d=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 D extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(a){return a.message},s={_errors:[]},r=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(i.argumentsError);else if(i.path.length===0)s._errors.push(n(i));else{let o=s,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(n(i))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return r(this),s}static assert(e){if(!(e instanceof D))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,b.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},s=[];for(const r of this.issues)if(r.path.length>0){const a=r.path[0];n[a]=n[a]||[],n[a].push(e(r))}else s.push(e(r));return{formErrors:s,fieldErrors:n}}get formErrors(){return this.flatten()}}D.create=t=>new D(t);const pe=(t,e)=>{let n;switch(t.code){case d.invalid_type:t.received===h.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case d.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,b.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:n=`Unrecognized key(s) in object: ${b.joinValues(t.keys,", ")}`;break;case d.invalid_union:n="Invalid input";break;case d.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${b.joinValues(t.options)}`;break;case d.invalid_enum_value:n=`Invalid enum value. Expected ${b.joinValues(t.options)}, received '${t.received}'`;break;case d.invalid_arguments:n="Invalid function arguments";break;case d.invalid_return_type:n="Invalid function return type";break;case d.invalid_date:n="Invalid date";break;case d.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:b.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case d.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case d.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case d.custom:n="Invalid input";break;case d.invalid_intersection_types:n="Intersection results could not be merged";break;case d.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case d.not_finite:n="Number must be finite";break;default:n=e.defaultError,b.assertNever(t)}return{message:n}};let xt=pe;function Xe(){return xt}const et=t=>{const{data:e,path:n,errorMaps:s,issueData:r}=t,a=[...n,...r.path||[]],i={...r,path:a};if(r.message!==void 0)return{...r,path:a,message:r.message};let o="";const c=s.filter(u=>!!u).slice().reverse();for(const u of c)o=u(i,{data:e,defaultError:o}).message;return{...r,path:a,message:o}};function l(t,e){const n=Xe(),s=et({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===pe?void 0:pe].filter(r=>!!r)});t.common.issues.push(s)}class T{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const s=[];for(const r of n){if(r.status==="aborted")return y;r.status==="dirty"&&e.dirty(),s.push(r.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,n){const s=[];for(const r of n){const a=await r.key,i=await r.value;s.push({key:a,value:i})}return T.mergeObjectSync(e,s)}static mergeObjectSync(e,n){const s={};for(const r of n){const{key:a,value:i}=r;if(a.status==="aborted"||i.status==="aborted")return y;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||r.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}}const y=Object.freeze({status:"aborted"}),te=t=>({status:"dirty",value:t}),N=t=>({status:"valid",value:t}),Re=t=>t.status==="aborted",je=t=>t.status==="dirty",Q=t=>t.status==="valid",oe=t=>typeof Promise<"u"&&t instanceof Promise;var f;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(f||(f={}));class L{constructor(e,n,s,r){this._cachedPath=[],this.parent=e,this.data=n,this._path=s,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const He=(t,e)=>{if(Q(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new D(t.common.issues);return this._error=n,this._error}}};function g(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:s,description:r}=t;if(e&&(n||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(i,o)=>{const{message:c}=t;return i.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??s??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:c??n??o.defaultError}},description:r}}class v{get description(){return this._def.description}_getType(e){return M(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:M(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new T,ctx:{common:e.parent.common,data:e.data,parsedType:M(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(oe(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const s=this.safeParse(e,n);if(s.success)return s.data;throw s.error}safeParse(e,n){const s={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)},r=this._parseSync({data:e,path:s.path,parent:s});return He(s,r)}"~validate"(e){const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:n});return Q(s)?{value:s.value}:{issues:n.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(s=>Q(s)?{value:s.value}:{issues:n.common.issues})}async parseAsync(e,n){const s=await this.safeParseAsync(e,n);if(s.success)return s.data;throw s.error}async safeParseAsync(e,n){const s={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)},r=this._parse({data:e,path:s.path,parent:s}),a=await(oe(r)?r:Promise.resolve(r));return He(s,a)}refine(e,n){const s=r=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(r):n;return this._refinement((r,a)=>{const i=e(r),o=()=>a.addIssue({code:d.custom,...s(r)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,n){return this._refinement((s,r)=>e(s)?!0:(r.addIssue(typeof n=="function"?n(s,r):n),!1))}_refinement(e){return new 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:n=>this["~validate"](n)}}optional(){return V.create(this,this._def)}nullable(){return G.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return $.create(this)}promise(){return he.create(this,this._def)}or(e){return de.create([this,e],this._def)}and(e){return ue.create(this,e,this._def)}transform(e){return new q({...g(this._def),schema:this,typeName:m.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new ye({...g(this._def),innerType:this,defaultValue:n,typeName:m.ZodDefault})}brand(){return new at({typeName:m.ZodBranded,type:this,...g(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new _e({...g(this._def),innerType:this,catchValue:n,typeName:m.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return xe.create(this,e)}readonly(){return ge.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const kt=/^c[^\s-]{8,}$/i,wt=/^[0-9a-z]+$/,St=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ct=/^[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,Tt=/^[a-z0-9_-]{21}$/i,Et=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ot=/^[-+]?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)?)??$/,At=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Nt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ae;const $t=/^(?:(?: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])$/,Rt=/^(?:(?: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])$/,jt=/^(([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]))$/,It=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Zt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Dt=/^([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])))",Lt=new RegExp(`^${tt}$`);function nt(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function Pt(t){return new RegExp(`^${nt(t)}$`)}function st(t){let e=`${tt}T${nt(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Mt(t,e){return!!((e==="v4"||!e)&&$t.test(t)||(e==="v6"||!e)&&jt.test(t))}function Vt(t,e){if(!Et.test(t))return!1;try{const[n]=t.split(".");if(!n)return!1;const s=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),r=JSON.parse(atob(s));return!(typeof r!="object"||r===null||"typ"in r&&r?.typ!=="JWT"||!r.alg||e&&r.alg!==e)}catch{return!1}}function Bt(t,e){return!!((e==="v4"||!e)&&Rt.test(t)||(e==="v6"||!e)&&It.test(t))}class Z 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:d.invalid_type,expected:h.string,received:a.parsedType}),y}const s=new T;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:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="max")e.data.length>a.value&&(r=this._getOrReturnCtx(e,r),l(r,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(r=this._getOrReturnCtx(e,r),i?l(r,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&l(r,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty())}else if(a.kind==="email")At.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"email",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")Ae||(Ae=new RegExp(Nt,"u")),Ae.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"emoji",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")Ct.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"uuid",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")Tt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"nanoid",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")kt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"cuid",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")wt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"cuid2",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")St.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"ulid",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),l(r,{validation:"url",code:d.invalid_string,message:a.message}),s.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"regex",code:d.invalid_string,message:a.message}),s.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(r=this._getOrReturnCtx(e,r),l(r,{code:d.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),s.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(r=this._getOrReturnCtx(e,r),l(r,{code:d.invalid_string,validation:{startsWith:a.value},message:a.message}),s.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(r=this._getOrReturnCtx(e,r),l(r,{code:d.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?st(a).test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:d.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?Lt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:d.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?Pt(a).test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:d.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?Ot.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"duration",code:d.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?Mt(e.data,a.version)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"ip",code:d.invalid_string,message:a.message}),s.dirty()):a.kind==="jwt"?Vt(e.data,a.alg)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"jwt",code:d.invalid_string,message:a.message}),s.dirty()):a.kind==="cidr"?Bt(e.data,a.version)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"cidr",code:d.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?Zt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"base64",code:d.invalid_string,message:a.message}),s.dirty()):a.kind==="base64url"?Dt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"base64url",code:d.invalid_string,message:a.message}),s.dirty()):b.assertNever(a);return{status:s.value,value:e.data}}_regex(e,n,s){return this.refinement(r=>e.test(r),{validation:n,code:d.invalid_string,...f.errToObj(s)})}_addCheck(e){return new Z({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...f.errToObj(e)})}url(e){return this._addCheck({kind:"url",...f.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...f.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...f.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...f.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...f.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...f.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...f.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...f.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...f.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...f.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...f.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...f.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,...f.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,...f.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...f.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...f.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...f.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...f.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...f.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...f.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...f.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...f.errToObj(n)})}nonempty(e){return this.min(1,f.errToObj(e))}trim(){return new Z({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Z({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Z({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}Z.create=t=>new Z({checks:[],typeName:m.ZodString,coerce:t?.coerce??!1,...g(t)});function Ut(t,e){const n=(t.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,r=n>s?n:s,a=Number.parseInt(t.toFixed(r).replace(".","")),i=Number.parseInt(e.toFixed(r).replace(".",""));return a%i/10**r}class Y 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:d.invalid_type,expected:h.number,received:a.parsedType}),y}let s;const r=new T;for(const a of this._def.checks)a.kind==="int"?b.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:d.invalid_type,expected:"integer",received:"float",message:a.message}),r.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="multipleOf"?Ut(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:d.not_finite,message:a.message}),r.dirty()):b.assertNever(a);return{status:r.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,f.toString(n))}gt(e,n){return this.setLimit("min",e,!1,f.toString(n))}lte(e,n){return this.setLimit("max",e,!0,f.toString(n))}lt(e,n){return this.setLimit("max",e,!1,f.toString(n))}setLimit(e,n,s,r){return new Y({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:s,message:f.toString(r)}]})}_addCheck(e){return new Y({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:f.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:f.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:f.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:f.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:f.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:f.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:f.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:f.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:f.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&b.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(n===null||s.value>n)&&(n=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(n)&&Number.isFinite(e)}}Y.create=t=>new Y({checks:[],typeName:m.ZodNumber,coerce:t?.coerce||!1,...g(t)});class ne 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 s;const r=new T;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):b.assertNever(a);return{status:r.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return l(n,{code:d.invalid_type,expected:h.bigint,received:n.parsedType}),y}gte(e,n){return this.setLimit("min",e,!0,f.toString(n))}gt(e,n){return this.setLimit("min",e,!1,f.toString(n))}lte(e,n){return this.setLimit("max",e,!0,f.toString(n))}lt(e,n){return this.setLimit("max",e,!1,f.toString(n))}setLimit(e,n,s,r){return new ne({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:s,message:f.toString(r)}]})}_addCheck(e){return new ne({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:f.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:f.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:f.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:f.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:f.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}ne.create=t=>new ne({checks:[],typeName:m.ZodBigInt,coerce:t?.coerce??!1,...g(t)});class me extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.boolean){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:h.boolean,received:s.parsedType}),y}return N(e.data)}}me.create=t=>new me({typeName:m.ZodBoolean,coerce:t?.coerce||!1,...g(t)});class ce 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:d.invalid_type,expected:h.date,received:a.parsedType}),y}if(Number.isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return l(a,{code:d.invalid_date}),y}const s=new T;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:d.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),s.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(r=this._getOrReturnCtx(e,r),l(r,{code:d.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):b.assertNever(a);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ce({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:f.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:f.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}ce.create=t=>new ce({checks:[],coerce:t?.coerce||!1,typeName:m.ZodDate,...g(t)});class Ie extends v{_parse(e){if(this._getType(e)!==h.symbol){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:h.symbol,received:s.parsedType}),y}return N(e.data)}}Ie.create=t=>new Ie({typeName:m.ZodSymbol,...g(t)});class Ze extends v{_parse(e){if(this._getType(e)!==h.undefined){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:h.undefined,received:s.parsedType}),y}return N(e.data)}}Ze.create=t=>new Ze({typeName:m.ZodUndefined,...g(t)});class De extends v{_parse(e){if(this._getType(e)!==h.null){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:h.null,received:s.parsedType}),y}return N(e.data)}}De.create=t=>new De({typeName:m.ZodNull,...g(t)});class Le extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return N(e.data)}}Le.create=t=>new Le({typeName:m.ZodAny,...g(t)});class Pe extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return N(e.data)}}Pe.create=t=>new Pe({typeName:m.ZodUnknown,...g(t)});class B extends v{_parse(e){const n=this._getOrReturnCtx(e);return l(n,{code:d.invalid_type,expected:h.never,received:n.parsedType}),y}}B.create=t=>new B({typeName:m.ZodNever,...g(t)});class Me extends v{_parse(e){if(this._getType(e)!==h.undefined){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:h.void,received:s.parsedType}),y}return N(e.data)}}Me.create=t=>new Me({typeName:m.ZodVoid,...g(t)});class $ extends v{_parse(e){const{ctx:n,status:s}=this._processInputParams(e),r=this._def;if(n.parsedType!==h.array)return l(n,{code:d.invalid_type,expected:h.array,received:n.parsedType}),y;if(r.exactLength!==null){const i=n.data.length>r.exactLength.value,o=n.data.length<r.exactLength.value;(i||o)&&(l(n,{code:i?d.too_big:d.too_small,minimum:o?r.exactLength.value:void 0,maximum:i?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),s.dirty())}if(r.minLength!==null&&n.data.length<r.minLength.value&&(l(n,{code:d.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),s.dirty()),r.maxLength!==null&&n.data.length>r.maxLength.value&&(l(n,{code:d.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),s.dirty()),n.common.async)return Promise.all([...n.data].map((i,o)=>r.type._parseAsync(new L(n,i,n.path,o)))).then(i=>T.mergeArray(s,i));const a=[...n.data].map((i,o)=>r.type._parseSync(new L(n,i,n.path,o)));return T.mergeArray(s,a)}get element(){return this._def.type}min(e,n){return new $({...this._def,minLength:{value:e,message:f.toString(n)}})}max(e,n){return new $({...this._def,maxLength:{value:e,message:f.toString(n)}})}length(e,n){return new $({...this._def,exactLength:{value:e,message:f.toString(n)}})}nonempty(e){return this.min(1,e)}}$.create=(t,e)=>new $({type:t,minLength:null,maxLength:null,exactLength:null,typeName:m.ZodArray,...g(e)});function ee(t){if(t instanceof w){const e={};for(const n in t.shape){const s=t.shape[n];e[n]=V.create(ee(s))}return new w({...t._def,shape:()=>e})}else return t instanceof $?new $({...t._def,type:ee(t.element)}):t instanceof V?V.create(ee(t.unwrap())):t instanceof G?G.create(ee(t.unwrap())):t instanceof z?z.create(t.items.map(e=>ee(e))):t}class w extends v{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),n=b.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==h.object){const u=this._getOrReturnCtx(e);return l(u,{code:d.invalid_type,expected:h.object,received:u.parsedType}),y}const{status:s,ctx:r}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof B&&this._def.unknownKeys==="strip"))for(const u in r.data)i.includes(u)||o.push(u);const c=[];for(const u of i){const p=a[u],k=r.data[u];c.push({key:{status:"valid",value:u},value:p._parse(new L(r,k,r.path,u)),alwaysSet:u in r.data})}if(this._def.catchall instanceof B){const u=this._def.unknownKeys;if(u==="passthrough")for(const p of o)c.push({key:{status:"valid",value:p},value:{status:"valid",value:r.data[p]}});else if(u==="strict")o.length>0&&(l(r,{code:d.unrecognized_keys,keys:o}),s.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const p of o){const k=r.data[p];c.push({key:{status:"valid",value:p},value:u._parse(new L(r,k,r.path,p)),alwaysSet:p in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const u=[];for(const p of c){const k=await p.key,C=await p.value;u.push({key:k,value:C,alwaysSet:p.alwaysSet})}return u}).then(u=>T.mergeObjectSync(s,u)):T.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(e){return f.errToObj,new w({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,s)=>{const r=this._def.errorMap?.(n,s).message??s.defaultError;return n.code==="unrecognized_keys"?{message:f.errToObj(e).message??r}:{message:r}}}:{}})}strip(){return new w({...this._def,unknownKeys:"strip"})}passthrough(){return new w({...this._def,unknownKeys:"passthrough"})}extend(e){return new w({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new w({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:m.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new w({...this._def,catchall:e})}pick(e){const n={};for(const s of b.objectKeys(e))e[s]&&this.shape[s]&&(n[s]=this.shape[s]);return new w({...this._def,shape:()=>n})}omit(e){const n={};for(const s of b.objectKeys(this.shape))e[s]||(n[s]=this.shape[s]);return new w({...this._def,shape:()=>n})}deepPartial(){return ee(this)}partial(e){const n={};for(const s of b.objectKeys(this.shape)){const r=this.shape[s];e&&!e[s]?n[s]=r:n[s]=r.optional()}return new w({...this._def,shape:()=>n})}required(e){const n={};for(const s of b.objectKeys(this.shape))if(e&&!e[s])n[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof V;)a=a._def.innerType;n[s]=a}return new w({...this._def,shape:()=>n})}keyof(){return rt(b.objectKeys(this.shape))}}w.create=(t,e)=>new w({shape:()=>t,unknownKeys:"strip",catchall:B.create(),typeName:m.ZodObject,...g(e)});w.strictCreate=(t,e)=>new w({shape:()=>t,unknownKeys:"strict",catchall:B.create(),typeName:m.ZodObject,...g(e)});w.lazycreate=(t,e)=>new w({shape:t,unknownKeys:"strip",catchall:B.create(),typeName:m.ZodObject,...g(e)});class de extends v{_parse(e){const{ctx:n}=this._processInputParams(e),s=this._def.options;function r(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return n.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new D(o.ctx.common.issues));return l(n,{code:d.invalid_union,unionErrors:i}),y}if(n.common.async)return Promise.all(s.map(async a=>{const i={...n,common:{...n.common,issues:[]},parent:null};return{result:await a._parseAsync({data:n.data,path:n.path,parent:i}),ctx:i}})).then(r);{let a;const i=[];for(const c of s){const u={...n,common:{...n.common,issues:[]},parent:null},p=c._parseSync({data:n.data,path:n.path,parent:u});if(p.status==="valid")return p;p.status==="dirty"&&!a&&(a={result:p,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return n.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new D(c));return l(n,{code:d.invalid_union,unionErrors:o}),y}}get options(){return this._def.options}}de.create=(t,e)=>new de({options:t,typeName:m.ZodUnion,...g(e)});function Ve(t,e){const n=M(t),s=M(e);if(t===e)return{valid:!0,data:t};if(n===h.object&&s===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=Ve(t[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(n===h.array&&s===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=Ve(i,o);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return n===h.date&&s===h.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class ue extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e),r=(a,i)=>{if(Re(a)||Re(i))return y;const o=Ve(a.value,i.value);return o.valid?((je(a)||je(i))&&n.dirty(),{status:n.value,value:o.data}):(l(s,{code:d.invalid_intersection_types}),y)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>r(a,i)):r(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}ue.create=(t,e,n)=>new ue({left:t,right:e,typeName:m.ZodIntersection,...g(n)});class z extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.array)return l(s,{code:d.invalid_type,expected:h.array,received:s.parsedType}),y;if(s.data.length<this._def.items.length)return l(s,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;!this._def.rest&&s.data.length>this._def.items.length&&(l(s,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const a=[...s.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new L(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(a).then(i=>T.mergeArray(n,i)):T.mergeArray(n,a)}get items(){return this._def.items}rest(e){return new z({...this._def,rest:e})}}z.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new z({items:t,typeName:m.ZodTuple,rest:null,...g(e)})};class le extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.object)return l(s,{code:d.invalid_type,expected:h.object,received:s.parsedType}),y;const r=[],a=this._def.keyType,i=this._def.valueType;for(const o in s.data)r.push({key:a._parse(new L(s,o,s.path,o)),value:i._parse(new L(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?T.mergeObjectAsync(n,r):T.mergeObjectSync(n,r)}get element(){return this._def.valueType}static create(e,n,s){return n instanceof v?new le({keyType:e,valueType:n,typeName:m.ZodRecord,...g(s)}):new le({keyType:Z.create(),valueType:e,typeName:m.ZodRecord,...g(n)})}}class Be extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.map)return l(s,{code:d.invalid_type,expected:h.map,received:s.parsedType}),y;const r=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,c],u)=>({key:r._parse(new L(s,o,s.path,[u,"key"])),value:a._parse(new L(s,c,s.path,[u,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const u=await c.key,p=await c.value;if(u.status==="aborted"||p.status==="aborted")return y;(u.status==="dirty"||p.status==="dirty")&&n.dirty(),o.set(u.value,p.value)}return{status:n.value,value:o}})}else{const o=new Map;for(const c of i){const u=c.key,p=c.value;if(u.status==="aborted"||p.status==="aborted")return y;(u.status==="dirty"||p.status==="dirty")&&n.dirty(),o.set(u.value,p.value)}return{status:n.value,value:o}}}}Be.create=(t,e,n)=>new Be({valueType:e,keyType:t,typeName:m.ZodMap,...g(n)});class se extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.set)return l(s,{code:d.invalid_type,expected:h.set,received:s.parsedType}),y;const r=this._def;r.minSize!==null&&s.data.size<r.minSize.value&&(l(s,{code:d.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),n.dirty()),r.maxSize!==null&&s.data.size>r.maxSize.value&&(l(s,{code:d.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),n.dirty());const a=this._def.valueType;function i(c){const u=new Set;for(const p of c){if(p.status==="aborted")return y;p.status==="dirty"&&n.dirty(),u.add(p.value)}return{status:n.value,value:u}}const o=[...s.data.values()].map((c,u)=>a._parse(new L(s,c,s.path,u)));return s.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,n){return new se({...this._def,minSize:{value:e,message:f.toString(n)}})}max(e,n){return new se({...this._def,maxSize:{value:e,message:f.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}se.create=(t,e)=>new se({valueType:t,minSize:null,maxSize:null,typeName:m.ZodSet,...g(e)});class Ue extends v{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}Ue.create=(t,e)=>new Ue({getter:t,typeName:m.ZodLazy,...g(e)});class ze extends v{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return l(n,{received:n.data,code:d.invalid_literal,expected:this._def.value}),y}return{status:"valid",value:e.data}}get value(){return this._def.value}}ze.create=(t,e)=>new ze({value:t,typeName:m.ZodLiteral,...g(e)});function rt(t,e){return new K({values:t,typeName:m.ZodEnum,...g(e)})}class K extends v{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),s=this._def.values;return l(n,{expected:b.joinValues(s),received:n.parsedType,code:d.invalid_type}),y}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const n=this._getOrReturnCtx(e),s=this._def.values;return l(n,{received:n.data,code:d.invalid_enum_value,options:s}),y}return N(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return K.create(e,{...this._def,...n})}exclude(e,n=this._def){return K.create(this.options.filter(s=>!e.includes(s)),{...this._def,...n})}}K.create=rt;class qe extends v{_parse(e){const n=b.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==h.string&&s.parsedType!==h.number){const r=b.objectValues(n);return l(s,{expected:b.joinValues(r),received:s.parsedType,code:d.invalid_type}),y}if(this._cache||(this._cache=new Set(b.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const r=b.objectValues(n);return l(s,{received:s.data,code:d.invalid_enum_value,options:r}),y}return N(e.data)}get enum(){return this._def.values}}qe.create=(t,e)=>new qe({values:t,typeName:m.ZodNativeEnum,...g(e)});class he extends v{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==h.promise&&n.common.async===!1)return l(n,{code:d.invalid_type,expected:h.promise,received:n.parsedType}),y;const s=n.parsedType===h.promise?n.data:Promise.resolve(n.data);return N(s.then(r=>this._def.type.parseAsync(r,{path:n.path,errorMap:n.common.contextualErrorMap})))}}he.create=(t,e)=>new he({type:t,typeName:m.ZodPromise,...g(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:n,ctx:s}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:i=>{l(s,i),i.fatal?n.abort():n.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const i=r.transform(s.data,a);if(s.common.async)return Promise.resolve(i).then(async o=>{if(n.value==="aborted")return y;const c=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return c.status==="aborted"?y:c.status==="dirty"||n.value==="dirty"?te(c.value):c});{if(n.value==="aborted")return y;const o=this._def.schema._parseSync({data:i,path:s.path,parent:s});return o.status==="aborted"?y:o.status==="dirty"||n.value==="dirty"?te(o.value):o}}if(r.type==="refinement"){const i=o=>{const c=r.refinement(o,a);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?y:(o.status==="dirty"&&n.dirty(),i(o.value),{status:n.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?y:(o.status==="dirty"&&n.dirty(),i(o.value).then(()=>({status:n.value,value:o.value}))))}if(r.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!Q(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:n.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>Q(i)?Promise.resolve(r.transform(i.value,a)).then(o=>({status:n.value,value:o})):y);b.assertNever(r)}}q.create=(t,e,n)=>new q({schema:t,typeName:m.ZodEffects,effect:e,...g(n)});q.createWithPreprocess=(t,e,n)=>new q({schema:e,effect:{type:"preprocess",transform:t},typeName:m.ZodEffects,...g(n)});class V extends v{_parse(e){return this._getType(e)===h.undefined?N(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}V.create=(t,e)=>new V({innerType:t,typeName:m.ZodOptional,...g(e)});class G extends v{_parse(e){return this._getType(e)===h.null?N(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}G.create=(t,e)=>new G({innerType:t,typeName:m.ZodNullable,...g(e)});class ye extends v{_parse(e){const{ctx:n}=this._processInputParams(e);let s=n.data;return n.parsedType===h.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}ye.create=(t,e)=>new ye({innerType:t,typeName:m.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...g(e)});class _e extends v{_parse(e){const{ctx:n}=this._processInputParams(e),s={...n,common:{...n.common,issues:[]}},r=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return oe(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new D(s.common.issues)},input:s.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new D(s.common.issues)},input:s.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,...g(e)});class Fe extends v{_parse(e){if(this._getType(e)!==h.nan){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:h.nan,received:s.parsedType}),y}return{status:"valid",value:e.data}}}Fe.create=t=>new Fe({typeName:m.ZodNaN,...g(t)});class at extends v{_parse(e){const{ctx:n}=this._processInputParams(e),s=n.data;return this._def.type._parse({data:s,path:n.path,parent:n})}unwrap(){return this._def.type}}class xe extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?y:a.status==="dirty"?(n.dirty(),te(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})})();{const r=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?y:r.status==="dirty"?(n.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:s.path,parent:s})}}static create(e,n){return new xe({in:e,out:n,typeName:m.ZodPipeline})}}class ge extends v{_parse(e){const n=this._def.innerType._parse(e),s=r=>(Q(r)&&(r.value=Object.freeze(r.value)),r);return oe(n)?n.then(r=>s(r)):s(n)}unwrap(){return this._def.innerType}}ge.create=(t,e)=>new ge({innerType:t,typeName:m.ZodReadonly,...g(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 _=Z.create,it=Y.create,ke=me.create;B.create;const A=$.create,R=w.create;de.create;ue.create;z.create;const ot=le.create;K.create;he.create;V.create;G.create;const zt=Object.freeze(Object.defineProperty({__proto__:null,DIRTY:te,INVALID:y,OK:N,ParseStatus:T,Schema:v,ZodAny:Le,ZodArray:$,ZodBigInt:ne,ZodBoolean:me,ZodBranded:at,ZodCatch:_e,ZodDate:ce,ZodDefault:ye,ZodEffects:q,ZodEnum:K,ZodError:D,get ZodFirstPartyTypeKind(){return m},ZodIntersection:ue,ZodIssueCode:d,ZodLazy:Ue,ZodLiteral:ze,ZodMap:Be,ZodNaN:Fe,ZodNativeEnum:qe,ZodNever:B,ZodNull:De,ZodNullable:G,ZodNumber:Y,ZodObject:w,ZodOptional:V,ZodParsedType:h,ZodPipeline:xe,ZodPromise:he,ZodReadonly:ge,ZodRecord:le,ZodSchema:v,ZodSet:se,ZodString:Z,ZodSymbol:Ie,ZodTransformer:q,ZodTuple:z,ZodType:v,ZodUndefined:Ze,ZodUnion:de,ZodUnknown:Pe,ZodVoid:Me,addIssueToContext:l,array:A,boolean:ke,datetimeRegex:st,defaultErrorMap:pe,getErrorMap:Xe,getParsedType:M,isAborted:Re,isAsync:oe,isDirty:je,isValid:Q,makeIssue:et,number:it,object:R,get objectUtil(){return $e},record:ot,string:_,get util(){return b}},Symbol.toStringTag,{value:"Module"}));bt(zt);const qt=(t,e)=>e.skipDedupe||e.method!=="GET",Ft=(t,e)=>e.method+"@"+t,Wt=t=>t.clone(),Jt=({skip:t=qt,key:e=Ft,resolver:n=Wt}={})=>{const s=new Map;return r=>(a,i)=>{if(t(a,i))return r(a,i);const o=e(a,i);if(!s.has(o))s.set(o,[]);else return new Promise((c,u)=>{s.get(o).push([c,u])});try{return r(a,i).then(c=>(s.get(o).forEach(([u])=>u(n(c))),s.delete(o),c)).catch(c=>{throw s.get(o).forEach(([,u])=>u(c)),s.delete(o),c})}catch(c){return s.delete(o),Promise.reject(c)}}},Ht=(t,e)=>t*e,Qt=t=>t&&(t.ok||t.status>=400&&t.status<500),Yt=({delayTimer:t=500,delayRamp:e=Ht,maxAttempts:n=10,until:s=Qt,onRetry:r=null,retryOnNetworkError:a=!1,resolveWithLatestResponse:i=!1,skip:o}={})=>c=>(u,p)=>{let k=0;if(o&&o(u,p))return c(u,p);const C=(S,E)=>Promise.resolve(s(S,E)).then(F=>F?S&&i?S:E?Promise.reject(E):S:(k++,!n||k<=n?new Promise(x=>{const P=e(t,k);setTimeout(()=>{typeof r=="function"?Promise.resolve(r({response:S,error:E,url:u,attempt:k,options:p})).then((O={})=>{var j,W;x(c((j=O&&O.url)!==null&&j!==void 0?j:u,(W=O&&O.options)!==null&&W!==void 0?W:p))}):x(c(u,p))},P)}).then(C).catch(x=>{if(!a)throw x;return C(null,x)}):S&&i?S:Promise.reject(E||new Error("Number of attempts exceeded."))));return c(u,p).then(C).catch(S=>{if(!a)throw S;return C(null,S)})},ve=R({code:it(),message:_()}),Kt=R({message:_()}),Gt=R({emails:A(_()).optional(),http_body:_().optional(),http_url:_().optional(),txt_name:_().optional(),txt_value:_().optional()}),Xt=R({ciphers:A(_()).optional(),early_hints:_().optional(),http2:_().optional(),min_tls_version:_().optional(),tls_1_3:_().optional()}),en=R({id:_(),bundle_method:_().optional(),certificate_authority:_(),custom_certificate:_().optional(),custom_csr_id:_().optional(),custom_key:_().optional(),expires_on:_().optional(),hosts:A(_()).optional(),issuer:_().optional(),method:_(),serial_number:_().optional(),settings:Xt.optional(),signature:_().optional(),type:_(),uploaded_on:_().optional(),validation_errors:A(Kt).optional(),validation_records:A(Gt).optional(),wildcard:ke()}),tn=R({name:_(),type:_(),value:_()}),nn=R({http_body:_().optional(),http_url:_().optional()}),ct=R({id:_(),ssl:en,hostname:_(),custom_metadata:ot(_()).optional(),custom_origin_server:_().optional(),custom_origin_sni:_().optional(),ownership_verification:tn.optional(),ownership_verification_http:nn.optional(),status:_(),verification_errors:A(_()).optional(),created_at:_()}),ie=R({errors:A(ve),messages:A(ve),success:ke(),result:ct});R({errors:A(ve),messages:A(ve),success:ke(),result:A(ct)});function H(t){return _t(`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([Yt(),Jt()])}function Qe(t){const e={},n={};if(!t)return{sslOverrides:e,rest:n};for(const[s,r]of Object.entries(t))s.startsWith("ssl.")?e[s.slice(4)]=r:n[s]=r;return{sslOverrides:e,rest:n}}function Ne(t){const e=[];if(t.ssl.validation_records)for(const s of t.ssl.validation_records)s.txt_name&&s.txt_value&&e.push({name:"txt",record:s.txt_value,domain:s.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 s of t.ssl.validation_records)s.http_body&&s.http_url&&e.push({name:"http",http_body:s.http_body,http_url:s.http_url});const n={...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:A(yt.verificationMethodsSchema).parse(e)},domain_metadata:n}}function sn(t){return{create:async(e,n)=>{const{sslOverrides:s,rest:r}=Qe(n.domain_metadata),{result:a,errors:i,success:o}=ie.parse(await H(t).post({hostname:n.domain,ssl:{method:"txt",type:"dv",...s},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:n.domain_metadata}),c},get:async(e,n)=>{const s=await t.customDomainAdapter.get(e,n);if(!s)throw new X(404);const r=await H(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json(),{result:a,errors:i,success:o}=ie.parse(r);if(!o)throw new X(503,{message:JSON.stringify(i)});if(t.enterprise&&a.custom_metadata?.tenant_id!==e)throw new X(404);return Ne({...s,...a})},getByDomain:async e=>t.customDomainAdapter.getByDomain(e),list:async e=>{const n=await t.customDomainAdapter.list(e);return(await Promise.all(n.map(async r=>{try{const a=await H(t).get(`/custom_hostnames/${encodeURIComponent(r.custom_domain_id)}`).json(),{result:i,success:o}=ie.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,n)=>{if(t.enterprise){const{result:r,success:a}=ie.parse(await H(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json());if(!a||r.custom_metadata?.tenant_id!==e)throw new X(404)}const s=await H(t).delete(`/custom_hostnames/${encodeURIComponent(n)}`).res();return s.ok&&await t.customDomainAdapter.remove(e,n),s.ok},update:async(e,n,s)=>{const{sslOverrides:r}=Qe(s.domain_metadata),a={};if(Object.keys(r).length>0){const i=await H(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json(),{result:o,success:c}=ie.parse(i);if(!c)throw new X(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 H(t).patch(a,`/custom_hostnames/${encodeURIComponent(n)}`).res();if(!i.ok)throw new X(503,{message:await i.text()})}return t.customDomainAdapter.update(e,n,s)}}}class rn{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 n=await this.getCache(),s=this.createRequest(e),r=await n.match(s);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(n){return console.error(`CloudflareCache: get error for key ${e}:`,n),null}}async set(e,n,s){try{const r=await this.getCache(),a=s??this.config.defaultTtlSeconds,i=a!==void 0,o=i?Math.max(0,a):0,c={value:n,expiresAt:i?new Date(Date.now()+(o>0?o*1e3:-1)).toISOString():void 0,cachedAt:new Date().toISOString()},u=this.createRequest(e),p={"Content-Type":"application/json"};i&&o>0&&(p["Cache-Control"]=`max-age=${o}`);const k=new Response(JSON.stringify(c),{headers:p});await r.put(u,k)}catch(r){console.error(`CloudflareCache: set error for key ${e}:`,r)}}async delete(e){try{const n=await this.getCache(),s=this.createRequest(e);return await n.delete(s)}catch(n){return console.error(`CloudflareCache: delete error for key ${e}:`,n),!1}}async 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 an(t={}){const e={defaultTtlSeconds:300,keyPrefix:"authhero",...t};return new rn(e)}let on="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",dt=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=on[n[t]&63];return e};async function We(t,e){const n=t.timeout||3e4,s=new AbortController,r=setTimeout(()=>s.abort(),n);try{const a=`https://api.sql.cloudflarestorage.com/api/v1/accounts/${t.accountId}/r2-sql/query/${t.warehouseName}`,i=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.authToken}`},body:JSON.stringify({query:e}),signal:s.signal});if(!i.ok)throw new Error(`R2 SQL query failed: ${i.status} ${i.statusText}`);const o=await i.json();if(!o.success&&o.errors)throw new Error(`R2 SQL error: ${o.errors.join(", ")}`);return o.data||o.result?.data||[]}finally{clearTimeout(r)}}function be(t){return`'${t.replace(/'/g,"''")}'`}function U(t){return`"${t.replace(/"/g,'""')}"`}function ut(t){const e=n=>{if(!n)return"";try{return JSON.parse(n)}catch{return n}};return{type:t.type,date:t.date,description:t.description,ip:t.ip,user_agent:t.user_agent,details:e(t.details),isMobile:!!t.isMobile,user_id:t.user_id,user_name:t.user_name,connection:t.connection,connection_id:t.connection_id,client_id:t.client_id,client_name:t.client_name,audience:t.audience,scope:t.scope,strategy:t.strategy,strategy_type:t.strategy_type,hostname:t.hostname,auth0_client:e(t.auth0_client),log_id:t.id,location_info:t.country_code||t.city_name||t.latitude||t.longitude||t.time_zone||t.continent_code?{country_code:t.country_code||"",city_name:t.city_name||"",latitude:t.latitude||"",longitude:t.longitude||"",time_zone:t.time_zone||"",continent_code:t.continent_code||""}:void 0}}function cn(t){return async(e,n)=>{const s=n.log_id||dt(),r={...n,log_id:s};return await dn(t,e,r),r}}async function dn(t,e,n){const s=a=>a?JSON.stringify(a):void 0,r={id:n.log_id,tenant_id:e,type:n.type,date:n.date,description:n.description?.substring(0,256),ip:n.ip,user_agent:n.user_agent,details:s(n.details)?.substring(0,8192),isMobile:n.isMobile?1:0,user_id:n.user_id,user_name:n.user_name,connection:n.connection,connection_id:n.connection_id,client_id:n.client_id,client_name:n.client_name,audience:n.audience,scope:n.scope,strategy:n.strategy,strategy_type:n.strategy_type,hostname:n.hostname,auth0_client:s(n.auth0_client),log_id:n.log_id,country_code:n.location_info?.country_code,city_name:n.location_info?.city_name,latitude:n.location_info?.latitude,longitude:n.location_info?.longitude,time_zone:n.location_info?.time_zone,continent_code:n.location_info?.continent_code};try{if(t.pipelineBinding)await t.pipelineBinding.send([r]);else if(t.pipelineEndpoint){const a=t.timeout||3e4,i=new AbortController,o=setTimeout(()=>i.abort(),a);try{const c=await fetch(t.pipelineEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([r]),signal:i.signal});if(!c.ok)throw new Error(`Pipeline ingestion failed: ${c.status} ${c.statusText}`)}finally{clearTimeout(o)}}else throw new Error("Either pipelineEndpoint or pipelineBinding must be configured")}catch(a){throw console.error("Failed to send log to Pipeline:",a),a}}function un(t){return async(e,n)=>{const s=t.namespace||"default",r=t.tableName||"logs",a=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const _t=require("@authhero/adapter-interfaces"),gt=require("wretch");function vt(t,e){var n={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(n[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,s=Object.getOwnPropertySymbols(t);r<s.length;r++)e.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(t,s[r])&&(n[s[r]]=t[s[r]]);return n}function bt(t,e){var n;return((n=t?._def)===null||n===void 0?void 0:n.typeName)===e}function ae(t,e){const n=t.ZodType.prototype[e];t.ZodType.prototype[e]=function(...s){const r=n.apply(this,s);return r._def.openapi=this._def.openapi,r}}function xt(t){if(typeof t.ZodType.prototype.openapi<"u")return;t.ZodType.prototype.openapi=function(r,a){var i,o,c,u,p,k;const C=typeof r=="string"?a:r,S=C??{},{param:E}=S,F=vt(S,["param"]),x=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),F),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||E?{param:Object.assign(Object.assign({},(k=(p=this._def.openapi)===null||p===void 0?void 0:p.metadata)===null||k===void 0?void 0:k.param),E)}:void 0),O=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(x).length>0?{_internal:x}:void 0),Object.keys(P).length>0?{metadata:P}:void 0)}));if(bt(this,"ZodObject")){const j=this.extend;O.extend=function(...W){var J,re,we,Se,Ce,Te,Ee;const Oe=j.apply(this,W);return Oe._def.openapi={_internal:{extendedFrom:!((re=(J=this._def.openapi)===null||J===void 0?void 0:J._internal)===null||re===void 0)&&re.refId?{refId:(Se=(we=this._def.openapi)===null||we===void 0?void 0:we._internal)===null||Se===void 0?void 0:Se.refId,schema:this}:(Te=(Ce=this._def.openapi)===null||Ce===void 0?void 0:Ce._internal)===null||Te===void 0?void 0:Te.extendedFrom},metadata:(Ee=Oe._def.openapi)===null||Ee===void 0?void 0:Ee.metadata},Oe}}return O},ae(t,"optional"),ae(t,"nullable"),ae(t,"default"),ae(t,"transform"),ae(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 u,p;c._def.openapi=(p=(u=r[o])===null||u===void 0?void 0:u._def)===null||p===void 0?void 0:p.openapi}),a._def.openapi=void 0,a};const n=t.ZodObject.prototype.pick;t.ZodObject.prototype.pick=function(...r){const a=n.apply(this,r);return a._def.openapi=void 0,a};const s=t.ZodObject.prototype.omit;t.ZodObject.prototype.omit=function(...r){const a=s.apply(this,r);return a._def.openapi=void 0,a}}var X=class extends Error{res;status;constructor(t=500,e){super(e?.message,{cause:e?.cause}),this.res=e?.res,this.status=t}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}};new Set(".\\+*[^]$()");var b;(function(t){t.assertEqual=r=>{};function e(r){}t.assertIs=e;function n(r){throw new Error}t.assertNever=n,t.arrayToEnum=r=>{const a={};for(const i of r)a[i]=i;return a},t.getValidEnumValues=r=>{const a=t.objectKeys(r).filter(o=>typeof r[r[o]]!="number"),i={};for(const o of a)i[o]=r[o];return t.objectValues(i)},t.objectValues=r=>t.objectKeys(r).map(function(a){return r[a]}),t.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const a=[];for(const i in r)Object.prototype.hasOwnProperty.call(r,i)&&a.push(i);return a},t.find=(r,a)=>{for(const i of r)if(a(i))return i},t.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function s(r,a=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}t.joinValues=s,t.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(b||(b={}));var $e;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})($e||($e={}));const h=b.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),M=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}},d=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 D extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(a){return a.message},s={_errors:[]},r=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(i.argumentsError);else if(i.path.length===0)s._errors.push(n(i));else{let o=s,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(n(i))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return r(this),s}static assert(e){if(!(e instanceof D))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,b.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},s=[];for(const r of this.issues)if(r.path.length>0){const a=r.path[0];n[a]=n[a]||[],n[a].push(e(r))}else s.push(e(r));return{formErrors:s,fieldErrors:n}}get formErrors(){return this.flatten()}}D.create=t=>new D(t);const pe=(t,e)=>{let n;switch(t.code){case d.invalid_type:t.received===h.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case d.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,b.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:n=`Unrecognized key(s) in object: ${b.joinValues(t.keys,", ")}`;break;case d.invalid_union:n="Invalid input";break;case d.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${b.joinValues(t.options)}`;break;case d.invalid_enum_value:n=`Invalid enum value. Expected ${b.joinValues(t.options)}, received '${t.received}'`;break;case d.invalid_arguments:n="Invalid function arguments";break;case d.invalid_return_type:n="Invalid function return type";break;case d.invalid_date:n="Invalid date";break;case d.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:b.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case d.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case d.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case d.custom:n="Invalid input";break;case d.invalid_intersection_types:n="Intersection results could not be merged";break;case d.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case d.not_finite:n="Number must be finite";break;default:n=e.defaultError,b.assertNever(t)}return{message:n}};let kt=pe;function Xe(){return kt}const et=t=>{const{data:e,path:n,errorMaps:s,issueData:r}=t,a=[...n,...r.path||[]],i={...r,path:a};if(r.message!==void 0)return{...r,path:a,message:r.message};let o="";const c=s.filter(u=>!!u).slice().reverse();for(const u of c)o=u(i,{data:e,defaultError:o}).message;return{...r,path:a,message:o}};function l(t,e){const n=Xe(),s=et({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===pe?void 0:pe].filter(r=>!!r)});t.common.issues.push(s)}class T{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const s=[];for(const r of n){if(r.status==="aborted")return y;r.status==="dirty"&&e.dirty(),s.push(r.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,n){const s=[];for(const r of n){const a=await r.key,i=await r.value;s.push({key:a,value:i})}return T.mergeObjectSync(e,s)}static mergeObjectSync(e,n){const s={};for(const r of n){const{key:a,value:i}=r;if(a.status==="aborted"||i.status==="aborted")return y;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||r.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}}const y=Object.freeze({status:"aborted"}),te=t=>({status:"dirty",value:t}),N=t=>({status:"valid",value:t}),Re=t=>t.status==="aborted",je=t=>t.status==="dirty",Q=t=>t.status==="valid",oe=t=>typeof Promise<"u"&&t instanceof Promise;var f;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(f||(f={}));class L{constructor(e,n,s,r){this._cachedPath=[],this.parent=e,this.data=n,this._path=s,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const He=(t,e)=>{if(Q(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new D(t.common.issues);return this._error=n,this._error}}};function g(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:s,description:r}=t;if(e&&(n||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(i,o)=>{const{message:c}=t;return i.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??s??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:c??n??o.defaultError}},description:r}}class v{get description(){return this._def.description}_getType(e){return M(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:M(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new T,ctx:{common:e.parent.common,data:e.data,parsedType:M(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(oe(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const s=this.safeParse(e,n);if(s.success)return s.data;throw s.error}safeParse(e,n){const s={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)},r=this._parseSync({data:e,path:s.path,parent:s});return He(s,r)}"~validate"(e){const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:n});return Q(s)?{value:s.value}:{issues:n.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(s=>Q(s)?{value:s.value}:{issues:n.common.issues})}async parseAsync(e,n){const s=await this.safeParseAsync(e,n);if(s.success)return s.data;throw s.error}async safeParseAsync(e,n){const s={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)},r=this._parse({data:e,path:s.path,parent:s}),a=await(oe(r)?r:Promise.resolve(r));return He(s,a)}refine(e,n){const s=r=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(r):n;return this._refinement((r,a)=>{const i=e(r),o=()=>a.addIssue({code:d.custom,...s(r)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,n){return this._refinement((s,r)=>e(s)?!0:(r.addIssue(typeof n=="function"?n(s,r):n),!1))}_refinement(e){return new 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:n=>this["~validate"](n)}}optional(){return B.create(this,this._def)}nullable(){return G.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return $.create(this)}promise(){return he.create(this,this._def)}or(e){return de.create([this,e],this._def)}and(e){return ue.create(this,e,this._def)}transform(e){return new q({...g(this._def),schema:this,typeName:m.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new ye({...g(this._def),innerType:this,defaultValue:n,typeName:m.ZodDefault})}brand(){return new at({typeName:m.ZodBranded,type:this,...g(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new _e({...g(this._def),innerType:this,catchValue:n,typeName:m.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return xe.create(this,e)}readonly(){return ge.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const wt=/^c[^\s-]{8,}$/i,St=/^[0-9a-z]+$/,Ct=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Tt=/^[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,Et=/^[a-z0-9_-]{21}$/i,Ot=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,At=/^[-+]?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)?)??$/,Nt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,$t="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ae;const Rt=/^(?:(?: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])$/,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])\/(3[0-2]|[12]?[0-9])$/,It=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,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])$/,Dt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Lt=/^([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])))",Pt=new RegExp(`^${tt}$`);function nt(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function Mt(t){return new RegExp(`^${nt(t)}$`)}function st(t){let e=`${tt}T${nt(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Bt(t,e){return!!((e==="v4"||!e)&&Rt.test(t)||(e==="v6"||!e)&&It.test(t))}function Vt(t,e){if(!Ot.test(t))return!1;try{const[n]=t.split(".");if(!n)return!1;const s=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),r=JSON.parse(atob(s));return!(typeof r!="object"||r===null||"typ"in r&&r?.typ!=="JWT"||!r.alg||e&&r.alg!==e)}catch{return!1}}function Ut(t,e){return!!((e==="v4"||!e)&&jt.test(t)||(e==="v6"||!e)&&Zt.test(t))}class Z 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:d.invalid_type,expected:h.string,received:a.parsedType}),y}const s=new T;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:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="max")e.data.length>a.value&&(r=this._getOrReturnCtx(e,r),l(r,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(r=this._getOrReturnCtx(e,r),i?l(r,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&l(r,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty())}else if(a.kind==="email")Nt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"email",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")Ae||(Ae=new RegExp($t,"u")),Ae.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"emoji",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")Tt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"uuid",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")Et.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"nanoid",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")wt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"cuid",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")St.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"cuid2",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")Ct.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"ulid",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),l(r,{validation:"url",code:d.invalid_string,message:a.message}),s.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"regex",code:d.invalid_string,message:a.message}),s.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(r=this._getOrReturnCtx(e,r),l(r,{code:d.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),s.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(r=this._getOrReturnCtx(e,r),l(r,{code:d.invalid_string,validation:{startsWith:a.value},message:a.message}),s.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(r=this._getOrReturnCtx(e,r),l(r,{code:d.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?st(a).test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:d.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?Pt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:d.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?Mt(a).test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:d.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?At.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"duration",code:d.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?Bt(e.data,a.version)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"ip",code:d.invalid_string,message:a.message}),s.dirty()):a.kind==="jwt"?Vt(e.data,a.alg)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"jwt",code:d.invalid_string,message:a.message}),s.dirty()):a.kind==="cidr"?Ut(e.data,a.version)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"cidr",code:d.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?Dt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"base64",code:d.invalid_string,message:a.message}),s.dirty()):a.kind==="base64url"?Lt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"base64url",code:d.invalid_string,message:a.message}),s.dirty()):b.assertNever(a);return{status:s.value,value:e.data}}_regex(e,n,s){return this.refinement(r=>e.test(r),{validation:n,code:d.invalid_string,...f.errToObj(s)})}_addCheck(e){return new Z({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...f.errToObj(e)})}url(e){return this._addCheck({kind:"url",...f.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...f.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...f.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...f.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...f.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...f.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...f.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...f.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...f.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...f.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...f.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...f.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,...f.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,...f.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...f.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...f.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...f.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...f.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...f.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...f.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...f.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...f.errToObj(n)})}nonempty(e){return this.min(1,f.errToObj(e))}trim(){return new Z({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Z({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Z({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}Z.create=t=>new Z({checks:[],typeName:m.ZodString,coerce:t?.coerce??!1,...g(t)});function zt(t,e){const n=(t.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,r=n>s?n:s,a=Number.parseInt(t.toFixed(r).replace(".","")),i=Number.parseInt(e.toFixed(r).replace(".",""));return a%i/10**r}class Y 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:d.invalid_type,expected:h.number,received:a.parsedType}),y}let s;const r=new T;for(const a of this._def.checks)a.kind==="int"?b.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:d.invalid_type,expected:"integer",received:"float",message:a.message}),r.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.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&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:d.not_finite,message:a.message}),r.dirty()):b.assertNever(a);return{status:r.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,f.toString(n))}gt(e,n){return this.setLimit("min",e,!1,f.toString(n))}lte(e,n){return this.setLimit("max",e,!0,f.toString(n))}lt(e,n){return this.setLimit("max",e,!1,f.toString(n))}setLimit(e,n,s,r){return new Y({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:s,message:f.toString(r)}]})}_addCheck(e){return new Y({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:f.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:f.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:f.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:f.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:f.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:f.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:f.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:f.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:f.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&b.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(n===null||s.value>n)&&(n=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(n)&&Number.isFinite(e)}}Y.create=t=>new Y({checks:[],typeName:m.ZodNumber,coerce:t?.coerce||!1,...g(t)});class ne 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 s;const r=new T;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):b.assertNever(a);return{status:r.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return l(n,{code:d.invalid_type,expected:h.bigint,received:n.parsedType}),y}gte(e,n){return this.setLimit("min",e,!0,f.toString(n))}gt(e,n){return this.setLimit("min",e,!1,f.toString(n))}lte(e,n){return this.setLimit("max",e,!0,f.toString(n))}lt(e,n){return this.setLimit("max",e,!1,f.toString(n))}setLimit(e,n,s,r){return new ne({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:s,message:f.toString(r)}]})}_addCheck(e){return new ne({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:f.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:f.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:f.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:f.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:f.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}ne.create=t=>new ne({checks:[],typeName:m.ZodBigInt,coerce:t?.coerce??!1,...g(t)});class me extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.boolean){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:h.boolean,received:s.parsedType}),y}return N(e.data)}}me.create=t=>new me({typeName:m.ZodBoolean,coerce:t?.coerce||!1,...g(t)});class ce 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:d.invalid_type,expected:h.date,received:a.parsedType}),y}if(Number.isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return l(a,{code:d.invalid_date}),y}const s=new T;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:d.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),s.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(r=this._getOrReturnCtx(e,r),l(r,{code:d.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):b.assertNever(a);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ce({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:f.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:f.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}ce.create=t=>new ce({checks:[],coerce:t?.coerce||!1,typeName:m.ZodDate,...g(t)});class Ie extends v{_parse(e){if(this._getType(e)!==h.symbol){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:h.symbol,received:s.parsedType}),y}return N(e.data)}}Ie.create=t=>new Ie({typeName:m.ZodSymbol,...g(t)});class Ze extends v{_parse(e){if(this._getType(e)!==h.undefined){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:h.undefined,received:s.parsedType}),y}return N(e.data)}}Ze.create=t=>new Ze({typeName:m.ZodUndefined,...g(t)});class De extends v{_parse(e){if(this._getType(e)!==h.null){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:h.null,received:s.parsedType}),y}return N(e.data)}}De.create=t=>new De({typeName:m.ZodNull,...g(t)});class Le extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return N(e.data)}}Le.create=t=>new Le({typeName:m.ZodAny,...g(t)});class Pe extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return N(e.data)}}Pe.create=t=>new Pe({typeName:m.ZodUnknown,...g(t)});class V extends v{_parse(e){const n=this._getOrReturnCtx(e);return l(n,{code:d.invalid_type,expected:h.never,received:n.parsedType}),y}}V.create=t=>new V({typeName:m.ZodNever,...g(t)});class Me extends v{_parse(e){if(this._getType(e)!==h.undefined){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:h.void,received:s.parsedType}),y}return N(e.data)}}Me.create=t=>new Me({typeName:m.ZodVoid,...g(t)});class $ extends v{_parse(e){const{ctx:n,status:s}=this._processInputParams(e),r=this._def;if(n.parsedType!==h.array)return l(n,{code:d.invalid_type,expected:h.array,received:n.parsedType}),y;if(r.exactLength!==null){const i=n.data.length>r.exactLength.value,o=n.data.length<r.exactLength.value;(i||o)&&(l(n,{code:i?d.too_big:d.too_small,minimum:o?r.exactLength.value:void 0,maximum:i?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),s.dirty())}if(r.minLength!==null&&n.data.length<r.minLength.value&&(l(n,{code:d.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),s.dirty()),r.maxLength!==null&&n.data.length>r.maxLength.value&&(l(n,{code:d.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),s.dirty()),n.common.async)return Promise.all([...n.data].map((i,o)=>r.type._parseAsync(new L(n,i,n.path,o)))).then(i=>T.mergeArray(s,i));const a=[...n.data].map((i,o)=>r.type._parseSync(new L(n,i,n.path,o)));return T.mergeArray(s,a)}get element(){return this._def.type}min(e,n){return new $({...this._def,minLength:{value:e,message:f.toString(n)}})}max(e,n){return new $({...this._def,maxLength:{value:e,message:f.toString(n)}})}length(e,n){return new $({...this._def,exactLength:{value:e,message:f.toString(n)}})}nonempty(e){return this.min(1,e)}}$.create=(t,e)=>new $({type:t,minLength:null,maxLength:null,exactLength:null,typeName:m.ZodArray,...g(e)});function ee(t){if(t instanceof w){const e={};for(const n in t.shape){const s=t.shape[n];e[n]=B.create(ee(s))}return new w({...t._def,shape:()=>e})}else return t instanceof $?new $({...t._def,type:ee(t.element)}):t instanceof B?B.create(ee(t.unwrap())):t instanceof G?G.create(ee(t.unwrap())):t instanceof z?z.create(t.items.map(e=>ee(e))):t}class w extends v{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),n=b.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==h.object){const u=this._getOrReturnCtx(e);return l(u,{code:d.invalid_type,expected:h.object,received:u.parsedType}),y}const{status:s,ctx:r}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof V&&this._def.unknownKeys==="strip"))for(const u in r.data)i.includes(u)||o.push(u);const c=[];for(const u of i){const p=a[u],k=r.data[u];c.push({key:{status:"valid",value:u},value:p._parse(new L(r,k,r.path,u)),alwaysSet:u in r.data})}if(this._def.catchall instanceof V){const u=this._def.unknownKeys;if(u==="passthrough")for(const p of o)c.push({key:{status:"valid",value:p},value:{status:"valid",value:r.data[p]}});else if(u==="strict")o.length>0&&(l(r,{code:d.unrecognized_keys,keys:o}),s.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const p of o){const k=r.data[p];c.push({key:{status:"valid",value:p},value:u._parse(new L(r,k,r.path,p)),alwaysSet:p in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const u=[];for(const p of c){const k=await p.key,C=await p.value;u.push({key:k,value:C,alwaysSet:p.alwaysSet})}return u}).then(u=>T.mergeObjectSync(s,u)):T.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(e){return f.errToObj,new w({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,s)=>{const r=this._def.errorMap?.(n,s).message??s.defaultError;return n.code==="unrecognized_keys"?{message:f.errToObj(e).message??r}:{message:r}}}:{}})}strip(){return new w({...this._def,unknownKeys:"strip"})}passthrough(){return new w({...this._def,unknownKeys:"passthrough"})}extend(e){return new w({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new w({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:m.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new w({...this._def,catchall:e})}pick(e){const n={};for(const s of b.objectKeys(e))e[s]&&this.shape[s]&&(n[s]=this.shape[s]);return new w({...this._def,shape:()=>n})}omit(e){const n={};for(const s of b.objectKeys(this.shape))e[s]||(n[s]=this.shape[s]);return new w({...this._def,shape:()=>n})}deepPartial(){return ee(this)}partial(e){const n={};for(const s of b.objectKeys(this.shape)){const r=this.shape[s];e&&!e[s]?n[s]=r:n[s]=r.optional()}return new w({...this._def,shape:()=>n})}required(e){const n={};for(const s of b.objectKeys(this.shape))if(e&&!e[s])n[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof B;)a=a._def.innerType;n[s]=a}return new w({...this._def,shape:()=>n})}keyof(){return rt(b.objectKeys(this.shape))}}w.create=(t,e)=>new w({shape:()=>t,unknownKeys:"strip",catchall:V.create(),typeName:m.ZodObject,...g(e)});w.strictCreate=(t,e)=>new w({shape:()=>t,unknownKeys:"strict",catchall:V.create(),typeName:m.ZodObject,...g(e)});w.lazycreate=(t,e)=>new w({shape:t,unknownKeys:"strip",catchall:V.create(),typeName:m.ZodObject,...g(e)});class de extends v{_parse(e){const{ctx:n}=this._processInputParams(e),s=this._def.options;function r(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return n.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new D(o.ctx.common.issues));return l(n,{code:d.invalid_union,unionErrors:i}),y}if(n.common.async)return Promise.all(s.map(async a=>{const i={...n,common:{...n.common,issues:[]},parent:null};return{result:await a._parseAsync({data:n.data,path:n.path,parent:i}),ctx:i}})).then(r);{let a;const i=[];for(const c of s){const u={...n,common:{...n.common,issues:[]},parent:null},p=c._parseSync({data:n.data,path:n.path,parent:u});if(p.status==="valid")return p;p.status==="dirty"&&!a&&(a={result:p,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return n.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new D(c));return l(n,{code:d.invalid_union,unionErrors:o}),y}}get options(){return this._def.options}}de.create=(t,e)=>new de({options:t,typeName:m.ZodUnion,...g(e)});function Be(t,e){const n=M(t),s=M(e);if(t===e)return{valid:!0,data:t};if(n===h.object&&s===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(n===h.array&&s===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 n===h.date&&s===h.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class ue extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e),r=(a,i)=>{if(Re(a)||Re(i))return y;const o=Be(a.value,i.value);return o.valid?((je(a)||je(i))&&n.dirty(),{status:n.value,value:o.data}):(l(s,{code:d.invalid_intersection_types}),y)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>r(a,i)):r(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}ue.create=(t,e,n)=>new ue({left:t,right:e,typeName:m.ZodIntersection,...g(n)});class z extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.array)return l(s,{code:d.invalid_type,expected:h.array,received:s.parsedType}),y;if(s.data.length<this._def.items.length)return l(s,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;!this._def.rest&&s.data.length>this._def.items.length&&(l(s,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const a=[...s.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new L(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(a).then(i=>T.mergeArray(n,i)):T.mergeArray(n,a)}get items(){return this._def.items}rest(e){return new z({...this._def,rest:e})}}z.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new z({items:t,typeName:m.ZodTuple,rest:null,...g(e)})};class le extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.object)return l(s,{code:d.invalid_type,expected:h.object,received:s.parsedType}),y;const r=[],a=this._def.keyType,i=this._def.valueType;for(const o in s.data)r.push({key:a._parse(new L(s,o,s.path,o)),value:i._parse(new L(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?T.mergeObjectAsync(n,r):T.mergeObjectSync(n,r)}get element(){return this._def.valueType}static create(e,n,s){return n instanceof v?new le({keyType:e,valueType:n,typeName:m.ZodRecord,...g(s)}):new le({keyType:Z.create(),valueType:e,typeName:m.ZodRecord,...g(n)})}}class Ve extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.map)return l(s,{code:d.invalid_type,expected:h.map,received:s.parsedType}),y;const r=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,c],u)=>({key:r._parse(new L(s,o,s.path,[u,"key"])),value:a._parse(new L(s,c,s.path,[u,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const u=await c.key,p=await c.value;if(u.status==="aborted"||p.status==="aborted")return y;(u.status==="dirty"||p.status==="dirty")&&n.dirty(),o.set(u.value,p.value)}return{status:n.value,value:o}})}else{const o=new Map;for(const c of i){const u=c.key,p=c.value;if(u.status==="aborted"||p.status==="aborted")return y;(u.status==="dirty"||p.status==="dirty")&&n.dirty(),o.set(u.value,p.value)}return{status:n.value,value:o}}}}Ve.create=(t,e,n)=>new Ve({valueType:e,keyType:t,typeName:m.ZodMap,...g(n)});class se extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.set)return l(s,{code:d.invalid_type,expected:h.set,received:s.parsedType}),y;const r=this._def;r.minSize!==null&&s.data.size<r.minSize.value&&(l(s,{code:d.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),n.dirty()),r.maxSize!==null&&s.data.size>r.maxSize.value&&(l(s,{code:d.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),n.dirty());const a=this._def.valueType;function i(c){const u=new Set;for(const p of c){if(p.status==="aborted")return y;p.status==="dirty"&&n.dirty(),u.add(p.value)}return{status:n.value,value:u}}const o=[...s.data.values()].map((c,u)=>a._parse(new L(s,c,s.path,u)));return s.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,n){return new se({...this._def,minSize:{value:e,message:f.toString(n)}})}max(e,n){return new se({...this._def,maxSize:{value:e,message:f.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}se.create=(t,e)=>new se({valueType:t,minSize:null,maxSize:null,typeName:m.ZodSet,...g(e)});class Ue extends v{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}Ue.create=(t,e)=>new Ue({getter:t,typeName:m.ZodLazy,...g(e)});class ze extends v{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return l(n,{received:n.data,code:d.invalid_literal,expected:this._def.value}),y}return{status:"valid",value:e.data}}get value(){return this._def.value}}ze.create=(t,e)=>new ze({value:t,typeName:m.ZodLiteral,...g(e)});function rt(t,e){return new K({values:t,typeName:m.ZodEnum,...g(e)})}class K extends v{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),s=this._def.values;return l(n,{expected:b.joinValues(s),received:n.parsedType,code:d.invalid_type}),y}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const n=this._getOrReturnCtx(e),s=this._def.values;return l(n,{received:n.data,code:d.invalid_enum_value,options:s}),y}return N(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return K.create(e,{...this._def,...n})}exclude(e,n=this._def){return K.create(this.options.filter(s=>!e.includes(s)),{...this._def,...n})}}K.create=rt;class qe extends v{_parse(e){const n=b.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==h.string&&s.parsedType!==h.number){const r=b.objectValues(n);return l(s,{expected:b.joinValues(r),received:s.parsedType,code:d.invalid_type}),y}if(this._cache||(this._cache=new Set(b.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const r=b.objectValues(n);return l(s,{received:s.data,code:d.invalid_enum_value,options:r}),y}return N(e.data)}get enum(){return this._def.values}}qe.create=(t,e)=>new qe({values:t,typeName:m.ZodNativeEnum,...g(e)});class he extends v{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==h.promise&&n.common.async===!1)return l(n,{code:d.invalid_type,expected:h.promise,received:n.parsedType}),y;const s=n.parsedType===h.promise?n.data:Promise.resolve(n.data);return N(s.then(r=>this._def.type.parseAsync(r,{path:n.path,errorMap:n.common.contextualErrorMap})))}}he.create=(t,e)=>new he({type:t,typeName:m.ZodPromise,...g(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:n,ctx:s}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:i=>{l(s,i),i.fatal?n.abort():n.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const i=r.transform(s.data,a);if(s.common.async)return Promise.resolve(i).then(async o=>{if(n.value==="aborted")return y;const c=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return c.status==="aborted"?y:c.status==="dirty"||n.value==="dirty"?te(c.value):c});{if(n.value==="aborted")return y;const o=this._def.schema._parseSync({data:i,path:s.path,parent:s});return o.status==="aborted"?y:o.status==="dirty"||n.value==="dirty"?te(o.value):o}}if(r.type==="refinement"){const i=o=>{const c=r.refinement(o,a);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?y:(o.status==="dirty"&&n.dirty(),i(o.value),{status:n.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?y:(o.status==="dirty"&&n.dirty(),i(o.value).then(()=>({status:n.value,value:o.value}))))}if(r.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!Q(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:n.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>Q(i)?Promise.resolve(r.transform(i.value,a)).then(o=>({status:n.value,value:o})):y);b.assertNever(r)}}q.create=(t,e,n)=>new q({schema:t,typeName:m.ZodEffects,effect:e,...g(n)});q.createWithPreprocess=(t,e,n)=>new q({schema:e,effect:{type:"preprocess",transform:t},typeName:m.ZodEffects,...g(n)});class B extends v{_parse(e){return this._getType(e)===h.undefined?N(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}B.create=(t,e)=>new B({innerType:t,typeName:m.ZodOptional,...g(e)});class G extends v{_parse(e){return this._getType(e)===h.null?N(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}G.create=(t,e)=>new G({innerType:t,typeName:m.ZodNullable,...g(e)});class ye extends v{_parse(e){const{ctx:n}=this._processInputParams(e);let s=n.data;return n.parsedType===h.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}ye.create=(t,e)=>new ye({innerType:t,typeName:m.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...g(e)});class _e extends v{_parse(e){const{ctx:n}=this._processInputParams(e),s={...n,common:{...n.common,issues:[]}},r=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return oe(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new D(s.common.issues)},input:s.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new D(s.common.issues)},input:s.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,...g(e)});class Fe extends v{_parse(e){if(this._getType(e)!==h.nan){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:h.nan,received:s.parsedType}),y}return{status:"valid",value:e.data}}}Fe.create=t=>new Fe({typeName:m.ZodNaN,...g(t)});class at extends v{_parse(e){const{ctx:n}=this._processInputParams(e),s=n.data;return this._def.type._parse({data:s,path:n.path,parent:n})}unwrap(){return this._def.type}}class xe extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?y:a.status==="dirty"?(n.dirty(),te(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})})();{const r=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?y:r.status==="dirty"?(n.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:s.path,parent:s})}}static create(e,n){return new xe({in:e,out:n,typeName:m.ZodPipeline})}}class ge extends v{_parse(e){const n=this._def.innerType._parse(e),s=r=>(Q(r)&&(r.value=Object.freeze(r.value)),r);return oe(n)?n.then(r=>s(r)):s(n)}unwrap(){return this._def.innerType}}ge.create=(t,e)=>new ge({innerType:t,typeName:m.ZodReadonly,...g(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 _=Z.create,it=Y.create,ke=me.create;V.create;const A=$.create,R=w.create;de.create;ue.create;z.create;const ot=le.create;K.create;he.create;B.create;G.create;const qt=Object.freeze(Object.defineProperty({__proto__:null,DIRTY:te,INVALID:y,OK:N,ParseStatus:T,Schema:v,ZodAny:Le,ZodArray:$,ZodBigInt:ne,ZodBoolean:me,ZodBranded:at,ZodCatch:_e,ZodDate:ce,ZodDefault:ye,ZodEffects:q,ZodEnum:K,ZodError:D,get ZodFirstPartyTypeKind(){return m},ZodIntersection:ue,ZodIssueCode:d,ZodLazy:Ue,ZodLiteral:ze,ZodMap:Ve,ZodNaN:Fe,ZodNativeEnum:qe,ZodNever:V,ZodNull:De,ZodNullable:G,ZodNumber:Y,ZodObject:w,ZodOptional:B,ZodParsedType:h,ZodPipeline:xe,ZodPromise:he,ZodReadonly:ge,ZodRecord:le,ZodSchema:v,ZodSet:se,ZodString:Z,ZodSymbol:Ie,ZodTransformer:q,ZodTuple:z,ZodType:v,ZodUndefined:Ze,ZodUnion:de,ZodUnknown:Pe,ZodVoid:Me,addIssueToContext:l,array:A,boolean:ke,datetimeRegex:st,defaultErrorMap:pe,getErrorMap:Xe,getParsedType:M,isAborted:Re,isAsync:oe,isDirty:je,isValid:Q,makeIssue:et,number:it,object:R,get objectUtil(){return $e},record:ot,string:_,get util(){return b}},Symbol.toStringTag,{value:"Module"}));xt(qt);const Ft=(t,e)=>e.skipDedupe||e.method!=="GET",Wt=(t,e)=>e.method+"@"+t,Jt=t=>t.clone(),Ht=({skip:t=Ft,key:e=Wt,resolver:n=Jt}={})=>{const s=new Map;return r=>(a,i)=>{if(t(a,i))return r(a,i);const o=e(a,i);if(!s.has(o))s.set(o,[]);else return new Promise((c,u)=>{s.get(o).push([c,u])});try{return r(a,i).then(c=>(s.get(o).forEach(([u])=>u(n(c))),s.delete(o),c)).catch(c=>{throw s.get(o).forEach(([,u])=>u(c)),s.delete(o),c})}catch(c){return s.delete(o),Promise.reject(c)}}},Qt=(t,e)=>t*e,Yt=t=>t&&(t.ok||t.status>=400&&t.status<500),Kt=({delayTimer:t=500,delayRamp:e=Qt,maxAttempts:n=10,until:s=Yt,onRetry:r=null,retryOnNetworkError:a=!1,resolveWithLatestResponse:i=!1,skip:o}={})=>c=>(u,p)=>{let k=0;if(o&&o(u,p))return c(u,p);const C=(S,E)=>Promise.resolve(s(S,E)).then(F=>F?S&&i?S:E?Promise.reject(E):S:(k++,!n||k<=n?new Promise(x=>{const P=e(t,k);setTimeout(()=>{typeof r=="function"?Promise.resolve(r({response:S,error:E,url:u,attempt:k,options:p})).then((O={})=>{var j,W;x(c((j=O&&O.url)!==null&&j!==void 0?j:u,(W=O&&O.options)!==null&&W!==void 0?W:p))}):x(c(u,p))},P)}).then(C).catch(x=>{if(!a)throw x;return C(null,x)}):S&&i?S:Promise.reject(E||new Error("Number of attempts exceeded."))));return c(u,p).then(C).catch(S=>{if(!a)throw S;return C(null,S)})},ve=R({code:it(),message:_()}),Gt=R({message:_()}),Xt=R({emails:A(_()).optional(),http_body:_().optional(),http_url:_().optional(),txt_name:_().optional(),txt_value:_().optional()}),en=R({ciphers:A(_()).optional(),early_hints:_().optional(),http2:_().optional(),min_tls_version:_().optional(),tls_1_3:_().optional()}),tn=R({id:_(),bundle_method:_().optional(),certificate_authority:_(),custom_certificate:_().optional(),custom_csr_id:_().optional(),custom_key:_().optional(),expires_on:_().optional(),hosts:A(_()).optional(),issuer:_().optional(),method:_(),serial_number:_().optional(),settings:en.optional(),signature:_().optional(),type:_(),uploaded_on:_().optional(),validation_errors:A(Gt).optional(),validation_records:A(Xt).optional(),wildcard:ke()}),nn=R({name:_(),type:_(),value:_()}),sn=R({http_body:_().optional(),http_url:_().optional()}),ct=R({id:_(),ssl:tn,hostname:_(),custom_metadata:ot(_()).optional(),custom_origin_server:_().optional(),custom_origin_sni:_().optional(),ownership_verification:nn.optional(),ownership_verification_http:sn.optional(),status:_(),verification_errors:A(_()).optional(),created_at:_()}),ie=R({errors:A(ve),messages:A(ve),success:ke(),result:ct});R({errors:A(ve),messages:A(ve),success:ke(),result:A(ct)});function H(t){return gt(`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([Kt(),Ht()])}function Qe(t){const e={},n={};if(!t)return{sslOverrides:e,rest:n};for(const[s,r]of Object.entries(t))s.startsWith("ssl.")?e[s.slice(4)]=r:n[s]=r;return{sslOverrides:e,rest:n}}function Ne(t){const e=[];if(t.ssl.validation_records)for(const s of t.ssl.validation_records)s.txt_name&&s.txt_value&&e.push({name:"txt",record:s.txt_value,domain:s.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 s of t.ssl.validation_records)s.http_body&&s.http_url&&e.push({name:"http",http_body:s.http_body,http_url:s.http_url});const n={...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:A(_t.verificationMethodsSchema).parse(e)},domain_metadata:n}}function rn(t){return{create:async(e,n)=>{const{sslOverrides:s,rest:r}=Qe(n.domain_metadata),{result:a,errors:i,success:o}=ie.parse(await H(t).post({hostname:n.domain,ssl:{method:"txt",type:"dv",...s},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:n.domain_metadata}),c},get:async(e,n)=>{const s=await t.customDomainAdapter.get(e,n);if(!s)throw new X(404);const r=await H(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json(),{result:a,errors:i,success:o}=ie.parse(r);if(!o)throw new X(503,{message:JSON.stringify(i)});if(t.enterprise&&a.custom_metadata?.tenant_id!==e)throw new X(404);return Ne({...s,...a})},getByDomain:async e=>t.customDomainAdapter.getByDomain(e),list:async e=>{const n=await t.customDomainAdapter.list(e);return(await Promise.all(n.map(async r=>{try{const a=await H(t).get(`/custom_hostnames/${encodeURIComponent(r.custom_domain_id)}`).json(),{result:i,success:o}=ie.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,n)=>{if(t.enterprise){const{result:r,success:a}=ie.parse(await H(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json());if(!a||r.custom_metadata?.tenant_id!==e)throw new X(404)}const s=await H(t).delete(`/custom_hostnames/${encodeURIComponent(n)}`).res();return s.ok&&await t.customDomainAdapter.remove(e,n),s.ok},update:async(e,n,s)=>{const{sslOverrides:r}=Qe(s.domain_metadata),a={};if(Object.keys(r).length>0){const i=await H(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json(),{result:o,success:c}=ie.parse(i);if(!c)throw new X(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 H(t).patch(a,`/custom_hostnames/${encodeURIComponent(n)}`).res();if(!i.ok)throw new X(503,{message:await i.text()})}return t.customDomainAdapter.update(e,n,s)}}}class an{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 n=await this.getCache(),s=this.createRequest(e),r=await n.match(s);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(n){return console.error(`CloudflareCache: get error for key ${e}:`,n),null}}async set(e,n,s){try{const r=await this.getCache(),a=s??this.config.defaultTtlSeconds,i=a!==void 0,o=i?Math.max(0,a):0,c={value:n,expiresAt:i?new Date(Date.now()+(o>0?o*1e3:-1)).toISOString():void 0,cachedAt:new Date().toISOString()},u=this.createRequest(e),p={"Content-Type":"application/json"};i&&o>0&&(p["Cache-Control"]=`max-age=${o}`);const k=new Response(JSON.stringify(c),{headers:p});await r.put(u,k)}catch(r){console.error(`CloudflareCache: set error for key ${e}:`,r)}}async delete(e){try{const n=await this.getCache(),s=this.createRequest(e);return await n.delete(s)}catch(n){return console.error(`CloudflareCache: delete error for key ${e}:`,n),!1}}async 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 on(t={}){const e={defaultTtlSeconds:300,keyPrefix:"authhero",...t};return new an(e)}let cn="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",dt=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=cn[n[t]&63];return e};async function We(t,e){const n=t.timeout||3e4,s=new AbortController,r=setTimeout(()=>s.abort(),n);try{const a=`https://api.sql.cloudflarestorage.com/api/v1/accounts/${t.accountId}/r2-sql/query/${t.warehouseName}`,i=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.authToken}`},body:JSON.stringify({query:e}),signal:s.signal});if(!i.ok)throw new Error(`R2 SQL query failed: ${i.status} ${i.statusText}`);const o=await i.json();if(!o.success&&o.errors)throw new Error(`R2 SQL error: ${o.errors.join(", ")}`);return o.data||o.result?.data||[]}finally{clearTimeout(r)}}function be(t){return`'${t.replace(/'/g,"''")}'`}function U(t){return`"${t.replace(/"/g,'""')}"`}function ut(t){const e=n=>{if(!n)return"";try{return JSON.parse(n)}catch{return n}};return{type:t.type,date:t.date,description:t.description,ip:t.ip,user_agent:t.user_agent,details:e(t.details),isMobile:!!t.isMobile,user_id:t.user_id,user_name:t.user_name,connection:t.connection,connection_id:t.connection_id,client_id:t.client_id,client_name:t.client_name,audience:t.audience,scope:t.scope,strategy:t.strategy,strategy_type:t.strategy_type,hostname:t.hostname,auth0_client:e(t.auth0_client),log_id:t.id,location_info:t.country_code||t.city_name||t.latitude||t.longitude||t.time_zone||t.continent_code?{country_code:t.country_code||"",city_name:t.city_name||"",latitude:t.latitude||"",longitude:t.longitude||"",time_zone:t.time_zone||"",continent_code:t.continent_code||""}:void 0}}function dn(t){return async(e,n)=>{const s=n.log_id||dt(),r={...n,log_id:s};return await un(t,e,r),r}}async function un(t,e,n){const s=a=>a?JSON.stringify(a):void 0,r={id:n.log_id,tenant_id:e,type:n.type,date:n.date,description:n.description?.substring(0,256),ip:n.ip,user_agent:n.user_agent,details:s(n.details)?.substring(0,8192),isMobile:n.isMobile?1:0,user_id:n.user_id,user_name:n.user_name,connection:n.connection,connection_id:n.connection_id,client_id:n.client_id,client_name:n.client_name,audience:n.audience,scope:n.scope,strategy:n.strategy,strategy_type:n.strategy_type,hostname:n.hostname,auth0_client:s(n.auth0_client),log_id:n.log_id,country_code:n.location_info?.country_code,city_name:n.location_info?.city_name,latitude:n.location_info?.latitude,longitude:n.location_info?.longitude,time_zone:n.location_info?.time_zone,continent_code:n.location_info?.continent_code};try{if(t.pipelineBinding)await t.pipelineBinding.send([r]);else if(t.pipelineEndpoint){const a=t.timeout||3e4,i=new AbortController,o=setTimeout(()=>i.abort(),a);try{const c=await fetch(t.pipelineEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([r]),signal:i.signal});if(!c.ok)throw new Error(`Pipeline ingestion failed: ${c.status} ${c.statusText}`)}finally{clearTimeout(o)}}else throw new Error("Either pipelineEndpoint or pipelineBinding must be configured")}catch(a){throw console.error("Failed to send log to Pipeline:",a),a}}function ln(t){return async(e,n)=>{const s=t.namespace||"default",r=t.tableName||"logs",a=`
2
2
  SELECT * FROM ${U(s)}.${U(r)}
3
3
  WHERE tenant_id = ${be(e)}
4
4
  AND id = ${be(n)}
5
5
  LIMIT 1
6
- `,i=await We(t,a);if(i.length===0)return null;const o=i[0];return o?ut(o):null}}function ln(t){const e={};return(t.match(/(\w+):(\S+)/g)||[]).forEach(s=>{const[r,a]=s.split(":");r&&a&&(e[r]=a)}),e}function hn(t){const e=[];for(const[n,s]of Object.entries(t)){const r=n.replace(/[^a-zA-Z0-9_]/g,"");r&&s&&e.push(`${U(r)} = ${be(s)}`)}return e}function fn(t){return async(e,n={})=>{const{page:s=0,per_page:r=50,include_totals:a=!1,sort:i,q:o}=n,c=t.namespace||"default",u=t.tableName||"logs",p=[`tenant_id = ${be(e)}`];if(o){const J=ln(o);p.push(...hn(J))}const k=p.join(" AND ");let C="ORDER BY date DESC";if(i&&i.sort_by){const J=i.sort_by.replace(/[^a-zA-Z0-9_]/g,""),re=i.sort_order==="asc"?"ASC":"DESC";C=`ORDER BY ${U(J)} ${re}`}const S=s*r,E=`LIMIT ${r} OFFSET ${S}`,F=`
6
+ `,i=await We(t,a);if(i.length===0)return null;const o=i[0];return o?ut(o):null}}function hn(t){const e={};return(t.match(/(\w+):(\S+)/g)||[]).forEach(s=>{const[r,a]=s.split(":");r&&a&&(e[r]=a)}),e}function fn(t){const e=[];for(const[n,s]of Object.entries(t)){const r=n.replace(/[^a-zA-Z0-9_]/g,"");r&&s&&e.push(`${U(r)} = ${be(s)}`)}return e}function pn(t){return async(e,n={})=>{const{page:s=0,per_page:r=50,include_totals:a=!1,sort:i,q:o}=n,c=t.namespace||"default",u=t.tableName||"logs",p=[`tenant_id = ${be(e)}`];if(o){const J=hn(o);p.push(...fn(J))}const k=p.join(" AND ");let C="ORDER BY date DESC";if(i&&i.sort_by){const J=i.sort_by.replace(/[^a-zA-Z0-9_]/g,""),re=i.sort_order==="asc"?"ASC":"DESC";C=`ORDER BY ${U(J)} ${re}`}const S=s*r,E=`LIMIT ${r} OFFSET ${S}`,F=`
7
7
  SELECT * FROM ${U(c)}.${U(u)}
8
8
  WHERE ${k}
9
9
  ${C}
@@ -11,13 +11,13 @@
11
11
  `,P=(await We(t,F)).map(ut);if(!a)return{logs:P,start:0,limit:0,length:0};const O=`
12
12
  SELECT COUNT(*) as count FROM ${U(c)}.${U(u)}
13
13
  WHERE ${k}
14
- `,W=(await We(t,O))[0]?.count||0;return{logs:P,start:S,limit:r,length:Number(W)}}}function pn(){return{async getDaily(){throw new Error("Stats queries are not supported by R2 SQL logs adapter. Use Analytics Engine or Kysely adapter instead.")},async getActiveUsers(){throw new Error("Stats queries are not supported by R2 SQL logs adapter. Use Analytics Engine or Kysely adapter instead.")}}}function lt(t){const e=!!t.pipelineEndpoint,n=!!t.pipelineBinding;if(!e&&!n)throw new Error('R2 SQL logs adapter requires one of: "pipelineEndpoint" or "pipelineBinding"');if(!t.authToken)throw new Error('R2 SQL logs adapter requires "authToken" configuration');if(!t.warehouseName)throw new Error('R2 SQL logs adapter requires "warehouseName" configuration');return{create:cn(t),list:fn(t),get:un(t)}}async function fe(t,e){const n=t.timeout||3e4,s=new AbortController,r=setTimeout(()=>s.abort(),n);try{const a=`https://api.cloudflare.com/client/v4/accounts/${t.accountId}/analytics_engine/sql`,i=await fetch(a,{method:"POST",headers:{"Content-Type":"text/plain",Authorization:`Bearer ${t.apiToken}`},body:e,signal:s.signal});if(!i.ok){const c=await i.text();throw new Error(`Analytics Engine query failed: ${i.status} ${i.statusText} - ${c}`)}const o=await i.json();if(!o.success&&o.errors&&o.errors.length>0)throw new Error(`Analytics Engine error: ${o.errors.map(c=>c.message).join(", ")}`);return o.data||[]}finally{clearTimeout(r)}}function I(t){return`'${t.replace(/'/g,"''").replace(/\\/g,"\\\\")}'`}function Je(t){return`"${t.replace(/"/g,'""')}"`}function ht(t){const e=r=>{if(r)try{return JSON.parse(r)}catch{return}},n=t.double2||t.timestamp,s=n?new Date(n).toISOString():"";return{log_id:t.blob1,type:t.blob3,date:s,description:t.blob4,ip:t.blob5,user_agent:t.blob6,user_id:t.blob7,user_name:t.blob8,connection:t.blob9,connection_id:t.blob10,client_id:t.blob11,client_name:t.blob12,audience:t.blob13,scope:t.blob14,strategy:t.blob15,strategy_type:t.blob16,hostname:t.blob17,details:e(t.blob18),auth0_client:e(t.blob19),location_info:e(t.blob20),isMobile:t.double1===1}}function mn(t){return async(e,n)=>{const s=n.log_id||dt(),r={...n,log_id:s};return yn(t,e,r),r}}function yn(t,e,n){if(!t.analyticsEngineBinding){console.error("Analytics Engine binding not configured");return}const s=a=>a==null?"":typeof a=="string"?a:JSON.stringify(a),r=(a,i=1024)=>a.substring(0,i);try{t.analyticsEngineBinding.writeDataPoint({blobs:[r(n.log_id),r(e),r(n.type||""),r(n.description||""),r(n.ip||""),r(n.user_agent||""),r(n.user_id||""),r(n.user_name||""),r(n.connection||""),r(n.connection_id||""),r(n.client_id||""),r(n.client_name||""),r(n.audience||""),r(n.scope||""),r(n.strategy||""),r(n.strategy_type||""),r(n.hostname||""),r(s(n.details)),r(s(n.auth0_client)),r(s(n.location_info))],doubles:[n.isMobile?1:0,new Date(n.date).getTime()],indexes:[e.substring(0,96)]})}catch(a){console.error("Failed to write log to Analytics Engine:",a)}}function _n(t){return async(e,n)=>{const s=t.dataset||"authhero_logs",r=`
14
+ `,W=(await We(t,O))[0]?.count||0;return{logs:P,start:S,limit:r,length:Number(W)}}}function mn(){return{async getDaily(){throw new Error("Stats queries are not supported by R2 SQL logs adapter. Use Analytics Engine or Kysely adapter instead.")},async getActiveUsers(){throw new Error("Stats queries are not supported by R2 SQL logs adapter. Use Analytics Engine or Kysely adapter instead.")}}}function lt(t){const e=!!t.pipelineEndpoint,n=!!t.pipelineBinding;if(!e&&!n)throw new Error('R2 SQL logs adapter requires one of: "pipelineEndpoint" or "pipelineBinding"');if(!t.authToken)throw new Error('R2 SQL logs adapter requires "authToken" configuration');if(!t.warehouseName)throw new Error('R2 SQL logs adapter requires "warehouseName" configuration');return{create:dn(t),list:pn(t),get:ln(t)}}async function fe(t,e){const n=t.timeout||3e4,s=new AbortController,r=setTimeout(()=>s.abort(),n);try{const a=`https://api.cloudflare.com/client/v4/accounts/${t.accountId}/analytics_engine/sql`,i=await fetch(a,{method:"POST",headers:{"Content-Type":"text/plain",Authorization:`Bearer ${t.apiToken}`},body:e,signal:s.signal});if(!i.ok){const c=await i.text();throw new Error(`Analytics Engine query failed: ${i.status} ${i.statusText} - ${c}`)}const o=await i.json();if(!o.success&&o.errors&&o.errors.length>0)throw new Error(`Analytics Engine error: ${o.errors.map(c=>c.message).join(", ")}`);return o.data||[]}finally{clearTimeout(r)}}function I(t){return`'${t.replace(/'/g,"''").replace(/\\/g,"\\\\")}'`}function Je(t){return`"${t.replace(/"/g,'""')}"`}function ht(t){const e=r=>{if(r)try{return JSON.parse(r)}catch{return}},n=t.double2||t.timestamp,s=n?new Date(n).toISOString():"";return{log_id:t.blob1,type:t.blob3,date:s,description:t.blob4,ip:t.blob5,user_agent:t.blob6,user_id:t.blob7,user_name:t.blob8,connection:t.blob9,connection_id:t.blob10,client_id:t.blob11,client_name:t.blob12,audience:t.blob13,scope:t.blob14,strategy:t.blob15,strategy_type:t.blob16,hostname:t.blob17,details:e(t.blob18),auth0_client:e(t.blob19),location_info:e(t.blob20),isMobile:t.double1===1}}function yn(t){return async(e,n)=>{const s=n.log_id||dt(),r={...n,log_id:s};return _n(t,e,r),r}}function _n(t,e,n){if(!t.analyticsEngineBinding){console.error("Analytics Engine binding not configured");return}const s=a=>a==null?"":typeof a=="string"?a:JSON.stringify(a),r=(a,i=1024)=>a.substring(0,i);try{t.analyticsEngineBinding.writeDataPoint({blobs:[r(n.log_id),r(e),r(n.type||""),r(n.description||""),r(n.ip||""),r(n.user_agent||""),r(n.user_id||""),r(n.user_name||""),r(n.connection||""),r(n.connection_id||""),r(n.client_id||""),r(n.client_name||""),r(n.audience||""),r(n.scope||""),r(n.strategy||""),r(n.strategy_type||""),r(n.hostname||""),r(s(n.details)),r(s(n.auth0_client)),r(s(n.location_info))],doubles:[n.isMobile?1:0,new Date(n.date).getTime()],indexes:[e.substring(0,96)]})}catch(a){console.error("Failed to write log to Analytics Engine:",a)}}function gn(t){return async(e,n)=>{const s=t.dataset||"authhero_logs",r=`
15
15
  SELECT *
16
16
  FROM ${Je(s)}
17
17
  WHERE index1 = ${I(e)}
18
18
  AND blob1 = ${I(n)}
19
19
  LIMIT 1
20
- `,a=await fe(t,r);return a.length===0||!a[0]?null:ht(a[0])}}function gn(t){const e={},n=/(\w+):(?:"([^"]*)"|(\S+))/g;let s;for(;(s=n.exec(t))!==null;){const r=s[1],a=s[2]!==void 0?s[2]:s[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 vn(t){const e=[];for(const[n,s]of Object.entries(t)){const r=s.filter(i=>i!=="");if(r.length===0)continue;if(n==="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(n);if(a)if(r.length===1)e.push(`${a} = ${I(r[0])}`);else{const i=r.map(o=>I(o)).join(", ");e.push(`${a} IN (${i})`)}}return e}function bn(t){if(t==="date")return"double2";const e=ft(t);return e||"timestamp"}function xn(t){return async(e,n={})=>{const{page:s=0,per_page:r=50,include_totals:a=!1,sort:i,q:o}=n,c=t.dataset||"authhero_logs",u=[`index1 = ${I(e)}`];if(o){const O=gn(o);u.push(...vn(O))}const p=u.join(" AND ");let k="ORDER BY timestamp DESC";if(i&&i.sort_by){const O=bn(i.sort_by),j=i.sort_order==="asc"?"ASC":"DESC";k=`ORDER BY ${O} ${j}`}const C=s*r,S=`LIMIT ${r} OFFSET ${C}`,E=`
20
+ `,a=await fe(t,r);return a.length===0||!a[0]?null:ht(a[0])}}function vn(t){const e={},n=/(\w+):(?:"([^"]*)"|(\S+))/g;let s;for(;(s=n.exec(t))!==null;){const r=s[1],a=s[2]!==void 0?s[2]:s[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 bn(t){const e=[];for(const[n,s]of Object.entries(t)){const r=s.filter(i=>i!=="");if(r.length===0)continue;if(n==="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(n);if(a)if(r.length===1)e.push(`${a} = ${I(r[0])}`);else{const i=r.map(o=>I(o)).join(", ");e.push(`${a} IN (${i})`)}}return e}function xn(t){if(t==="date")return"double2";const e=ft(t);return e||"timestamp"}function kn(t){return async(e,n={})=>{const{page:s=0,per_page:r=50,include_totals:a=!1,sort:i,q:o}=n,c=t.dataset||"authhero_logs",u=[`index1 = ${I(e)}`];if(o){const O=vn(o);u.push(...bn(O))}const p=u.join(" AND ");let k="ORDER BY timestamp DESC";if(i&&i.sort_by){const O=xn(i.sort_by),j=i.sort_order==="asc"?"ASC":"DESC";k=`ORDER BY ${O} ${j}`}const C=s*r,S=`LIMIT ${r} OFFSET ${C}`,E=`
21
21
  SELECT *
22
22
  FROM ${Je(c)}
23
23
  WHERE ${p}
@@ -27,7 +27,7 @@
27
27
  SELECT count() as count
28
28
  FROM ${Je(c)}
29
29
  WHERE ${p}
30
- `;try{const j=(await fe(t,P))[0]?.count||0;return{logs:x,start:C,limit:r,length:Number(j)}}catch{return{logs:x,start:C,limit:r,length:x.length}}}}const Ye=["s","seacft","seccft","sepft","sertft","ssa"],kn=["pwd_leak","signup_pwd_leak","reset_pwd_leak"];function Ke(t){return`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`}function Ge(t){return t.toISOString().split("T")[0]}function wn(t){const e=t.dataset||"authhero_logs";return{async getDaily(n,s={}){const{from:r,to:a}=s,i=new Date,o=new Date(i);o.setDate(o.getDate()-30);const c=r?Ke(r):Ge(o),u=a?Ke(a):Ge(i),p=new Date(`${c}T00:00:00Z`).getTime(),k=new Date(`${u}T23:59:59.999Z`).getTime(),C=Ye.map(x=>I(x)).join(", "),S=kn.map(x=>I(x)).join(", "),E=`
30
+ `;try{const j=(await fe(t,P))[0]?.count||0;return{logs:x,start:C,limit:r,length:Number(j)}}catch{return{logs:x,start:C,limit:r,length:x.length}}}}const Ye=["s","seacft","seccft","sepft","sertft","ssa"],wn=["pwd_leak","signup_pwd_leak","reset_pwd_leak"];function Ke(t){return`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`}function Ge(t){return t.toISOString().split("T")[0]}function Sn(t){const e=t.dataset||"authhero_logs";return{async getDaily(n,s={}){const{from:r,to:a}=s,i=new Date,o=new Date(i);o.setDate(o.getDate()-30);const c=r?Ke(r):Ge(o),u=a?Ke(a):Ge(i),p=new Date(`${c}T00:00:00Z`).getTime(),k=new Date(`${u}T23:59:59.999Z`).getTime(),C=Ye.map(x=>I(x)).join(", "),S=wn.map(x=>I(x)).join(", "),E=`
31
31
  SELECT
32
32
  toDate(toDateTime(double2 / 1000)) AS date,
33
33
  SUM(CASE WHEN blob3 IN (${C}) THEN 1 ELSE 0 END) AS logins,
@@ -49,7 +49,7 @@
49
49
  AND blob3 IN (${a})
50
50
  AND blob7 IS NOT NULL
51
51
  AND blob7 != ''
52
- `,c=(await fe(t,i))[0];return c&&c.count!==void 0&&Number(c.count)||0}}}function pt(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:mn(t),list:xn(t),get:_n(t)}}function Sn(){return{async getGeoInfo(t){try{const e=t["cf-ipcountry"],n=t["cf-ipcity"],s=t["cf-iplatitude"],r=t["cf-iplongitude"],a=t["cf-timezone"],i=t["cf-ipcontinent"];return e?{country_code:e,city_name:n||"",latitude:s||"",longitude:r||"",time_zone:a||"",continent_code:i||""}:null}catch(e){return console.warn("Failed to get geo info from Cloudflare headers:",e),null}}}}function mt(t){return`// Auto-generated AuthHero code hook worker
52
+ `,c=(await fe(t,i))[0];return c&&c.count!==void 0&&Number(c.count)||0}}}function pt(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:yn(t),list:kn(t),get:gn(t)}}function Cn(){return{async getGeoInfo(t){try{const e=t["cf-ipcountry"],n=t["cf-ipcity"],s=t["cf-iplatitude"],r=t["cf-iplongitude"],a=t["cf-timezone"],i=t["cf-ipcontinent"];return e?{country_code:e,city_name:n||"",latitude:s||"",longitude:r||"",time_zone:a||"",continent_code:i||""}:null}catch(e){return console.warn("Failed to get geo info from Cloudflare headers:",e),null}}}}class Tn{constructor(e){this.bindings=e}bindings;async consume(e,n){const s=this.bindings[e];if(!s)return{allowed:!0};try{const{success:r}=await s.limit({key:n});return{allowed:r}}catch(r){return console.error(`CloudflareRateLimit: limit() error for scope ${e}:`,r),{allowed:!0}}}}function mt(t){if(!(!t||!Object.keys(t).some(n=>t[n])))return new Tn(t)}function yt(t){return`// Auto-generated AuthHero code hook worker
53
53
 
54
54
  const fnNames = {
55
55
  "post-user-login": "onExecutePostLogin",
@@ -152,4 +152,4 @@ export default {
152
152
  }
153
153
  },
154
154
  };
155
- `}class Cn{config;constructor(e){this.config=e}async execute(e){const n=Date.now();if(!e.hookCodeId)return{success:!1,error:"CloudflareCodeExecutor requires hookCodeId",durationMs:Date.now()-n,apiCalls:[]};const s=`hook-${e.hookCodeId}`,r=JSON.stringify({triggerId:e.triggerId,event:e.event});try{let a;if(this.config.dispatcher)a=await this.config.dispatcher.get(s,{},{limits:{cpuMs:e.cpuLimitMs??5e3}}).fetch(new Request("https://hook.internal/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:r}));else if(this.config.dispatchUrl)a=await fetch(`${this.config.dispatchUrl}/${s}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiToken}`},body:r});else return{success:!1,error:"No dispatcher binding or dispatchUrl configured",durationMs:Date.now()-n,apiCalls:[]};if(!a.ok){const o=await a.text();return{success:!1,error:`Worker invocation failed (${a.status}): ${o}`,durationMs:Date.now()-n,apiCalls:[]}}return{...await a.json(),durationMs:Date.now()-n}}catch(a){return{success:!1,error:a instanceof Error?a.message:String(a),durationMs:Date.now()-n,apiCalls:[]}}}async deploy(e,n){const s=`hook-${e}`,r=mt(n),a=`https://api.cloudflare.com/client/v4/accounts/${this.config.accountId}/workers/dispatch/namespaces/${this.config.dispatchNamespace}/scripts/${s}`,i=JSON.stringify({main_module:"index.js",compatibility_date:this.config.compatibilityDate??"2024-11-20"}),o=new FormData;o.append("metadata",new Blob([i],{type:"application/json"})),o.append("index.js",new Blob([r],{type:"application/javascript+module"}),"index.js");const c=await fetch(a,{method:"PUT",headers:{Authorization:`Bearer ${this.config.apiToken}`},body:o});if(!c.ok){const u=await c.text();throw new Error(`Failed to deploy hook worker ${s}: ${c.status} ${u}`)}}async remove(e){const n=`hook-${e}`,s=`https://api.cloudflare.com/client/v4/accounts/${this.config.accountId}/workers/dispatch/namespaces/${this.config.dispatchNamespace}/scripts/${n}`,r=await fetch(s,{method:"DELETE",headers:{Authorization:`Bearer ${this.config.apiToken}`}});if(!r.ok&&r.status!==404){const a=await r.text();throw new Error(`Failed to remove hook worker ${n}: ${r.status} ${a}`)}}}function Tn(t){const e={customDomains:sn(t),cache:an({...t.cacheName&&{cacheName:t.cacheName},...t.defaultTtlSeconds!==void 0&&{defaultTtlSeconds:t.defaultTtlSeconds},...t.keyPrefix&&{keyPrefix:t.keyPrefix}}),geo:Sn()};return t.r2SqlLogs?e.logs=lt(t.r2SqlLogs):t.analyticsEngineLogs&&(e.logs=pt(t.analyticsEngineLogs)),e}exports.CloudflareCodeExecutor=Cn;exports.createAnalyticsEngineLogsAdapter=pt;exports.createAnalyticsEngineStatsAdapter=wn;exports.createR2SQLLogsAdapter=lt;exports.createR2SQLStatsAdapter=pn;exports.default=Tn;exports.generateWorkerScript=mt;
155
+ `}class En{config;constructor(e){this.config=e}async execute(e){const n=Date.now();if(!e.hookCodeId)return{success:!1,error:"CloudflareCodeExecutor requires hookCodeId",durationMs:Date.now()-n,apiCalls:[]};const s=`hook-${e.hookCodeId}`,r=JSON.stringify({triggerId:e.triggerId,event:e.event});try{let a;if(this.config.dispatcher)a=await this.config.dispatcher.get(s,{},{limits:{cpuMs:e.cpuLimitMs??5e3}}).fetch(new Request("https://hook.internal/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:r}));else if(this.config.dispatchUrl)a=await fetch(`${this.config.dispatchUrl}/${s}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiToken}`},body:r});else return{success:!1,error:"No dispatcher binding or dispatchUrl configured",durationMs:Date.now()-n,apiCalls:[]};if(!a.ok){const o=await a.text();return{success:!1,error:`Worker invocation failed (${a.status}): ${o}`,durationMs:Date.now()-n,apiCalls:[]}}return{...await a.json(),durationMs:Date.now()-n}}catch(a){return{success:!1,error:a instanceof Error?a.message:String(a),durationMs:Date.now()-n,apiCalls:[]}}}async deploy(e,n){const s=`hook-${e}`,r=yt(n),a=`https://api.cloudflare.com/client/v4/accounts/${this.config.accountId}/workers/dispatch/namespaces/${this.config.dispatchNamespace}/scripts/${s}`,i=JSON.stringify({main_module:"index.js",compatibility_date:this.config.compatibilityDate??"2024-11-20"}),o=new FormData;o.append("metadata",new Blob([i],{type:"application/json"})),o.append("index.js",new Blob([r],{type:"application/javascript+module"}),"index.js");const c=await fetch(a,{method:"PUT",headers:{Authorization:`Bearer ${this.config.apiToken}`},body:o});if(!c.ok){const u=await c.text();throw new Error(`Failed to deploy hook worker ${s}: ${c.status} ${u}`)}}async remove(e){const n=`hook-${e}`,s=`https://api.cloudflare.com/client/v4/accounts/${this.config.accountId}/workers/dispatch/namespaces/${this.config.dispatchNamespace}/scripts/${n}`,r=await fetch(s,{method:"DELETE",headers:{Authorization:`Bearer ${this.config.apiToken}`}});if(!r.ok&&r.status!==404){const a=await r.text();throw new Error(`Failed to remove hook worker ${n}: ${r.status} ${a}`)}}}function On(t){const e={customDomains:rn(t),cache:on({...t.cacheName&&{cacheName:t.cacheName},...t.defaultTtlSeconds!==void 0&&{defaultTtlSeconds:t.defaultTtlSeconds},...t.keyPrefix&&{keyPrefix:t.keyPrefix}}),geo:Cn()};t.r2SqlLogs?e.logs=lt(t.r2SqlLogs):t.analyticsEngineLogs&&(e.logs=pt(t.analyticsEngineLogs));const n=mt(t.rateLimitBindings);return n&&(e.rateLimit=n),e}exports.CloudflareCodeExecutor=En;exports.createAnalyticsEngineLogsAdapter=pt;exports.createAnalyticsEngineStatsAdapter=Sn;exports.createCloudflareRateLimitAdapter=mt;exports.createR2SQLLogsAdapter=lt;exports.createR2SQLStatsAdapter=mn;exports.default=On;exports.generateWorkerScript=yt;
@@ -310,7 +310,7 @@ export interface ListParams {
310
310
  take?: number;
311
311
  }
312
312
  declare const logInsertSchema: z.ZodObject<{
313
- 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" | "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>;
313
+ 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" | "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>;
314
314
  date: z.ZodString;
315
315
  description: z.ZodOptional<z.ZodString>;
316
316
  ip: z.ZodOptional<z.ZodString>;
@@ -375,7 +375,7 @@ declare const logInsertSchema: z.ZodObject<{
375
375
  continent_code: string;
376
376
  }>>;
377
377
  }, "strip", z.ZodTypeAny, {
378
- 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" | "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";
378
+ 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" | "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";
379
379
  date: string;
380
380
  isMobile: boolean;
381
381
  description?: string | undefined;
@@ -448,7 +448,7 @@ declare const logInsertSchema: z.ZodObject<{
448
448
  export type LogInsert = z.infer<typeof logInsertSchema>;
449
449
  declare const logSchema: z.ZodObject<{
450
450
  log_id: z.ZodString;
451
- 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" | "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>;
451
+ 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" | "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>;
452
452
  date: z.ZodString;
453
453
  description: z.ZodOptional<z.ZodString>;
454
454
  ip: z.ZodOptional<z.ZodString>;
@@ -512,7 +512,7 @@ declare const logSchema: z.ZodObject<{
512
512
  continent_code: string;
513
513
  }>>;
514
514
  }, "strip", z.ZodTypeAny, {
515
- 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" | "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";
515
+ 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" | "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";
516
516
  date: string;
517
517
  isMobile: boolean;
518
518
  log_id: string;
@@ -683,6 +683,37 @@ export interface StatsAdapter {
683
683
  */
684
684
  getActiveUsers(tenantId: string): Promise<number>;
685
685
  }
686
+ /**
687
+ * Logical buckets that consumers can rate-limit against. Backends decide
688
+ * how each scope is enforced (e.g. mapping to a separate Cloudflare Workers
689
+ * Rate Limiter binding with its own deploy-time limit/period).
690
+ */
691
+ export type RateLimitScope = "pre-login" | "pre-user-registration" | "brute-force";
692
+ export interface RateLimitDecision {
693
+ /** True if the request is allowed; false if the limit was exceeded. */
694
+ allowed: boolean;
695
+ /** Optional retry-after hint in seconds (omitted if the backend can't tell). */
696
+ retryAfterSeconds?: number;
697
+ }
698
+ export interface RateLimitAdapter {
699
+ /**
700
+ * Consume one unit of quota for the given scope and key.
701
+ *
702
+ * The numeric threshold and window are backend-specific; the
703
+ * Cloudflare Workers Rate Limiter binding bakes them in at deploy
704
+ * time and cannot honor a per-tenant override. Callers that need
705
+ * per-tenant `max_attempts` should layer their own counter on top.
706
+ *
707
+ * Returns `{ allowed: true }` if the scope is not configured, so
708
+ * callers can opt in by configuring backends without changing call
709
+ * sites.
710
+ */
711
+ consume(scope: RateLimitScope, key: string): Promise<RateLimitDecision>;
712
+ }
713
+ export interface CodeExecutionLog {
714
+ level: "log" | "info" | "warn" | "error" | "debug";
715
+ message: string;
716
+ }
686
717
  export interface CodeExecutionResult {
687
718
  success: boolean;
688
719
  error?: string;
@@ -691,6 +722,12 @@ export interface CodeExecutionResult {
691
722
  method: string;
692
723
  args: unknown[];
693
724
  }>;
725
+ /**
726
+ * Console output captured from the user code during execution. Populated by
727
+ * executors that shadow `console.*` inside the sandbox; absent on executors
728
+ * that don't support capture.
729
+ */
730
+ logs?: CodeExecutionLog[];
694
731
  }
695
732
  export interface CodeExecutor {
696
733
  execute(params: {
@@ -918,6 +955,35 @@ export declare function createAnalyticsEngineStatsAdapter(config: AnalyticsEngin
918
955
  * ```
919
956
  */
920
957
  export declare function createAnalyticsEngineLogsAdapter(config: AnalyticsEngineLogsAdapterConfig): LogsDataAdapter;
958
+ /**
959
+ * Minimal shape of the Cloudflare Workers Rate Limiter binding. We declare
960
+ * it locally rather than depending on `@cloudflare/workers-types` so the
961
+ * adapter package stays runtime-agnostic.
962
+ *
963
+ * Reference: https://developers.cloudflare.com/workers/runtime-apis/bindings/rate-limit/
964
+ */
965
+ export interface CloudflareRateLimitBinding {
966
+ limit(options: {
967
+ key: string;
968
+ }): Promise<{
969
+ success: boolean;
970
+ }>;
971
+ }
972
+ /**
973
+ * Map of scopes to Cloudflare Workers Rate Limiter bindings. Each binding's
974
+ * `limit` and `period` are configured at deploy time in `wrangler.toml` and
975
+ * cannot be overridden per request.
976
+ *
977
+ * Workers Rate Limiter only supports `period: 10` or `period: 60` seconds —
978
+ * it is a short-window burst guard, not a daily cap. For Auth0-style
979
+ * thresholds (e.g. 100 attempts / day) see `FUTURE: Durable Object backend`
980
+ * below.
981
+ *
982
+ * Any scope omitted from this map results in a permissive ("allowed: true")
983
+ * decision so callers can configure backends incrementally.
984
+ */
985
+ export type CloudflareRateLimitBindings = Partial<Record<RateLimitScope, CloudflareRateLimitBinding>>;
986
+ export declare function createCloudflareRateLimitAdapter(bindings: CloudflareRateLimitBindings | undefined): RateLimitAdapter | undefined;
921
987
  export interface CloudflareConfig {
922
988
  zoneId: string;
923
989
  authKey: string;
@@ -946,6 +1012,13 @@ export interface CloudflareConfig {
946
1012
  * Use this for low-latency log writes with Cloudflare Analytics Engine
947
1013
  */
948
1014
  analyticsEngineLogs?: AnalyticsEngineLogsAdapterConfig;
1015
+ /**
1016
+ * Cloudflare Workers Rate Limiter bindings, keyed by logical scope.
1017
+ * Each binding's `limit` and `period` are baked in at deploy time; this
1018
+ * adapter can't override them per tenant. Bindings are optional — any
1019
+ * unconfigured scope is treated as permissive.
1020
+ */
1021
+ rateLimitBindings?: CloudflareRateLimitBindings;
949
1022
  }
950
1023
  /**
951
1024
  * Cloudflare Workers for Platforms dispatch namespace binding type.
@@ -1053,6 +1126,7 @@ export interface CloudflareAdapters {
1053
1126
  cache: CacheAdapter;
1054
1127
  logs?: LogsDataAdapter;
1055
1128
  geo?: GeoAdapter;
1129
+ rateLimit?: RateLimitAdapter;
1056
1130
  }
1057
1131
  declare function createAdapters(config: CloudflareConfig): CloudflareAdapters;
1058
1132
 
@@ -398,7 +398,7 @@ class T {
398
398
  }
399
399
  const y = Object.freeze({
400
400
  status: "aborted"
401
- }), te = (t) => ({ status: "dirty", value: t }), A = (t) => ({ status: "valid", value: t }), Re = (t) => t.status === "aborted", je = (t) => t.status === "dirty", Q = (t) => t.status === "valid", oe = (t) => typeof Promise < "u" && t instanceof Promise;
401
+ }), te = (t) => ({ status: "dirty", value: t }), N = (t) => ({ status: "valid", value: t }), Re = (t) => t.status === "aborted", je = (t) => t.status === "dirty", Q = (t) => t.status === "valid", oe = (t) => typeof Promise < "u" && t instanceof Promise;
402
402
  var f;
403
403
  (function(t) {
404
404
  t.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, t.toString = (e) => typeof e == "string" ? e : e?.message;
@@ -582,7 +582,7 @@ class v {
582
582
  };
583
583
  }
584
584
  optional() {
585
- return V.create(this, this._def);
585
+ return B.create(this, this._def);
586
586
  }
587
587
  nullable() {
588
588
  return G.create(this, this._def);
@@ -656,8 +656,8 @@ class v {
656
656
  }
657
657
  }
658
658
  const vt = /^c[^\s-]{8,}$/i, bt = /^[0-9a-z]+$/, xt = /^[0-9A-HJKMNP-TV-Z]{26}$/i, kt = /^[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, wt = /^[a-z0-9_-]{21}$/i, St = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, Ct = /^[-+]?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)?)??$/, Tt = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, Et = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
659
- let Ne;
660
- const Ot = /^(?:(?: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])$/, Nt = /^(?:(?: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])$/, At = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, $t = /^(([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])$/, Rt = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, jt = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, 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])))", It = new RegExp(`^${tt}$`);
659
+ let Ae;
660
+ const Ot = /^(?:(?: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])$/, At = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, Nt = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, $t = /^(([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])$/, Rt = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, jt = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, 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])))", It = new RegExp(`^${tt}$`);
661
661
  function nt(t) {
662
662
  let e = "[0-5]\\d";
663
663
  t.precision ? e = `${e}\\.\\d{${t.precision}}` : t.precision == null && (e = `${e}(\\.\\d+)?`);
@@ -673,7 +673,7 @@ function st(t) {
673
673
  return n.push(t.local ? "Z?" : "Z"), t.offset && n.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${n.join("|")})`, new RegExp(`^${e}$`);
674
674
  }
675
675
  function Dt(t, e) {
676
- return !!((e === "v4" || !e) && Ot.test(t) || (e === "v6" || !e) && At.test(t));
676
+ return !!((e === "v4" || !e) && Ot.test(t) || (e === "v6" || !e) && Nt.test(t));
677
677
  }
678
678
  function Lt(t, e) {
679
679
  if (!St.test(t))
@@ -689,7 +689,7 @@ function Lt(t, e) {
689
689
  }
690
690
  }
691
691
  function Pt(t, e) {
692
- return !!((e === "v4" || !e) && Nt.test(t) || (e === "v6" || !e) && $t.test(t));
692
+ return !!((e === "v4" || !e) && At.test(t) || (e === "v6" || !e) && $t.test(t));
693
693
  }
694
694
  class Z extends v {
695
695
  _parse(e) {
@@ -746,7 +746,7 @@ class Z extends v {
746
746
  message: a.message
747
747
  }), s.dirty());
748
748
  else if (a.kind === "emoji")
749
- Ne || (Ne = new RegExp(Et, "u")), Ne.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
749
+ Ae || (Ae = new RegExp(Et, "u")), Ae.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
750
750
  validation: "emoji",
751
751
  code: d.invalid_string,
752
752
  message: a.message
@@ -1393,7 +1393,7 @@ class me extends v {
1393
1393
  received: s.parsedType
1394
1394
  }), y;
1395
1395
  }
1396
- return A(e.data);
1396
+ return N(e.data);
1397
1397
  }
1398
1398
  }
1399
1399
  me.create = (t) => new me({
@@ -1489,7 +1489,7 @@ class Ie extends v {
1489
1489
  received: s.parsedType
1490
1490
  }), y;
1491
1491
  }
1492
- return A(e.data);
1492
+ return N(e.data);
1493
1493
  }
1494
1494
  }
1495
1495
  Ie.create = (t) => new Ie({
@@ -1506,7 +1506,7 @@ class Ze extends v {
1506
1506
  received: s.parsedType
1507
1507
  }), y;
1508
1508
  }
1509
- return A(e.data);
1509
+ return N(e.data);
1510
1510
  }
1511
1511
  }
1512
1512
  Ze.create = (t) => new Ze({
@@ -1523,7 +1523,7 @@ class De extends v {
1523
1523
  received: s.parsedType
1524
1524
  }), y;
1525
1525
  }
1526
- return A(e.data);
1526
+ return N(e.data);
1527
1527
  }
1528
1528
  }
1529
1529
  De.create = (t) => new De({
@@ -1535,7 +1535,7 @@ class Le extends v {
1535
1535
  super(...arguments), this._any = !0;
1536
1536
  }
1537
1537
  _parse(e) {
1538
- return A(e.data);
1538
+ return N(e.data);
1539
1539
  }
1540
1540
  }
1541
1541
  Le.create = (t) => new Le({
@@ -1547,14 +1547,14 @@ class Pe extends v {
1547
1547
  super(...arguments), this._unknown = !0;
1548
1548
  }
1549
1549
  _parse(e) {
1550
- return A(e.data);
1550
+ return N(e.data);
1551
1551
  }
1552
1552
  }
1553
1553
  Pe.create = (t) => new Pe({
1554
1554
  typeName: m.ZodUnknown,
1555
1555
  ...g(t)
1556
1556
  });
1557
- class B extends v {
1557
+ class V extends v {
1558
1558
  _parse(e) {
1559
1559
  const n = this._getOrReturnCtx(e);
1560
1560
  return l(n, {
@@ -1564,7 +1564,7 @@ class B extends v {
1564
1564
  }), y;
1565
1565
  }
1566
1566
  }
1567
- B.create = (t) => new B({
1567
+ V.create = (t) => new V({
1568
1568
  typeName: m.ZodNever,
1569
1569
  ...g(t)
1570
1570
  });
@@ -1578,7 +1578,7 @@ class Me extends v {
1578
1578
  received: s.parsedType
1579
1579
  }), y;
1580
1580
  }
1581
- return A(e.data);
1581
+ return N(e.data);
1582
1582
  }
1583
1583
  }
1584
1584
  Me.create = (t) => new Me({
@@ -1663,7 +1663,7 @@ function ee(t) {
1663
1663
  const e = {};
1664
1664
  for (const n in t.shape) {
1665
1665
  const s = t.shape[n];
1666
- e[n] = V.create(ee(s));
1666
+ e[n] = B.create(ee(s));
1667
1667
  }
1668
1668
  return new w({
1669
1669
  ...t._def,
@@ -1672,7 +1672,7 @@ function ee(t) {
1672
1672
  } else return t instanceof $ ? new $({
1673
1673
  ...t._def,
1674
1674
  type: ee(t.element)
1675
- }) : t instanceof V ? V.create(ee(t.unwrap())) : t instanceof G ? G.create(ee(t.unwrap())) : t instanceof z ? z.create(t.items.map((e) => ee(e))) : t;
1675
+ }) : t instanceof B ? B.create(ee(t.unwrap())) : t instanceof G ? G.create(ee(t.unwrap())) : t instanceof z ? z.create(t.items.map((e) => ee(e))) : t;
1676
1676
  }
1677
1677
  class w extends v {
1678
1678
  constructor() {
@@ -1694,7 +1694,7 @@ class w extends v {
1694
1694
  }), y;
1695
1695
  }
1696
1696
  const { status: s, ctx: r } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
1697
- if (!(this._def.catchall instanceof B && this._def.unknownKeys === "strip"))
1697
+ if (!(this._def.catchall instanceof V && this._def.unknownKeys === "strip"))
1698
1698
  for (const u in r.data)
1699
1699
  i.includes(u) || o.push(u);
1700
1700
  const c = [];
@@ -1706,7 +1706,7 @@ class w extends v {
1706
1706
  alwaysSet: u in r.data
1707
1707
  });
1708
1708
  }
1709
- if (this._def.catchall instanceof B) {
1709
+ if (this._def.catchall instanceof V) {
1710
1710
  const u = this._def.unknownKeys;
1711
1711
  if (u === "passthrough")
1712
1712
  for (const p of o)
@@ -1927,7 +1927,7 @@ class w extends v {
1927
1927
  n[s] = this.shape[s];
1928
1928
  else {
1929
1929
  let a = this.shape[s];
1930
- for (; a instanceof V; )
1930
+ for (; a instanceof B; )
1931
1931
  a = a._def.innerType;
1932
1932
  n[s] = a;
1933
1933
  }
@@ -1943,21 +1943,21 @@ class w extends v {
1943
1943
  w.create = (t, e) => new w({
1944
1944
  shape: () => t,
1945
1945
  unknownKeys: "strip",
1946
- catchall: B.create(),
1946
+ catchall: V.create(),
1947
1947
  typeName: m.ZodObject,
1948
1948
  ...g(e)
1949
1949
  });
1950
1950
  w.strictCreate = (t, e) => new w({
1951
1951
  shape: () => t,
1952
1952
  unknownKeys: "strict",
1953
- catchall: B.create(),
1953
+ catchall: V.create(),
1954
1954
  typeName: m.ZodObject,
1955
1955
  ...g(e)
1956
1956
  });
1957
1957
  w.lazycreate = (t, e) => new w({
1958
1958
  shape: t,
1959
1959
  unknownKeys: "strip",
1960
- catchall: B.create(),
1960
+ catchall: V.create(),
1961
1961
  typeName: m.ZodObject,
1962
1962
  ...g(e)
1963
1963
  });
@@ -2034,14 +2034,14 @@ de.create = (t, e) => new de({
2034
2034
  typeName: m.ZodUnion,
2035
2035
  ...g(e)
2036
2036
  });
2037
- function Ve(t, e) {
2037
+ function Be(t, e) {
2038
2038
  const n = M(t), s = M(e);
2039
2039
  if (t === e)
2040
2040
  return { valid: !0, data: t };
2041
2041
  if (n === h.object && s === h.object) {
2042
2042
  const r = b.objectKeys(e), a = b.objectKeys(t).filter((o) => r.indexOf(o) !== -1), i = { ...t, ...e };
2043
2043
  for (const o of a) {
2044
- const c = Ve(t[o], e[o]);
2044
+ const c = Be(t[o], e[o]);
2045
2045
  if (!c.valid)
2046
2046
  return { valid: !1 };
2047
2047
  i[o] = c.data;
@@ -2052,7 +2052,7 @@ function Ve(t, e) {
2052
2052
  return { valid: !1 };
2053
2053
  const r = [];
2054
2054
  for (let a = 0; a < t.length; a++) {
2055
- const i = t[a], o = e[a], c = Ve(i, o);
2055
+ const i = t[a], o = e[a], c = Be(i, o);
2056
2056
  if (!c.valid)
2057
2057
  return { valid: !1 };
2058
2058
  r.push(c.data);
@@ -2065,7 +2065,7 @@ class ue extends v {
2065
2065
  const { status: n, ctx: s } = this._processInputParams(e), r = (a, i) => {
2066
2066
  if (Re(a) || Re(i))
2067
2067
  return y;
2068
- const o = Ve(a.value, i.value);
2068
+ const o = Be(a.value, i.value);
2069
2069
  return o.valid ? ((je(a) || je(i)) && n.dirty(), { status: n.value, value: o.data }) : (l(s, {
2070
2070
  code: d.invalid_intersection_types
2071
2071
  }), y);
@@ -2189,7 +2189,7 @@ class le extends v {
2189
2189
  });
2190
2190
  }
2191
2191
  }
2192
- class Be extends v {
2192
+ class Ve extends v {
2193
2193
  get keySchema() {
2194
2194
  return this._def.keyType;
2195
2195
  }
@@ -2231,7 +2231,7 @@ class Be extends v {
2231
2231
  }
2232
2232
  }
2233
2233
  }
2234
- Be.create = (t, e, n) => new Be({
2234
+ Ve.create = (t, e, n) => new Ve({
2235
2235
  valueType: e,
2236
2236
  keyType: t,
2237
2237
  typeName: m.ZodMap,
@@ -2361,7 +2361,7 @@ class K extends v {
2361
2361
  options: s
2362
2362
  }), y;
2363
2363
  }
2364
- return A(e.data);
2364
+ return N(e.data);
2365
2365
  }
2366
2366
  get options() {
2367
2367
  return this._def.values;
@@ -2417,7 +2417,7 @@ class Fe extends v {
2417
2417
  options: r
2418
2418
  }), y;
2419
2419
  }
2420
- return A(e.data);
2420
+ return N(e.data);
2421
2421
  }
2422
2422
  get enum() {
2423
2423
  return this._def.values;
@@ -2441,7 +2441,7 @@ class he extends v {
2441
2441
  received: n.parsedType
2442
2442
  }), y;
2443
2443
  const s = n.parsedType === h.promise ? n.data : Promise.resolve(n.data);
2444
- return A(s.then((r) => this._def.type.parseAsync(r, {
2444
+ return N(s.then((r) => this._def.type.parseAsync(r, {
2445
2445
  path: n.path,
2446
2446
  errorMap: n.common.contextualErrorMap
2447
2447
  })));
@@ -2544,22 +2544,22 @@ F.createWithPreprocess = (t, e, n) => new F({
2544
2544
  typeName: m.ZodEffects,
2545
2545
  ...g(n)
2546
2546
  });
2547
- class V extends v {
2547
+ class B extends v {
2548
2548
  _parse(e) {
2549
- return this._getType(e) === h.undefined ? A(void 0) : this._def.innerType._parse(e);
2549
+ return this._getType(e) === h.undefined ? N(void 0) : this._def.innerType._parse(e);
2550
2550
  }
2551
2551
  unwrap() {
2552
2552
  return this._def.innerType;
2553
2553
  }
2554
2554
  }
2555
- V.create = (t, e) => new V({
2555
+ B.create = (t, e) => new B({
2556
2556
  innerType: t,
2557
2557
  typeName: m.ZodOptional,
2558
2558
  ...g(e)
2559
2559
  });
2560
2560
  class G extends v {
2561
2561
  _parse(e) {
2562
- return this._getType(e) === h.null ? A(null) : this._def.innerType._parse(e);
2562
+ return this._getType(e) === h.null ? N(null) : this._def.innerType._parse(e);
2563
2563
  }
2564
2564
  unwrap() {
2565
2565
  return this._def.innerType;
@@ -2722,21 +2722,21 @@ var m;
2722
2722
  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";
2723
2723
  })(m || (m = {}));
2724
2724
  const _ = Z.create, it = Y.create, ke = me.create;
2725
- B.create;
2726
- const N = $.create, R = w.create;
2725
+ V.create;
2726
+ const A = $.create, R = w.create;
2727
2727
  de.create;
2728
2728
  ue.create;
2729
2729
  z.create;
2730
2730
  const ot = le.create;
2731
2731
  K.create;
2732
2732
  he.create;
2733
- V.create;
2733
+ B.create;
2734
2734
  G.create;
2735
- const Vt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2735
+ const Bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2736
2736
  __proto__: null,
2737
2737
  DIRTY: te,
2738
2738
  INVALID: y,
2739
- OK: A,
2739
+ OK: N,
2740
2740
  ParseStatus: T,
2741
2741
  Schema: v,
2742
2742
  ZodAny: Le,
@@ -2757,15 +2757,15 @@ const Vt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2757
2757
  ZodIssueCode: d,
2758
2758
  ZodLazy: Ue,
2759
2759
  ZodLiteral: ze,
2760
- ZodMap: Be,
2760
+ ZodMap: Ve,
2761
2761
  ZodNaN: qe,
2762
2762
  ZodNativeEnum: Fe,
2763
- ZodNever: B,
2763
+ ZodNever: V,
2764
2764
  ZodNull: De,
2765
2765
  ZodNullable: G,
2766
2766
  ZodNumber: Y,
2767
2767
  ZodObject: w,
2768
- ZodOptional: V,
2768
+ ZodOptional: B,
2769
2769
  ZodParsedType: h,
2770
2770
  ZodPipeline: xe,
2771
2771
  ZodPromise: he,
@@ -2783,7 +2783,7 @@ const Vt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2783
2783
  ZodUnknown: Pe,
2784
2784
  ZodVoid: Me,
2785
2785
  addIssueToContext: l,
2786
- array: N,
2786
+ array: A,
2787
2787
  boolean: ke,
2788
2788
  datetimeRegex: st,
2789
2789
  defaultErrorMap: pe,
@@ -2805,8 +2805,8 @@ const Vt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2805
2805
  return b;
2806
2806
  }
2807
2807
  }, Symbol.toStringTag, { value: "Module" }));
2808
- _t(Vt);
2809
- const Bt = (t, e) => e.skipDedupe || e.method !== "GET", Ut = (t, e) => e.method + "@" + t, zt = (t) => t.clone(), Ft = ({ skip: t = Bt, key: e = Ut, resolver: n = zt } = {}) => {
2808
+ _t(Bt);
2809
+ const Vt = (t, e) => e.skipDedupe || e.method !== "GET", Ut = (t, e) => e.method + "@" + t, zt = (t) => t.clone(), Ft = ({ skip: t = Vt, key: e = Ut, resolver: n = zt } = {}) => {
2810
2810
  const s = /* @__PURE__ */ new Map();
2811
2811
  return (r) => (a, i) => {
2812
2812
  if (t(a, i))
@@ -2860,13 +2860,13 @@ const Bt = (t, e) => e.skipDedupe || e.method !== "GET", Ut = (t, e) => e.method
2860
2860
  }), Ht = R({
2861
2861
  message: _()
2862
2862
  }), Qt = R({
2863
- emails: N(_()).optional(),
2863
+ emails: A(_()).optional(),
2864
2864
  http_body: _().optional(),
2865
2865
  http_url: _().optional(),
2866
2866
  txt_name: _().optional(),
2867
2867
  txt_value: _().optional()
2868
2868
  }), Yt = R({
2869
- ciphers: N(_()).optional(),
2869
+ ciphers: A(_()).optional(),
2870
2870
  early_hints: _().optional(),
2871
2871
  http2: _().optional(),
2872
2872
  min_tls_version: _().optional(),
@@ -2879,7 +2879,7 @@ const Bt = (t, e) => e.skipDedupe || e.method !== "GET", Ut = (t, e) => e.method
2879
2879
  custom_csr_id: _().optional(),
2880
2880
  custom_key: _().optional(),
2881
2881
  expires_on: _().optional(),
2882
- hosts: N(_()).optional(),
2882
+ hosts: A(_()).optional(),
2883
2883
  issuer: _().optional(),
2884
2884
  method: _(),
2885
2885
  serial_number: _().optional(),
@@ -2887,8 +2887,8 @@ const Bt = (t, e) => e.skipDedupe || e.method !== "GET", Ut = (t, e) => e.method
2887
2887
  signature: _().optional(),
2888
2888
  type: _(),
2889
2889
  uploaded_on: _().optional(),
2890
- validation_errors: N(Ht).optional(),
2891
- validation_records: N(Qt).optional(),
2890
+ validation_errors: A(Ht).optional(),
2891
+ validation_records: A(Qt).optional(),
2892
2892
  wildcard: ke()
2893
2893
  }), Gt = R({
2894
2894
  name: _(),
@@ -2907,19 +2907,19 @@ const Bt = (t, e) => e.skipDedupe || e.method !== "GET", Ut = (t, e) => e.method
2907
2907
  ownership_verification: Gt.optional(),
2908
2908
  ownership_verification_http: Xt.optional(),
2909
2909
  status: _(),
2910
- verification_errors: N(_()).optional(),
2910
+ verification_errors: A(_()).optional(),
2911
2911
  created_at: _()
2912
2912
  }), ie = R({
2913
- errors: N(ve),
2914
- messages: N(ve),
2913
+ errors: A(ve),
2914
+ messages: A(ve),
2915
2915
  success: ke(),
2916
2916
  result: ct
2917
2917
  });
2918
2918
  R({
2919
- errors: N(ve),
2920
- messages: N(ve),
2919
+ errors: A(ve),
2920
+ messages: A(ve),
2921
2921
  success: ke(),
2922
- result: N(ct)
2922
+ result: A(ct)
2923
2923
  });
2924
2924
  function H(t) {
2925
2925
  return pt(`https://api.cloudflare.com/client/v4/zones/${t.zoneId}`).headers({
@@ -2935,7 +2935,7 @@ function Qe(t) {
2935
2935
  s.startsWith("ssl.") ? e[s.slice(4)] = r : n[s] = r;
2936
2936
  return { sslOverrides: e, rest: n };
2937
2937
  }
2938
- function Ae(t) {
2938
+ function Ne(t) {
2939
2939
  const e = [];
2940
2940
  if (t.ssl.validation_records)
2941
2941
  for (const s of t.ssl.validation_records)
@@ -2972,7 +2972,7 @@ function Ae(t) {
2972
2972
  status: t.status === "active" ? "ready" : "pending",
2973
2973
  type: "auth0_managed_certs",
2974
2974
  verification: {
2975
- methods: N(ft).parse(e)
2975
+ methods: A(ft).parse(e)
2976
2976
  },
2977
2977
  domain_metadata: n
2978
2978
  };
@@ -3000,7 +3000,7 @@ function en(t) {
3000
3000
  );
3001
3001
  if (!o)
3002
3002
  throw new Error(JSON.stringify(i));
3003
- const c = Ae({
3003
+ const c = Ne({
3004
3004
  ...a,
3005
3005
  primary: !1,
3006
3006
  domain_metadata: r
@@ -3026,7 +3026,7 @@ function en(t) {
3026
3026
  });
3027
3027
  if (t.enterprise && a.custom_metadata?.tenant_id !== e)
3028
3028
  throw new X(404);
3029
- return Ae({ ...s, ...a });
3029
+ return Ne({ ...s, ...a });
3030
3030
  },
3031
3031
  getByDomain: async (e) => t.customDomainAdapter.getByDomain(e),
3032
3032
  list: async (e) => {
@@ -3037,7 +3037,7 @@ function en(t) {
3037
3037
  const a = await H(t).get(
3038
3038
  `/custom_hostnames/${encodeURIComponent(r.custom_domain_id)}`
3039
3039
  ).json(), { result: i, success: o } = ie.parse(a);
3040
- return !o || t.enterprise && i.custom_metadata?.tenant_id !== e ? null : Ae({
3040
+ return !o || t.enterprise && i.custom_metadata?.tenant_id !== e ? null : Ne({
3041
3041
  ...r,
3042
3042
  ...i
3043
3043
  });
@@ -3404,7 +3404,7 @@ function un(t) {
3404
3404
  };
3405
3405
  };
3406
3406
  }
3407
- function Cn() {
3407
+ function En() {
3408
3408
  return {
3409
3409
  async getDaily() {
3410
3410
  throw new Error(
@@ -3716,7 +3716,7 @@ function Ke(t) {
3716
3716
  function Ge(t) {
3717
3717
  return t.toISOString().split("T")[0];
3718
3718
  }
3719
- function Tn(t) {
3719
+ function On(t) {
3720
3720
  const e = t.dataset || "authhero_logs";
3721
3721
  return {
3722
3722
  async getDaily(n, s = {}) {
@@ -3798,7 +3798,33 @@ function xn() {
3798
3798
  }
3799
3799
  };
3800
3800
  }
3801
- function kn(t) {
3801
+ class kn {
3802
+ constructor(e) {
3803
+ this.bindings = e;
3804
+ }
3805
+ bindings;
3806
+ async consume(e, n) {
3807
+ const s = this.bindings[e];
3808
+ if (!s)
3809
+ return { allowed: !0 };
3810
+ try {
3811
+ const { success: r } = await s.limit({ key: n });
3812
+ return { allowed: r };
3813
+ } catch (r) {
3814
+ return console.error(
3815
+ `CloudflareRateLimit: limit() error for scope ${e}:`,
3816
+ r
3817
+ ), { allowed: !0 };
3818
+ }
3819
+ }
3820
+ }
3821
+ function wn(t) {
3822
+ if (!(!t || !Object.keys(t).some(
3823
+ (n) => t[n]
3824
+ )))
3825
+ return new kn(t);
3826
+ }
3827
+ function Sn(t) {
3802
3828
  return `// Auto-generated AuthHero code hook worker
3803
3829
 
3804
3830
  const fnNames = {
@@ -3904,7 +3930,7 @@ export default {
3904
3930
  };
3905
3931
  `;
3906
3932
  }
3907
- class En {
3933
+ class An {
3908
3934
  config;
3909
3935
  constructor(e) {
3910
3936
  this.config = e;
@@ -3979,7 +4005,7 @@ class En {
3979
4005
  * Wraps the code in a worker template and uploads via Cloudflare API.
3980
4006
  */
3981
4007
  async deploy(e, n) {
3982
- const s = `hook-${e}`, r = kn(n), a = `https://api.cloudflare.com/client/v4/accounts/${this.config.accountId}/workers/dispatch/namespaces/${this.config.dispatchNamespace}/scripts/${s}`, i = JSON.stringify({
4008
+ const s = `hook-${e}`, r = Sn(n), a = `https://api.cloudflare.com/client/v4/accounts/${this.config.accountId}/workers/dispatch/namespaces/${this.config.dispatchNamespace}/scripts/${s}`, i = JSON.stringify({
3983
4009
  main_module: "index.js",
3984
4010
  compatibility_date: this.config.compatibilityDate ?? "2024-11-20"
3985
4011
  }), o = new FormData();
@@ -4023,7 +4049,7 @@ class En {
4023
4049
  }
4024
4050
  }
4025
4051
  }
4026
- function On(t) {
4052
+ function Nn(t) {
4027
4053
  const e = {
4028
4054
  customDomains: en(t),
4029
4055
  // Always create a cache adapter (let createCloudflareCache apply defaults)
@@ -4038,16 +4064,19 @@ function On(t) {
4038
4064
  // passed at request time via getGeoInfo(headers)
4039
4065
  geo: xn()
4040
4066
  };
4041
- return t.r2SqlLogs ? e.logs = ln(t.r2SqlLogs) : t.analyticsEngineLogs && (e.logs = bn(
4067
+ t.r2SqlLogs ? e.logs = ln(t.r2SqlLogs) : t.analyticsEngineLogs && (e.logs = bn(
4042
4068
  t.analyticsEngineLogs
4043
- )), e;
4069
+ ));
4070
+ const n = wn(t.rateLimitBindings);
4071
+ return n && (e.rateLimit = n), e;
4044
4072
  }
4045
4073
  export {
4046
- En as CloudflareCodeExecutor,
4074
+ An as CloudflareCodeExecutor,
4047
4075
  bn as createAnalyticsEngineLogsAdapter,
4048
- Tn as createAnalyticsEngineStatsAdapter,
4076
+ On as createAnalyticsEngineStatsAdapter,
4077
+ wn as createCloudflareRateLimitAdapter,
4049
4078
  ln as createR2SQLLogsAdapter,
4050
- Cn as createR2SQLStatsAdapter,
4051
- On as default,
4052
- kn as generateWorkerScript
4079
+ En as createR2SQLStatsAdapter,
4080
+ Nn as default,
4081
+ Sn as generateWorkerScript
4053
4082
  };
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.25.9",
14
+ "version": "2.26.0",
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": "1.11.0",
50
- "@authhero/kysely-adapter": "10.132.0"
49
+ "@authhero/adapter-interfaces": "1.12.0",
50
+ "@authhero/kysely-adapter": "10.132.1"
51
51
  },
52
52
  "scripts": {
53
53
  "build": "tsc && vite build && dts-bundle-generator --config ./dts-bundle-generator.config.ts",